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 };
49
50 static void proc_pid_fill_inode(struct inode * inode)
51 {
52 struct task_struct * p;
53 int pid = inode->i_ino >> 16;
54 int ino = inode->i_ino & 0xffff;
55
56 for_each_task(p) {
57 if (p->pid == pid) {
58 if (p->dumpable || ino == PROC_PID_INO) {
59 inode->i_uid = p->euid;
60 inode->i_gid = p->gid;
61 }
62 return;
63 }
64 }
65 }
66
67
68
69
70
71
72
73 struct proc_dir_entry proc_pid = {
74 PROC_PID_INO, 5, "<pid>",
75 S_IFDIR | S_IRUGO | S_IXUGO, 2, 0, 0,
76 0, &proc_base_inode_operations,
77 NULL, proc_pid_fill_inode,
78 NULL, &proc_root, NULL
79 };
80
81 void proc_base_init(void)
82 {
83 proc_register(&proc_pid, &(struct proc_dir_entry) {
84 PROC_PID_MEM, 3, "mem",
85 S_IFREG | S_IRUSR | S_IWUSR, 1, 0, 0,
86 0, &proc_mem_inode_operations,
87 NULL, proc_pid_fill_inode,
88 });
89 proc_register(&proc_pid, &(struct proc_dir_entry) {
90 PROC_PID_CWD, 3, "cwd",
91 S_IFLNK | S_IRWXU, 1, 0, 0,
92 0, &proc_link_inode_operations,
93 NULL, proc_pid_fill_inode,
94 });
95 proc_register(&proc_pid, &(struct proc_dir_entry) {
96 PROC_PID_ROOT, 4, "root",
97 S_IFLNK | S_IRWXU, 1, 0, 0,
98 0, &proc_link_inode_operations,
99 NULL, proc_pid_fill_inode,
100 });
101 proc_register(&proc_pid, &(struct proc_dir_entry) {
102 PROC_PID_EXE, 3, "exe",
103 S_IFLNK | S_IRWXU, 1, 0, 0,
104 0, &proc_link_inode_operations,
105 NULL, proc_pid_fill_inode,
106 });
107 proc_register(&proc_pid, &(struct proc_dir_entry) {
108 PROC_PID_FD, 2, "fd",
109 S_IFDIR | S_IRUSR | S_IXUSR, 1, 0, 0,
110 0, &proc_fd_inode_operations,
111 NULL, proc_pid_fill_inode,
112 });
113 proc_register(&proc_pid, &(struct proc_dir_entry) {
114 PROC_PID_ENVIRON, 7, "environ",
115 S_IFREG | S_IRUSR, 1, 0, 0,
116 0, &proc_array_inode_operations,
117 NULL, proc_pid_fill_inode,
118 });
119 proc_register(&proc_pid, &(struct proc_dir_entry) {
120 PROC_PID_CMDLINE, 7, "cmdline",
121 S_IFREG | S_IRUGO, 1, 0, 0,
122 0, &proc_array_inode_operations,
123 NULL, proc_pid_fill_inode,
124 });
125 proc_register(&proc_pid, &(struct proc_dir_entry) {
126 PROC_PID_STAT, 4, "stat",
127 S_IFREG | S_IRUGO, 1, 0, 0,
128 0, &proc_array_inode_operations,
129 NULL, proc_pid_fill_inode,
130 });
131 proc_register(&proc_pid, &(struct proc_dir_entry) {
132 PROC_PID_STATM, 5, "statm",
133 S_IFREG | S_IRUGO, 1, 0, 0,
134 0, &proc_array_inode_operations,
135 NULL, proc_pid_fill_inode,
136 });
137 proc_register(&proc_pid, &(struct proc_dir_entry) {
138 PROC_PID_MAPS, 4, "maps",
139 S_IFIFO | S_IRUGO, 1, 0, 0,
140 0, &proc_arraylong_inode_operations,
141 NULL, proc_pid_fill_inode,
142 });
143 };