Home | History | Annotate | Line # | Download | only in procfs
procfs.h revision 1.47.2.2
      1  1.47.2.2     skrll /*	$NetBSD: procfs.h,v 1.47.2.2 2004/08/03 10:54:06 skrll Exp $	*/
      2      1.11       cgd 
      3       1.1       cgd /*
      4       1.9   mycroft  * Copyright (c) 1993
      5       1.9   mycroft  *	The Regents of the University of California.  All rights reserved.
      6       1.1       cgd  *
      7       1.1       cgd  * This code is derived from software contributed to Berkeley by
      8       1.1       cgd  * Jan-Simon Pendry.
      9       1.1       cgd  *
     10       1.1       cgd  * Redistribution and use in source and binary forms, with or without
     11       1.1       cgd  * modification, are permitted provided that the following conditions
     12       1.1       cgd  * are met:
     13       1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     14       1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     15       1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     17       1.1       cgd  *    documentation and/or other materials provided with the distribution.
     18  1.47.2.2     skrll  * 3. Neither the name of the University nor the names of its contributors
     19  1.47.2.2     skrll  *    may be used to endorse or promote products derived from this software
     20  1.47.2.2     skrll  *    without specific prior written permission.
     21  1.47.2.2     skrll  *
     22  1.47.2.2     skrll  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23  1.47.2.2     skrll  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  1.47.2.2     skrll  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  1.47.2.2     skrll  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26  1.47.2.2     skrll  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  1.47.2.2     skrll  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  1.47.2.2     skrll  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  1.47.2.2     skrll  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  1.47.2.2     skrll  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  1.47.2.2     skrll  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  1.47.2.2     skrll  * SUCH DAMAGE.
     33  1.47.2.2     skrll  *
     34  1.47.2.2     skrll  *	@(#)procfs.h	8.9 (Berkeley) 5/14/95
     35  1.47.2.2     skrll  */
     36  1.47.2.2     skrll 
     37  1.47.2.2     skrll /*
     38  1.47.2.2     skrll  * Copyright (c) 1993 Jan-Simon Pendry
     39  1.47.2.2     skrll  *
     40  1.47.2.2     skrll  * This code is derived from software contributed to Berkeley by
     41  1.47.2.2     skrll  * Jan-Simon Pendry.
     42  1.47.2.2     skrll  *
     43  1.47.2.2     skrll  * Redistribution and use in source and binary forms, with or without
     44  1.47.2.2     skrll  * modification, are permitted provided that the following conditions
     45  1.47.2.2     skrll  * are met:
     46  1.47.2.2     skrll  * 1. Redistributions of source code must retain the above copyright
     47  1.47.2.2     skrll  *    notice, this list of conditions and the following disclaimer.
     48  1.47.2.2     skrll  * 2. Redistributions in binary form must reproduce the above copyright
     49  1.47.2.2     skrll  *    notice, this list of conditions and the following disclaimer in the
     50  1.47.2.2     skrll  *    documentation and/or other materials provided with the distribution.
     51       1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     52       1.1       cgd  *    must display the following acknowledgement:
     53       1.1       cgd  *	This product includes software developed by the University of
     54       1.1       cgd  *	California, Berkeley and its contributors.
     55       1.1       cgd  * 4. Neither the name of the University nor the names of its contributors
     56       1.1       cgd  *    may be used to endorse or promote products derived from this software
     57       1.1       cgd  *    without specific prior written permission.
     58       1.1       cgd  *
     59       1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     60       1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     61       1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     62       1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     63       1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     64       1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     65       1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     66       1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     67       1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     68       1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     69       1.1       cgd  * SUCH DAMAGE.
     70       1.1       cgd  *
     71      1.21      fvdl  *	@(#)procfs.h	8.9 (Berkeley) 5/14/95
     72       1.1       cgd  */
     73       1.1       cgd 
     74      1.36   thorpej /* This also pulls in __HAVE_PROCFS_MACHDEP */
     75      1.36   thorpej #include <sys/ptrace.h>
     76      1.36   thorpej 
     77  1.47.2.2     skrll #ifdef _KERNEL
     78       1.1       cgd /*
     79       1.1       cgd  * The different types of node in a procfs filesystem
     80       1.1       cgd  */
     81       1.1       cgd typedef enum {
     82  1.47.2.2     skrll 	PFSroot,	/* the filesystem root */
     83  1.47.2.2     skrll 	PFScurproc,	/* symbolic link for curproc */
     84  1.47.2.2     skrll 	PFSself,	/* like curproc, but this is the Linux name */
     85  1.47.2.2     skrll 	PFSproc,	/* a process-specific sub-directory */
     86  1.47.2.2     skrll 	PFSfile,	/* the executable file */
     87  1.47.2.2     skrll 	PFSmem,		/* the process's memory image */
     88  1.47.2.2     skrll 	PFSregs,	/* the process's register set */
     89  1.47.2.2     skrll 	PFSfpregs,	/* the process's FP register set */
     90  1.47.2.2     skrll 	PFSctl,		/* process control */
     91  1.47.2.2     skrll 	PFSstat,	/* process status (if -o linux) */
     92  1.47.2.2     skrll 	PFSstatus,	/* process status */
     93  1.47.2.2     skrll 	PFSnote,	/* process notifier */
     94  1.47.2.2     skrll 	PFSnotepg,	/* process group notifier */
     95  1.47.2.2     skrll 	PFSmap,		/* memory map */
     96  1.47.2.2     skrll 	PFScmdline,	/* process command line args */
     97  1.47.2.2     skrll 	PFSmeminfo,	/* system memory info (if -o linux) */
     98  1.47.2.2     skrll 	PFScpuinfo,	/* CPU info (if -o linux) */
     99  1.47.2.2     skrll 	PFSmaps,	/* memory map, Linux style (if -o linux) */
    100  1.47.2.2     skrll 	PFSfd,		/* a directory containing the processes open fd's */
    101  1.47.2.2     skrll 	PFSuptime,	/* elapsed time since (if -o linux) */
    102      1.36   thorpej #ifdef __HAVE_PROCFS_MACHDEP
    103      1.36   thorpej 	PROCFS_MACHDEP_NODE_TYPES
    104      1.36   thorpej #endif
    105       1.1       cgd } pfstype;
    106       1.1       cgd 
    107       1.1       cgd /*
    108       1.1       cgd  * control data for the proc file system.
    109       1.1       cgd  */
    110       1.1       cgd struct pfsnode {
    111      1.28      fvdl 	LIST_ENTRY(pfsnode) pfs_hash;	/* hash chain */
    112       1.1       cgd 	struct vnode	*pfs_vnode;	/* vnode associated with this pfsnode */
    113       1.1       cgd 	pfstype		pfs_type;	/* type of procfs node */
    114       1.1       cgd 	pid_t		pfs_pid;	/* associated process */
    115      1.39  christos 	int		pfs_fd;		/* associated fd if not -1 */
    116      1.18   mycroft 	mode_t		pfs_mode;	/* mode bits for stat() */
    117       1.1       cgd 	u_long		pfs_flags;	/* open flags */
    118       1.1       cgd 	u_long		pfs_fileno;	/* unique file id */
    119       1.1       cgd };
    120       1.1       cgd 
    121       1.9   mycroft #define PROCFS_NOTELEN	64	/* max length of a note (/proc/$pid/note) */
    122       1.1       cgd #define PROCFS_CTLLEN 	8	/* max length of a ctl msg (/proc/$pid/ctl */
    123       1.1       cgd 
    124  1.47.2.2     skrll #endif /* _KERNEL */
    125  1.47.2.2     skrll 
    126      1.31      fvdl struct procfs_args {
    127      1.31      fvdl 	int version;
    128      1.31      fvdl 	int flags;
    129      1.31      fvdl };
    130      1.31      fvdl 
    131      1.31      fvdl #define PROCFS_ARGSVERSION	1
    132      1.31      fvdl 
    133      1.31      fvdl #define PROCFSMNT_LINUXCOMPAT	0x01
    134      1.38  christos 
    135      1.38  christos #define PROCFSMNT_BITS "\177\20" \
    136  1.47.2.2     skrll     "b\00linuxcompat\0"
    137      1.31      fvdl 
    138       1.1       cgd /*
    139       1.1       cgd  * Kernel stuff follows
    140       1.1       cgd  */
    141      1.13    briggs #ifdef _KERNEL
    142       1.9   mycroft #define CNEQ(cnp, s, len) \
    143       1.9   mycroft 	 ((cnp)->cn_namelen == (len) && \
    144      1.22     perry 	  (memcmp((s), (cnp)->cn_nameptr, (len)) == 0))
    145       1.1       cgd 
    146      1.14   mycroft #define UIO_MX 32
    147      1.14   mycroft 
    148      1.39  christos #define PROCFS_FILENO(pid, type, fd) \
    149  1.47.2.2     skrll     (((type) < PFSproc) ? ((type) + 2) : \
    150      1.43  jdolecek 	(((fd) == -1) ? ((((pid)+1) << 5) + ((int) (type))) : \
    151      1.43  jdolecek 	((((pid)+1) << 16) | ((fd) << 5) | ((int) (type)))))
    152       1.1       cgd 
    153      1.28      fvdl struct procfsmount {
    154      1.28      fvdl 	void *pmnt_exechook;
    155      1.31      fvdl 	int pmnt_flags;
    156      1.28      fvdl };
    157      1.28      fvdl 
    158      1.28      fvdl #define VFSTOPROC(mp)	((struct procfsmount *)(mp)->mnt_data)
    159      1.28      fvdl 
    160       1.1       cgd /*
    161       1.1       cgd  * Convert between pfsnode vnode
    162       1.1       cgd  */
    163       1.1       cgd #define VTOPFS(vp)	((struct pfsnode *)(vp)->v_data)
    164       1.1       cgd #define PFSTOV(pfs)	((pfs)->pfs_vnode)
    165       1.1       cgd 
    166       1.9   mycroft typedef struct vfs_namemap vfs_namemap_t;
    167       1.9   mycroft struct vfs_namemap {
    168       1.1       cgd 	const char *nm_name;
    169       1.1       cgd 	int nm_val;
    170       1.1       cgd };
    171       1.1       cgd 
    172       1.9   mycroft int vfs_getuserstr __P((struct uio *, char *, int *));
    173      1.32  jdolecek const vfs_namemap_t *vfs_findname __P((const vfs_namemap_t *, const char *, int));
    174       1.1       cgd 
    175       1.1       cgd #define PFIND(pid) ((pid) ? pfind(pid) : &proc0)
    176       1.9   mycroft int procfs_freevp __P((struct vnode *));
    177      1.39  christos int procfs_allocvp __P((struct mount *, struct vnode **, pid_t, pfstype, int));
    178  1.47.2.1   darrenr int procfs_donote __P((struct lwp *, struct proc *, struct pfsnode *,
    179      1.24  christos     struct uio *));
    180  1.47.2.1   darrenr int procfs_doregs __P((struct lwp *, struct lwp *, struct pfsnode *,
    181      1.24  christos     struct uio *));
    182  1.47.2.1   darrenr int procfs_dofpregs __P((struct lwp *, struct lwp *, struct pfsnode *,
    183      1.24  christos     struct uio *));
    184  1.47.2.1   darrenr int procfs_domem __P((struct lwp *, struct lwp *, struct pfsnode *,
    185      1.24  christos     struct uio *));
    186  1.47.2.1   darrenr int procfs_doctl __P((struct lwp *, struct lwp *, struct pfsnode *,
    187      1.44  christos     struct uio *));
    188  1.47.2.1   darrenr int procfs_do_pid_stat __P((struct lwp *, struct lwp *, struct pfsnode *,
    189      1.24  christos     struct uio *));
    190  1.47.2.1   darrenr int procfs_dostatus __P((struct lwp *, struct lwp *, struct pfsnode *,
    191      1.24  christos     struct uio *));
    192  1.47.2.1   darrenr int procfs_domap __P((struct lwp *, struct proc *, struct pfsnode *,
    193      1.34      fvdl     struct uio *, int));
    194  1.47.2.1   darrenr int procfs_docmdline __P((struct lwp *, struct proc *, struct pfsnode *,
    195      1.24  christos     struct uio *));
    196  1.47.2.1   darrenr int procfs_domeminfo __P((struct lwp *, struct proc *, struct pfsnode *,
    197      1.31      fvdl     struct uio *));
    198  1.47.2.1   darrenr int procfs_docpuinfo __P((struct lwp *, struct proc *, struct pfsnode *,
    199      1.31      fvdl     struct uio *));
    200  1.47.2.1   darrenr int procfs_dofd __P((struct lwp *, struct proc *, struct pfsnode *,
    201      1.41       jrf     struct uio *));
    202  1.47.2.1   darrenr int procfs_douptime __P((struct lwp *, struct proc *, struct pfsnode *,
    203      1.39  christos     struct uio *));
    204      1.19   thorpej 
    205  1.47.2.1   darrenr void procfs_revoke_vnodes __P((struct lwp *, void *));
    206      1.28      fvdl void procfs_hashinit __P((void));
    207      1.35       chs void procfs_hashreinit __P((void));
    208      1.29  jdolecek void procfs_hashdone __P((void));
    209      1.42  jdolecek int procfs_getfp __P((struct pfsnode *, struct proc **, struct file **));
    210       1.8       cgd 
    211       1.8       cgd /* functions to check whether or not files should be displayed */
    212  1.47.2.1   darrenr int procfs_validfile __P((struct lwp *, struct mount *));
    213  1.47.2.1   darrenr int procfs_validfpregs __P((struct lwp *, struct mount *));
    214  1.47.2.1   darrenr int procfs_validregs __P((struct lwp *, struct mount *));
    215  1.47.2.1   darrenr int procfs_validmap __P((struct lwp *, struct mount *));
    216      1.17  christos 
    217      1.17  christos int procfs_rw __P((void *));
    218      1.31      fvdl 
    219      1.31      fvdl int procfs_getcpuinfstr __P((char *, int *));
    220       1.1       cgd 
    221       1.1       cgd #define PROCFS_LOCKED	0x01
    222       1.1       cgd #define PROCFS_WANT	0x02
    223       1.1       cgd 
    224      1.16  christos extern int (**procfs_vnodeop_p) __P((void *));
    225       1.1       cgd extern struct vfsops procfs_vfsops;
    226       1.1       cgd 
    227  1.47.2.1   darrenr int	procfs_root __P((struct mount *, struct vnode **, struct lwp *));
    228      1.36   thorpej 
    229      1.36   thorpej #ifdef __HAVE_PROCFS_MACHDEP
    230      1.36   thorpej struct vattr;
    231      1.36   thorpej 
    232      1.36   thorpej void	procfs_machdep_allocvp(struct vnode *);
    233  1.47.2.1   darrenr int	procfs_machdep_rw(struct lwp *, struct lwp *, struct pfsnode *,
    234      1.36   thorpej 	    struct uio *);
    235      1.36   thorpej int	procfs_machdep_getattr(struct vnode *, struct vattr *, struct proc *);
    236      1.36   thorpej #endif
    237      1.16  christos 
    238  1.47.2.2     skrll #ifdef SYSCTL_SETUP_PROTO
    239  1.47.2.2     skrll SYSCTL_SETUP_PROTO(sysctl_vfs_procfs_setup);
    240  1.47.2.2     skrll #endif /* SYSCTL_SETUP_PROTO */
    241      1.13    briggs #endif /* _KERNEL */
    242