ia64/xen-unstable

view netbsd-2.0-xen-sparse/sys/miscfs/kernfs/kernfs.h @ 6462:af3750d1ec53

Bug fixes from Kevin (x2) and Anthony
Missing prototypes (Kevin)
Bad n_rid_blocks computation (Anthony)
Bad pte when single-entry dtlb lookup is successful (Kevin)
author djm@kirby.fc.hp.com
date Fri Sep 02 11:59:08 2005 -0600 (2005-09-02)
parents a01199a95070
children
line source
1 /* $NetBSD: kernfs.h,v 1.20.2.3 2004/05/23 10:46:05 tron Exp $ */
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 */
37 #define _PATH_KERNFS "/kern" /* Default mountpoint */
39 #ifdef _KERNEL
40 #include <sys/queue.h>
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 KFSsubdir, /* directory */
61 KFSlasttype, /* last used type */
62 KFSmaxtype = (1<<6) - 1 /* last possible type */
63 } kfstype;
65 /*
66 * Control data for the kern file system.
67 */
68 struct kern_target {
69 u_char kt_type;
70 u_char kt_namlen;
71 const char *kt_name;
72 void *kt_data;
73 kfstype kt_tag;
74 u_char kt_vtype;
75 mode_t kt_mode;
76 };
78 struct dyn_kern_target {
79 struct kern_target dkt_kt;
80 SIMPLEQ_ENTRY(dyn_kern_target) dkt_queue;
81 };
83 struct kernfs_subdir {
84 SIMPLEQ_HEAD(,dyn_kern_target) ks_entries;
85 unsigned int ks_nentries;
86 unsigned int ks_dirs;
87 const struct kern_target *ks_parent;
88 };
90 struct kernfs_node {
91 LIST_ENTRY(kernfs_node) kfs_hash; /* hash chain */
92 TAILQ_ENTRY(kernfs_node) kfs_list; /* flat list */
93 struct vnode *kfs_vnode; /* vnode associated with this pfsnode */
94 kfstype kfs_type; /* type of procfs node */
95 mode_t kfs_mode; /* mode bits for stat() */
96 long kfs_fileno; /* unique file id */
97 u_int32_t kfs_value; /* SA id or SP id (KFSint) */
98 const struct kern_target *kfs_kt;
99 void *kfs_v; /* pointer to secasvar/secpolicy/mbuf */
100 long kfs_cookie; /* fileno cookie */
101 };
103 struct kernfs_mount {
104 TAILQ_HEAD(, kernfs_node) nodelist;
105 long fileno_cookie;
106 };
108 #define UIO_MX 32
110 #define KERNFS_FILENO(kt, typ, cookie) \
111 ((kt >= &kern_targets[0] && kt < &kern_targets[static_nkern_targets]) \
112 ? 2 + ((kt) - &kern_targets[0]) \
113 : (((cookie + 1) << 6) | (typ)))
114 #define KERNFS_TYPE_FILENO(typ, cookie) \
115 (((cookie + 1) << 6) | (typ))
117 #define VFSTOKERNFS(mp) ((struct kernfs_mount *)((mp)->mnt_data))
118 #define VTOKERN(vp) ((struct kernfs_node *)(vp)->v_data)
119 #define KERNFSTOV(kfs) ((kfs)->kfs_vnode)
121 extern const struct kern_target kern_targets[];
122 extern int nkern_targets;
123 extern const int static_nkern_targets;
124 extern int (**kernfs_vnodeop_p) __P((void *));
125 extern struct vfsops kernfs_vfsops;
126 extern dev_t rrootdev;
128 struct secasvar;
129 struct secpolicy;
131 int kernfs_root __P((struct mount *, struct vnode **));
133 void kernfs_hashinit __P((void));
134 void kernfs_hashreinit __P((void));
135 void kernfs_hashdone __P((void));
136 int kernfs_freevp __P((struct vnode *));
137 int kernfs_allocvp __P((struct mount *, struct vnode **, kfstype,
138 const struct kern_target *, u_int32_t));
140 void kernfs_revoke_sa __P((struct secasvar *));
141 void kernfs_revoke_sp __P((struct secpolicy *));
143 /*
144 * Data types for the kernfs file operations.
145 */
146 typedef enum {
147 KERNFS_XREAD,
148 KERNFS_XWRITE,
149 KERNFS_FILEOP_CLOSE,
150 KERNFS_FILEOP_GETATTR,
151 KERNFS_FILEOP_IOCTL,
152 KERNFS_FILEOP_MMAP,
153 KERNFS_FILEOP_OPEN,
154 KERNFS_FILEOP_READ,
155 KERNFS_FILEOP_WRITE,
156 } kfsfileop;
158 struct kernfs_fileop {
159 kfstype kf_type;
160 kfsfileop kf_fileop;
161 union {
162 void *_kf_genop;
163 int (*_kf_vop)(void *);
164 int (*_kf_xread)
165 (const struct kernfs_node *, int, char **, size_t,
166 size_t *);
167 int (*_kf_xwrite)
168 (const struct kernfs_node *, char *, size_t);
169 } _kf_opfn;
170 SPLAY_ENTRY(kernfs_fileop) kf_node;
171 };
172 #define kf_genop _kf_opfn
173 #define kf_vop _kf_opfn._kf_vop
174 #define kf_xwrite _kf_opfn._kf_xwrite
175 #define kf_xread _kf_opfn._kf_xread
177 typedef struct kern_target kernfs_parentdir_t;
178 typedef struct dyn_kern_target kernfs_entry_t;
180 /*
181 * Functions for adding kernfs datatypes and nodes.
182 */
183 kfstype kernfs_alloctype(int, const struct kernfs_fileop *);
184 #define KERNFS_ALLOCTYPE(kf) kernfs_alloctype(sizeof((kf)) / \
185 sizeof((kf)[0]), (kf))
186 #define KERNFS_ALLOCENTRY(dkt, m_type, m_flags) \
187 dkt = (struct dyn_kern_target *)malloc( \
188 sizeof(struct dyn_kern_target), (m_type), (m_flags))
189 #define KERNFS_INITENTRY(dkt, type, name, data, tag, vtype, mode) do { \
190 (dkt)->dkt_kt.kt_type = (type); \
191 (dkt)->dkt_kt.kt_namlen = strlen((name)); \
192 (dkt)->dkt_kt.kt_name = (name); \
193 (dkt)->dkt_kt.kt_data = (data); \
194 (dkt)->dkt_kt.kt_tag = (tag); \
195 (dkt)->dkt_kt.kt_vtype = (vtype); \
196 (dkt)->dkt_kt.kt_mode = (mode); \
197 } while (/*CONSTCOND*/0)
198 #define KERNFS_ENTOPARENTDIR(dkt) &(dkt)->dkt_kt
199 int kernfs_addentry __P((kernfs_parentdir_t *, kernfs_entry_t *));
201 #ifdef SYSCTL_SETUP_PROTO
202 SYSCTL_SETUP_PROTO(sysctl_vfs_kernfs_setup);
203 #endif /* SYSCTL_SETUP_PROTO */
205 #endif /* _KERNEL */