blob: ca20e423034bf48a8e6e237cff0f3f3896d5280b [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,
Al Viro59301222016-05-27 10:19:30 -040033 struct dentry *unused, struct inode *inode,
34 const char *name, const void *value,
35 size_t size, int flags)
Dave Kleikampac27a0e2006-10-11 01:20:50 -070036{
Al Viro59301222016-05-27 10:19:30 -040037 if (!test_opt(inode->i_sb, XATTR_USER))
Dave Kleikampac27a0e2006-10-11 01:20:50 -070038 return -EOPNOTSUPP;
Al Viro59301222016-05-27 10:19:30 -040039 return ext4_xattr_set(inode, EXT4_XATTR_INDEX_USER,
Christoph Hellwig431547b2009-11-13 09:52:56 +000040 name, value, size, flags);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070041}
42
Stephen Hemminger11e27522010-05-13 17:53:18 -070043const struct xattr_handler ext4_xattr_user_handler = {
Dave Kleikampac27a0e2006-10-11 01:20:50 -070044 .prefix = XATTR_USER_PREFIX,
Mingming Cao617ba132006-10-11 01:20:53 -070045 .list = ext4_xattr_user_list,
46 .get = ext4_xattr_user_get,
47 .set = ext4_xattr_user_set,
Dave Kleikampac27a0e2006-10-11 01:20:50 -070048};