Home | History | Annotate | Line # | Download | only in procfs
procfs.h revision 1.1.1.2
      1      1.1   cgd /*
      2      1.1   cgd  * Copyright (c) 1993 Jan-Simon Pendry
      3  1.1.1.1  fvdl  * Copyright (c) 1993
      4  1.1.1.1  fvdl  *	The Regents of the University of California.  All rights reserved.
      5      1.1   cgd  *
      6      1.1   cgd  * This code is derived from software contributed to Berkeley by
      7      1.1   cgd  * Jan-Simon Pendry.
      8      1.1   cgd  *
      9      1.1   cgd  * Redistribution and use in source and binary forms, with or without
     10      1.1   cgd  * modification, are permitted provided that the following conditions
     11      1.1   cgd  * are met:
     12      1.1   cgd  * 1. Redistributions of source code must retain the above copyright
     13      1.1   cgd  *    notice, this list of conditions and the following disclaimer.
     14      1.1   cgd  * 2. Redistributions in binary form must reproduce the above copyright
     15      1.1   cgd  *    notice, this list of conditions and the following disclaimer in the
     16      1.1   cgd  *    documentation and/or other materials provided with the distribution.
     17      1.1   cgd  * 3. All advertising materials mentioning features or use of this software
     18      1.1   cgd  *    must display the following acknowledgement:
     19      1.1   cgd  *	This product includes software developed by the University of
     20      1.1   cgd  *	California, Berkeley and its contributors.
     21      1.1   cgd  * 4. Neither the name of the University nor the names of its contributors
     22      1.1   cgd  *    may be used to endorse or promote products derived from this software
     23      1.1   cgd  *    without specific prior written permission.
     24      1.1   cgd  *
     25      1.1   cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26      1.1   cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27      1.1   cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28      1.1   cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29      1.1   cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30      1.1   cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31      1.1   cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32      1.1   cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33      1.1   cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34      1.1   cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35      1.1   cgd  * SUCH DAMAGE.
     36      1.1   cgd  *
     37  1.1.1.2  fvdl  *	@(#)procfs.h	8.9 (Berkeley) 5/14/95
     38      1.1   cgd  *
     39  1.1.1.1  fvdl  * From:
     40  1.1.1.1  fvdl  *	$Id: procfs.h,v 1.1.1.2 1998/03/01 02:13:17 fvdl Exp $
     41      1.1   cgd  */
     42      1.1   cgd 
     43      1.1   cgd /*
     44      1.1   cgd  * The different types of node in a procfs filesystem
     45      1.1   cgd  */
     46      1.1   cgd typedef enum {
     47      1.1   cgd 	Proot,		/* the filesystem root */
     48  1.1.1.2  fvdl 	Pcurproc,	/* symbolic link for curproc */
     49      1.1   cgd 	Pproc,		/* a process-specific sub-directory */
     50      1.1   cgd 	Pfile,		/* the executable file */
     51      1.1   cgd 	Pmem,		/* the process's memory image */
     52      1.1   cgd 	Pregs,		/* the process's register set */
     53  1.1.1.1  fvdl 	Pfpregs,	/* the process's FP register set */
     54      1.1   cgd 	Pctl,		/* process control */
     55      1.1   cgd 	Pstatus,	/* process status */
     56      1.1   cgd 	Pnote,		/* process notifier */
     57      1.1   cgd 	Pnotepg		/* process group notifier */
     58      1.1   cgd } pfstype;
     59      1.1   cgd 
     60      1.1   cgd /*
     61      1.1   cgd  * control data for the proc file system.
     62      1.1   cgd  */
     63      1.1   cgd struct pfsnode {
     64      1.1   cgd 	struct pfsnode	*pfs_next;	/* next on list */
     65      1.1   cgd 	struct vnode	*pfs_vnode;	/* vnode associated with this pfsnode */
     66      1.1   cgd 	pfstype		pfs_type;	/* type of procfs node */
     67      1.1   cgd 	pid_t		pfs_pid;	/* associated process */
     68      1.1   cgd 	u_short		pfs_mode;	/* mode bits for stat() */
     69      1.1   cgd 	u_long		pfs_flags;	/* open flags */
     70      1.1   cgd 	u_long		pfs_fileno;	/* unique file id */
     71      1.1   cgd };
     72      1.1   cgd 
     73      1.1   cgd #define PROCFS_NOTELEN	64	/* max length of a note (/proc/$pid/note) */
     74      1.1   cgd #define PROCFS_CTLLEN 	8	/* max length of a ctl msg (/proc/$pid/ctl */
     75      1.1   cgd 
     76      1.1   cgd /*
     77      1.1   cgd  * Kernel stuff follows
     78      1.1   cgd  */
     79      1.1   cgd #ifdef KERNEL
     80  1.1.1.1  fvdl #define CNEQ(cnp, s, len) \
     81  1.1.1.1  fvdl 	 ((cnp)->cn_namelen == (len) && \
     82  1.1.1.1  fvdl 	  (bcmp((s), (cnp)->cn_nameptr, (len)) == 0))
     83      1.1   cgd 
     84      1.1   cgd /*
     85      1.1   cgd  * Format of a directory entry in /proc, ...
     86      1.1   cgd  * This must map onto struct dirent (see <dirent.h>)
     87      1.1   cgd  */
     88      1.1   cgd #define PROCFS_NAMELEN 8
     89      1.1   cgd struct pfsdent {
     90      1.1   cgd 	u_long	d_fileno;
     91      1.1   cgd 	u_short	d_reclen;
     92  1.1.1.1  fvdl 	u_char	d_type;
     93  1.1.1.1  fvdl 	u_char	d_namlen;
     94      1.1   cgd 	char	d_name[PROCFS_NAMELEN];
     95      1.1   cgd };
     96      1.1   cgd #define UIO_MX sizeof(struct pfsdent)
     97      1.1   cgd #define PROCFS_FILENO(pid, type) \
     98  1.1.1.2  fvdl 	(((type) < Pproc) ? \
     99  1.1.1.2  fvdl 			((type) + 2) : \
    100  1.1.1.2  fvdl 			((((pid)+1) << 4) + ((int) (type))))
    101      1.1   cgd 
    102      1.1   cgd /*
    103      1.1   cgd  * Convert between pfsnode vnode
    104      1.1   cgd  */
    105      1.1   cgd #define VTOPFS(vp)	((struct pfsnode *)(vp)->v_data)
    106      1.1   cgd #define PFSTOV(pfs)	((pfs)->pfs_vnode)
    107      1.1   cgd 
    108      1.1   cgd typedef struct vfs_namemap vfs_namemap_t;
    109      1.1   cgd struct vfs_namemap {
    110      1.1   cgd 	const char *nm_name;
    111      1.1   cgd 	int nm_val;
    112      1.1   cgd };
    113      1.1   cgd 
    114  1.1.1.2  fvdl int vfs_getuserstr __P((struct uio *, char *, int *));
    115  1.1.1.2  fvdl vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int));
    116      1.1   cgd 
    117  1.1.1.1  fvdl /* <machine/reg.h> */
    118      1.1   cgd struct reg;
    119  1.1.1.1  fvdl struct fpreg;
    120      1.1   cgd 
    121      1.1   cgd #define PFIND(pid) ((pid) ? pfind(pid) : &proc0)
    122  1.1.1.2  fvdl int procfs_freevp __P((struct vnode *));
    123  1.1.1.2  fvdl int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype));
    124  1.1.1.2  fvdl struct vnode *procfs_findtextvp __P((struct proc *));
    125  1.1.1.2  fvdl int procfs_sstep __P((struct proc *, int));
    126  1.1.1.2  fvdl void procfs_fix_sstep __P((struct proc *));
    127  1.1.1.2  fvdl int procfs_read_regs __P((struct proc *, struct reg *));
    128  1.1.1.2  fvdl int procfs_write_regs __P((struct proc *, struct reg *));
    129  1.1.1.2  fvdl int procfs_read_fpregs __P((struct proc *, struct fpreg *));
    130  1.1.1.2  fvdl int procfs_write_fpregs __P((struct proc *, struct fpreg *));
    131  1.1.1.2  fvdl int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
    132  1.1.1.2  fvdl int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
    133  1.1.1.2  fvdl int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
    134  1.1.1.2  fvdl int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
    135  1.1.1.2  fvdl int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
    136  1.1.1.2  fvdl int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
    137  1.1.1.2  fvdl 
    138  1.1.1.2  fvdl /* functions to check whether or not files should be displayed */
    139  1.1.1.2  fvdl int procfs_validfile __P((struct proc *));
    140  1.1.1.2  fvdl int procfs_validfpregs __P((struct proc *));
    141  1.1.1.2  fvdl int procfs_validregs __P((struct proc *));
    142      1.1   cgd 
    143      1.1   cgd #define PROCFS_LOCKED	0x01
    144      1.1   cgd #define PROCFS_WANT	0x02
    145      1.1   cgd 
    146  1.1.1.1  fvdl extern int (**procfs_vnodeop_p)();
    147      1.1   cgd extern struct vfsops procfs_vfsops;
    148      1.1   cgd 
    149      1.1   cgd /*
    150      1.1   cgd  * Prototypes for procfs vnode ops
    151      1.1   cgd  */
    152      1.1   cgd int	procfs_badop();	/* varargs */
    153  1.1.1.1  fvdl int	procfs_rw __P((struct vop_read_args *));
    154  1.1.1.1  fvdl int	procfs_lookup __P((struct vop_lookup_args *));
    155  1.1.1.1  fvdl #define procfs_create ((int (*) __P((struct vop_create_args *))) procfs_badop)
    156  1.1.1.1  fvdl #define procfs_mknod ((int (*) __P((struct vop_mknod_args *))) procfs_badop)
    157  1.1.1.1  fvdl int	procfs_open __P((struct vop_open_args *));
    158  1.1.1.1  fvdl int	procfs_close __P((struct vop_close_args *));
    159  1.1.1.1  fvdl int	procfs_access __P((struct vop_access_args *));
    160  1.1.1.1  fvdl int	procfs_getattr __P((struct vop_getattr_args *));
    161  1.1.1.1  fvdl int	procfs_setattr __P((struct vop_setattr_args *));
    162      1.1   cgd #define	procfs_read procfs_rw
    163      1.1   cgd #define	procfs_write procfs_rw
    164  1.1.1.1  fvdl int	procfs_ioctl __P((struct vop_ioctl_args *));
    165  1.1.1.1  fvdl #define procfs_select ((int (*) __P((struct vop_select_args *))) procfs_badop)
    166  1.1.1.1  fvdl #define procfs_mmap ((int (*) __P((struct vop_mmap_args *))) procfs_badop)
    167  1.1.1.2  fvdl #define	procfs_revoke vop_revoke
    168  1.1.1.1  fvdl #define procfs_fsync ((int (*) __P((struct vop_fsync_args *))) procfs_badop)
    169  1.1.1.1  fvdl #define procfs_seek ((int (*) __P((struct vop_seek_args *))) procfs_badop)
    170  1.1.1.1  fvdl #define procfs_remove ((int (*) __P((struct vop_remove_args *))) procfs_badop)
    171  1.1.1.1  fvdl #define procfs_link ((int (*) __P((struct vop_link_args *))) procfs_badop)
    172  1.1.1.1  fvdl #define procfs_rename ((int (*) __P((struct vop_rename_args *))) procfs_badop)
    173  1.1.1.1  fvdl #define procfs_mkdir ((int (*) __P((struct vop_mkdir_args *))) procfs_badop)
    174  1.1.1.1  fvdl #define procfs_rmdir ((int (*) __P((struct vop_rmdir_args *))) procfs_badop)
    175  1.1.1.1  fvdl #define procfs_symlink ((int (*) __P((struct vop_symlink_args *))) procfs_badop)
    176  1.1.1.1  fvdl int	procfs_readdir __P((struct vop_readdir_args *));
    177  1.1.1.2  fvdl int	procfs_readlink __P((struct vop_readlink_args *));
    178  1.1.1.1  fvdl int	procfs_abortop __P((struct vop_abortop_args *));
    179  1.1.1.1  fvdl int	procfs_inactive __P((struct vop_inactive_args *));
    180  1.1.1.1  fvdl int	procfs_reclaim __P((struct vop_reclaim_args *));
    181  1.1.1.2  fvdl #define procfs_lock ((int (*) __P((struct  vop_lock_args *)))vop_nolock)
    182  1.1.1.2  fvdl #define procfs_unlock ((int (*) __P((struct  vop_unlock_args *)))vop_nounlock)
    183  1.1.1.1  fvdl int	procfs_bmap __P((struct vop_bmap_args *));
    184  1.1.1.1  fvdl #define	procfs_strategy ((int (*) __P((struct vop_strategy_args *))) procfs_badop)
    185  1.1.1.1  fvdl int	procfs_print __P((struct vop_print_args *));
    186  1.1.1.2  fvdl #define procfs_islocked \
    187  1.1.1.2  fvdl 	((int (*) __P((struct vop_islocked_args *)))vop_noislocked)
    188  1.1.1.1  fvdl #define procfs_advlock ((int (*) __P((struct vop_advlock_args *))) procfs_badop)
    189  1.1.1.1  fvdl #define procfs_blkatoff ((int (*) __P((struct vop_blkatoff_args *))) procfs_badop)
    190  1.1.1.1  fvdl #define procfs_valloc ((int (*) __P((struct vop_valloc_args *))) procfs_badop)
    191  1.1.1.1  fvdl #define procfs_vfree ((int (*) __P((struct vop_vfree_args *))) nullop)
    192  1.1.1.1  fvdl #define procfs_truncate ((int (*) __P((struct vop_truncate_args *))) procfs_badop)
    193  1.1.1.1  fvdl #define procfs_update ((int (*) __P((struct vop_update_args *))) nullop)
    194      1.1   cgd #endif /* KERNEL */
    195