Home | History | Annotate | Line # | Download | only in procfs
procfs.h revision 1.29.4.1
      1  1.29.4.1        he /*	$NetBSD: procfs.h,v 1.29.4.1 2001/03/30 21:47:21 he Exp $	*/
      2      1.11       cgd 
      3       1.1       cgd /*
      4       1.1       cgd  * Copyright (c) 1993 Jan-Simon Pendry
      5       1.9   mycroft  * Copyright (c) 1993
      6       1.9   mycroft  *	The Regents of the University of California.  All rights reserved.
      7       1.1       cgd  *
      8       1.1       cgd  * This code is derived from software contributed to Berkeley by
      9       1.1       cgd  * Jan-Simon Pendry.
     10       1.1       cgd  *
     11       1.1       cgd  * Redistribution and use in source and binary forms, with or without
     12       1.1       cgd  * modification, are permitted provided that the following conditions
     13       1.1       cgd  * are met:
     14       1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     15       1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     16       1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     18       1.1       cgd  *    documentation and/or other materials provided with the distribution.
     19       1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     20       1.1       cgd  *    must display the following acknowledgement:
     21       1.1       cgd  *	This product includes software developed by the University of
     22       1.1       cgd  *	California, Berkeley and its contributors.
     23       1.1       cgd  * 4. Neither the name of the University nor the names of its contributors
     24       1.1       cgd  *    may be used to endorse or promote products derived from this software
     25       1.1       cgd  *    without specific prior written permission.
     26       1.1       cgd  *
     27       1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     28       1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     29       1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     30       1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     31       1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     32       1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     33       1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     34       1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     35       1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     36       1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     37       1.1       cgd  * SUCH DAMAGE.
     38       1.1       cgd  *
     39      1.21      fvdl  *	@(#)procfs.h	8.9 (Berkeley) 5/14/95
     40       1.1       cgd  */
     41       1.1       cgd 
     42       1.1       cgd /*
     43       1.1       cgd  * The different types of node in a procfs filesystem
     44       1.1       cgd  */
     45       1.1       cgd typedef enum {
     46       1.1       cgd 	Proot,		/* the filesystem root */
     47       1.9   mycroft 	Pcurproc,	/* symbolic link for curproc */
     48      1.27   thorpej 	Pself,		/* like curproc, but this is the Linux name */
     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.9   mycroft 	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.23   msaitoh 	Pnotepg,	/* process group notifier */
     58      1.24  christos 	Pmap,		/* memory map */
     59  1.29.4.1        he 	Pcmdline,	/* process command line args */
     60  1.29.4.1        he 	Pmeminfo,	/* system memory info (if -o linux) */
     61  1.29.4.1        he 	Pcpuinfo	/* CPU info (if -o linux) */
     62       1.1       cgd } pfstype;
     63       1.1       cgd 
     64       1.1       cgd /*
     65       1.1       cgd  * control data for the proc file system.
     66       1.1       cgd  */
     67       1.1       cgd struct pfsnode {
     68      1.28      fvdl 	LIST_ENTRY(pfsnode) pfs_hash;	/* hash chain */
     69       1.1       cgd 	struct vnode	*pfs_vnode;	/* vnode associated with this pfsnode */
     70       1.1       cgd 	pfstype		pfs_type;	/* type of procfs node */
     71       1.1       cgd 	pid_t		pfs_pid;	/* associated process */
     72      1.18   mycroft 	mode_t		pfs_mode;	/* mode bits for stat() */
     73       1.1       cgd 	u_long		pfs_flags;	/* open flags */
     74       1.1       cgd 	u_long		pfs_fileno;	/* unique file id */
     75       1.1       cgd };
     76       1.1       cgd 
     77       1.9   mycroft #define PROCFS_NOTELEN	64	/* max length of a note (/proc/$pid/note) */
     78       1.1       cgd #define PROCFS_CTLLEN 	8	/* max length of a ctl msg (/proc/$pid/ctl */
     79       1.1       cgd 
     80  1.29.4.1        he struct procfs_args {
     81  1.29.4.1        he 	int version;
     82  1.29.4.1        he 	int flags;
     83  1.29.4.1        he };
     84  1.29.4.1        he 
     85  1.29.4.1        he #define PROCFS_ARGSVERSION	1
     86  1.29.4.1        he 
     87  1.29.4.1        he #define PROCFSMNT_LINUXCOMPAT	0x01
     88  1.29.4.1        he 
     89       1.1       cgd /*
     90       1.1       cgd  * Kernel stuff follows
     91       1.1       cgd  */
     92      1.13    briggs #ifdef _KERNEL
     93       1.9   mycroft #define CNEQ(cnp, s, len) \
     94       1.9   mycroft 	 ((cnp)->cn_namelen == (len) && \
     95      1.22     perry 	  (memcmp((s), (cnp)->cn_nameptr, (len)) == 0))
     96       1.1       cgd 
     97      1.14   mycroft #define UIO_MX 32
     98      1.14   mycroft 
     99       1.1       cgd #define PROCFS_FILENO(pid, type) \
    100       1.9   mycroft 	(((type) < Pproc) ? \
    101       1.9   mycroft 			((type) + 2) : \
    102       1.7        ws 			((((pid)+1) << 4) + ((int) (type))))
    103       1.1       cgd 
    104      1.28      fvdl struct procfsmount {
    105      1.28      fvdl 	void *pmnt_exechook;
    106      1.28      fvdl 	struct mount *pmnt_mp;
    107  1.29.4.1        he 	int pmnt_flags;
    108      1.28      fvdl };
    109      1.28      fvdl 
    110      1.28      fvdl #define VFSTOPROC(mp)	((struct procfsmount *)(mp)->mnt_data)
    111      1.28      fvdl #define PROCTOVFS(pp)	((pp)->pmnt_mp)
    112      1.28      fvdl 
    113       1.1       cgd /*
    114       1.1       cgd  * Convert between pfsnode vnode
    115       1.1       cgd  */
    116       1.1       cgd #define VTOPFS(vp)	((struct pfsnode *)(vp)->v_data)
    117       1.1       cgd #define PFSTOV(pfs)	((pfs)->pfs_vnode)
    118       1.1       cgd 
    119       1.9   mycroft typedef struct vfs_namemap vfs_namemap_t;
    120       1.9   mycroft struct vfs_namemap {
    121       1.1       cgd 	const char *nm_name;
    122       1.1       cgd 	int nm_val;
    123       1.1       cgd };
    124       1.1       cgd 
    125       1.9   mycroft int vfs_getuserstr __P((struct uio *, char *, int *));
    126       1.9   mycroft vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int));
    127       1.1       cgd 
    128       1.1       cgd #define PFIND(pid) ((pid) ? pfind(pid) : &proc0)
    129       1.9   mycroft int procfs_freevp __P((struct vnode *));
    130       1.9   mycroft int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype));
    131       1.9   mycroft struct vnode *procfs_findtextvp __P((struct proc *));
    132      1.24  christos int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *,
    133      1.24  christos     struct uio *));
    134      1.24  christos int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *,
    135      1.24  christos     struct uio *));
    136      1.24  christos int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *,
    137      1.24  christos     struct uio *));
    138      1.24  christos int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *,
    139      1.24  christos     struct uio *));
    140      1.24  christos int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *,
    141      1.24  christos     struct uio *));
    142      1.24  christos int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *,
    143      1.24  christos     struct uio *));
    144      1.24  christos int procfs_domap __P((struct proc *, struct proc *, struct pfsnode *,
    145      1.24  christos     struct uio *));
    146      1.24  christos int procfs_docmdline __P((struct proc *, struct proc *, struct pfsnode *,
    147      1.24  christos     struct uio *));
    148  1.29.4.1        he int procfs_domeminfo __P((struct proc *, struct proc *, struct pfsnode *,
    149  1.29.4.1        he     struct uio *));
    150  1.29.4.1        he int procfs_docpuinfo __P((struct proc *, struct proc *, struct pfsnode *,
    151  1.29.4.1        he     struct uio *));
    152      1.19   thorpej 
    153      1.24  christos int procfs_checkioperm __P((struct proc *, struct proc *));
    154      1.28      fvdl void procfs_revoke_vnodes __P((struct proc *, void *));
    155      1.28      fvdl void procfs_hashinit __P((void));
    156      1.29  jdolecek void procfs_hashdone __P((void));
    157       1.8       cgd 
    158       1.8       cgd /* functions to check whether or not files should be displayed */
    159  1.29.4.1        he int procfs_validfile __P((struct proc *, struct mount *));
    160  1.29.4.1        he int procfs_validfpregs __P((struct proc *, struct mount *));
    161  1.29.4.1        he int procfs_validregs __P((struct proc *, struct mount *));
    162  1.29.4.1        he int procfs_validmap __P((struct proc *, struct mount *));
    163      1.17  christos 
    164      1.17  christos int procfs_rw __P((void *));
    165  1.29.4.1        he 
    166  1.29.4.1        he int procfs_getcpuinfstr __P((char *, int *));
    167       1.1       cgd 
    168       1.1       cgd #define PROCFS_LOCKED	0x01
    169       1.1       cgd #define PROCFS_WANT	0x02
    170       1.1       cgd 
    171      1.16  christos extern int (**procfs_vnodeop_p) __P((void *));
    172       1.1       cgd extern struct vfsops procfs_vfsops;
    173       1.1       cgd 
    174      1.16  christos int	procfs_root __P((struct mount *, struct vnode **));
    175      1.16  christos 
    176      1.13    briggs #endif /* _KERNEL */
    177