linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ernesto A. Fernández" <ernesto.mnd.fernandez@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: "Al Viro" <viro@zeniv.linux.org.uk>,
	"Andreas Gruenbacher" <agruenba@redhat.com>,
	"Hin-Tak Leung" <htl10@users.sourceforge.net>,
	"Vyacheslav Dubeyko" <slava@dubeyko.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Ernesto A. Fernández" <ernesto.mnd.fernandez@gmail.com>
Subject: [PATCH] hfsplus: return ENODATA when no xattr is found
Date: Thu, 19 Oct 2017 16:41:17 -0300	[thread overview]
Message-ID: <20171019194114.GA4045@debian.home> (raw)

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 --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;
-- 
2.1.4

             reply	other threads:[~2017-10-19 19:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 19:41 Ernesto A. Fernández [this message]
     [not found] <51697605.866452.1508445053840.ref@mail.yahoo.com>
2017-10-19 20:30 ` [PATCH] hfsplus: return ENODATA when no xattr is found Hin-Tak Leung
2017-10-19 23:02   ` Ernesto A. Fernández
2017-10-20  0:15     ` Viacheslav Dubeyko
2017-10-20  0:54       ` Ernesto A. Fernández

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171019194114.GA4045@debian.home \
    --to=ernesto.mnd.fernandez@gmail.com \
    --cc=agruenba@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=htl10@users.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=slava@dubeyko.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).