blob: fb2f992ae763a59c3081713d6d95c93c035d83f9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/string.h>
10#include "ext2.h"
11#include "xattr.h"
12
Andreas Gruenbacher764a5c62015-12-02 14:44:43 +010013static bool
14ext2_xattr_user_list(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -070015{
Andreas Gruenbacher764a5c62015-12-02 14:44:43 +010016 return test_opt(dentry->d_sb, XATTR_USER);
Linus Torvalds1da177e2005-04-16 15:20:36 -070017}
18
19static int
Andreas Gruenbacherd9a82a02015-10-04 19:18:51 +020020ext2_xattr_user_get(const struct xattr_handler *handler,
Al Virob2968212016-04-10 20:48:24 -040021 struct dentry *unused, struct inode *inode,
22 const char *name, void *buffer, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023{
Al Virob2968212016-04-10 20:48:24 -040024 if (!test_opt(inode->i_sb, XATTR_USER))
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 return -EOPNOTSUPP;
Al Virob2968212016-04-10 20:48:24 -040026 return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER,
Christoph Hellwig431547b2009-11-13 09:52:56 +000027 name, buffer, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -070028}
29
30static int
Andreas Gruenbacherd9a82a02015-10-04 19:18:51 +020031ext2_xattr_user_set(const struct xattr_handler *handler,
Al Viro59301222016-05-27 10:19:30 -040032 struct dentry *unused, struct inode *inode,
33 const char *name, const void *value,
34 size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070035{
Al Viro59301222016-05-27 10:19:30 -040036 if (!test_opt(inode->i_sb, XATTR_USER))
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 return -EOPNOTSUPP;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Al Viro59301222016-05-27 10:19:30 -040039 return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER,
Christoph Hellwig431547b2009-11-13 09:52:56 +000040 name, value, size, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070041}
42
Stephen Hemminger749c72ef2010-05-13 17:53:16 -070043const struct xattr_handler ext2_xattr_user_handler = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 .prefix = XATTR_USER_PREFIX,
45 .list = ext2_xattr_user_list,
46 .get = ext2_xattr_user_get,
47 .set = ext2_xattr_user_set,
48};