diff options
author | Bill Nottingham | 2006-10-09 22:10:48 +0200 |
---|---|---|
committer | Linus Torvalds | 2006-10-09 23:20:38 +0200 |
commit | 659564c8adfe1765476beee8d55cd18986946892 (patch) | |
tree | 8ddef1e06257449b4ca6ca83fc80867771a6f5a4 | |
parent | [PATCH] tifm __iomem annotations, NULL noise removal (diff) | |
download | kernel-qcow2-linux-659564c8adfe1765476beee8d55cd18986946892.tar.gz kernel-qcow2-linux-659564c8adfe1765476beee8d55cd18986946892.tar.xz kernel-qcow2-linux-659564c8adfe1765476beee8d55cd18986946892.zip |
[PATCH] Introduce vfs_listxattr
This patch moves code out of fs/xattr.c:listxattr into a new function -
vfs_listxattr. The code for vfs_listxattr was originally submitted by Bill
Nottingham <notting@redhat.com> to Unionfs.
Sorry about that. The reason for this submission is to make the
listxattr code in fs/xattr.c a little cleaner (as well as to clean up
some code in Unionfs.)
Currently, Unionfs has vfs_listxattr defined in its code. I think
that's very ugly, and I'd like to see it (re)moved. The logical place
to put it, is along side of all the other vfs_*xattr functions.
Overall, I think this patch is benefitial for both kernel.org kernel and
Unionfs.
Signed-off-by: Josef "Jeff" Sipek <jsipek@cs.sunysb.edu>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/xattr.c | 33 | ||||
-rw-r--r-- | include/linux/xattr.h | 1 |
2 files changed, 22 insertions, 12 deletions
diff --git a/fs/xattr.c b/fs/xattr.c index c32f15b5f60f..395635100f77 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -135,6 +135,26 @@ vfs_getxattr(struct dentry *dentry, char *name, void *value, size_t size) } EXPORT_SYMBOL_GPL(vfs_getxattr); +ssize_t +vfs_listxattr(struct dentry *d, char *list, size_t size) +{ + ssize_t error; + + error = security_inode_listxattr(d); + if (error) + return error; + error = -EOPNOTSUPP; + if (d->d_inode->i_op && d->d_inode->i_op->listxattr) { + error = d->d_inode->i_op->listxattr(d, list, size); + } else { + error = security_inode_listsecurity(d->d_inode, list, size); + if (size && error > size) + error = -ERANGE; + } + return error; +} +EXPORT_SYMBOL_GPL(vfs_listxattr); + int vfs_removexattr(struct dentry *dentry, char *name) { @@ -346,17 +366,7 @@ listxattr(struct dentry *d, char __user *list, size_t size) return -ENOMEM; } - error = security_inode_listxattr(d); - if (error) - goto out; - error = -EOPNOTSUPP; - if (d->d_inode->i_op && d->d_inode->i_op->listxattr) { - error = d->d_inode->i_op->listxattr(d, klist, size); - } else { - error = security_inode_listsecurity(d->d_inode, klist, size); - if (size && error > size) - error = -ERANGE; - } + error = vfs_listxattr(d, klist, size); if (error > 0) { if (size && copy_to_user(list, klist, error)) error = -EFAULT; @@ -365,7 +375,6 @@ listxattr(struct dentry *d, char __user *list, size_t size) than XATTR_LIST_MAX bytes. Not possible. */ error = -E2BIG; } -out: kfree(klist); return error; } diff --git a/include/linux/xattr.h b/include/linux/xattr.h index cda8a96e2fa0..0e7f1e20ea45 100644 --- a/include/linux/xattr.h +++ b/include/linux/xattr.h @@ -41,6 +41,7 @@ struct xattr_handler { }; ssize_t vfs_getxattr(struct dentry *, char *, void *, size_t); +ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size); int vfs_setxattr(struct dentry *, char *, void *, size_t, int); int vfs_removexattr(struct dentry *, char *); |