Annotation of src/sys/fs/puffs/puffs_sys.h, Revision 1.51
1.51 ! pooka 1: /* $NetBSD: puffs_sys.h,v 1.50 2007/09/27 14:35:15 pooka Exp $ */
1.1 pooka 2:
3: /*
4: * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
5: *
6: * Development of this software was supported by the
7: * Google Summer of Code program and the Ulla Tuominen Foundation.
8: * The Google SoC project was mentored by Bill Studenmund.
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: *
19: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
20: * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29: * SUCH DAMAGE.
30: */
31:
32: #ifndef _PUFFS_SYS_H_
33: #define _PUFFS_SYS_H_
34:
35: #include <sys/param.h>
36: #include <sys/select.h>
37: #include <sys/kauth.h>
1.28 pooka 38: #include <sys/mutex.h>
1.1 pooka 39: #include <sys/queue.h>
1.4 pooka 40: #include <sys/pool.h>
1.1 pooka 41:
42: #include <fs/puffs/puffs_msgif.h>
43:
1.6 pooka 44: #include <miscfs/genfs/genfs_node.h>
45:
1.2 pooka 46: extern int (**puffs_vnodeop_p)(void *);
47: extern int (**puffs_specop_p)(void *);
1.3 pooka 48: extern int (**puffs_fifoop_p)(void *);
1.2 pooka 49:
50: extern const struct vnodeopv_desc puffs_vnodeop_opv_desc;
51: extern const struct vnodeopv_desc puffs_specop_opv_desc;
1.3 pooka 52: extern const struct vnodeopv_desc puffs_fifoop_opv_desc;
1.10 pooka 53: extern const struct vnodeopv_desc puffs_msgop_opv_desc;
1.2 pooka 54:
1.4 pooka 55: extern struct pool puffs_pnpool;
56:
1.1 pooka 57: #define PUFFS_SIZEOPREQ_UIO_IN 1
58: #define PUFFS_SIZEOPREQ_UIO_OUT 2
59: #define PUFFS_SIZEOPREQ_BUF_IN 3
60: #define PUFFS_SIZEOPREQ_BUF_OUT 4
61:
62: #define PUFFS_SIZEOP_UIO(a) \
63: (((a)==PUFFS_SIZEOPREQ_UIO_IN)||(a)==PUFFS_SIZEOPREQ_UIO_OUT)
64: #define PUFFS_SIZEOP_BUF(a) \
65: (((a)==PUFFS_SIZEOPREQ_BUF_IN)||(a)==PUFFS_SIZEOPREQ_BUF_OUT)
66:
67: /* XXX: alignment-optimization */
68: struct puffs_sizepark {
69: uint64_t pkso_reqid;
70: uint8_t pkso_reqtype;
71:
72: struct uio *pkso_uio;
73: void *pkso_copybuf;
74: size_t pkso_bufsize;
75:
76: TAILQ_ENTRY(puffs_sizepark) pkso_entries;
77: };
78:
1.12 pooka 79: #ifdef DEBUG
1.24 pooka 80: #ifndef PUFFSDEBUG
81: #define PUFFSDEBUG
82: #endif
83: #endif
84:
85: #ifdef PUFFSDEBUG
1.12 pooka 86: extern int puffsdebug; /* puffs_subr.c */
87: #define DPRINTF(x) if (puffsdebug > 0) printf x
88: #define DPRINTF_VERBOSE(x) if (puffsdebug > 1) printf x
89: #else
1.1 pooka 90: #define DPRINTF(x)
1.10 pooka 91: #define DPRINTF_VERBOSE(x)
1.12 pooka 92: #endif
1.1 pooka 93:
94: #define MPTOPUFFSMP(mp) ((struct puffs_mount *)((mp)->mnt_data))
95: #define PMPTOMP(pmp) (pmp->pmp_mp)
96: #define VPTOPP(vp) ((struct puffs_node *)(vp)->v_data)
97: #define VPTOPNC(vp) (((struct puffs_node *)(vp)->v_data)->pn_cookie)
98: #define VPTOPUFFSMP(vp) ((struct puffs_mount*)((struct puffs_node*)vp->v_data))
99: #define FPTOPMP(fp) (((struct puffs_instance *)fp->f_data)->pi_pmp)
100: #define FPTOPI(fp) ((struct puffs_instance *)fp->f_data)
101:
1.32 pooka 102: /* we don't pass the kernel overlay to userspace */
103: #define PUFFS_TOFHSIZE(s) ((s)==0 ? (s) : (s)+4)
104: #define PUFFS_FROMFHSIZE(s) ((s)==0 ? (s) : (s)-4)
105:
1.34 pooka 106: #define ALLOPS(pmp) (pmp->pmp_flags & PUFFS_KFLAG_ALLOPS)
1.10 pooka 107: #define EXISTSOP(pmp, op) \
1.34 pooka 108: (ALLOPS(pmp) || ((pmp)->pmp_vnopmask[PUFFS_VN_##op]))
1.10 pooka 109:
1.42 pooka 110: #define PUFFS_USE_NAMECACHE(pmp) \
111: (((pmp)->pmp_flags & PUFFS_KFLAG_NOCACHE_NAME) == 0)
112: #define PUFFS_USE_PAGECACHE(pmp) \
113: (((pmp)->pmp_flags & PUFFS_KFLAG_NOCACHE_PAGE) == 0)
1.45 pooka 114: #define PUFFS_USE_FULLPNBUF(pmp) \
115: ((pmp)->pmp_flags & PUFFS_KFLAG_LOOKUP_FULLPNBUF)
1.16 pooka 116:
1.27 pooka 117: #define PUFFS_WCACHEINFO(pmp) 0
118:
1.50 pooka 119: struct puffs_newcookie {
120: void *pnc_cookie;
121:
122: LIST_ENTRY(puffs_newcookie) pnc_entries;
123: };
124:
1.1 pooka 125: TAILQ_HEAD(puffs_wq, puffs_park);
1.20 pooka 126: LIST_HEAD(puffs_node_hashlist, puffs_node);
1.1 pooka 127: struct puffs_mount {
1.28 pooka 128: kmutex_t pmp_lock;
1.1 pooka 129:
1.31 pooka 130: struct puffs_kargs pmp_args;
1.10 pooka 131: #define pmp_flags pmp_args.pa_flags
132: #define pmp_vnopmask pmp_args.pa_vnopmask
1.1 pooka 133:
134: struct puffs_wq pmp_req_touser;
1.33 pooka 135: int pmp_req_touser_count;
1.28 pooka 136: kcondvar_t pmp_req_waiter_cv;
1.1 pooka 137: size_t pmp_req_maxsize;
138:
139: struct puffs_wq pmp_req_replywait;
140: TAILQ_HEAD(, puffs_sizepark) pmp_req_sizepark;
141:
1.20 pooka 142: struct puffs_node_hashlist *pmp_pnodehash;
1.32 pooka 143: int pmp_npnodehash;
1.1 pooka 144:
1.50 pooka 145: LIST_HEAD(, puffs_newcookie) pmp_newcookie;
146:
1.1 pooka 147: struct mount *pmp_mp;
1.35 pooka 148:
1.1 pooka 149: struct vnode *pmp_root;
1.35 pooka 150: void *pmp_root_cookie;
151: enum vtype pmp_root_vtype;
152: vsize_t pmp_root_vsize;
153: dev_t pmp_root_rdev;
154:
1.1 pooka 155: struct selinfo *pmp_sel; /* in puffs_instance */
156:
1.33 pooka 157: unsigned int pmp_refcount;
158: kcondvar_t pmp_refcount_cv;
1.28 pooka 159:
1.33 pooka 160: kcondvar_t pmp_unmounting_cv;
1.14 pooka 161: uint8_t pmp_unmounting;
1.33 pooka 162:
163: uint8_t pmp_status;
1.22 pooka 164: uint8_t pmp_suspend;
1.28 pooka 165:
166: uint64_t pmp_nextreq;
1.1 pooka 167: };
1.8 pooka 168:
1.1 pooka 169: #define PUFFSTAT_BEFOREINIT 0
170: #define PUFFSTAT_MOUNTING 1
171: #define PUFFSTAT_RUNNING 2
1.14 pooka 172: #define PUFFSTAT_DYING 3 /* Do you want your possessions identified? */
1.1 pooka 173:
1.27 pooka 174:
1.37 pooka 175: #define PNODE_NOREFS 0x01 /* no backend reference */
1.38 pooka 176: #define PNODE_DYING 0x02 /* NOREF + inactive */
177: #define PNODE_SUSPEND 0x04 /* issue all operations as FAF */
178: #define PNODE_DOINACT 0x08 /* if inactive-on-demand, call inactive */
1.27 pooka 179:
180: #define PNODE_METACACHE_ATIME 0x10 /* cache atime metadata */
181: #define PNODE_METACACHE_CTIME 0x20 /* cache atime metadata */
182: #define PNODE_METACACHE_MTIME 0x40 /* cache atime metadata */
183: #define PNODE_METACACHE_SIZE 0x80 /* cache atime metadata */
184: #define PNODE_METACACHE_MASK 0xf0
185:
1.1 pooka 186: struct puffs_node {
1.6 pooka 187: struct genfs_node pn_gnode; /* genfs glue */
188:
1.36 pooka 189: kmutex_t pn_mtx;
190: int pn_refcount;
191:
1.1 pooka 192: void *pn_cookie; /* userspace pnode cookie */
193: struct vnode *pn_vp; /* backpointer to vnode */
194: uint32_t pn_stat; /* node status */
195:
1.36 pooka 196: struct selinfo pn_sel; /* for selecting on the node */
197: short pn_revents; /* available events */
198:
1.27 pooka 199: /* metacache */
200: struct timespec pn_mc_atime;
201: struct timespec pn_mc_ctime;
202: struct timespec pn_mc_mtime;
203: u_quad_t pn_mc_size;
204:
1.47 pooka 205: voff_t pn_serversize;
206:
1.20 pooka 207: LIST_ENTRY(puffs_node) pn_hashent;
1.1 pooka 208: };
209:
1.29 pooka 210: typedef void (*parkdone_fn)(struct puffs_req *, void *);
211:
1.28 pooka 212: void puffs_transport_init(void);
213: void puffs_transport_destroy(void);
214:
215: void puffs_msgif_init(void);
216: void puffs_msgif_destroy(void);
1.30 pooka 217: void *puffs_park_alloc(int);
218: void puffs_park_release(void *, int);
1.28 pooka 219:
1.1 pooka 220: int puffs_vfstouser(struct puffs_mount *, int, void *, size_t);
1.22 pooka 221: void puffs_suspendtouser(struct puffs_mount *, int);
1.29 pooka 222: int puffs_vntouser(struct puffs_mount *, int, void *, size_t, size_t,
1.34 pooka 223: struct vnode *, struct vnode *);
1.29 pooka 224: int puffs_vntouser_req(struct puffs_mount *, int, void *, size_t, size_t,
1.34 pooka 225: uint64_t, struct vnode *, struct vnode *);
1.29 pooka 226: void puffs_vntouser_call(struct puffs_mount *, int, void *, size_t, size_t,
1.34 pooka 227: parkdone_fn, void *, struct vnode *, struct vnode*);
228: void puffs_vntouser_faf(struct puffs_mount *, int, void *, size_t,
229: struct vnode *);
1.27 pooka 230: void puffs_cacheop(struct puffs_mount *, struct puffs_park *,
231: struct puffs_cacheinfo *, size_t, void *);
232: struct puffs_park *puffs_cacheop_alloc(void);
1.51 ! pooka 233: void puffs_errnotify(struct puffs_mount *, uint8_t, int, void *);
1.1 pooka 234:
1.6 pooka 235: int puffs_getvnode(struct mount *, void *, enum vtype, voff_t, dev_t,
1.2 pooka 236: struct vnode **);
1.1 pooka 237: int puffs_newnode(struct mount *, struct vnode *, struct vnode **,
1.2 pooka 238: void *, struct componentname *, enum vtype, dev_t);
1.1 pooka 239: void puffs_putvnode(struct vnode *);
1.36 pooka 240:
241: void puffs_releasenode(struct puffs_node *);
242: void puffs_referencenode(struct puffs_node *);
243:
1.50 pooka 244: int puffs_cookie2vnode(struct puffs_mount *, void *, int, int,
245: struct vnode **);
1.43 pooka 246: void puffs_makecn(struct puffs_kcn *, struct puffs_kcred *,
1.45 pooka 247: struct puffs_kcid *, const struct componentname *, int);
1.43 pooka 248: void puffs_credcvt(struct puffs_kcred *, kauth_cred_t);
1.44 pooka 249: void puffs_cidcvt(struct puffs_kcid *, const struct lwp *);
1.1 pooka 250:
1.29 pooka 251: void puffs_parkdone_asyncbioread(struct puffs_req *, void *);
1.36 pooka 252: void puffs_parkdone_poll(struct puffs_req *, void *);
1.29 pooka 253:
1.33 pooka 254: void puffs_mp_reference(struct puffs_mount *);
255: void puffs_mp_release(struct puffs_mount *);
256:
1.6 pooka 257: void puffs_updatenode(struct vnode *, int);
258: #define PUFFS_UPDATEATIME 0x01
259: #define PUFFS_UPDATECTIME 0x02
260: #define PUFFS_UPDATEMTIME 0x04
261: #define PUFFS_UPDATESIZE 0x08
262:
1.1 pooka 263: int puffs_setpmp(pid_t, int, struct puffs_mount *);
264: void puffs_nukebypmp(struct puffs_mount *);
265:
1.28 pooka 266: uint64_t puffs_getreqid(struct puffs_mount *);
267: void puffs_userdead(struct puffs_mount *);
1.1 pooka 268:
1.13 pooka 269: /* get/put called by ioctl handler */
270: int puffs_getop(struct puffs_mount *, struct puffs_reqh_get *, int);
271: int puffs_putop(struct puffs_mount *, struct puffs_reqh_put *);
272:
1.1 pooka 273: extern int (**puffs_vnodeop_p)(void *);
274:
275: MALLOC_DECLARE(M_PUFFS);
276:
277: #endif /* _PUFFS_SYS_H_ */
CVSweb <webmaster@jp.NetBSD.org>