aboutsummaryrefslogtreecommitdiffstats
path: root/mm/shmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/shmem.c')
-rw-r--r--mm/shmem.c91
1 files changed, 5 insertions, 86 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 5a81b1ee4f7a..bdc4bbb6ddbb 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -45,7 +45,6 @@
45#include <linux/swapops.h> 45#include <linux/swapops.h>
46#include <linux/mempolicy.h> 46#include <linux/mempolicy.h>
47#include <linux/namei.h> 47#include <linux/namei.h>
48#include <linux/xattr.h>
49#include <asm/uaccess.h> 48#include <asm/uaccess.h>
50#include <asm/div64.h> 49#include <asm/div64.h>
51#include <asm/pgtable.h> 50#include <asm/pgtable.h>
@@ -179,7 +178,6 @@ static struct address_space_operations shmem_aops;
179static struct file_operations shmem_file_operations; 178static struct file_operations shmem_file_operations;
180static struct inode_operations shmem_inode_operations; 179static struct inode_operations shmem_inode_operations;
181static struct inode_operations shmem_dir_inode_operations; 180static struct inode_operations shmem_dir_inode_operations;
182static struct inode_operations shmem_special_inode_operations;
183static struct vm_operations_struct shmem_vm_ops; 181static struct vm_operations_struct shmem_vm_ops;
184 182
185static struct backing_dev_info shmem_backing_dev_info = { 183static struct backing_dev_info shmem_backing_dev_info = {
@@ -1195,6 +1193,7 @@ static int shmem_populate(struct vm_area_struct *vma,
1195 err = shmem_getpage(inode, pgoff, &page, sgp, NULL); 1193 err = shmem_getpage(inode, pgoff, &page, sgp, NULL);
1196 if (err) 1194 if (err)
1197 return err; 1195 return err;
1196 /* Page may still be null, but only if nonblock was set. */
1198 if (page) { 1197 if (page) {
1199 mark_page_accessed(page); 1198 mark_page_accessed(page);
1200 err = install_page(mm, vma, addr, page, prot); 1199 err = install_page(mm, vma, addr, page, prot);
@@ -1202,7 +1201,10 @@ static int shmem_populate(struct vm_area_struct *vma,
1202 page_cache_release(page); 1201 page_cache_release(page);
1203 return err; 1202 return err;
1204 } 1203 }
1205 } else if (nonblock) { 1204 } else {
1205 /* No page was found just because we can't read it in
1206 * now (being here implies nonblock != 0), but the page
1207 * may exist, so set the PTE to fault it in later. */
1206 err = install_file_pte(mm, vma, addr, pgoff, prot); 1208 err = install_file_pte(mm, vma, addr, pgoff, prot);
1207 if (err) 1209 if (err)
1208 return err; 1210 return err;
@@ -1296,7 +1298,6 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
1296 1298
1297 switch (mode & S_IFMT) { 1299 switch (mode & S_IFMT) {
1298 default: 1300 default:
1299 inode->i_op = &shmem_special_inode_operations;
1300 init_special_inode(inode, mode, dev); 1301 init_special_inode(inode, mode, dev);
1301 break; 1302 break;
1302 case S_IFREG: 1303 case S_IFREG:
@@ -1800,12 +1801,6 @@ static void shmem_put_link(struct dentry *dentry, struct nameidata *nd, void *co
1800static struct inode_operations shmem_symlink_inline_operations = { 1801static struct inode_operations shmem_symlink_inline_operations = {
1801 .readlink = generic_readlink, 1802 .readlink = generic_readlink,
1802 .follow_link = shmem_follow_link_inline, 1803 .follow_link = shmem_follow_link_inline,
1803#ifdef CONFIG_TMPFS_XATTR
1804 .setxattr = generic_setxattr,
1805 .getxattr = generic_getxattr,
1806 .listxattr = generic_listxattr,
1807 .removexattr = generic_removexattr,
1808#endif
1809}; 1804};
1810 1805
1811static struct inode_operations shmem_symlink_inode_operations = { 1806static struct inode_operations shmem_symlink_inode_operations = {
@@ -1813,12 +1808,6 @@ static struct inode_operations shmem_symlink_inode_operations = {
1813 .readlink = generic_readlink, 1808 .readlink = generic_readlink,
1814 .follow_link = shmem_follow_link, 1809 .follow_link = shmem_follow_link,
1815 .put_link = shmem_put_link, 1810 .put_link = shmem_put_link,
1816#ifdef CONFIG_TMPFS_XATTR
1817 .setxattr = generic_setxattr,
1818 .getxattr = generic_getxattr,
1819 .listxattr = generic_listxattr,
1820 .removexattr = generic_removexattr,
1821#endif
1822}; 1811};
1823 1812
1824static int shmem_parse_options(char *options, int *mode, uid_t *uid, gid_t *gid, unsigned long *blocks, unsigned long *inodes) 1813static int shmem_parse_options(char *options, int *mode, uid_t *uid, gid_t *gid, unsigned long *blocks, unsigned long *inodes)
@@ -1938,12 +1927,6 @@ static void shmem_put_super(struct super_block *sb)
1938 sb->s_fs_info = NULL; 1927 sb->s_fs_info = NULL;
1939} 1928}
1940 1929
1941#ifdef CONFIG_TMPFS_XATTR
1942static struct xattr_handler *shmem_xattr_handlers[];
1943#else
1944#define shmem_xattr_handlers NULL
1945#endif
1946
1947static int shmem_fill_super(struct super_block *sb, 1930static int shmem_fill_super(struct super_block *sb,
1948 void *data, int silent) 1931 void *data, int silent)
1949{ 1932{
@@ -1994,7 +1977,6 @@ static int shmem_fill_super(struct super_block *sb,
1994 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; 1977 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
1995 sb->s_magic = TMPFS_MAGIC; 1978 sb->s_magic = TMPFS_MAGIC;
1996 sb->s_op = &shmem_ops; 1979 sb->s_op = &shmem_ops;
1997 sb->s_xattr = shmem_xattr_handlers;
1998 1980
1999 inode = shmem_get_inode(sb, S_IFDIR | mode, 0); 1981 inode = shmem_get_inode(sb, S_IFDIR | mode, 0);
2000 if (!inode) 1982 if (!inode)
@@ -2083,12 +2065,6 @@ static struct file_operations shmem_file_operations = {
2083static struct inode_operations shmem_inode_operations = { 2065static struct inode_operations shmem_inode_operations = {
2084 .truncate = shmem_truncate, 2066 .truncate = shmem_truncate,
2085 .setattr = shmem_notify_change, 2067 .setattr = shmem_notify_change,
2086#ifdef CONFIG_TMPFS_XATTR
2087 .setxattr = generic_setxattr,
2088 .getxattr = generic_getxattr,
2089 .listxattr = generic_listxattr,
2090 .removexattr = generic_removexattr,
2091#endif
2092}; 2068};
2093 2069
2094static struct inode_operations shmem_dir_inode_operations = { 2070static struct inode_operations shmem_dir_inode_operations = {
@@ -2102,21 +2078,6 @@ static struct inode_operations shmem_dir_inode_operations = {
2102 .rmdir = shmem_rmdir, 2078 .rmdir = shmem_rmdir,
2103 .mknod = shmem_mknod, 2079 .mknod = shmem_mknod,
2104 .rename = shmem_rename, 2080 .rename = shmem_rename,
2105#ifdef CONFIG_TMPFS_XATTR
2106 .setxattr = generic_setxattr,
2107 .getxattr = generic_getxattr,
2108 .listxattr = generic_listxattr,
2109 .removexattr = generic_removexattr,
2110#endif
2111#endif
2112};
2113
2114static struct inode_operations shmem_special_inode_operations = {
2115#ifdef CONFIG_TMPFS_XATTR
2116 .setxattr = generic_setxattr,
2117 .getxattr = generic_getxattr,
2118 .listxattr = generic_listxattr,
2119 .removexattr = generic_removexattr,
2120#endif 2081#endif
2121}; 2082};
2122 2083
@@ -2142,48 +2103,6 @@ static struct vm_operations_struct shmem_vm_ops = {
2142}; 2103};
2143 2104
2144 2105
2145#ifdef CONFIG_TMPFS_SECURITY
2146
2147static size_t shmem_xattr_security_list(struct inode *inode, char *list, size_t list_len,
2148 const char *name, size_t name_len)
2149{
2150 return security_inode_listsecurity(inode, list, list_len);
2151}
2152
2153static int shmem_xattr_security_get(struct inode *inode, const char *name, void *buffer, size_t size)
2154{
2155 if (strcmp(name, "") == 0)
2156 return -EINVAL;
2157 return security_inode_getsecurity(inode, name, buffer, size);
2158}
2159
2160static int shmem_xattr_security_set(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2161{
2162 if (strcmp(name, "") == 0)
2163 return -EINVAL;
2164 return security_inode_setsecurity(inode, name, value, size, flags);
2165}
2166
2167static struct xattr_handler shmem_xattr_security_handler = {
2168 .prefix = XATTR_SECURITY_PREFIX,
2169 .list = shmem_xattr_security_list,
2170 .get = shmem_xattr_security_get,
2171 .set = shmem_xattr_security_set,
2172};
2173
2174#endif /* CONFIG_TMPFS_SECURITY */
2175
2176#ifdef CONFIG_TMPFS_XATTR
2177
2178static struct xattr_handler *shmem_xattr_handlers[] = {
2179#ifdef CONFIG_TMPFS_SECURITY
2180 &shmem_xattr_security_handler,
2181#endif
2182 NULL
2183};
2184
2185#endif /* CONFIG_TMPFS_XATTR */
2186
2187static struct super_block *shmem_get_sb(struct file_system_type *fs_type, 2106static struct super_block *shmem_get_sb(struct file_system_type *fs_type,
2188 int flags, const char *dev_name, void *data) 2107 int flags, const char *dev_name, void *data)
2189{ 2108{