xref: /csrg-svn/sys/miscfs/procfs/procfs.h (revision 69441)
165520Spendry /*
265520Spendry  * Copyright (c) 1993 Jan-Simon Pendry
365808Sbostic  * Copyright (c) 1993
465808Sbostic  *	The Regents of the University of California.  All rights reserved.
565520Spendry  *
665520Spendry  * This code is derived from software contributed to Berkeley by
765520Spendry  * Jan-Simon Pendry.
865520Spendry  *
965520Spendry  * %sccs.include.redist.c%
1065520Spendry  *
11*69441Smckusick  *	@(#)procfs.h	8.9 (Berkeley) 05/14/95
1265520Spendry  *
1365520Spendry  * From:
1465520Spendry  *	$Id: procfs.h,v 3.2 1993/12/15 09:40:17 jsp Exp $
1565520Spendry  */
1665520Spendry 
1765520Spendry /*
1865520Spendry  * The different types of node in a procfs filesystem
1965520Spendry  */
2065520Spendry typedef enum {
2165520Spendry 	Proot,		/* the filesystem root */
2267389Spendry 	Pcurproc,	/* symbolic link for curproc */
2365520Spendry 	Pproc,		/* a process-specific sub-directory */
2465520Spendry 	Pfile,		/* the executable file */
2565520Spendry 	Pmem,		/* the process's memory image */
2665520Spendry 	Pregs,		/* the process's register set */
2765924Spendry 	Pfpregs,	/* the process's FP register set */
2865520Spendry 	Pctl,		/* process control */
2965520Spendry 	Pstatus,	/* process status */
3065520Spendry 	Pnote,		/* process notifier */
3165520Spendry 	Pnotepg		/* process group notifier */
3265520Spendry } pfstype;
3365520Spendry 
3465520Spendry /*
3565520Spendry  * control data for the proc file system.
3665520Spendry  */
3765520Spendry struct pfsnode {
3865520Spendry 	struct pfsnode	*pfs_next;	/* next on list */
3965520Spendry 	struct vnode	*pfs_vnode;	/* vnode associated with this pfsnode */
4065520Spendry 	pfstype		pfs_type;	/* type of procfs node */
4165520Spendry 	pid_t		pfs_pid;	/* associated process */
4265520Spendry 	u_short		pfs_mode;	/* mode bits for stat() */
4365520Spendry 	u_long		pfs_flags;	/* open flags */
4465520Spendry 	u_long		pfs_fileno;	/* unique file id */
4565520Spendry };
4665520Spendry 
4765520Spendry #define PROCFS_NOTELEN	64	/* max length of a note (/proc/$pid/note) */
4865520Spendry #define PROCFS_CTLLEN 	8	/* max length of a ctl msg (/proc/$pid/ctl */
4965520Spendry 
5065520Spendry /*
5165520Spendry  * Kernel stuff follows
5265520Spendry  */
5365520Spendry #ifdef KERNEL
5465520Spendry #define CNEQ(cnp, s, len) \
5565520Spendry 	 ((cnp)->cn_namelen == (len) && \
5665520Spendry 	  (bcmp((s), (cnp)->cn_nameptr, (len)) == 0))
5765520Spendry 
5865520Spendry /*
5965520Spendry  * Format of a directory entry in /proc, ...
6065520Spendry  * This must map onto struct dirent (see <dirent.h>)
6165520Spendry  */
6265520Spendry #define PROCFS_NAMELEN 8
6365520Spendry struct pfsdent {
6465520Spendry 	u_long	d_fileno;
6565520Spendry 	u_short	d_reclen;
6665520Spendry 	u_char	d_type;
6765520Spendry 	u_char	d_namlen;
6865520Spendry 	char	d_name[PROCFS_NAMELEN];
6965520Spendry };
7065520Spendry #define UIO_MX sizeof(struct pfsdent)
7165520Spendry #define PROCFS_FILENO(pid, type) \
7267389Spendry 	(((type) < Pproc) ? \
7367389Spendry 			((type) + 2) : \
7467389Spendry 			((((pid)+1) << 4) + ((int) (type))))
7565520Spendry 
7665520Spendry /*
7765520Spendry  * Convert between pfsnode vnode
7865520Spendry  */
7965520Spendry #define VTOPFS(vp)	((struct pfsnode *)(vp)->v_data)
8065520Spendry #define PFSTOV(pfs)	((pfs)->pfs_vnode)
8165520Spendry 
8265520Spendry typedef struct vfs_namemap vfs_namemap_t;
8365520Spendry struct vfs_namemap {
8465520Spendry 	const char *nm_name;
8565520Spendry 	int nm_val;
8665520Spendry };
8765520Spendry 
8867389Spendry int vfs_getuserstr __P((struct uio *, char *, int *));
8967389Spendry vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int));
9065520Spendry 
9165520Spendry /* <machine/reg.h> */
9265520Spendry struct reg;
9365993Spendry struct fpreg;
9465520Spendry 
9565520Spendry #define PFIND(pid) ((pid) ? pfind(pid) : &proc0)
9667389Spendry int procfs_freevp __P((struct vnode *));
9767389Spendry int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype));
9867389Spendry struct vnode *procfs_findtextvp __P((struct proc *));
9967389Spendry int procfs_sstep __P((struct proc *, int));
10067389Spendry void procfs_fix_sstep __P((struct proc *));
10167389Spendry int procfs_read_regs __P((struct proc *, struct reg *));
10267389Spendry int procfs_write_regs __P((struct proc *, struct reg *));
10367389Spendry int procfs_read_fpregs __P((struct proc *, struct fpreg *));
10467389Spendry int procfs_write_fpregs __P((struct proc *, struct fpreg *));
10567389Spendry int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
10667389Spendry int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
10767389Spendry int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
10867389Spendry int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
10967389Spendry int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
11067389Spendry int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
11165520Spendry 
11267389Spendry /* functions to check whether or not files should be displayed */
11367389Spendry int procfs_validfile __P((struct proc *));
11467389Spendry int procfs_validfpregs __P((struct proc *));
11567389Spendry int procfs_validregs __P((struct proc *));
11667389Spendry 
11765520Spendry #define PROCFS_LOCKED	0x01
11865520Spendry #define PROCFS_WANT	0x02
11965520Spendry 
12065520Spendry extern int (**procfs_vnodeop_p)();
12165520Spendry extern struct vfsops procfs_vfsops;
12265520Spendry 
12365520Spendry /*
12465520Spendry  * Prototypes for procfs vnode ops
12565520Spendry  */
12665520Spendry int	procfs_badop();	/* varargs */
12765520Spendry int	procfs_rw __P((struct vop_read_args *));
12865520Spendry int	procfs_lookup __P((struct vop_lookup_args *));
12965520Spendry #define procfs_create ((int (*) __P((struct vop_create_args *))) procfs_badop)
13065520Spendry #define procfs_mknod ((int (*) __P((struct vop_mknod_args *))) procfs_badop)
13165520Spendry int	procfs_open __P((struct vop_open_args *));
13265520Spendry int	procfs_close __P((struct vop_close_args *));
13365520Spendry int	procfs_access __P((struct vop_access_args *));
13465520Spendry int	procfs_getattr __P((struct vop_getattr_args *));
13565520Spendry int	procfs_setattr __P((struct vop_setattr_args *));
13665520Spendry #define	procfs_read procfs_rw
13765520Spendry #define	procfs_write procfs_rw
13865520Spendry int	procfs_ioctl __P((struct vop_ioctl_args *));
13965520Spendry #define procfs_select ((int (*) __P((struct vop_select_args *))) procfs_badop)
14065520Spendry #define procfs_mmap ((int (*) __P((struct vop_mmap_args *))) procfs_badop)
14168732Smckusick #define	procfs_revoke vop_revoke
14265520Spendry #define procfs_fsync ((int (*) __P((struct vop_fsync_args *))) procfs_badop)
14365520Spendry #define procfs_seek ((int (*) __P((struct vop_seek_args *))) procfs_badop)
14465520Spendry #define procfs_remove ((int (*) __P((struct vop_remove_args *))) procfs_badop)
14565520Spendry #define procfs_link ((int (*) __P((struct vop_link_args *))) procfs_badop)
14665520Spendry #define procfs_rename ((int (*) __P((struct vop_rename_args *))) procfs_badop)
14765520Spendry #define procfs_mkdir ((int (*) __P((struct vop_mkdir_args *))) procfs_badop)
14865520Spendry #define procfs_rmdir ((int (*) __P((struct vop_rmdir_args *))) procfs_badop)
14965520Spendry #define procfs_symlink ((int (*) __P((struct vop_symlink_args *))) procfs_badop)
15065520Spendry int	procfs_readdir __P((struct vop_readdir_args *));
15167389Spendry int	procfs_readlink __P((struct vop_readlink_args *));
15265520Spendry int	procfs_abortop __P((struct vop_abortop_args *));
15365520Spendry int	procfs_inactive __P((struct vop_inactive_args *));
15465520Spendry int	procfs_reclaim __P((struct vop_reclaim_args *));
155*69441Smckusick #define procfs_lock ((int (*) __P((struct  vop_lock_args *)))vop_nolock)
156*69441Smckusick #define procfs_unlock ((int (*) __P((struct  vop_unlock_args *)))vop_nounlock)
15765520Spendry int	procfs_bmap __P((struct vop_bmap_args *));
15865520Spendry #define	procfs_strategy ((int (*) __P((struct vop_strategy_args *))) procfs_badop)
15965520Spendry int	procfs_print __P((struct vop_print_args *));
160*69441Smckusick #define procfs_islocked \
161*69441Smckusick 	((int (*) __P((struct vop_islocked_args *)))vop_noislocked)
16265520Spendry #define procfs_advlock ((int (*) __P((struct vop_advlock_args *))) procfs_badop)
16365520Spendry #define procfs_blkatoff ((int (*) __P((struct vop_blkatoff_args *))) procfs_badop)
16465520Spendry #define procfs_valloc ((int (*) __P((struct vop_valloc_args *))) procfs_badop)
16565520Spendry #define procfs_vfree ((int (*) __P((struct vop_vfree_args *))) nullop)
16665520Spendry #define procfs_truncate ((int (*) __P((struct vop_truncate_args *))) procfs_badop)
16765520Spendry #define procfs_update ((int (*) __P((struct vop_update_args *))) nullop)
16865520Spendry #endif /* KERNEL */
169