procfs.h revision 1.12 1 1.12 cgd /* $NetBSD: procfs.h,v 1.12 1994/10/29 07:58:53 cgd Exp $ */
2 1.11 cgd
3 1.1 cgd /*
4 1.1 cgd * Copyright (c) 1993 Jan-Simon Pendry
5 1.9 mycroft * Copyright (c) 1993
6 1.9 mycroft * The Regents of the University of California. All rights reserved.
7 1.1 cgd *
8 1.1 cgd * This code is derived from software contributed to Berkeley by
9 1.1 cgd * Jan-Simon Pendry.
10 1.1 cgd *
11 1.1 cgd * Redistribution and use in source and binary forms, with or without
12 1.1 cgd * modification, are permitted provided that the following conditions
13 1.1 cgd * are met:
14 1.1 cgd * 1. Redistributions of source code must retain the above copyright
15 1.1 cgd * notice, this list of conditions and the following disclaimer.
16 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 cgd * notice, this list of conditions and the following disclaimer in the
18 1.1 cgd * documentation and/or other materials provided with the distribution.
19 1.1 cgd * 3. All advertising materials mentioning features or use of this software
20 1.1 cgd * must display the following acknowledgement:
21 1.1 cgd * This product includes software developed by the University of
22 1.1 cgd * California, Berkeley and its contributors.
23 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
24 1.1 cgd * may be used to endorse or promote products derived from this software
25 1.1 cgd * without specific prior written permission.
26 1.1 cgd *
27 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 1.1 cgd * SUCH DAMAGE.
38 1.1 cgd *
39 1.11 cgd * @(#)procfs.h 8.7 (Berkeley) 6/15/94
40 1.1 cgd */
41 1.1 cgd
42 1.1 cgd /*
43 1.1 cgd * The different types of node in a procfs filesystem
44 1.1 cgd */
45 1.1 cgd typedef enum {
46 1.1 cgd Proot, /* the filesystem root */
47 1.9 mycroft Pcurproc, /* symbolic link for curproc */
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.9 mycroft Pfpregs, /* the process's FP 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.9 mycroft #define PROCFS_NOTELEN 64 /* 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.9 mycroft #define CNEQ(cnp, s, len) \
80 1.9 mycroft ((cnp)->cn_namelen == (len) && \
81 1.9 mycroft (bcmp((s), (cnp)->cn_nameptr, (len)) == 0))
82 1.1 cgd
83 1.1 cgd /*
84 1.1 cgd * Format of a directory entry in /proc, ...
85 1.1 cgd * This must map onto struct dirent (see <dirent.h>)
86 1.1 cgd */
87 1.1 cgd #define PROCFS_NAMELEN 8
88 1.1 cgd struct pfsdent {
89 1.12 cgd u_int32_t d_fileno;
90 1.12 cgd u_int16_t d_reclen;
91 1.12 cgd u_int8_t d_type;
92 1.12 cgd u_int8_t d_namlen;
93 1.12 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.9 mycroft (((type) < Pproc) ? \
98 1.9 mycroft ((type) + 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.9 mycroft typedef struct vfs_namemap vfs_namemap_t;
108 1.9 mycroft struct vfs_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.9 mycroft int vfs_getuserstr __P((struct uio *, char *, int *));
114 1.9 mycroft vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int));
115 1.1 cgd
116 1.1 cgd #define PFIND(pid) ((pid) ? pfind(pid) : &proc0)
117 1.9 mycroft int procfs_freevp __P((struct vnode *));
118 1.9 mycroft int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype));
119 1.9 mycroft struct vnode *procfs_findtextvp __P((struct proc *));
120 1.9 mycroft int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
121 1.9 mycroft int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
122 1.9 mycroft int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
123 1.9 mycroft int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
124 1.9 mycroft int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
125 1.9 mycroft int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
126 1.8 cgd
127 1.8 cgd /* functions to check whether or not files should be displayed */
128 1.9 mycroft int procfs_validfile __P((struct proc *));
129 1.9 mycroft int procfs_validfpregs __P((struct proc *));
130 1.9 mycroft int procfs_validregs __P((struct proc *));
131 1.1 cgd
132 1.1 cgd #define PROCFS_LOCKED 0x01
133 1.1 cgd #define PROCFS_WANT 0x02
134 1.1 cgd
135 1.9 mycroft extern int (**procfs_vnodeop_p)();
136 1.1 cgd extern struct vfsops procfs_vfsops;
137 1.1 cgd
138 1.1 cgd /*
139 1.1 cgd * Prototypes for procfs vnode ops
140 1.1 cgd */
141 1.1 cgd int procfs_badop(); /* varargs */
142 1.9 mycroft int procfs_rw __P((struct vop_read_args *));
143 1.9 mycroft int procfs_lookup __P((struct vop_lookup_args *));
144 1.9 mycroft #define procfs_create ((int (*) __P((struct vop_create_args *))) procfs_badop)
145 1.9 mycroft #define procfs_mknod ((int (*) __P((struct vop_mknod_args *))) procfs_badop)
146 1.9 mycroft int procfs_open __P((struct vop_open_args *));
147 1.9 mycroft int procfs_close __P((struct vop_close_args *));
148 1.9 mycroft int procfs_access __P((struct vop_access_args *));
149 1.9 mycroft int procfs_getattr __P((struct vop_getattr_args *));
150 1.9 mycroft int procfs_setattr __P((struct vop_setattr_args *));
151 1.1 cgd #define procfs_read procfs_rw
152 1.1 cgd #define procfs_write procfs_rw
153 1.9 mycroft int procfs_ioctl __P((struct vop_ioctl_args *));
154 1.9 mycroft #define procfs_select ((int (*) __P((struct vop_select_args *))) procfs_badop)
155 1.9 mycroft #define procfs_mmap ((int (*) __P((struct vop_mmap_args *))) procfs_badop)
156 1.9 mycroft #define procfs_fsync ((int (*) __P((struct vop_fsync_args *))) procfs_badop)
157 1.9 mycroft #define procfs_seek ((int (*) __P((struct vop_seek_args *))) procfs_badop)
158 1.9 mycroft #define procfs_remove ((int (*) __P((struct vop_remove_args *))) procfs_badop)
159 1.9 mycroft #define procfs_link ((int (*) __P((struct vop_link_args *))) procfs_badop)
160 1.9 mycroft #define procfs_rename ((int (*) __P((struct vop_rename_args *))) procfs_badop)
161 1.9 mycroft #define procfs_mkdir ((int (*) __P((struct vop_mkdir_args *))) procfs_badop)
162 1.9 mycroft #define procfs_rmdir ((int (*) __P((struct vop_rmdir_args *))) procfs_badop)
163 1.9 mycroft #define procfs_symlink ((int (*) __P((struct vop_symlink_args *))) procfs_badop)
164 1.9 mycroft int procfs_readdir __P((struct vop_readdir_args *));
165 1.9 mycroft int procfs_readlink __P((struct vop_readlink_args *));
166 1.9 mycroft int procfs_abortop __P((struct vop_abortop_args *));
167 1.9 mycroft int procfs_inactive __P((struct vop_inactive_args *));
168 1.9 mycroft int procfs_reclaim __P((struct vop_reclaim_args *));
169 1.9 mycroft #define procfs_lock ((int (*) __P((struct vop_lock_args *))) nullop)
170 1.9 mycroft #define procfs_unlock ((int (*) __P((struct vop_unlock_args *))) nullop)
171 1.9 mycroft int procfs_bmap __P((struct vop_bmap_args *));
172 1.9 mycroft #define procfs_strategy ((int (*) __P((struct vop_strategy_args *))) procfs_badop)
173 1.9 mycroft int procfs_print __P((struct vop_print_args *));
174 1.9 mycroft #define procfs_islocked ((int (*) __P((struct vop_islocked_args *))) nullop)
175 1.9 mycroft #define procfs_advlock ((int (*) __P((struct vop_advlock_args *))) procfs_badop)
176 1.9 mycroft #define procfs_blkatoff ((int (*) __P((struct vop_blkatoff_args *))) procfs_badop)
177 1.9 mycroft #define procfs_valloc ((int (*) __P((struct vop_valloc_args *))) procfs_badop)
178 1.9 mycroft #define procfs_vfree ((int (*) __P((struct vop_vfree_args *))) nullop)
179 1.9 mycroft #define procfs_truncate ((int (*) __P((struct vop_truncate_args *))) procfs_badop)
180 1.9 mycroft #define procfs_update ((int (*) __P((struct vop_update_args *))) nullop)
181 1.1 cgd #endif /* KERNEL */
182