xref: /csrg-svn/sys/miscfs/procfs/procfs.h (revision 65924)
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*65924Spendry  *	@(#)procfs.h	8.5 (Berkeley) 01/27/94
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 */
2265520Spendry 	Pproc,		/* a process-specific sub-directory */
2365520Spendry 	Pfile,		/* the executable file */
2465520Spendry 	Pmem,		/* the process's memory image */
2565520Spendry 	Pregs,		/* the process's register set */
26*65924Spendry 	Pfpregs,	/* the process's FP register set */
2765520Spendry 	Pctl,		/* process control */
2865520Spendry 	Pstatus,	/* process status */
2965520Spendry 	Pnote,		/* process notifier */
3065520Spendry 	Pnotepg		/* process group notifier */
3165520Spendry } pfstype;
3265520Spendry 
3365520Spendry /*
3465520Spendry  * control data for the proc file system.
3565520Spendry  */
3665520Spendry struct pfsnode {
3765520Spendry 	struct pfsnode	*pfs_next;	/* next on list */
3865520Spendry 	struct vnode	*pfs_vnode;	/* vnode associated with this pfsnode */
3965520Spendry 	pfstype		pfs_type;	/* type of procfs node */
4065520Spendry 	pid_t		pfs_pid;	/* associated process */
4165520Spendry 	u_short		pfs_mode;	/* mode bits for stat() */
4265520Spendry 	u_long		pfs_flags;	/* open flags */
4365520Spendry 	u_long		pfs_fileno;	/* unique file id */
4465520Spendry };
4565520Spendry 
4665520Spendry #define PROCFS_NOTELEN	64	/* max length of a note (/proc/$pid/note) */
4765520Spendry #define PROCFS_CTLLEN 	8	/* max length of a ctl msg (/proc/$pid/ctl */
4865520Spendry 
4965520Spendry /*
5065520Spendry  * Kernel stuff follows
5165520Spendry  */
5265520Spendry #ifdef KERNEL
5365520Spendry #define CNEQ(cnp, s, len) \
5465520Spendry 	 ((cnp)->cn_namelen == (len) && \
5565520Spendry 	  (bcmp((s), (cnp)->cn_nameptr, (len)) == 0))
5665520Spendry 
5765520Spendry /*
5865520Spendry  * Format of a directory entry in /proc, ...
5965520Spendry  * This must map onto struct dirent (see <dirent.h>)
6065520Spendry  */
6165520Spendry #define PROCFS_NAMELEN 8
6265520Spendry struct pfsdent {
6365520Spendry 	u_long	d_fileno;
6465520Spendry 	u_short	d_reclen;
6565520Spendry 	u_char	d_type;
6665520Spendry 	u_char	d_namlen;
6765520Spendry 	char	d_name[PROCFS_NAMELEN];
6865520Spendry };
6965520Spendry #define UIO_MX sizeof(struct pfsdent)
7065520Spendry #define PROCFS_FILENO(pid, type) \
7165520Spendry 	(((type) == Proot) ? \
7265520Spendry 			2 : \
7365520Spendry 			((((pid)+1) << 3) + ((int) (type))))
7465520Spendry 
7565520Spendry /*
7665520Spendry  * Convert between pfsnode vnode
7765520Spendry  */
7865520Spendry #define VTOPFS(vp)	((struct pfsnode *)(vp)->v_data)
7965520Spendry #define PFSTOV(pfs)	((pfs)->pfs_vnode)
8065520Spendry 
8165520Spendry typedef struct vfs_namemap vfs_namemap_t;
8265520Spendry struct vfs_namemap {
8365520Spendry 	const char *nm_name;
8465520Spendry 	int nm_val;
8565520Spendry };
8665520Spendry 
8765520Spendry extern int vfs_getuserstr __P((struct uio *, char *, int *));
8865520Spendry extern vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int));
8965520Spendry 
9065520Spendry /* <machine/reg.h> */
9165520Spendry struct reg;
9265520Spendry 
9365520Spendry #define PFIND(pid) ((pid) ? pfind(pid) : &proc0)
9465520Spendry extern int procfs_freevp __P((struct vnode *));
9565520Spendry extern int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype));
9665520Spendry extern struct vnode *procfs_findtextvp __P((struct proc *));
9765520Spendry extern int procfs_sstep __P((struct proc *));
9865531Spendry extern void procfs_fix_sstep __P((struct proc *));
9965520Spendry extern int procfs_read_regs __P((struct proc *, struct reg *));
10065520Spendry extern int procfs_write_regs __P((struct proc *, struct reg *));
101*65924Spendry extern int procfs_read_fpregs __P((struct proc *, struct fpreg *));
102*65924Spendry extern int procfs_write_fpregs __P((struct proc *, struct fpreg *));
10365520Spendry extern int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
10465520Spendry extern int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
105*65924Spendry extern int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
10665520Spendry extern int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
10765520Spendry extern int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
10865520Spendry extern int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
10965520Spendry 
11065520Spendry #define PROCFS_LOCKED	0x01
11165520Spendry #define PROCFS_WANT	0x02
11265520Spendry 
11365520Spendry extern int (**procfs_vnodeop_p)();
11465520Spendry extern struct vfsops procfs_vfsops;
11565520Spendry 
11665520Spendry /*
11765520Spendry  * Prototypes for procfs vnode ops
11865520Spendry  */
11965520Spendry int	procfs_badop();	/* varargs */
12065520Spendry int	procfs_rw __P((struct vop_read_args *));
12165520Spendry int	procfs_lookup __P((struct vop_lookup_args *));
12265520Spendry #define procfs_create ((int (*) __P((struct vop_create_args *))) procfs_badop)
12365520Spendry #define procfs_mknod ((int (*) __P((struct vop_mknod_args *))) procfs_badop)
12465520Spendry int	procfs_open __P((struct vop_open_args *));
12565520Spendry int	procfs_close __P((struct vop_close_args *));
12665520Spendry int	procfs_access __P((struct vop_access_args *));
12765520Spendry int	procfs_getattr __P((struct vop_getattr_args *));
12865520Spendry int	procfs_setattr __P((struct vop_setattr_args *));
12965520Spendry #define	procfs_read procfs_rw
13065520Spendry #define	procfs_write procfs_rw
13165520Spendry int	procfs_ioctl __P((struct vop_ioctl_args *));
13265520Spendry #define procfs_select ((int (*) __P((struct vop_select_args *))) procfs_badop)
13365520Spendry #define procfs_mmap ((int (*) __P((struct vop_mmap_args *))) procfs_badop)
13465520Spendry #define procfs_fsync ((int (*) __P((struct vop_fsync_args *))) procfs_badop)
13565520Spendry #define procfs_seek ((int (*) __P((struct vop_seek_args *))) procfs_badop)
13665520Spendry #define procfs_remove ((int (*) __P((struct vop_remove_args *))) procfs_badop)
13765520Spendry #define procfs_link ((int (*) __P((struct vop_link_args *))) procfs_badop)
13865520Spendry #define procfs_rename ((int (*) __P((struct vop_rename_args *))) procfs_badop)
13965520Spendry #define procfs_mkdir ((int (*) __P((struct vop_mkdir_args *))) procfs_badop)
14065520Spendry #define procfs_rmdir ((int (*) __P((struct vop_rmdir_args *))) procfs_badop)
14165520Spendry #define procfs_symlink ((int (*) __P((struct vop_symlink_args *))) procfs_badop)
14265520Spendry int	procfs_readdir __P((struct vop_readdir_args *));
14365520Spendry #define procfs_readlink ((int (*) __P((struct vop_readlink_args *))) procfs_badop)
14465520Spendry int	procfs_abortop __P((struct vop_abortop_args *));
14565520Spendry int	procfs_inactive __P((struct vop_inactive_args *));
14665520Spendry int	procfs_reclaim __P((struct vop_reclaim_args *));
14765520Spendry #define procfs_lock ((int (*) __P((struct vop_lock_args *))) nullop)
14865520Spendry #define procfs_unlock ((int (*) __P((struct vop_unlock_args *))) nullop)
14965520Spendry int	procfs_bmap __P((struct vop_bmap_args *));
15065520Spendry #define	procfs_strategy ((int (*) __P((struct vop_strategy_args *))) procfs_badop)
15165520Spendry int	procfs_print __P((struct vop_print_args *));
15265520Spendry #define procfs_islocked ((int (*) __P((struct vop_islocked_args *))) nullop)
15365520Spendry #define procfs_advlock ((int (*) __P((struct vop_advlock_args *))) procfs_badop)
15465520Spendry #define procfs_blkatoff ((int (*) __P((struct vop_blkatoff_args *))) procfs_badop)
15565520Spendry #define procfs_valloc ((int (*) __P((struct vop_valloc_args *))) procfs_badop)
15665520Spendry #define procfs_vfree ((int (*) __P((struct vop_vfree_args *))) nullop)
15765520Spendry #define procfs_truncate ((int (*) __P((struct vop_truncate_args *))) procfs_badop)
15865520Spendry #define procfs_update ((int (*) __P((struct vop_update_args *))) nullop)
15965520Spendry #endif /* KERNEL */
160