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