diff options
author | Christoph Hellwig <hch@lst.de> | 2009-11-13 04:52:56 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-16 12:16:49 -0500 |
commit | 431547b3c4533b8c7fd150ab36980b9a3147797b (patch) | |
tree | 807ff2790f3c13c7c91ed2afd6d833032899482d /fs/ext3/xattr.c | |
parent | ef26ca97e83052790940cbc444b01b0d17a813c1 (diff) |
sanitize xattr handler prototypes
Add a flags argument to struct xattr_handler and pass it to all xattr
handler methods. This allows using the same methods for multiple
handlers, e.g. for the ACL methods which perform exactly the same action
for the access and default ACLs, just using a different underlying
attribute. With a little more groundwork it'll also allow sharing the
methods for the regular user/trusted/secure handlers in extN, ocfs2 and
jffs2 like it's already done for xfs in this patch.
Also change the inode argument to the handlers to a dentry to allow
using the handlers mechnism for filesystems that require it later,
e.g. cifs.
[with GFS2 bits updated by Steven Whitehouse <swhiteho@redhat.com>]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: James Morris <jmorris@namei.org>
Acked-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ext3/xattr.c')
-rw-r--r-- | fs/ext3/xattr.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c index 387d92d00b97..66895ccf76c7 100644 --- a/fs/ext3/xattr.c +++ b/fs/ext3/xattr.c | |||
@@ -99,7 +99,7 @@ static struct buffer_head *ext3_xattr_cache_find(struct inode *, | |||
99 | struct mb_cache_entry **); | 99 | struct mb_cache_entry **); |
100 | static void ext3_xattr_rehash(struct ext3_xattr_header *, | 100 | static void ext3_xattr_rehash(struct ext3_xattr_header *, |
101 | struct ext3_xattr_entry *); | 101 | struct ext3_xattr_entry *); |
102 | static int ext3_xattr_list(struct inode *inode, char *buffer, | 102 | static int ext3_xattr_list(struct dentry *dentry, char *buffer, |
103 | size_t buffer_size); | 103 | size_t buffer_size); |
104 | 104 | ||
105 | static struct mb_cache *ext3_xattr_cache; | 105 | static struct mb_cache *ext3_xattr_cache; |
@@ -147,7 +147,7 @@ ext3_xattr_handler(int name_index) | |||
147 | ssize_t | 147 | ssize_t |
148 | ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) | 148 | ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) |
149 | { | 149 | { |
150 | return ext3_xattr_list(dentry->d_inode, buffer, size); | 150 | return ext3_xattr_list(dentry, buffer, size); |
151 | } | 151 | } |
152 | 152 | ||
153 | static int | 153 | static int |
@@ -332,7 +332,7 @@ ext3_xattr_get(struct inode *inode, int name_index, const char *name, | |||
332 | } | 332 | } |
333 | 333 | ||
334 | static int | 334 | static int |
335 | ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | 335 | ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry, |
336 | char *buffer, size_t buffer_size) | 336 | char *buffer, size_t buffer_size) |
337 | { | 337 | { |
338 | size_t rest = buffer_size; | 338 | size_t rest = buffer_size; |
@@ -342,9 +342,10 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | |||
342 | ext3_xattr_handler(entry->e_name_index); | 342 | ext3_xattr_handler(entry->e_name_index); |
343 | 343 | ||
344 | if (handler) { | 344 | if (handler) { |
345 | size_t size = handler->list(inode, buffer, rest, | 345 | size_t size = handler->list(dentry, buffer, rest, |
346 | entry->e_name, | 346 | entry->e_name, |
347 | entry->e_name_len); | 347 | entry->e_name_len, |
348 | handler->flags); | ||
348 | if (buffer) { | 349 | if (buffer) { |
349 | if (size > rest) | 350 | if (size > rest) |
350 | return -ERANGE; | 351 | return -ERANGE; |
@@ -357,8 +358,9 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | |||
357 | } | 358 | } |
358 | 359 | ||
359 | static int | 360 | static int |
360 | ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | 361 | ext3_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
361 | { | 362 | { |
363 | struct inode *inode = dentry->d_inode; | ||
362 | struct buffer_head *bh = NULL; | 364 | struct buffer_head *bh = NULL; |
363 | int error; | 365 | int error; |
364 | 366 | ||
@@ -383,7 +385,7 @@ ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
383 | goto cleanup; | 385 | goto cleanup; |
384 | } | 386 | } |
385 | ext3_xattr_cache_insert(bh); | 387 | ext3_xattr_cache_insert(bh); |
386 | error = ext3_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size); | 388 | error = ext3_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); |
387 | 389 | ||
388 | cleanup: | 390 | cleanup: |
389 | brelse(bh); | 391 | brelse(bh); |
@@ -392,8 +394,9 @@ cleanup: | |||
392 | } | 394 | } |
393 | 395 | ||
394 | static int | 396 | static int |
395 | ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | 397 | ext3_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
396 | { | 398 | { |
399 | struct inode *inode = dentry->d_inode; | ||
397 | struct ext3_xattr_ibody_header *header; | 400 | struct ext3_xattr_ibody_header *header; |
398 | struct ext3_inode *raw_inode; | 401 | struct ext3_inode *raw_inode; |
399 | struct ext3_iloc iloc; | 402 | struct ext3_iloc iloc; |
@@ -411,7 +414,7 @@ ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
411 | error = ext3_xattr_check_names(IFIRST(header), end); | 414 | error = ext3_xattr_check_names(IFIRST(header), end); |
412 | if (error) | 415 | if (error) |
413 | goto cleanup; | 416 | goto cleanup; |
414 | error = ext3_xattr_list_entries(inode, IFIRST(header), | 417 | error = ext3_xattr_list_entries(dentry, IFIRST(header), |
415 | buffer, buffer_size); | 418 | buffer, buffer_size); |
416 | 419 | ||
417 | cleanup: | 420 | cleanup: |
@@ -430,12 +433,12 @@ cleanup: | |||
430 | * used / required on success. | 433 | * used / required on success. |
431 | */ | 434 | */ |
432 | static int | 435 | static int |
433 | ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | 436 | ext3_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
434 | { | 437 | { |
435 | int i_error, b_error; | 438 | int i_error, b_error; |
436 | 439 | ||
437 | down_read(&EXT3_I(inode)->xattr_sem); | 440 | down_read(&EXT3_I(dentry->d_inode)->xattr_sem); |
438 | i_error = ext3_xattr_ibody_list(inode, buffer, buffer_size); | 441 | i_error = ext3_xattr_ibody_list(dentry, buffer, buffer_size); |
439 | if (i_error < 0) { | 442 | if (i_error < 0) { |
440 | b_error = 0; | 443 | b_error = 0; |
441 | } else { | 444 | } else { |
@@ -443,11 +446,11 @@ ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
443 | buffer += i_error; | 446 | buffer += i_error; |
444 | buffer_size -= i_error; | 447 | buffer_size -= i_error; |
445 | } | 448 | } |
446 | b_error = ext3_xattr_block_list(inode, buffer, buffer_size); | 449 | b_error = ext3_xattr_block_list(dentry, buffer, buffer_size); |
447 | if (b_error < 0) | 450 | if (b_error < 0) |
448 | i_error = 0; | 451 | i_error = 0; |
449 | } | 452 | } |
450 | up_read(&EXT3_I(inode)->xattr_sem); | 453 | up_read(&EXT3_I(dentry->d_inode)->xattr_sem); |
451 | return i_error + b_error; | 454 | return i_error + b_error; |
452 | } | 455 | } |
453 | 456 | ||