OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [before_ORP/] [uclinux/] [uClinux-2.0.x/] [fs/] [proc/] [base.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 *  linux/fs/proc/base.c
3
 *
4
 *  Copyright (C) 1991, 1992 Linus Torvalds
5
 *
6
 *  proc base directory handling functions
7
 */
8
 
9
/*
10
 * uClinux revisions for NO_MM
11
 * Copyright (C) 1998  Kenneth Albanowski <kjahds@kjahds.com>,
12
 *                     The Silver Hammer Group, Ltd.
13
 */
14
 
15
#include <asm/segment.h>
16
 
17
#include <linux/errno.h>
18
#include <linux/sched.h>
19
#include <linux/proc_fs.h>
20
#include <linux/stat.h>
21
 
22
static struct file_operations proc_base_operations = {
23
        NULL,                   /* lseek - default */
24
        NULL,                   /* read - bad */
25
        NULL,                   /* write - bad */
26
        proc_readdir,           /* readdir */
27
        NULL,                   /* select - default */
28
        NULL,                   /* ioctl - default */
29
        NULL,                   /* mmap */
30
        NULL,                   /* no special open code */
31
        NULL,                   /* no special release code */
32
        NULL                    /* can't fsync */
33
};
34
 
35
/*
36
 * proc directories can do almost nothing..
37
 */
38
static struct inode_operations proc_base_inode_operations = {
39
        &proc_base_operations,  /* default base directory file-ops */
40
        NULL,                   /* create */
41
        proc_lookup,            /* lookup */
42
        NULL,                   /* link */
43
        NULL,                   /* unlink */
44
        NULL,                   /* symlink */
45
        NULL,                   /* mkdir */
46
        NULL,                   /* rmdir */
47
        NULL,                   /* mknod */
48
        NULL,                   /* rename */
49
        NULL,                   /* readlink */
50
        NULL,                   /* follow_link */
51
        NULL,                   /* readpage */
52
        NULL,                   /* writepage */
53
        NULL,                   /* bmap */
54
        NULL,                   /* truncate */
55
        NULL                    /* permission */
56
};
57
 
58
static void proc_pid_fill_inode(struct inode * inode)
59
{
60
        struct task_struct * p;
61
        int pid = inode->i_ino >> 16;
62
        int ino = inode->i_ino & 0xffff;
63
 
64
        for_each_task(p) {
65
                if (p->pid == pid) {
66
                        if (p->dumpable || ino == PROC_PID_INO) {
67
                                inode->i_uid = p->euid;
68
                                inode->i_gid = p->gid;
69
                        }
70
                        return;
71
                }
72
        }
73
}
74
 
75
/*
76
 * This is really a pseudo-entry, and only links
77
 * backwards to the parent with no link from the
78
 * root directory to this. This way we can have just
79
 * one entry for every /proc/<pid>/ directory.
80
 */
81
struct proc_dir_entry proc_pid = {
82
        PROC_PID_INO, 5, "<pid>",
83
        S_IFDIR | S_IRUGO | S_IXUGO, 2, 0, 0,
84
        0, &proc_base_inode_operations,
85
        NULL, proc_pid_fill_inode,
86
        NULL, &proc_root, NULL
87
};
88
 
89
struct proc_dir_entry pde_status = {
90
                PROC_PID_STATUS, 6, "status",
91
                S_IFREG | S_IRUGO, 1, 0, 0,
92
                0, &proc_array_inode_operations,
93
                NULL, proc_pid_fill_inode,
94
};
95
struct proc_dir_entry pde_mem = {
96
                PROC_PID_MEM, 3, "mem",
97
                S_IFREG | S_IRUSR | S_IWUSR, 1, 0, 0,
98
                0, &proc_mem_inode_operations,
99
                NULL, proc_pid_fill_inode,
100
};
101
struct proc_dir_entry pde_cwd = {
102
                PROC_PID_CWD, 3, "cwd",
103
                S_IFLNK | S_IRWXU, 1, 0, 0,
104
                0, &proc_link_inode_operations,
105
                NULL, proc_pid_fill_inode,
106
};
107
struct proc_dir_entry pde_root = {
108
                PROC_PID_ROOT, 4, "root",
109
                S_IFLNK | S_IRWXU, 1, 0, 0,
110
                0, &proc_link_inode_operations,
111
                NULL, proc_pid_fill_inode,
112
};
113
struct proc_dir_entry pde_exe = {
114
                PROC_PID_EXE, 3, "exe",
115
                S_IFLNK | S_IRWXU, 1, 0, 0,
116
                0, &proc_link_inode_operations,
117
                NULL, proc_pid_fill_inode,
118
};
119
struct proc_dir_entry pde_fd = {
120
                PROC_PID_FD, 2, "fd",
121
                S_IFDIR | S_IRUSR | S_IXUSR, 1, 0, 0,
122
                0, &proc_fd_inode_operations,
123
                NULL, proc_pid_fill_inode,
124
};
125
struct proc_dir_entry pde_environ = {
126
                PROC_PID_ENVIRON, 7, "environ",
127
                S_IFREG | S_IRUSR, 1, 0, 0,
128
                0, &proc_array_inode_operations,
129
                NULL, proc_pid_fill_inode,
130
};
131
struct proc_dir_entry pde_pidcmdline = {
132
                PROC_PID_CMDLINE, 7, "cmdline",
133
                S_IFREG | S_IRUGO, 1, 0, 0,
134
                0, &proc_array_inode_operations,
135
                NULL, proc_pid_fill_inode,
136
};
137
struct proc_dir_entry pde_pidstat = {
138
                PROC_PID_STAT, 4, "stat",
139
                S_IFREG | S_IRUGO, 1, 0, 0,
140
                0, &proc_array_inode_operations,
141
                NULL, proc_pid_fill_inode,
142
};
143
#ifndef NO_MM
144
struct proc_dir_entry pde_statm = {
145
                PROC_PID_STATM, 5, "statm",
146
                S_IFREG | S_IRUGO, 1, 0, 0,
147
                0, &proc_array_inode_operations,
148
                NULL, proc_pid_fill_inode,
149
};
150
struct proc_dir_entry pde_maps = {
151
                PROC_PID_MAPS, 4, "maps",
152
                S_IFIFO | S_IRUGO, 1, 0, 0,
153
                0, &proc_arraylong_inode_operations,
154
                NULL, proc_pid_fill_inode,
155
};
156
#endif /* !NO_MM */
157
 
158
 
159
void proc_base_init(void)
160
{
161
        proc_register(&proc_pid, &pde_status);
162
        proc_register(&proc_pid, &pde_mem);
163
        proc_register(&proc_pid, &pde_cwd);
164
        proc_register(&proc_pid, &pde_root);
165
        proc_register(&proc_pid, &pde_exe);
166
        proc_register(&proc_pid, &pde_fd);
167
        proc_register(&proc_pid, &pde_environ);
168
        proc_register(&proc_pid, &pde_pidcmdline);
169
        proc_register(&proc_pid, &pde_pidstat);
170
#ifndef NO_MM
171
        proc_register(&proc_pid, &pde_statm);
172
        proc_register(&proc_pid, &pde_maps);
173
#endif /* !NO_MM */
174
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.