Linux Audio

Check our new training course

Linux debugging, profiling, tracing and performance analysis training

Apr 14-17, 2025
Register
Loading...
v6.8
 1// SPDX-License-Identifier: GPL-2.0
 2#include "reiserfs.h"
 3#include <linux/errno.h>
 4#include <linux/fs.h>
 5#include <linux/pagemap.h>
 6#include <linux/xattr.h>
 7#include "xattr.h"
 8#include <linux/uaccess.h>
 9
10static int
11user_get(const struct xattr_handler *handler, struct dentry *unused,
12	 struct inode *inode, const char *name, void *buffer, size_t size)
13{
14	if (!reiserfs_xattrs_user(inode->i_sb))
 
 
 
15		return -EOPNOTSUPP;
16	return reiserfs_xattr_get(inode, xattr_full_name(handler, name),
17				  buffer, size);
18}
19
20static int
21user_set(const struct xattr_handler *handler, struct mnt_idmap *idmap,
22	 struct dentry *unused,
23	 struct inode *inode, const char *name, const void *buffer,
24	 size_t size, int flags)
25{
26	if (!reiserfs_xattrs_user(inode->i_sb))
 
 
 
27		return -EOPNOTSUPP;
28	return reiserfs_xattr_set(inode,
29				  xattr_full_name(handler, name),
30				  buffer, size, flags);
31}
32
33static bool user_list(struct dentry *dentry)
 
34{
35	return reiserfs_xattrs_user(dentry->d_sb);
 
 
 
 
 
 
 
 
36}
37
38const struct xattr_handler reiserfs_xattr_user_handler = {
39	.prefix = XATTR_USER_PREFIX,
40	.get = user_get,
41	.set = user_set,
42	.list = user_list,
43};
v3.15
 
 1#include "reiserfs.h"
 2#include <linux/errno.h>
 3#include <linux/fs.h>
 4#include <linux/pagemap.h>
 5#include <linux/xattr.h>
 6#include "xattr.h"
 7#include <asm/uaccess.h>
 8
 9static int
10user_get(struct dentry *dentry, const char *name, void *buffer, size_t size,
11	 int handler_flags)
12{
13
14	if (strlen(name) < sizeof(XATTR_USER_PREFIX))
15		return -EINVAL;
16	if (!reiserfs_xattrs_user(dentry->d_sb))
17		return -EOPNOTSUPP;
18	return reiserfs_xattr_get(dentry->d_inode, name, buffer, size);
 
19}
20
21static int
22user_set(struct dentry *dentry, const char *name, const void *buffer,
23	 size_t size, int flags, int handler_flags)
 
 
24{
25	if (strlen(name) < sizeof(XATTR_USER_PREFIX))
26		return -EINVAL;
27
28	if (!reiserfs_xattrs_user(dentry->d_sb))
29		return -EOPNOTSUPP;
30	return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags);
 
 
31}
32
33static size_t user_list(struct dentry *dentry, char *list, size_t list_size,
34			const char *name, size_t name_len, int handler_flags)
35{
36	const size_t len = name_len + 1;
37
38	if (!reiserfs_xattrs_user(dentry->d_sb))
39		return 0;
40	if (list && len <= list_size) {
41		memcpy(list, name, name_len);
42		list[name_len] = '\0';
43	}
44	return len;
45}
46
47const struct xattr_handler reiserfs_xattr_user_handler = {
48	.prefix = XATTR_USER_PREFIX,
49	.get = user_get,
50	.set = user_set,
51	.list = user_list,
52};