This source file includes following definitions.
- proc_pid_fill_inode
- proc_base_init
1
2
3
4
5
6
7
8
9 #include <asm/segment.h>
10
11 #include <linux/errno.h>
12 #include <linux/sched.h>
13 #include <linux/proc_fs.h>
14 #include <linux/stat.h>
15
16 static struct file_operations proc_base_operations = {
17 NULL,
18 NULL,
19 NULL,
20 proc_readdir,
21 NULL,
22 NULL,
23 NULL,
24 NULL,
25 NULL,
26 NULL
27 };
28
29
30
31
32 static struct inode_operations proc_base_inode_operations = {
33 &proc_base_operations,
34 NULL,
35 proc_lookup,
36 NULL,
37 NULL,
38 NULL,
39 NULL,
40 NULL,
41 NULL,
42 NULL,
43 NULL,
44 NULL,
45 NULL,
46 NULL,
47 NULL,
48 NULL,
49 NULL
50 };
51
52 static void proc_pid_fill_inode(struct inode * inode)
53 {
54 struct task_struct * p;
55 int pid = inode->i_ino >> 16;
56 int ino = inode->i_ino & 0xffff;
57
58 for_each_task(p) {
59 if (p->pid == pid) {
60 if (p->dumpable || ino == PROC_PID_INO) {
61 inode->i_uid = p->euid;
62 inode->i_gid = p->gid;
63 }
64 return;
65 }
66 }
67 }
68
69
70
71
72
73
74
75 struct proc_dir_entry proc_pid = {
76 PROC_PID_INO, 5, "<pid>",
77 S_IFDIR | S_IRUGO | S_IXUGO, 2, 0, 0,
78 0, &proc_base_inode_operations,
79 NULL, proc_pid_fill_inode,
80 NULL, &proc_root, NULL
81 };
82
83 void proc_base_init(void)
84 {
85 proc_register(&proc_pid, &(struct proc_dir_entry) {
86 PROC_PID_MEM, 3, "mem",
87 S_IFREG | S_IRUSR | S_IWUSR, 1, 0, 0,
88 0, &proc_mem_inode_operations,
89 NULL, proc_pid_fill_inode,
90 });
91 proc_register(&proc_pid, &(struct proc_dir_entry) {
92 PROC_PID_CWD, 3, "cwd",
93 S_IFLNK | S_IRWXU, 1, 0, 0,
94 0, &proc_link_inode_operations,
95 NULL, proc_pid_fill_inode,
96 });
97 proc_register(&proc_pid, &(struct proc_dir_entry) {
98 PROC_PID_ROOT, 4, "root",
99 S_IFLNK | S_IRWXU, 1, 0, 0,
100 0, &proc_link_inode_operations,
101 NULL, proc_pid_fill_inode,
102 });
103 proc_register(&proc_pid, &(struct proc_dir_entry) {
104 PROC_PID_EXE, 3, "exe",
105 S_IFLNK | S_IRWXU, 1, 0, 0,
106 0, &proc_link_inode_operations,
107 NULL, proc_pid_fill_inode,
108 });
109 proc_register(&proc_pid, &(struct proc_dir_entry) {
110 PROC_PID_FD, 2, "fd",
111 S_IFDIR | S_IRUSR | S_IXUSR, 1, 0, 0,
112 0, &proc_fd_inode_operations,
113 NULL, proc_pid_fill_inode,
114 });
115 proc_register(&proc_pid, &(struct proc_dir_entry) {
116 PROC_PID_ENVIRON, 7, "environ",
117 S_IFREG | S_IRUSR, 1, 0, 0,
118 0, &proc_array_inode_operations,
119 NULL, proc_pid_fill_inode,
120 });
121 proc_register(&proc_pid, &(struct proc_dir_entry) {
122 PROC_PID_CMDLINE, 7, "cmdline",
123 S_IFREG | S_IRUGO, 1, 0, 0,
124 0, &proc_array_inode_operations,
125 NULL, proc_pid_fill_inode,
126 });
127 proc_register(&proc_pid, &(struct proc_dir_entry) {
128 PROC_PID_STAT, 4, "stat",
129 S_IFREG | S_IRUGO, 1, 0, 0,
130 0, &proc_array_inode_operations,
131 NULL, proc_pid_fill_inode,
132 });
133 proc_register(&proc_pid, &(struct proc_dir_entry) {
134 PROC_PID_STATM, 5, "statm",
135 S_IFREG | S_IRUGO, 1, 0, 0,
136 0, &proc_array_inode_operations,
137 NULL, proc_pid_fill_inode,
138 });
139 proc_register(&proc_pid, &(struct proc_dir_entry) {
140 PROC_PID_MAPS, 4, "maps",
141 S_IFIFO | S_IRUGO, 1, 0, 0,
142 0, &proc_arraylong_inode_operations,
143 NULL, proc_pid_fill_inode,
144 });
145 };