Commit | Line | Data |
---|---|---|
4e89d26e | 1 | /* |
4e89d26e | 2 | * Copyright (c) 1993 Jan-Simon Pendry |
1611db1e KB |
3 | * Copyright (c) 1993 |
4 | * The Regents of the University of California. All rights reserved. | |
4e89d26e JSP |
5 | * |
6 | * This code is derived from software contributed to Berkeley by | |
7 | * Jan-Simon Pendry. | |
8 | * | |
ed554bc5 C |
9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | |
17 | * 3. All advertising materials mentioning features or use of this software | |
18 | * must display the following acknowledgement: | |
19 | * This product includes software developed by the University of | |
20 | * California, Berkeley and its contributors. | |
21 | * 4. Neither the name of the University nor the names of its contributors | |
22 | * may be used to endorse or promote products derived from this software | |
23 | * without specific prior written permission. | |
4e89d26e | 24 | * |
ed554bc5 C |
25 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
35 | * SUCH DAMAGE. | |
36 | * | |
37 | * @(#)procfs.h 8.6 (Berkeley) 2/3/94 | |
4e89d26e JSP |
38 | * |
39 | * From: | |
40 | * $Id: procfs.h,v 3.2 1993/12/15 09:40:17 jsp Exp $ | |
41 | */ | |
42 | ||
43 | /* | |
44 | * The different types of node in a procfs filesystem | |
45 | */ | |
46 | typedef enum { | |
47 | Proot, /* the filesystem root */ | |
48 | Pproc, /* a process-specific sub-directory */ | |
49 | Pfile, /* the executable file */ | |
50 | Pmem, /* the process's memory image */ | |
51 | Pregs, /* the process's register set */ | |
6fdd7e21 | 52 | Pfpregs, /* the process's FP register set */ |
4e89d26e JSP |
53 | Pctl, /* process control */ |
54 | Pstatus, /* process status */ | |
55 | Pnote, /* process notifier */ | |
56 | Pnotepg /* process group notifier */ | |
57 | } pfstype; | |
58 | ||
59 | /* | |
60 | * control data for the proc file system. | |
61 | */ | |
62 | struct pfsnode { | |
63 | struct pfsnode *pfs_next; /* next on list */ | |
64 | struct vnode *pfs_vnode; /* vnode associated with this pfsnode */ | |
65 | pfstype pfs_type; /* type of procfs node */ | |
66 | pid_t pfs_pid; /* associated process */ | |
67 | u_short pfs_mode; /* mode bits for stat() */ | |
68 | u_long pfs_flags; /* open flags */ | |
69 | u_long pfs_fileno; /* unique file id */ | |
70 | }; | |
71 | ||
72 | #define PROCFS_NOTELEN 64 /* max length of a note (/proc/$pid/note) */ | |
73 | #define PROCFS_CTLLEN 8 /* max length of a ctl msg (/proc/$pid/ctl */ | |
74 | ||
75 | /* | |
76 | * Kernel stuff follows | |
77 | */ | |
78 | #ifdef KERNEL | |
79 | #define CNEQ(cnp, s, len) \ | |
80 | ((cnp)->cn_namelen == (len) && \ | |
81 | (bcmp((s), (cnp)->cn_nameptr, (len)) == 0)) | |
82 | ||
83 | /* | |
84 | * Format of a directory entry in /proc, ... | |
85 | * This must map onto struct dirent (see <dirent.h>) | |
86 | */ | |
87 | #define PROCFS_NAMELEN 8 | |
88 | struct pfsdent { | |
89 | u_long d_fileno; | |
90 | u_short d_reclen; | |
91 | u_char d_type; | |
92 | u_char d_namlen; | |
93 | char d_name[PROCFS_NAMELEN]; | |
94 | }; | |
95 | #define UIO_MX sizeof(struct pfsdent) | |
96 | #define PROCFS_FILENO(pid, type) \ | |
97 | (((type) == Proot) ? \ | |
98 | 2 : \ | |
99 | ((((pid)+1) << 3) + ((int) (type)))) | |
100 | ||
101 | /* | |
102 | * Convert between pfsnode vnode | |
103 | */ | |
104 | #define VTOPFS(vp) ((struct pfsnode *)(vp)->v_data) | |
105 | #define PFSTOV(pfs) ((pfs)->pfs_vnode) | |
106 | ||
107 | typedef struct vfs_namemap vfs_namemap_t; | |
108 | struct vfs_namemap { | |
109 | const char *nm_name; | |
110 | int nm_val; | |
111 | }; | |
112 | ||
113 | extern int vfs_getuserstr __P((struct uio *, char *, int *)); | |
114 | extern vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int)); | |
115 | ||
116 | /* <machine/reg.h> */ | |
117 | struct reg; | |
e30956f6 | 118 | struct fpreg; |
4e89d26e JSP |
119 | |
120 | #define PFIND(pid) ((pid) ? pfind(pid) : &proc0) | |
121 | extern int procfs_freevp __P((struct vnode *)); | |
122 | extern int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype)); | |
123 | extern struct vnode *procfs_findtextvp __P((struct proc *)); | |
124 | extern int procfs_sstep __P((struct proc *)); | |
ece858e1 | 125 | extern void procfs_fix_sstep __P((struct proc *)); |
4e89d26e JSP |
126 | extern int procfs_read_regs __P((struct proc *, struct reg *)); |
127 | extern int procfs_write_regs __P((struct proc *, struct reg *)); | |
6fdd7e21 JSP |
128 | extern int procfs_read_fpregs __P((struct proc *, struct fpreg *)); |
129 | extern int procfs_write_fpregs __P((struct proc *, struct fpreg *)); | |
4e89d26e JSP |
130 | extern int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); |
131 | extern int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); | |
6fdd7e21 | 132 | extern int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); |
4e89d26e JSP |
133 | extern int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); |
134 | extern int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); | |
135 | extern int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); | |
136 | ||
137 | #define PROCFS_LOCKED 0x01 | |
138 | #define PROCFS_WANT 0x02 | |
139 | ||
140 | extern int (**procfs_vnodeop_p)(); | |
141 | extern struct vfsops procfs_vfsops; | |
142 | ||
143 | /* | |
144 | * Prototypes for procfs vnode ops | |
145 | */ | |
146 | int procfs_badop(); /* varargs */ | |
147 | int procfs_rw __P((struct vop_read_args *)); | |
148 | int procfs_lookup __P((struct vop_lookup_args *)); | |
149 | #define procfs_create ((int (*) __P((struct vop_create_args *))) procfs_badop) | |
150 | #define procfs_mknod ((int (*) __P((struct vop_mknod_args *))) procfs_badop) | |
151 | int procfs_open __P((struct vop_open_args *)); | |
152 | int procfs_close __P((struct vop_close_args *)); | |
153 | int procfs_access __P((struct vop_access_args *)); | |
154 | int procfs_getattr __P((struct vop_getattr_args *)); | |
155 | int procfs_setattr __P((struct vop_setattr_args *)); | |
156 | #define procfs_read procfs_rw | |
157 | #define procfs_write procfs_rw | |
158 | int procfs_ioctl __P((struct vop_ioctl_args *)); | |
159 | #define procfs_select ((int (*) __P((struct vop_select_args *))) procfs_badop) | |
160 | #define procfs_mmap ((int (*) __P((struct vop_mmap_args *))) procfs_badop) | |
161 | #define procfs_fsync ((int (*) __P((struct vop_fsync_args *))) procfs_badop) | |
162 | #define procfs_seek ((int (*) __P((struct vop_seek_args *))) procfs_badop) | |
163 | #define procfs_remove ((int (*) __P((struct vop_remove_args *))) procfs_badop) | |
164 | #define procfs_link ((int (*) __P((struct vop_link_args *))) procfs_badop) | |
165 | #define procfs_rename ((int (*) __P((struct vop_rename_args *))) procfs_badop) | |
166 | #define procfs_mkdir ((int (*) __P((struct vop_mkdir_args *))) procfs_badop) | |
167 | #define procfs_rmdir ((int (*) __P((struct vop_rmdir_args *))) procfs_badop) | |
168 | #define procfs_symlink ((int (*) __P((struct vop_symlink_args *))) procfs_badop) | |
169 | int procfs_readdir __P((struct vop_readdir_args *)); | |
170 | #define procfs_readlink ((int (*) __P((struct vop_readlink_args *))) procfs_badop) | |
171 | int procfs_abortop __P((struct vop_abortop_args *)); | |
172 | int procfs_inactive __P((struct vop_inactive_args *)); | |
173 | int procfs_reclaim __P((struct vop_reclaim_args *)); | |
174 | #define procfs_lock ((int (*) __P((struct vop_lock_args *))) nullop) | |
175 | #define procfs_unlock ((int (*) __P((struct vop_unlock_args *))) nullop) | |
176 | int procfs_bmap __P((struct vop_bmap_args *)); | |
177 | #define procfs_strategy ((int (*) __P((struct vop_strategy_args *))) procfs_badop) | |
178 | int procfs_print __P((struct vop_print_args *)); | |
179 | #define procfs_islocked ((int (*) __P((struct vop_islocked_args *))) nullop) | |
180 | #define procfs_advlock ((int (*) __P((struct vop_advlock_args *))) procfs_badop) | |
4e89d26e JSP |
181 | #define procfs_blkatoff ((int (*) __P((struct vop_blkatoff_args *))) procfs_badop) |
182 | #define procfs_valloc ((int (*) __P((struct vop_valloc_args *))) procfs_badop) | |
183 | #define procfs_vfree ((int (*) __P((struct vop_vfree_args *))) nullop) | |
184 | #define procfs_truncate ((int (*) __P((struct vop_truncate_args *))) procfs_badop) | |
185 | #define procfs_update ((int (*) __P((struct vop_update_args *))) nullop) | |
186 | #endif /* KERNEL */ |