puffs_priv.h revision 1.7
11.7Spooka/*	$NetBSD: puffs_priv.h,v 1.7 2007/05/05 15:48:18 pooka Exp $	*/
21.1Spooka
31.1Spooka/*
41.1Spooka * Copyright (c) 2006 Antti Kantee.  All Rights Reserved.
51.1Spooka *
61.1Spooka * Redistribution and use in source and binary forms, with or without
71.1Spooka * modification, are permitted provided that the following conditions
81.1Spooka * are met:
91.1Spooka * 1. Redistributions of source code must retain the above copyright
101.1Spooka *    notice, this list of conditions and the following disclaimer.
111.1Spooka * 2. Redistributions in binary form must reproduce the above copyright
121.1Spooka *    notice, this list of conditions and the following disclaimer in the
131.1Spooka *    documentation and/or other materials provided with the distribution.
141.1Spooka * 3. The name of the company nor the name of the author may be used to
151.1Spooka *    endorse or promote products derived from this software without specific
161.1Spooka *    prior written permission.
171.1Spooka *
181.1Spooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
191.1Spooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
201.1Spooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
211.1Spooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
221.1Spooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
231.1Spooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
241.1Spooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
251.1Spooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
261.1Spooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
271.1Spooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
281.1Spooka * SUCH DAMAGE.
291.1Spooka */
301.1Spooka
311.1Spooka#ifndef _PUFFS_PRIVATE_H_
321.1Spooka#define _PUFFS_PRIVATE_H_
331.1Spooka
341.1Spooka#include <sys/types.h>
351.1Spooka#include <fs/puffs/puffs_msgif.h>
361.1Spooka
371.1Spooka#include <puffs.h>
381.2Spooka#include <ucontext.h>
391.2Spooka
401.4Spooka#define PU_CMAP(pu, c)	(pu->pu_cmap ? pu->pu_cmap(c) : (struct puffs_node *)c)
411.4Spooka
421.7Spookastruct puffs_framectrl;
431.7Spooka
441.5Spooka/*
451.5Spooka * usermount: describes one file system instance
461.5Spooka */
471.5Spookastruct puffs_usermount {
481.5Spooka	struct puffs_ops	pu_ops;
491.6Spooka	struct puffs_kargs	pu_kargs;
501.5Spooka
511.5Spooka	uint32_t		pu_flags;
521.5Spooka	size_t			pu_cc_stacksize;
531.5Spooka
541.5Spooka	int			pu_state;
551.5Spooka
561.5Spooka	struct puffs_node	*pu_pn_root;
571.5Spooka
581.5Spooka	LIST_HEAD(, puffs_node)	pu_pnodelst;
591.5Spooka
601.5Spooka	struct puffs_node	*(*pu_cmap)(void *);
611.5Spooka
621.5Spooka	pu_pathbuild_fn		pu_pathbuild;
631.5Spooka	pu_pathtransform_fn	pu_pathtransform;
641.5Spooka	pu_pathcmp_fn		pu_pathcmp;
651.5Spooka	pu_pathfree_fn		pu_pathfree;
661.5Spooka	pu_namemod_fn		pu_namemod;
671.5Spooka
681.7Spooka	struct puffs_framectrl	*pu_framectrl;
691.7Spooka
701.5Spooka	void	*pu_privdata;
711.5Spooka};
721.5Spooka
731.2Spooka/* call context */
741.2Spooka
751.2Spookastruct puffs_cc {
761.2Spooka	struct puffs_usermount	*pcc_pu;
771.2Spooka	struct puffs_req	*pcc_preq;
781.2Spooka
791.2Spooka	ucontext_t		pcc_uc;		/* "continue" 		*/
801.2Spooka	ucontext_t		pcc_uc_ret;	/* "yield" 		*/
811.2Spooka	void			*pcc_stack;
821.2Spooka
831.2Spooka	int			pcc_flags;
841.2Spooka
851.2Spooka	/* these are for threading information to the implementation	*/
861.2Spooka	void			*pcc_priv;
871.2Spooka	int			pcc_rv;
881.2Spooka
891.2Spooka	TAILQ_ENTRY(puffs_cc)	entries;
901.2Spooka};
911.2Spooka#define PCC_ONCE	0x01
921.2Spooka#define PCC_REALCC	0x02
931.2Spooka#define PCC_FREEPRIV	0x04
941.2Spooka#define PCC_PREQ_NOCOPY	0x08
951.2Spooka#define PCC_DONE	0x10
961.2Spooka
971.2Spooka#define PCC_CALL_NONE	0x10000
981.2Spooka#define PCC_CALL_IN	0x20000
991.2Spooka#define PCC_CALL_OUT	0x40000
1001.2Spooka#define PCC_CALL_MASK	0x70000
1011.2Spooka
1021.2Spooka#define pcc_callstat(a)	   (a->pcc_flags & PCC_CALL_MASK)
1031.2Spooka#define pcc_callset(a, b)  (a->pcc_flags = (a->pcc_flags & ~PCC_CALL_MASK) | b)
1041.2Spooka
1051.2Spooka#define pcc_init_local(ap)   						\
1061.2Spookado {									\
1071.2Spooka	memset(ap, 0, sizeof(*ap));					\
1081.2Spooka	(ap)->pcc_flags = PCC_ONCE;					\
1091.2Spooka} while (/*CONSTCOND*/0)
1101.2Spooka
1111.2Spooka/*
1121.2Spooka * Reqs
1131.2Spooka */
1141.1Spooka
1151.1Spookastruct puffs_getreq {
1161.1Spooka	struct puffs_usermount	*pgr_pu;
1171.1Spooka
1181.1Spooka	struct puffs_reqh_get	pgr_phg;
1191.2Spooka	struct puffs_reqh_get	pgr_phg_orig;
1201.2Spooka
1211.1Spooka	struct puffs_req	*pgr_nextpreq;
1221.1Spooka	size_t			pgr_advance;
1231.2Spooka
1241.2Spooka	/* diagnostics */
1251.2Spooka	int			pgr_nppr;
1261.1Spooka};
1271.1Spooka
1281.1Spookastruct puffs_putreq {
1291.1Spooka	struct puffs_usermount *ppr_pu;
1301.1Spooka
1311.1Spooka	struct puffs_reqh_put	ppr_php;
1321.1Spooka
1331.1Spooka	/* to adjust next request info */
1341.2Spooka	void			**ppr_buf;
1351.2Spooka	size_t			*ppr_buflen;
1361.2Spooka	uint64_t 		*ppr_id;
1371.2Spooka
1381.2Spooka	/* for delayed action freeing of preq's */
1391.2Spooka	TAILQ_HEAD(, puffs_cc)	ppr_pccq;
1401.2Spooka
1411.2Spooka	/* diagnostics */
1421.2Spooka	struct puffs_getreq	*ppr_pgr;
1431.1Spooka};
1441.1Spooka
1451.2Spooka__BEGIN_DECLS
1461.2Spooka
1471.3Spookavoid	puffs_calldispatcher(struct puffs_cc *);
1481.3Spooka
1491.2Spooka__END_DECLS
1501.2Spooka
1511.1Spooka#endif /* _PUFFS_PRIVATE_H_ */
152