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 /mm/shmem.c | |
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 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index 4fb41c83daca..f8485062f3ba 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/swap.h> | 31 | #include <linux/swap.h> |
32 | #include <linux/ima.h> | ||
33 | 32 | ||
34 | static struct vfsmount *shm_mnt; | 33 | static struct vfsmount *shm_mnt; |
35 | 34 | ||
@@ -42,6 +41,7 @@ static struct vfsmount *shm_mnt; | |||
42 | 41 | ||
43 | #include <linux/xattr.h> | 42 | #include <linux/xattr.h> |
44 | #include <linux/exportfs.h> | 43 | #include <linux/exportfs.h> |
44 | #include <linux/posix_acl.h> | ||
45 | #include <linux/generic_acl.h> | 45 | #include <linux/generic_acl.h> |
46 | #include <linux/mman.h> | 46 | #include <linux/mman.h> |
47 | #include <linux/string.h> | 47 | #include <linux/string.h> |
@@ -810,7 +810,7 @@ static int shmem_notify_change(struct dentry *dentry, struct iattr *attr) | |||
810 | error = inode_setattr(inode, attr); | 810 | error = inode_setattr(inode, attr); |
811 | #ifdef CONFIG_TMPFS_POSIX_ACL | 811 | #ifdef CONFIG_TMPFS_POSIX_ACL |
812 | if (!error && (attr->ia_valid & ATTR_MODE)) | 812 | if (!error && (attr->ia_valid & ATTR_MODE)) |
813 | error = generic_acl_chmod(inode, &shmem_acl_ops); | 813 | error = generic_acl_chmod(inode); |
814 | #endif | 814 | #endif |
815 | if (page) | 815 | if (page) |
816 | page_cache_release(page); | 816 | page_cache_release(page); |
@@ -1824,11 +1824,13 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | |||
1824 | return error; | 1824 | return error; |
1825 | } | 1825 | } |
1826 | } | 1826 | } |
1827 | error = shmem_acl_init(inode, dir); | 1827 | #ifdef CONFIG_TMPFS_POSIX_ACL |
1828 | error = generic_acl_init(inode, dir); | ||
1828 | if (error) { | 1829 | if (error) { |
1829 | iput(inode); | 1830 | iput(inode); |
1830 | return error; | 1831 | return error; |
1831 | } | 1832 | } |
1833 | #endif | ||
1832 | if (dir->i_mode & S_ISGID) { | 1834 | if (dir->i_mode & S_ISGID) { |
1833 | inode->i_gid = dir->i_gid; | 1835 | inode->i_gid = dir->i_gid; |
1834 | if (S_ISDIR(mode)) | 1836 | if (S_ISDIR(mode)) |
@@ -2043,27 +2045,28 @@ static const struct inode_operations shmem_symlink_inode_operations = { | |||
2043 | * filesystem level, though. | 2045 | * filesystem level, though. |
2044 | */ | 2046 | */ |
2045 | 2047 | ||
2046 | static size_t shmem_xattr_security_list(struct inode *inode, char *list, | 2048 | static size_t shmem_xattr_security_list(struct dentry *dentry, char *list, |
2047 | size_t list_len, const char *name, | 2049 | size_t list_len, const char *name, |
2048 | size_t name_len) | 2050 | size_t name_len, int handler_flags) |
2049 | { | 2051 | { |
2050 | return security_inode_listsecurity(inode, list, list_len); | 2052 | return security_inode_listsecurity(dentry->d_inode, list, list_len); |
2051 | } | 2053 | } |
2052 | 2054 | ||
2053 | static int shmem_xattr_security_get(struct inode *inode, const char *name, | 2055 | static int shmem_xattr_security_get(struct dentry *dentry, const char *name, |
2054 | void *buffer, size_t size) | 2056 | void *buffer, size_t size, int handler_flags) |
2055 | { | 2057 | { |
2056 | if (strcmp(name, "") == 0) | 2058 | if (strcmp(name, "") == 0) |
2057 | return -EINVAL; | 2059 | return -EINVAL; |
2058 | return xattr_getsecurity(inode, name, buffer, size); | 2060 | return xattr_getsecurity(dentry->d_inode, name, buffer, size); |
2059 | } | 2061 | } |
2060 | 2062 | ||
2061 | static int shmem_xattr_security_set(struct inode *inode, const char *name, | 2063 | static int shmem_xattr_security_set(struct dentry *dentry, const char *name, |
2062 | const void *value, size_t size, int flags) | 2064 | const void *value, size_t size, int flags, int handler_flags) |
2063 | { | 2065 | { |
2064 | if (strcmp(name, "") == 0) | 2066 | if (strcmp(name, "") == 0) |
2065 | return -EINVAL; | 2067 | return -EINVAL; |
2066 | return security_inode_setsecurity(inode, name, value, size, flags); | 2068 | return security_inode_setsecurity(dentry->d_inode, name, value, |
2069 | size, flags); | ||
2067 | } | 2070 | } |
2068 | 2071 | ||
2069 | static struct xattr_handler shmem_xattr_security_handler = { | 2072 | static struct xattr_handler shmem_xattr_security_handler = { |
@@ -2074,8 +2077,8 @@ static struct xattr_handler shmem_xattr_security_handler = { | |||
2074 | }; | 2077 | }; |
2075 | 2078 | ||
2076 | static struct xattr_handler *shmem_xattr_handlers[] = { | 2079 | static struct xattr_handler *shmem_xattr_handlers[] = { |
2077 | &shmem_xattr_acl_access_handler, | 2080 | &generic_acl_access_handler, |
2078 | &shmem_xattr_acl_default_handler, | 2081 | &generic_acl_default_handler, |
2079 | &shmem_xattr_security_handler, | 2082 | &shmem_xattr_security_handler, |
2080 | NULL | 2083 | NULL |
2081 | }; | 2084 | }; |
@@ -2454,7 +2457,7 @@ static const struct inode_operations shmem_inode_operations = { | |||
2454 | .getxattr = generic_getxattr, | 2457 | .getxattr = generic_getxattr, |
2455 | .listxattr = generic_listxattr, | 2458 | .listxattr = generic_listxattr, |
2456 | .removexattr = generic_removexattr, | 2459 | .removexattr = generic_removexattr, |
2457 | .check_acl = shmem_check_acl, | 2460 | .check_acl = generic_check_acl, |
2458 | #endif | 2461 | #endif |
2459 | 2462 | ||
2460 | }; | 2463 | }; |
@@ -2477,7 +2480,7 @@ static const struct inode_operations shmem_dir_inode_operations = { | |||
2477 | .getxattr = generic_getxattr, | 2480 | .getxattr = generic_getxattr, |
2478 | .listxattr = generic_listxattr, | 2481 | .listxattr = generic_listxattr, |
2479 | .removexattr = generic_removexattr, | 2482 | .removexattr = generic_removexattr, |
2480 | .check_acl = shmem_check_acl, | 2483 | .check_acl = generic_check_acl, |
2481 | #endif | 2484 | #endif |
2482 | }; | 2485 | }; |
2483 | 2486 | ||
@@ -2488,7 +2491,7 @@ static const struct inode_operations shmem_special_inode_operations = { | |||
2488 | .getxattr = generic_getxattr, | 2491 | .getxattr = generic_getxattr, |
2489 | .listxattr = generic_listxattr, | 2492 | .listxattr = generic_listxattr, |
2490 | .removexattr = generic_removexattr, | 2493 | .removexattr = generic_removexattr, |
2491 | .check_acl = shmem_check_acl, | 2494 | .check_acl = generic_check_acl, |
2492 | #endif | 2495 | #endif |
2493 | }; | 2496 | }; |
2494 | 2497 | ||
@@ -2626,7 +2629,8 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags | |||
2626 | int error; | 2629 | int error; |
2627 | struct file *file; | 2630 | struct file *file; |
2628 | struct inode *inode; | 2631 | struct inode *inode; |
2629 | struct dentry *dentry, *root; | 2632 | struct path path; |
2633 | struct dentry *root; | ||
2630 | struct qstr this; | 2634 | struct qstr this; |
2631 | 2635 | ||
2632 | if (IS_ERR(shm_mnt)) | 2636 | if (IS_ERR(shm_mnt)) |
@@ -2643,38 +2647,35 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags | |||
2643 | this.len = strlen(name); | 2647 | this.len = strlen(name); |
2644 | this.hash = 0; /* will go */ | 2648 | this.hash = 0; /* will go */ |
2645 | root = shm_mnt->mnt_root; | 2649 | root = shm_mnt->mnt_root; |
2646 | dentry = d_alloc(root, &this); | 2650 | path.dentry = d_alloc(root, &this); |
2647 | if (!dentry) | 2651 | if (!path.dentry) |
2648 | goto put_memory; | 2652 | goto put_memory; |
2649 | 2653 | path.mnt = mntget(shm_mnt); | |
2650 | error = -ENFILE; | ||
2651 | file = get_empty_filp(); | ||
2652 | if (!file) | ||
2653 | goto put_dentry; | ||
2654 | 2654 | ||
2655 | error = -ENOSPC; | 2655 | error = -ENOSPC; |
2656 | inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0, flags); | 2656 | inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0, flags); |
2657 | if (!inode) | 2657 | if (!inode) |
2658 | goto close_file; | 2658 | goto put_dentry; |
2659 | 2659 | ||
2660 | d_instantiate(dentry, inode); | 2660 | d_instantiate(path.dentry, inode); |
2661 | inode->i_size = size; | 2661 | inode->i_size = size; |
2662 | inode->i_nlink = 0; /* It is unlinked */ | 2662 | inode->i_nlink = 0; /* It is unlinked */ |
2663 | init_file(file, shm_mnt, dentry, FMODE_WRITE | FMODE_READ, | ||
2664 | &shmem_file_operations); | ||
2665 | |||
2666 | #ifndef CONFIG_MMU | 2663 | #ifndef CONFIG_MMU |
2667 | error = ramfs_nommu_expand_for_mapping(inode, size); | 2664 | error = ramfs_nommu_expand_for_mapping(inode, size); |
2668 | if (error) | 2665 | if (error) |
2669 | goto close_file; | 2666 | goto put_dentry; |
2670 | #endif | 2667 | #endif |
2671 | ima_counts_get(file); | 2668 | |
2669 | error = -ENFILE; | ||
2670 | file = alloc_file(&path, FMODE_WRITE | FMODE_READ, | ||
2671 | &shmem_file_operations); | ||
2672 | if (!file) | ||
2673 | goto put_dentry; | ||
2674 | |||
2672 | return file; | 2675 | return file; |
2673 | 2676 | ||
2674 | close_file: | ||
2675 | put_filp(file); | ||
2676 | put_dentry: | 2677 | put_dentry: |
2677 | dput(dentry); | 2678 | path_put(&path); |
2678 | put_memory: | 2679 | put_memory: |
2679 | shmem_unacct_size(flags, size); | 2680 | shmem_unacct_size(flags, size); |
2680 | return ERR_PTR(error); | 2681 | return ERR_PTR(error); |