Whamcloud - gitweb
fuse2fs: fix return value handling
authorDarrick J. Wong <djwong@kernel.org>
Wed, 21 May 2025 22:41:11 +0000 (15:41 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 23 May 2025 13:41:20 +0000 (09:41 -0400)
For the xattr functions, don't obliterate the return value of the file
system operation with an error code coming from ext2fs_xattrs_close
failing.  Granted, it doesn't ever fail (right now!) so this is mostly
just preening.

Also fix the obsolete op_truncate not to squash error returns.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677978.1383760.8801097477278077188.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/fuse2fs.c

index 9bfddb8..e8417d1 100644 (file)
@@ -2560,7 +2560,7 @@ static int op_getxattr(const char *path, const char *key, char *value,
        ext2fs_free_mem(&ptr);
 out2:
        err = ext2fs_xattrs_close(&h);
-       if (err)
+       if (err && !ret)
                ret = translate_error(fs, ino, err);
 out:
        pthread_mutex_unlock(&ff->bfl);
@@ -2658,7 +2658,7 @@ static int op_listxattr(const char *path, char *names, size_t len)
        ret = bufsz;
 out2:
        err = ext2fs_xattrs_close(&h);
-       if (err)
+       if (err && !ret)
                ret = translate_error(fs, ino, err);
 out:
        pthread_mutex_unlock(&ff->bfl);
@@ -2848,7 +2848,7 @@ static int op_removexattr(const char *path, const char *key)
        ret = update_ctime(fs, ino, NULL);
 out2:
        err = ext2fs_xattrs_close(&h);
-       if (err)
+       if (err && !ret)
                ret = translate_error(fs, ino, err);
 out:
        pthread_mutex_unlock(&ff->bfl);
@@ -3161,7 +3161,7 @@ out2:
 
 out:
        pthread_mutex_unlock(&ff->bfl);
-       return 0;
+       return ret;
 }
 
 static int op_fgetattr(const char *path EXT2FS_ATTR((unused)),