diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-16 15:04:02 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-16 15:04:02 -0500 |
commit | bac5e54c29f352d962a2447d22735316b347b9f1 (patch) | |
tree | 7642993fa93164835ffaa2dacd341388193f1979 /fs | |
parent | 529e89430d6c0d64db8ac474cb95e68e2527c79a (diff) | |
parent | c05c4edd876b7ae92787d1295868afcb89b6a348 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (38 commits)
direct I/O fallback sync simplification
ocfs: stop using do_sync_mapping_range
cleanup blockdev_direct_IO locking
make generic_acl slightly more generic
sanitize xattr handler prototypes
libfs: move EXPORT_SYMBOL for d_alloc_name
vfs: force reval of target when following LAST_BIND symlinks (try #7)
ima: limit imbalance msg
Untangling ima mess, part 3: kill dead code in ima
Untangling ima mess, part 2: deal with counters
Untangling ima mess, part 1: alloc_file()
O_TRUNC open shouldn't fail after file truncation
ima: call ima_inode_free ima_inode_free
IMA: clean up the IMA counts updating code
ima: only insert at inode creation time
ima: valid return code from ima_inode_alloc
fs: move get_empty_filp() deffinition to internal.h
Sanitize exec_permission_lite()
Kill cached_lookup() and real_lookup()
Kill path_lookup_open()
...
Trivial conflicts in fs/direct-io.c
Diffstat (limited to 'fs')
55 files changed, 889 insertions, 1165 deletions
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c index 2ca7a7cafdbf..94f5110c4655 100644 --- a/fs/anon_inodes.c +++ b/fs/anon_inodes.c | |||
@@ -88,7 +88,7 @@ struct file *anon_inode_getfile(const char *name, | |||
88 | void *priv, int flags) | 88 | void *priv, int flags) |
89 | { | 89 | { |
90 | struct qstr this; | 90 | struct qstr this; |
91 | struct dentry *dentry; | 91 | struct path path; |
92 | struct file *file; | 92 | struct file *file; |
93 | int error; | 93 | int error; |
94 | 94 | ||
@@ -106,10 +106,11 @@ struct file *anon_inode_getfile(const char *name, | |||
106 | this.name = name; | 106 | this.name = name; |
107 | this.len = strlen(name); | 107 | this.len = strlen(name); |
108 | this.hash = 0; | 108 | this.hash = 0; |
109 | dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this); | 109 | path.dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this); |
110 | if (!dentry) | 110 | if (!path.dentry) |
111 | goto err_module; | 111 | goto err_module; |
112 | 112 | ||
113 | path.mnt = mntget(anon_inode_mnt); | ||
113 | /* | 114 | /* |
114 | * We know the anon_inode inode count is always greater than zero, | 115 | * We know the anon_inode inode count is always greater than zero, |
115 | * so we can avoid doing an igrab() and we can use an open-coded | 116 | * so we can avoid doing an igrab() and we can use an open-coded |
@@ -117,14 +118,13 @@ struct file *anon_inode_getfile(const char *name, | |||
117 | */ | 118 | */ |
118 | atomic_inc(&anon_inode_inode->i_count); | 119 | atomic_inc(&anon_inode_inode->i_count); |
119 | 120 | ||
120 | dentry->d_op = &anon_inodefs_dentry_operations; | 121 | path.dentry->d_op = &anon_inodefs_dentry_operations; |
121 | /* Do not publish this dentry inside the global dentry hash table */ | 122 | /* Do not publish this dentry inside the global dentry hash table */ |
122 | dentry->d_flags &= ~DCACHE_UNHASHED; | 123 | path.dentry->d_flags &= ~DCACHE_UNHASHED; |
123 | d_instantiate(dentry, anon_inode_inode); | 124 | d_instantiate(path.dentry, anon_inode_inode); |
124 | 125 | ||
125 | error = -ENFILE; | 126 | error = -ENFILE; |
126 | file = alloc_file(anon_inode_mnt, dentry, | 127 | file = alloc_file(&path, FMODE_READ | FMODE_WRITE, fops); |
127 | FMODE_READ | FMODE_WRITE, fops); | ||
128 | if (!file) | 128 | if (!file) |
129 | goto err_dput; | 129 | goto err_dput; |
130 | file->f_mapping = anon_inode_inode->i_mapping; | 130 | file->f_mapping = anon_inode_inode->i_mapping; |
@@ -137,7 +137,7 @@ struct file *anon_inode_getfile(const char *name, | |||
137 | return file; | 137 | return file; |
138 | 138 | ||
139 | err_dput: | 139 | err_dput: |
140 | dput(dentry); | 140 | path_put(&path); |
141 | err_module: | 141 | err_module: |
142 | module_put(fops->owner); | 142 | module_put(fops->owner); |
143 | return ERR_PTR(error); | 143 | return ERR_PTR(error); |
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 361604244271..52cbe47022bf 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c | |||
@@ -73,13 +73,13 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type) | |||
73 | return acl; | 73 | return acl; |
74 | } | 74 | } |
75 | 75 | ||
76 | static int btrfs_xattr_get_acl(struct inode *inode, int type, | 76 | static int btrfs_xattr_acl_get(struct dentry *dentry, const char *name, |
77 | void *value, size_t size) | 77 | void *value, size_t size, int type) |
78 | { | 78 | { |
79 | struct posix_acl *acl; | 79 | struct posix_acl *acl; |
80 | int ret = 0; | 80 | int ret = 0; |
81 | 81 | ||
82 | acl = btrfs_get_acl(inode, type); | 82 | acl = btrfs_get_acl(dentry->d_inode, type); |
83 | 83 | ||
84 | if (IS_ERR(acl)) | 84 | if (IS_ERR(acl)) |
85 | return PTR_ERR(acl); | 85 | return PTR_ERR(acl); |
@@ -151,8 +151,8 @@ out: | |||
151 | return ret; | 151 | return ret; |
152 | } | 152 | } |
153 | 153 | ||
154 | static int btrfs_xattr_set_acl(struct inode *inode, int type, | 154 | static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name, |
155 | const void *value, size_t size) | 155 | const void *value, size_t size, int flags, int type) |
156 | { | 156 | { |
157 | int ret = 0; | 157 | int ret = 0; |
158 | struct posix_acl *acl = NULL; | 158 | struct posix_acl *acl = NULL; |
@@ -167,38 +167,13 @@ static int btrfs_xattr_set_acl(struct inode *inode, int type, | |||
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | ret = btrfs_set_acl(inode, acl, type); | 170 | ret = btrfs_set_acl(dentry->d_inode, acl, type); |
171 | 171 | ||
172 | posix_acl_release(acl); | 172 | posix_acl_release(acl); |
173 | 173 | ||
174 | return ret; | 174 | return ret; |
175 | } | 175 | } |
176 | 176 | ||
177 | |||
178 | static int btrfs_xattr_acl_access_get(struct inode *inode, const char *name, | ||
179 | void *value, size_t size) | ||
180 | { | ||
181 | return btrfs_xattr_get_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
182 | } | ||
183 | |||
184 | static int btrfs_xattr_acl_access_set(struct inode *inode, const char *name, | ||
185 | const void *value, size_t size, int flags) | ||
186 | { | ||
187 | return btrfs_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
188 | } | ||
189 | |||
190 | static int btrfs_xattr_acl_default_get(struct inode *inode, const char *name, | ||
191 | void *value, size_t size) | ||
192 | { | ||
193 | return btrfs_xattr_get_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
194 | } | ||
195 | |||
196 | static int btrfs_xattr_acl_default_set(struct inode *inode, const char *name, | ||
197 | const void *value, size_t size, int flags) | ||
198 | { | ||
199 | return btrfs_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
200 | } | ||
201 | |||
202 | int btrfs_check_acl(struct inode *inode, int mask) | 177 | int btrfs_check_acl(struct inode *inode, int mask) |
203 | { | 178 | { |
204 | struct posix_acl *acl; | 179 | struct posix_acl *acl; |
@@ -303,14 +278,16 @@ int btrfs_acl_chmod(struct inode *inode) | |||
303 | 278 | ||
304 | struct xattr_handler btrfs_xattr_acl_default_handler = { | 279 | struct xattr_handler btrfs_xattr_acl_default_handler = { |
305 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 280 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
306 | .get = btrfs_xattr_acl_default_get, | 281 | .flags = ACL_TYPE_DEFAULT, |
307 | .set = btrfs_xattr_acl_default_set, | 282 | .get = btrfs_xattr_acl_get, |
283 | .set = btrfs_xattr_acl_set, | ||
308 | }; | 284 | }; |
309 | 285 | ||
310 | struct xattr_handler btrfs_xattr_acl_access_handler = { | 286 | struct xattr_handler btrfs_xattr_acl_access_handler = { |
311 | .prefix = POSIX_ACL_XATTR_ACCESS, | 287 | .prefix = POSIX_ACL_XATTR_ACCESS, |
312 | .get = btrfs_xattr_acl_access_get, | 288 | .flags = ACL_TYPE_ACCESS, |
313 | .set = btrfs_xattr_acl_access_set, | 289 | .get = btrfs_xattr_acl_get, |
290 | .set = btrfs_xattr_acl_set, | ||
314 | }; | 291 | }; |
315 | 292 | ||
316 | #else /* CONFIG_BTRFS_FS_POSIX_ACL */ | 293 | #else /* CONFIG_BTRFS_FS_POSIX_ACL */ |
diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c index 3797e0077b35..2906077ac798 100644 --- a/fs/cachefiles/bind.c +++ b/fs/cachefiles/bind.c | |||
@@ -84,7 +84,7 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args) | |||
84 | static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) | 84 | static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) |
85 | { | 85 | { |
86 | struct cachefiles_object *fsdef; | 86 | struct cachefiles_object *fsdef; |
87 | struct nameidata nd; | 87 | struct path path; |
88 | struct kstatfs stats; | 88 | struct kstatfs stats; |
89 | struct dentry *graveyard, *cachedir, *root; | 89 | struct dentry *graveyard, *cachedir, *root; |
90 | const struct cred *saved_cred; | 90 | const struct cred *saved_cred; |
@@ -114,15 +114,12 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) | |||
114 | _debug("- fsdef %p", fsdef); | 114 | _debug("- fsdef %p", fsdef); |
115 | 115 | ||
116 | /* look up the directory at the root of the cache */ | 116 | /* look up the directory at the root of the cache */ |
117 | memset(&nd, 0, sizeof(nd)); | 117 | ret = kern_path(cache->rootdirname, LOOKUP_DIRECTORY, &path); |
118 | |||
119 | ret = path_lookup(cache->rootdirname, LOOKUP_DIRECTORY, &nd); | ||
120 | if (ret < 0) | 118 | if (ret < 0) |
121 | goto error_open_root; | 119 | goto error_open_root; |
122 | 120 | ||
123 | cache->mnt = mntget(nd.path.mnt); | 121 | cache->mnt = path.mnt; |
124 | root = dget(nd.path.dentry); | 122 | root = path.dentry; |
125 | path_put(&nd.path); | ||
126 | 123 | ||
127 | /* check parameters */ | 124 | /* check parameters */ |
128 | ret = -EOPNOTSUPP; | 125 | ret = -EOPNOTSUPP; |
diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c index a6c8c6fe8df9..1d8332563863 100644 --- a/fs/cachefiles/rdwr.c +++ b/fs/cachefiles/rdwr.c | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | #include <linux/mount.h> | 12 | #include <linux/mount.h> |
13 | #include <linux/file.h> | 13 | #include <linux/file.h> |
14 | #include <linux/ima.h> | ||
15 | #include "internal.h" | 14 | #include "internal.h" |
16 | 15 | ||
17 | /* | 16 | /* |
@@ -923,7 +922,6 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page) | |||
923 | if (IS_ERR(file)) { | 922 | if (IS_ERR(file)) { |
924 | ret = PTR_ERR(file); | 923 | ret = PTR_ERR(file); |
925 | } else { | 924 | } else { |
926 | ima_counts_get(file); | ||
927 | ret = -EIO; | 925 | ret = -EIO; |
928 | if (file->f_op->write) { | 926 | if (file->f_op->write) { |
929 | pos = (loff_t) page->index << PAGE_SHIFT; | 927 | pos = (loff_t) page->index << PAGE_SHIFT; |
diff --git a/fs/dcache.c b/fs/dcache.c index a100fa35a48f..953173a293a9 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -978,6 +978,7 @@ struct dentry *d_alloc_name(struct dentry *parent, const char *name) | |||
978 | q.hash = full_name_hash(q.name, q.len); | 978 | q.hash = full_name_hash(q.name, q.len); |
979 | return d_alloc(parent, &q); | 979 | return d_alloc(parent, &q); |
980 | } | 980 | } |
981 | EXPORT_SYMBOL(d_alloc_name); | ||
981 | 982 | ||
982 | /* the caller must hold dcache_lock */ | 983 | /* the caller must hold dcache_lock */ |
983 | static void __d_instantiate(struct dentry *dentry, struct inode *inode) | 984 | static void __d_instantiate(struct dentry *dentry, struct inode *inode) |
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index c6ac85d6c701..101fe4c7b1ee 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/key.h> | 35 | #include <linux/key.h> |
36 | #include <linux/parser.h> | 36 | #include <linux/parser.h> |
37 | #include <linux/fs_stack.h> | 37 | #include <linux/fs_stack.h> |
38 | #include <linux/ima.h> | ||
39 | #include "ecryptfs_kernel.h" | 38 | #include "ecryptfs_kernel.h" |
40 | 39 | ||
41 | /** | 40 | /** |
@@ -119,7 +118,6 @@ int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) | |||
119 | const struct cred *cred = current_cred(); | 118 | const struct cred *cred = current_cred(); |
120 | struct ecryptfs_inode_info *inode_info = | 119 | struct ecryptfs_inode_info *inode_info = |
121 | ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); | 120 | ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); |
122 | int opened_lower_file = 0; | ||
123 | int rc = 0; | 121 | int rc = 0; |
124 | 122 | ||
125 | mutex_lock(&inode_info->lower_file_mutex); | 123 | mutex_lock(&inode_info->lower_file_mutex); |
@@ -136,12 +134,9 @@ int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) | |||
136 | "for lower_dentry [0x%p] and lower_mnt [0x%p]; " | 134 | "for lower_dentry [0x%p] and lower_mnt [0x%p]; " |
137 | "rc = [%d]\n", lower_dentry, lower_mnt, rc); | 135 | "rc = [%d]\n", lower_dentry, lower_mnt, rc); |
138 | inode_info->lower_file = NULL; | 136 | inode_info->lower_file = NULL; |
139 | } else | 137 | } |
140 | opened_lower_file = 1; | ||
141 | } | 138 | } |
142 | mutex_unlock(&inode_info->lower_file_mutex); | 139 | mutex_unlock(&inode_info->lower_file_mutex); |
143 | if (opened_lower_file) | ||
144 | ima_counts_get(inode_info->lower_file); | ||
145 | return rc; | 140 | return rc; |
146 | } | 141 | } |
147 | 142 | ||
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c index a63d44256a70..a99e54318c3d 100644 --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c | |||
@@ -339,12 +339,12 @@ ext2_acl_chmod(struct inode *inode) | |||
339 | * Extended attribut handlers | 339 | * Extended attribut handlers |
340 | */ | 340 | */ |
341 | static size_t | 341 | static size_t |
342 | ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size, | 342 | ext2_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_size, |
343 | const char *name, size_t name_len) | 343 | const char *name, size_t name_len, int type) |
344 | { | 344 | { |
345 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | 345 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
346 | 346 | ||
347 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 347 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
348 | return 0; | 348 | return 0; |
349 | if (list && size <= list_size) | 349 | if (list && size <= list_size) |
350 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); | 350 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); |
@@ -352,12 +352,12 @@ ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size, | |||
352 | } | 352 | } |
353 | 353 | ||
354 | static size_t | 354 | static size_t |
355 | ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size, | 355 | ext2_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_size, |
356 | const char *name, size_t name_len) | 356 | const char *name, size_t name_len, int type) |
357 | { | 357 | { |
358 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | 358 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
359 | 359 | ||
360 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 360 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
361 | return 0; | 361 | return 0; |
362 | if (list && size <= list_size) | 362 | if (list && size <= list_size) |
363 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); | 363 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); |
@@ -365,15 +365,18 @@ ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size, | |||
365 | } | 365 | } |
366 | 366 | ||
367 | static int | 367 | static int |
368 | ext2_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | 368 | ext2_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, |
369 | size_t size, int type) | ||
369 | { | 370 | { |
370 | struct posix_acl *acl; | 371 | struct posix_acl *acl; |
371 | int error; | 372 | int error; |
372 | 373 | ||
373 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 374 | if (strcmp(name, "") != 0) |
375 | return -EINVAL; | ||
376 | if (!test_opt(dentry->d_sb, POSIX_ACL)) | ||
374 | return -EOPNOTSUPP; | 377 | return -EOPNOTSUPP; |
375 | 378 | ||
376 | acl = ext2_get_acl(inode, type); | 379 | acl = ext2_get_acl(dentry->d_inode, type); |
377 | if (IS_ERR(acl)) | 380 | if (IS_ERR(acl)) |
378 | return PTR_ERR(acl); | 381 | return PTR_ERR(acl); |
379 | if (acl == NULL) | 382 | if (acl == NULL) |
@@ -385,33 +388,17 @@ ext2_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | |||
385 | } | 388 | } |
386 | 389 | ||
387 | static int | 390 | static int |
388 | ext2_xattr_get_acl_access(struct inode *inode, const char *name, | 391 | ext2_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, |
389 | void *buffer, size_t size) | 392 | size_t size, int flags, int type) |
390 | { | ||
391 | if (strcmp(name, "") != 0) | ||
392 | return -EINVAL; | ||
393 | return ext2_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); | ||
394 | } | ||
395 | |||
396 | static int | ||
397 | ext2_xattr_get_acl_default(struct inode *inode, const char *name, | ||
398 | void *buffer, size_t size) | ||
399 | { | ||
400 | if (strcmp(name, "") != 0) | ||
401 | return -EINVAL; | ||
402 | return ext2_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
403 | } | ||
404 | |||
405 | static int | ||
406 | ext2_xattr_set_acl(struct inode *inode, int type, const void *value, | ||
407 | size_t size) | ||
408 | { | 393 | { |
409 | struct posix_acl *acl; | 394 | struct posix_acl *acl; |
410 | int error; | 395 | int error; |
411 | 396 | ||
412 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 397 | if (strcmp(name, "") != 0) |
398 | return -EINVAL; | ||
399 | if (!test_opt(dentry->d_sb, POSIX_ACL)) | ||
413 | return -EOPNOTSUPP; | 400 | return -EOPNOTSUPP; |
414 | if (!is_owner_or_cap(inode)) | 401 | if (!is_owner_or_cap(dentry->d_inode)) |
415 | return -EPERM; | 402 | return -EPERM; |
416 | 403 | ||
417 | if (value) { | 404 | if (value) { |
@@ -426,41 +413,25 @@ ext2_xattr_set_acl(struct inode *inode, int type, const void *value, | |||
426 | } else | 413 | } else |
427 | acl = NULL; | 414 | acl = NULL; |
428 | 415 | ||
429 | error = ext2_set_acl(inode, type, acl); | 416 | error = ext2_set_acl(dentry->d_inode, type, acl); |
430 | 417 | ||
431 | release_and_out: | 418 | release_and_out: |
432 | posix_acl_release(acl); | 419 | posix_acl_release(acl); |
433 | return error; | 420 | return error; |
434 | } | 421 | } |
435 | 422 | ||
436 | static int | ||
437 | ext2_xattr_set_acl_access(struct inode *inode, const char *name, | ||
438 | const void *value, size_t size, int flags) | ||
439 | { | ||
440 | if (strcmp(name, "") != 0) | ||
441 | return -EINVAL; | ||
442 | return ext2_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
443 | } | ||
444 | |||
445 | static int | ||
446 | ext2_xattr_set_acl_default(struct inode *inode, const char *name, | ||
447 | const void *value, size_t size, int flags) | ||
448 | { | ||
449 | if (strcmp(name, "") != 0) | ||
450 | return -EINVAL; | ||
451 | return ext2_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
452 | } | ||
453 | |||
454 | struct xattr_handler ext2_xattr_acl_access_handler = { | 423 | struct xattr_handler ext2_xattr_acl_access_handler = { |
455 | .prefix = POSIX_ACL_XATTR_ACCESS, | 424 | .prefix = POSIX_ACL_XATTR_ACCESS, |
425 | .flags = ACL_TYPE_ACCESS, | ||
456 | .list = ext2_xattr_list_acl_access, | 426 | .list = ext2_xattr_list_acl_access, |
457 | .get = ext2_xattr_get_acl_access, | 427 | .get = ext2_xattr_get_acl, |
458 | .set = ext2_xattr_set_acl_access, | 428 | .set = ext2_xattr_set_acl, |
459 | }; | 429 | }; |
460 | 430 | ||
461 | struct xattr_handler ext2_xattr_acl_default_handler = { | 431 | struct xattr_handler ext2_xattr_acl_default_handler = { |
462 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 432 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
433 | .flags = ACL_TYPE_DEFAULT, | ||
463 | .list = ext2_xattr_list_acl_default, | 434 | .list = ext2_xattr_list_acl_default, |
464 | .get = ext2_xattr_get_acl_default, | 435 | .get = ext2_xattr_get_acl, |
465 | .set = ext2_xattr_set_acl_default, | 436 | .set = ext2_xattr_set_acl, |
466 | }; | 437 | }; |
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index 7913531ec6d5..904f00642f84 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/mbcache.h> | 60 | #include <linux/mbcache.h> |
61 | #include <linux/quotaops.h> | 61 | #include <linux/quotaops.h> |
62 | #include <linux/rwsem.h> | 62 | #include <linux/rwsem.h> |
63 | #include <linux/security.h> | ||
63 | #include "ext2.h" | 64 | #include "ext2.h" |
64 | #include "xattr.h" | 65 | #include "xattr.h" |
65 | #include "acl.h" | 66 | #include "acl.h" |
@@ -249,8 +250,9 @@ cleanup: | |||
249 | * used / required on success. | 250 | * used / required on success. |
250 | */ | 251 | */ |
251 | static int | 252 | static int |
252 | ext2_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | 253 | ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
253 | { | 254 | { |
255 | struct inode *inode = dentry->d_inode; | ||
254 | struct buffer_head *bh = NULL; | 256 | struct buffer_head *bh = NULL; |
255 | struct ext2_xattr_entry *entry; | 257 | struct ext2_xattr_entry *entry; |
256 | char *end; | 258 | char *end; |
@@ -300,9 +302,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list", | |||
300 | ext2_xattr_handler(entry->e_name_index); | 302 | ext2_xattr_handler(entry->e_name_index); |
301 | 303 | ||
302 | if (handler) { | 304 | if (handler) { |
303 | size_t size = handler->list(inode, buffer, rest, | 305 | size_t size = handler->list(dentry, buffer, rest, |
304 | entry->e_name, | 306 | entry->e_name, |
305 | entry->e_name_len); | 307 | entry->e_name_len, |
308 | handler->flags); | ||
306 | if (buffer) { | 309 | if (buffer) { |
307 | if (size > rest) { | 310 | if (size > rest) { |
308 | error = -ERANGE; | 311 | error = -ERANGE; |
@@ -330,7 +333,7 @@ cleanup: | |||
330 | ssize_t | 333 | ssize_t |
331 | ext2_listxattr(struct dentry *dentry, char *buffer, size_t size) | 334 | ext2_listxattr(struct dentry *dentry, char *buffer, size_t size) |
332 | { | 335 | { |
333 | return ext2_xattr_list(dentry->d_inode, buffer, size); | 336 | return ext2_xattr_list(dentry, buffer, size); |
334 | } | 337 | } |
335 | 338 | ||
336 | /* | 339 | /* |
diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c index 70c0dbdcdcb7..c8155845ac05 100644 --- a/fs/ext2/xattr_security.c +++ b/fs/ext2/xattr_security.c | |||
@@ -11,8 +11,8 @@ | |||
11 | #include "xattr.h" | 11 | #include "xattr.h" |
12 | 12 | ||
13 | static size_t | 13 | static size_t |
14 | ext2_xattr_security_list(struct inode *inode, char *list, size_t list_size, | 14 | ext2_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, |
15 | const char *name, size_t name_len) | 15 | const char *name, size_t name_len, int type) |
16 | { | 16 | { |
17 | const int prefix_len = XATTR_SECURITY_PREFIX_LEN; | 17 | const int prefix_len = XATTR_SECURITY_PREFIX_LEN; |
18 | const size_t total_len = prefix_len + name_len + 1; | 18 | const size_t total_len = prefix_len + name_len + 1; |
@@ -26,22 +26,22 @@ ext2_xattr_security_list(struct inode *inode, char *list, size_t list_size, | |||
26 | } | 26 | } |
27 | 27 | ||
28 | static int | 28 | static int |
29 | ext2_xattr_security_get(struct inode *inode, const char *name, | 29 | ext2_xattr_security_get(struct dentry *dentry, const char *name, |
30 | void *buffer, size_t size) | 30 | void *buffer, size_t size, int type) |
31 | { | 31 | { |
32 | if (strcmp(name, "") == 0) | 32 | if (strcmp(name, "") == 0) |
33 | return -EINVAL; | 33 | return -EINVAL; |
34 | return ext2_xattr_get(inode, EXT2_XATTR_INDEX_SECURITY, name, | 34 | return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_SECURITY, name, |
35 | buffer, size); | 35 | buffer, size); |
36 | } | 36 | } |
37 | 37 | ||
38 | static int | 38 | static int |
39 | ext2_xattr_security_set(struct inode *inode, const char *name, | 39 | ext2_xattr_security_set(struct dentry *dentry, const char *name, |
40 | const void *value, size_t size, int flags) | 40 | const void *value, size_t size, int flags, int type) |
41 | { | 41 | { |
42 | if (strcmp(name, "") == 0) | 42 | if (strcmp(name, "") == 0) |
43 | return -EINVAL; | 43 | return -EINVAL; |
44 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, name, | 44 | return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_SECURITY, name, |
45 | value, size, flags); | 45 | value, size, flags); |
46 | } | 46 | } |
47 | 47 | ||
diff --git a/fs/ext2/xattr_trusted.c b/fs/ext2/xattr_trusted.c index e8219f8eae9f..2a26d71f4771 100644 --- a/fs/ext2/xattr_trusted.c +++ b/fs/ext2/xattr_trusted.c | |||
@@ -13,8 +13,8 @@ | |||
13 | #include "xattr.h" | 13 | #include "xattr.h" |
14 | 14 | ||
15 | static size_t | 15 | static size_t |
16 | ext2_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | 16 | ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, |
17 | const char *name, size_t name_len) | 17 | const char *name, size_t name_len, int type) |
18 | { | 18 | { |
19 | const int prefix_len = XATTR_TRUSTED_PREFIX_LEN; | 19 | const int prefix_len = XATTR_TRUSTED_PREFIX_LEN; |
20 | const size_t total_len = prefix_len + name_len + 1; | 20 | const size_t total_len = prefix_len + name_len + 1; |
@@ -31,22 +31,22 @@ ext2_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | |||
31 | } | 31 | } |
32 | 32 | ||
33 | static int | 33 | static int |
34 | ext2_xattr_trusted_get(struct inode *inode, const char *name, | 34 | ext2_xattr_trusted_get(struct dentry *dentry, const char *name, |
35 | void *buffer, size_t size) | 35 | void *buffer, size_t size, int type) |
36 | { | 36 | { |
37 | if (strcmp(name, "") == 0) | 37 | if (strcmp(name, "") == 0) |
38 | return -EINVAL; | 38 | return -EINVAL; |
39 | return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name, | 39 | return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name, |
40 | buffer, size); | 40 | buffer, size); |
41 | } | 41 | } |
42 | 42 | ||
43 | static int | 43 | static int |
44 | ext2_xattr_trusted_set(struct inode *inode, const char *name, | 44 | ext2_xattr_trusted_set(struct dentry *dentry, const char *name, |
45 | const void *value, size_t size, int flags) | 45 | const void *value, size_t size, int flags, int type) |
46 | { | 46 | { |
47 | if (strcmp(name, "") == 0) | 47 | if (strcmp(name, "") == 0) |
48 | return -EINVAL; | 48 | return -EINVAL; |
49 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name, | 49 | return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name, |
50 | value, size, flags); | 50 | value, size, flags); |
51 | } | 51 | } |
52 | 52 | ||
diff --git a/fs/ext2/xattr_user.c b/fs/ext2/xattr_user.c index 92495d28c62f..3f6caf3684b4 100644 --- a/fs/ext2/xattr_user.c +++ b/fs/ext2/xattr_user.c | |||
@@ -12,13 +12,13 @@ | |||
12 | #include "xattr.h" | 12 | #include "xattr.h" |
13 | 13 | ||
14 | static size_t | 14 | static size_t |
15 | ext2_xattr_user_list(struct inode *inode, char *list, size_t list_size, | 15 | ext2_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, |
16 | const char *name, size_t name_len) | 16 | const char *name, size_t name_len, int type) |
17 | { | 17 | { |
18 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; | 18 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; |
19 | const size_t total_len = prefix_len + name_len + 1; | 19 | const size_t total_len = prefix_len + name_len + 1; |
20 | 20 | ||
21 | if (!test_opt(inode->i_sb, XATTR_USER)) | 21 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
22 | return 0; | 22 | return 0; |
23 | 23 | ||
24 | if (list && total_len <= list_size) { | 24 | if (list && total_len <= list_size) { |
@@ -30,27 +30,28 @@ ext2_xattr_user_list(struct inode *inode, char *list, size_t list_size, | |||
30 | } | 30 | } |
31 | 31 | ||
32 | static int | 32 | static int |
33 | ext2_xattr_user_get(struct inode *inode, const char *name, | 33 | ext2_xattr_user_get(struct dentry *dentry, const char *name, |
34 | void *buffer, size_t size) | 34 | void *buffer, size_t size, int type) |
35 | { | 35 | { |
36 | if (strcmp(name, "") == 0) | 36 | if (strcmp(name, "") == 0) |
37 | return -EINVAL; | 37 | return -EINVAL; |
38 | if (!test_opt(inode->i_sb, XATTR_USER)) | 38 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
39 | return -EOPNOTSUPP; | 39 | return -EOPNOTSUPP; |
40 | return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER, name, buffer, size); | 40 | return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_USER, |
41 | name, buffer, size); | ||
41 | } | 42 | } |
42 | 43 | ||
43 | static int | 44 | static int |
44 | ext2_xattr_user_set(struct inode *inode, const char *name, | 45 | ext2_xattr_user_set(struct dentry *dentry, const char *name, |
45 | const void *value, size_t size, int flags) | 46 | const void *value, size_t size, int flags, int type) |
46 | { | 47 | { |
47 | if (strcmp(name, "") == 0) | 48 | if (strcmp(name, "") == 0) |
48 | return -EINVAL; | 49 | return -EINVAL; |
49 | if (!test_opt(inode->i_sb, XATTR_USER)) | 50 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
50 | return -EOPNOTSUPP; | 51 | return -EOPNOTSUPP; |
51 | 52 | ||
52 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, name, | 53 | return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_USER, |
53 | value, size, flags); | 54 | name, value, size, flags); |
54 | } | 55 | } |
55 | 56 | ||
56 | struct xattr_handler ext2_xattr_user_handler = { | 57 | struct xattr_handler ext2_xattr_user_handler = { |
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c index c9b0df376b5f..82ba34158661 100644 --- a/fs/ext3/acl.c +++ b/fs/ext3/acl.c | |||
@@ -366,12 +366,12 @@ out: | |||
366 | * Extended attribute handlers | 366 | * Extended attribute handlers |
367 | */ | 367 | */ |
368 | static size_t | 368 | static size_t |
369 | ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, | 369 | ext3_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len, |
370 | const char *name, size_t name_len) | 370 | const char *name, size_t name_len, int type) |
371 | { | 371 | { |
372 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | 372 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
373 | 373 | ||
374 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 374 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
375 | return 0; | 375 | return 0; |
376 | if (list && size <= list_len) | 376 | if (list && size <= list_len) |
377 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); | 377 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); |
@@ -379,12 +379,12 @@ ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, | |||
379 | } | 379 | } |
380 | 380 | ||
381 | static size_t | 381 | static size_t |
382 | ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, | 382 | ext3_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len, |
383 | const char *name, size_t name_len) | 383 | const char *name, size_t name_len, int type) |
384 | { | 384 | { |
385 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | 385 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
386 | 386 | ||
387 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 387 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
388 | return 0; | 388 | return 0; |
389 | if (list && size <= list_len) | 389 | if (list && size <= list_len) |
390 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); | 390 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); |
@@ -392,15 +392,18 @@ ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, | |||
392 | } | 392 | } |
393 | 393 | ||
394 | static int | 394 | static int |
395 | ext3_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | 395 | ext3_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, |
396 | size_t size, int type) | ||
396 | { | 397 | { |
397 | struct posix_acl *acl; | 398 | struct posix_acl *acl; |
398 | int error; | 399 | int error; |
399 | 400 | ||
400 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 401 | if (strcmp(name, "") != 0) |
402 | return -EINVAL; | ||
403 | if (!test_opt(dentry->d_sb, POSIX_ACL)) | ||
401 | return -EOPNOTSUPP; | 404 | return -EOPNOTSUPP; |
402 | 405 | ||
403 | acl = ext3_get_acl(inode, type); | 406 | acl = ext3_get_acl(dentry->d_inode, type); |
404 | if (IS_ERR(acl)) | 407 | if (IS_ERR(acl)) |
405 | return PTR_ERR(acl); | 408 | return PTR_ERR(acl); |
406 | if (acl == NULL) | 409 | if (acl == NULL) |
@@ -412,31 +415,16 @@ ext3_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | |||
412 | } | 415 | } |
413 | 416 | ||
414 | static int | 417 | static int |
415 | ext3_xattr_get_acl_access(struct inode *inode, const char *name, | 418 | ext3_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, |
416 | void *buffer, size_t size) | 419 | size_t size, int flags, int type) |
417 | { | ||
418 | if (strcmp(name, "") != 0) | ||
419 | return -EINVAL; | ||
420 | return ext3_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); | ||
421 | } | ||
422 | |||
423 | static int | ||
424 | ext3_xattr_get_acl_default(struct inode *inode, const char *name, | ||
425 | void *buffer, size_t size) | ||
426 | { | ||
427 | if (strcmp(name, "") != 0) | ||
428 | return -EINVAL; | ||
429 | return ext3_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
430 | } | ||
431 | |||
432 | static int | ||
433 | ext3_xattr_set_acl(struct inode *inode, int type, const void *value, | ||
434 | size_t size) | ||
435 | { | 420 | { |
421 | struct inode *inode = dentry->d_inode; | ||
436 | handle_t *handle; | 422 | handle_t *handle; |
437 | struct posix_acl *acl; | 423 | struct posix_acl *acl; |
438 | int error, retries = 0; | 424 | int error, retries = 0; |
439 | 425 | ||
426 | if (strcmp(name, "") != 0) | ||
427 | return -EINVAL; | ||
440 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 428 | if (!test_opt(inode->i_sb, POSIX_ACL)) |
441 | return -EOPNOTSUPP; | 429 | return -EOPNOTSUPP; |
442 | if (!is_owner_or_cap(inode)) | 430 | if (!is_owner_or_cap(inode)) |
@@ -468,34 +456,18 @@ release_and_out: | |||
468 | return error; | 456 | return error; |
469 | } | 457 | } |
470 | 458 | ||
471 | static int | ||
472 | ext3_xattr_set_acl_access(struct inode *inode, const char *name, | ||
473 | const void *value, size_t size, int flags) | ||
474 | { | ||
475 | if (strcmp(name, "") != 0) | ||
476 | return -EINVAL; | ||
477 | return ext3_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
478 | } | ||
479 | |||
480 | static int | ||
481 | ext3_xattr_set_acl_default(struct inode *inode, const char *name, | ||
482 | const void *value, size_t size, int flags) | ||
483 | { | ||
484 | if (strcmp(name, "") != 0) | ||
485 | return -EINVAL; | ||
486 | return ext3_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
487 | } | ||
488 | |||
489 | struct xattr_handler ext3_xattr_acl_access_handler = { | 459 | struct xattr_handler ext3_xattr_acl_access_handler = { |
490 | .prefix = POSIX_ACL_XATTR_ACCESS, | 460 | .prefix = POSIX_ACL_XATTR_ACCESS, |
461 | .flags = ACL_TYPE_ACCESS, | ||
491 | .list = ext3_xattr_list_acl_access, | 462 | .list = ext3_xattr_list_acl_access, |
492 | .get = ext3_xattr_get_acl_access, | 463 | .get = ext3_xattr_get_acl, |
493 | .set = ext3_xattr_set_acl_access, | 464 | .set = ext3_xattr_set_acl, |
494 | }; | 465 | }; |
495 | 466 | ||
496 | struct xattr_handler ext3_xattr_acl_default_handler = { | 467 | struct xattr_handler ext3_xattr_acl_default_handler = { |
497 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 468 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
469 | .flags = ACL_TYPE_DEFAULT, | ||
498 | .list = ext3_xattr_list_acl_default, | 470 | .list = ext3_xattr_list_acl_default, |
499 | .get = ext3_xattr_get_acl_default, | 471 | .get = ext3_xattr_get_acl, |
500 | .set = ext3_xattr_set_acl_default, | 472 | .set = ext3_xattr_set_acl, |
501 | }; | 473 | }; |
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c index 387d92d00b97..66895ccf76c7 100644 --- a/fs/ext3/xattr.c +++ b/fs/ext3/xattr.c | |||
@@ -99,7 +99,7 @@ static struct buffer_head *ext3_xattr_cache_find(struct inode *, | |||
99 | struct mb_cache_entry **); | 99 | struct mb_cache_entry **); |
100 | static void ext3_xattr_rehash(struct ext3_xattr_header *, | 100 | static void ext3_xattr_rehash(struct ext3_xattr_header *, |
101 | struct ext3_xattr_entry *); | 101 | struct ext3_xattr_entry *); |
102 | static int ext3_xattr_list(struct inode *inode, char *buffer, | 102 | static int ext3_xattr_list(struct dentry *dentry, char *buffer, |
103 | size_t buffer_size); | 103 | size_t buffer_size); |
104 | 104 | ||
105 | static struct mb_cache *ext3_xattr_cache; | 105 | static struct mb_cache *ext3_xattr_cache; |
@@ -147,7 +147,7 @@ ext3_xattr_handler(int name_index) | |||
147 | ssize_t | 147 | ssize_t |
148 | ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) | 148 | ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) |
149 | { | 149 | { |
150 | return ext3_xattr_list(dentry->d_inode, buffer, size); | 150 | return ext3_xattr_list(dentry, buffer, size); |
151 | } | 151 | } |
152 | 152 | ||
153 | static int | 153 | static int |
@@ -332,7 +332,7 @@ ext3_xattr_get(struct inode *inode, int name_index, const char *name, | |||
332 | } | 332 | } |
333 | 333 | ||
334 | static int | 334 | static int |
335 | ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | 335 | ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry, |
336 | char *buffer, size_t buffer_size) | 336 | char *buffer, size_t buffer_size) |
337 | { | 337 | { |
338 | size_t rest = buffer_size; | 338 | size_t rest = buffer_size; |
@@ -342,9 +342,10 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | |||
342 | ext3_xattr_handler(entry->e_name_index); | 342 | ext3_xattr_handler(entry->e_name_index); |
343 | 343 | ||
344 | if (handler) { | 344 | if (handler) { |
345 | size_t size = handler->list(inode, buffer, rest, | 345 | size_t size = handler->list(dentry, buffer, rest, |
346 | entry->e_name, | 346 | entry->e_name, |
347 | entry->e_name_len); | 347 | entry->e_name_len, |
348 | handler->flags); | ||
348 | if (buffer) { | 349 | if (buffer) { |
349 | if (size > rest) | 350 | if (size > rest) |
350 | return -ERANGE; | 351 | return -ERANGE; |
@@ -357,8 +358,9 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | |||
357 | } | 358 | } |
358 | 359 | ||
359 | static int | 360 | static int |
360 | ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | 361 | ext3_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
361 | { | 362 | { |
363 | struct inode *inode = dentry->d_inode; | ||
362 | struct buffer_head *bh = NULL; | 364 | struct buffer_head *bh = NULL; |
363 | int error; | 365 | int error; |
364 | 366 | ||
@@ -383,7 +385,7 @@ ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
383 | goto cleanup; | 385 | goto cleanup; |
384 | } | 386 | } |
385 | ext3_xattr_cache_insert(bh); | 387 | ext3_xattr_cache_insert(bh); |
386 | error = ext3_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size); | 388 | error = ext3_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); |
387 | 389 | ||
388 | cleanup: | 390 | cleanup: |
389 | brelse(bh); | 391 | brelse(bh); |
@@ -392,8 +394,9 @@ cleanup: | |||
392 | } | 394 | } |
393 | 395 | ||
394 | static int | 396 | static int |
395 | ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | 397 | ext3_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
396 | { | 398 | { |
399 | struct inode *inode = dentry->d_inode; | ||
397 | struct ext3_xattr_ibody_header *header; | 400 | struct ext3_xattr_ibody_header *header; |
398 | struct ext3_inode *raw_inode; | 401 | struct ext3_inode *raw_inode; |
399 | struct ext3_iloc iloc; | 402 | struct ext3_iloc iloc; |
@@ -411,7 +414,7 @@ ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
411 | error = ext3_xattr_check_names(IFIRST(header), end); | 414 | error = ext3_xattr_check_names(IFIRST(header), end); |
412 | if (error) | 415 | if (error) |
413 | goto cleanup; | 416 | goto cleanup; |
414 | error = ext3_xattr_list_entries(inode, IFIRST(header), | 417 | error = ext3_xattr_list_entries(dentry, IFIRST(header), |
415 | buffer, buffer_size); | 418 | buffer, buffer_size); |
416 | 419 | ||
417 | cleanup: | 420 | cleanup: |
@@ -430,12 +433,12 @@ cleanup: | |||
430 | * used / required on success. | 433 | * used / required on success. |
431 | */ | 434 | */ |
432 | static int | 435 | static int |
433 | ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | 436 | ext3_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
434 | { | 437 | { |
435 | int i_error, b_error; | 438 | int i_error, b_error; |
436 | 439 | ||
437 | down_read(&EXT3_I(inode)->xattr_sem); | 440 | down_read(&EXT3_I(dentry->d_inode)->xattr_sem); |
438 | i_error = ext3_xattr_ibody_list(inode, buffer, buffer_size); | 441 | i_error = ext3_xattr_ibody_list(dentry, buffer, buffer_size); |
439 | if (i_error < 0) { | 442 | if (i_error < 0) { |
440 | b_error = 0; | 443 | b_error = 0; |
441 | } else { | 444 | } else { |
@@ -443,11 +446,11 @@ ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
443 | buffer += i_error; | 446 | buffer += i_error; |
444 | buffer_size -= i_error; | 447 | buffer_size -= i_error; |
445 | } | 448 | } |
446 | b_error = ext3_xattr_block_list(inode, buffer, buffer_size); | 449 | b_error = ext3_xattr_block_list(dentry, buffer, buffer_size); |
447 | if (b_error < 0) | 450 | if (b_error < 0) |
448 | i_error = 0; | 451 | i_error = 0; |
449 | } | 452 | } |
450 | up_read(&EXT3_I(inode)->xattr_sem); | 453 | up_read(&EXT3_I(dentry->d_inode)->xattr_sem); |
451 | return i_error + b_error; | 454 | return i_error + b_error; |
452 | } | 455 | } |
453 | 456 | ||
diff --git a/fs/ext3/xattr_security.c b/fs/ext3/xattr_security.c index 37b81097bdf2..474348788dd9 100644 --- a/fs/ext3/xattr_security.c +++ b/fs/ext3/xattr_security.c | |||
@@ -12,8 +12,8 @@ | |||
12 | #include "xattr.h" | 12 | #include "xattr.h" |
13 | 13 | ||
14 | static size_t | 14 | static size_t |
15 | ext3_xattr_security_list(struct inode *inode, char *list, size_t list_size, | 15 | ext3_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, |
16 | const char *name, size_t name_len) | 16 | const char *name, size_t name_len, int type) |
17 | { | 17 | { |
18 | const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; | 18 | const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; |
19 | const size_t total_len = prefix_len + name_len + 1; | 19 | const size_t total_len = prefix_len + name_len + 1; |
@@ -28,23 +28,23 @@ ext3_xattr_security_list(struct inode *inode, char *list, size_t list_size, | |||
28 | } | 28 | } |
29 | 29 | ||
30 | static int | 30 | static int |
31 | ext3_xattr_security_get(struct inode *inode, const char *name, | 31 | ext3_xattr_security_get(struct dentry *dentry, const char *name, |
32 | void *buffer, size_t size) | 32 | void *buffer, size_t size, int type) |
33 | { | 33 | { |
34 | if (strcmp(name, "") == 0) | 34 | if (strcmp(name, "") == 0) |
35 | return -EINVAL; | 35 | return -EINVAL; |
36 | return ext3_xattr_get(inode, EXT3_XATTR_INDEX_SECURITY, name, | 36 | return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_SECURITY, |
37 | buffer, size); | 37 | name, buffer, size); |
38 | } | 38 | } |
39 | 39 | ||
40 | static int | 40 | static int |
41 | ext3_xattr_security_set(struct inode *inode, const char *name, | 41 | ext3_xattr_security_set(struct dentry *dentry, const char *name, |
42 | const void *value, size_t size, int flags) | 42 | const void *value, size_t size, int flags, int type) |
43 | { | 43 | { |
44 | if (strcmp(name, "") == 0) | 44 | if (strcmp(name, "") == 0) |
45 | return -EINVAL; | 45 | return -EINVAL; |
46 | return ext3_xattr_set(inode, EXT3_XATTR_INDEX_SECURITY, name, | 46 | return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_SECURITY, |
47 | value, size, flags); | 47 | name, value, size, flags); |
48 | } | 48 | } |
49 | 49 | ||
50 | int | 50 | int |
diff --git a/fs/ext3/xattr_trusted.c b/fs/ext3/xattr_trusted.c index c7c41a410c4b..e5562845ed96 100644 --- a/fs/ext3/xattr_trusted.c +++ b/fs/ext3/xattr_trusted.c | |||
@@ -14,8 +14,8 @@ | |||
14 | #include "xattr.h" | 14 | #include "xattr.h" |
15 | 15 | ||
16 | static size_t | 16 | static size_t |
17 | ext3_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | 17 | ext3_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, |
18 | const char *name, size_t name_len) | 18 | const char *name, size_t name_len, int type) |
19 | { | 19 | { |
20 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; | 20 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; |
21 | const size_t total_len = prefix_len + name_len + 1; | 21 | const size_t total_len = prefix_len + name_len + 1; |
@@ -32,22 +32,22 @@ ext3_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | |||
32 | } | 32 | } |
33 | 33 | ||
34 | static int | 34 | static int |
35 | ext3_xattr_trusted_get(struct inode *inode, const char *name, | 35 | ext3_xattr_trusted_get(struct dentry *dentry, const char *name, |
36 | void *buffer, size_t size) | 36 | void *buffer, size_t size, int type) |
37 | { | 37 | { |
38 | if (strcmp(name, "") == 0) | 38 | if (strcmp(name, "") == 0) |
39 | return -EINVAL; | 39 | return -EINVAL; |
40 | return ext3_xattr_get(inode, EXT3_XATTR_INDEX_TRUSTED, name, | 40 | return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_TRUSTED, |
41 | buffer, size); | 41 | name, buffer, size); |
42 | } | 42 | } |
43 | 43 | ||
44 | static int | 44 | static int |
45 | ext3_xattr_trusted_set(struct inode *inode, const char *name, | 45 | ext3_xattr_trusted_set(struct dentry *dentry, const char *name, |
46 | const void *value, size_t size, int flags) | 46 | const void *value, size_t size, int flags, int type) |
47 | { | 47 | { |
48 | if (strcmp(name, "") == 0) | 48 | if (strcmp(name, "") == 0) |
49 | return -EINVAL; | 49 | return -EINVAL; |
50 | return ext3_xattr_set(inode, EXT3_XATTR_INDEX_TRUSTED, name, | 50 | return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_TRUSTED, name, |
51 | value, size, flags); | 51 | value, size, flags); |
52 | } | 52 | } |
53 | 53 | ||
diff --git a/fs/ext3/xattr_user.c b/fs/ext3/xattr_user.c index 430fe63b31b3..3bcfe9ee0a68 100644 --- a/fs/ext3/xattr_user.c +++ b/fs/ext3/xattr_user.c | |||
@@ -13,13 +13,13 @@ | |||
13 | #include "xattr.h" | 13 | #include "xattr.h" |
14 | 14 | ||
15 | static size_t | 15 | static size_t |
16 | ext3_xattr_user_list(struct inode *inode, char *list, size_t list_size, | 16 | ext3_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, |
17 | const char *name, size_t name_len) | 17 | const char *name, size_t name_len, int type) |
18 | { | 18 | { |
19 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; | 19 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; |
20 | const size_t total_len = prefix_len + name_len + 1; | 20 | const size_t total_len = prefix_len + name_len + 1; |
21 | 21 | ||
22 | if (!test_opt(inode->i_sb, XATTR_USER)) | 22 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
23 | return 0; | 23 | return 0; |
24 | 24 | ||
25 | if (list && total_len <= list_size) { | 25 | if (list && total_len <= list_size) { |
@@ -31,26 +31,27 @@ ext3_xattr_user_list(struct inode *inode, char *list, size_t list_size, | |||
31 | } | 31 | } |
32 | 32 | ||
33 | static int | 33 | static int |
34 | ext3_xattr_user_get(struct inode *inode, const char *name, | 34 | ext3_xattr_user_get(struct dentry *dentry, const char *name, void *buffer, |
35 | void *buffer, size_t size) | 35 | size_t size, int type) |
36 | { | 36 | { |
37 | if (strcmp(name, "") == 0) | 37 | if (strcmp(name, "") == 0) |
38 | return -EINVAL; | 38 | return -EINVAL; |
39 | if (!test_opt(inode->i_sb, XATTR_USER)) | 39 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
40 | return -EOPNOTSUPP; | 40 | return -EOPNOTSUPP; |
41 | return ext3_xattr_get(inode, EXT3_XATTR_INDEX_USER, name, buffer, size); | 41 | return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_USER, |
42 | name, buffer, size); | ||
42 | } | 43 | } |
43 | 44 | ||
44 | static int | 45 | static int |
45 | ext3_xattr_user_set(struct inode *inode, const char *name, | 46 | ext3_xattr_user_set(struct dentry *dentry, const char *name, |
46 | const void *value, size_t size, int flags) | 47 | const void *value, size_t size, int flags, int type) |
47 | { | 48 | { |
48 | if (strcmp(name, "") == 0) | 49 | if (strcmp(name, "") == 0) |
49 | return -EINVAL; | 50 | return -EINVAL; |
50 | if (!test_opt(inode->i_sb, XATTR_USER)) | 51 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
51 | return -EOPNOTSUPP; | 52 | return -EOPNOTSUPP; |
52 | return ext3_xattr_set(inode, EXT3_XATTR_INDEX_USER, name, | 53 | return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_USER, |
53 | value, size, flags); | 54 | name, value, size, flags); |
54 | } | 55 | } |
55 | 56 | ||
56 | struct xattr_handler ext3_xattr_user_handler = { | 57 | struct xattr_handler ext3_xattr_user_handler = { |
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index 0df88b2a69b0..8a2a29d35a6f 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c | |||
@@ -364,12 +364,12 @@ out: | |||
364 | * Extended attribute handlers | 364 | * Extended attribute handlers |
365 | */ | 365 | */ |
366 | static size_t | 366 | static size_t |
367 | ext4_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, | 367 | ext4_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len, |
368 | const char *name, size_t name_len) | 368 | const char *name, size_t name_len, int type) |
369 | { | 369 | { |
370 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | 370 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
371 | 371 | ||
372 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 372 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
373 | return 0; | 373 | return 0; |
374 | if (list && size <= list_len) | 374 | if (list && size <= list_len) |
375 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); | 375 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); |
@@ -377,12 +377,12 @@ ext4_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, | |||
377 | } | 377 | } |
378 | 378 | ||
379 | static size_t | 379 | static size_t |
380 | ext4_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, | 380 | ext4_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len, |
381 | const char *name, size_t name_len) | 381 | const char *name, size_t name_len, int type) |
382 | { | 382 | { |
383 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | 383 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
384 | 384 | ||
385 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 385 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
386 | return 0; | 386 | return 0; |
387 | if (list && size <= list_len) | 387 | if (list && size <= list_len) |
388 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); | 388 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); |
@@ -390,15 +390,18 @@ ext4_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, | |||
390 | } | 390 | } |
391 | 391 | ||
392 | static int | 392 | static int |
393 | ext4_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | 393 | ext4_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, |
394 | size_t size, int type) | ||
394 | { | 395 | { |
395 | struct posix_acl *acl; | 396 | struct posix_acl *acl; |
396 | int error; | 397 | int error; |
397 | 398 | ||
398 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 399 | if (strcmp(name, "") != 0) |
400 | return -EINVAL; | ||
401 | if (!test_opt(dentry->d_sb, POSIX_ACL)) | ||
399 | return -EOPNOTSUPP; | 402 | return -EOPNOTSUPP; |
400 | 403 | ||
401 | acl = ext4_get_acl(inode, type); | 404 | acl = ext4_get_acl(dentry->d_inode, type); |
402 | if (IS_ERR(acl)) | 405 | if (IS_ERR(acl)) |
403 | return PTR_ERR(acl); | 406 | return PTR_ERR(acl); |
404 | if (acl == NULL) | 407 | if (acl == NULL) |
@@ -410,31 +413,16 @@ ext4_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | |||
410 | } | 413 | } |
411 | 414 | ||
412 | static int | 415 | static int |
413 | ext4_xattr_get_acl_access(struct inode *inode, const char *name, | 416 | ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, |
414 | void *buffer, size_t size) | 417 | size_t size, int flags, int type) |
415 | { | ||
416 | if (strcmp(name, "") != 0) | ||
417 | return -EINVAL; | ||
418 | return ext4_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); | ||
419 | } | ||
420 | |||
421 | static int | ||
422 | ext4_xattr_get_acl_default(struct inode *inode, const char *name, | ||
423 | void *buffer, size_t size) | ||
424 | { | ||
425 | if (strcmp(name, "") != 0) | ||
426 | return -EINVAL; | ||
427 | return ext4_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
428 | } | ||
429 | |||
430 | static int | ||
431 | ext4_xattr_set_acl(struct inode *inode, int type, const void *value, | ||
432 | size_t size) | ||
433 | { | 418 | { |
419 | struct inode *inode = dentry->d_inode; | ||
434 | handle_t *handle; | 420 | handle_t *handle; |
435 | struct posix_acl *acl; | 421 | struct posix_acl *acl; |
436 | int error, retries = 0; | 422 | int error, retries = 0; |
437 | 423 | ||
424 | if (strcmp(name, "") != 0) | ||
425 | return -EINVAL; | ||
438 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 426 | if (!test_opt(inode->i_sb, POSIX_ACL)) |
439 | return -EOPNOTSUPP; | 427 | return -EOPNOTSUPP; |
440 | if (!is_owner_or_cap(inode)) | 428 | if (!is_owner_or_cap(inode)) |
@@ -466,34 +454,18 @@ release_and_out: | |||
466 | return error; | 454 | return error; |
467 | } | 455 | } |
468 | 456 | ||
469 | static int | ||
470 | ext4_xattr_set_acl_access(struct inode *inode, const char *name, | ||
471 | const void *value, size_t size, int flags) | ||
472 | { | ||
473 | if (strcmp(name, "") != 0) | ||
474 | return -EINVAL; | ||
475 | return ext4_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
476 | } | ||
477 | |||
478 | static int | ||
479 | ext4_xattr_set_acl_default(struct inode *inode, const char *name, | ||
480 | const void *value, size_t size, int flags) | ||
481 | { | ||
482 | if (strcmp(name, "") != 0) | ||
483 | return -EINVAL; | ||
484 | return ext4_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
485 | } | ||
486 | |||
487 | struct xattr_handler ext4_xattr_acl_access_handler = { | 457 | struct xattr_handler ext4_xattr_acl_access_handler = { |
488 | .prefix = POSIX_ACL_XATTR_ACCESS, | 458 | .prefix = POSIX_ACL_XATTR_ACCESS, |
459 | .flags = ACL_TYPE_ACCESS, | ||
489 | .list = ext4_xattr_list_acl_access, | 460 | .list = ext4_xattr_list_acl_access, |
490 | .get = ext4_xattr_get_acl_access, | 461 | .get = ext4_xattr_get_acl, |
491 | .set = ext4_xattr_set_acl_access, | 462 | .set = ext4_xattr_set_acl, |
492 | }; | 463 | }; |
493 | 464 | ||
494 | struct xattr_handler ext4_xattr_acl_default_handler = { | 465 | struct xattr_handler ext4_xattr_acl_default_handler = { |
495 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 466 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
467 | .flags = ACL_TYPE_DEFAULT, | ||
496 | .list = ext4_xattr_list_acl_default, | 468 | .list = ext4_xattr_list_acl_default, |
497 | .get = ext4_xattr_get_acl_default, | 469 | .get = ext4_xattr_get_acl, |
498 | .set = ext4_xattr_set_acl_default, | 470 | .set = ext4_xattr_set_acl, |
499 | }; | 471 | }; |
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 910bf9a59cb3..83218bebbc7c 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -92,7 +92,7 @@ static struct buffer_head *ext4_xattr_cache_find(struct inode *, | |||
92 | struct mb_cache_entry **); | 92 | struct mb_cache_entry **); |
93 | static void ext4_xattr_rehash(struct ext4_xattr_header *, | 93 | static void ext4_xattr_rehash(struct ext4_xattr_header *, |
94 | struct ext4_xattr_entry *); | 94 | struct ext4_xattr_entry *); |
95 | static int ext4_xattr_list(struct inode *inode, char *buffer, | 95 | static int ext4_xattr_list(struct dentry *dentry, char *buffer, |
96 | size_t buffer_size); | 96 | size_t buffer_size); |
97 | 97 | ||
98 | static struct mb_cache *ext4_xattr_cache; | 98 | static struct mb_cache *ext4_xattr_cache; |
@@ -140,7 +140,7 @@ ext4_xattr_handler(int name_index) | |||
140 | ssize_t | 140 | ssize_t |
141 | ext4_listxattr(struct dentry *dentry, char *buffer, size_t size) | 141 | ext4_listxattr(struct dentry *dentry, char *buffer, size_t size) |
142 | { | 142 | { |
143 | return ext4_xattr_list(dentry->d_inode, buffer, size); | 143 | return ext4_xattr_list(dentry, buffer, size); |
144 | } | 144 | } |
145 | 145 | ||
146 | static int | 146 | static int |
@@ -325,7 +325,7 @@ ext4_xattr_get(struct inode *inode, int name_index, const char *name, | |||
325 | } | 325 | } |
326 | 326 | ||
327 | static int | 327 | static int |
328 | ext4_xattr_list_entries(struct inode *inode, struct ext4_xattr_entry *entry, | 328 | ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry, |
329 | char *buffer, size_t buffer_size) | 329 | char *buffer, size_t buffer_size) |
330 | { | 330 | { |
331 | size_t rest = buffer_size; | 331 | size_t rest = buffer_size; |
@@ -335,9 +335,10 @@ ext4_xattr_list_entries(struct inode *inode, struct ext4_xattr_entry *entry, | |||
335 | ext4_xattr_handler(entry->e_name_index); | 335 | ext4_xattr_handler(entry->e_name_index); |
336 | 336 | ||
337 | if (handler) { | 337 | if (handler) { |
338 | size_t size = handler->list(inode, buffer, rest, | 338 | size_t size = handler->list(dentry, buffer, rest, |
339 | entry->e_name, | 339 | entry->e_name, |
340 | entry->e_name_len); | 340 | entry->e_name_len, |
341 | handler->flags); | ||
341 | if (buffer) { | 342 | if (buffer) { |
342 | if (size > rest) | 343 | if (size > rest) |
343 | return -ERANGE; | 344 | return -ERANGE; |
@@ -350,8 +351,9 @@ ext4_xattr_list_entries(struct inode *inode, struct ext4_xattr_entry *entry, | |||
350 | } | 351 | } |
351 | 352 | ||
352 | static int | 353 | static int |
353 | ext4_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | 354 | ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
354 | { | 355 | { |
356 | struct inode *inode = dentry->d_inode; | ||
355 | struct buffer_head *bh = NULL; | 357 | struct buffer_head *bh = NULL; |
356 | int error; | 358 | int error; |
357 | 359 | ||
@@ -376,7 +378,7 @@ ext4_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
376 | goto cleanup; | 378 | goto cleanup; |
377 | } | 379 | } |
378 | ext4_xattr_cache_insert(bh); | 380 | ext4_xattr_cache_insert(bh); |
379 | error = ext4_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size); | 381 | error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); |
380 | 382 | ||
381 | cleanup: | 383 | cleanup: |
382 | brelse(bh); | 384 | brelse(bh); |
@@ -385,8 +387,9 @@ cleanup: | |||
385 | } | 387 | } |
386 | 388 | ||
387 | static int | 389 | static int |
388 | ext4_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | 390 | ext4_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
389 | { | 391 | { |
392 | struct inode *inode = dentry->d_inode; | ||
390 | struct ext4_xattr_ibody_header *header; | 393 | struct ext4_xattr_ibody_header *header; |
391 | struct ext4_inode *raw_inode; | 394 | struct ext4_inode *raw_inode; |
392 | struct ext4_iloc iloc; | 395 | struct ext4_iloc iloc; |
@@ -404,7 +407,7 @@ ext4_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
404 | error = ext4_xattr_check_names(IFIRST(header), end); | 407 | error = ext4_xattr_check_names(IFIRST(header), end); |
405 | if (error) | 408 | if (error) |
406 | goto cleanup; | 409 | goto cleanup; |
407 | error = ext4_xattr_list_entries(inode, IFIRST(header), | 410 | error = ext4_xattr_list_entries(dentry, IFIRST(header), |
408 | buffer, buffer_size); | 411 | buffer, buffer_size); |
409 | 412 | ||
410 | cleanup: | 413 | cleanup: |
@@ -423,12 +426,12 @@ cleanup: | |||
423 | * used / required on success. | 426 | * used / required on success. |
424 | */ | 427 | */ |
425 | static int | 428 | static int |
426 | ext4_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | 429 | ext4_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
427 | { | 430 | { |
428 | int i_error, b_error; | 431 | int i_error, b_error; |
429 | 432 | ||
430 | down_read(&EXT4_I(inode)->xattr_sem); | 433 | down_read(&EXT4_I(dentry->d_inode)->xattr_sem); |
431 | i_error = ext4_xattr_ibody_list(inode, buffer, buffer_size); | 434 | i_error = ext4_xattr_ibody_list(dentry, buffer, buffer_size); |
432 | if (i_error < 0) { | 435 | if (i_error < 0) { |
433 | b_error = 0; | 436 | b_error = 0; |
434 | } else { | 437 | } else { |
@@ -436,11 +439,11 @@ ext4_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
436 | buffer += i_error; | 439 | buffer += i_error; |
437 | buffer_size -= i_error; | 440 | buffer_size -= i_error; |
438 | } | 441 | } |
439 | b_error = ext4_xattr_block_list(inode, buffer, buffer_size); | 442 | b_error = ext4_xattr_block_list(dentry, buffer, buffer_size); |
440 | if (b_error < 0) | 443 | if (b_error < 0) |
441 | i_error = 0; | 444 | i_error = 0; |
442 | } | 445 | } |
443 | up_read(&EXT4_I(inode)->xattr_sem); | 446 | up_read(&EXT4_I(dentry->d_inode)->xattr_sem); |
444 | return i_error + b_error; | 447 | return i_error + b_error; |
445 | } | 448 | } |
446 | 449 | ||
diff --git a/fs/ext4/xattr_security.c b/fs/ext4/xattr_security.c index ca5f89fc6cae..983c253999a7 100644 --- a/fs/ext4/xattr_security.c +++ b/fs/ext4/xattr_security.c | |||
@@ -12,8 +12,8 @@ | |||
12 | #include "xattr.h" | 12 | #include "xattr.h" |
13 | 13 | ||
14 | static size_t | 14 | static size_t |
15 | ext4_xattr_security_list(struct inode *inode, char *list, size_t list_size, | 15 | ext4_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, |
16 | const char *name, size_t name_len) | 16 | const char *name, size_t name_len, int type) |
17 | { | 17 | { |
18 | const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1; | 18 | const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1; |
19 | const size_t total_len = prefix_len + name_len + 1; | 19 | const size_t total_len = prefix_len + name_len + 1; |
@@ -28,23 +28,23 @@ ext4_xattr_security_list(struct inode *inode, char *list, size_t list_size, | |||
28 | } | 28 | } |
29 | 29 | ||
30 | static int | 30 | static int |
31 | ext4_xattr_security_get(struct inode *inode, const char *name, | 31 | ext4_xattr_security_get(struct dentry *dentry, const char *name, |
32 | void *buffer, size_t size) | 32 | void *buffer, size_t size, int type) |
33 | { | 33 | { |
34 | if (strcmp(name, "") == 0) | 34 | if (strcmp(name, "") == 0) |
35 | return -EINVAL; | 35 | return -EINVAL; |
36 | return ext4_xattr_get(inode, EXT4_XATTR_INDEX_SECURITY, name, | 36 | return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_SECURITY, |
37 | buffer, size); | 37 | name, buffer, size); |
38 | } | 38 | } |
39 | 39 | ||
40 | static int | 40 | static int |
41 | ext4_xattr_security_set(struct inode *inode, const char *name, | 41 | ext4_xattr_security_set(struct dentry *dentry, const char *name, |
42 | const void *value, size_t size, int flags) | 42 | const void *value, size_t size, int flags, int type) |
43 | { | 43 | { |
44 | if (strcmp(name, "") == 0) | 44 | if (strcmp(name, "") == 0) |
45 | return -EINVAL; | 45 | return -EINVAL; |
46 | return ext4_xattr_set(inode, EXT4_XATTR_INDEX_SECURITY, name, | 46 | return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_SECURITY, |
47 | value, size, flags); | 47 | name, value, size, flags); |
48 | } | 48 | } |
49 | 49 | ||
50 | int | 50 | int |
diff --git a/fs/ext4/xattr_trusted.c b/fs/ext4/xattr_trusted.c index ac1a52cf2a37..15b50edc6587 100644 --- a/fs/ext4/xattr_trusted.c +++ b/fs/ext4/xattr_trusted.c | |||
@@ -14,8 +14,8 @@ | |||
14 | #include "xattr.h" | 14 | #include "xattr.h" |
15 | 15 | ||
16 | static size_t | 16 | static size_t |
17 | ext4_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | 17 | ext4_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, |
18 | const char *name, size_t name_len) | 18 | const char *name, size_t name_len, int type) |
19 | { | 19 | { |
20 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; | 20 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; |
21 | const size_t total_len = prefix_len + name_len + 1; | 21 | const size_t total_len = prefix_len + name_len + 1; |
@@ -32,23 +32,23 @@ ext4_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | |||
32 | } | 32 | } |
33 | 33 | ||
34 | static int | 34 | static int |
35 | ext4_xattr_trusted_get(struct inode *inode, const char *name, | 35 | ext4_xattr_trusted_get(struct dentry *dentry, const char *name, void *buffer, |
36 | void *buffer, size_t size) | 36 | size_t size, int type) |
37 | { | 37 | { |
38 | if (strcmp(name, "") == 0) | 38 | if (strcmp(name, "") == 0) |
39 | return -EINVAL; | 39 | return -EINVAL; |
40 | return ext4_xattr_get(inode, EXT4_XATTR_INDEX_TRUSTED, name, | 40 | return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_TRUSTED, |
41 | buffer, size); | 41 | name, buffer, size); |
42 | } | 42 | } |
43 | 43 | ||
44 | static int | 44 | static int |
45 | ext4_xattr_trusted_set(struct inode *inode, const char *name, | 45 | ext4_xattr_trusted_set(struct dentry *dentry, const char *name, |
46 | const void *value, size_t size, int flags) | 46 | const void *value, size_t size, int flags, int type) |
47 | { | 47 | { |
48 | if (strcmp(name, "") == 0) | 48 | if (strcmp(name, "") == 0) |
49 | return -EINVAL; | 49 | return -EINVAL; |
50 | return ext4_xattr_set(inode, EXT4_XATTR_INDEX_TRUSTED, name, | 50 | return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_TRUSTED, |
51 | value, size, flags); | 51 | name, value, size, flags); |
52 | } | 52 | } |
53 | 53 | ||
54 | struct xattr_handler ext4_xattr_trusted_handler = { | 54 | struct xattr_handler ext4_xattr_trusted_handler = { |
diff --git a/fs/ext4/xattr_user.c b/fs/ext4/xattr_user.c index d91aa61b42aa..c4ce05746ce1 100644 --- a/fs/ext4/xattr_user.c +++ b/fs/ext4/xattr_user.c | |||
@@ -13,13 +13,13 @@ | |||
13 | #include "xattr.h" | 13 | #include "xattr.h" |
14 | 14 | ||
15 | static size_t | 15 | static size_t |
16 | ext4_xattr_user_list(struct inode *inode, char *list, size_t list_size, | 16 | ext4_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, |
17 | const char *name, size_t name_len) | 17 | const char *name, size_t name_len, int type) |
18 | { | 18 | { |
19 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; | 19 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; |
20 | const size_t total_len = prefix_len + name_len + 1; | 20 | const size_t total_len = prefix_len + name_len + 1; |
21 | 21 | ||
22 | if (!test_opt(inode->i_sb, XATTR_USER)) | 22 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
23 | return 0; | 23 | return 0; |
24 | 24 | ||
25 | if (list && total_len <= list_size) { | 25 | if (list && total_len <= list_size) { |
@@ -31,26 +31,27 @@ ext4_xattr_user_list(struct inode *inode, char *list, size_t list_size, | |||
31 | } | 31 | } |
32 | 32 | ||
33 | static int | 33 | static int |
34 | ext4_xattr_user_get(struct inode *inode, const char *name, | 34 | ext4_xattr_user_get(struct dentry *dentry, const char *name, |
35 | void *buffer, size_t size) | 35 | void *buffer, size_t size, int type) |
36 | { | 36 | { |
37 | if (strcmp(name, "") == 0) | 37 | if (strcmp(name, "") == 0) |
38 | return -EINVAL; | 38 | return -EINVAL; |
39 | if (!test_opt(inode->i_sb, XATTR_USER)) | 39 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
40 | return -EOPNOTSUPP; | 40 | return -EOPNOTSUPP; |
41 | return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, name, buffer, size); | 41 | return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_USER, |
42 | name, buffer, size); | ||
42 | } | 43 | } |
43 | 44 | ||
44 | static int | 45 | static int |
45 | ext4_xattr_user_set(struct inode *inode, const char *name, | 46 | ext4_xattr_user_set(struct dentry *dentry, const char *name, |
46 | const void *value, size_t size, int flags) | 47 | const void *value, size_t size, int flags, int type) |
47 | { | 48 | { |
48 | if (strcmp(name, "") == 0) | 49 | if (strcmp(name, "") == 0) |
49 | return -EINVAL; | 50 | return -EINVAL; |
50 | if (!test_opt(inode->i_sb, XATTR_USER)) | 51 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
51 | return -EOPNOTSUPP; | 52 | return -EOPNOTSUPP; |
52 | return ext4_xattr_set(inode, EXT4_XATTR_INDEX_USER, name, | 53 | return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_USER, |
53 | value, size, flags); | 54 | name, value, size, flags); |
54 | } | 55 | } |
55 | 56 | ||
56 | struct xattr_handler ext4_xattr_user_handler = { | 57 | struct xattr_handler ext4_xattr_user_handler = { |
diff --git a/fs/file_table.c b/fs/file_table.c index 4bef4c01ec6f..17a55b81be2d 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
@@ -21,9 +21,12 @@ | |||
21 | #include <linux/fsnotify.h> | 21 | #include <linux/fsnotify.h> |
22 | #include <linux/sysctl.h> | 22 | #include <linux/sysctl.h> |
23 | #include <linux/percpu_counter.h> | 23 | #include <linux/percpu_counter.h> |
24 | #include <linux/ima.h> | ||
24 | 25 | ||
25 | #include <asm/atomic.h> | 26 | #include <asm/atomic.h> |
26 | 27 | ||
28 | #include "internal.h" | ||
29 | |||
27 | /* sysctl tunables... */ | 30 | /* sysctl tunables... */ |
28 | struct files_stat_struct files_stat = { | 31 | struct files_stat_struct files_stat = { |
29 | .max_files = NR_FILE | 32 | .max_files = NR_FILE |
@@ -147,8 +150,6 @@ fail: | |||
147 | return NULL; | 150 | return NULL; |
148 | } | 151 | } |
149 | 152 | ||
150 | EXPORT_SYMBOL(get_empty_filp); | ||
151 | |||
152 | /** | 153 | /** |
153 | * alloc_file - allocate and initialize a 'struct file' | 154 | * alloc_file - allocate and initialize a 'struct file' |
154 | * @mnt: the vfsmount on which the file will reside | 155 | * @mnt: the vfsmount on which the file will reside |
@@ -164,8 +165,8 @@ EXPORT_SYMBOL(get_empty_filp); | |||
164 | * If all the callers of init_file() are eliminated, its | 165 | * If all the callers of init_file() are eliminated, its |
165 | * code should be moved into this function. | 166 | * code should be moved into this function. |
166 | */ | 167 | */ |
167 | struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry, | 168 | struct file *alloc_file(struct path *path, fmode_t mode, |
168 | fmode_t mode, const struct file_operations *fop) | 169 | const struct file_operations *fop) |
169 | { | 170 | { |
170 | struct file *file; | 171 | struct file *file; |
171 | 172 | ||
@@ -173,35 +174,8 @@ struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry, | |||
173 | if (!file) | 174 | if (!file) |
174 | return NULL; | 175 | return NULL; |
175 | 176 | ||
176 | init_file(file, mnt, dentry, mode, fop); | 177 | file->f_path = *path; |
177 | return file; | 178 | file->f_mapping = path->dentry->d_inode->i_mapping; |
178 | } | ||
179 | EXPORT_SYMBOL(alloc_file); | ||
180 | |||
181 | /** | ||
182 | * init_file - initialize a 'struct file' | ||
183 | * @file: the already allocated 'struct file' to initialized | ||
184 | * @mnt: the vfsmount on which the file resides | ||
185 | * @dentry: the dentry representing this file | ||
186 | * @mode: the mode the file is opened with | ||
187 | * @fop: the 'struct file_operations' for this file | ||
188 | * | ||
189 | * Use this instead of setting the members directly. Doing so | ||
190 | * avoids making mistakes like forgetting the mntget() or | ||
191 | * forgetting to take a write on the mnt. | ||
192 | * | ||
193 | * Note: This is a crappy interface. It is here to make | ||
194 | * merging with the existing users of get_empty_filp() | ||
195 | * who have complex failure logic easier. All users | ||
196 | * of this should be moving to alloc_file(). | ||
197 | */ | ||
198 | int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry, | ||
199 | fmode_t mode, const struct file_operations *fop) | ||
200 | { | ||
201 | int error = 0; | ||
202 | file->f_path.dentry = dentry; | ||
203 | file->f_path.mnt = mntget(mnt); | ||
204 | file->f_mapping = dentry->d_inode->i_mapping; | ||
205 | file->f_mode = mode; | 179 | file->f_mode = mode; |
206 | file->f_op = fop; | 180 | file->f_op = fop; |
207 | 181 | ||
@@ -211,14 +185,15 @@ int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry, | |||
211 | * visible. We do this for consistency, and so | 185 | * visible. We do this for consistency, and so |
212 | * that we can do debugging checks at __fput() | 186 | * that we can do debugging checks at __fput() |
213 | */ | 187 | */ |
214 | if ((mode & FMODE_WRITE) && !special_file(dentry->d_inode->i_mode)) { | 188 | if ((mode & FMODE_WRITE) && !special_file(path->dentry->d_inode->i_mode)) { |
189 | int error = 0; | ||
215 | file_take_write(file); | 190 | file_take_write(file); |
216 | error = mnt_clone_write(mnt); | 191 | error = mnt_clone_write(path->mnt); |
217 | WARN_ON(error); | 192 | WARN_ON(error); |
218 | } | 193 | } |
219 | return error; | 194 | ima_counts_get(file); |
195 | return file; | ||
220 | } | 196 | } |
221 | EXPORT_SYMBOL(init_file); | ||
222 | 197 | ||
223 | void fput(struct file *file) | 198 | void fput(struct file *file) |
224 | { | 199 | { |
diff --git a/fs/generic_acl.c b/fs/generic_acl.c index e0b53aa7bbec..55458031e501 100644 --- a/fs/generic_acl.c +++ b/fs/generic_acl.c | |||
@@ -1,62 +1,58 @@ | |||
1 | /* | 1 | /* |
2 | * fs/generic_acl.c | ||
3 | * | ||
4 | * (C) 2005 Andreas Gruenbacher <agruen@suse.de> | 2 | * (C) 2005 Andreas Gruenbacher <agruen@suse.de> |
5 | * | 3 | * |
6 | * This file is released under the GPL. | 4 | * This file is released under the GPL. |
5 | * | ||
6 | * Generic ACL support for in-memory filesystems. | ||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/sched.h> | 9 | #include <linux/sched.h> |
10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
11 | #include <linux/generic_acl.h> | 11 | #include <linux/generic_acl.h> |
12 | #include <linux/posix_acl.h> | ||
13 | #include <linux/posix_acl_xattr.h> | ||
12 | 14 | ||
13 | /** | 15 | |
14 | * generic_acl_list - Generic xattr_handler->list() operation | 16 | static size_t |
15 | * @ops: Filesystem specific getacl and setacl callbacks | 17 | generic_acl_list(struct dentry *dentry, char *list, size_t list_size, |
16 | */ | 18 | const char *name, size_t name_len, int type) |
17 | size_t | ||
18 | generic_acl_list(struct inode *inode, struct generic_acl_operations *ops, | ||
19 | int type, char *list, size_t list_size) | ||
20 | { | 19 | { |
21 | struct posix_acl *acl; | 20 | struct posix_acl *acl; |
22 | const char *name; | 21 | const char *xname; |
23 | size_t size; | 22 | size_t size; |
24 | 23 | ||
25 | acl = ops->getacl(inode, type); | 24 | acl = get_cached_acl(dentry->d_inode, type); |
26 | if (!acl) | 25 | if (!acl) |
27 | return 0; | 26 | return 0; |
28 | posix_acl_release(acl); | 27 | posix_acl_release(acl); |
29 | 28 | ||
30 | switch(type) { | 29 | switch (type) { |
31 | case ACL_TYPE_ACCESS: | 30 | case ACL_TYPE_ACCESS: |
32 | name = POSIX_ACL_XATTR_ACCESS; | 31 | xname = POSIX_ACL_XATTR_ACCESS; |
33 | break; | 32 | break; |
34 | 33 | case ACL_TYPE_DEFAULT: | |
35 | case ACL_TYPE_DEFAULT: | 34 | xname = POSIX_ACL_XATTR_DEFAULT; |
36 | name = POSIX_ACL_XATTR_DEFAULT; | 35 | break; |
37 | break; | 36 | default: |
38 | 37 | return 0; | |
39 | default: | ||
40 | return 0; | ||
41 | } | 38 | } |
42 | size = strlen(name) + 1; | 39 | size = strlen(xname) + 1; |
43 | if (list && size <= list_size) | 40 | if (list && size <= list_size) |
44 | memcpy(list, name, size); | 41 | memcpy(list, xname, size); |
45 | return size; | 42 | return size; |
46 | } | 43 | } |
47 | 44 | ||
48 | /** | 45 | static int |
49 | * generic_acl_get - Generic xattr_handler->get() operation | 46 | generic_acl_get(struct dentry *dentry, const char *name, void *buffer, |
50 | * @ops: Filesystem specific getacl and setacl callbacks | 47 | size_t size, int type) |
51 | */ | ||
52 | int | ||
53 | generic_acl_get(struct inode *inode, struct generic_acl_operations *ops, | ||
54 | int type, void *buffer, size_t size) | ||
55 | { | 48 | { |
56 | struct posix_acl *acl; | 49 | struct posix_acl *acl; |
57 | int error; | 50 | int error; |
58 | 51 | ||
59 | acl = ops->getacl(inode, type); | 52 | if (strcmp(name, "") != 0) |
53 | return -EINVAL; | ||
54 | |||
55 | acl = get_cached_acl(dentry->d_inode, type); | ||
60 | if (!acl) | 56 | if (!acl) |
61 | return -ENODATA; | 57 | return -ENODATA; |
62 | error = posix_acl_to_xattr(acl, buffer, size); | 58 | error = posix_acl_to_xattr(acl, buffer, size); |
@@ -65,17 +61,16 @@ generic_acl_get(struct inode *inode, struct generic_acl_operations *ops, | |||
65 | return error; | 61 | return error; |
66 | } | 62 | } |
67 | 63 | ||
68 | /** | 64 | static int |
69 | * generic_acl_set - Generic xattr_handler->set() operation | 65 | generic_acl_set(struct dentry *dentry, const char *name, const void *value, |
70 | * @ops: Filesystem specific getacl and setacl callbacks | 66 | size_t size, int flags, int type) |
71 | */ | ||
72 | int | ||
73 | generic_acl_set(struct inode *inode, struct generic_acl_operations *ops, | ||
74 | int type, const void *value, size_t size) | ||
75 | { | 67 | { |
68 | struct inode *inode = dentry->d_inode; | ||
76 | struct posix_acl *acl = NULL; | 69 | struct posix_acl *acl = NULL; |
77 | int error; | 70 | int error; |
78 | 71 | ||
72 | if (strcmp(name, "") != 0) | ||
73 | return -EINVAL; | ||
79 | if (S_ISLNK(inode->i_mode)) | 74 | if (S_ISLNK(inode->i_mode)) |
80 | return -EOPNOTSUPP; | 75 | return -EOPNOTSUPP; |
81 | if (!is_owner_or_cap(inode)) | 76 | if (!is_owner_or_cap(inode)) |
@@ -91,28 +86,27 @@ generic_acl_set(struct inode *inode, struct generic_acl_operations *ops, | |||
91 | error = posix_acl_valid(acl); | 86 | error = posix_acl_valid(acl); |
92 | if (error) | 87 | if (error) |
93 | goto failed; | 88 | goto failed; |
94 | switch(type) { | 89 | switch (type) { |
95 | case ACL_TYPE_ACCESS: | 90 | case ACL_TYPE_ACCESS: |
96 | mode = inode->i_mode; | 91 | mode = inode->i_mode; |
97 | error = posix_acl_equiv_mode(acl, &mode); | 92 | error = posix_acl_equiv_mode(acl, &mode); |
98 | if (error < 0) | 93 | if (error < 0) |
99 | goto failed; | 94 | goto failed; |
100 | inode->i_mode = mode; | 95 | inode->i_mode = mode; |
101 | if (error == 0) { | 96 | if (error == 0) { |
102 | posix_acl_release(acl); | 97 | posix_acl_release(acl); |
103 | acl = NULL; | 98 | acl = NULL; |
104 | } | 99 | } |
105 | break; | 100 | break; |
106 | 101 | case ACL_TYPE_DEFAULT: | |
107 | case ACL_TYPE_DEFAULT: | 102 | if (!S_ISDIR(inode->i_mode)) { |
108 | if (!S_ISDIR(inode->i_mode)) { | 103 | error = -EINVAL; |
109 | error = -EINVAL; | 104 | goto failed; |
110 | goto failed; | 105 | } |
111 | } | 106 | break; |
112 | break; | ||
113 | } | 107 | } |
114 | } | 108 | } |
115 | ops->setacl(inode, type, acl); | 109 | set_cached_acl(inode, type, acl); |
116 | error = 0; | 110 | error = 0; |
117 | failed: | 111 | failed: |
118 | posix_acl_release(acl); | 112 | posix_acl_release(acl); |
@@ -121,14 +115,12 @@ failed: | |||
121 | 115 | ||
122 | /** | 116 | /** |
123 | * generic_acl_init - Take care of acl inheritance at @inode create time | 117 | * generic_acl_init - Take care of acl inheritance at @inode create time |
124 | * @ops: Filesystem specific getacl and setacl callbacks | ||
125 | * | 118 | * |
126 | * Files created inside a directory with a default ACL inherit the | 119 | * Files created inside a directory with a default ACL inherit the |
127 | * directory's default ACL. | 120 | * directory's default ACL. |
128 | */ | 121 | */ |
129 | int | 122 | int |
130 | generic_acl_init(struct inode *inode, struct inode *dir, | 123 | generic_acl_init(struct inode *inode, struct inode *dir) |
131 | struct generic_acl_operations *ops) | ||
132 | { | 124 | { |
133 | struct posix_acl *acl = NULL; | 125 | struct posix_acl *acl = NULL; |
134 | mode_t mode = inode->i_mode; | 126 | mode_t mode = inode->i_mode; |
@@ -136,7 +128,7 @@ generic_acl_init(struct inode *inode, struct inode *dir, | |||
136 | 128 | ||
137 | inode->i_mode = mode & ~current_umask(); | 129 | inode->i_mode = mode & ~current_umask(); |
138 | if (!S_ISLNK(inode->i_mode)) | 130 | if (!S_ISLNK(inode->i_mode)) |
139 | acl = ops->getacl(dir, ACL_TYPE_DEFAULT); | 131 | acl = get_cached_acl(dir, ACL_TYPE_DEFAULT); |
140 | if (acl) { | 132 | if (acl) { |
141 | struct posix_acl *clone; | 133 | struct posix_acl *clone; |
142 | 134 | ||
@@ -145,7 +137,7 @@ generic_acl_init(struct inode *inode, struct inode *dir, | |||
145 | error = -ENOMEM; | 137 | error = -ENOMEM; |
146 | if (!clone) | 138 | if (!clone) |
147 | goto cleanup; | 139 | goto cleanup; |
148 | ops->setacl(inode, ACL_TYPE_DEFAULT, clone); | 140 | set_cached_acl(inode, ACL_TYPE_DEFAULT, clone); |
149 | posix_acl_release(clone); | 141 | posix_acl_release(clone); |
150 | } | 142 | } |
151 | clone = posix_acl_clone(acl, GFP_KERNEL); | 143 | clone = posix_acl_clone(acl, GFP_KERNEL); |
@@ -156,7 +148,7 @@ generic_acl_init(struct inode *inode, struct inode *dir, | |||
156 | if (error >= 0) { | 148 | if (error >= 0) { |
157 | inode->i_mode = mode; | 149 | inode->i_mode = mode; |
158 | if (error > 0) | 150 | if (error > 0) |
159 | ops->setacl(inode, ACL_TYPE_ACCESS, clone); | 151 | set_cached_acl(inode, ACL_TYPE_ACCESS, clone); |
160 | } | 152 | } |
161 | posix_acl_release(clone); | 153 | posix_acl_release(clone); |
162 | } | 154 | } |
@@ -169,20 +161,19 @@ cleanup: | |||
169 | 161 | ||
170 | /** | 162 | /** |
171 | * generic_acl_chmod - change the access acl of @inode upon chmod() | 163 | * generic_acl_chmod - change the access acl of @inode upon chmod() |
172 | * @ops: FIlesystem specific getacl and setacl callbacks | ||
173 | * | 164 | * |
174 | * A chmod also changes the permissions of the owner, group/mask, and | 165 | * A chmod also changes the permissions of the owner, group/mask, and |
175 | * other ACL entries. | 166 | * other ACL entries. |
176 | */ | 167 | */ |
177 | int | 168 | int |
178 | generic_acl_chmod(struct inode *inode, struct generic_acl_operations *ops) | 169 | generic_acl_chmod(struct inode *inode) |
179 | { | 170 | { |
180 | struct posix_acl *acl, *clone; | 171 | struct posix_acl *acl, *clone; |
181 | int error = 0; | 172 | int error = 0; |
182 | 173 | ||
183 | if (S_ISLNK(inode->i_mode)) | 174 | if (S_ISLNK(inode->i_mode)) |
184 | return -EOPNOTSUPP; | 175 | return -EOPNOTSUPP; |
185 | acl = ops->getacl(inode, ACL_TYPE_ACCESS); | 176 | acl = get_cached_acl(inode, ACL_TYPE_ACCESS); |
186 | if (acl) { | 177 | if (acl) { |
187 | clone = posix_acl_clone(acl, GFP_KERNEL); | 178 | clone = posix_acl_clone(acl, GFP_KERNEL); |
188 | posix_acl_release(acl); | 179 | posix_acl_release(acl); |
@@ -190,8 +181,37 @@ generic_acl_chmod(struct inode *inode, struct generic_acl_operations *ops) | |||
190 | return -ENOMEM; | 181 | return -ENOMEM; |
191 | error = posix_acl_chmod_masq(clone, inode->i_mode); | 182 | error = posix_acl_chmod_masq(clone, inode->i_mode); |
192 | if (!error) | 183 | if (!error) |
193 | ops->setacl(inode, ACL_TYPE_ACCESS, clone); | 184 | set_cached_acl(inode, ACL_TYPE_ACCESS, clone); |
194 | posix_acl_release(clone); | 185 | posix_acl_release(clone); |
195 | } | 186 | } |
196 | return error; | 187 | return error; |
197 | } | 188 | } |
189 | |||
190 | int | ||
191 | generic_check_acl(struct inode *inode, int mask) | ||
192 | { | ||
193 | struct posix_acl *acl = get_cached_acl(inode, ACL_TYPE_ACCESS); | ||
194 | |||
195 | if (acl) { | ||
196 | int error = posix_acl_permission(inode, acl, mask); | ||
197 | posix_acl_release(acl); | ||
198 | return error; | ||
199 | } | ||
200 | return -EAGAIN; | ||
201 | } | ||
202 | |||
203 | struct xattr_handler generic_acl_access_handler = { | ||
204 | .prefix = POSIX_ACL_XATTR_ACCESS, | ||
205 | .flags = ACL_TYPE_ACCESS, | ||
206 | .list = generic_acl_list, | ||
207 | .get = generic_acl_get, | ||
208 | .set = generic_acl_set, | ||
209 | }; | ||
210 | |||
211 | struct xattr_handler generic_acl_default_handler = { | ||
212 | .prefix = POSIX_ACL_XATTR_DEFAULT, | ||
213 | .flags = ACL_TYPE_DEFAULT, | ||
214 | .list = generic_acl_list, | ||
215 | .get = generic_acl_get, | ||
216 | .set = generic_acl_set, | ||
217 | }; | ||
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index 3eb1ea846173..87ee309d4c24 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c | |||
@@ -126,7 +126,7 @@ static int gfs2_acl_set(struct inode *inode, int type, struct posix_acl *acl) | |||
126 | error = posix_acl_to_xattr(acl, data, len); | 126 | error = posix_acl_to_xattr(acl, data, len); |
127 | if (error < 0) | 127 | if (error < 0) |
128 | goto out; | 128 | goto out; |
129 | error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, data, len, 0); | 129 | error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS); |
130 | if (!error) | 130 | if (!error) |
131 | set_cached_acl(inode, type, acl); | 131 | set_cached_acl(inode, type, acl); |
132 | out: | 132 | out: |
@@ -232,9 +232,10 @@ static int gfs2_acl_type(const char *name) | |||
232 | return -EINVAL; | 232 | return -EINVAL; |
233 | } | 233 | } |
234 | 234 | ||
235 | static int gfs2_xattr_system_get(struct inode *inode, const char *name, | 235 | static int gfs2_xattr_system_get(struct dentry *dentry, const char *name, |
236 | void *buffer, size_t size) | 236 | void *buffer, size_t size, int xtype) |
237 | { | 237 | { |
238 | struct inode *inode = dentry->d_inode; | ||
238 | struct posix_acl *acl; | 239 | struct posix_acl *acl; |
239 | int type; | 240 | int type; |
240 | int error; | 241 | int error; |
@@ -255,9 +256,11 @@ static int gfs2_xattr_system_get(struct inode *inode, const char *name, | |||
255 | return error; | 256 | return error; |
256 | } | 257 | } |
257 | 258 | ||
258 | static int gfs2_xattr_system_set(struct inode *inode, const char *name, | 259 | static int gfs2_xattr_system_set(struct dentry *dentry, const char *name, |
259 | const void *value, size_t size, int flags) | 260 | const void *value, size_t size, int flags, |
261 | int xtype) | ||
260 | { | 262 | { |
263 | struct inode *inode = dentry->d_inode; | ||
261 | struct gfs2_sbd *sdp = GFS2_SB(inode); | 264 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
262 | struct posix_acl *acl = NULL; | 265 | struct posix_acl *acl = NULL; |
263 | int error = 0, type; | 266 | int error = 0, type; |
@@ -319,7 +322,7 @@ static int gfs2_xattr_system_set(struct inode *inode, const char *name, | |||
319 | } | 322 | } |
320 | 323 | ||
321 | set_acl: | 324 | set_acl: |
322 | error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, value, size, 0); | 325 | error = __gfs2_xattr_set(inode, name, value, size, 0, GFS2_EATYPE_SYS); |
323 | if (!error) { | 326 | if (!error) { |
324 | if (acl) | 327 | if (acl) |
325 | set_cached_acl(inode, type, acl); | 328 | set_cached_acl(inode, type, acl); |
@@ -334,6 +337,7 @@ out: | |||
334 | 337 | ||
335 | struct xattr_handler gfs2_xattr_system_handler = { | 338 | struct xattr_handler gfs2_xattr_system_handler = { |
336 | .prefix = XATTR_SYSTEM_PREFIX, | 339 | .prefix = XATTR_SYSTEM_PREFIX, |
340 | .flags = GFS2_EATYPE_SYS, | ||
337 | .get = gfs2_xattr_system_get, | 341 | .get = gfs2_xattr_system_get, |
338 | .set = gfs2_xattr_system_set, | 342 | .set = gfs2_xattr_system_set, |
339 | }; | 343 | }; |
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 26ba2a4c4a2d..3ff32fa793da 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -801,7 +801,8 @@ static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip) | |||
801 | return err; | 801 | return err; |
802 | } | 802 | } |
803 | 803 | ||
804 | err = gfs2_xattr_set(&ip->i_inode, GFS2_EATYPE_SECURITY, name, value, len, 0); | 804 | err = __gfs2_xattr_set(&ip->i_inode, name, value, len, 0, |
805 | GFS2_EATYPE_SECURITY); | ||
805 | kfree(value); | 806 | kfree(value); |
806 | kfree(name); | 807 | kfree(name); |
807 | 808 | ||
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c index 912f5cbc4740..8a04108e0c22 100644 --- a/fs/gfs2/xattr.c +++ b/fs/gfs2/xattr.c | |||
@@ -567,18 +567,17 @@ out: | |||
567 | /** | 567 | /** |
568 | * gfs2_xattr_get - Get a GFS2 extended attribute | 568 | * gfs2_xattr_get - Get a GFS2 extended attribute |
569 | * @inode: The inode | 569 | * @inode: The inode |
570 | * @type: The type of extended attribute | ||
571 | * @name: The name of the extended attribute | 570 | * @name: The name of the extended attribute |
572 | * @buffer: The buffer to write the result into | 571 | * @buffer: The buffer to write the result into |
573 | * @size: The size of the buffer | 572 | * @size: The size of the buffer |
573 | * @type: The type of extended attribute | ||
574 | * | 574 | * |
575 | * Returns: actual size of data on success, -errno on error | 575 | * Returns: actual size of data on success, -errno on error |
576 | */ | 576 | */ |
577 | 577 | static int gfs2_xattr_get(struct dentry *dentry, const char *name, | |
578 | int gfs2_xattr_get(struct inode *inode, int type, const char *name, | 578 | void *buffer, size_t size, int type) |
579 | void *buffer, size_t size) | ||
580 | { | 579 | { |
581 | struct gfs2_inode *ip = GFS2_I(inode); | 580 | struct gfs2_inode *ip = GFS2_I(dentry->d_inode); |
582 | struct gfs2_ea_location el; | 581 | struct gfs2_ea_location el; |
583 | int error; | 582 | int error; |
584 | 583 | ||
@@ -1119,7 +1118,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) | |||
1119 | 1118 | ||
1120 | /** | 1119 | /** |
1121 | * gfs2_xattr_remove - Remove a GFS2 extended attribute | 1120 | * gfs2_xattr_remove - Remove a GFS2 extended attribute |
1122 | * @inode: The inode | 1121 | * @ip: The inode |
1123 | * @type: The type of the extended attribute | 1122 | * @type: The type of the extended attribute |
1124 | * @name: The name of the extended attribute | 1123 | * @name: The name of the extended attribute |
1125 | * | 1124 | * |
@@ -1130,9 +1129,8 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) | |||
1130 | * Returns: 0, or errno on failure | 1129 | * Returns: 0, or errno on failure |
1131 | */ | 1130 | */ |
1132 | 1131 | ||
1133 | static int gfs2_xattr_remove(struct inode *inode, int type, const char *name) | 1132 | static int gfs2_xattr_remove(struct gfs2_inode *ip, int type, const char *name) |
1134 | { | 1133 | { |
1135 | struct gfs2_inode *ip = GFS2_I(inode); | ||
1136 | struct gfs2_ea_location el; | 1134 | struct gfs2_ea_location el; |
1137 | int error; | 1135 | int error; |
1138 | 1136 | ||
@@ -1156,24 +1154,24 @@ static int gfs2_xattr_remove(struct inode *inode, int type, const char *name) | |||
1156 | } | 1154 | } |
1157 | 1155 | ||
1158 | /** | 1156 | /** |
1159 | * gfs2_xattr_set - Set (or remove) a GFS2 extended attribute | 1157 | * __gfs2_xattr_set - Set (or remove) a GFS2 extended attribute |
1160 | * @inode: The inode | 1158 | * @ip: The inode |
1161 | * @type: The type of the extended attribute | ||
1162 | * @name: The name of the extended attribute | 1159 | * @name: The name of the extended attribute |
1163 | * @value: The value of the extended attribute (NULL for remove) | 1160 | * @value: The value of the extended attribute (NULL for remove) |
1164 | * @size: The size of the @value argument | 1161 | * @size: The size of the @value argument |
1165 | * @flags: Create or Replace | 1162 | * @flags: Create or Replace |
1163 | * @type: The type of the extended attribute | ||
1166 | * | 1164 | * |
1167 | * See gfs2_xattr_remove() for details of the removal of xattrs. | 1165 | * See gfs2_xattr_remove() for details of the removal of xattrs. |
1168 | * | 1166 | * |
1169 | * Returns: 0 or errno on failure | 1167 | * Returns: 0 or errno on failure |
1170 | */ | 1168 | */ |
1171 | 1169 | ||
1172 | int gfs2_xattr_set(struct inode *inode, int type, const char *name, | 1170 | int __gfs2_xattr_set(struct inode *inode, const char *name, |
1173 | const void *value, size_t size, int flags) | 1171 | const void *value, size_t size, int flags, int type) |
1174 | { | 1172 | { |
1175 | struct gfs2_sbd *sdp = GFS2_SB(inode); | ||
1176 | struct gfs2_inode *ip = GFS2_I(inode); | 1173 | struct gfs2_inode *ip = GFS2_I(inode); |
1174 | struct gfs2_sbd *sdp = GFS2_SB(inode); | ||
1177 | struct gfs2_ea_location el; | 1175 | struct gfs2_ea_location el; |
1178 | unsigned int namel = strlen(name); | 1176 | unsigned int namel = strlen(name); |
1179 | int error; | 1177 | int error; |
@@ -1184,7 +1182,7 @@ int gfs2_xattr_set(struct inode *inode, int type, const char *name, | |||
1184 | return -ERANGE; | 1182 | return -ERANGE; |
1185 | 1183 | ||
1186 | if (value == NULL) | 1184 | if (value == NULL) |
1187 | return gfs2_xattr_remove(inode, type, name); | 1185 | return gfs2_xattr_remove(ip, type, name); |
1188 | 1186 | ||
1189 | if (ea_check_size(sdp, namel, size)) | 1187 | if (ea_check_size(sdp, namel, size)) |
1190 | return -ERANGE; | 1188 | return -ERANGE; |
@@ -1224,6 +1222,13 @@ int gfs2_xattr_set(struct inode *inode, int type, const char *name, | |||
1224 | return error; | 1222 | return error; |
1225 | } | 1223 | } |
1226 | 1224 | ||
1225 | static int gfs2_xattr_set(struct dentry *dentry, const char *name, | ||
1226 | const void *value, size_t size, int flags, int type) | ||
1227 | { | ||
1228 | return __gfs2_xattr_set(dentry->d_inode, name, value, | ||
1229 | size, flags, type); | ||
1230 | } | ||
1231 | |||
1227 | static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, | 1232 | static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, |
1228 | struct gfs2_ea_header *ea, char *data) | 1233 | struct gfs2_ea_header *ea, char *data) |
1229 | { | 1234 | { |
@@ -1529,40 +1534,18 @@ out_alloc: | |||
1529 | return error; | 1534 | return error; |
1530 | } | 1535 | } |
1531 | 1536 | ||
1532 | static int gfs2_xattr_user_get(struct inode *inode, const char *name, | ||
1533 | void *buffer, size_t size) | ||
1534 | { | ||
1535 | return gfs2_xattr_get(inode, GFS2_EATYPE_USR, name, buffer, size); | ||
1536 | } | ||
1537 | |||
1538 | static int gfs2_xattr_user_set(struct inode *inode, const char *name, | ||
1539 | const void *value, size_t size, int flags) | ||
1540 | { | ||
1541 | return gfs2_xattr_set(inode, GFS2_EATYPE_USR, name, value, size, flags); | ||
1542 | } | ||
1543 | |||
1544 | static int gfs2_xattr_security_get(struct inode *inode, const char *name, | ||
1545 | void *buffer, size_t size) | ||
1546 | { | ||
1547 | return gfs2_xattr_get(inode, GFS2_EATYPE_SECURITY, name, buffer, size); | ||
1548 | } | ||
1549 | |||
1550 | static int gfs2_xattr_security_set(struct inode *inode, const char *name, | ||
1551 | const void *value, size_t size, int flags) | ||
1552 | { | ||
1553 | return gfs2_xattr_set(inode, GFS2_EATYPE_SECURITY, name, value, size, flags); | ||
1554 | } | ||
1555 | |||
1556 | static struct xattr_handler gfs2_xattr_user_handler = { | 1537 | static struct xattr_handler gfs2_xattr_user_handler = { |
1557 | .prefix = XATTR_USER_PREFIX, | 1538 | .prefix = XATTR_USER_PREFIX, |
1558 | .get = gfs2_xattr_user_get, | 1539 | .flags = GFS2_EATYPE_USR, |
1559 | .set = gfs2_xattr_user_set, | 1540 | .get = gfs2_xattr_get, |
1541 | .set = gfs2_xattr_set, | ||
1560 | }; | 1542 | }; |
1561 | 1543 | ||
1562 | static struct xattr_handler gfs2_xattr_security_handler = { | 1544 | static struct xattr_handler gfs2_xattr_security_handler = { |
1563 | .prefix = XATTR_SECURITY_PREFIX, | 1545 | .prefix = XATTR_SECURITY_PREFIX, |
1564 | .get = gfs2_xattr_security_get, | 1546 | .flags = GFS2_EATYPE_SECURITY, |
1565 | .set = gfs2_xattr_security_set, | 1547 | .get = gfs2_xattr_get, |
1548 | .set = gfs2_xattr_set, | ||
1566 | }; | 1549 | }; |
1567 | 1550 | ||
1568 | struct xattr_handler *gfs2_xattr_handlers[] = { | 1551 | struct xattr_handler *gfs2_xattr_handlers[] = { |
diff --git a/fs/gfs2/xattr.h b/fs/gfs2/xattr.h index 8d6ae5813c4d..d392f8358f2f 100644 --- a/fs/gfs2/xattr.h +++ b/fs/gfs2/xattr.h | |||
@@ -53,10 +53,9 @@ struct gfs2_ea_location { | |||
53 | struct gfs2_ea_header *el_prev; | 53 | struct gfs2_ea_header *el_prev; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | extern int gfs2_xattr_get(struct inode *inode, int type, const char *name, | 56 | extern int __gfs2_xattr_set(struct inode *inode, const char *name, |
57 | void *buffer, size_t size); | 57 | const void *value, size_t size, |
58 | extern int gfs2_xattr_set(struct inode *inode, int type, const char *name, | 58 | int flags, int type); |
59 | const void *value, size_t size, int flags); | ||
60 | extern ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size); | 59 | extern ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size); |
61 | extern int gfs2_ea_dealloc(struct gfs2_inode *ip); | 60 | extern int gfs2_ea_dealloc(struct gfs2_inode *ip); |
62 | 61 | ||
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 87a1258953b8..a0bbd3d1b41a 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/dnotify.h> | 30 | #include <linux/dnotify.h> |
31 | #include <linux/statfs.h> | 31 | #include <linux/statfs.h> |
32 | #include <linux/security.h> | 32 | #include <linux/security.h> |
33 | #include <linux/ima.h> | ||
34 | #include <linux/magic.h> | 33 | #include <linux/magic.h> |
35 | 34 | ||
36 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
@@ -922,7 +921,8 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag, | |||
922 | int error = -ENOMEM; | 921 | int error = -ENOMEM; |
923 | struct file *file; | 922 | struct file *file; |
924 | struct inode *inode; | 923 | struct inode *inode; |
925 | struct dentry *dentry, *root; | 924 | struct path path; |
925 | struct dentry *root; | ||
926 | struct qstr quick_string; | 926 | struct qstr quick_string; |
927 | 927 | ||
928 | *user = NULL; | 928 | *user = NULL; |
@@ -944,10 +944,11 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag, | |||
944 | quick_string.name = name; | 944 | quick_string.name = name; |
945 | quick_string.len = strlen(quick_string.name); | 945 | quick_string.len = strlen(quick_string.name); |
946 | quick_string.hash = 0; | 946 | quick_string.hash = 0; |
947 | dentry = d_alloc(root, &quick_string); | 947 | path.dentry = d_alloc(root, &quick_string); |
948 | if (!dentry) | 948 | if (!path.dentry) |
949 | goto out_shm_unlock; | 949 | goto out_shm_unlock; |
950 | 950 | ||
951 | path.mnt = mntget(hugetlbfs_vfsmount); | ||
951 | error = -ENOSPC; | 952 | error = -ENOSPC; |
952 | inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(), | 953 | inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(), |
953 | current_fsgid(), S_IFREG | S_IRWXUGO, 0); | 954 | current_fsgid(), S_IFREG | S_IRWXUGO, 0); |
@@ -960,24 +961,22 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag, | |||
960 | acctflag)) | 961 | acctflag)) |
961 | goto out_inode; | 962 | goto out_inode; |
962 | 963 | ||
963 | d_instantiate(dentry, inode); | 964 | d_instantiate(path.dentry, inode); |
964 | inode->i_size = size; | 965 | inode->i_size = size; |
965 | inode->i_nlink = 0; | 966 | inode->i_nlink = 0; |
966 | 967 | ||
967 | error = -ENFILE; | 968 | error = -ENFILE; |
968 | file = alloc_file(hugetlbfs_vfsmount, dentry, | 969 | file = alloc_file(&path, FMODE_WRITE | FMODE_READ, |
969 | FMODE_WRITE | FMODE_READ, | ||
970 | &hugetlbfs_file_operations); | 970 | &hugetlbfs_file_operations); |
971 | if (!file) | 971 | if (!file) |
972 | goto out_dentry; /* inode is already attached */ | 972 | goto out_dentry; /* inode is already attached */ |
973 | ima_counts_get(file); | ||
974 | 973 | ||
975 | return file; | 974 | return file; |
976 | 975 | ||
977 | out_inode: | 976 | out_inode: |
978 | iput(inode); | 977 | iput(inode); |
979 | out_dentry: | 978 | out_dentry: |
980 | dput(dentry); | 979 | path_put(&path); |
981 | out_shm_unlock: | 980 | out_shm_unlock: |
982 | if (*user) { | 981 | if (*user) { |
983 | user_shm_unlock(size, *user); | 982 | user_shm_unlock(size, *user); |
diff --git a/fs/internal.h b/fs/internal.h index 515175b8b72e..f67cd141d9a8 100644 --- a/fs/internal.h +++ b/fs/internal.h | |||
@@ -79,6 +79,7 @@ extern void chroot_fs_refs(struct path *, struct path *); | |||
79 | * file_table.c | 79 | * file_table.c |
80 | */ | 80 | */ |
81 | extern void mark_files_ro(struct super_block *); | 81 | extern void mark_files_ro(struct super_block *); |
82 | extern struct file *get_empty_filp(void); | ||
82 | 83 | ||
83 | /* | 84 | /* |
84 | * super.c | 85 | * super.c |
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 7edb62e97419..7cdc3196476a 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
@@ -350,8 +350,8 @@ int jffs2_acl_chmod(struct inode *inode) | |||
350 | return rc; | 350 | return rc; |
351 | } | 351 | } |
352 | 352 | ||
353 | static size_t jffs2_acl_access_listxattr(struct inode *inode, char *list, size_t list_size, | 353 | static size_t jffs2_acl_access_listxattr(struct dentry *dentry, char *list, |
354 | const char *name, size_t name_len) | 354 | size_t list_size, const char *name, size_t name_len, int type) |
355 | { | 355 | { |
356 | const int retlen = sizeof(POSIX_ACL_XATTR_ACCESS); | 356 | const int retlen = sizeof(POSIX_ACL_XATTR_ACCESS); |
357 | 357 | ||
@@ -360,8 +360,8 @@ static size_t jffs2_acl_access_listxattr(struct inode *inode, char *list, size_t | |||
360 | return retlen; | 360 | return retlen; |
361 | } | 361 | } |
362 | 362 | ||
363 | static size_t jffs2_acl_default_listxattr(struct inode *inode, char *list, size_t list_size, | 363 | static size_t jffs2_acl_default_listxattr(struct dentry *dentry, char *list, |
364 | const char *name, size_t name_len) | 364 | size_t list_size, const char *name, size_t name_len, int type) |
365 | { | 365 | { |
366 | const int retlen = sizeof(POSIX_ACL_XATTR_DEFAULT); | 366 | const int retlen = sizeof(POSIX_ACL_XATTR_DEFAULT); |
367 | 367 | ||
@@ -370,12 +370,16 @@ static size_t jffs2_acl_default_listxattr(struct inode *inode, char *list, size_ | |||
370 | return retlen; | 370 | return retlen; |
371 | } | 371 | } |
372 | 372 | ||
373 | static int jffs2_acl_getxattr(struct inode *inode, int type, void *buffer, size_t size) | 373 | static int jffs2_acl_getxattr(struct dentry *dentry, const char *name, |
374 | void *buffer, size_t size, int type) | ||
374 | { | 375 | { |
375 | struct posix_acl *acl; | 376 | struct posix_acl *acl; |
376 | int rc; | 377 | int rc; |
377 | 378 | ||
378 | acl = jffs2_get_acl(inode, type); | 379 | if (name[0] != '\0') |
380 | return -EINVAL; | ||
381 | |||
382 | acl = jffs2_get_acl(dentry->d_inode, type); | ||
379 | if (IS_ERR(acl)) | 383 | if (IS_ERR(acl)) |
380 | return PTR_ERR(acl); | 384 | return PTR_ERR(acl); |
381 | if (!acl) | 385 | if (!acl) |
@@ -386,26 +390,15 @@ static int jffs2_acl_getxattr(struct inode *inode, int type, void *buffer, size_ | |||
386 | return rc; | 390 | return rc; |
387 | } | 391 | } |
388 | 392 | ||
389 | static int jffs2_acl_access_getxattr(struct inode *inode, const char *name, void *buffer, size_t size) | 393 | static int jffs2_acl_setxattr(struct dentry *dentry, const char *name, |
390 | { | 394 | const void *value, size_t size, int flags, int type) |
391 | if (name[0] != '\0') | ||
392 | return -EINVAL; | ||
393 | return jffs2_acl_getxattr(inode, ACL_TYPE_ACCESS, buffer, size); | ||
394 | } | ||
395 | |||
396 | static int jffs2_acl_default_getxattr(struct inode *inode, const char *name, void *buffer, size_t size) | ||
397 | { | ||
398 | if (name[0] != '\0') | ||
399 | return -EINVAL; | ||
400 | return jffs2_acl_getxattr(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
401 | } | ||
402 | |||
403 | static int jffs2_acl_setxattr(struct inode *inode, int type, const void *value, size_t size) | ||
404 | { | 395 | { |
405 | struct posix_acl *acl; | 396 | struct posix_acl *acl; |
406 | int rc; | 397 | int rc; |
407 | 398 | ||
408 | if (!is_owner_or_cap(inode)) | 399 | if (name[0] != '\0') |
400 | return -EINVAL; | ||
401 | if (!is_owner_or_cap(dentry->d_inode)) | ||
409 | return -EPERM; | 402 | return -EPERM; |
410 | 403 | ||
411 | if (value) { | 404 | if (value) { |
@@ -420,38 +413,24 @@ static int jffs2_acl_setxattr(struct inode *inode, int type, const void *value, | |||
420 | } else { | 413 | } else { |
421 | acl = NULL; | 414 | acl = NULL; |
422 | } | 415 | } |
423 | rc = jffs2_set_acl(inode, type, acl); | 416 | rc = jffs2_set_acl(dentry->d_inode, type, acl); |
424 | out: | 417 | out: |
425 | posix_acl_release(acl); | 418 | posix_acl_release(acl); |
426 | return rc; | 419 | return rc; |
427 | } | 420 | } |
428 | 421 | ||
429 | static int jffs2_acl_access_setxattr(struct inode *inode, const char *name, | ||
430 | const void *buffer, size_t size, int flags) | ||
431 | { | ||
432 | if (name[0] != '\0') | ||
433 | return -EINVAL; | ||
434 | return jffs2_acl_setxattr(inode, ACL_TYPE_ACCESS, buffer, size); | ||
435 | } | ||
436 | |||
437 | static int jffs2_acl_default_setxattr(struct inode *inode, const char *name, | ||
438 | const void *buffer, size_t size, int flags) | ||
439 | { | ||
440 | if (name[0] != '\0') | ||
441 | return -EINVAL; | ||
442 | return jffs2_acl_setxattr(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
443 | } | ||
444 | |||
445 | struct xattr_handler jffs2_acl_access_xattr_handler = { | 422 | struct xattr_handler jffs2_acl_access_xattr_handler = { |
446 | .prefix = POSIX_ACL_XATTR_ACCESS, | 423 | .prefix = POSIX_ACL_XATTR_ACCESS, |
424 | .flags = ACL_TYPE_DEFAULT, | ||
447 | .list = jffs2_acl_access_listxattr, | 425 | .list = jffs2_acl_access_listxattr, |
448 | .get = jffs2_acl_access_getxattr, | 426 | .get = jffs2_acl_getxattr, |
449 | .set = jffs2_acl_access_setxattr, | 427 | .set = jffs2_acl_setxattr, |
450 | }; | 428 | }; |
451 | 429 | ||
452 | struct xattr_handler jffs2_acl_default_xattr_handler = { | 430 | struct xattr_handler jffs2_acl_default_xattr_handler = { |
453 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 431 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
432 | .flags = ACL_TYPE_DEFAULT, | ||
454 | .list = jffs2_acl_default_listxattr, | 433 | .list = jffs2_acl_default_listxattr, |
455 | .get = jffs2_acl_default_getxattr, | 434 | .get = jffs2_acl_getxattr, |
456 | .set = jffs2_acl_default_setxattr, | 435 | .set = jffs2_acl_setxattr, |
457 | }; | 436 | }; |
diff --git a/fs/jffs2/security.c b/fs/jffs2/security.c index 02c39c64ecb3..eaccee058583 100644 --- a/fs/jffs2/security.c +++ b/fs/jffs2/security.c | |||
@@ -44,26 +44,28 @@ int jffs2_init_security(struct inode *inode, struct inode *dir) | |||
44 | } | 44 | } |
45 | 45 | ||
46 | /* ---- XATTR Handler for "security.*" ----------------- */ | 46 | /* ---- XATTR Handler for "security.*" ----------------- */ |
47 | static int jffs2_security_getxattr(struct inode *inode, const char *name, | 47 | static int jffs2_security_getxattr(struct dentry *dentry, const char *name, |
48 | void *buffer, size_t size) | 48 | void *buffer, size_t size, int type) |
49 | { | 49 | { |
50 | if (!strcmp(name, "")) | 50 | if (!strcmp(name, "")) |
51 | return -EINVAL; | 51 | return -EINVAL; |
52 | 52 | ||
53 | return do_jffs2_getxattr(inode, JFFS2_XPREFIX_SECURITY, name, buffer, size); | 53 | return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_SECURITY, |
54 | name, buffer, size); | ||
54 | } | 55 | } |
55 | 56 | ||
56 | static int jffs2_security_setxattr(struct inode *inode, const char *name, const void *buffer, | 57 | static int jffs2_security_setxattr(struct dentry *dentry, const char *name, |
57 | size_t size, int flags) | 58 | const void *buffer, size_t size, int flags, int type) |
58 | { | 59 | { |
59 | if (!strcmp(name, "")) | 60 | if (!strcmp(name, "")) |
60 | return -EINVAL; | 61 | return -EINVAL; |
61 | 62 | ||
62 | return do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, name, buffer, size, flags); | 63 | return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_SECURITY, |
64 | name, buffer, size, flags); | ||
63 | } | 65 | } |
64 | 66 | ||
65 | static size_t jffs2_security_listxattr(struct inode *inode, char *list, size_t list_size, | 67 | static size_t jffs2_security_listxattr(struct dentry *dentry, char *list, |
66 | const char *name, size_t name_len) | 68 | size_t list_size, const char *name, size_t name_len, int type) |
67 | { | 69 | { |
68 | size_t retlen = XATTR_SECURITY_PREFIX_LEN + name_len + 1; | 70 | size_t retlen = XATTR_SECURITY_PREFIX_LEN + name_len + 1; |
69 | 71 | ||
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c index 4b107881acd5..9e75c62c85d6 100644 --- a/fs/jffs2/xattr.c +++ b/fs/jffs2/xattr.c | |||
@@ -990,9 +990,11 @@ ssize_t jffs2_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
990 | if (!xhandle) | 990 | if (!xhandle) |
991 | continue; | 991 | continue; |
992 | if (buffer) { | 992 | if (buffer) { |
993 | rc = xhandle->list(inode, buffer+len, size-len, xd->xname, xd->name_len); | 993 | rc = xhandle->list(dentry, buffer+len, size-len, |
994 | xd->xname, xd->name_len, xd->flags); | ||
994 | } else { | 995 | } else { |
995 | rc = xhandle->list(inode, NULL, 0, xd->xname, xd->name_len); | 996 | rc = xhandle->list(dentry, NULL, 0, xd->xname, |
997 | xd->name_len, xd->flags); | ||
996 | } | 998 | } |
997 | if (rc < 0) | 999 | if (rc < 0) |
998 | goto out; | 1000 | goto out; |
diff --git a/fs/jffs2/xattr_trusted.c b/fs/jffs2/xattr_trusted.c index 8ec5765ef348..3e5a5e356e05 100644 --- a/fs/jffs2/xattr_trusted.c +++ b/fs/jffs2/xattr_trusted.c | |||
@@ -16,24 +16,26 @@ | |||
16 | #include <linux/mtd/mtd.h> | 16 | #include <linux/mtd/mtd.h> |
17 | #include "nodelist.h" | 17 | #include "nodelist.h" |
18 | 18 | ||
19 | static int jffs2_trusted_getxattr(struct inode *inode, const char *name, | 19 | static int jffs2_trusted_getxattr(struct dentry *dentry, const char *name, |
20 | void *buffer, size_t size) | 20 | void *buffer, size_t size, int type) |
21 | { | 21 | { |
22 | if (!strcmp(name, "")) | 22 | if (!strcmp(name, "")) |
23 | return -EINVAL; | 23 | return -EINVAL; |
24 | return do_jffs2_getxattr(inode, JFFS2_XPREFIX_TRUSTED, name, buffer, size); | 24 | return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_TRUSTED, |
25 | name, buffer, size); | ||
25 | } | 26 | } |
26 | 27 | ||
27 | static int jffs2_trusted_setxattr(struct inode *inode, const char *name, const void *buffer, | 28 | static int jffs2_trusted_setxattr(struct dentry *dentry, const char *name, |
28 | size_t size, int flags) | 29 | const void *buffer, size_t size, int flags, int type) |
29 | { | 30 | { |
30 | if (!strcmp(name, "")) | 31 | if (!strcmp(name, "")) |
31 | return -EINVAL; | 32 | return -EINVAL; |
32 | return do_jffs2_setxattr(inode, JFFS2_XPREFIX_TRUSTED, name, buffer, size, flags); | 33 | return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_TRUSTED, |
34 | name, buffer, size, flags); | ||
33 | } | 35 | } |
34 | 36 | ||
35 | static size_t jffs2_trusted_listxattr(struct inode *inode, char *list, size_t list_size, | 37 | static size_t jffs2_trusted_listxattr(struct dentry *dentry, char *list, |
36 | const char *name, size_t name_len) | 38 | size_t list_size, const char *name, size_t name_len, int type) |
37 | { | 39 | { |
38 | size_t retlen = XATTR_TRUSTED_PREFIX_LEN + name_len + 1; | 40 | size_t retlen = XATTR_TRUSTED_PREFIX_LEN + name_len + 1; |
39 | 41 | ||
diff --git a/fs/jffs2/xattr_user.c b/fs/jffs2/xattr_user.c index 8bbeab90ada1..8544af67dffe 100644 --- a/fs/jffs2/xattr_user.c +++ b/fs/jffs2/xattr_user.c | |||
@@ -16,24 +16,26 @@ | |||
16 | #include <linux/mtd/mtd.h> | 16 | #include <linux/mtd/mtd.h> |
17 | #include "nodelist.h" | 17 | #include "nodelist.h" |
18 | 18 | ||
19 | static int jffs2_user_getxattr(struct inode *inode, const char *name, | 19 | static int jffs2_user_getxattr(struct dentry *dentry, const char *name, |
20 | void *buffer, size_t size) | 20 | void *buffer, size_t size, int type) |
21 | { | 21 | { |
22 | if (!strcmp(name, "")) | 22 | if (!strcmp(name, "")) |
23 | return -EINVAL; | 23 | return -EINVAL; |
24 | return do_jffs2_getxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size); | 24 | return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_USER, |
25 | name, buffer, size); | ||
25 | } | 26 | } |
26 | 27 | ||
27 | static int jffs2_user_setxattr(struct inode *inode, const char *name, const void *buffer, | 28 | static int jffs2_user_setxattr(struct dentry *dentry, const char *name, |
28 | size_t size, int flags) | 29 | const void *buffer, size_t size, int flags, int type) |
29 | { | 30 | { |
30 | if (!strcmp(name, "")) | 31 | if (!strcmp(name, "")) |
31 | return -EINVAL; | 32 | return -EINVAL; |
32 | return do_jffs2_setxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size, flags); | 33 | return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_USER, |
34 | name, buffer, size, flags); | ||
33 | } | 35 | } |
34 | 36 | ||
35 | static size_t jffs2_user_listxattr(struct inode *inode, char *list, size_t list_size, | 37 | static size_t jffs2_user_listxattr(struct dentry *dentry, char *list, |
36 | const char *name, size_t name_len) | 38 | size_t list_size, const char *name, size_t name_len, int type) |
37 | { | 39 | { |
38 | size_t retlen = XATTR_USER_PREFIX_LEN + name_len + 1; | 40 | size_t retlen = XATTR_USER_PREFIX_LEN + name_len + 1; |
39 | 41 | ||
diff --git a/fs/libfs.c b/fs/libfs.c index 219576c52d80..6e8d17e1dc4c 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -848,7 +848,6 @@ EXPORT_SYMBOL(simple_write_end); | |||
848 | EXPORT_SYMBOL(simple_dir_inode_operations); | 848 | EXPORT_SYMBOL(simple_dir_inode_operations); |
849 | EXPORT_SYMBOL(simple_dir_operations); | 849 | EXPORT_SYMBOL(simple_dir_operations); |
850 | EXPORT_SYMBOL(simple_empty); | 850 | EXPORT_SYMBOL(simple_empty); |
851 | EXPORT_SYMBOL(d_alloc_name); | ||
852 | EXPORT_SYMBOL(simple_fill_super); | 851 | EXPORT_SYMBOL(simple_fill_super); |
853 | EXPORT_SYMBOL(simple_getattr); | 852 | EXPORT_SYMBOL(simple_getattr); |
854 | EXPORT_SYMBOL(simple_link); | 853 | EXPORT_SYMBOL(simple_link); |
diff --git a/fs/namei.c b/fs/namei.c index 87f97ba90ad1..d2783c8a770b 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -35,6 +35,8 @@ | |||
35 | #include <linux/fs_struct.h> | 35 | #include <linux/fs_struct.h> |
36 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> |
37 | 37 | ||
38 | #include "internal.h" | ||
39 | |||
38 | #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) | 40 | #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
39 | 41 | ||
40 | /* [Feb-1997 T. Schoebel-Theuer] | 42 | /* [Feb-1997 T. Schoebel-Theuer] |
@@ -108,8 +110,6 @@ | |||
108 | * any extra contention... | 110 | * any extra contention... |
109 | */ | 111 | */ |
110 | 112 | ||
111 | static int __link_path_walk(const char *name, struct nameidata *nd); | ||
112 | |||
113 | /* In order to reduce some races, while at the same time doing additional | 113 | /* In order to reduce some races, while at the same time doing additional |
114 | * checking and hopefully speeding things up, we copy filenames to the | 114 | * checking and hopefully speeding things up, we copy filenames to the |
115 | * kernel data space before using them.. | 115 | * kernel data space before using them.. |
@@ -414,36 +414,55 @@ do_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
414 | } | 414 | } |
415 | 415 | ||
416 | /* | 416 | /* |
417 | * Internal lookup() using the new generic dcache. | 417 | * force_reval_path - force revalidation of a dentry |
418 | * SMP-safe | 418 | * |
419 | * In some situations the path walking code will trust dentries without | ||
420 | * revalidating them. This causes problems for filesystems that depend on | ||
421 | * d_revalidate to handle file opens (e.g. NFSv4). When FS_REVAL_DOT is set | ||
422 | * (which indicates that it's possible for the dentry to go stale), force | ||
423 | * a d_revalidate call before proceeding. | ||
424 | * | ||
425 | * Returns 0 if the revalidation was successful. If the revalidation fails, | ||
426 | * either return the error returned by d_revalidate or -ESTALE if the | ||
427 | * revalidation it just returned 0. If d_revalidate returns 0, we attempt to | ||
428 | * invalidate the dentry. It's up to the caller to handle putting references | ||
429 | * to the path if necessary. | ||
419 | */ | 430 | */ |
420 | static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, struct nameidata *nd) | 431 | static int |
432 | force_reval_path(struct path *path, struct nameidata *nd) | ||
421 | { | 433 | { |
422 | struct dentry * dentry = __d_lookup(parent, name); | 434 | int status; |
435 | struct dentry *dentry = path->dentry; | ||
423 | 436 | ||
424 | /* lockess __d_lookup may fail due to concurrent d_move() | 437 | /* |
425 | * in some unrelated directory, so try with d_lookup | 438 | * only check on filesystems where it's possible for the dentry to |
439 | * become stale. It's assumed that if this flag is set then the | ||
440 | * d_revalidate op will also be defined. | ||
426 | */ | 441 | */ |
427 | if (!dentry) | 442 | if (!(dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT)) |
428 | dentry = d_lookup(parent, name); | 443 | return 0; |
429 | 444 | ||
430 | if (dentry && dentry->d_op && dentry->d_op->d_revalidate) | 445 | status = dentry->d_op->d_revalidate(dentry, nd); |
431 | dentry = do_revalidate(dentry, nd); | 446 | if (status > 0) |
447 | return 0; | ||
432 | 448 | ||
433 | return dentry; | 449 | if (!status) { |
450 | d_invalidate(dentry); | ||
451 | status = -ESTALE; | ||
452 | } | ||
453 | return status; | ||
434 | } | 454 | } |
435 | 455 | ||
436 | /* | 456 | /* |
437 | * Short-cut version of permission(), for calling by | 457 | * Short-cut version of permission(), for calling on directories |
438 | * path_walk(), when dcache lock is held. Combines parts | 458 | * during pathname resolution. Combines parts of permission() |
439 | * of permission() and generic_permission(), and tests ONLY for | 459 | * and generic_permission(), and tests ONLY for MAY_EXEC permission. |
440 | * MAY_EXEC permission. | ||
441 | * | 460 | * |
442 | * If appropriate, check DAC only. If not appropriate, or | 461 | * If appropriate, check DAC only. If not appropriate, or |
443 | * short-cut DAC fails, then call permission() to do more | 462 | * short-cut DAC fails, then call ->permission() to do more |
444 | * complete permission check. | 463 | * complete permission check. |
445 | */ | 464 | */ |
446 | static int exec_permission_lite(struct inode *inode) | 465 | static int exec_permission(struct inode *inode) |
447 | { | 466 | { |
448 | int ret; | 467 | int ret; |
449 | 468 | ||
@@ -465,99 +484,6 @@ ok: | |||
465 | return security_inode_permission(inode, MAY_EXEC); | 484 | return security_inode_permission(inode, MAY_EXEC); |
466 | } | 485 | } |
467 | 486 | ||
468 | /* | ||
469 | * This is called when everything else fails, and we actually have | ||
470 | * to go to the low-level filesystem to find out what we should do.. | ||
471 | * | ||
472 | * We get the directory semaphore, and after getting that we also | ||
473 | * make sure that nobody added the entry to the dcache in the meantime.. | ||
474 | * SMP-safe | ||
475 | */ | ||
476 | static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, struct nameidata *nd) | ||
477 | { | ||
478 | struct dentry * result; | ||
479 | struct inode *dir = parent->d_inode; | ||
480 | |||
481 | mutex_lock(&dir->i_mutex); | ||
482 | /* | ||
483 | * First re-do the cached lookup just in case it was created | ||
484 | * while we waited for the directory semaphore.. | ||
485 | * | ||
486 | * FIXME! This could use version numbering or similar to | ||
487 | * avoid unnecessary cache lookups. | ||
488 | * | ||
489 | * The "dcache_lock" is purely to protect the RCU list walker | ||
490 | * from concurrent renames at this point (we mustn't get false | ||
491 | * negatives from the RCU list walk here, unlike the optimistic | ||
492 | * fast walk). | ||
493 | * | ||
494 | * so doing d_lookup() (with seqlock), instead of lockfree __d_lookup | ||
495 | */ | ||
496 | result = d_lookup(parent, name); | ||
497 | if (!result) { | ||
498 | struct dentry *dentry; | ||
499 | |||
500 | /* Don't create child dentry for a dead directory. */ | ||
501 | result = ERR_PTR(-ENOENT); | ||
502 | if (IS_DEADDIR(dir)) | ||
503 | goto out_unlock; | ||
504 | |||
505 | dentry = d_alloc(parent, name); | ||
506 | result = ERR_PTR(-ENOMEM); | ||
507 | if (dentry) { | ||
508 | result = dir->i_op->lookup(dir, dentry, nd); | ||
509 | if (result) | ||
510 | dput(dentry); | ||
511 | else | ||
512 | result = dentry; | ||
513 | } | ||
514 | out_unlock: | ||
515 | mutex_unlock(&dir->i_mutex); | ||
516 | return result; | ||
517 | } | ||
518 | |||
519 | /* | ||
520 | * Uhhuh! Nasty case: the cache was re-populated while | ||
521 | * we waited on the semaphore. Need to revalidate. | ||
522 | */ | ||
523 | mutex_unlock(&dir->i_mutex); | ||
524 | if (result->d_op && result->d_op->d_revalidate) { | ||
525 | result = do_revalidate(result, nd); | ||
526 | if (!result) | ||
527 | result = ERR_PTR(-ENOENT); | ||
528 | } | ||
529 | return result; | ||
530 | } | ||
531 | |||
532 | /* | ||
533 | * Wrapper to retry pathname resolution whenever the underlying | ||
534 | * file system returns an ESTALE. | ||
535 | * | ||
536 | * Retry the whole path once, forcing real lookup requests | ||
537 | * instead of relying on the dcache. | ||
538 | */ | ||
539 | static __always_inline int link_path_walk(const char *name, struct nameidata *nd) | ||
540 | { | ||
541 | struct path save = nd->path; | ||
542 | int result; | ||
543 | |||
544 | /* make sure the stuff we saved doesn't go away */ | ||
545 | path_get(&save); | ||
546 | |||
547 | result = __link_path_walk(name, nd); | ||
548 | if (result == -ESTALE) { | ||
549 | /* nd->path had been dropped */ | ||
550 | nd->path = save; | ||
551 | path_get(&nd->path); | ||
552 | nd->flags |= LOOKUP_REVAL; | ||
553 | result = __link_path_walk(name, nd); | ||
554 | } | ||
555 | |||
556 | path_put(&save); | ||
557 | |||
558 | return result; | ||
559 | } | ||
560 | |||
561 | static __always_inline void set_root(struct nameidata *nd) | 487 | static __always_inline void set_root(struct nameidata *nd) |
562 | { | 488 | { |
563 | if (!nd->root.mnt) { | 489 | if (!nd->root.mnt) { |
@@ -569,6 +495,8 @@ static __always_inline void set_root(struct nameidata *nd) | |||
569 | } | 495 | } |
570 | } | 496 | } |
571 | 497 | ||
498 | static int link_path_walk(const char *, struct nameidata *); | ||
499 | |||
572 | static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *link) | 500 | static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *link) |
573 | { | 501 | { |
574 | int res = 0; | 502 | int res = 0; |
@@ -641,11 +569,14 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata | |||
641 | error = 0; | 569 | error = 0; |
642 | if (s) | 570 | if (s) |
643 | error = __vfs_follow_link(nd, s); | 571 | error = __vfs_follow_link(nd, s); |
572 | else if (nd->last_type == LAST_BIND) { | ||
573 | error = force_reval_path(&nd->path, nd); | ||
574 | if (error) | ||
575 | path_put(&nd->path); | ||
576 | } | ||
644 | if (dentry->d_inode->i_op->put_link) | 577 | if (dentry->d_inode->i_op->put_link) |
645 | dentry->d_inode->i_op->put_link(dentry, nd, cookie); | 578 | dentry->d_inode->i_op->put_link(dentry, nd, cookie); |
646 | } | 579 | } |
647 | path_put(path); | ||
648 | |||
649 | return error; | 580 | return error; |
650 | } | 581 | } |
651 | 582 | ||
@@ -672,6 +603,7 @@ static inline int do_follow_link(struct path *path, struct nameidata *nd) | |||
672 | current->total_link_count++; | 603 | current->total_link_count++; |
673 | nd->depth++; | 604 | nd->depth++; |
674 | err = __do_follow_link(path, nd); | 605 | err = __do_follow_link(path, nd); |
606 | path_put(path); | ||
675 | current->link_count--; | 607 | current->link_count--; |
676 | nd->depth--; | 608 | nd->depth--; |
677 | return err; | 609 | return err; |
@@ -797,8 +729,19 @@ static int do_lookup(struct nameidata *nd, struct qstr *name, | |||
797 | struct path *path) | 729 | struct path *path) |
798 | { | 730 | { |
799 | struct vfsmount *mnt = nd->path.mnt; | 731 | struct vfsmount *mnt = nd->path.mnt; |
800 | struct dentry *dentry = __d_lookup(nd->path.dentry, name); | 732 | struct dentry *dentry, *parent; |
733 | struct inode *dir; | ||
734 | /* | ||
735 | * See if the low-level filesystem might want | ||
736 | * to use its own hash.. | ||
737 | */ | ||
738 | if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) { | ||
739 | int err = nd->path.dentry->d_op->d_hash(nd->path.dentry, name); | ||
740 | if (err < 0) | ||
741 | return err; | ||
742 | } | ||
801 | 743 | ||
744 | dentry = __d_lookup(nd->path.dentry, name); | ||
802 | if (!dentry) | 745 | if (!dentry) |
803 | goto need_lookup; | 746 | goto need_lookup; |
804 | if (dentry->d_op && dentry->d_op->d_revalidate) | 747 | if (dentry->d_op && dentry->d_op->d_revalidate) |
@@ -810,7 +753,59 @@ done: | |||
810 | return 0; | 753 | return 0; |
811 | 754 | ||
812 | need_lookup: | 755 | need_lookup: |
813 | dentry = real_lookup(nd->path.dentry, name, nd); | 756 | parent = nd->path.dentry; |
757 | dir = parent->d_inode; | ||
758 | |||
759 | mutex_lock(&dir->i_mutex); | ||
760 | /* | ||
761 | * First re-do the cached lookup just in case it was created | ||
762 | * while we waited for the directory semaphore.. | ||
763 | * | ||
764 | * FIXME! This could use version numbering or similar to | ||
765 | * avoid unnecessary cache lookups. | ||
766 | * | ||
767 | * The "dcache_lock" is purely to protect the RCU list walker | ||
768 | * from concurrent renames at this point (we mustn't get false | ||
769 | * negatives from the RCU list walk here, unlike the optimistic | ||
770 | * fast walk). | ||
771 | * | ||
772 | * so doing d_lookup() (with seqlock), instead of lockfree __d_lookup | ||
773 | */ | ||
774 | dentry = d_lookup(parent, name); | ||
775 | if (!dentry) { | ||
776 | struct dentry *new; | ||
777 | |||
778 | /* Don't create child dentry for a dead directory. */ | ||
779 | dentry = ERR_PTR(-ENOENT); | ||
780 | if (IS_DEADDIR(dir)) | ||
781 | goto out_unlock; | ||
782 | |||
783 | new = d_alloc(parent, name); | ||
784 | dentry = ERR_PTR(-ENOMEM); | ||
785 | if (new) { | ||
786 | dentry = dir->i_op->lookup(dir, new, nd); | ||
787 | if (dentry) | ||
788 | dput(new); | ||
789 | else | ||
790 | dentry = new; | ||
791 | } | ||
792 | out_unlock: | ||
793 | mutex_unlock(&dir->i_mutex); | ||
794 | if (IS_ERR(dentry)) | ||
795 | goto fail; | ||
796 | goto done; | ||
797 | } | ||
798 | |||
799 | /* | ||
800 | * Uhhuh! Nasty case: the cache was re-populated while | ||
801 | * we waited on the semaphore. Need to revalidate. | ||
802 | */ | ||
803 | mutex_unlock(&dir->i_mutex); | ||
804 | if (dentry->d_op && dentry->d_op->d_revalidate) { | ||
805 | dentry = do_revalidate(dentry, nd); | ||
806 | if (!dentry) | ||
807 | dentry = ERR_PTR(-ENOENT); | ||
808 | } | ||
814 | if (IS_ERR(dentry)) | 809 | if (IS_ERR(dentry)) |
815 | goto fail; | 810 | goto fail; |
816 | goto done; | 811 | goto done; |
@@ -835,7 +830,7 @@ fail: | |||
835 | * Returns 0 and nd will have valid dentry and mnt on success. | 830 | * Returns 0 and nd will have valid dentry and mnt on success. |
836 | * Returns error and drops reference to input namei data on failure. | 831 | * Returns error and drops reference to input namei data on failure. |
837 | */ | 832 | */ |
838 | static int __link_path_walk(const char *name, struct nameidata *nd) | 833 | static int link_path_walk(const char *name, struct nameidata *nd) |
839 | { | 834 | { |
840 | struct path next; | 835 | struct path next; |
841 | struct inode *inode; | 836 | struct inode *inode; |
@@ -858,7 +853,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd) | |||
858 | unsigned int c; | 853 | unsigned int c; |
859 | 854 | ||
860 | nd->flags |= LOOKUP_CONTINUE; | 855 | nd->flags |= LOOKUP_CONTINUE; |
861 | err = exec_permission_lite(inode); | 856 | err = exec_permission(inode); |
862 | if (err) | 857 | if (err) |
863 | break; | 858 | break; |
864 | 859 | ||
@@ -898,16 +893,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd) | |||
898 | case 1: | 893 | case 1: |
899 | continue; | 894 | continue; |
900 | } | 895 | } |
901 | /* | ||
902 | * See if the low-level filesystem might want | ||
903 | * to use its own hash.. | ||
904 | */ | ||
905 | if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) { | ||
906 | err = nd->path.dentry->d_op->d_hash(nd->path.dentry, | ||
907 | &this); | ||
908 | if (err < 0) | ||
909 | break; | ||
910 | } | ||
911 | /* This does the actual lookups.. */ | 896 | /* This does the actual lookups.. */ |
912 | err = do_lookup(nd, &this, &next); | 897 | err = do_lookup(nd, &this, &next); |
913 | if (err) | 898 | if (err) |
@@ -953,12 +938,6 @@ last_component: | |||
953 | case 1: | 938 | case 1: |
954 | goto return_reval; | 939 | goto return_reval; |
955 | } | 940 | } |
956 | if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) { | ||
957 | err = nd->path.dentry->d_op->d_hash(nd->path.dentry, | ||
958 | &this); | ||
959 | if (err < 0) | ||
960 | break; | ||
961 | } | ||
962 | err = do_lookup(nd, &this, &next); | 941 | err = do_lookup(nd, &this, &next); |
963 | if (err) | 942 | if (err) |
964 | break; | 943 | break; |
@@ -1017,8 +996,27 @@ return_err: | |||
1017 | 996 | ||
1018 | static int path_walk(const char *name, struct nameidata *nd) | 997 | static int path_walk(const char *name, struct nameidata *nd) |
1019 | { | 998 | { |
999 | struct path save = nd->path; | ||
1000 | int result; | ||
1001 | |||
1020 | current->total_link_count = 0; | 1002 | current->total_link_count = 0; |
1021 | return link_path_walk(name, nd); | 1003 | |
1004 | /* make sure the stuff we saved doesn't go away */ | ||
1005 | path_get(&save); | ||
1006 | |||
1007 | result = link_path_walk(name, nd); | ||
1008 | if (result == -ESTALE) { | ||
1009 | /* nd->path had been dropped */ | ||
1010 | current->total_link_count = 0; | ||
1011 | nd->path = save; | ||
1012 | path_get(&nd->path); | ||
1013 | nd->flags |= LOOKUP_REVAL; | ||
1014 | result = link_path_walk(name, nd); | ||
1015 | } | ||
1016 | |||
1017 | path_put(&save); | ||
1018 | |||
1019 | return result; | ||
1022 | } | 1020 | } |
1023 | 1021 | ||
1024 | static int path_init(int dfd, const char *name, unsigned int flags, struct nameidata *nd) | 1022 | static int path_init(int dfd, const char *name, unsigned int flags, struct nameidata *nd) |
@@ -1141,36 +1139,6 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt, | |||
1141 | return retval; | 1139 | return retval; |
1142 | } | 1140 | } |
1143 | 1141 | ||
1144 | /** | ||
1145 | * path_lookup_open - lookup a file path with open intent | ||
1146 | * @dfd: the directory to use as base, or AT_FDCWD | ||
1147 | * @name: pointer to file name | ||
1148 | * @lookup_flags: lookup intent flags | ||
1149 | * @nd: pointer to nameidata | ||
1150 | * @open_flags: open intent flags | ||
1151 | */ | ||
1152 | static int path_lookup_open(int dfd, const char *name, | ||
1153 | unsigned int lookup_flags, struct nameidata *nd, int open_flags) | ||
1154 | { | ||
1155 | struct file *filp = get_empty_filp(); | ||
1156 | int err; | ||
1157 | |||
1158 | if (filp == NULL) | ||
1159 | return -ENFILE; | ||
1160 | nd->intent.open.file = filp; | ||
1161 | nd->intent.open.flags = open_flags; | ||
1162 | nd->intent.open.create_mode = 0; | ||
1163 | err = do_path_lookup(dfd, name, lookup_flags|LOOKUP_OPEN, nd); | ||
1164 | if (IS_ERR(nd->intent.open.file)) { | ||
1165 | if (err == 0) { | ||
1166 | err = PTR_ERR(nd->intent.open.file); | ||
1167 | path_put(&nd->path); | ||
1168 | } | ||
1169 | } else if (err != 0) | ||
1170 | release_open_intent(nd); | ||
1171 | return err; | ||
1172 | } | ||
1173 | |||
1174 | static struct dentry *__lookup_hash(struct qstr *name, | 1142 | static struct dentry *__lookup_hash(struct qstr *name, |
1175 | struct dentry *base, struct nameidata *nd) | 1143 | struct dentry *base, struct nameidata *nd) |
1176 | { | 1144 | { |
@@ -1191,7 +1159,17 @@ static struct dentry *__lookup_hash(struct qstr *name, | |||
1191 | goto out; | 1159 | goto out; |
1192 | } | 1160 | } |
1193 | 1161 | ||
1194 | dentry = cached_lookup(base, name, nd); | 1162 | dentry = __d_lookup(base, name); |
1163 | |||
1164 | /* lockess __d_lookup may fail due to concurrent d_move() | ||
1165 | * in some unrelated directory, so try with d_lookup | ||
1166 | */ | ||
1167 | if (!dentry) | ||
1168 | dentry = d_lookup(base, name); | ||
1169 | |||
1170 | if (dentry && dentry->d_op && dentry->d_op->d_revalidate) | ||
1171 | dentry = do_revalidate(dentry, nd); | ||
1172 | |||
1195 | if (!dentry) { | 1173 | if (!dentry) { |
1196 | struct dentry *new; | 1174 | struct dentry *new; |
1197 | 1175 | ||
@@ -1223,7 +1201,7 @@ static struct dentry *lookup_hash(struct nameidata *nd) | |||
1223 | { | 1201 | { |
1224 | int err; | 1202 | int err; |
1225 | 1203 | ||
1226 | err = inode_permission(nd->path.dentry->d_inode, MAY_EXEC); | 1204 | err = exec_permission(nd->path.dentry->d_inode); |
1227 | if (err) | 1205 | if (err) |
1228 | return ERR_PTR(err); | 1206 | return ERR_PTR(err); |
1229 | return __lookup_hash(&nd->last, nd->path.dentry, nd); | 1207 | return __lookup_hash(&nd->last, nd->path.dentry, nd); |
@@ -1273,7 +1251,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) | |||
1273 | if (err) | 1251 | if (err) |
1274 | return ERR_PTR(err); | 1252 | return ERR_PTR(err); |
1275 | 1253 | ||
1276 | err = inode_permission(base->d_inode, MAY_EXEC); | 1254 | err = exec_permission(base->d_inode); |
1277 | if (err) | 1255 | if (err) |
1278 | return ERR_PTR(err); | 1256 | return ERR_PTR(err); |
1279 | return __lookup_hash(&this, base, NULL); | 1257 | return __lookup_hash(&this, base, NULL); |
@@ -1511,69 +1489,45 @@ int may_open(struct path *path, int acc_mode, int flag) | |||
1511 | if (error) | 1489 | if (error) |
1512 | return error; | 1490 | return error; |
1513 | 1491 | ||
1514 | error = ima_path_check(path, acc_mode ? | ||
1515 | acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC) : | ||
1516 | ACC_MODE(flag) & (MAY_READ | MAY_WRITE), | ||
1517 | IMA_COUNT_UPDATE); | ||
1518 | |||
1519 | if (error) | ||
1520 | return error; | ||
1521 | /* | 1492 | /* |
1522 | * An append-only file must be opened in append mode for writing. | 1493 | * An append-only file must be opened in append mode for writing. |
1523 | */ | 1494 | */ |
1524 | if (IS_APPEND(inode)) { | 1495 | if (IS_APPEND(inode)) { |
1525 | error = -EPERM; | ||
1526 | if ((flag & FMODE_WRITE) && !(flag & O_APPEND)) | 1496 | if ((flag & FMODE_WRITE) && !(flag & O_APPEND)) |
1527 | goto err_out; | 1497 | return -EPERM; |
1528 | if (flag & O_TRUNC) | 1498 | if (flag & O_TRUNC) |
1529 | goto err_out; | 1499 | return -EPERM; |
1530 | } | 1500 | } |
1531 | 1501 | ||
1532 | /* O_NOATIME can only be set by the owner or superuser */ | 1502 | /* O_NOATIME can only be set by the owner or superuser */ |
1533 | if (flag & O_NOATIME) | 1503 | if (flag & O_NOATIME && !is_owner_or_cap(inode)) |
1534 | if (!is_owner_or_cap(inode)) { | 1504 | return -EPERM; |
1535 | error = -EPERM; | ||
1536 | goto err_out; | ||
1537 | } | ||
1538 | 1505 | ||
1539 | /* | 1506 | /* |
1540 | * Ensure there are no outstanding leases on the file. | 1507 | * Ensure there are no outstanding leases on the file. |
1541 | */ | 1508 | */ |
1542 | error = break_lease(inode, flag); | 1509 | return break_lease(inode, flag); |
1543 | if (error) | 1510 | } |
1544 | goto err_out; | ||
1545 | |||
1546 | if (flag & O_TRUNC) { | ||
1547 | error = get_write_access(inode); | ||
1548 | if (error) | ||
1549 | goto err_out; | ||
1550 | |||
1551 | /* | ||
1552 | * Refuse to truncate files with mandatory locks held on them. | ||
1553 | */ | ||
1554 | error = locks_verify_locked(inode); | ||
1555 | if (!error) | ||
1556 | error = security_path_truncate(path, 0, | ||
1557 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN); | ||
1558 | if (!error) { | ||
1559 | vfs_dq_init(inode); | ||
1560 | |||
1561 | error = do_truncate(dentry, 0, | ||
1562 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN, | ||
1563 | NULL); | ||
1564 | } | ||
1565 | put_write_access(inode); | ||
1566 | if (error) | ||
1567 | goto err_out; | ||
1568 | } else | ||
1569 | if (flag & FMODE_WRITE) | ||
1570 | vfs_dq_init(inode); | ||
1571 | 1511 | ||
1572 | return 0; | 1512 | static int handle_truncate(struct path *path) |
1573 | err_out: | 1513 | { |
1574 | ima_counts_put(path, acc_mode ? | 1514 | struct inode *inode = path->dentry->d_inode; |
1575 | acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC) : | 1515 | int error = get_write_access(inode); |
1576 | ACC_MODE(flag) & (MAY_READ | MAY_WRITE)); | 1516 | if (error) |
1517 | return error; | ||
1518 | /* | ||
1519 | * Refuse to truncate files with mandatory locks held on them. | ||
1520 | */ | ||
1521 | error = locks_verify_locked(inode); | ||
1522 | if (!error) | ||
1523 | error = security_path_truncate(path, 0, | ||
1524 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN); | ||
1525 | if (!error) { | ||
1526 | error = do_truncate(path->dentry, 0, | ||
1527 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN, | ||
1528 | NULL); | ||
1529 | } | ||
1530 | put_write_access(inode); | ||
1577 | return error; | 1531 | return error; |
1578 | } | 1532 | } |
1579 | 1533 | ||
@@ -1628,7 +1582,7 @@ static inline int open_to_namei_flags(int flag) | |||
1628 | return flag; | 1582 | return flag; |
1629 | } | 1583 | } |
1630 | 1584 | ||
1631 | static int open_will_write_to_fs(int flag, struct inode *inode) | 1585 | static int open_will_truncate(int flag, struct inode *inode) |
1632 | { | 1586 | { |
1633 | /* | 1587 | /* |
1634 | * We'll never write to the fs underlying | 1588 | * We'll never write to the fs underlying |
@@ -1650,10 +1604,10 @@ struct file *do_filp_open(int dfd, const char *pathname, | |||
1650 | struct file *filp; | 1604 | struct file *filp; |
1651 | struct nameidata nd; | 1605 | struct nameidata nd; |
1652 | int error; | 1606 | int error; |
1653 | struct path path; | 1607 | struct path path, save; |
1654 | struct dentry *dir; | 1608 | struct dentry *dir; |
1655 | int count = 0; | 1609 | int count = 0; |
1656 | int will_write; | 1610 | int will_truncate; |
1657 | int flag = open_to_namei_flags(open_flag); | 1611 | int flag = open_to_namei_flags(open_flag); |
1658 | 1612 | ||
1659 | /* | 1613 | /* |
@@ -1681,8 +1635,22 @@ struct file *do_filp_open(int dfd, const char *pathname, | |||
1681 | * The simplest case - just a plain lookup. | 1635 | * The simplest case - just a plain lookup. |
1682 | */ | 1636 | */ |
1683 | if (!(flag & O_CREAT)) { | 1637 | if (!(flag & O_CREAT)) { |
1684 | error = path_lookup_open(dfd, pathname, lookup_flags(flag), | 1638 | filp = get_empty_filp(); |
1685 | &nd, flag); | 1639 | |
1640 | if (filp == NULL) | ||
1641 | return ERR_PTR(-ENFILE); | ||
1642 | nd.intent.open.file = filp; | ||
1643 | nd.intent.open.flags = flag; | ||
1644 | nd.intent.open.create_mode = 0; | ||
1645 | error = do_path_lookup(dfd, pathname, | ||
1646 | lookup_flags(flag)|LOOKUP_OPEN, &nd); | ||
1647 | if (IS_ERR(nd.intent.open.file)) { | ||
1648 | if (error == 0) { | ||
1649 | error = PTR_ERR(nd.intent.open.file); | ||
1650 | path_put(&nd.path); | ||
1651 | } | ||
1652 | } else if (error) | ||
1653 | release_open_intent(&nd); | ||
1686 | if (error) | 1654 | if (error) |
1687 | return ERR_PTR(error); | 1655 | return ERR_PTR(error); |
1688 | goto ok; | 1656 | goto ok; |
@@ -1758,13 +1726,17 @@ do_last: | |||
1758 | goto exit; | 1726 | goto exit; |
1759 | } | 1727 | } |
1760 | filp = nameidata_to_filp(&nd, open_flag); | 1728 | filp = nameidata_to_filp(&nd, open_flag); |
1761 | if (IS_ERR(filp)) | ||
1762 | ima_counts_put(&nd.path, | ||
1763 | acc_mode & (MAY_READ | MAY_WRITE | | ||
1764 | MAY_EXEC)); | ||
1765 | mnt_drop_write(nd.path.mnt); | 1729 | mnt_drop_write(nd.path.mnt); |
1766 | if (nd.root.mnt) | 1730 | if (nd.root.mnt) |
1767 | path_put(&nd.root); | 1731 | path_put(&nd.root); |
1732 | if (!IS_ERR(filp)) { | ||
1733 | error = ima_path_check(&filp->f_path, filp->f_mode & | ||
1734 | (MAY_READ | MAY_WRITE | MAY_EXEC)); | ||
1735 | if (error) { | ||
1736 | fput(filp); | ||
1737 | filp = ERR_PTR(error); | ||
1738 | } | ||
1739 | } | ||
1768 | return filp; | 1740 | return filp; |
1769 | } | 1741 | } |
1770 | 1742 | ||
@@ -1805,28 +1777,45 @@ ok: | |||
1805 | * be avoided. Taking this mnt write here | 1777 | * be avoided. Taking this mnt write here |
1806 | * ensures that (2) can not occur. | 1778 | * ensures that (2) can not occur. |
1807 | */ | 1779 | */ |
1808 | will_write = open_will_write_to_fs(flag, nd.path.dentry->d_inode); | 1780 | will_truncate = open_will_truncate(flag, nd.path.dentry->d_inode); |
1809 | if (will_write) { | 1781 | if (will_truncate) { |
1810 | error = mnt_want_write(nd.path.mnt); | 1782 | error = mnt_want_write(nd.path.mnt); |
1811 | if (error) | 1783 | if (error) |
1812 | goto exit; | 1784 | goto exit; |
1813 | } | 1785 | } |
1814 | error = may_open(&nd.path, acc_mode, flag); | 1786 | error = may_open(&nd.path, acc_mode, flag); |
1815 | if (error) { | 1787 | if (error) { |
1816 | if (will_write) | 1788 | if (will_truncate) |
1817 | mnt_drop_write(nd.path.mnt); | 1789 | mnt_drop_write(nd.path.mnt); |
1818 | goto exit; | 1790 | goto exit; |
1819 | } | 1791 | } |
1820 | filp = nameidata_to_filp(&nd, open_flag); | 1792 | filp = nameidata_to_filp(&nd, open_flag); |
1821 | if (IS_ERR(filp)) | 1793 | if (!IS_ERR(filp)) { |
1822 | ima_counts_put(&nd.path, | 1794 | error = ima_path_check(&filp->f_path, filp->f_mode & |
1823 | acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC)); | 1795 | (MAY_READ | MAY_WRITE | MAY_EXEC)); |
1796 | if (error) { | ||
1797 | fput(filp); | ||
1798 | filp = ERR_PTR(error); | ||
1799 | } | ||
1800 | } | ||
1801 | if (!IS_ERR(filp)) { | ||
1802 | if (acc_mode & MAY_WRITE) | ||
1803 | vfs_dq_init(nd.path.dentry->d_inode); | ||
1804 | |||
1805 | if (will_truncate) { | ||
1806 | error = handle_truncate(&nd.path); | ||
1807 | if (error) { | ||
1808 | fput(filp); | ||
1809 | filp = ERR_PTR(error); | ||
1810 | } | ||
1811 | } | ||
1812 | } | ||
1824 | /* | 1813 | /* |
1825 | * It is now safe to drop the mnt write | 1814 | * It is now safe to drop the mnt write |
1826 | * because the filp has had a write taken | 1815 | * because the filp has had a write taken |
1827 | * on its behalf. | 1816 | * on its behalf. |
1828 | */ | 1817 | */ |
1829 | if (will_write) | 1818 | if (will_truncate) |
1830 | mnt_drop_write(nd.path.mnt); | 1819 | mnt_drop_write(nd.path.mnt); |
1831 | if (nd.root.mnt) | 1820 | if (nd.root.mnt) |
1832 | path_put(&nd.root); | 1821 | path_put(&nd.root); |
@@ -1863,7 +1852,18 @@ do_link: | |||
1863 | error = security_inode_follow_link(path.dentry, &nd); | 1852 | error = security_inode_follow_link(path.dentry, &nd); |
1864 | if (error) | 1853 | if (error) |
1865 | goto exit_dput; | 1854 | goto exit_dput; |
1855 | save = nd.path; | ||
1856 | path_get(&save); | ||
1866 | error = __do_follow_link(&path, &nd); | 1857 | error = __do_follow_link(&path, &nd); |
1858 | if (error == -ESTALE) { | ||
1859 | /* nd.path had been dropped */ | ||
1860 | nd.path = save; | ||
1861 | path_get(&nd.path); | ||
1862 | nd.flags |= LOOKUP_REVAL; | ||
1863 | error = __do_follow_link(&path, &nd); | ||
1864 | } | ||
1865 | path_put(&save); | ||
1866 | path_put(&path); | ||
1867 | if (error) { | 1867 | if (error) { |
1868 | /* Does someone understand code flow here? Or it is only | 1868 | /* Does someone understand code flow here? Or it is only |
1869 | * me so stupid? Anathema to whoever designed this non-sense | 1869 | * me so stupid? Anathema to whoever designed this non-sense |
diff --git a/fs/namespace.c b/fs/namespace.c index 7d70d63ceb29..faab1273281e 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -2068,7 +2068,7 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, | |||
2068 | * create_mnt_ns - creates a private namespace and adds a root filesystem | 2068 | * create_mnt_ns - creates a private namespace and adds a root filesystem |
2069 | * @mnt: pointer to the new root filesystem mountpoint | 2069 | * @mnt: pointer to the new root filesystem mountpoint |
2070 | */ | 2070 | */ |
2071 | struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) | 2071 | static struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) |
2072 | { | 2072 | { |
2073 | struct mnt_namespace *new_ns; | 2073 | struct mnt_namespace *new_ns; |
2074 | 2074 | ||
@@ -2080,7 +2080,6 @@ struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) | |||
2080 | } | 2080 | } |
2081 | return new_ns; | 2081 | return new_ns; |
2082 | } | 2082 | } |
2083 | EXPORT_SYMBOL(create_mnt_ns); | ||
2084 | 2083 | ||
2085 | SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, | 2084 | SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, |
2086 | char __user *, type, unsigned long, flags, void __user *, data) | 2085 | char __user *, type, unsigned long, flags, void __user *, data) |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index ce907efc5508..d5b112bcf3de 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -2648,21 +2648,13 @@ out_freepage: | |||
2648 | static int nfs_follow_remote_path(struct vfsmount *root_mnt, | 2648 | static int nfs_follow_remote_path(struct vfsmount *root_mnt, |
2649 | const char *export_path, struct vfsmount *mnt_target) | 2649 | const char *export_path, struct vfsmount *mnt_target) |
2650 | { | 2650 | { |
2651 | struct mnt_namespace *ns_private; | ||
2652 | struct nameidata nd; | 2651 | struct nameidata nd; |
2653 | struct super_block *s; | 2652 | struct super_block *s; |
2654 | int ret; | 2653 | int ret; |
2655 | 2654 | ||
2656 | ns_private = create_mnt_ns(root_mnt); | ||
2657 | ret = PTR_ERR(ns_private); | ||
2658 | if (IS_ERR(ns_private)) | ||
2659 | goto out_mntput; | ||
2660 | |||
2661 | ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, | 2655 | ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, |
2662 | export_path, LOOKUP_FOLLOW, &nd); | 2656 | export_path, LOOKUP_FOLLOW, &nd); |
2663 | 2657 | ||
2664 | put_mnt_ns(ns_private); | ||
2665 | |||
2666 | if (ret != 0) | 2658 | if (ret != 0) |
2667 | goto out_err; | 2659 | goto out_err; |
2668 | 2660 | ||
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index e3ef3ec0efd0..7c2e337d05af 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -752,8 +752,6 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, | |||
752 | flags, current_cred()); | 752 | flags, current_cred()); |
753 | if (IS_ERR(*filp)) | 753 | if (IS_ERR(*filp)) |
754 | host_err = PTR_ERR(*filp); | 754 | host_err = PTR_ERR(*filp); |
755 | else | ||
756 | ima_counts_get(*filp); | ||
757 | out_nfserr: | 755 | out_nfserr: |
758 | err = nfserrno(host_err); | 756 | err = nfserrno(host_err); |
759 | out: | 757 | out: |
@@ -2132,8 +2130,7 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp, | |||
2132 | */ | 2130 | */ |
2133 | path.mnt = exp->ex_path.mnt; | 2131 | path.mnt = exp->ex_path.mnt; |
2134 | path.dentry = dentry; | 2132 | path.dentry = dentry; |
2135 | err = ima_path_check(&path, acc & (MAY_READ | MAY_WRITE | MAY_EXEC), | 2133 | err = ima_path_check(&path, acc & (MAY_READ | MAY_WRITE | MAY_EXEC)); |
2136 | IMA_COUNT_LEAVE); | ||
2137 | nfsd_out: | 2134 | nfsd_out: |
2138 | return err? nfserrno(err) : 0; | 2135 | return err? nfserrno(err) : 0; |
2139 | } | 2136 | } |
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 5403b3ef3a42..8173faee31e6 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
@@ -1118,8 +1118,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags, | |||
1118 | /* Abandoning the newly allocated superblock */ | 1118 | /* Abandoning the newly allocated superblock */ |
1119 | mutex_unlock(&nilfs->ns_mount_mutex); | 1119 | mutex_unlock(&nilfs->ns_mount_mutex); |
1120 | put_nilfs(nilfs); | 1120 | put_nilfs(nilfs); |
1121 | up_write(&s->s_umount); | 1121 | deactivate_locked_super(s); |
1122 | deactivate_super(s); | ||
1123 | /* | 1122 | /* |
1124 | * deactivate_super() invokes close_bdev_exclusive(). | 1123 | * deactivate_super() invokes close_bdev_exclusive(). |
1125 | * We must finish all post-cleaning before this call; | 1124 | * We must finish all post-cleaning before this call; |
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 5ef5f365a5c8..8271cf05c957 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -646,6 +646,7 @@ SYSCALL_DEFINE1(inotify_init1, int, flags) | |||
646 | struct fsnotify_group *group; | 646 | struct fsnotify_group *group; |
647 | struct user_struct *user; | 647 | struct user_struct *user; |
648 | struct file *filp; | 648 | struct file *filp; |
649 | struct path path; | ||
649 | int fd, ret; | 650 | int fd, ret; |
650 | 651 | ||
651 | /* Check the IN_* constants for consistency. */ | 652 | /* Check the IN_* constants for consistency. */ |
@@ -659,12 +660,6 @@ SYSCALL_DEFINE1(inotify_init1, int, flags) | |||
659 | if (fd < 0) | 660 | if (fd < 0) |
660 | return fd; | 661 | return fd; |
661 | 662 | ||
662 | filp = get_empty_filp(); | ||
663 | if (!filp) { | ||
664 | ret = -ENFILE; | ||
665 | goto out_put_fd; | ||
666 | } | ||
667 | |||
668 | user = get_current_user(); | 663 | user = get_current_user(); |
669 | if (unlikely(atomic_read(&user->inotify_devs) >= | 664 | if (unlikely(atomic_read(&user->inotify_devs) >= |
670 | inotify_max_user_instances)) { | 665 | inotify_max_user_instances)) { |
@@ -679,24 +674,28 @@ SYSCALL_DEFINE1(inotify_init1, int, flags) | |||
679 | goto out_free_uid; | 674 | goto out_free_uid; |
680 | } | 675 | } |
681 | 676 | ||
682 | filp->f_op = &inotify_fops; | 677 | atomic_inc(&user->inotify_devs); |
683 | filp->f_path.mnt = mntget(inotify_mnt); | 678 | |
684 | filp->f_path.dentry = dget(inotify_mnt->mnt_root); | 679 | path.mnt = inotify_mnt; |
685 | filp->f_mapping = filp->f_path.dentry->d_inode->i_mapping; | 680 | path.dentry = inotify_mnt->mnt_root; |
686 | filp->f_mode = FMODE_READ; | 681 | path_get(&path); |
682 | filp = alloc_file(&path, FMODE_READ, &inotify_fops); | ||
683 | if (!filp) | ||
684 | goto Enfile; | ||
685 | |||
687 | filp->f_flags = O_RDONLY | (flags & O_NONBLOCK); | 686 | filp->f_flags = O_RDONLY | (flags & O_NONBLOCK); |
688 | filp->private_data = group; | 687 | filp->private_data = group; |
689 | 688 | ||
690 | atomic_inc(&user->inotify_devs); | ||
691 | |||
692 | fd_install(fd, filp); | 689 | fd_install(fd, filp); |
693 | 690 | ||
694 | return fd; | 691 | return fd; |
695 | 692 | ||
693 | Enfile: | ||
694 | ret = -ENFILE; | ||
695 | path_put(&path); | ||
696 | atomic_dec(&user->inotify_devs); | ||
696 | out_free_uid: | 697 | out_free_uid: |
697 | free_uid(user); | 698 | free_uid(user); |
698 | put_filp(filp); | ||
699 | out_put_fd: | ||
700 | put_unused_fd(fd); | 699 | put_unused_fd(fd); |
701 | return ret; | 700 | return ret; |
702 | } | 701 | } |
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c index fbeaec762103..e3e47415d851 100644 --- a/fs/ocfs2/acl.c +++ b/fs/ocfs2/acl.c | |||
@@ -331,13 +331,14 @@ cleanup: | |||
331 | return ret; | 331 | return ret; |
332 | } | 332 | } |
333 | 333 | ||
334 | static size_t ocfs2_xattr_list_acl_access(struct inode *inode, | 334 | static size_t ocfs2_xattr_list_acl_access(struct dentry *dentry, |
335 | char *list, | 335 | char *list, |
336 | size_t list_len, | 336 | size_t list_len, |
337 | const char *name, | 337 | const char *name, |
338 | size_t name_len) | 338 | size_t name_len, |
339 | int type) | ||
339 | { | 340 | { |
340 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 341 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
341 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | 342 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
342 | 343 | ||
343 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | 344 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) |
@@ -348,13 +349,14 @@ static size_t ocfs2_xattr_list_acl_access(struct inode *inode, | |||
348 | return size; | 349 | return size; |
349 | } | 350 | } |
350 | 351 | ||
351 | static size_t ocfs2_xattr_list_acl_default(struct inode *inode, | 352 | static size_t ocfs2_xattr_list_acl_default(struct dentry *dentry, |
352 | char *list, | 353 | char *list, |
353 | size_t list_len, | 354 | size_t list_len, |
354 | const char *name, | 355 | const char *name, |
355 | size_t name_len) | 356 | size_t name_len, |
357 | int type) | ||
356 | { | 358 | { |
357 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 359 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
358 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | 360 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
359 | 361 | ||
360 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | 362 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) |
@@ -365,19 +367,19 @@ static size_t ocfs2_xattr_list_acl_default(struct inode *inode, | |||
365 | return size; | 367 | return size; |
366 | } | 368 | } |
367 | 369 | ||
368 | static int ocfs2_xattr_get_acl(struct inode *inode, | 370 | static int ocfs2_xattr_get_acl(struct dentry *dentry, const char *name, |
369 | int type, | 371 | void *buffer, size_t size, int type) |
370 | void *buffer, | ||
371 | size_t size) | ||
372 | { | 372 | { |
373 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 373 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
374 | struct posix_acl *acl; | 374 | struct posix_acl *acl; |
375 | int ret; | 375 | int ret; |
376 | 376 | ||
377 | if (strcmp(name, "") != 0) | ||
378 | return -EINVAL; | ||
377 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | 379 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) |
378 | return -EOPNOTSUPP; | 380 | return -EOPNOTSUPP; |
379 | 381 | ||
380 | acl = ocfs2_get_acl(inode, type); | 382 | acl = ocfs2_get_acl(dentry->d_inode, type); |
381 | if (IS_ERR(acl)) | 383 | if (IS_ERR(acl)) |
382 | return PTR_ERR(acl); | 384 | return PTR_ERR(acl); |
383 | if (acl == NULL) | 385 | if (acl == NULL) |
@@ -388,35 +390,16 @@ static int ocfs2_xattr_get_acl(struct inode *inode, | |||
388 | return ret; | 390 | return ret; |
389 | } | 391 | } |
390 | 392 | ||
391 | static int ocfs2_xattr_get_acl_access(struct inode *inode, | 393 | static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name, |
392 | const char *name, | 394 | const void *value, size_t size, int flags, int type) |
393 | void *buffer, | ||
394 | size_t size) | ||
395 | { | ||
396 | if (strcmp(name, "") != 0) | ||
397 | return -EINVAL; | ||
398 | return ocfs2_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); | ||
399 | } | ||
400 | |||
401 | static int ocfs2_xattr_get_acl_default(struct inode *inode, | ||
402 | const char *name, | ||
403 | void *buffer, | ||
404 | size_t size) | ||
405 | { | ||
406 | if (strcmp(name, "") != 0) | ||
407 | return -EINVAL; | ||
408 | return ocfs2_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
409 | } | ||
410 | |||
411 | static int ocfs2_xattr_set_acl(struct inode *inode, | ||
412 | int type, | ||
413 | const void *value, | ||
414 | size_t size) | ||
415 | { | 395 | { |
396 | struct inode *inode = dentry->d_inode; | ||
416 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 397 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
417 | struct posix_acl *acl; | 398 | struct posix_acl *acl; |
418 | int ret = 0; | 399 | int ret = 0; |
419 | 400 | ||
401 | if (strcmp(name, "") != 0) | ||
402 | return -EINVAL; | ||
420 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | 403 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) |
421 | return -EOPNOTSUPP; | 404 | return -EOPNOTSUPP; |
422 | 405 | ||
@@ -442,38 +425,18 @@ cleanup: | |||
442 | return ret; | 425 | return ret; |
443 | } | 426 | } |
444 | 427 | ||
445 | static int ocfs2_xattr_set_acl_access(struct inode *inode, | ||
446 | const char *name, | ||
447 | const void *value, | ||
448 | size_t size, | ||
449 | int flags) | ||
450 | { | ||
451 | if (strcmp(name, "") != 0) | ||
452 | return -EINVAL; | ||
453 | return ocfs2_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
454 | } | ||
455 | |||
456 | static int ocfs2_xattr_set_acl_default(struct inode *inode, | ||
457 | const char *name, | ||
458 | const void *value, | ||
459 | size_t size, | ||
460 | int flags) | ||
461 | { | ||
462 | if (strcmp(name, "") != 0) | ||
463 | return -EINVAL; | ||
464 | return ocfs2_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
465 | } | ||
466 | |||
467 | struct xattr_handler ocfs2_xattr_acl_access_handler = { | 428 | struct xattr_handler ocfs2_xattr_acl_access_handler = { |
468 | .prefix = POSIX_ACL_XATTR_ACCESS, | 429 | .prefix = POSIX_ACL_XATTR_ACCESS, |
430 | .flags = ACL_TYPE_ACCESS, | ||
469 | .list = ocfs2_xattr_list_acl_access, | 431 | .list = ocfs2_xattr_list_acl_access, |
470 | .get = ocfs2_xattr_get_acl_access, | 432 | .get = ocfs2_xattr_get_acl, |
471 | .set = ocfs2_xattr_set_acl_access, | 433 | .set = ocfs2_xattr_set_acl, |
472 | }; | 434 | }; |
473 | 435 | ||
474 | struct xattr_handler ocfs2_xattr_acl_default_handler = { | 436 | struct xattr_handler ocfs2_xattr_acl_default_handler = { |
475 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 437 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
438 | .flags = ACL_TYPE_DEFAULT, | ||
476 | .list = ocfs2_xattr_list_acl_default, | 439 | .list = ocfs2_xattr_list_acl_default, |
477 | .get = ocfs2_xattr_get_acl_default, | 440 | .get = ocfs2_xattr_get_acl, |
478 | .set = ocfs2_xattr_set_acl_default, | 441 | .set = ocfs2_xattr_set_acl, |
479 | }; | 442 | }; |
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 7c7198a5bc90..fb4e672579b8 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -7190,8 +7190,8 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle, | |||
7190 | * wait on them - the truncate_inode_pages() call later will | 7190 | * wait on them - the truncate_inode_pages() call later will |
7191 | * do that for us. | 7191 | * do that for us. |
7192 | */ | 7192 | */ |
7193 | ret = do_sync_mapping_range(inode->i_mapping, range_start, | 7193 | ret = filemap_fdatawrite_range(inode->i_mapping, range_start, |
7194 | range_end - 1, SYNC_FILE_RANGE_WRITE); | 7194 | range_end - 1); |
7195 | if (ret) | 7195 | if (ret) |
7196 | mlog_errno(ret); | 7196 | mlog_errno(ret); |
7197 | 7197 | ||
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index fe3419068df2..43c114831c0d 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -205,8 +205,6 @@ static int ocfs2_get_xattr_tree_value_root(struct super_block *sb, | |||
205 | int offset, | 205 | int offset, |
206 | struct ocfs2_xattr_value_root **xv, | 206 | struct ocfs2_xattr_value_root **xv, |
207 | struct buffer_head **bh); | 207 | struct buffer_head **bh); |
208 | static int ocfs2_xattr_security_set(struct inode *inode, const char *name, | ||
209 | const void *value, size_t size, int flags); | ||
210 | 208 | ||
211 | static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb) | 209 | static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb) |
212 | { | 210 | { |
@@ -6978,9 +6976,9 @@ int ocfs2_init_security_and_acl(struct inode *dir, | |||
6978 | 6976 | ||
6979 | ret = ocfs2_init_security_get(inode, dir, &si); | 6977 | ret = ocfs2_init_security_get(inode, dir, &si); |
6980 | if (!ret) { | 6978 | if (!ret) { |
6981 | ret = ocfs2_xattr_security_set(inode, si.name, | 6979 | ret = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, |
6982 | si.value, si.value_len, | 6980 | si.name, si.value, si.value_len, |
6983 | XATTR_CREATE); | 6981 | XATTR_CREATE); |
6984 | if (ret) { | 6982 | if (ret) { |
6985 | mlog_errno(ret); | 6983 | mlog_errno(ret); |
6986 | goto leave; | 6984 | goto leave; |
@@ -7008,9 +7006,9 @@ leave: | |||
7008 | /* | 7006 | /* |
7009 | * 'security' attributes support | 7007 | * 'security' attributes support |
7010 | */ | 7008 | */ |
7011 | static size_t ocfs2_xattr_security_list(struct inode *inode, char *list, | 7009 | static size_t ocfs2_xattr_security_list(struct dentry *dentry, char *list, |
7012 | size_t list_size, const char *name, | 7010 | size_t list_size, const char *name, |
7013 | size_t name_len) | 7011 | size_t name_len, int type) |
7014 | { | 7012 | { |
7015 | const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; | 7013 | const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; |
7016 | const size_t total_len = prefix_len + name_len + 1; | 7014 | const size_t total_len = prefix_len + name_len + 1; |
@@ -7023,23 +7021,23 @@ static size_t ocfs2_xattr_security_list(struct inode *inode, char *list, | |||
7023 | return total_len; | 7021 | return total_len; |
7024 | } | 7022 | } |
7025 | 7023 | ||
7026 | static int ocfs2_xattr_security_get(struct inode *inode, const char *name, | 7024 | static int ocfs2_xattr_security_get(struct dentry *dentry, const char *name, |
7027 | void *buffer, size_t size) | 7025 | void *buffer, size_t size, int type) |
7028 | { | 7026 | { |
7029 | if (strcmp(name, "") == 0) | 7027 | if (strcmp(name, "") == 0) |
7030 | return -EINVAL; | 7028 | return -EINVAL; |
7031 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY, name, | 7029 | return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_SECURITY, |
7032 | buffer, size); | 7030 | name, buffer, size); |
7033 | } | 7031 | } |
7034 | 7032 | ||
7035 | static int ocfs2_xattr_security_set(struct inode *inode, const char *name, | 7033 | static int ocfs2_xattr_security_set(struct dentry *dentry, const char *name, |
7036 | const void *value, size_t size, int flags) | 7034 | const void *value, size_t size, int flags, int type) |
7037 | { | 7035 | { |
7038 | if (strcmp(name, "") == 0) | 7036 | if (strcmp(name, "") == 0) |
7039 | return -EINVAL; | 7037 | return -EINVAL; |
7040 | 7038 | ||
7041 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, name, value, | 7039 | return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_SECURITY, |
7042 | size, flags); | 7040 | name, value, size, flags); |
7043 | } | 7041 | } |
7044 | 7042 | ||
7045 | int ocfs2_init_security_get(struct inode *inode, | 7043 | int ocfs2_init_security_get(struct inode *inode, |
@@ -7076,9 +7074,9 @@ struct xattr_handler ocfs2_xattr_security_handler = { | |||
7076 | /* | 7074 | /* |
7077 | * 'trusted' attributes support | 7075 | * 'trusted' attributes support |
7078 | */ | 7076 | */ |
7079 | static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list, | 7077 | static size_t ocfs2_xattr_trusted_list(struct dentry *dentry, char *list, |
7080 | size_t list_size, const char *name, | 7078 | size_t list_size, const char *name, |
7081 | size_t name_len) | 7079 | size_t name_len, int type) |
7082 | { | 7080 | { |
7083 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; | 7081 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; |
7084 | const size_t total_len = prefix_len + name_len + 1; | 7082 | const size_t total_len = prefix_len + name_len + 1; |
@@ -7091,23 +7089,23 @@ static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list, | |||
7091 | return total_len; | 7089 | return total_len; |
7092 | } | 7090 | } |
7093 | 7091 | ||
7094 | static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name, | 7092 | static int ocfs2_xattr_trusted_get(struct dentry *dentry, const char *name, |
7095 | void *buffer, size_t size) | 7093 | void *buffer, size_t size, int type) |
7096 | { | 7094 | { |
7097 | if (strcmp(name, "") == 0) | 7095 | if (strcmp(name, "") == 0) |
7098 | return -EINVAL; | 7096 | return -EINVAL; |
7099 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name, | 7097 | return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_TRUSTED, |
7100 | buffer, size); | 7098 | name, buffer, size); |
7101 | } | 7099 | } |
7102 | 7100 | ||
7103 | static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name, | 7101 | static int ocfs2_xattr_trusted_set(struct dentry *dentry, const char *name, |
7104 | const void *value, size_t size, int flags) | 7102 | const void *value, size_t size, int flags, int type) |
7105 | { | 7103 | { |
7106 | if (strcmp(name, "") == 0) | 7104 | if (strcmp(name, "") == 0) |
7107 | return -EINVAL; | 7105 | return -EINVAL; |
7108 | 7106 | ||
7109 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value, | 7107 | return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_TRUSTED, |
7110 | size, flags); | 7108 | name, value, size, flags); |
7111 | } | 7109 | } |
7112 | 7110 | ||
7113 | struct xattr_handler ocfs2_xattr_trusted_handler = { | 7111 | struct xattr_handler ocfs2_xattr_trusted_handler = { |
@@ -7120,13 +7118,13 @@ struct xattr_handler ocfs2_xattr_trusted_handler = { | |||
7120 | /* | 7118 | /* |
7121 | * 'user' attributes support | 7119 | * 'user' attributes support |
7122 | */ | 7120 | */ |
7123 | static size_t ocfs2_xattr_user_list(struct inode *inode, char *list, | 7121 | static size_t ocfs2_xattr_user_list(struct dentry *dentry, char *list, |
7124 | size_t list_size, const char *name, | 7122 | size_t list_size, const char *name, |
7125 | size_t name_len) | 7123 | size_t name_len, int type) |
7126 | { | 7124 | { |
7127 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; | 7125 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; |
7128 | const size_t total_len = prefix_len + name_len + 1; | 7126 | const size_t total_len = prefix_len + name_len + 1; |
7129 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 7127 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
7130 | 7128 | ||
7131 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | 7129 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) |
7132 | return 0; | 7130 | return 0; |
@@ -7139,31 +7137,31 @@ static size_t ocfs2_xattr_user_list(struct inode *inode, char *list, | |||
7139 | return total_len; | 7137 | return total_len; |
7140 | } | 7138 | } |
7141 | 7139 | ||
7142 | static int ocfs2_xattr_user_get(struct inode *inode, const char *name, | 7140 | static int ocfs2_xattr_user_get(struct dentry *dentry, const char *name, |
7143 | void *buffer, size_t size) | 7141 | void *buffer, size_t size, int type) |
7144 | { | 7142 | { |
7145 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 7143 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
7146 | 7144 | ||
7147 | if (strcmp(name, "") == 0) | 7145 | if (strcmp(name, "") == 0) |
7148 | return -EINVAL; | 7146 | return -EINVAL; |
7149 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | 7147 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) |
7150 | return -EOPNOTSUPP; | 7148 | return -EOPNOTSUPP; |
7151 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name, | 7149 | return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_USER, name, |
7152 | buffer, size); | 7150 | buffer, size); |
7153 | } | 7151 | } |
7154 | 7152 | ||
7155 | static int ocfs2_xattr_user_set(struct inode *inode, const char *name, | 7153 | static int ocfs2_xattr_user_set(struct dentry *dentry, const char *name, |
7156 | const void *value, size_t size, int flags) | 7154 | const void *value, size_t size, int flags, int type) |
7157 | { | 7155 | { |
7158 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 7156 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
7159 | 7157 | ||
7160 | if (strcmp(name, "") == 0) | 7158 | if (strcmp(name, "") == 0) |
7161 | return -EINVAL; | 7159 | return -EINVAL; |
7162 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | 7160 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) |
7163 | return -EOPNOTSUPP; | 7161 | return -EOPNOTSUPP; |
7164 | 7162 | ||
7165 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value, | 7163 | return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_USER, |
7166 | size, flags); | 7164 | name, value, size, flags); |
7167 | } | 7165 | } |
7168 | 7166 | ||
7169 | struct xattr_handler ocfs2_xattr_user_handler = { | 7167 | struct xattr_handler ocfs2_xattr_user_handler = { |
@@ -30,6 +30,9 @@ | |||
30 | #include <linux/audit.h> | 30 | #include <linux/audit.h> |
31 | #include <linux/falloc.h> | 31 | #include <linux/falloc.h> |
32 | #include <linux/fs_struct.h> | 32 | #include <linux/fs_struct.h> |
33 | #include <linux/ima.h> | ||
34 | |||
35 | #include "internal.h" | ||
33 | 36 | ||
34 | int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 37 | int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
35 | { | 38 | { |
@@ -855,6 +858,7 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, | |||
855 | if (error) | 858 | if (error) |
856 | goto cleanup_all; | 859 | goto cleanup_all; |
857 | } | 860 | } |
861 | ima_counts_get(f); | ||
858 | 862 | ||
859 | f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); | 863 | f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); |
860 | 864 | ||
@@ -974,7 +974,7 @@ struct file *create_write_pipe(int flags) | |||
974 | int err; | 974 | int err; |
975 | struct inode *inode; | 975 | struct inode *inode; |
976 | struct file *f; | 976 | struct file *f; |
977 | struct dentry *dentry; | 977 | struct path path; |
978 | struct qstr name = { .name = "" }; | 978 | struct qstr name = { .name = "" }; |
979 | 979 | ||
980 | err = -ENFILE; | 980 | err = -ENFILE; |
@@ -983,21 +983,22 @@ struct file *create_write_pipe(int flags) | |||
983 | goto err; | 983 | goto err; |
984 | 984 | ||
985 | err = -ENOMEM; | 985 | err = -ENOMEM; |
986 | dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); | 986 | path.dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); |
987 | if (!dentry) | 987 | if (!path.dentry) |
988 | goto err_inode; | 988 | goto err_inode; |
989 | path.mnt = mntget(pipe_mnt); | ||
989 | 990 | ||
990 | dentry->d_op = &pipefs_dentry_operations; | 991 | path.dentry->d_op = &pipefs_dentry_operations; |
991 | /* | 992 | /* |
992 | * We dont want to publish this dentry into global dentry hash table. | 993 | * We dont want to publish this dentry into global dentry hash table. |
993 | * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED | 994 | * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED |
994 | * This permits a working /proc/$pid/fd/XXX on pipes | 995 | * This permits a working /proc/$pid/fd/XXX on pipes |
995 | */ | 996 | */ |
996 | dentry->d_flags &= ~DCACHE_UNHASHED; | 997 | path.dentry->d_flags &= ~DCACHE_UNHASHED; |
997 | d_instantiate(dentry, inode); | 998 | d_instantiate(path.dentry, inode); |
998 | 999 | ||
999 | err = -ENFILE; | 1000 | err = -ENFILE; |
1000 | f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipefifo_fops); | 1001 | f = alloc_file(&path, FMODE_WRITE, &write_pipefifo_fops); |
1001 | if (!f) | 1002 | if (!f) |
1002 | goto err_dentry; | 1003 | goto err_dentry; |
1003 | f->f_mapping = inode->i_mapping; | 1004 | f->f_mapping = inode->i_mapping; |
@@ -1009,7 +1010,7 @@ struct file *create_write_pipe(int flags) | |||
1009 | 1010 | ||
1010 | err_dentry: | 1011 | err_dentry: |
1011 | free_pipe_info(inode); | 1012 | free_pipe_info(inode); |
1012 | dput(dentry); | 1013 | path_put(&path); |
1013 | return ERR_PTR(err); | 1014 | return ERR_PTR(err); |
1014 | 1015 | ||
1015 | err_inode: | 1016 | err_inode: |
@@ -1028,20 +1029,14 @@ void free_write_pipe(struct file *f) | |||
1028 | 1029 | ||
1029 | struct file *create_read_pipe(struct file *wrf, int flags) | 1030 | struct file *create_read_pipe(struct file *wrf, int flags) |
1030 | { | 1031 | { |
1031 | struct file *f = get_empty_filp(); | 1032 | /* Grab pipe from the writer */ |
1033 | struct file *f = alloc_file(&wrf->f_path, FMODE_READ, | ||
1034 | &read_pipefifo_fops); | ||
1032 | if (!f) | 1035 | if (!f) |
1033 | return ERR_PTR(-ENFILE); | 1036 | return ERR_PTR(-ENFILE); |
1034 | 1037 | ||
1035 | /* Grab pipe from the writer */ | ||
1036 | f->f_path = wrf->f_path; | ||
1037 | path_get(&wrf->f_path); | 1038 | path_get(&wrf->f_path); |
1038 | f->f_mapping = wrf->f_path.dentry->d_inode->i_mapping; | ||
1039 | |||
1040 | f->f_pos = 0; | ||
1041 | f->f_flags = O_RDONLY | (flags & O_NONBLOCK); | 1039 | f->f_flags = O_RDONLY | (flags & O_NONBLOCK); |
1042 | f->f_op = &read_pipefifo_fops; | ||
1043 | f->f_mode = FMODE_READ; | ||
1044 | f->f_version = 0; | ||
1045 | 1040 | ||
1046 | return f; | 1041 | return f; |
1047 | } | 1042 | } |
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index 58aa8e75f7f5..8c7033a8b67e 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <net/checksum.h> | 48 | #include <net/checksum.h> |
49 | #include <linux/stat.h> | 49 | #include <linux/stat.h> |
50 | #include <linux/quotaops.h> | 50 | #include <linux/quotaops.h> |
51 | #include <linux/security.h> | ||
51 | 52 | ||
52 | #define PRIVROOT_NAME ".reiserfs_priv" | 53 | #define PRIVROOT_NAME ".reiserfs_priv" |
53 | #define XAROOT_NAME "xattrs" | 54 | #define XAROOT_NAME "xattrs" |
@@ -726,15 +727,14 @@ ssize_t | |||
726 | reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, | 727 | reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, |
727 | size_t size) | 728 | size_t size) |
728 | { | 729 | { |
729 | struct inode *inode = dentry->d_inode; | ||
730 | struct xattr_handler *handler; | 730 | struct xattr_handler *handler; |
731 | 731 | ||
732 | handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); | 732 | handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); |
733 | 733 | ||
734 | if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) | 734 | if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) |
735 | return -EOPNOTSUPP; | 735 | return -EOPNOTSUPP; |
736 | 736 | ||
737 | return handler->get(inode, name, buffer, size); | 737 | return handler->get(dentry, name, buffer, size, handler->flags); |
738 | } | 738 | } |
739 | 739 | ||
740 | /* | 740 | /* |
@@ -746,15 +746,14 @@ int | |||
746 | reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, | 746 | reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, |
747 | size_t size, int flags) | 747 | size_t size, int flags) |
748 | { | 748 | { |
749 | struct inode *inode = dentry->d_inode; | ||
750 | struct xattr_handler *handler; | 749 | struct xattr_handler *handler; |
751 | 750 | ||
752 | handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); | 751 | handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); |
753 | 752 | ||
754 | if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) | 753 | if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) |
755 | return -EOPNOTSUPP; | 754 | return -EOPNOTSUPP; |
756 | 755 | ||
757 | return handler->set(inode, name, value, size, flags); | 756 | return handler->set(dentry, name, value, size, flags, handler->flags); |
758 | } | 757 | } |
759 | 758 | ||
760 | /* | 759 | /* |
@@ -764,21 +763,20 @@ reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, | |||
764 | */ | 763 | */ |
765 | int reiserfs_removexattr(struct dentry *dentry, const char *name) | 764 | int reiserfs_removexattr(struct dentry *dentry, const char *name) |
766 | { | 765 | { |
767 | struct inode *inode = dentry->d_inode; | ||
768 | struct xattr_handler *handler; | 766 | struct xattr_handler *handler; |
769 | handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); | 767 | handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); |
770 | 768 | ||
771 | if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) | 769 | if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) |
772 | return -EOPNOTSUPP; | 770 | return -EOPNOTSUPP; |
773 | 771 | ||
774 | return handler->set(inode, name, NULL, 0, XATTR_REPLACE); | 772 | return handler->set(dentry, name, NULL, 0, XATTR_REPLACE, handler->flags); |
775 | } | 773 | } |
776 | 774 | ||
777 | struct listxattr_buf { | 775 | struct listxattr_buf { |
778 | size_t size; | 776 | size_t size; |
779 | size_t pos; | 777 | size_t pos; |
780 | char *buf; | 778 | char *buf; |
781 | struct inode *inode; | 779 | struct dentry *dentry; |
782 | }; | 780 | }; |
783 | 781 | ||
784 | static int listxattr_filler(void *buf, const char *name, int namelen, | 782 | static int listxattr_filler(void *buf, const char *name, int namelen, |
@@ -789,17 +787,19 @@ static int listxattr_filler(void *buf, const char *name, int namelen, | |||
789 | if (name[0] != '.' || | 787 | if (name[0] != '.' || |
790 | (namelen != 1 && (name[1] != '.' || namelen != 2))) { | 788 | (namelen != 1 && (name[1] != '.' || namelen != 2))) { |
791 | struct xattr_handler *handler; | 789 | struct xattr_handler *handler; |
792 | handler = find_xattr_handler_prefix(b->inode->i_sb->s_xattr, | 790 | handler = find_xattr_handler_prefix(b->dentry->d_sb->s_xattr, |
793 | name); | 791 | name); |
794 | if (!handler) /* Unsupported xattr name */ | 792 | if (!handler) /* Unsupported xattr name */ |
795 | return 0; | 793 | return 0; |
796 | if (b->buf) { | 794 | if (b->buf) { |
797 | size = handler->list(b->inode, b->buf + b->pos, | 795 | size = handler->list(b->dentry, b->buf + b->pos, |
798 | b->size, name, namelen); | 796 | b->size, name, namelen, |
797 | handler->flags); | ||
799 | if (size > b->size) | 798 | if (size > b->size) |
800 | return -ERANGE; | 799 | return -ERANGE; |
801 | } else { | 800 | } else { |
802 | size = handler->list(b->inode, NULL, 0, name, namelen); | 801 | size = handler->list(b->dentry, NULL, 0, name, |
802 | namelen, handler->flags); | ||
803 | } | 803 | } |
804 | 804 | ||
805 | b->pos += size; | 805 | b->pos += size; |
@@ -820,7 +820,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size) | |||
820 | int err = 0; | 820 | int err = 0; |
821 | loff_t pos = 0; | 821 | loff_t pos = 0; |
822 | struct listxattr_buf buf = { | 822 | struct listxattr_buf buf = { |
823 | .inode = dentry->d_inode, | 823 | .dentry = dentry, |
824 | .buf = buffer, | 824 | .buf = buffer, |
825 | .size = buffer ? size : 0, | 825 | .size = buffer ? size : 0, |
826 | }; | 826 | }; |
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c index 35d6e672a279..cc32e6ada67b 100644 --- a/fs/reiserfs/xattr_acl.c +++ b/fs/reiserfs/xattr_acl.c | |||
@@ -15,8 +15,10 @@ static int reiserfs_set_acl(struct reiserfs_transaction_handle *th, | |||
15 | struct posix_acl *acl); | 15 | struct posix_acl *acl); |
16 | 16 | ||
17 | static int | 17 | static int |
18 | xattr_set_acl(struct inode *inode, int type, const void *value, size_t size) | 18 | posix_acl_set(struct dentry *dentry, const char *name, const void *value, |
19 | size_t size, int flags, int type) | ||
19 | { | 20 | { |
21 | struct inode *inode = dentry->d_inode; | ||
20 | struct posix_acl *acl; | 22 | struct posix_acl *acl; |
21 | int error, error2; | 23 | int error, error2; |
22 | struct reiserfs_transaction_handle th; | 24 | struct reiserfs_transaction_handle th; |
@@ -60,15 +62,16 @@ xattr_set_acl(struct inode *inode, int type, const void *value, size_t size) | |||
60 | } | 62 | } |
61 | 63 | ||
62 | static int | 64 | static int |
63 | xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | 65 | posix_acl_get(struct dentry *dentry, const char *name, void *buffer, |
66 | size_t size, int type) | ||
64 | { | 67 | { |
65 | struct posix_acl *acl; | 68 | struct posix_acl *acl; |
66 | int error; | 69 | int error; |
67 | 70 | ||
68 | if (!reiserfs_posixacl(inode->i_sb)) | 71 | if (!reiserfs_posixacl(dentry->d_sb)) |
69 | return -EOPNOTSUPP; | 72 | return -EOPNOTSUPP; |
70 | 73 | ||
71 | acl = reiserfs_get_acl(inode, type); | 74 | acl = reiserfs_get_acl(dentry->d_inode, type); |
72 | if (IS_ERR(acl)) | 75 | if (IS_ERR(acl)) |
73 | return PTR_ERR(acl); | 76 | return PTR_ERR(acl); |
74 | if (acl == NULL) | 77 | if (acl == NULL) |
@@ -482,30 +485,12 @@ int reiserfs_acl_chmod(struct inode *inode) | |||
482 | return error; | 485 | return error; |
483 | } | 486 | } |
484 | 487 | ||
485 | static int | 488 | static size_t posix_acl_access_list(struct dentry *dentry, char *list, |
486 | posix_acl_access_get(struct inode *inode, const char *name, | ||
487 | void *buffer, size_t size) | ||
488 | { | ||
489 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1) | ||
490 | return -EINVAL; | ||
491 | return xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); | ||
492 | } | ||
493 | |||
494 | static int | ||
495 | posix_acl_access_set(struct inode *inode, const char *name, | ||
496 | const void *value, size_t size, int flags) | ||
497 | { | ||
498 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1) | ||
499 | return -EINVAL; | ||
500 | return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
501 | } | ||
502 | |||
503 | static size_t posix_acl_access_list(struct inode *inode, char *list, | ||
504 | size_t list_size, const char *name, | 489 | size_t list_size, const char *name, |
505 | size_t name_len) | 490 | size_t name_len, int type) |
506 | { | 491 | { |
507 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | 492 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
508 | if (!reiserfs_posixacl(inode->i_sb)) | 493 | if (!reiserfs_posixacl(dentry->d_sb)) |
509 | return 0; | 494 | return 0; |
510 | if (list && size <= list_size) | 495 | if (list && size <= list_size) |
511 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); | 496 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); |
@@ -514,35 +499,18 @@ static size_t posix_acl_access_list(struct inode *inode, char *list, | |||
514 | 499 | ||
515 | struct xattr_handler reiserfs_posix_acl_access_handler = { | 500 | struct xattr_handler reiserfs_posix_acl_access_handler = { |
516 | .prefix = POSIX_ACL_XATTR_ACCESS, | 501 | .prefix = POSIX_ACL_XATTR_ACCESS, |
517 | .get = posix_acl_access_get, | 502 | .flags = ACL_TYPE_ACCESS, |
518 | .set = posix_acl_access_set, | 503 | .get = posix_acl_get, |
504 | .set = posix_acl_set, | ||
519 | .list = posix_acl_access_list, | 505 | .list = posix_acl_access_list, |
520 | }; | 506 | }; |
521 | 507 | ||
522 | static int | 508 | static size_t posix_acl_default_list(struct dentry *dentry, char *list, |
523 | posix_acl_default_get(struct inode *inode, const char *name, | ||
524 | void *buffer, size_t size) | ||
525 | { | ||
526 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1) | ||
527 | return -EINVAL; | ||
528 | return xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
529 | } | ||
530 | |||
531 | static int | ||
532 | posix_acl_default_set(struct inode *inode, const char *name, | ||
533 | const void *value, size_t size, int flags) | ||
534 | { | ||
535 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1) | ||
536 | return -EINVAL; | ||
537 | return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
538 | } | ||
539 | |||
540 | static size_t posix_acl_default_list(struct inode *inode, char *list, | ||
541 | size_t list_size, const char *name, | 509 | size_t list_size, const char *name, |
542 | size_t name_len) | 510 | size_t name_len, int type) |
543 | { | 511 | { |
544 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | 512 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
545 | if (!reiserfs_posixacl(inode->i_sb)) | 513 | if (!reiserfs_posixacl(dentry->d_sb)) |
546 | return 0; | 514 | return 0; |
547 | if (list && size <= list_size) | 515 | if (list && size <= list_size) |
548 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); | 516 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); |
@@ -551,7 +519,8 @@ static size_t posix_acl_default_list(struct inode *inode, char *list, | |||
551 | 519 | ||
552 | struct xattr_handler reiserfs_posix_acl_default_handler = { | 520 | struct xattr_handler reiserfs_posix_acl_default_handler = { |
553 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 521 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
554 | .get = posix_acl_default_get, | 522 | .flags = ACL_TYPE_DEFAULT, |
555 | .set = posix_acl_default_set, | 523 | .get = posix_acl_get, |
524 | .set = posix_acl_set, | ||
556 | .list = posix_acl_default_list, | 525 | .list = posix_acl_default_list, |
557 | }; | 526 | }; |
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c index a92c8792c0f6..d8b5bfcbdd30 100644 --- a/fs/reiserfs/xattr_security.c +++ b/fs/reiserfs/xattr_security.c | |||
@@ -8,36 +8,37 @@ | |||
8 | #include <asm/uaccess.h> | 8 | #include <asm/uaccess.h> |
9 | 9 | ||
10 | static int | 10 | static int |
11 | security_get(struct inode *inode, const char *name, void *buffer, size_t size) | 11 | security_get(struct dentry *dentry, const char *name, void *buffer, size_t size, |
12 | int handler_flags) | ||
12 | { | 13 | { |
13 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) | 14 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) |
14 | return -EINVAL; | 15 | return -EINVAL; |
15 | 16 | ||
16 | if (IS_PRIVATE(inode)) | 17 | if (IS_PRIVATE(dentry->d_inode)) |
17 | return -EPERM; | 18 | return -EPERM; |
18 | 19 | ||
19 | return reiserfs_xattr_get(inode, name, buffer, size); | 20 | return reiserfs_xattr_get(dentry->d_inode, name, buffer, size); |
20 | } | 21 | } |
21 | 22 | ||
22 | static int | 23 | static int |
23 | security_set(struct inode *inode, const char *name, const void *buffer, | 24 | security_set(struct dentry *dentry, const char *name, const void *buffer, |
24 | size_t size, int flags) | 25 | size_t size, int flags, int handler_flags) |
25 | { | 26 | { |
26 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) | 27 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) |
27 | return -EINVAL; | 28 | return -EINVAL; |
28 | 29 | ||
29 | if (IS_PRIVATE(inode)) | 30 | if (IS_PRIVATE(dentry->d_inode)) |
30 | return -EPERM; | 31 | return -EPERM; |
31 | 32 | ||
32 | return reiserfs_xattr_set(inode, name, buffer, size, flags); | 33 | return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags); |
33 | } | 34 | } |
34 | 35 | ||
35 | static size_t security_list(struct inode *inode, char *list, size_t list_len, | 36 | static size_t security_list(struct dentry *dentry, char *list, size_t list_len, |
36 | const char *name, size_t namelen) | 37 | const char *name, size_t namelen, int handler_flags) |
37 | { | 38 | { |
38 | const size_t len = namelen + 1; | 39 | const size_t len = namelen + 1; |
39 | 40 | ||
40 | if (IS_PRIVATE(inode)) | 41 | if (IS_PRIVATE(dentry->d_inode)) |
41 | return 0; | 42 | return 0; |
42 | 43 | ||
43 | if (list && len <= list_len) { | 44 | if (list && len <= list_len) { |
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c index a865042f75e2..5b08aaca3daf 100644 --- a/fs/reiserfs/xattr_trusted.c +++ b/fs/reiserfs/xattr_trusted.c | |||
@@ -8,36 +8,37 @@ | |||
8 | #include <asm/uaccess.h> | 8 | #include <asm/uaccess.h> |
9 | 9 | ||
10 | static int | 10 | static int |
11 | trusted_get(struct inode *inode, const char *name, void *buffer, size_t size) | 11 | trusted_get(struct dentry *dentry, const char *name, void *buffer, size_t size, |
12 | int handler_flags) | ||
12 | { | 13 | { |
13 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) | 14 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) |
14 | return -EINVAL; | 15 | return -EINVAL; |
15 | 16 | ||
16 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) | 17 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode)) |
17 | return -EPERM; | 18 | return -EPERM; |
18 | 19 | ||
19 | return reiserfs_xattr_get(inode, name, buffer, size); | 20 | return reiserfs_xattr_get(dentry->d_inode, name, buffer, size); |
20 | } | 21 | } |
21 | 22 | ||
22 | static int | 23 | static int |
23 | trusted_set(struct inode *inode, const char *name, const void *buffer, | 24 | trusted_set(struct dentry *dentry, const char *name, const void *buffer, |
24 | size_t size, int flags) | 25 | size_t size, int flags, int handler_flags) |
25 | { | 26 | { |
26 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) | 27 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) |
27 | return -EINVAL; | 28 | return -EINVAL; |
28 | 29 | ||
29 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) | 30 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode)) |
30 | return -EPERM; | 31 | return -EPERM; |
31 | 32 | ||
32 | return reiserfs_xattr_set(inode, name, buffer, size, flags); | 33 | return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags); |
33 | } | 34 | } |
34 | 35 | ||
35 | static size_t trusted_list(struct inode *inode, char *list, size_t list_size, | 36 | static size_t trusted_list(struct dentry *dentry, char *list, size_t list_size, |
36 | const char *name, size_t name_len) | 37 | const char *name, size_t name_len, int handler_flags) |
37 | { | 38 | { |
38 | const size_t len = name_len + 1; | 39 | const size_t len = name_len + 1; |
39 | 40 | ||
40 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) | 41 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode)) |
41 | return 0; | 42 | return 0; |
42 | 43 | ||
43 | if (list && len <= list_size) { | 44 | if (list && len <= list_size) { |
diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c index e3238dc4f3db..75d59c49b911 100644 --- a/fs/reiserfs/xattr_user.c +++ b/fs/reiserfs/xattr_user.c | |||
@@ -7,34 +7,35 @@ | |||
7 | #include <asm/uaccess.h> | 7 | #include <asm/uaccess.h> |
8 | 8 | ||
9 | static int | 9 | static int |
10 | user_get(struct inode *inode, const char *name, void *buffer, size_t size) | 10 | user_get(struct dentry *dentry, const char *name, void *buffer, size_t size, |
11 | int handler_flags) | ||
11 | { | 12 | { |
12 | 13 | ||
13 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) | 14 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) |
14 | return -EINVAL; | 15 | return -EINVAL; |
15 | if (!reiserfs_xattrs_user(inode->i_sb)) | 16 | if (!reiserfs_xattrs_user(dentry->d_sb)) |
16 | return -EOPNOTSUPP; | 17 | return -EOPNOTSUPP; |
17 | return reiserfs_xattr_get(inode, name, buffer, size); | 18 | return reiserfs_xattr_get(dentry->d_inode, name, buffer, size); |
18 | } | 19 | } |
19 | 20 | ||
20 | static int | 21 | static int |
21 | user_set(struct inode *inode, const char *name, const void *buffer, | 22 | user_set(struct dentry *dentry, const char *name, const void *buffer, |
22 | size_t size, int flags) | 23 | size_t size, int flags, int handler_flags) |
23 | { | 24 | { |
24 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) | 25 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) |
25 | return -EINVAL; | 26 | return -EINVAL; |
26 | 27 | ||
27 | if (!reiserfs_xattrs_user(inode->i_sb)) | 28 | if (!reiserfs_xattrs_user(dentry->d_sb)) |
28 | return -EOPNOTSUPP; | 29 | return -EOPNOTSUPP; |
29 | return reiserfs_xattr_set(inode, name, buffer, size, flags); | 30 | return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags); |
30 | } | 31 | } |
31 | 32 | ||
32 | static size_t user_list(struct inode *inode, char *list, size_t list_size, | 33 | static size_t user_list(struct dentry *dentry, char *list, size_t list_size, |
33 | const char *name, size_t name_len) | 34 | const char *name, size_t name_len, int handler_flags) |
34 | { | 35 | { |
35 | const size_t len = name_len + 1; | 36 | const size_t len = name_len + 1; |
36 | 37 | ||
37 | if (!reiserfs_xattrs_user(inode->i_sb)) | 38 | if (!reiserfs_xattrs_user(dentry->d_sb)) |
38 | return 0; | 39 | return 0; |
39 | if (list && len <= list_size) { | 40 | if (list && len <= list_size) { |
40 | memcpy(list, name, name_len); | 41 | memcpy(list, name, name_len); |
diff --git a/fs/xattr.c b/fs/xattr.c index 6d4f6d3449fb..46f87e828b48 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
@@ -615,12 +615,11 @@ ssize_t | |||
615 | generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) | 615 | generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) |
616 | { | 616 | { |
617 | struct xattr_handler *handler; | 617 | struct xattr_handler *handler; |
618 | struct inode *inode = dentry->d_inode; | ||
619 | 618 | ||
620 | handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); | 619 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
621 | if (!handler) | 620 | if (!handler) |
622 | return -EOPNOTSUPP; | 621 | return -EOPNOTSUPP; |
623 | return handler->get(inode, name, buffer, size); | 622 | return handler->get(dentry, name, buffer, size, handler->flags); |
624 | } | 623 | } |
625 | 624 | ||
626 | /* | 625 | /* |
@@ -630,18 +629,20 @@ generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t s | |||
630 | ssize_t | 629 | ssize_t |
631 | generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) | 630 | generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) |
632 | { | 631 | { |
633 | struct inode *inode = dentry->d_inode; | 632 | struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; |
634 | struct xattr_handler *handler, **handlers = inode->i_sb->s_xattr; | ||
635 | unsigned int size = 0; | 633 | unsigned int size = 0; |
636 | 634 | ||
637 | if (!buffer) { | 635 | if (!buffer) { |
638 | for_each_xattr_handler(handlers, handler) | 636 | for_each_xattr_handler(handlers, handler) { |
639 | size += handler->list(inode, NULL, 0, NULL, 0); | 637 | size += handler->list(dentry, NULL, 0, NULL, 0, |
638 | handler->flags); | ||
639 | } | ||
640 | } else { | 640 | } else { |
641 | char *buf = buffer; | 641 | char *buf = buffer; |
642 | 642 | ||
643 | for_each_xattr_handler(handlers, handler) { | 643 | for_each_xattr_handler(handlers, handler) { |
644 | size = handler->list(inode, buf, buffer_size, NULL, 0); | 644 | size = handler->list(dentry, buf, buffer_size, |
645 | NULL, 0, handler->flags); | ||
645 | if (size > buffer_size) | 646 | if (size > buffer_size) |
646 | return -ERANGE; | 647 | return -ERANGE; |
647 | buf += size; | 648 | buf += size; |
@@ -659,14 +660,13 @@ int | |||
659 | generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) | 660 | generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) |
660 | { | 661 | { |
661 | struct xattr_handler *handler; | 662 | struct xattr_handler *handler; |
662 | struct inode *inode = dentry->d_inode; | ||
663 | 663 | ||
664 | if (size == 0) | 664 | if (size == 0) |
665 | value = ""; /* empty EA, do not remove */ | 665 | value = ""; /* empty EA, do not remove */ |
666 | handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); | 666 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
667 | if (!handler) | 667 | if (!handler) |
668 | return -EOPNOTSUPP; | 668 | return -EOPNOTSUPP; |
669 | return handler->set(inode, name, value, size, flags); | 669 | return handler->set(dentry, name, value, size, 0, handler->flags); |
670 | } | 670 | } |
671 | 671 | ||
672 | /* | 672 | /* |
@@ -677,12 +677,12 @@ int | |||
677 | generic_removexattr(struct dentry *dentry, const char *name) | 677 | generic_removexattr(struct dentry *dentry, const char *name) |
678 | { | 678 | { |
679 | struct xattr_handler *handler; | 679 | struct xattr_handler *handler; |
680 | struct inode *inode = dentry->d_inode; | ||
681 | 680 | ||
682 | handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); | 681 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
683 | if (!handler) | 682 | if (!handler) |
684 | return -EOPNOTSUPP; | 683 | return -EOPNOTSUPP; |
685 | return handler->set(inode, name, NULL, 0, XATTR_REPLACE); | 684 | return handler->set(dentry, name, NULL, 0, |
685 | XATTR_REPLACE, handler->flags); | ||
686 | } | 686 | } |
687 | 687 | ||
688 | EXPORT_SYMBOL(generic_getxattr); | 688 | EXPORT_SYMBOL(generic_getxattr); |
diff --git a/fs/xfs/linux-2.6/xfs_acl.c b/fs/xfs/linux-2.6/xfs_acl.c index 69e598b6986f..2512125dfa7c 100644 --- a/fs/xfs/linux-2.6/xfs_acl.c +++ b/fs/xfs/linux-2.6/xfs_acl.c | |||
@@ -354,37 +354,14 @@ xfs_acl_chmod(struct inode *inode) | |||
354 | return error; | 354 | return error; |
355 | } | 355 | } |
356 | 356 | ||
357 | /* | ||
358 | * System xattr handlers. | ||
359 | * | ||
360 | * Currently Posix ACLs are the only system namespace extended attribute | ||
361 | * handlers supported by XFS, so we just implement the handlers here. | ||
362 | * If we ever support other system extended attributes this will need | ||
363 | * some refactoring. | ||
364 | */ | ||
365 | |||
366 | static int | 357 | static int |
367 | xfs_decode_acl(const char *name) | 358 | xfs_xattr_acl_get(struct dentry *dentry, const char *name, |
368 | { | 359 | void *value, size_t size, int type) |
369 | if (strcmp(name, "posix_acl_access") == 0) | ||
370 | return ACL_TYPE_ACCESS; | ||
371 | else if (strcmp(name, "posix_acl_default") == 0) | ||
372 | return ACL_TYPE_DEFAULT; | ||
373 | return -EINVAL; | ||
374 | } | ||
375 | |||
376 | static int | ||
377 | xfs_xattr_system_get(struct inode *inode, const char *name, | ||
378 | void *value, size_t size) | ||
379 | { | 360 | { |
380 | struct posix_acl *acl; | 361 | struct posix_acl *acl; |
381 | int type, error; | 362 | int error; |
382 | |||
383 | type = xfs_decode_acl(name); | ||
384 | if (type < 0) | ||
385 | return type; | ||
386 | 363 | ||
387 | acl = xfs_get_acl(inode, type); | 364 | acl = xfs_get_acl(dentry->d_inode, type); |
388 | if (IS_ERR(acl)) | 365 | if (IS_ERR(acl)) |
389 | return PTR_ERR(acl); | 366 | return PTR_ERR(acl); |
390 | if (acl == NULL) | 367 | if (acl == NULL) |
@@ -397,15 +374,13 @@ xfs_xattr_system_get(struct inode *inode, const char *name, | |||
397 | } | 374 | } |
398 | 375 | ||
399 | static int | 376 | static int |
400 | xfs_xattr_system_set(struct inode *inode, const char *name, | 377 | xfs_xattr_acl_set(struct dentry *dentry, const char *name, |
401 | const void *value, size_t size, int flags) | 378 | const void *value, size_t size, int flags, int type) |
402 | { | 379 | { |
380 | struct inode *inode = dentry->d_inode; | ||
403 | struct posix_acl *acl = NULL; | 381 | struct posix_acl *acl = NULL; |
404 | int error = 0, type; | 382 | int error = 0; |
405 | 383 | ||
406 | type = xfs_decode_acl(name); | ||
407 | if (type < 0) | ||
408 | return type; | ||
409 | if (flags & XATTR_CREATE) | 384 | if (flags & XATTR_CREATE) |
410 | return -EINVAL; | 385 | return -EINVAL; |
411 | if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) | 386 | if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) |
@@ -462,8 +437,16 @@ xfs_xattr_system_set(struct inode *inode, const char *name, | |||
462 | return error; | 437 | return error; |
463 | } | 438 | } |
464 | 439 | ||
465 | struct xattr_handler xfs_xattr_system_handler = { | 440 | struct xattr_handler xfs_xattr_acl_access_handler = { |
466 | .prefix = XATTR_SYSTEM_PREFIX, | 441 | .prefix = POSIX_ACL_XATTR_ACCESS, |
467 | .get = xfs_xattr_system_get, | 442 | .flags = ACL_TYPE_ACCESS, |
468 | .set = xfs_xattr_system_set, | 443 | .get = xfs_xattr_acl_get, |
444 | .set = xfs_xattr_acl_set, | ||
445 | }; | ||
446 | |||
447 | struct xattr_handler xfs_xattr_acl_default_handler = { | ||
448 | .prefix = POSIX_ACL_XATTR_DEFAULT, | ||
449 | .flags = ACL_TYPE_DEFAULT, | ||
450 | .get = xfs_xattr_acl_get, | ||
451 | .set = xfs_xattr_acl_set, | ||
469 | }; | 452 | }; |
diff --git a/fs/xfs/linux-2.6/xfs_xattr.c b/fs/xfs/linux-2.6/xfs_xattr.c index 497c7fb75cc1..0b1878857fc3 100644 --- a/fs/xfs/linux-2.6/xfs_xattr.c +++ b/fs/xfs/linux-2.6/xfs_xattr.c | |||
@@ -30,10 +30,10 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | static int | 32 | static int |
33 | __xfs_xattr_get(struct inode *inode, const char *name, | 33 | xfs_xattr_get(struct dentry *dentry, const char *name, |
34 | void *value, size_t size, int xflags) | 34 | void *value, size_t size, int xflags) |
35 | { | 35 | { |
36 | struct xfs_inode *ip = XFS_I(inode); | 36 | struct xfs_inode *ip = XFS_I(dentry->d_inode); |
37 | int error, asize = size; | 37 | int error, asize = size; |
38 | 38 | ||
39 | if (strcmp(name, "") == 0) | 39 | if (strcmp(name, "") == 0) |
@@ -52,10 +52,10 @@ __xfs_xattr_get(struct inode *inode, const char *name, | |||
52 | } | 52 | } |
53 | 53 | ||
54 | static int | 54 | static int |
55 | __xfs_xattr_set(struct inode *inode, const char *name, const void *value, | 55 | xfs_xattr_set(struct dentry *dentry, const char *name, const void *value, |
56 | size_t size, int flags, int xflags) | 56 | size_t size, int flags, int xflags) |
57 | { | 57 | { |
58 | struct xfs_inode *ip = XFS_I(inode); | 58 | struct xfs_inode *ip = XFS_I(dentry->d_inode); |
59 | 59 | ||
60 | if (strcmp(name, "") == 0) | 60 | if (strcmp(name, "") == 0) |
61 | return -EINVAL; | 61 | return -EINVAL; |
@@ -71,75 +71,34 @@ __xfs_xattr_set(struct inode *inode, const char *name, const void *value, | |||
71 | return -xfs_attr_set(ip, name, (void *)value, size, xflags); | 71 | return -xfs_attr_set(ip, name, (void *)value, size, xflags); |
72 | } | 72 | } |
73 | 73 | ||
74 | static int | ||
75 | xfs_xattr_user_get(struct inode *inode, const char *name, | ||
76 | void *value, size_t size) | ||
77 | { | ||
78 | return __xfs_xattr_get(inode, name, value, size, 0); | ||
79 | } | ||
80 | |||
81 | static int | ||
82 | xfs_xattr_user_set(struct inode *inode, const char *name, | ||
83 | const void *value, size_t size, int flags) | ||
84 | { | ||
85 | return __xfs_xattr_set(inode, name, value, size, flags, 0); | ||
86 | } | ||
87 | |||
88 | static struct xattr_handler xfs_xattr_user_handler = { | 74 | static struct xattr_handler xfs_xattr_user_handler = { |
89 | .prefix = XATTR_USER_PREFIX, | 75 | .prefix = XATTR_USER_PREFIX, |
90 | .get = xfs_xattr_user_get, | 76 | .flags = 0, /* no flags implies user namespace */ |
91 | .set = xfs_xattr_user_set, | 77 | .get = xfs_xattr_get, |
78 | .set = xfs_xattr_set, | ||
92 | }; | 79 | }; |
93 | 80 | ||
94 | |||
95 | static int | ||
96 | xfs_xattr_trusted_get(struct inode *inode, const char *name, | ||
97 | void *value, size_t size) | ||
98 | { | ||
99 | return __xfs_xattr_get(inode, name, value, size, ATTR_ROOT); | ||
100 | } | ||
101 | |||
102 | static int | ||
103 | xfs_xattr_trusted_set(struct inode *inode, const char *name, | ||
104 | const void *value, size_t size, int flags) | ||
105 | { | ||
106 | return __xfs_xattr_set(inode, name, value, size, flags, ATTR_ROOT); | ||
107 | } | ||
108 | |||
109 | static struct xattr_handler xfs_xattr_trusted_handler = { | 81 | static struct xattr_handler xfs_xattr_trusted_handler = { |
110 | .prefix = XATTR_TRUSTED_PREFIX, | 82 | .prefix = XATTR_TRUSTED_PREFIX, |
111 | .get = xfs_xattr_trusted_get, | 83 | .flags = ATTR_ROOT, |
112 | .set = xfs_xattr_trusted_set, | 84 | .get = xfs_xattr_get, |
85 | .set = xfs_xattr_set, | ||
113 | }; | 86 | }; |
114 | 87 | ||
115 | |||
116 | static int | ||
117 | xfs_xattr_secure_get(struct inode *inode, const char *name, | ||
118 | void *value, size_t size) | ||
119 | { | ||
120 | return __xfs_xattr_get(inode, name, value, size, ATTR_SECURE); | ||
121 | } | ||
122 | |||
123 | static int | ||
124 | xfs_xattr_secure_set(struct inode *inode, const char *name, | ||
125 | const void *value, size_t size, int flags) | ||
126 | { | ||
127 | return __xfs_xattr_set(inode, name, value, size, flags, ATTR_SECURE); | ||
128 | } | ||
129 | |||
130 | static struct xattr_handler xfs_xattr_security_handler = { | 88 | static struct xattr_handler xfs_xattr_security_handler = { |
131 | .prefix = XATTR_SECURITY_PREFIX, | 89 | .prefix = XATTR_SECURITY_PREFIX, |
132 | .get = xfs_xattr_secure_get, | 90 | .flags = ATTR_SECURE, |
133 | .set = xfs_xattr_secure_set, | 91 | .get = xfs_xattr_get, |
92 | .set = xfs_xattr_set, | ||
134 | }; | 93 | }; |
135 | 94 | ||
136 | |||
137 | struct xattr_handler *xfs_xattr_handlers[] = { | 95 | struct xattr_handler *xfs_xattr_handlers[] = { |
138 | &xfs_xattr_user_handler, | 96 | &xfs_xattr_user_handler, |
139 | &xfs_xattr_trusted_handler, | 97 | &xfs_xattr_trusted_handler, |
140 | &xfs_xattr_security_handler, | 98 | &xfs_xattr_security_handler, |
141 | #ifdef CONFIG_XFS_POSIX_ACL | 99 | #ifdef CONFIG_XFS_POSIX_ACL |
142 | &xfs_xattr_system_handler, | 100 | &xfs_xattr_acl_access_handler, |
101 | &xfs_xattr_acl_default_handler, | ||
143 | #endif | 102 | #endif |
144 | NULL | 103 | NULL |
145 | }; | 104 | }; |
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h index 947b150df8ed..00fd357c3e46 100644 --- a/fs/xfs/xfs_acl.h +++ b/fs/xfs/xfs_acl.h | |||
@@ -49,7 +49,8 @@ extern int xfs_acl_chmod(struct inode *inode); | |||
49 | extern int posix_acl_access_exists(struct inode *inode); | 49 | extern int posix_acl_access_exists(struct inode *inode); |
50 | extern int posix_acl_default_exists(struct inode *inode); | 50 | extern int posix_acl_default_exists(struct inode *inode); |
51 | 51 | ||
52 | extern struct xattr_handler xfs_xattr_system_handler; | 52 | extern struct xattr_handler xfs_xattr_acl_access_handler; |
53 | extern struct xattr_handler xfs_xattr_acl_default_handler; | ||
53 | #else | 54 | #else |
54 | # define xfs_check_acl NULL | 55 | # define xfs_check_acl NULL |
55 | # define xfs_get_acl(inode, type) NULL | 56 | # define xfs_get_acl(inode, type) NULL |