From 128ac4dadbd633a7c66a4983c94f4f7f379dfc89 Mon Sep 17 00:00:00 2001 From: Andrey Albershteyn Date: Tue, 9 Sep 2025 17:24:39 +0200 Subject: [PATCH] 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 --- db/rdump.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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; } -- 2.47.3