blob: 72a2a96d677f9ed455e0ac92cdeaf241b5ab188b [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,
21 struct dentry *dentry, const char *name,
22 void *buffer, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023{
Christoph Hellwig431547b2009-11-13 09:52:56 +000024 if (!test_opt(dentry->d_sb, XATTR_USER))
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 return -EOPNOTSUPP;
David Howells2b0143b2015-03-17 22:25:59 +000026 return ext2_xattr_get(d_inode(dentry), 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,
32 struct dentry *dentry, const char *name,
33 const void *value, size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070034{
Christoph Hellwig431547b2009-11-13 09:52:56 +000035 if (!test_opt(dentry->d_sb, XATTR_USER))
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 return -EOPNOTSUPP;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
David Howells2b0143b2015-03-17 22:25:59 +000038 return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_USER,
Christoph Hellwig431547b2009-11-13 09:52:56 +000039 name, value, size, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040}
41
Stephen Hemminger749c72ef2010-05-13 17:53:16 -070042const struct xattr_handler ext2_xattr_user_handler = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 .prefix = XATTR_USER_PREFIX,
44 .list = ext2_xattr_user_list,
45 .get = ext2_xattr_user_get,
46 .set = ext2_xattr_user_set,
47};