Skip to content

Commit 5d2eb54

Browse files
committed
Merge branch 'for-linus-3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs xattr cleanups from Al Viro. * 'for-linus-3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: f2fs: xattr simplifications squashfs: xattr simplifications 9p: xattr simplifications xattr handlers: Pass handler to operations instead of flags jffs2: Add missing capability check for listing trusted xattrs hfsplus: Remove unused xattr handler list operations ubifs: Remove unused security xattr handler vfs: Fix the posix_acl_xattr_list return value vfs: Check attribute names in posix acl xattr handers
2 parents 2870f6c + 29608d2 commit 5d2eb54

39 files changed

Lines changed: 390 additions & 651 deletions

fs/9p/Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ obj-$(CONFIG_9P_FS) := 9p.o
1010
vfs_dentry.o \
1111
v9fs.o \
1212
fid.o \
13-
xattr.o \
14-
xattr_user.o \
15-
xattr_trusted.o
13+
xattr.o
1614

1715
9p-$(CONFIG_9P_FSCACHE) += cache.o
1816
9p-$(CONFIG_9P_FS_POSIX_ACL) += acl.o
19-
9p-$(CONFIG_9P_FS_SECURITY) += xattr_security.o

fs/9p/acl.c

Lines changed: 13 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -212,26 +212,9 @@ int v9fs_acl_mode(struct inode *dir, umode_t *modep,
212212
return 0;
213213
}
214214

215-
static int v9fs_remote_get_acl(struct dentry *dentry, const char *name,
216-
void *buffer, size_t size, int type)
217-
{
218-
char *full_name;
219-
220-
switch (type) {
221-
case ACL_TYPE_ACCESS:
222-
full_name = POSIX_ACL_XATTR_ACCESS;
223-
break;
224-
case ACL_TYPE_DEFAULT:
225-
full_name = POSIX_ACL_XATTR_DEFAULT;
226-
break;
227-
default:
228-
BUG();
229-
}
230-
return v9fs_xattr_get(dentry, full_name, buffer, size);
231-
}
232-
233-
static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
234-
void *buffer, size_t size, int type)
215+
static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
216+
struct dentry *dentry, const char *name,
217+
void *buffer, size_t size)
235218
{
236219
struct v9fs_session_info *v9ses;
237220
struct posix_acl *acl;
@@ -245,9 +228,9 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
245228
* We allow set/get/list of acl when access=client is not specified
246229
*/
247230
if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
248-
return v9fs_remote_get_acl(dentry, name, buffer, size, type);
231+
return v9fs_xattr_get(dentry, handler->prefix, buffer, size);
249232

250-
acl = v9fs_get_cached_acl(d_inode(dentry), type);
233+
acl = v9fs_get_cached_acl(d_inode(dentry), handler->flags);
251234
if (IS_ERR(acl))
252235
return PTR_ERR(acl);
253236
if (acl == NULL)
@@ -258,29 +241,9 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
258241
return error;
259242
}
260243

261-
static int v9fs_remote_set_acl(struct dentry *dentry, const char *name,
262-
const void *value, size_t size,
263-
int flags, int type)
264-
{
265-
char *full_name;
266-
267-
switch (type) {
268-
case ACL_TYPE_ACCESS:
269-
full_name = POSIX_ACL_XATTR_ACCESS;
270-
break;
271-
case ACL_TYPE_DEFAULT:
272-
full_name = POSIX_ACL_XATTR_DEFAULT;
273-
break;
274-
default:
275-
BUG();
276-
}
277-
return v9fs_xattr_set(dentry, full_name, value, size, flags);
278-
}
279-
280-
281-
static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
282-
const void *value, size_t size,
283-
int flags, int type)
244+
static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
245+
struct dentry *dentry, const char *name,
246+
const void *value, size_t size, int flags)
284247
{
285248
int retval;
286249
struct posix_acl *acl;
@@ -296,8 +259,8 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
296259
* xattr value. We leave it to the server to validate
297260
*/
298261
if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
299-
return v9fs_remote_set_acl(dentry, name,
300-
value, size, flags, type);
262+
return v9fs_xattr_set(dentry, handler->prefix, value, size,
263+
flags);
301264

302265
if (S_ISLNK(inode->i_mode))
303266
return -EOPNOTSUPP;
@@ -316,9 +279,8 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
316279
} else
317280
acl = NULL;
318281

