Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/ext2/xattr_user.c |
| 3 | * Handler for extended user attributes. |
| 4 | * |
| 5 | * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org> |
| 6 | */ |
| 7 | |
| 8 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/string.h> |
| 10 | #include "ext2.h" |
| 11 | #include "xattr.h" |
| 12 | |
Andreas Gruenbacher | 764a5c6 | 2015-12-02 14:44:43 +0100 | [diff] [blame] | 13 | static bool |
| 14 | ext2_xattr_user_list(struct dentry *dentry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | { |
Andreas Gruenbacher | 764a5c6 | 2015-12-02 14:44:43 +0100 | [diff] [blame] | 16 | return test_opt(dentry->d_sb, XATTR_USER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | static int |
Andreas Gruenbacher | d9a82a0 | 2015-10-04 19:18:51 +0200 | [diff] [blame] | 20 | ext2_xattr_user_get(const struct xattr_handler *handler, |
| 21 | struct dentry *dentry, const char *name, |
| 22 | void *buffer, size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 24 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | return -EOPNOTSUPP; |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 26 | return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_USER, |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 27 | name, buffer, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | static int |
Andreas Gruenbacher | d9a82a0 | 2015-10-04 19:18:51 +0200 | [diff] [blame] | 31 | ext2_xattr_user_set(const struct xattr_handler *handler, |
| 32 | struct dentry *dentry, const char *name, |
| 33 | const void *value, size_t size, int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | { |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 35 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | return -EOPNOTSUPP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 38 | return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_USER, |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 39 | name, value, size, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Stephen Hemminger | 749c72ef | 2010-05-13 17:53:16 -0700 | [diff] [blame] | 42 | const struct xattr_handler ext2_xattr_user_handler = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | .prefix = XATTR_USER_PREFIX, |
| 44 | .list = ext2_xattr_user_list, |
| 45 | .get = ext2_xattr_user_get, |
| 46 | .set = ext2_xattr_user_set, |
| 47 | }; |