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