319-
switch (type) {
282+
switch (handler->flags) {
320283
case ACL_TYPE_ACCESS:
321-
name = POSIX_ACL_XATTR_ACCESS;
322284
if (acl) {
323285
umode_t mode = inode->i_mode;
324286
retval = posix_acl_equiv_mode(acl, &mode);
@@ -349,7 +311,6 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
349311
}
350312
break;
351313
case ACL_TYPE_DEFAULT:
352-
name = POSIX_ACL_XATTR_DEFAULT;
353314
if (!S_ISDIR(inode->i_mode)) {
354315
retval = acl ? -EINVAL : 0;
355316
goto err_out;
@@ -358,9 +319,9 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
358319
default:
359320
BUG();
360321
}
361-
retval = v9fs_xattr_set(dentry, name, value, size, flags);
322+
retval = v9fs_xattr_set(dentry, handler->prefix, value, size, flags);
362323
if (!retval)
363-
set_cached_acl(inode, type, acl);
324+
set_cached_acl(inode, handler->flags, acl);
364325
err_out:
365326
posix_acl_release(acl);
366327
return retval;

fs/9p/xattr.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,48 @@ ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
137137
return v9fs_xattr_get(dentry, NULL, buffer, buffer_size);
138138
}
139139

140+
static int v9fs_xattr_handler_get(const struct xattr_handler *handler,
141+
struct dentry *dentry, const char *name,
142+
void *buffer, size_t size)
143+
{
144+
const char *full_name = xattr_full_name(handler, name);
145+
146+
if (strcmp(name, "") == 0)
147+
return -EINVAL;
148+
return v9fs_xattr_get(dentry, full_name, buffer, size);
149+
}
150+
151+
static int v9fs_xattr_handler_set(const struct xattr_handler *handler,
152+
struct dentry *dentry, const char *name,
153+
const void *value, size_t size, int flags)
154+
{
155+
const char *full_name = xattr_full_name(handler, name);
156+
157+
if (strcmp(name, "") == 0)
158+
return -EINVAL;
159+
return v9fs_xattr_set(dentry, full_name, value, size, flags);
160+
}
161+
162+
static struct xattr_handler v9fs_xattr_user_handler = {
163+
.prefix = XATTR_USER_PREFIX,
164+
.get = v9fs_xattr_handler_get,
165+
.set = v9fs_xattr_handler_set,
166+
};
167+
168+
static struct xattr_handler v9fs_xattr_trusted_handler = {
169+
.prefix = XATTR_TRUSTED_PREFIX,
170+
.get = v9fs_xattr_handler_get,
171+
.set = v9fs_xattr_handler_set,
172+
};
173+
174+
#ifdef CONFIG_9P_FS_SECURITY
175+
static struct xattr_handler v9fs_xattr_security_handler = {
176+
.prefix = XATTR_SECURITY_PREFIX,
177+
.get = v9fs_xattr_handler_get,
178+
.set = v9fs_xattr_handler_set,
179+
};
180+
#endif
181+
140182
const struct xattr_handler *v9fs_xattr_handlers[] = {
141183
&v9fs_xattr_user_handler,
142184
&v9fs_xattr_trusted_handler,

fs/9p/xattr.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
#include <net/9p/client.h>
2020

2121
extern const struct xattr_handler *v9fs_xattr_handlers[];
22-
extern struct xattr_handler v9fs_xattr_user_handler;
23-
extern struct xattr_handler v9fs_xattr_trusted_handler;
24-
extern struct xattr_handler v9fs_xattr_security_handler;
2522
extern const struct xattr_handler v9fs_xattr_acl_access_handler;
2623
extern const struct xattr_handler v9fs_xattr_acl_default_handler;
2724

fs/9p/xattr_security.c

Lines changed: 0 additions & 80 deletions
This file was deleted.

fs/9p/xattr_trusted.c

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)