procfs.h revision 1.8 1 1.1 cgd /*
2 1.1 cgd * Copyright (c) 1993 The Regents of the University of California.
3 1.1 cgd * Copyright (c) 1993 Jan-Simon Pendry
4 1.1 cgd * All rights reserved.
5 1.1 cgd *
6 1.1 cgd * This code is derived from software contributed to Berkeley by
7 1.1 cgd * Jan-Simon Pendry.
8 1.1 cgd *
9 1.1 cgd * Redistribution and use in source and binary forms, with or without
10 1.1 cgd * modification, are permitted provided that the following conditions
11 1.1 cgd * are met:
12 1.1 cgd * 1. Redistributions of source code must retain the above copyright
13 1.1 cgd * notice, this list of conditions and the following disclaimer.
14 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 cgd * notice, this list of conditions and the following disclaimer in the
16 1.1 cgd * documentation and/or other materials provided with the distribution.
17 1.1 cgd * 3. All advertising materials mentioning features or use of this software
18 1.1 cgd * must display the following acknowledgement:
19 1.1 cgd * This product includes software developed by the University of
20 1.1 cgd * California, Berkeley and its contributors.
21 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
22 1.1 cgd * may be used to endorse or promote products derived from this software
23 1.1 cgd * without specific prior written permission.
24 1.1 cgd *
25 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.1 cgd * SUCH DAMAGE.
36 1.1 cgd *
37 1.1 cgd * From:
38 1.1 cgd * Id: procfs.h,v 4.1 1993/12/17 10:47:45 jsp Rel
39 1.1 cgd *
40 1.8 cgd * $Id: procfs.h,v 1.8 1994/04/12 02:55:51 cgd Exp $
41 1.1 cgd */
42 1.1 cgd
43 1.1 cgd /*
44 1.1 cgd * The different types of node in a procfs filesystem
45 1.1 cgd */
46 1.1 cgd typedef enum {
47 1.1 cgd Proot, /* the filesystem root */
48 1.1 cgd Pproc, /* a process-specific sub-directory */
49 1.1 cgd Pfile, /* the executable file */
50 1.1 cgd Pmem, /* the process's memory image */
51 1.1 cgd Pregs, /* the process's register set */
52 1.6 cgd Pfpregs, /* the process's floating point register set */
53 1.1 cgd Pctl, /* process control */
54 1.1 cgd Pstatus, /* process status */
55 1.1 cgd Pnote, /* process notifier */
56 1.1 cgd Pnotepg /* process group notifier */
57 1.1 cgd } pfstype;
58 1.1 cgd
59 1.1 cgd /*
60 1.1 cgd * control data for the proc file system.
61 1.1 cgd */
62 1.1 cgd struct pfsnode {
63 1.1 cgd struct pfsnode *pfs_next; /* next on list */
64 1.1 cgd struct vnode *pfs_vnode; /* vnode associated with this pfsnode */
65 1.1 cgd pfstype pfs_type; /* type of procfs node */
66 1.1 cgd pid_t pfs_pid; /* associated process */
67 1.1 cgd u_short pfs_mode; /* mode bits for stat() */
68 1.1 cgd u_long pfs_flags; /* open flags */
69 1.1 cgd u_long pfs_fileno; /* unique file id */
70 1.1 cgd };
71 1.1 cgd
72 1.5 ws #define PROCFS_NOTELEN 8 /* max length of a note (/proc/$pid/note) */
73 1.1 cgd #define PROCFS_CTLLEN 8 /* max length of a ctl msg (/proc/$pid/ctl */
74 1.1 cgd
75 1.1 cgd /*
76 1.1 cgd * Kernel stuff follows
77 1.1 cgd */
78 1.1 cgd #ifdef KERNEL
79 1.1 cgd
80 1.1 cgd #define NDEQ(ndp, s, len) \
81 1.1 cgd ((ndp)->ni_namelen == (len) && \
82 1.1 cgd (bcmp((s), (ndp)->ni_ptr, (len)) == 0))
83 1.1 cgd
84 1.1 cgd /*
85 1.1 cgd * Format of a directory entry in /proc, ...
86 1.1 cgd * This must map onto struct dirent (see <dirent.h>)
87 1.1 cgd */
88 1.1 cgd #define PROCFS_NAMELEN 8
89 1.1 cgd struct pfsdent {
90 1.1 cgd u_long d_fileno;
91 1.1 cgd u_short d_reclen;
92 1.1 cgd u_short d_namlen;
93 1.1 cgd char d_name[PROCFS_NAMELEN];
94 1.1 cgd };
95 1.1 cgd #define UIO_MX sizeof(struct pfsdent)
96 1.1 cgd #define PROCFS_FILENO(pid, type) \
97 1.1 cgd (((type) == Proot) ? \
98 1.3 ws ((pid) + 2) : \
99 1.7 ws ((((pid)+1) << 4) + ((int) (type))))
100 1.1 cgd
101 1.1 cgd /*
102 1.1 cgd * Convert between pfsnode vnode
103 1.1 cgd */
104 1.1 cgd #define VTOPFS(vp) ((struct pfsnode *)(vp)->v_data)
105 1.1 cgd #define PFSTOV(pfs) ((pfs)->pfs_vnode)
106 1.1 cgd
107 1.5 ws typedef struct procfs_namemap procfs_namemap_t;
108 1.5 ws struct procfs_namemap {
109 1.1 cgd const char *nm_name;
110 1.1 cgd int nm_val;
111 1.1 cgd };
112 1.1 cgd
113 1.5 ws extern int procfs_getuserstr __P((struct uio *, char *, int *));
114 1.5 ws extern procfs_namemap_t *procfs_findname __P((procfs_namemap_t *, char *, int));
115 1.1 cgd
116 1.1 cgd struct reg;
117 1.1 cgd
118 1.1 cgd #define PFIND(pid) ((pid) ? pfind(pid) : &proc0)
119 1.1 cgd extern int procfs_freevp __P((struct vnode *));
120 1.1 cgd extern int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype));
121 1.1 cgd extern struct vnode *procfs_findtextvp __P((struct proc *));
122 1.1 cgd extern int procfs_sstep __P((struct proc *));
123 1.1 cgd extern int procfs_read_regs __P((struct proc *, struct reg *));
124 1.1 cgd extern int procfs_write_regs __P((struct proc *, struct reg *));
125 1.1 cgd extern int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
126 1.1 cgd extern int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
127 1.1 cgd extern int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
128 1.1 cgd extern int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
129 1.1 cgd extern int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
130 1.1 cgd extern int procfs_rw __P((struct vnode *, struct uio *, int, struct ucred *));
131 1.8 cgd
132 1.8 cgd /* functions to check whether or not files should be displayed */
133 1.8 cgd extern int procfs_validfile __P((struct proc *));
134 1.8 cgd extern int procfs_validfpregs __P((struct proc *));
135 1.8 cgd extern int procfs_validregs __P((struct proc *));
136 1.1 cgd
137 1.1 cgd #define PROCFS_LOCKED 0x01
138 1.1 cgd #define PROCFS_WANT 0x02
139 1.1 cgd
140 1.1 cgd extern struct vnodeops procfs_vnodeops;
141 1.1 cgd extern struct vfsops procfs_vfsops;
142 1.1 cgd
143 1.1 cgd /*
144 1.1 cgd * Prototypes for procfs vnode ops
145 1.1 cgd */
146 1.1 cgd int procfs_badop(); /* varargs */
147 1.1 cgd int procfs_rw __P((
148 1.1 cgd struct vnode *vp,
149 1.1 cgd struct uio *uio,
150 1.1 cgd int ioflag,
151 1.1 cgd struct ucred *cred));
152 1.1 cgd int procfs_lookup __P((
153 1.1 cgd struct vnode *vp,
154 1.1 cgd struct nameidata *ndp,
155 1.1 cgd struct proc *p));
156 1.1 cgd #define procfs_create ((int (*) __P(( \
157 1.1 cgd struct nameidata *ndp, \
158 1.1 cgd struct vattr *vap, \
159 1.1 cgd struct proc *p))) procfs_badop)
160 1.1 cgd #define procfs_mknod ((int (*) __P(( \
161 1.1 cgd struct nameidata *ndp, \
162 1.1 cgd struct vattr *vap, \
163 1.1 cgd struct ucred *cred, \
164 1.1 cgd struct proc *p))) procfs_badop)
165 1.1 cgd int procfs_open __P((
166 1.1 cgd struct vnode *vp,
167 1.1 cgd int mode,
168 1.1 cgd struct ucred *cred,
169 1.1 cgd struct proc *p));
170 1.1 cgd int procfs_close __P((
171 1.1 cgd struct vnode *vp,
172 1.1 cgd int fflag,
173 1.1 cgd struct ucred *cred,
174 1.1 cgd struct proc *p));
175 1.1 cgd int procfs_access __P((
176 1.1 cgd struct vnode *vp,
177 1.1 cgd int mode,
178 1.1 cgd struct ucred *cred,
179 1.1 cgd struct proc *p));
180 1.1 cgd int procfs_getattr __P((
181 1.1 cgd struct vnode *vp,
182 1.1 cgd struct vattr *vap,
183 1.1 cgd struct ucred *cred,
184 1.1 cgd struct proc *p));
185 1.1 cgd int procfs_setattr __P((
186 1.1 cgd struct vnode *vp,
187 1.1 cgd struct vattr *vap,
188 1.1 cgd struct ucred *cred,
189 1.1 cgd struct proc *p));
190 1.1 cgd #define procfs_read procfs_rw
191 1.1 cgd #define procfs_write procfs_rw
192 1.1 cgd int procfs_ioctl __P((
193 1.1 cgd struct vnode *vp,
194 1.1 cgd int command,
195 1.1 cgd caddr_t data,
196 1.1 cgd int fflag,
197 1.1 cgd struct ucred *cred,
198 1.1 cgd struct proc *p));
199 1.1 cgd #define procfs_select ((int (*) __P(( \
200 1.1 cgd struct vnode *vp, \
201 1.1 cgd int which, \
202 1.1 cgd int fflags, \
203 1.1 cgd struct ucred *cred, \
204 1.1 cgd struct proc *p))) procfs_badop)
205 1.1 cgd #define procfs_mmap ((int (*) __P(( \
206 1.1 cgd struct vnode *vp, \
207 1.1 cgd int fflags, \
208 1.1 cgd struct ucred *cred, \
209 1.1 cgd struct proc *p))) procfs_badop)
210 1.1 cgd #define procfs_fsync ((int (*) __P(( \
211 1.1 cgd struct vnode *vp, \
212 1.1 cgd int fflags, \
213 1.1 cgd struct ucred *cred, \
214 1.1 cgd int waitfor, \
215 1.1 cgd struct proc *p))) procfs_badop)
216 1.1 cgd #define procfs_seek ((int (*) __P(( \
217 1.1 cgd struct vnode *vp, \
218 1.1 cgd off_t oldoff, \
219 1.1 cgd off_t newoff, \
220 1.1 cgd struct ucred *cred))) procfs_badop)
221 1.1 cgd #define procfs_remove ((int (*) __P(( \
222 1.1 cgd struct nameidata *ndp, \
223 1.1 cgd struct proc *p))) procfs_badop)
224 1.1 cgd #define procfs_link ((int (*) __P(( \
225 1.1 cgd struct vnode *vp, \
226 1.1 cgd struct nameidata *ndp, \
227 1.1 cgd struct proc *p))) procfs_badop)
228 1.1 cgd #define procfs_rename ((int (*) __P(( \
229 1.1 cgd struct nameidata *fndp, \
230 1.1 cgd struct nameidata *tdnp, \
231 1.1 cgd struct proc *p))) procfs_badop)
232 1.1 cgd #define procfs_mkdir ((int (*) __P(( \
233 1.1 cgd struct nameidata *ndp, \
234 1.1 cgd struct vattr *vap, \
235 1.1 cgd struct proc *p))) procfs_badop)
236 1.1 cgd #define procfs_rmdir ((int (*) __P(( \
237 1.1 cgd struct nameidata *ndp, \
238 1.1 cgd struct proc *p))) procfs_badop)
239 1.1 cgd #define procfs_symlink ((int (*) __P(( \
240 1.1 cgd struct nameidata *ndp, \
241 1.1 cgd struct vattr *vap, \
242 1.1 cgd char *target, \
243 1.1 cgd struct proc *p))) procfs_badop)
244 1.1 cgd int procfs_readdir __P((
245 1.1 cgd struct vnode *vp,
246 1.1 cgd struct uio *uio,
247 1.1 cgd struct ucred *cred,
248 1.1 cgd int *eofflagp,
249 1.1 cgd u_int *cookies,
250 1.1 cgd int ncookies));
251 1.4 ws int procfs_readlink __P((
252 1.4 ws struct vnode *vp,
253 1.4 ws struct uio *uio,
254 1.3 ws struct ucred *cred));
255 1.1 cgd int procfs_abortop __P((
256 1.1 cgd struct nameidata *ndp));
257 1.1 cgd int procfs_inactive __P((
258 1.1 cgd struct vnode *vp,
259 1.1 cgd struct proc *p));
260 1.1 cgd int procfs_reclaim __P((
261 1.1 cgd struct vnode *vp));
262 1.1 cgd #define procfs_lock ((int (*) __P(( \
263 1.1 cgd struct vnode *vp))) nullop)
264 1.1 cgd #define procfs_unlock ((int (*) __P(( \
265 1.1 cgd struct vnode *vp))) nullop)
266 1.1 cgd int procfs_bmap __P((
267 1.1 cgd struct vnode *vp,
268 1.1 cgd daddr_t bn,
269 1.1 cgd struct vnode **vpp,
270 1.1 cgd daddr_t *bnp));
271 1.1 cgd #define procfs_strategy ((int (*) __P(( \
272 1.1 cgd struct buf *bp))) procfs_badop)
273 1.1 cgd int procfs_print __P((
274 1.1 cgd struct vnode *vp));
275 1.1 cgd #define procfs_islocked ((int (*) __P(( \
276 1.1 cgd struct vnode *vp))) nullop)
277 1.1 cgd #define procfs_advlock ((int (*) __P(( \
278 1.1 cgd struct vnode *vp, \
279 1.1 cgd caddr_t id, \
280 1.1 cgd int op, \
281 1.1 cgd struct flock *fl, \
282 1.1 cgd int flags))) procfs_badop)
283 1.1 cgd
284 1.1 cgd #endif /* KERNEL */
285