aboutsummaryrefslogtreecommitdiffstats
path: root/mm/shmem.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-02-14 22:38:02 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-02-26 02:43:22 -0500
commit3451538a114d738a6528b1da58e19e7d8964c647 (patch)
tree6aeefee69b655c3a0817c6fb7c3771d69937e630 /mm/shmem.c
parent3f3834c35466324e3a7d7bf3a950dbcd99645f38 (diff)
shmem_setup_file(): use d_alloc_pseudo() instead of d_alloc()
Note that provided ->d_dname() reproduces what we used to get for those guys in e.g. /proc/self/maps; it might be a good idea to change that to something less ugly, but for now let's keep the existing user-visible behaviour Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r--mm/shmem.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 8b4c198552ba..25cd688bd208 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2865,6 +2865,16 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range);
2865 2865
2866/* common code */ 2866/* common code */
2867 2867
2868static char *shmem_dname(struct dentry *dentry, char *buffer, int buflen)
2869{
2870 return dynamic_dname(dentry, buffer, buflen, "/%s (deleted)",
2871 dentry->d_name.name);
2872}
2873
2874static struct dentry_operations anon_ops = {
2875 .d_dname = shmem_dname
2876};
2877
2868/** 2878/**
2869 * shmem_file_setup - get an unlinked file living in tmpfs 2879 * shmem_file_setup - get an unlinked file living in tmpfs
2870 * @name: name for dentry (to be seen in /proc/<pid>/maps 2880 * @name: name for dentry (to be seen in /proc/<pid>/maps
@@ -2876,7 +2886,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
2876 struct file *res; 2886 struct file *res;
2877 struct inode *inode; 2887 struct inode *inode;
2878 struct path path; 2888 struct path path;
2879 struct dentry *root; 2889 struct super_block *sb;
2880 struct qstr this; 2890 struct qstr this;
2881 2891
2882 if (IS_ERR(shm_mnt)) 2892 if (IS_ERR(shm_mnt))
@@ -2892,14 +2902,15 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
2892 this.name = name; 2902 this.name = name;
2893 this.len = strlen(name); 2903 this.len = strlen(name);
2894 this.hash = 0; /* will go */ 2904 this.hash = 0; /* will go */
2895 root = shm_mnt->mnt_root; 2905 sb = shm_mnt->mnt_sb;
2896 path.dentry = d_alloc(root, &this); 2906 path.dentry = d_alloc_pseudo(sb, &this);
2897 if (!path.dentry) 2907 if (!path.dentry)
2898 goto put_memory; 2908 goto put_memory;
2909 d_set_d_op(path.dentry, &anon_ops);
2899 path.mnt = mntget(shm_mnt); 2910 path.mnt = mntget(shm_mnt);
2900 2911
2901 res = ERR_PTR(-ENOSPC); 2912 res = ERR_PTR(-ENOSPC);
2902 inode = shmem_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0, flags); 2913 inode = shmem_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0, flags);
2903 if (!inode) 2914 if (!inode)
2904 goto put_dentry; 2915 goto put_dentry;
2905 2916