* [PATCH] ext2: return -ENODATA for NULL i_file_acl in ext2_xattr_list
@ 2010-07-13 15:15 Wang Sheng-Hui
0 siblings, 0 replies; 4+ messages in thread
From: Wang Sheng-Hui @ 2010-07-13 15:15 UTC (permalink / raw)
To: kernel-janitors, linux-ext4, linux-kernel
Sorry, I noticed the format is changed by my client
in the former patch. Please check this one.
Signed-off-by: Wang Sheng-Hui <crosslonelyover@gmail.com>
---
fs/ext2/xattr.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 7c39157..5ecbbd8 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -263,7 +263,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
buffer, (long)buffer_size);
down_read(&EXT2_I(inode)->xattr_sem);
- error = 0;
+ error = -ENODATA;
if (!EXT2_I(inode)->i_file_acl)
goto cleanup;
ea_idebug(inode, "reading block %d", EXT2_I(inode)->i_file_acl);
--
1.7.1.1
--------------
Wang Sheng-Hui
2010-07-13
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ext2: return -ENODATA for NULL i_file_acl in ext2_xattr_list
@ 2010-07-13 14:55 Wang Sheng-Hui
2010-07-13 18:36 ` Andreas Dilger
0 siblings, 1 reply; 4+ messages in thread
From: Wang Sheng-Hui @ 2010-07-13 14:55 UTC (permalink / raw)
To: kernel-janitors, linux-ext4, linux-kernel
Hi,
In ext2_xattr_list, if (!EXT2_I(inode)->i_file_acl)
is true, we should return -ENODATA instead of 0.
Following patch is against 2.6.35-rc5. Please check
it.
Signed-off-by: Wang Sheng-Hui <crosslonelyover@gmail.com>
---
fs/ext2/xattr.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 7c39157..5ecbbd8 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -263,7 +263,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer,
size_t buffer_size)
buffer, (long)buffer_size);
down_read(&EXT2_I(inode)->xattr_sem);
- error = 0;
+ error = -ENODATA;
if (!EXT2_I(inode)->i_file_acl)
goto cleanup;
ea_idebug(inode, "reading block %d", EXT2_I(inode)->i_file_acl);
--
1.7.1.1
--
Thanks and Regards,
shenghui
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ext2: return -ENODATA for NULL i_file_acl in ext2_xattr_list
2010-07-13 14:55 Wang Sheng-Hui
@ 2010-07-13 18:36 ` Andreas Dilger
2010-07-13 23:47 ` shenghui
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Dilger @ 2010-07-13 18:36 UTC (permalink / raw)
To: Wang Sheng-Hui; +Cc: kernel-janitors, linux-ext4, linux-kernel
On 2010-07-13, at 08:55, Wang Sheng-Hui wrote:
> In ext2_xattr_list, if (!EXT2_I(inode)->i_file_acl)
> is true, we should return -ENODATA instead of 0.
>
> @@ -263,7 +263,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer,
> size_t buffer_size)
>
> down_read(&EXT2_I(inode)->xattr_sem);
> - error = 0;
> + error = -ENODATA;
> if (!EXT2_I(inode)->i_file_acl)
> goto cleanup;
> ea_idebug(inode, "reading block %d", EXT2_I(inode)->i_file_acl);
The "error" value gets overwritten almost immediately with -EIO, and then at the end of the function if there is an xattr block but it doesn't contain any attributes (I'm not sure if this could happen, but it seems possible) it will return "error = buffer_size - rest; /* total size */", so 0 if "rest" was not changed from its initial value of buffer_size.
The question is why this return value should be changed to -ENODATA in the first place? This isn't true for ext3_xattr_list() or ext4_xattr_list(). I tend to think it is not an error to get back an empty list, and applications shouldn't treat it as such. Most applications will check "if (rc < 0)" and treat it as an error. This is different than e.g. requesting a specific value by name (which does return -ENODATA) because it would otherwise be ambiguous whether the xattr existed but had zero size or didn't exist at all.
Cheers, Andreas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ext2: return -ENODATA for NULL i_file_acl in ext2_xattr_list
2010-07-13 18:36 ` Andreas Dilger
@ 2010-07-13 23:47 ` shenghui
0 siblings, 0 replies; 4+ messages in thread
From: shenghui @ 2010-07-13 23:47 UTC (permalink / raw)
To: Andreas Dilger; +Cc: kernel-janitors, linux-ext4, linux-kernel
2010/7/14 Andreas Dilger <adilger@dilger.ca>:
> The "error" value gets overwritten almost immediately with -EIO, and then at the end of the function if there is an xattr block but it doesn't contain any attributes (I'm not sure if this could happen, but it seems possible) it will return "error = buffer_size - rest; /* total size */", so 0 if "rest" was not changed from its initial value of buffer_size.
>
> The question is why this return value should be changed to -ENODATA in the first place? This isn't true for ext3_xattr_list() or ext4_xattr_list(). I tend to think it is not an error to get back an empty list, and applications shouldn't treat it as such. Most applications will check "if (rc < 0)" and treat it as an error. This is different than e.g. requesting a specific value by name (which does return -ENODATA) because it would otherwise be ambiguous whether the xattr existed but had zero size or didn't exist at all.
>
Thanks for your explanation!
--
Thanks and Best Regards,
shenghui
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-07-13 23:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-13 15:15 [PATCH] ext2: return -ENODATA for NULL i_file_acl in ext2_xattr_list Wang Sheng-Hui
-- strict thread matches above, loose matches on Subject: below --
2010-07-13 14:55 Wang Sheng-Hui
2010-07-13 18:36 ` Andreas Dilger
2010-07-13 23:47 ` shenghui
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).