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