Commit 7b540d06 authored by Al Viro's avatar Al Viro

proc_map_files_readdir(): don't bother with grabbing files

all we need is their ->f_mode, so just collect _that_
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent cb0942b8
...@@ -1805,7 +1805,7 @@ static int proc_map_files_get_link(struct dentry *dentry, struct path *path) ...@@ -1805,7 +1805,7 @@ static int proc_map_files_get_link(struct dentry *dentry, struct path *path)
} }
struct map_files_info { struct map_files_info {
struct file *file; fmode_t mode;
unsigned long len; unsigned long len;
unsigned char name[4*sizeof(long)+2]; /* max: %lx-%lx\0 */ unsigned char name[4*sizeof(long)+2]; /* max: %lx-%lx\0 */
}; };
...@@ -1814,13 +1814,10 @@ static struct dentry * ...@@ -1814,13 +1814,10 @@ static struct dentry *
proc_map_files_instantiate(struct inode *dir, struct dentry *dentry, proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
struct task_struct *task, const void *ptr) struct task_struct *task, const void *ptr)
{ {
const struct file *file = ptr; fmode_t mode = (fmode_t)(unsigned long)ptr;
struct proc_inode *ei; struct proc_inode *ei;
struct inode *inode; struct inode *inode;
if (!file)
return ERR_PTR(-ENOENT);
inode = proc_pid_make_inode(dir->i_sb, task); inode = proc_pid_make_inode(dir->i_sb, task);
if (!inode) if (!inode)
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
...@@ -1832,9 +1829,9 @@ proc_map_files_instantiate(struct inode *dir, struct dentry *dentry, ...@@ -1832,9 +1829,9 @@ proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
inode->i_size = 64; inode->i_size = 64;
inode->i_mode = S_IFLNK; inode->i_mode = S_IFLNK;
if (file->f_mode & FMODE_READ) if (mode & FMODE_READ)
inode->i_mode |= S_IRUSR; inode->i_mode |= S_IRUSR;
if (file->f_mode & FMODE_WRITE) if (mode & FMODE_WRITE)
inode->i_mode |= S_IWUSR; inode->i_mode |= S_IWUSR;
d_set_d_op(dentry, &tid_map_files_dentry_operations); d_set_d_op(dentry, &tid_map_files_dentry_operations);
...@@ -1878,7 +1875,8 @@ static struct dentry *proc_map_files_lookup(struct inode *dir, ...@@ -1878,7 +1875,8 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
if (!vma) if (!vma)
goto out_no_vma; goto out_no_vma;
result = proc_map_files_instantiate(dir, dentry, task, vma->vm_file); result = proc_map_files_instantiate(dir, dentry, task,
(void *)(unsigned long)vma->vm_file->f_mode);
out_no_vma: out_no_vma:
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
...@@ -1979,7 +1977,7 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -1979,7 +1977,7 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (++pos <= filp->f_pos) if (++pos <= filp->f_pos)
continue; continue;
info.file = get_file(vma->vm_file); info.mode = vma->vm_file->f_mode;
info.len = snprintf(info.name, info.len = snprintf(info.name,
sizeof(info.name), "%lx-%lx", sizeof(info.name), "%lx-%lx",
vma->vm_start, vma->vm_end); vma->vm_start, vma->vm_end);
...@@ -1994,19 +1992,11 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -1994,19 +1992,11 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)
ret = proc_fill_cache(filp, dirent, filldir, ret = proc_fill_cache(filp, dirent, filldir,
p->name, p->len, p->name, p->len,
proc_map_files_instantiate, proc_map_files_instantiate,
task, p->file); task,
(void *)(unsigned long)p->mode);
if (ret) if (ret)
break; break;
filp->f_pos++; filp->f_pos++;
fput(p->file);
}
for (; i < nr_files; i++) {
/*
* In case of error don't forget
* to put rest of file refs.
*/
p = flex_array_get(fa, i);
fput(p->file);
} }
if (fa) if (fa)
flex_array_free(fa); flex_array_free(fa);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment