VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500   1) /*
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500   2)  * FUSE: Filesystem in Userspace
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500   3)  * Copyright (C) 2001-2016  Miklos Szeredi <miklos@szeredi.hu>
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500   4)  *
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500   5)  * This program can be distributed under the terms of the GNU GPL.
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500   6)  * See the file COPYING.
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500   7)  */
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500   8) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500   9) #include "fuse_i.h"
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  10) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  11) #include <linux/xattr.h>
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500  12) #include <linux/posix_acl_xattr.h>
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  13) 
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500  14) int fuse_setxattr(struct inode *inode, const char *name, const void *value,
52a4c95f4d24b (Vivek Goyal       2021-03-25 11:18:22 -0400  15) 		  size_t size, int flags, unsigned int extra_flags)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  16) {
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200  17) 	struct fuse_mount *fm = get_fuse_mount(inode);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  18) 	FUSE_ARGS(args);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  19) 	struct fuse_setxattr_in inarg;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  20) 	int err;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  21) 
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200  22) 	if (fm->fc->no_setxattr)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  23) 		return -EOPNOTSUPP;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  24) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  25) 	memset(&inarg, 0, sizeof(inarg));
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  26) 	inarg.size = size;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  27) 	inarg.flags = flags;
52a4c95f4d24b (Vivek Goyal       2021-03-25 11:18:22 -0400  28) 	inarg.setxattr_flags = extra_flags;
52a4c95f4d24b (Vivek Goyal       2021-03-25 11:18:22 -0400  29) 
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  30) 	args.opcode = FUSE_SETXATTR;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  31) 	args.nodeid = get_node_id(inode);
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  32) 	args.in_numargs = 3;
52a4c95f4d24b (Vivek Goyal       2021-03-25 11:18:22 -0400  33) 	args.in_args[0].size = fm->fc->setxattr_ext ?
52a4c95f4d24b (Vivek Goyal       2021-03-25 11:18:22 -0400  34) 		sizeof(inarg) : FUSE_COMPAT_SETXATTR_IN_SIZE;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  35) 	args.in_args[0].value = &inarg;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  36) 	args.in_args[1].size = strlen(name) + 1;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  37) 	args.in_args[1].value = name;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  38) 	args.in_args[2].size = size;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  39) 	args.in_args[2].value = value;
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200  40) 	err = fuse_simple_request(fm, &args);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  41) 	if (err == -ENOSYS) {
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200  42) 		fm->fc->no_setxattr = 1;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  43) 		err = -EOPNOTSUPP;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  44) 	}
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  45) 	if (!err) {
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  46) 		fuse_invalidate_attr(inode);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  47) 		fuse_update_ctime(inode);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  48) 	}
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  49) 	return err;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  50) }
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  51) 
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500  52) ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value,
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500  53) 		      size_t size)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  54) {
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200  55) 	struct fuse_mount *fm = get_fuse_mount(inode);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  56) 	FUSE_ARGS(args);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  57) 	struct fuse_getxattr_in inarg;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  58) 	struct fuse_getxattr_out outarg;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  59) 	ssize_t ret;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  60) 
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200  61) 	if (fm->fc->no_getxattr)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  62) 		return -EOPNOTSUPP;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  63) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  64) 	memset(&inarg, 0, sizeof(inarg));
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  65) 	inarg.size = size;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  66) 	args.opcode = FUSE_GETXATTR;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  67) 	args.nodeid = get_node_id(inode);
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  68) 	args.in_numargs = 2;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  69) 	args.in_args[0].size = sizeof(inarg);
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  70) 	args.in_args[0].value = &inarg;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  71) 	args.in_args[1].size = strlen(name) + 1;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  72) 	args.in_args[1].value = name;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  73) 	/* This is really two different operations rolled into one */
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  74) 	args.out_numargs = 1;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  75) 	if (size) {
1f4e9d03d1fbf (Miklos Szeredi    2019-09-10 15:04:08 +0200  76) 		args.out_argvar = true;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  77) 		args.out_args[0].size = size;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  78) 		args.out_args[0].value = value;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  79) 	} else {
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  80) 		args.out_args[0].size = sizeof(outarg);
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200  81) 		args.out_args[0].value = &outarg;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  82) 	}
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200  83) 	ret = fuse_simple_request(fm, &args);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  84) 	if (!ret && !size)
63401ccdb2ca0 (Miklos Szeredi    2016-10-03 11:06:05 +0200  85) 		ret = min_t(ssize_t, outarg.size, XATTR_SIZE_MAX);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  86) 	if (ret == -ENOSYS) {
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200  87) 		fm->fc->no_getxattr = 1;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  88) 		ret = -EOPNOTSUPP;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  89) 	}
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  90) 	return ret;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  91) }
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  92) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  93) static int fuse_verify_xattr_list(char *list, size_t size)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  94) {
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  95) 	size_t origsize = size;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  96) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  97) 	while (size) {
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  98) 		size_t thislen = strnlen(list, size);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500  99) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 100) 		if (!thislen || thislen == size)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 101) 			return -EIO;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 102) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 103) 		size -= thislen + 1;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 104) 		list += thislen + 1;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 105) 	}
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 106) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 107) 	return origsize;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 108) }
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 109) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 110) ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 111) {
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 112) 	struct inode *inode = d_inode(entry);
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200 113) 	struct fuse_mount *fm = get_fuse_mount(inode);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 114) 	FUSE_ARGS(args);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 115) 	struct fuse_getxattr_in inarg;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 116) 	struct fuse_getxattr_out outarg;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 117) 	ssize_t ret;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 118) 
5d069dbe8aaf2 (Miklos Szeredi    2020-12-10 15:33:14 +0100 119) 	if (fuse_is_bad(inode))
5d069dbe8aaf2 (Miklos Szeredi    2020-12-10 15:33:14 +0100 120) 		return -EIO;
5d069dbe8aaf2 (Miklos Szeredi    2020-12-10 15:33:14 +0100 121) 
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200 122) 	if (!fuse_allow_current_process(fm->fc))
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 123) 		return -EACCES;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 124) 
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200 125) 	if (fm->fc->no_listxattr)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 126) 		return -EOPNOTSUPP;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 127) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 128) 	memset(&inarg, 0, sizeof(inarg));
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 129) 	inarg.size = size;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 130) 	args.opcode = FUSE_LISTXATTR;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 131) 	args.nodeid = get_node_id(inode);
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 132) 	args.in_numargs = 1;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 133) 	args.in_args[0].size = sizeof(inarg);
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 134) 	args.in_args[0].value = &inarg;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 135) 	/* This is really two different operations rolled into one */
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 136) 	args.out_numargs = 1;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 137) 	if (size) {
1f4e9d03d1fbf (Miklos Szeredi    2019-09-10 15:04:08 +0200 138) 		args.out_argvar = true;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 139) 		args.out_args[0].size = size;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 140) 		args.out_args[0].value = list;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 141) 	} else {
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 142) 		args.out_args[0].size = sizeof(outarg);
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 143) 		args.out_args[0].value = &outarg;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 144) 	}
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200 145) 	ret = fuse_simple_request(fm, &args);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 146) 	if (!ret && !size)
63401ccdb2ca0 (Miklos Szeredi    2016-10-03 11:06:05 +0200 147) 		ret = min_t(ssize_t, outarg.size, XATTR_LIST_MAX);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 148) 	if (ret > 0 && size)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 149) 		ret = fuse_verify_xattr_list(list, ret);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 150) 	if (ret == -ENOSYS) {
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200 151) 		fm->fc->no_listxattr = 1;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 152) 		ret = -EOPNOTSUPP;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 153) 	}
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 154) 	return ret;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 155) }
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 156) 
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500 157) int fuse_removexattr(struct inode *inode, const char *name)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 158) {
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200 159) 	struct fuse_mount *fm = get_fuse_mount(inode);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 160) 	FUSE_ARGS(args);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 161) 	int err;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 162) 
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200 163) 	if (fm->fc->no_removexattr)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 164) 		return -EOPNOTSUPP;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 165) 
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 166) 	args.opcode = FUSE_REMOVEXATTR;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 167) 	args.nodeid = get_node_id(inode);
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 168) 	args.in_numargs = 1;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 169) 	args.in_args[0].size = strlen(name) + 1;
d5b4854357f47 (Miklos Szeredi    2019-09-10 15:04:08 +0200 170) 	args.in_args[0].value = name;
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200 171) 	err = fuse_simple_request(fm, &args);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 172) 	if (err == -ENOSYS) {
fcee216beb9c1 (Max Reitz         2020-05-06 17:44:12 +0200 173) 		fm->fc->no_removexattr = 1;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 174) 		err = -EOPNOTSUPP;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 175) 	}
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 176) 	if (!err) {
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 177) 		fuse_invalidate_attr(inode);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 178) 		fuse_update_ctime(inode);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 179) 	}
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 180) 	return err;
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 181) }
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 182) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 183) static int fuse_xattr_get(const struct xattr_handler *handler,
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 184) 			 struct dentry *dentry, struct inode *inode,
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 185) 			 const char *name, void *value, size_t size)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 186) {
5d069dbe8aaf2 (Miklos Szeredi    2020-12-10 15:33:14 +0100 187) 	if (fuse_is_bad(inode))
5d069dbe8aaf2 (Miklos Szeredi    2020-12-10 15:33:14 +0100 188) 		return -EIO;
5d069dbe8aaf2 (Miklos Szeredi    2020-12-10 15:33:14 +0100 189) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 190) 	return fuse_getxattr(inode, name, value, size);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 191) }
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 192) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 193) static int fuse_xattr_set(const struct xattr_handler *handler,
e65ce2a50cf6a (Christian Brauner 2021-01-21 14:19:27 +0100 194) 			  struct user_namespace *mnt_userns,
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 195) 			  struct dentry *dentry, struct inode *inode,
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 196) 			  const char *name, const void *value, size_t size,
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 197) 			  int flags)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 198) {
5d069dbe8aaf2 (Miklos Szeredi    2020-12-10 15:33:14 +0100 199) 	if (fuse_is_bad(inode))
5d069dbe8aaf2 (Miklos Szeredi    2020-12-10 15:33:14 +0100 200) 		return -EIO;
5d069dbe8aaf2 (Miklos Szeredi    2020-12-10 15:33:14 +0100 201) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 202) 	if (!value)
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 203) 		return fuse_removexattr(inode, name);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 204) 
52a4c95f4d24b (Vivek Goyal       2021-03-25 11:18:22 -0400 205) 	return fuse_setxattr(inode, name, value, size, flags, 0);
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 206) }
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 207) 
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 208) static bool no_xattr_list(struct dentry *dentry)
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 209) {
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 210) 	return false;
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 211) }
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 212) 
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 213) static int no_xattr_get(const struct xattr_handler *handler,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 214) 			struct dentry *dentry, struct inode *inode,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 215) 			const char *name, void *value, size_t size)
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 216) {
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 217) 	return -EOPNOTSUPP;
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 218) }
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 219) 
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 220) static int no_xattr_set(const struct xattr_handler *handler,
e65ce2a50cf6a (Christian Brauner 2021-01-21 14:19:27 +0100 221) 			struct user_namespace *mnt_userns,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 222) 			struct dentry *dentry, struct inode *nodee,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 223) 			const char *name, const void *value,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 224) 			size_t size, int flags)
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 225) {
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 226) 	return -EOPNOTSUPP;
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 227) }
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 228) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 229) static const struct xattr_handler fuse_xattr_handler = {
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 230) 	.prefix = "",
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 231) 	.get    = fuse_xattr_get,
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 232) 	.set    = fuse_xattr_set,
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 233) };
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 234) 
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 235) const struct xattr_handler *fuse_xattr_handlers[] = {
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 236) 	&fuse_xattr_handler,
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 237) 	NULL
703c73629f934 (Seth Forshee      2016-08-29 08:46:36 -0500 238) };
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500 239) 
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500 240) const struct xattr_handler *fuse_acl_xattr_handlers[] = {
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500 241) 	&posix_acl_access_xattr_handler,
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500 242) 	&posix_acl_default_xattr_handler,
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500 243) 	&fuse_xattr_handler,
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500 244) 	NULL
60bcc88ad185d (Seth Forshee      2016-08-29 08:46:37 -0500 245) };
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 246) 
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 247) static const struct xattr_handler fuse_no_acl_access_xattr_handler = {
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 248) 	.name  = XATTR_NAME_POSIX_ACL_ACCESS,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 249) 	.flags = ACL_TYPE_ACCESS,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 250) 	.list  = no_xattr_list,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 251) 	.get   = no_xattr_get,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 252) 	.set   = no_xattr_set,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 253) };
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 254) 
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 255) static const struct xattr_handler fuse_no_acl_default_xattr_handler = {
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 256) 	.name  = XATTR_NAME_POSIX_ACL_DEFAULT,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 257) 	.flags = ACL_TYPE_ACCESS,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 258) 	.list  = no_xattr_list,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 259) 	.get   = no_xattr_get,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 260) 	.set   = no_xattr_set,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 261) };
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 262) 
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 263) const struct xattr_handler *fuse_no_acl_xattr_handlers[] = {
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 264) 	&fuse_no_acl_access_xattr_handler,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 265) 	&fuse_no_acl_default_xattr_handler,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 266) 	&fuse_xattr_handler,
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 267) 	NULL
e45b2546e23c2 (Eric W. Biederman 2018-05-04 11:47:28 -0500 268) };