proc_fill_cache(): just make instantiate_t return int
all instances always return ERR_PTR(-E...) or NULL, anyway Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
db96316487
commit
c52a47ace7
@ -1700,7 +1700,7 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,
|
||||
struct dentry *new;
|
||||
new = d_alloc(dir, &qname);
|
||||
if (new) {
|
||||
child = instantiate(dir->d_inode, new, task, ptr);
|
||||
child = ERR_PTR(instantiate(dir->d_inode, new, task, ptr));
|
||||
if (child)
|
||||
dput(new);
|
||||
else
|
||||
@ -1844,7 +1844,7 @@ struct map_files_info {
|
||||
unsigned char name[4*sizeof(long)+2]; /* max: %lx-%lx\0 */
|
||||
};
|
||||
|
||||
static struct dentry *
|
||||
static int
|
||||
proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
|
||||
struct task_struct *task, const void *ptr)
|
||||
{
|
||||
@ -1854,7 +1854,7 @@ proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
|
||||
|
||||
inode = proc_pid_make_inode(dir->i_sb, task);
|
||||
if (!inode)
|
||||
return ERR_PTR(-ENOENT);
|
||||
return -ENOENT;
|
||||
|
||||
ei = PROC_I(inode);
|
||||
ei->op.proc_get_link = proc_map_files_get_link;
|
||||
@ -1871,7 +1871,7 @@ proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
|
||||
d_set_d_op(dentry, &tid_map_files_dentry_operations);
|
||||
d_add(dentry, inode);
|
||||
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct dentry *proc_map_files_lookup(struct inode *dir,
|
||||
@ -1880,23 +1880,23 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
|
||||
unsigned long vm_start, vm_end;
|
||||
struct vm_area_struct *vma;
|
||||
struct task_struct *task;
|
||||
struct dentry *result;
|
||||
int result;
|
||||
struct mm_struct *mm;
|
||||
|
||||
result = ERR_PTR(-EPERM);
|
||||
result = -EPERM;
|
||||
if (!capable(CAP_SYS_ADMIN))
|
||||
goto out;
|
||||
|
||||
result = ERR_PTR(-ENOENT);
|
||||
result = -ENOENT;
|
||||
task = get_proc_task(dir);
|
||||
if (!task)
|
||||
goto out;
|
||||
|
||||
result = ERR_PTR(-EACCES);
|
||||
result = -EACCES;
|
||||
if (!ptrace_may_access(task, PTRACE_MODE_READ))
|
||||
goto out_put_task;
|
||||
|
||||
result = ERR_PTR(-ENOENT);
|
||||
result = -ENOENT;
|
||||
if (dname_to_vma_addr(dentry, &vm_start, &vm_end))
|
||||
goto out_put_task;
|
||||
|
||||
@ -1919,7 +1919,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
|
||||
out_put_task:
|
||||
put_task_struct(task);
|
||||
out:
|
||||
return result;
|
||||
return ERR_PTR(result);
|
||||
}
|
||||
|
||||
static const struct inode_operations proc_map_files_inode_operations = {
|
||||
@ -2133,13 +2133,12 @@ static const struct file_operations proc_timers_operations = {
|
||||
};
|
||||
#endif /* CONFIG_CHECKPOINT_RESTORE */
|
||||
|
||||
static struct dentry *proc_pident_instantiate(struct inode *dir,
|
||||
static int proc_pident_instantiate(struct inode *dir,
|
||||
struct dentry *dentry, struct task_struct *task, const void *ptr)
|
||||
{
|
||||
const struct pid_entry *p = ptr;
|
||||
struct inode *inode;
|
||||
struct proc_inode *ei;
|
||||
struct dentry *error = ERR_PTR(-ENOENT);
|
||||
|
||||
inode = proc_pid_make_inode(dir->i_sb, task);
|
||||
if (!inode)
|
||||
@ -2158,9 +2157,9 @@ static struct dentry *proc_pident_instantiate(struct inode *dir,
|
||||
d_add(dentry, inode);
|
||||
/* Close the race of the process dying before we return the dentry */
|
||||
if (pid_revalidate(dentry, 0))
|
||||
error = NULL;
|
||||
return 0;
|
||||
out:
|
||||
return error;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static struct dentry *proc_pident_lookup(struct inode *dir,
|
||||
@ -2168,11 +2167,11 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
|
||||
const struct pid_entry *ents,
|
||||
unsigned int nents)
|
||||
{
|
||||
struct dentry *error;
|
||||
int error;
|
||||
struct task_struct *task = get_proc_task(dir);
|
||||
const struct pid_entry *p, *last;
|
||||
|
||||
error = ERR_PTR(-ENOENT);
|
||||
error = -ENOENT;
|
||||
|
||||
if (!task)
|
||||
goto out_no_task;
|
||||
@ -2195,7 +2194,7 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
|
||||
out:
|
||||
put_task_struct(task);
|
||||
out_no_task:
|
||||
return error;
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
|
||||
static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
|
||||
@ -2778,11 +2777,10 @@ void proc_flush_task(struct task_struct *task)
|
||||
}
|
||||
}
|
||||
|
||||
static struct dentry *proc_pid_instantiate(struct inode *dir,
|
||||
struct dentry * dentry,
|
||||
struct task_struct *task, const void *ptr)
|
||||
static int proc_pid_instantiate(struct inode *dir,
|
||||
struct dentry * dentry,
|
||||
struct task_struct *task, const void *ptr)
|
||||
{
|
||||
struct dentry *error = ERR_PTR(-ENOENT);
|
||||
struct inode *inode;
|
||||
|
||||
inode = proc_pid_make_inode(dir->i_sb, task);
|
||||
@ -2802,14 +2800,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
|
||||
d_add(dentry, inode);
|
||||
/* Close the race of the process dying before we return the dentry */
|
||||
if (pid_revalidate(dentry, 0))
|
||||
error = NULL;
|
||||
return 0;
|
||||
out:
|
||||
return error;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags)
|
||||
{
|
||||
struct dentry *result = NULL;
|
||||
int result = 0;
|
||||
struct task_struct *task;
|
||||
unsigned tgid;
|
||||
struct pid_namespace *ns;
|
||||
@ -2830,7 +2828,7 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
|
||||
result = proc_pid_instantiate(dir, dentry, task, NULL);
|
||||
put_task_struct(task);
|
||||
out:
|
||||
return result;
|
||||
return ERR_PTR(result);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3025,10 +3023,9 @@ static const struct inode_operations proc_tid_base_inode_operations = {
|
||||
.setattr = proc_setattr,
|
||||
};
|
||||
|
||||
static struct dentry *proc_task_instantiate(struct inode *dir,
|
||||
static int proc_task_instantiate(struct inode *dir,
|
||||
struct dentry *dentry, struct task_struct *task, const void *ptr)
|
||||
{
|
||||
struct dentry *error = ERR_PTR(-ENOENT);
|
||||
struct inode *inode;
|
||||
inode = proc_pid_make_inode(dir->i_sb, task);
|
||||
|
||||
@ -3047,14 +3044,14 @@ static struct dentry *proc_task_instantiate(struct inode *dir,
|
||||
d_add(dentry, inode);
|
||||
/* Close the race of the process dying before we return the dentry */
|
||||
if (pid_revalidate(dentry, 0))
|
||||
error = NULL;
|
||||
return 0;
|
||||
out:
|
||||
return error;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags)
|
||||
{
|
||||
struct dentry *result = ERR_PTR(-ENOENT);
|
||||
int result = -ENOENT;
|
||||
struct task_struct *task;
|
||||
struct task_struct *leader = get_proc_task(dir);
|
||||
unsigned tid;
|
||||
@ -3084,7 +3081,7 @@ static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry
|
||||
out:
|
||||
put_task_struct(leader);
|
||||
out_no_task:
|
||||
return result;
|
||||
return ERR_PTR(result);
|
||||
}
|
||||
|
||||
/*
|
||||
|
18
fs/proc/fd.c
18
fs/proc/fd.c
@ -167,11 +167,10 @@ static int proc_fd_link(struct dentry *dentry, struct path *path)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct dentry *
|
||||
static int
|
||||
proc_fd_instantiate(struct inode *dir, struct dentry *dentry,
|
||||
struct task_struct *task, const void *ptr)
|
||||
{
|
||||
struct dentry *error = ERR_PTR(-ENOENT);
|
||||
unsigned fd = (unsigned long)ptr;
|
||||
struct proc_inode *ei;
|
||||
struct inode *inode;
|
||||
@ -194,9 +193,9 @@ proc_fd_instantiate(struct inode *dir, struct dentry *dentry,
|
||||
|
||||
/* Close the race of the process dying before we return the dentry */
|
||||
if (tid_fd_revalidate(dentry, 0))
|
||||
error = NULL;
|
||||
return 0;
|
||||
out:
|
||||
return error;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static struct dentry *proc_lookupfd_common(struct inode *dir,
|
||||
@ -204,7 +203,7 @@ static struct dentry *proc_lookupfd_common(struct inode *dir,
|
||||
instantiate_t instantiate)
|
||||
{
|
||||
struct task_struct *task = get_proc_task(dir);
|
||||
struct dentry *result = ERR_PTR(-ENOENT);
|
||||
int result = -ENOENT;
|
||||
unsigned fd = name_to_int(dentry);
|
||||
|
||||
if (!task)
|
||||
@ -216,7 +215,7 @@ static struct dentry *proc_lookupfd_common(struct inode *dir,
|
||||
out:
|
||||
put_task_struct(task);
|
||||
out_no_task:
|
||||
return result;
|
||||
return ERR_PTR(result);
|
||||
}
|
||||
|
||||
static int proc_readfd_common(struct file *file, struct dir_context *ctx,
|
||||
@ -300,11 +299,10 @@ const struct inode_operations proc_fd_inode_operations = {
|
||||
.setattr = proc_setattr,
|
||||
};
|
||||
|
||||
static struct dentry *
|
||||
static int
|
||||
proc_fdinfo_instantiate(struct inode *dir, struct dentry *dentry,
|
||||
struct task_struct *task, const void *ptr)
|
||||
{
|
||||
struct dentry *error = ERR_PTR(-ENOENT);
|
||||
unsigned fd = (unsigned long)ptr;
|
||||
struct proc_inode *ei;
|
||||
struct inode *inode;
|
||||
@ -324,9 +322,9 @@ proc_fdinfo_instantiate(struct inode *dir, struct dentry *dentry,
|
||||
|
||||
/* Close the race of the process dying before we return the dentry */
|
||||
if (tid_fd_revalidate(dentry, 0))
|
||||
error = NULL;
|
||||
return 0;
|
||||
out:
|
||||
return error;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static struct dentry *
|
||||
|
@ -170,7 +170,7 @@ extern struct dentry *proc_pid_lookup(struct inode *, struct dentry *, unsigned
|
||||
extern loff_t mem_lseek(struct file *, loff_t, int);
|
||||
|
||||
/* Lookups */
|
||||
typedef struct dentry *instantiate_t(struct inode *, struct dentry *,
|
||||
typedef int instantiate_t(struct inode *, struct dentry *,
|
||||
struct task_struct *, const void *);
|
||||
extern bool proc_fill_cache(struct file *, struct dir_context *, const char *, int,
|
||||
instantiate_t, struct task_struct *, const void *);
|
||||
|
@ -187,13 +187,12 @@ static const struct inode_operations proc_ns_link_inode_operations = {
|
||||
.setattr = proc_setattr,
|
||||
};
|
||||
|
||||
static struct dentry *proc_ns_instantiate(struct inode *dir,
|
||||
static int proc_ns_instantiate(struct inode *dir,
|
||||
struct dentry *dentry, struct task_struct *task, const void *ptr)
|
||||
{
|
||||
const struct proc_ns_operations *ns_ops = ptr;
|
||||
struct inode *inode;
|
||||
struct proc_inode *ei;
|
||||
struct dentry *error = ERR_PTR(-ENOENT);
|
||||
|
||||
inode = proc_pid_make_inode(dir->i_sb, task);
|
||||
if (!inode)
|
||||
@ -208,9 +207,9 @@ static struct dentry *proc_ns_instantiate(struct inode *dir,
|
||||
d_add(dentry, inode);
|
||||
/* Close the race of the process dying before we return the dentry */
|
||||
if (pid_revalidate(dentry, 0))
|
||||
error = NULL;
|
||||
return 0;
|
||||
out:
|
||||
return error;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int proc_ns_dir_readdir(struct file *file, struct dir_context *ctx)
|
||||
@ -248,12 +247,12 @@ const struct file_operations proc_ns_dir_operations = {
|
||||
static struct dentry *proc_ns_dir_lookup(struct inode *dir,
|
||||
struct dentry *dentry, unsigned int flags)
|
||||
{
|
||||
struct dentry *error;
|
||||
int error;
|
||||
struct task_struct *task = get_proc_task(dir);
|
||||
const struct proc_ns_operations **entry, **last;
|
||||
unsigned int len = dentry->d_name.len;
|
||||
|
||||
error = ERR_PTR(-ENOENT);
|
||||
error = -ENOENT;
|
||||
|
||||
if (!task)
|
||||
goto out_no_task;
|
||||
@ -272,7 +271,7 @@ static struct dentry *proc_ns_dir_lookup(struct inode *dir,
|
||||
out:
|
||||
put_task_struct(task);
|
||||
out_no_task:
|
||||
return error;
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
|
||||
const struct inode_operations proc_ns_dir_inode_operations = {
|
||||
|
Loading…
Reference in New Issue
Block a user