blob: 17a446ffecd30c1ace66c1a2f2fb349f0a24211c [file] [log] [blame]
Dave Kleikampac27a0e2006-10-11 01:20:50 -07001/*
Mingming Cao617ba132006-10-11 01:20:53 -07002 * linux/fs/ext4/xattr_user.c
Dave Kleikampac27a0e2006-10-11 01:20:50 -07003 * Handler for extended user attributes.
4 *
5 * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
6 */
7
Dave Kleikampac27a0e2006-10-11 01:20:50 -07008#include <linux/string.h>
9#include <linux/fs.h>
Christoph Hellwig3dcf5452008-04-29 18:13:32 -040010#include "ext4_jbd2.h"
11#include "ext4.h"
Dave Kleikampac27a0e2006-10-11 01:20:50 -070012#include "xattr.h"
13
Andreas Gruenbacher764a5c62015-12-02 14:44:43 +010014static bool
15ext4_xattr_user_list(struct dentry *dentry)
Dave Kleikampac27a0e2006-10-11 01:20:50 -070016{
Andreas Gruenbacher764a5c62015-12-02 14:44:43 +010017 return test_opt(dentry->d_sb, XATTR_USER);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070018}
19
20static int
Andreas Gruenbacherd9a82a02015-10-04 19:18:51 +020021ext4_xattr_user_get(const struct xattr_handler *handler,
Al Virob2968212016-04-10 20:48:24 -040022 struct dentry *unused, struct inode *inode,
23 const char *name, void *buffer, size_t size)
Dave Kleikampac27a0e2006-10-11 01:20:50 -070024{
Al Virob2968212016-04-10 20:48:24 -040025 if (!test_opt(inode->i_sb, XATTR_USER))
Dave Kleikampac27a0e2006-10-11 01:20:50 -070026 return -EOPNOTSUPP;
Al Virob2968212016-04-10 20:48:24 -040027 return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER,
Christoph Hellwig431547b2009-11-13 09:52:56 +000028 name, buffer, size);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070029}
30
31static int
Andreas Gruenbacherd9a82a02015-10-04 19:18:51 +020032ext4_xattr_user_set(const struct xattr_handler *handler,
33 struct dentry *dentry, const char *name,
34 const void *value, size_t size, int flags)
Dave Kleikampac27a0e2006-10-11 01:20:50 -070035{
Christoph Hellwig431547b2009-11-13 09:52:56 +000036 if (!test_opt(dentry->d_sb, XATTR_USER))
Dave Kleikampac27a0e2006-10-11 01:20:50 -070037 return -EOPNOTSUPP;
David Howells2b0143b2015-03-17 22:25:59 +000038 return ext4_xattr_set(d_inode(dentry), EXT4_XATTR_INDEX_USER,
Christoph Hellwig431547b2009-11-13 09:52:56 +000039 name, value, size, flags);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070040}
41
Stephen Hemminger11e27522010-05-13 17:53:18 -070042const struct xattr_handler ext4_xattr_user_handler = {
Dave Kleikampac27a0e2006-10-11 01:20:50 -070043 .prefix = XATTR_USER_PREFIX,
Mingming Cao617ba132006-10-11 01:20:53 -070044 .list = ext4_xattr_user_list,
45 .get = ext4_xattr_user_get,
46 .set = ext4_xattr_user_set,
Dave Kleikampac27a0e2006-10-11 01:20:50 -070047};