Skip to content

Commit 54aae14

Browse files
eaferAstralBob
authored andcommitted
gfs2: don't return ENODATA in __gfs2_xattr_set unless replacing
The function __gfs2_xattr_set() will return -ENODATA when called to remove a xattr that does not exist. The result is that setfacl will show an exit status of 1 when called to set only a file's mode bits (on a file with no ACLs), despite succeeding. A "No data available" error will be printed as well. To fix this return 0 instead, except when the XATTR_REPLACE flag is set, in which case -ENODATA is appropriate. This is consistent with how most other xattr setting functions work, in other filesystems. Signed-off-by: Ernesto A. Fernández <[email protected]> Signed-off-by: Bob Peterson <[email protected]>
1 parent c4a9d18 commit 54aae14

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/gfs2/xattr.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,12 @@ int __gfs2_xattr_set(struct inode *inode, const char *name,
12101210
if (namel > GFS2_EA_MAX_NAME_LEN)
12111211
return -ERANGE;
12121212

1213-
if (value == NULL)
1214-
return gfs2_xattr_remove(ip, type, name);
1213+
if (value == NULL) {
1214+
error = gfs2_xattr_remove(ip, type, name);
1215+
if (error == -ENODATA && !(flags & XATTR_REPLACE))
1216+
error = 0;
1217+
return error;
1218+
}
12151219

12161220
if (ea_check_size(sdp, namel, size))
12171221
return -ERANGE;

0 commit comments

Comments
 (0)