aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xattr.c
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2006-10-09 16:10:48 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-09 17:20:38 -0400
commit659564c8adfe1765476beee8d55cd18986946892 (patch)
tree8ddef1e06257449b4ca6ca83fc80867771a6f5a4 /fs/xattr.c
parente069d79d23739977800c3b8495853b735f77ef30 (diff)
[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>
Diffstat (limited to 'fs/xattr.c')
-rw-r--r--fs/xattr.c33
1 files changed, 21 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)
135} 135}
136EXPORT_SYMBOL_GPL(vfs_getxattr); 136EXPORT_SYMBOL_GPL(vfs_getxattr);
137 137
138ssize_t
139vfs_listxattr(struct dentry *d, char *list, size_t size)
140{
141 ssize_t error;
142
143 error = security_inode_listxattr(d);
144 if (error)
145 return error;
146 error = -EOPNOTSUPP;
147 if (d->d_inode->i_op && d->d_inode->i_op->listxattr) {
148 error = d->d_inode->i_op->listxattr(d, list, size);
149 } else {
150 error = security_inode_listsecurity(d->d_inode, list, size);
151 if (size && error > size)
152 error = -ERANGE;
153 }
154 return error;
155}
156EXPORT_SYMBOL_GPL(vfs_listxattr);
157
138int 158int
139vfs_removexattr(struct dentry *dentry, char *name) 159vfs_removexattr(struct dentry *dentry, char *name)
140{ 160{
@@ -346,17 +366,7 @@ listxattr(struct dentry *d, char __user *list, size_t size)
346 return -ENOMEM; 366 return -ENOMEM;
347 } 367 }
348 368
349 error = security_inode_listxattr(d); 369 error = vfs_listxattr(d, klist, size);
350 if (error)
351 goto out;
352 error = -EOPNOTSUPP;
353 if (d->d_inode->i_op && d->d_inode->i_op->listxattr) {
354 error = d->d_inode->i_op->listxattr(d, klist, size);
355 } else {
356 error = security_inode_listsecurity(d->d_inode, klist, size);
357 if (size && error > size)
358 error = -ERANGE;
359 }
360 if (error > 0) { 370 if (error > 0) {
361 if (size && copy_to_user(list, klist, error)) 371 if (size && copy_to_user(list, klist, error))
362 error = -EFAULT; 372 error = -EFAULT;
@@ -365,7 +375,6 @@ listxattr(struct dentry *d, char __user *list, size_t size)
365 than XATTR_LIST_MAX bytes. Not possible. */ 375 than XATTR_LIST_MAX bytes. Not possible. */
366 error = -E2BIG; 376 error = -E2BIG;
367 } 377 }
368out:
369 kfree(klist); 378 kfree(klist);
370 return error; 379 return error;
371} 380}