xref: /minix3/sys/fs/puffs/puffs_sys.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: puffs_sys.h,v 1.89 2015/02/15 20:21:29 manu Exp $	*/
284d9c625SLionel Sambuc 
384d9c625SLionel Sambuc /*
484d9c625SLionel Sambuc  * Copyright (c) 2005, 2006  Antti Kantee.  All Rights Reserved.
584d9c625SLionel Sambuc  *
684d9c625SLionel Sambuc  * Development of this software was supported by the
784d9c625SLionel Sambuc  * Google Summer of Code program and the Ulla Tuominen Foundation.
884d9c625SLionel Sambuc  * The Google SoC project was mentored by Bill Studenmund.
984d9c625SLionel Sambuc  *
1084d9c625SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
1184d9c625SLionel Sambuc  * modification, are permitted provided that the following conditions
1284d9c625SLionel Sambuc  * are met:
1384d9c625SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
1484d9c625SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
1584d9c625SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
1684d9c625SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
1784d9c625SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
1884d9c625SLionel Sambuc  *
1984d9c625SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
2084d9c625SLionel Sambuc  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2184d9c625SLionel Sambuc  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2284d9c625SLionel Sambuc  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2384d9c625SLionel Sambuc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2484d9c625SLionel Sambuc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2584d9c625SLionel Sambuc  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2684d9c625SLionel Sambuc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2784d9c625SLionel Sambuc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2884d9c625SLionel Sambuc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2984d9c625SLionel Sambuc  * SUCH DAMAGE.
3084d9c625SLionel Sambuc  */
3184d9c625SLionel Sambuc 
3284d9c625SLionel Sambuc #ifndef _PUFFS_SYS_H_
3384d9c625SLionel Sambuc #define _PUFFS_SYS_H_
3484d9c625SLionel Sambuc 
3584d9c625SLionel Sambuc #include <sys/param.h>
3684d9c625SLionel Sambuc #include <sys/select.h>
3784d9c625SLionel Sambuc #include <sys/kauth.h>
3884d9c625SLionel Sambuc #include <sys/mutex.h>
3984d9c625SLionel Sambuc #include <sys/queue.h>
4084d9c625SLionel Sambuc #include <sys/pool.h>
4184d9c625SLionel Sambuc 
4284d9c625SLionel Sambuc #include <fs/puffs/puffs_msgif.h>
4384d9c625SLionel Sambuc 
4484d9c625SLionel Sambuc #include <miscfs/genfs/genfs_node.h>
4584d9c625SLionel Sambuc 
4684d9c625SLionel Sambuc extern int (**puffs_vnodeop_p)(void *);
4784d9c625SLionel Sambuc extern int (**puffs_specop_p)(void *);
4884d9c625SLionel Sambuc extern int (**puffs_fifoop_p)(void *);
4984d9c625SLionel Sambuc 
5084d9c625SLionel Sambuc extern const struct vnodeopv_desc puffs_vnodeop_opv_desc;
5184d9c625SLionel Sambuc extern const struct vnodeopv_desc puffs_specop_opv_desc;
5284d9c625SLionel Sambuc extern const struct vnodeopv_desc puffs_fifoop_opv_desc;
5384d9c625SLionel Sambuc extern const struct vnodeopv_desc puffs_msgop_opv_desc;
5484d9c625SLionel Sambuc 
5584d9c625SLionel Sambuc extern struct pool puffs_pnpool;
5684d9c625SLionel Sambuc extern struct pool puffs_vapool;
5784d9c625SLionel Sambuc 
5884d9c625SLionel Sambuc #ifdef DEBUG
5984d9c625SLionel Sambuc #ifndef PUFFSDEBUG
6084d9c625SLionel Sambuc #define PUFFSDEBUG
6184d9c625SLionel Sambuc #endif
6284d9c625SLionel Sambuc #endif
6384d9c625SLionel Sambuc 
6484d9c625SLionel Sambuc #ifdef PUFFSDEBUG
6584d9c625SLionel Sambuc extern int puffsdebug; /* puffs_subr.c */
66*0a6a1f1dSLionel Sambuc #define DPRINTF(x) do { \
67*0a6a1f1dSLionel Sambuc 		if (puffsdebug > 0) printf x; \
68*0a6a1f1dSLionel Sambuc 	} while (/*CONSTCOND*/0)
69*0a6a1f1dSLionel Sambuc #define DPRINTF_VERBOSE(x) do { \
70*0a6a1f1dSLionel Sambuc 		if (puffsdebug > 1) printf x; \
71*0a6a1f1dSLionel Sambuc 	} while (/*CONSTCOND*/0)
7284d9c625SLionel Sambuc #else
73*0a6a1f1dSLionel Sambuc #define DPRINTF(x) ((void)0)
74*0a6a1f1dSLionel Sambuc #define DPRINTF_VERBOSE(x) ((void)0)
7584d9c625SLionel Sambuc #endif
7684d9c625SLionel Sambuc 
7784d9c625SLionel Sambuc #define MPTOPUFFSMP(mp) ((struct puffs_mount *)((mp)->mnt_data))
7884d9c625SLionel Sambuc #define PMPTOMP(pmp) (pmp->pmp_mp)
7984d9c625SLionel Sambuc #define VPTOPP(vp) ((struct puffs_node *)(vp)->v_data)
8084d9c625SLionel Sambuc #define VPTOPNC(vp) (((struct puffs_node *)(vp)->v_data)->pn_cookie)
8184d9c625SLionel Sambuc #define VPTOPUFFSMP(vp) ((struct puffs_mount*)((struct puffs_node*)vp->v_data))
8284d9c625SLionel Sambuc 
8384d9c625SLionel Sambuc /* we don't pass the kernel overlay to userspace */
8484d9c625SLionel Sambuc #define PUFFS_TOFHSIZE(s) ((s)==0 ? (s) : (s)+4)
8584d9c625SLionel Sambuc #define PUFFS_FROMFHSIZE(s) ((s)==0 ? (s) : (s)-4)
8684d9c625SLionel Sambuc 
8784d9c625SLionel Sambuc #define ALLOPS(pmp) (pmp->pmp_flags & PUFFS_KFLAG_ALLOPS)
8884d9c625SLionel Sambuc #define EXISTSOP(pmp, op) \
8984d9c625SLionel Sambuc  (ALLOPS(pmp) || ((pmp)->pmp_vnopmask[PUFFS_VN_##op]))
9084d9c625SLionel Sambuc 
9184d9c625SLionel Sambuc #define PUFFS_USE_NAMECACHE(pmp)	\
9284d9c625SLionel Sambuc     (((pmp)->pmp_flags & PUFFS_KFLAG_NOCACHE_NAME) == 0)
9384d9c625SLionel Sambuc #define PUFFS_USE_PAGECACHE(pmp)	\
9484d9c625SLionel Sambuc     (((pmp)->pmp_flags & PUFFS_KFLAG_NOCACHE_PAGE) == 0)
9584d9c625SLionel Sambuc #define PUFFS_USE_FULLPNBUF(pmp)	\
9684d9c625SLionel Sambuc     ((pmp)->pmp_flags & PUFFS_KFLAG_LOOKUP_FULLPNBUF)
9784d9c625SLionel Sambuc #define PUFFS_USE_FS_TTL(pmp)	\
9884d9c625SLionel Sambuc     ((pmp)->pmp_flags & PUFFS_KFLAG_CACHE_FS_TTL)
9984d9c625SLionel Sambuc #define PUFFS_USE_DOTDOTCACHE(pmp)	\
10084d9c625SLionel Sambuc     ((pmp)->pmp_flags & PUFFS_KFLAG_CACHE_DOTDOT)
101*0a6a1f1dSLionel Sambuc #define PUFFS_USE_METAFLUSH(pmp)	\
102*0a6a1f1dSLionel Sambuc     (((pmp)->pmp_flags & PUFFS_KFLAG_NOFLUSH_META) == 0)
10384d9c625SLionel Sambuc 
10484d9c625SLionel Sambuc #define PUFFS_WCACHEINFO(pmp)	(__USE(pmp), 0)
10584d9c625SLionel Sambuc 
10684d9c625SLionel Sambuc struct puffs_newcookie {
10784d9c625SLionel Sambuc 	puffs_cookie_t	pnc_cookie;
10884d9c625SLionel Sambuc 
10984d9c625SLionel Sambuc 	LIST_ENTRY(puffs_newcookie) pnc_entries;
11084d9c625SLionel Sambuc };
11184d9c625SLionel Sambuc 
11284d9c625SLionel Sambuc #define PUFFS_SOPREQ_EXPIRE_TIMEOUT 1000
11384d9c625SLionel Sambuc extern int puffs_sopreq_expire_timeout;
11484d9c625SLionel Sambuc 
11584d9c625SLionel Sambuc enum puffs_sopreqtype {
11684d9c625SLionel Sambuc 	PUFFS_SOPREQSYS_EXIT,
11784d9c625SLionel Sambuc 	PUFFS_SOPREQ_FLUSH,
11884d9c625SLionel Sambuc 	PUFFS_SOPREQ_UNMOUNT,
11984d9c625SLionel Sambuc 	PUFFS_SOPREQ_EXPIRE,
12084d9c625SLionel Sambuc };
12184d9c625SLionel Sambuc 
12284d9c625SLionel Sambuc struct puffs_sopreq {
12384d9c625SLionel Sambuc 	union {
12484d9c625SLionel Sambuc 		struct puffs_req preq;
12584d9c625SLionel Sambuc 		struct puffs_flush pf;
12684d9c625SLionel Sambuc 		puffs_cookie_t ck;
12784d9c625SLionel Sambuc 	} psopr_u;
12884d9c625SLionel Sambuc 
12984d9c625SLionel Sambuc 	enum puffs_sopreqtype psopr_sopreq;
13084d9c625SLionel Sambuc 	TAILQ_ENTRY(puffs_sopreq) psopr_entries;
13184d9c625SLionel Sambuc 	int psopr_at;
13284d9c625SLionel Sambuc };
13384d9c625SLionel Sambuc #define psopr_preq psopr_u.preq
13484d9c625SLionel Sambuc #define psopr_pf psopr_u.pf
13584d9c625SLionel Sambuc #define psopr_ck psopr_u.ck
13684d9c625SLionel Sambuc 
13784d9c625SLionel Sambuc TAILQ_HEAD(puffs_wq, puffs_msgpark);
13884d9c625SLionel Sambuc LIST_HEAD(puffs_node_hashlist, puffs_node);
13984d9c625SLionel Sambuc struct puffs_mount {
14084d9c625SLionel Sambuc 	kmutex_t	 		pmp_lock;
14184d9c625SLionel Sambuc 
14284d9c625SLionel Sambuc 	struct puffs_kargs		pmp_args;
14384d9c625SLionel Sambuc #define pmp_flags pmp_args.pa_flags
14484d9c625SLionel Sambuc #define pmp_vnopmask pmp_args.pa_vnopmask
14584d9c625SLionel Sambuc 
14684d9c625SLionel Sambuc 	struct puffs_wq			pmp_msg_touser;
14784d9c625SLionel Sambuc 	int				pmp_msg_touser_count;
14884d9c625SLionel Sambuc 	kcondvar_t			pmp_msg_waiter_cv;
14984d9c625SLionel Sambuc 	size_t				pmp_msg_maxsize;
15084d9c625SLionel Sambuc 
15184d9c625SLionel Sambuc 	struct puffs_wq			pmp_msg_replywait;
15284d9c625SLionel Sambuc 
15384d9c625SLionel Sambuc 	struct mount			*pmp_mp;
15484d9c625SLionel Sambuc 
15584d9c625SLionel Sambuc 	struct vnode			*pmp_root;
15684d9c625SLionel Sambuc 	puffs_cookie_t			pmp_root_cookie;
15784d9c625SLionel Sambuc 	enum vtype			pmp_root_vtype;
15884d9c625SLionel Sambuc 	vsize_t				pmp_root_vsize;
15984d9c625SLionel Sambuc 	dev_t				pmp_root_rdev;
16084d9c625SLionel Sambuc 
16184d9c625SLionel Sambuc 	struct putter_instance		*pmp_pi;
16284d9c625SLionel Sambuc 
16384d9c625SLionel Sambuc 	unsigned int			pmp_refcount;
16484d9c625SLionel Sambuc 	kcondvar_t			pmp_refcount_cv;
16584d9c625SLionel Sambuc 
16684d9c625SLionel Sambuc 	kcondvar_t			pmp_unmounting_cv;
16784d9c625SLionel Sambuc 	uint8_t				pmp_unmounting;
16884d9c625SLionel Sambuc 
16984d9c625SLionel Sambuc 	uint8_t				pmp_status;
17084d9c625SLionel Sambuc 	uint8_t				pmp_suspend;
17184d9c625SLionel Sambuc 
17284d9c625SLionel Sambuc 	uint8_t				*pmp_curput;
17384d9c625SLionel Sambuc 	size_t				pmp_curres;
17484d9c625SLionel Sambuc 	void				*pmp_curopaq;
17584d9c625SLionel Sambuc 
17684d9c625SLionel Sambuc 	uint64_t			pmp_nextmsgid;
17784d9c625SLionel Sambuc 
17884d9c625SLionel Sambuc 	kmutex_t			pmp_sopmtx;
17984d9c625SLionel Sambuc 	kcondvar_t			pmp_sopcv;
18084d9c625SLionel Sambuc 	int				pmp_sopthrcount;
18184d9c625SLionel Sambuc 	TAILQ_HEAD(, puffs_sopreq)	pmp_sopfastreqs;
18284d9c625SLionel Sambuc 	TAILQ_HEAD(, puffs_sopreq)	pmp_sopnodereqs;
18384d9c625SLionel Sambuc 	bool				pmp_docompat;
18484d9c625SLionel Sambuc };
18584d9c625SLionel Sambuc 
18684d9c625SLionel Sambuc #define PUFFSTAT_BEFOREINIT	0
18784d9c625SLionel Sambuc #define PUFFSTAT_MOUNTING	1
18884d9c625SLionel Sambuc #define PUFFSTAT_RUNNING	2
18984d9c625SLionel Sambuc #define PUFFSTAT_DYING		3 /* Do you want your possessions identified? */
19084d9c625SLionel Sambuc 
19184d9c625SLionel Sambuc 
19284d9c625SLionel Sambuc #define PNODE_NOREFS	0x001	/* no backend reference			*/
19384d9c625SLionel Sambuc #define PNODE_DYING	0x002	/* NOREFS + inactive			*/
19484d9c625SLionel Sambuc #define PNODE_FAF	0x004	/* issue all operations as FAF		*/
19584d9c625SLionel Sambuc #define PNODE_DOINACT 	0x008	/* if inactive-on-demand, call inactive */
19684d9c625SLionel Sambuc #define PNODE_SOPEXP	0x100	/* Node reclaim postponed in sop thread	*/
197*0a6a1f1dSLionel Sambuc #define PNODE_RDIRECT	0x200	/* bypass page cache on read		*/
198*0a6a1f1dSLionel Sambuc #define PNODE_WDIRECT	0x400	/* bypass page cache on write		*/
19984d9c625SLionel Sambuc 
20084d9c625SLionel Sambuc #define PNODE_METACACHE_ATIME	0x10	/* cache atime metadata */
20184d9c625SLionel Sambuc #define PNODE_METACACHE_CTIME	0x20	/* cache atime metadata */
20284d9c625SLionel Sambuc #define PNODE_METACACHE_MTIME	0x40	/* cache atime metadata */
20384d9c625SLionel Sambuc #define PNODE_METACACHE_SIZE	0x80	/* cache atime metadata */
20484d9c625SLionel Sambuc #define PNODE_METACACHE_MASK	0xf0
20584d9c625SLionel Sambuc 
20684d9c625SLionel Sambuc struct puffs_node {
20784d9c625SLionel Sambuc 	struct genfs_node pn_gnode;	/* genfs glue			*/
20884d9c625SLionel Sambuc 
20984d9c625SLionel Sambuc 	kmutex_t	pn_mtx;
21084d9c625SLionel Sambuc 	int		pn_refcount;
21184d9c625SLionel Sambuc 	int		pn_nlookup;
21284d9c625SLionel Sambuc 
21384d9c625SLionel Sambuc 	puffs_cookie_t	pn_cookie;	/* userspace pnode cookie	*/
21484d9c625SLionel Sambuc 	struct vnode	*pn_vp;		/* backpointer to vnode		*/
21584d9c625SLionel Sambuc 	uint32_t	pn_stat;	/* node status			*/
21684d9c625SLionel Sambuc 
21784d9c625SLionel Sambuc 	struct selinfo	pn_sel;		/* for selecting on the node	*/
21884d9c625SLionel Sambuc 	short		pn_revents;	/* available events		*/
21984d9c625SLionel Sambuc 
22084d9c625SLionel Sambuc 	/* metacache */
22184d9c625SLionel Sambuc 	struct timespec	pn_mc_atime;
22284d9c625SLionel Sambuc 	struct timespec	pn_mc_ctime;
22384d9c625SLionel Sambuc 	struct timespec	pn_mc_mtime;
22484d9c625SLionel Sambuc 	u_quad_t	pn_mc_size;
22584d9c625SLionel Sambuc 
22684d9c625SLionel Sambuc 	voff_t		pn_serversize;
22784d9c625SLionel Sambuc 
22884d9c625SLionel Sambuc 	struct lockf *	pn_lockf;
22984d9c625SLionel Sambuc 
23084d9c625SLionel Sambuc 	kmutex_t	pn_sizemtx;	/* size modification mutex	*/
23184d9c625SLionel Sambuc 
23284d9c625SLionel Sambuc 	int		pn_cn_timeout;	/* path cache */
23384d9c625SLionel Sambuc 	int		pn_cn_grace;	/* grace time before reclaim */
23484d9c625SLionel Sambuc 	int		pn_va_timeout;	/* attribute cache */
23584d9c625SLionel Sambuc 	struct vattr *	pn_va_cache;	/* attribute cache */
23684d9c625SLionel Sambuc 	struct vnode *  pn_parent;	/* parent cache */
23784d9c625SLionel Sambuc };
23884d9c625SLionel Sambuc 
23984d9c625SLionel Sambuc typedef void (*parkdone_fn)(struct puffs_mount *, struct puffs_req *, void *);
24084d9c625SLionel Sambuc 
24184d9c625SLionel Sambuc struct puffs_msgpark;
24284d9c625SLionel Sambuc void	puffs_msgif_init(void);
24384d9c625SLionel Sambuc void	puffs_msgif_destroy(void);
24484d9c625SLionel Sambuc int	puffs_msgmem_alloc(size_t, struct puffs_msgpark **, void **, int);
24584d9c625SLionel Sambuc void	puffs_msgmem_release(struct puffs_msgpark *);
24684d9c625SLionel Sambuc 
24784d9c625SLionel Sambuc void	puffs_sop_thread(void *);
24884d9c625SLionel Sambuc 
24984d9c625SLionel Sambuc void	puffs_msg_setfaf(struct puffs_msgpark *);
25084d9c625SLionel Sambuc void	puffs_msg_setdelta(struct puffs_msgpark *, size_t);
25184d9c625SLionel Sambuc void	puffs_msg_setinfo(struct puffs_msgpark *, int, int, puffs_cookie_t);
25284d9c625SLionel Sambuc void	puffs_msg_setcall(struct puffs_msgpark *, parkdone_fn, void *);
25384d9c625SLionel Sambuc 
25484d9c625SLionel Sambuc void	puffs_msg_enqueue(struct puffs_mount *, struct puffs_msgpark *);
25584d9c625SLionel Sambuc int	puffs_msg_wait(struct puffs_mount *, struct puffs_msgpark *);
25684d9c625SLionel Sambuc int	puffs_msg_wait2(struct puffs_mount *, struct puffs_msgpark *,
25784d9c625SLionel Sambuc 			struct puffs_node *, struct puffs_node *);
25884d9c625SLionel Sambuc 
25984d9c625SLionel Sambuc void	puffs_msg_sendresp(struct puffs_mount *, struct puffs_req *, int);
26084d9c625SLionel Sambuc 
26184d9c625SLionel Sambuc int	puffs_getvnode(struct mount *, puffs_cookie_t, enum vtype,
26284d9c625SLionel Sambuc 		       voff_t, dev_t, struct vnode **);
26384d9c625SLionel Sambuc int	puffs_newnode(struct mount *, struct vnode *, struct vnode **,
26484d9c625SLionel Sambuc 		      puffs_cookie_t, struct componentname *,
26584d9c625SLionel Sambuc 		      enum vtype, dev_t);
26684d9c625SLionel Sambuc void	puffs_putvnode(struct vnode *);
26784d9c625SLionel Sambuc 
26884d9c625SLionel Sambuc void	puffs_releasenode(struct puffs_node *);
26984d9c625SLionel Sambuc void	puffs_referencenode(struct puffs_node *);
27084d9c625SLionel Sambuc 
27184d9c625SLionel Sambuc #define PUFFS_NOSUCHCOOKIE (-1)
272*0a6a1f1dSLionel Sambuc int	puffs_cookie2vnode(struct puffs_mount *, puffs_cookie_t,
27384d9c625SLionel Sambuc 			   struct vnode **);
27484d9c625SLionel Sambuc void	puffs_makecn(struct puffs_kcn *, struct puffs_kcred *,
27584d9c625SLionel Sambuc 		     const struct componentname *, int);
27684d9c625SLionel Sambuc void	puffs_credcvt(struct puffs_kcred *, kauth_cred_t);
27784d9c625SLionel Sambuc 
27884d9c625SLionel Sambuc void	puffs_parkdone_asyncbioread(struct puffs_mount *,
27984d9c625SLionel Sambuc 				    struct puffs_req *, void *);
28084d9c625SLionel Sambuc void	puffs_parkdone_asyncbiowrite(struct puffs_mount *,
28184d9c625SLionel Sambuc 				     struct puffs_req *, void *);
28284d9c625SLionel Sambuc void	puffs_parkdone_poll(struct puffs_mount *, struct puffs_req *, void *);
28384d9c625SLionel Sambuc 
28484d9c625SLionel Sambuc void	puffs_mp_reference(struct puffs_mount *);
28584d9c625SLionel Sambuc void	puffs_mp_release(struct puffs_mount *);
28684d9c625SLionel Sambuc 
28784d9c625SLionel Sambuc void	puffs_gop_size(struct vnode *, off_t, off_t *, int);
28884d9c625SLionel Sambuc void	puffs_gop_markupdate(struct vnode *, int);
28984d9c625SLionel Sambuc 
29084d9c625SLionel Sambuc void	puffs_senderr(struct puffs_mount *, int, int, const char *,
29184d9c625SLionel Sambuc 		      puffs_cookie_t);
29284d9c625SLionel Sambuc 
29384d9c625SLionel Sambuc bool	puffs_compat_outgoing(struct puffs_req *, struct puffs_req**, ssize_t*);
29484d9c625SLionel Sambuc void	puffs_compat_incoming(struct puffs_req *, struct puffs_req *);
29584d9c625SLionel Sambuc 
29684d9c625SLionel Sambuc void	puffs_updatenode(struct puffs_node *, int, voff_t);
29784d9c625SLionel Sambuc #define PUFFS_UPDATEATIME	0x01
29884d9c625SLionel Sambuc #define PUFFS_UPDATECTIME	0x02
29984d9c625SLionel Sambuc #define PUFFS_UPDATEMTIME	0x04
30084d9c625SLionel Sambuc #define PUFFS_UPDATESIZE	0x08
30184d9c625SLionel Sambuc 
30284d9c625SLionel Sambuc void	puffs_userdead(struct puffs_mount *);
30384d9c625SLionel Sambuc 
30484d9c625SLionel Sambuc extern int (**puffs_vnodeop_p)(void *);
30584d9c625SLionel Sambuc 
30684d9c625SLionel Sambuc /* for putter */
30784d9c625SLionel Sambuc int	puffs_msgif_getout(void *, size_t, int, uint8_t **, size_t *, void **);
30884d9c625SLionel Sambuc void	puffs_msgif_releaseout(void *, void *, int);
30984d9c625SLionel Sambuc int	puffs_msgif_dispatch(void *, struct putter_hdr *);
31084d9c625SLionel Sambuc size_t	puffs_msgif_waitcount(void *);
31184d9c625SLionel Sambuc int	puffs_msgif_close(void *);
31284d9c625SLionel Sambuc 
31384d9c625SLionel Sambuc static __inline int
checkerr(struct puffs_mount * pmp,int error,const char * str)31484d9c625SLionel Sambuc checkerr(struct puffs_mount *pmp, int error, const char *str)
31584d9c625SLionel Sambuc {
31684d9c625SLionel Sambuc 
31784d9c625SLionel Sambuc 	if (error < 0 || error > ELAST) {
31884d9c625SLionel Sambuc 		puffs_senderr(pmp, PUFFS_ERR_ERROR, error, str, NULL);
31984d9c625SLionel Sambuc 		error = EPROTO;
32084d9c625SLionel Sambuc 	}
32184d9c625SLionel Sambuc 
32284d9c625SLionel Sambuc 	return error;
32384d9c625SLionel Sambuc }
32484d9c625SLionel Sambuc 
32584d9c625SLionel Sambuc #define PUFFS_MSG_VARS(type, a)						\
32684d9c625SLionel Sambuc 	struct puffs_##type##msg_##a *a##_msg;				\
32784d9c625SLionel Sambuc 	struct puffs_msgpark *park_##a = NULL
32884d9c625SLionel Sambuc 
32984d9c625SLionel Sambuc #define PUFFS_MSG_ALLOC(type, a)					\
33084d9c625SLionel Sambuc 	puffs_msgmem_alloc(sizeof(struct puffs_##type##msg_##a),	\
33184d9c625SLionel Sambuc 	    &park_##a, (void *)& a##_msg, 1)
33284d9c625SLionel Sambuc 
33384d9c625SLionel Sambuc #define PUFFS_MSG_RELEASE(a) 						\
33484d9c625SLionel Sambuc do {									\
33584d9c625SLionel Sambuc 	if (park_##a) puffs_msgmem_release(park_##a);			\
33684d9c625SLionel Sambuc } while (/*CONSTCOND*/0)
33784d9c625SLionel Sambuc 
33884d9c625SLionel Sambuc #define PUFFS_MSG_ENQUEUEWAIT_NOERROR(pmp, park)			\
33984d9c625SLionel Sambuc do {									\
34084d9c625SLionel Sambuc 	puffs_msg_enqueue(pmp, park);					\
34184d9c625SLionel Sambuc 	puffs_msg_wait(pmp, park);					\
34284d9c625SLionel Sambuc } while (/*CONSTCOND*/0)
34384d9c625SLionel Sambuc 
34484d9c625SLionel Sambuc #define PUFFS_MSG_ENQUEUEWAIT2_NOERROR(pmp, park, vp1, vp2)		\
34584d9c625SLionel Sambuc do {									\
34684d9c625SLionel Sambuc 	puffs_msg_enqueue(pmp, park);					\
34784d9c625SLionel Sambuc 	puffs_msg_wait2(pmp, park, vp1, vp2);				\
34884d9c625SLionel Sambuc } while (/*CONSTCOND*/0)
34984d9c625SLionel Sambuc 
35084d9c625SLionel Sambuc #define PUFFS_MSG_ENQUEUEWAIT(pmp, park, var)				\
35184d9c625SLionel Sambuc do {									\
35284d9c625SLionel Sambuc 	puffs_msg_enqueue(pmp, park);					\
35384d9c625SLionel Sambuc 	var = puffs_msg_wait(pmp, park);				\
35484d9c625SLionel Sambuc } while (/*CONSTCOND*/0)
35584d9c625SLionel Sambuc 
35684d9c625SLionel Sambuc #define PUFFS_MSG_ENQUEUEWAIT2(pmp, park, vp1, vp2, var)		\
35784d9c625SLionel Sambuc do {									\
35884d9c625SLionel Sambuc 	puffs_msg_enqueue(pmp, park);					\
35984d9c625SLionel Sambuc 	var = puffs_msg_wait2(pmp, park, vp1, vp2);			\
36084d9c625SLionel Sambuc } while (/*CONSTCOND*/0)
36184d9c625SLionel Sambuc 
36284d9c625SLionel Sambuc #endif /* _PUFFS_SYS_H_ */
363