]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_db: actually report errors from libxfs_attr_set
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:23:25 +0000 (16:23 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:12 +0000 (17:01 -0700)
Actually tell the user what went wrong when setting or removing xattrs.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
db/attrset.c

index 0086625713236e78bde565c9e996e56fc9542b79..81d530055193ce9523fe2b520b785cf582430e01 100644 (file)
@@ -121,6 +121,7 @@ attr_set_f(
        char                    *value_from_file = NULL;
        enum xfs_attr_update    op = XFS_ATTRUPDATE_UPSERT;
        int                     c;
+       int                     error;
 
        if (cur_typ == NULL) {
                dbprintf(_("no current type\n"));
@@ -260,9 +261,11 @@ attr_set_f(
        args.owner = iocur_top->ino;
        libxfs_attr_sethash(&args);
 
-       if (libxfs_attr_set(&args, op, false)) {
-               dbprintf(_("failed to set attr %s on inode %llu\n"),
-                       args.name, (unsigned long long)iocur_top->ino);
+       error = -libxfs_attr_set(&args, op, false);
+       if (error) {
+               dbprintf(_("failed to set attr %s on inode %llu: %s\n"),
+                       args.name, (unsigned long long)iocur_top->ino,
+                       strerror(error));
                goto out;
        }
 
@@ -291,6 +294,7 @@ attr_remove_f(
        };
        char                    *name_from_file = NULL;
        int                     c;
+       int                     error;
 
        if (cur_typ == NULL) {
                dbprintf(_("no current type\n"));
@@ -379,10 +383,12 @@ attr_remove_f(
        args.owner = iocur_top->ino;
        libxfs_attr_sethash(&args);
 
-       if (libxfs_attr_set(&args, XFS_ATTRUPDATE_REMOVE, false)) {
-               dbprintf(_("failed to remove attr %s from inode %llu\n"),
+       error = -libxfs_attr_set(&args, XFS_ATTRUPDATE_REMOVE, false);
+       if (error) {
+               dbprintf(_("failed to remove attr %s from inode %llu: %s\n"),
                        (unsigned char *)args.name,
-                       (unsigned long long)iocur_top->ino);
+                       (unsigned long long)iocur_top->ino,
+                       strerror(error));
                goto out;
        }