]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: use file_setattr to copy attributes on special files with rdump
authorAndrey Albershteyn <aalbersh@redhat.com>
Tue, 9 Sep 2025 15:24:39 +0000 (17:24 +0200)
committerAndrey Albershteyn <aalbersh@kernel.org>
Mon, 15 Sep 2025 09:10:05 +0000 (11:10 +0200)
rdump just skipped file attributes on special files as copying wasn't
possible. Let's use new file_getattr/file_setattr syscalls to copy
attributes even for special files.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
db/rdump.c

index 9ff833553ccbfbddd0b0eeee3deb2123c254b7a3..82520e37d713e58bf8b0ff19d093e59ecf5026f1 100644 (file)
@@ -17,6 +17,7 @@
 #include "field.h"
 #include "inode.h"
 #include "listxattr.h"
+#include "libfrog/file_attr.h"
 #include <sys/xattr.h>
 #include <linux/xattr.h>
 
@@ -152,6 +153,12 @@ rdump_fileattrs_path(
        const struct destdir    *destdir,
        const struct pathbuf    *pbuf)
 {
+       struct file_attr        fa = {
+               .fa_extsize     = ip->i_extsize,
+               .fa_projid      = ip->i_projid,
+               .fa_cowextsize  = ip->i_cowextsize,
+               .fa_xflags      = xfs_ip2xflags(ip),
+       };
        int                     ret;
 
        ret = fchmodat(destdir->fd, pbuf->path, VFS_I(ip)->i_mode & ~S_IFMT,
@@ -181,7 +188,18 @@ rdump_fileattrs_path(
                        return 1;
        }
 
-       /* Cannot copy fsxattrs until setfsxattrat gets merged */
+       ret = xfrog_file_setattr(destdir->fd, pbuf->path, NULL, &fa,
+                       AT_SYMLINK_NOFOLLOW);
+       if (ret) {
+               if (errno == EOPNOTSUPP || errno == EPERM || errno == ENOTTY)
+                       lost_mask |= LOST_FSXATTR;
+               else
+                       dbprintf(_("%s%s%s: xfrog_file_setattr %s\n"),
+                                       destdir->path, destdir->sep, pbuf->path,
+                                       strerror(errno));
+               if (strict_errors)
+                       return 1;
+       }
 
        return 0;
 }