-#if SUPPORT_LINKS
- if (!kept && preserve_links && S_ISLNK(file->mode)) {
- extern int safe_symlinks;
- if (safe_symlinks && unsafe_symlink(file->u.link, backup_dir_buf)) {
- if (verbose) {
- rprintf(FINFO, "ignoring unsafe symlink %s -> %s\n",
- full_fname(backup_dir_buf), file->u.link);
+ /* Fall back to making a copy. */
+ if (!(file = make_file(fname, NULL, &sx.st, 0, NO_FILTERS)))
+ return 1; /* the file could have disappeared */
+
+#ifdef SUPPORT_ACLS
+ if (preserve_acls && !S_ISLNK(file->mode)) {
+ get_acl(fname, &sx);
+ cache_tmp_acl(file, &sx);
+ free_acl(&sx);
+ }
+#endif
+#ifdef SUPPORT_XATTRS
+ if (preserve_xattrs) {
+ get_xattr(fname, &sx);
+ cache_tmp_xattr(file, &sx);
+ free_xattr(&sx);
+ }
+#endif
+
+ /* Check to see if this is a device file, or link */
+ if ((am_root && preserve_devices && IS_DEVICE(file->mode))
+ || (preserve_specials && IS_SPECIAL(file->mode))) {
+ if (do_mknod(buf, file->mode, sx.st.st_rdev) < 0)
+ rsyserr(FERROR, errno, "mknod %s failed", full_fname(buf));
+ else if (DEBUG_GTE(BACKUP, 1))
+ rprintf(FINFO, "make_backup: DEVICE %s successful.\n", fname);
+ ret = 2;
+ }
+
+#ifdef SUPPORT_LINKS
+ if (!ret && preserve_links && S_ISLNK(file->mode)) {
+ const char *sl = F_SYMLINK(file);
+ if (safe_symlinks && unsafe_symlink(sl, fname)) {
+ if (INFO_GTE(SYMSAFE, 1)) {
+ rprintf(FINFO, "not backing up unsafe symlink \"%s\" -> \"%s\"\n",
+ fname, sl);