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>
This commit is contained in:
parent
3f3834c354
commit
3451538a11
1 changed files with 15 additions and 4 deletions
19
mm/shmem.c
19
mm/shmem.c
|
@ -2865,6 +2865,16 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range);
|
||||||
|
|
||||||
/* common code */
|
/* common code */
|
||||||
|
|
||||||
|
static char *shmem_dname(struct dentry *dentry, char *buffer, int buflen)
|
||||||
|
{
|
||||||
|
return dynamic_dname(dentry, buffer, buflen, "/%s (deleted)",
|
||||||
|
dentry->d_name.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct dentry_operations anon_ops = {
|
||||||
|
.d_dname = shmem_dname
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* shmem_file_setup - get an unlinked file living in tmpfs
|
* shmem_file_setup - get an unlinked file living in tmpfs
|
||||||
* @name: name for dentry (to be seen in /proc/<pid>/maps
|
* @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
|
||||||
struct file *res;
|
struct file *res;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct path path;
|
struct path path;
|
||||||
struct dentry *root;
|
struct super_block *sb;
|
||||||
struct qstr this;
|
struct qstr this;
|
||||||
|
|
||||||
if (IS_ERR(shm_mnt))
|
if (IS_ERR(shm_mnt))
|
||||||
|
@ -2892,14 +2902,15 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.len = strlen(name);
|
this.len = strlen(name);
|
||||||
this.hash = 0; /* will go */
|
this.hash = 0; /* will go */
|
||||||
root = shm_mnt->mnt_root;
|
sb = shm_mnt->mnt_sb;
|
||||||
path.dentry = d_alloc(root, &this);
|
path.dentry = d_alloc_pseudo(sb, &this);
|
||||||
if (!path.dentry)
|
if (!path.dentry)
|
||||||
goto put_memory;
|
goto put_memory;
|
||||||
|
d_set_d_op(path.dentry, &anon_ops);
|
||||||
path.mnt = mntget(shm_mnt);
|
path.mnt = mntget(shm_mnt);
|
||||||
|
|
||||||
res = ERR_PTR(-ENOSPC);
|
res = ERR_PTR(-ENOSPC);
|
||||||
inode = shmem_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0, flags);
|
inode = shmem_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0, flags);
|
||||||
if (!inode)
|
if (!inode)
|
||||||
goto put_dentry;
|
goto put_dentry;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue