Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 84613
b: refs/heads/master
c: be61408
h: refs/heads/master
i:
  84611: 9c99770
v: v3
  • Loading branch information
Eric W. Biederman authored and Linus Torvalds committed Feb 8, 2008
1 parent d820783 commit 2127b3e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 94413d8807a3c511a3675be4ce27a4d16d6408ee
refs/heads/master: be614086a4aff163d5aa0dc160638d1193b59cde
43 changes: 43 additions & 0 deletions trunk/fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ struct pid_entry {
NOD(NAME, (S_IFREG|(MODE)), \
NULL, &proc_info_file_operations, \
{ .proc_read = &proc_##OTYPE } )
#define ONE(NAME, MODE, OTYPE) \
NOD(NAME, (S_IFREG|(MODE)), \
NULL, &proc_single_file_operations, \
{ .proc_show = &proc_##OTYPE } )

int maps_protect;
EXPORT_SYMBOL(maps_protect);
Expand Down Expand Up @@ -658,6 +662,45 @@ static const struct file_operations proc_info_file_operations = {
.read = proc_info_read,
};

static int proc_single_show(struct seq_file *m, void *v)
{
struct inode *inode = m->private;
struct pid_namespace *ns;
struct pid *pid;
struct task_struct *task;
int ret;

ns = inode->i_sb->s_fs_info;
pid = proc_pid(inode);
task = get_pid_task(pid, PIDTYPE_PID);
if (!task)
return -ESRCH;

ret = PROC_I(inode)->op.proc_show(m, ns, pid, task);

put_task_struct(task);
return ret;
}

static int proc_single_open(struct inode *inode, struct file *filp)
{
int ret;
ret = single_open(filp, proc_single_show, NULL);
if (!ret) {
struct seq_file *m = filp->private_data;

m->private = inode;
}
return ret;
}

static const struct file_operations proc_single_file_operations = {
.open = proc_single_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

static int mem_open(struct inode* inode, struct file* file)
{
file->private_data = (void*)((long)current->self_exec_id);
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/proc_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ extern void kclist_add(struct kcore_list *, void *, size_t);
union proc_op {
int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
int (*proc_read)(struct task_struct *task, char *page);
int (*proc_show)(struct seq_file *m,
struct pid_namespace *ns, struct pid *pid,
struct task_struct *task);
};

struct proc_inode {
Expand Down

0 comments on commit 2127b3e

Please sign in to comment.