diff mbox

hfsplus: return ENODATA when no xattr is found

Message ID 20171019194114.GA4045@debian.home (mailing list archive)
State New, archived
Headers show

Commit Message

Ernesto A. Fernández Oct. 19, 2017, 7:41 p.m. UTC
There are several points in the code where ENOENT or EOPNOTSUPP are
used to signal that an extended attribute does not exist. This is
clearly noticeable from the odd error messages shown by setfattr and
getfattr. Use ENODATA instead.

Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
---
 fs/hfsplus/attributes.c | 6 ++++--
 fs/hfsplus/xattr.c      | 6 +++---
 2 files changed, 7 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c
index e5b221d..77b0d40 100644
--- a/fs/hfsplus/attributes.c
+++ b/fs/hfsplus/attributes.c
@@ -268,7 +268,7 @@  static int __hfsplus_delete_attr(struct inode *inode, u32 cnid,
 			offsetof(struct hfsplus_attr_key, cnid),
 			sizeof(__be32));
 	if (cnid != be32_to_cpu(found_cnid))
-		return -ENOENT;
+		return -ENODATA;
 
 	hfs_bnode_read(fd->bnode, &record_type,
 			fd->entryoffset, sizeof(record_type));
@@ -283,7 +283,7 @@  static int __hfsplus_delete_attr(struct inode *inode, u32 cnid,
 		return -EOPNOTSUPP;
 	default:
 		pr_err("invalid extended attribute record\n");
-		return -ENOENT;
+		return -ENODATA;
 	}
 
 	err = hfs_brec_remove(fd);
@@ -324,6 +324,8 @@  int hfsplus_delete_attr(struct inode *inode, const char *name)
 	}
 
 	err = hfs_brec_find(&fd, hfs_find_rec_by_key);
+	if (err == -ENOENT)
+		err = -ENODATA;
 	if (err)
 		goto out;
 
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index d37bb88..814082c 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -511,7 +511,7 @@  ssize_t __hfsplus_getxattr(struct inode *inode, const char *name,
 		return hfsplus_getxattr_finder_info(inode, value, size);
 
 	if (!HFSPLUS_SB(inode->i_sb)->attr_tree)
-		return -EOPNOTSUPP;
+		return -ENODATA;
 
 	entry = hfsplus_alloc_attr_entry();
 	if (!entry) {
@@ -697,7 +697,7 @@  ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)
 	if (res < 0)
 		return res;
 	else if (!HFSPLUS_SB(inode->i_sb)->attr_tree)
-		return (res == 0) ? -EOPNOTSUPP : res;
+		return (res == 0) ? -ENODATA : res;
 
 	err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->attr_tree, &fd);
 	if (err) {
@@ -780,7 +780,7 @@  static int hfsplus_removexattr(struct inode *inode, const char *name)
 	int is_all_xattrs_deleted = 0;
 
 	if (!HFSPLUS_SB(inode->i_sb)->attr_tree)
-		return -EOPNOTSUPP;
+		return -ENODATA;
 
 	if (!strcmp_xattr_finder_info(name))
 		return -EOPNOTSUPP;