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