Home | History | Annotate | Line # | Download | only in kernfs
kernfs.h revision 1.20.2.1
      1  1.20.2.1       jdc /*	$NetBSD: kernfs.h,v 1.20.2.1 2004/05/14 06:32:21 jdc Exp $	*/
      2       1.8       cgd 
      3       1.1       cgd /*
      4       1.6   mycroft  * Copyright (c) 1992, 1993
      5       1.6   mycroft  *	The Regents of the University of California.  All rights reserved.
      6       1.1       cgd  *
      7       1.5       cgd  * This code is derived from software donated to Berkeley by
      8       1.1       cgd  * Jan-Simon Pendry.
      9       1.1       cgd  *
     10       1.2       cgd  * Redistribution and use in source and binary forms, with or without
     11       1.2       cgd  * modification, are permitted provided that the following conditions
     12       1.2       cgd  * are met:
     13       1.2       cgd  * 1. Redistributions of source code must retain the above copyright
     14       1.2       cgd  *    notice, this list of conditions and the following disclaimer.
     15       1.2       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.2       cgd  *    notice, this list of conditions and the following disclaimer in the
     17       1.2       cgd  *    documentation and/or other materials provided with the distribution.
     18      1.17       agc  * 3. Neither the name of the University nor the names of its contributors
     19       1.2       cgd  *    may be used to endorse or promote products derived from this software
     20       1.2       cgd  *    without specific prior written permission.
     21       1.1       cgd  *
     22       1.2       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23       1.2       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24       1.2       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25       1.2       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26       1.2       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27       1.2       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28       1.2       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29       1.2       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30       1.2       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31       1.2       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32       1.2       cgd  * SUCH DAMAGE.
     33       1.1       cgd  *
     34      1.12      fvdl  *	@(#)kernfs.h	8.6 (Berkeley) 3/29/95
     35       1.1       cgd  */
     36       1.1       cgd 
     37       1.6   mycroft #define	_PATH_KERNFS	"/kern"		/* Default mountpoint */
     38       1.6   mycroft 
     39       1.9    briggs #ifdef _KERNEL
     40      1.18    itojun #include <sys/queue.h>
     41      1.18    itojun 
     42      1.18    itojun /*
     43      1.18    itojun  * The different types of node in a kernfs filesystem
     44      1.18    itojun  */
     45      1.18    itojun typedef enum {
     46      1.20     darcy 	KFSkern,		/* the filesystem itself (.) */
     47      1.20     darcy 	KFSroot,		/* the filesystem root (..) */
     48      1.20     darcy 	KFSnull,		/* none aplicable */
     49      1.20     darcy 	KFStime,		/* boottime */
     50      1.20     darcy 	KFSint,			/* integer */
     51      1.20     darcy 	KFSstring,		/* string */
     52      1.20     darcy 	KFShostname,	/* hostname */
     53      1.20     darcy 	KFSavenrun,		/* loadavg */
     54      1.20     darcy 	KFSdevice,		/* device file (rootdev/rrootdev) */
     55      1.20     darcy 	KFSmsgbuf,		/* msgbuf */
     56      1.20     darcy 	KFSipsecsadir,	/* ipsec security association (top dir) */
     57      1.20     darcy 	KFSipsecspdir,	/* ipsec security policy (top dir) */
     58      1.20     darcy 	KFSipsecsa,		/* ipsec security association entry */
     59      1.20     darcy 	KFSipsecsp,		/* ipsec security policy entry */
     60      1.18    itojun } kfstype;
     61      1.11        pk 
     62      1.18    itojun /*
     63      1.18    itojun  * control data for the kern file system.
     64      1.18    itojun  */
     65      1.11        pk struct kern_target {
     66      1.18    itojun 	u_char		kt_type;
     67      1.18    itojun 	u_char		kt_namlen;
     68      1.18    itojun 	const char	*kt_name;
     69      1.18    itojun 	void		*kt_data;
     70      1.18    itojun 	kfstype		kt_tag;
     71      1.18    itojun 	u_char		kt_vtype;
     72      1.18    itojun 	mode_t		kt_mode;
     73       1.1       cgd };
     74       1.1       cgd 
     75       1.1       cgd struct kernfs_node {
     76      1.18    itojun 	LIST_ENTRY(kernfs_node) kfs_hash; /* hash chain */
     77      1.18    itojun 	TAILQ_ENTRY(kernfs_node) kfs_list; /* flat list */
     78      1.18    itojun 	struct vnode	*kfs_vnode;	/* vnode associated with this pfsnode */
     79      1.18    itojun 	kfstype		kfs_type;	/* type of procfs node */
     80      1.18    itojun 	mode_t		kfs_mode;	/* mode bits for stat() */
     81      1.18    itojun 	long		kfs_fileno;	/* unique file id */
     82      1.20     darcy 	u_int32_t	kfs_value;	/* SA id or SP id (KFSint) */
     83      1.18    itojun 	const struct kern_target *kfs_kt;
     84      1.18    itojun 	void		*kfs_v;		/* pointer to secasvar/secpolicy/mbuf */
     85      1.18    itojun 	long		kfs_cookie;	/* fileno cookie */
     86      1.18    itojun };
     87      1.18    itojun 
     88      1.18    itojun struct kernfs_mount {
     89      1.18    itojun 	TAILQ_HEAD(, kernfs_node) nodelist;
     90      1.18    itojun 	long fileno_cookie;
     91       1.1       cgd };
     92       1.1       cgd 
     93      1.18    itojun #define UIO_MX	32
     94      1.18    itojun 
     95      1.18    itojun #define KERNFS_FILENO(kt, typ, cookie) \
     96  1.20.2.1       jdc 	((kt >= &kern_targets[0] && kt < &kern_targets[nkern_targets]) ? \
     97  1.20.2.1       jdc 	    2 + ((kt) - &kern_targets[0]) \
     98  1.20.2.1       jdc 	      : (((cookie + 1) << 6) | (typ)))
     99      1.18    itojun 
    100       1.1       cgd #define VFSTOKERNFS(mp)	((struct kernfs_mount *)((mp)->mnt_data))
    101      1.18    itojun #define	VTOKERN(vp)	((struct kernfs_node *)(vp)->v_data)
    102      1.18    itojun #define KERNFSTOV(kfs)	((kfs)->kfs_vnode)
    103       1.1       cgd 
    104      1.18    itojun extern const struct kern_target kern_targets[];
    105      1.18    itojun extern int nkern_targets;
    106      1.10  christos extern int (**kernfs_vnodeop_p) __P((void *));
    107       1.1       cgd extern struct vfsops kernfs_vfsops;
    108       1.6   mycroft extern dev_t rrootdev;
    109      1.18    itojun 
    110      1.18    itojun struct secasvar;
    111      1.18    itojun struct secpolicy;
    112      1.18    itojun 
    113      1.18    itojun int kernfs_root __P((struct mount *, struct vnode **));
    114      1.18    itojun 
    115      1.18    itojun void kernfs_hashinit __P((void));
    116      1.18    itojun void kernfs_hashreinit __P((void));
    117      1.18    itojun void kernfs_hashdone __P((void));
    118      1.18    itojun int kernfs_freevp __P((struct vnode *));
    119      1.18    itojun int kernfs_allocvp __P((struct mount *, struct vnode **, kfstype,
    120      1.18    itojun 	const struct kern_target *, u_int32_t));
    121      1.18    itojun 
    122      1.18    itojun void kernfs_revoke_sa __P((struct secasvar *));
    123      1.18    itojun void kernfs_revoke_sp __P((struct secpolicy *));
    124       1.9    briggs #endif /* _KERNEL */
    125