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 | * | |
9 | * %sccs.include.redist.c% | |
10 | * | |
679a7c6b | 11 | * @(#)procfs.h 8.7 (Berkeley) %G% |
4e89d26e JSP |
12 | * |
13 | * From: | |
14 | * $Id: procfs.h,v 3.2 1993/12/15 09:40:17 jsp Exp $ | |
15 | */ | |
16 | ||
17 | /* | |
18 | * The different types of node in a procfs filesystem | |
19 | */ | |
20 | typedef enum { | |
21 | Proot, /* the filesystem root */ | |
679a7c6b | 22 | Pcurproc, /* symbolic link for curproc */ |
4e89d26e JSP |
23 | Pproc, /* a process-specific sub-directory */ |
24 | Pfile, /* the executable file */ | |
25 | Pmem, /* the process's memory image */ | |
26 | Pregs, /* the process's register set */ | |
6fdd7e21 | 27 | Pfpregs, /* the process's FP register set */ |
4e89d26e JSP |
28 | Pctl, /* process control */ |
29 | Pstatus, /* process status */ | |
30 | Pnote, /* process notifier */ | |
31 | Pnotepg /* process group notifier */ | |
32 | } pfstype; | |
33 | ||
34 | /* | |
35 | * control data for the proc file system. | |
36 | */ | |
37 | struct pfsnode { | |
38 | struct pfsnode *pfs_next; /* next on list */ | |
39 | struct vnode *pfs_vnode; /* vnode associated with this pfsnode */ | |
40 | pfstype pfs_type; /* type of procfs node */ | |
41 | pid_t pfs_pid; /* associated process */ | |
42 | u_short pfs_mode; /* mode bits for stat() */ | |
43 | u_long pfs_flags; /* open flags */ | |
44 | u_long pfs_fileno; /* unique file id */ | |
45 | }; | |
46 | ||
47 | #define PROCFS_NOTELEN 64 /* max length of a note (/proc/$pid/note) */ | |
48 | #define PROCFS_CTLLEN 8 /* max length of a ctl msg (/proc/$pid/ctl */ | |
49 | ||
50 | /* | |
51 | * Kernel stuff follows | |
52 | */ | |
53 | #ifdef KERNEL | |
54 | #define CNEQ(cnp, s, len) \ | |
55 | ((cnp)->cn_namelen == (len) && \ | |
56 | (bcmp((s), (cnp)->cn_nameptr, (len)) == 0)) | |
57 | ||
58 | /* | |
59 | * Format of a directory entry in /proc, ... | |
60 | * This must map onto struct dirent (see <dirent.h>) | |
61 | */ | |
62 | #define PROCFS_NAMELEN 8 | |
63 | struct pfsdent { | |
64 | u_long d_fileno; | |
65 | u_short d_reclen; | |
66 | u_char d_type; | |
67 | u_char d_namlen; | |
68 | char d_name[PROCFS_NAMELEN]; | |
69 | }; | |
70 | #define UIO_MX sizeof(struct pfsdent) | |
71 | #define PROCFS_FILENO(pid, type) \ | |
679a7c6b JSP |
72 | (((type) < Pproc) ? \ |
73 | ((type) + 2) : \ | |
74 | ((((pid)+1) << 4) + ((int) (type)))) | |
4e89d26e JSP |
75 | |
76 | /* | |
77 | * Convert between pfsnode vnode | |
78 | */ | |
79 | #define VTOPFS(vp) ((struct pfsnode *)(vp)->v_data) | |
80 | #define PFSTOV(pfs) ((pfs)->pfs_vnode) | |
81 | ||
82 | typedef struct vfs_namemap vfs_namemap_t; | |
83 | struct vfs_namemap { | |
84 | const char *nm_name; | |
85 | int nm_val; | |
86 | }; | |
87 | ||
679a7c6b JSP |
88 | int vfs_getuserstr __P((struct uio *, char *, int *)); |
89 | vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int)); | |
4e89d26e JSP |
90 | |
91 | /* <machine/reg.h> */ | |
92 | struct reg; | |
e30956f6 | 93 | struct fpreg; |
4e89d26e JSP |
94 | |
95 | #define PFIND(pid) ((pid) ? pfind(pid) : &proc0) | |
679a7c6b JSP |
96 | int procfs_freevp __P((struct vnode *)); |
97 | int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype)); | |
98 | struct vnode *procfs_findtextvp __P((struct proc *)); | |
99 | int procfs_sstep __P((struct proc *, int)); | |
100 | void procfs_fix_sstep __P((struct proc *)); | |
101 | int procfs_read_regs __P((struct proc *, struct reg *)); | |
102 | int procfs_write_regs __P((struct proc *, struct reg *)); | |
103 | int procfs_read_fpregs __P((struct proc *, struct fpreg *)); | |
104 | int procfs_write_fpregs __P((struct proc *, struct fpreg *)); | |
105 | int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); | |
106 | int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); | |
107 | int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); | |
108 | int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); | |
109 | int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); | |
110 | int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio)); | |
111 | ||
112 | /* functions to check whether or not files should be displayed */ | |
113 | int procfs_validfile __P((struct proc *)); | |
114 | int procfs_validfpregs __P((struct proc *)); | |
115 | int procfs_validregs __P((struct proc *)); | |
4e89d26e JSP |
116 | |
117 | #define PROCFS_LOCKED 0x01 | |
118 | #define PROCFS_WANT 0x02 | |
119 | ||
120 | extern int (**procfs_vnodeop_p)(); | |
121 | extern struct vfsops procfs_vfsops; | |
122 | ||
123 | /* | |
124 | * Prototypes for procfs vnode ops | |
125 | */ | |
126 | int procfs_badop(); /* varargs */ | |
127 | int procfs_rw __P((struct vop_read_args *)); | |
128 | int procfs_lookup __P((struct vop_lookup_args *)); | |
129 | #define procfs_create ((int (*) __P((struct vop_create_args *))) procfs_badop) | |
130 | #define procfs_mknod ((int (*) __P((struct vop_mknod_args *))) procfs_badop) | |
131 | int procfs_open __P((struct vop_open_args *)); | |
132 | int procfs_close __P((struct vop_close_args *)); | |
133 | int procfs_access __P((struct vop_access_args *)); | |
134 | int procfs_getattr __P((struct vop_getattr_args *)); | |
135 | int procfs_setattr __P((struct vop_setattr_args *)); | |
136 | #define procfs_read procfs_rw | |
137 | #define procfs_write procfs_rw | |
138 | int procfs_ioctl __P((struct vop_ioctl_args *)); | |
139 | #define procfs_select ((int (*) __P((struct vop_select_args *))) procfs_badop) | |
140 | #define procfs_mmap ((int (*) __P((struct vop_mmap_args *))) procfs_badop) | |
141 | #define procfs_fsync ((int (*) __P((struct vop_fsync_args *))) procfs_badop) | |
142 | #define procfs_seek ((int (*) __P((struct vop_seek_args *))) procfs_badop) | |
143 | #define procfs_remove ((int (*) __P((struct vop_remove_args *))) procfs_badop) | |
144 | #define procfs_link ((int (*) __P((struct vop_link_args *))) procfs_badop) | |
145 | #define procfs_rename ((int (*) __P((struct vop_rename_args *))) procfs_badop) | |
146 | #define procfs_mkdir ((int (*) __P((struct vop_mkdir_args *))) procfs_badop) | |
147 | #define procfs_rmdir ((int (*) __P((struct vop_rmdir_args *))) procfs_badop) | |
148 | #define procfs_symlink ((int (*) __P((struct vop_symlink_args *))) procfs_badop) | |
149 | int procfs_readdir __P((struct vop_readdir_args *)); | |
679a7c6b | 150 | int procfs_readlink __P((struct vop_readlink_args *)); |
4e89d26e JSP |
151 | int procfs_abortop __P((struct vop_abortop_args *)); |
152 | int procfs_inactive __P((struct vop_inactive_args *)); | |
153 | int procfs_reclaim __P((struct vop_reclaim_args *)); | |
154 | #define procfs_lock ((int (*) __P((struct vop_lock_args *))) nullop) | |
155 | #define procfs_unlock ((int (*) __P((struct vop_unlock_args *))) nullop) | |
156 | int procfs_bmap __P((struct vop_bmap_args *)); | |
157 | #define procfs_strategy ((int (*) __P((struct vop_strategy_args *))) procfs_badop) | |
158 | int procfs_print __P((struct vop_print_args *)); | |
159 | #define procfs_islocked ((int (*) __P((struct vop_islocked_args *))) nullop) | |
160 | #define procfs_advlock ((int (*) __P((struct vop_advlock_args *))) procfs_badop) | |
4e89d26e JSP |
161 | #define procfs_blkatoff ((int (*) __P((struct vop_blkatoff_args *))) procfs_badop) |
162 | #define procfs_valloc ((int (*) __P((struct vop_valloc_args *))) procfs_badop) | |
163 | #define procfs_vfree ((int (*) __P((struct vop_vfree_args *))) nullop) | |
164 | #define procfs_truncate ((int (*) __P((struct vop_truncate_args *))) procfs_badop) | |
165 | #define procfs_update ((int (*) __P((struct vop_update_args *))) nullop) | |
166 | #endif /* KERNEL */ |