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