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, |
Al Viro | b296821 | 2016-04-10 20:48:24 -0400 | [diff] [blame] | 21 | struct dentry *unused, struct inode *inode, |
| 22 | const char *name, void *buffer, size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
Al Viro | b296821 | 2016-04-10 20:48:24 -0400 | [diff] [blame] | 24 | if (!test_opt(inode->i_sb, XATTR_USER)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | return -EOPNOTSUPP; |
Al Viro | b296821 | 2016-04-10 20:48:24 -0400 | [diff] [blame] | 26 | return ext2_xattr_get(inode, 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, |
Al Viro | 5930122 | 2016-05-27 10:19:30 -0400 | [diff] [blame] | 32 | struct dentry *unused, struct inode *inode, |
| 33 | const char *name, const void *value, |
| 34 | size_t size, int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | { |
Al Viro | 5930122 | 2016-05-27 10:19:30 -0400 | [diff] [blame] | 36 | if (!test_opt(inode->i_sb, XATTR_USER)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | return -EOPNOTSUPP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Al Viro | 5930122 | 2016-05-27 10:19:30 -0400 | [diff] [blame] | 39 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 40 | name, value, size, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | } |
| 42 | |
Stephen Hemminger | 749c72ef | 2010-05-13 17:53:16 -0700 | [diff] [blame] | 43 | const struct xattr_handler ext2_xattr_user_handler = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | .prefix = XATTR_USER_PREFIX, |
| 45 | .list = ext2_xattr_user_list, |
| 46 | .get = ext2_xattr_user_get, |
| 47 | .set = ext2_xattr_user_set, |
| 48 | }; |