From: Andrey Albershteyn Date: Tue, 9 Sep 2025 15:24:39 +0000 (+0200) Subject: xfs_db: use file_setattr to copy attributes on special files with rdump X-Git-Tag: v6.17.0~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=128ac4dadbd633a7c66a4983c94f4f7f379dfc89;p=thirdparty%2Fxfsprogs-dev.git xfs_db: use file_setattr to copy attributes on special files with rdump 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 Signed-off-by: Andrey Albershteyn --- diff --git a/db/rdump.c b/db/rdump.c index 9ff83355..82520e37 100644 --- a/db/rdump.c +++ b/db/rdump.c @@ -17,6 +17,7 @@ #include "field.h" #include "inode.h" #include "listxattr.h" +#include "libfrog/file_attr.h" #include #include @@ -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; }