Home | History | Annotate | Line # | Download | only in puffs
puffs_msgif.h revision 1.34
      1 /*	$NetBSD: puffs_msgif.h,v 1.34 2007/06/24 22:16:03 pooka Exp $	*/
      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_MSGIF_H_
     33 #define _PUFFS_MSGIF_H_
     34 
     35 #include <sys/param.h>
     36 #include <sys/time.h>
     37 #include <sys/ioccom.h>
     38 #include <sys/uio.h>
     39 #include <sys/vnode.h>
     40 #include <sys/ucred.h>
     41 #include <sys/statvfs.h>
     42 #include <sys/dirent.h>
     43 #include <sys/fcntl.h>
     44 
     45 #define PUFFSOP_VFS	1
     46 #define PUFFSOP_VN	2
     47 #define PUFFSOP_CACHE	3
     48 #define PUFFSOPFLAG_FAF	0x10	/* fire-and-forget */
     49 
     50 #define PUFFSOP_OPCMASK		0x03
     51 #define PUFFSOP_OPCLASS(a)	((a) & PUFFSOP_OPCMASK)
     52 #define PUFFSOP_WANTREPLY(a)	(((a) & PUFFSOPFLAG_FAF) == 0)
     53 
     54 /* XXX: we don't need everything */
     55 enum {
     56 	PUFFS_VFS_MOUNT,	PUFFS_VFS_START,	PUFFS_VFS_UNMOUNT,
     57 	PUFFS_VFS_ROOT,		PUFFS_VFS_STATVFS,	PUFFS_VFS_SYNC,
     58 	PUFFS_VFS_VGET,		PUFFS_VFS_FHTOVP,	PUFFS_VFS_VPTOFH,
     59 	PUFFS_VFS_INIT,		PUFFS_VFS_DONE,		PUFFS_VFS_SNAPSHOT,
     60 	PUFFS_VFS_EXTATTCTL,	PUFFS_VFS_SUSPEND
     61 };
     62 #define PUFFS_VFS_MAX PUFFS_VFS_EXTATTCTL
     63 
     64 /* moreXXX: we don't need everything here either */
     65 enum {
     66 	PUFFS_VN_LOOKUP,	PUFFS_VN_CREATE,	PUFFS_VN_MKNOD,
     67 	PUFFS_VN_OPEN,		PUFFS_VN_CLOSE,		PUFFS_VN_ACCESS,
     68 	PUFFS_VN_GETATTR,	PUFFS_VN_SETATTR,	PUFFS_VN_READ,
     69 	PUFFS_VN_WRITE,		PUFFS_VN_IOCTL,		PUFFS_VN_FCNTL,
     70 	PUFFS_VN_POLL,		PUFFS_VN_KQFILTER,	PUFFS_VN_REVOKE,
     71 	PUFFS_VN_MMAP,		PUFFS_VN_FSYNC,		PUFFS_VN_SEEK,
     72 	PUFFS_VN_REMOVE,	PUFFS_VN_LINK,		PUFFS_VN_RENAME,
     73 	PUFFS_VN_MKDIR,		PUFFS_VN_RMDIR,		PUFFS_VN_SYMLINK,
     74 	PUFFS_VN_READDIR,	PUFFS_VN_READLINK,	PUFFS_VN_ABORTOP,
     75 	PUFFS_VN_INACTIVE,	PUFFS_VN_RECLAIM,	PUFFS_VN_LOCK,
     76 	PUFFS_VN_UNLOCK,	PUFFS_VN_BMAP,		PUFFS_VN_STRATEGY,
     77 	PUFFS_VN_PRINT,		PUFFS_VN_ISLOCKED,	PUFFS_VN_PATHCONF,
     78 	PUFFS_VN_ADVLOCK,	PUFFS_VN_LEASE,		PUFFS_VN_WHITEOUT,
     79 	PUFFS_VN_GETPAGES,	PUFFS_VN_PUTPAGES,	PUFFS_VN_GETEXTATTR,
     80 	PUFFS_VN_LISTEXTATTR,	PUFFS_VN_OPENEXTATTR,	PUFFS_VN_DELETEEXTATTR,
     81 	PUFFS_VN_SETEXTATTR
     82 };
     83 #define PUFFS_VN_MAX PUFFS_VN_SETEXTATTR
     84 
     85 #define PUFFSDEVELVERS	0x80000000
     86 #define PUFFSVERSION	11
     87 #define PUFFSNAMESIZE	32
     88 struct puffs_kargs {
     89 	unsigned int	pa_vers;
     90 	int		pa_fd;
     91 	uint32_t	pa_flags;
     92 
     93 	size_t		pa_maxreqlen;
     94 	int		pa_nhashbuckets;
     95 
     96 	size_t		pa_fhsize;
     97 	int		pa_fhflags;
     98 
     99 	void		*pa_root_cookie;
    100 	enum vtype	pa_root_vtype;
    101 	voff_t		pa_root_vsize;
    102 	dev_t		pa_root_rdev;
    103 
    104 	struct statvfs	pa_svfsb;
    105 
    106 	char		pa_name[PUFFSNAMESIZE+1];   /* name for puffs type */
    107 	uint8_t		pa_vnopmask[PUFFS_VN_MAX];
    108 };
    109 #define PUFFS_KFLAG_NOCACHE_NAME	0x01	/* don't use name cache     */
    110 #define PUFFS_KFLAG_NOCACHE_PAGE	0x02	/* don't use page cache	    */
    111 #define PUFFS_KFLAG_ALLOPS		0x04	/* ignore pa_vnopmask       */
    112 #define PUFFS_KFLAG_WTCACHE		0x08	/* write-through page cache */
    113 #define PUFFS_KFLAG_IAONDEMAND		0x10	/* inactive only on demand  */
    114 #define PUFFS_KFLAG_MASK		0x1f
    115 
    116 #define PUFFS_FHFLAG_DYNAMIC	0x01
    117 #define PUFFS_FHFLAG_NFSV2	0x02
    118 #define PUFFS_FHFLAG_NFSV3	0x04
    119 #define PUFFS_FHFLAG_PROTOMASK	0x06
    120 
    121 #define PUFFS_FHSIZE_MAX	1020	/* XXX: FHANDLE_SIZE_MAX - 4 */
    122 
    123 /*
    124  * This is the device minor number for the cloning device.  Make it
    125  * a high number "just in case", even though we don't want to open
    126  * any specific devices currently.
    127  */
    128 #define PUFFS_CLONER 0x7ffff
    129 
    130 struct puffs_reqh_get {
    131 	void	*phg_buf;	/* user buffer		*/
    132 	size_t	phg_buflen;	/* user buffer length	*/
    133 
    134 	int	phg_nops;	/* max ops user wants / number delivered */
    135 	int	phg_more;	/* advisory: more ops available? */
    136 };
    137 
    138 struct puffs_reqh_put {
    139 	int		php_nops;	/* ops available / ops handled */
    140 
    141 	/* these describe the first request */
    142 	uint64_t	php_id;		/* request id */
    143 	void		*php_buf;	/* user buffer address */
    144 	size_t		php_buflen;	/* user buffer length, hdr NOT incl. */
    145 };
    146 
    147 /*
    148  * The requests work as follows:
    149  *
    150  *  + GETOP: When fetching operations from the kernel, the user server
    151  *           supplies a flat buffer into which operations are written.
    152  *           The number of operations written to the buffer is
    153  *           MIN(prhg_nops, requests waiting, space in buffer).
    154  *
    155  *           Operations follow each other and each one is described
    156  *           by the puffs_req structure, which is immediately followed
    157  *           by the aligned request data buffer in preq_buf.  The next
    158  *           puffs_req can be found at preq + preq_buflen.
    159  *
    160  *           Visually, the server should expect:
    161  *
    162  *           |<-- preq_buflen -->|
    163  *           ---------------------------------------------------------------
    164  *           |hdr|  buffer |align|hdr| buffer |hdr| ....   |buffer|        |
    165  *           ---------------------------------------------------------------
    166  *           ^ start       ^ unaligned        ^ aligned    ^ always aligned
    167  *
    168  *           The server is allowed to modify the contents of the buffers.
    169  *           Since the headers are the same size for both get and put, it
    170  *           is possible to handle all operations simply by doing in-place
    171  *           modification.  Where more input is expected that what was put
    172  *           out, the kernel leaves a hole in the buffer.  This hole size
    173  *           is derived from the operational semantics known by the vnode
    174  *           layer.  The hole size is included in preq_buflen.  The
    175  *           amount of relevant information in the buffer is call-specific
    176  *           and can be deduced by the server from the call type.
    177  *
    178  *  + PUTOP: When returning the results of an operation to the kernel, the
    179  *           user server is allowed to input results in a scatter-gather
    180  *           fashion.  Each request is made up of a header and the buffer.
    181  *           The header describes the *NEXT* request for copyin, *NOT* the
    182  *           current one.  The first request is described in puffs_reqh_put
    183  *           and the last one is left uninterpreted.  This is to halve the
    184  *           amount of copyin's required.
    185  *
    186  *           Fans of my ascii art, rejoice:
    187  *               /-------------------->| preq_buflen     |
    188  *           ---^----------------------------------------------------------
    189  *           |hdr|buffer| empty spaces |hdr|    buffer   |                |
    190  *           --v-----------------------^-v---------------------------------
    191  *             \------- preq_buf -----/  \------- preq_buf ....
    192  *
    193  *           This scheme also allows for better in-place modification of the
    194  *           request buffer when handling requests.  The vision is that
    195  *           operations which can be immediately satisfied will be edited
    196  *           in-place while ones which can't will be left blank.  Also,
    197  *           requests from async operations which have been satisfied
    198  *           meanwhile can be included.
    199  *
    200  *           The total number of operations is given by the ioctl control
    201  *           structure puffs_reqh.  The values in the header in the final
    202  *           are not used.
    203  */
    204 struct puffs_req {
    205 	uint64_t	preq_id;		/* get: cur, put: next */
    206 
    207 	union u {
    208 		struct {
    209 			uint8_t	opclass;	/* cur */
    210 			uint8_t	optype;		/* cur */
    211 
    212 			/*
    213 			 * preq_cookie is the node cookie associated with
    214 			 * the request.  It always maps 1:1 to a vnode
    215 			 * and could map to a userspace struct puffs_node.
    216 			 * The cookie usually describes the first
    217 			 * vnode argument of the VOP_POP() in question.
    218 			 */
    219 
    220 			void	*cookie;	/* cur */
    221 		} out;
    222 		struct {
    223 			int	rv;		/* cur */
    224 			int	setbacks;	/* cur */
    225 			void	*buf;		/* next */
    226 		} in;
    227 	} u;
    228 
    229 	size_t  preq_buflen;			/* get: cur, put: next */
    230 	/*
    231 	 * the following helper pads the struct size to md alignment
    232 	 * multiple (should size_t not cut it).  it makes sure that
    233 	 * whatever comes after this struct is aligned
    234 	 */
    235 	uint8_t	preq_buf[0] __aligned(ALIGNBYTES+1);
    236 };
    237 #define preq_opclass	u.out.opclass
    238 #define preq_optype	u.out.optype
    239 #define preq_cookie	u.out.cookie
    240 #define preq_rv		u.in.rv
    241 #define preq_setbacks	u.in.setbacks
    242 #define preq_nextbuf	u.in.buf
    243 
    244 #define PUFFS_SETBACK_INACT_N1	0x01	/* set VOP_INACTIVE for node 1 */
    245 #define PUFFS_SETBACK_INACT_N2	0x02	/* set VOP_INACTIVE for node 2 */
    246 #define PUFFS_SETBACK_NOREF_N1	0x04	/* set pn PN_NOREFS for node 1 */
    247 #define PUFFS_SETBACK_NOREF_N2	0x08	/* set pn PN_NOREFS for node 2 */
    248 #define PUFFS_SETBACK_MASK	0x0f
    249 
    250 /*
    251  * Some operations have unknown size requirements.  So as the first
    252  * stab at handling it, do an extra bounce between the kernel and
    253  * userspace.
    254  */
    255 struct puffs_sizeop {
    256 	uint64_t	pso_reqid;
    257 
    258 	uint8_t		*pso_userbuf;
    259 	size_t		pso_bufsize;
    260 };
    261 
    262 /*
    263  * Flush operation.  This can be used to invalidate:
    264  * 1) name cache for one node
    265  * 2) name cache for all children
    266  * 3) name cache for the entire mount
    267  * 4) page cache for a set of ranges in one node
    268  * 5) page cache for one entire node
    269  *
    270  * It can be used to flush:
    271  * 1) page cache for a set of ranges in one node
    272  * 2) page cache for one entire node
    273  */
    274 
    275 /* XXX: needs restructuring */
    276 struct puffs_flush {
    277 	void		*pf_cookie;
    278 
    279 	int		pf_op;
    280 	off_t		pf_start;
    281 	off_t		pf_end;
    282 };
    283 #define PUFFS_INVAL_NAMECACHE_NODE		0
    284 #define PUFFS_INVAL_NAMECACHE_DIR		1
    285 #define PUFFS_INVAL_NAMECACHE_ALL		2
    286 #define PUFFS_INVAL_PAGECACHE_NODE_RANGE	3
    287 #define PUFFS_FLUSH_PAGECACHE_NODE_RANGE	4
    288 
    289 
    290 /*
    291  * Available ioctl operations
    292  */
    293 #define PUFFSGETOP		_IOWR('p', 1, struct puffs_reqh_get)
    294 #define PUFFSPUTOP		_IOWR('p', 2, struct puffs_reqh_put)
    295 #define PUFFSSIZEOP		_IOWR('p', 3, struct puffs_sizeop)
    296 #define PUFFSFLUSHOP		_IOW ('p', 4, struct puffs_flush)
    297 #if 0
    298 #define PUFFSFLUSHMULTIOP	_IOW ('p', 5, struct puffs_flushmulti)
    299 #endif
    300 #define PUFFSSUSPENDOP		_IO  ('p', 6)
    301 
    302 
    303 /*
    304  * Credentials for an operation.  Can be either struct uucred for
    305  * ops called from a credential context or NOCRED/FSCRED for ops
    306  * called from within the kernel.  It is up to the implementation
    307  * if it makes a difference between these two and the super-user.
    308  */
    309 struct puffs_cred {
    310 	struct uucred	pcr_uuc;
    311 	uint8_t		pcr_type;
    312 	uint8_t		pcr_internal;
    313 };
    314 #define PUFFCRED_TYPE_UUC	1
    315 #define PUFFCRED_TYPE_INTERNAL	2
    316 #define PUFFCRED_CRED_NOCRED	1
    317 #define PUFFCRED_CRED_FSCRED	2
    318 
    319 /*
    320  * 2*MAXPHYS is the max size the system will attempt to copy,
    321  * else treated as garbage
    322  */
    323 #define PUFFS_REQ_MAXSIZE	2*MAXPHYS
    324 #define PUFFS_REQSTRUCT_MAX	4096 /* XXX: approxkludge */
    325 
    326 #define PUFFS_TOMOVE(a,b) (MIN((a), b->pmp_req_maxsize - PUFFS_REQSTRUCT_MAX))
    327 
    328 /* puffs struct componentname built by kernel */
    329 struct puffs_kcn {
    330 	/* args */
    331 	u_long			pkcn_nameiop;	/* namei operation	*/
    332 	u_long			pkcn_flags;	/* flags		*/
    333 	pid_t			pkcn_pid;	/* caller pid		*/
    334 	struct puffs_cred	pkcn_cred;	/* caller creds		*/
    335 
    336 	char pkcn_name[MAXPATHLEN+1];  /* nul-terminated path component	*/
    337 	long pkcn_namelen;
    338 };
    339 
    340 /*
    341  * XXX: figure out what to do with these, copied from namei.h for now
    342  */
    343 #define	PUFFSLOOKUP_LOOKUP	0	/* perform name lookup only */
    344 #define PUFFSLOOKUP_CREATE	1	/* setup for file creation */
    345 #define PUFFSLOOKUP_DELETE	2	/* setup for file deletion */
    346 #define PUFFSLOOKUP_RENAME	3	/* setup for file renaming */
    347 #define PUFFSLOOKUP_OPMASK	3	/* mask for operation */
    348 
    349 #define PUFFSLOOKUP_FOLLOW	0x00004	/* follow final symlink */
    350 #define PUFFSLOOKUP_NOFOLLOW	0x00008	/* don't follow final symlink */
    351 #define PUFFSLOOKUP_ISLASTCN	0x08000 /* is last component of lookup */
    352 
    353 
    354 /*
    355  * Next come the individual requests.  They are all subclassed from
    356  * puffs_req and contain request-specific fields in addition.  Note
    357  * that there are some requests which have to handle arbitrary-length
    358  * buffers.
    359  *
    360  * The division is the following: puffs_req is to be touched only
    361  * by generic routines while the other stuff is supposed to be
    362  * modified only by specific routines.
    363  */
    364 
    365 /*
    366  * aux structures for vfs operations.
    367  */
    368 struct puffs_vfsreq_unmount {
    369 	struct puffs_req	pvfsr_pr;
    370 
    371 	int			pvfsr_flags;
    372 	pid_t			pvfsr_pid;
    373 };
    374 
    375 struct puffs_vfsreq_statvfs {
    376 	struct puffs_req	pvfsr_pr;
    377 
    378 	struct statvfs		pvfsr_sb;
    379 	pid_t			pvfsr_pid;
    380 };
    381 
    382 struct puffs_vfsreq_sync {
    383 	struct puffs_req	pvfsr_pr;
    384 
    385 	struct puffs_cred	pvfsr_cred;
    386 	pid_t			pvfsr_pid;
    387 	int			pvfsr_waitfor;
    388 };
    389 
    390 struct puffs_vfsreq_fhtonode {
    391 	struct puffs_req	pvfsr_pr;
    392 
    393 	void			*pvfsr_fhcookie;	/* IN	*/
    394 	enum vtype		pvfsr_vtype;		/* IN	*/
    395 	voff_t			pvfsr_size;		/* IN	*/
    396 	dev_t			pvfsr_rdev;		/* IN	*/
    397 
    398 	size_t			pvfsr_dsize;		/* OUT */
    399 	uint8_t			pvfsr_data[0]		/* OUT, XXX */
    400 				    __aligned(ALIGNBYTES+1);
    401 };
    402 
    403 struct puffs_vfsreq_nodetofh {
    404 	struct puffs_req	pvfsr_pr;
    405 
    406 	void			*pvfsr_fhcookie;	/* OUT	*/
    407 
    408 	size_t			pvfsr_dsize;		/* OUT/IN  */
    409 	uint8_t			pvfsr_data[0]		/* IN, XXX */
    410 				    __aligned(ALIGNBYTES+1);
    411 };
    412 
    413 struct puffs_vfsreq_suspend {
    414 	struct puffs_req	pvfsr_pr;
    415 
    416 	int			pvfsr_status;
    417 };
    418 #define PUFFS_SUSPEND_START	0
    419 #define PUFFS_SUSPEND_SUSPENDED	1
    420 #define PUFFS_SUSPEND_RESUME	2
    421 #define PUFFS_SUSPEND_ERROR	3
    422 
    423 /*
    424  * aux structures for vnode operations.
    425  */
    426 
    427 struct puffs_vnreq_lookup {
    428 	struct puffs_req	pvn_pr;
    429 
    430 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    431 	void			*pvnr_newnode;		/* IN	*/
    432 	enum vtype		pvnr_vtype;		/* IN	*/
    433 	voff_t			pvnr_size;		/* IN	*/
    434 	dev_t			pvnr_rdev;		/* IN	*/
    435 };
    436 
    437 struct puffs_vnreq_create {
    438 	struct puffs_req	pvn_pr;
    439 
    440 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    441 	struct vattr		pvnr_va;		/* OUT	*/
    442 	void			*pvnr_newnode;		/* IN	*/
    443 };
    444 
    445 struct puffs_vnreq_mknod {
    446 	struct puffs_req	pvn_pr;
    447 
    448 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    449 	struct vattr		pvnr_va;		/* OUT	*/
    450 	void			*pvnr_newnode;		/* IN	*/
    451 };
    452 
    453 struct puffs_vnreq_open {
    454 	struct puffs_req	pvn_pr;
    455 
    456 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    457 	pid_t			pvnr_pid;		/* OUT	*/
    458 	int			pvnr_mode;		/* OUT	*/
    459 };
    460 
    461 struct puffs_vnreq_close {
    462 	struct puffs_req	pvn_pr;
    463 
    464 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    465 	pid_t			pvnr_pid;		/* OUT	*/
    466 	int			pvnr_fflag;		/* OUT	*/
    467 };
    468 
    469 struct puffs_vnreq_access {
    470 	struct puffs_req	pvn_pr;
    471 
    472 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    473 	pid_t			pvnr_pid;		/* OUT	*/
    474 	int			pvnr_mode;		/* OUT	*/
    475 };
    476 
    477 #define puffs_vnreq_setattr puffs_vnreq_setgetattr
    478 #define puffs_vnreq_getattr puffs_vnreq_setgetattr
    479 struct puffs_vnreq_setgetattr {
    480 	struct puffs_req	pvn_pr;
    481 
    482 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    483 	struct vattr		pvnr_va;		/* IN/OUT (op depend) */
    484 	pid_t			pvnr_pid;		/* OUT	*/
    485 };
    486 
    487 #define puffs_vnreq_read puffs_vnreq_readwrite
    488 #define puffs_vnreq_write puffs_vnreq_readwrite
    489 struct puffs_vnreq_readwrite {
    490 	struct puffs_req	pvn_pr;
    491 
    492 	struct puffs_cred	pvnr_cred;		/* OUT	  */
    493 	off_t			pvnr_offset;		/* OUT	  */
    494 	size_t			pvnr_resid;		/* IN/OUT */
    495 	int			pvnr_ioflag;		/* OUT	  */
    496 
    497 	uint8_t			pvnr_data[0];		/* IN/OUT (wr/rd) */
    498 };
    499 
    500 #define puffs_vnreq_ioctl puffs_vnreq_fcnioctl
    501 #define puffs_vnreq_fcntl puffs_vnreq_fcnioctl
    502 struct puffs_vnreq_fcnioctl {
    503 	struct puffs_req	pvn_pr;
    504 
    505 	struct puffs_cred	pvnr_cred;
    506 	u_long			pvnr_command;
    507 	pid_t			pvnr_pid;
    508 	int			pvnr_fflag;
    509 
    510 	void			*pvnr_data;
    511 	size_t			pvnr_datalen;
    512 	int			pvnr_copyback;
    513 };
    514 
    515 struct puffs_vnreq_poll {
    516 	struct puffs_req	pvn_pr;
    517 
    518 	int			pvnr_events;		/* IN/OUT */
    519 	pid_t			pvnr_pid;		/* OUT	  */
    520 };
    521 
    522 struct puffs_vnreq_fsync {
    523 	struct puffs_req	pvn_pr;
    524 
    525 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    526 	off_t			pvnr_offlo;		/* OUT	*/
    527 	off_t			pvnr_offhi;		/* OUT	*/
    528 	pid_t			pvnr_pid;		/* OUT	*/
    529 	int			pvnr_flags;		/* OUT	*/
    530 };
    531 
    532 struct puffs_vnreq_seek {
    533 	struct puffs_req	pvn_pr;
    534 
    535 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    536 	off_t			pvnr_oldoff;		/* OUT	*/
    537 	off_t			pvnr_newoff;		/* OUT	*/
    538 };
    539 
    540 struct puffs_vnreq_remove {
    541 	struct puffs_req	pvn_pr;
    542 
    543 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    544 	void			*pvnr_cookie_targ;	/* OUT	*/
    545 };
    546 
    547 struct puffs_vnreq_mkdir {
    548 	struct puffs_req	pvn_pr;
    549 
    550 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    551 	struct vattr		pvnr_va;		/* OUT	*/
    552 	void			*pvnr_newnode;		/* IN	*/
    553 };
    554 
    555 struct puffs_vnreq_rmdir {
    556 	struct puffs_req	pvn_pr;
    557 
    558 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    559 	void			*pvnr_cookie_targ;	/* OUT	*/
    560 };
    561 
    562 struct puffs_vnreq_link {
    563 	struct puffs_req	pvn_pr;
    564 
    565 	struct puffs_kcn	pvnr_cn;		/* OUT */
    566 	void			*pvnr_cookie_targ;	/* OUT */
    567 };
    568 
    569 struct puffs_vnreq_rename {
    570 	struct puffs_req	pvn_pr;
    571 
    572 	struct puffs_kcn	pvnr_cn_src;		/* OUT	*/
    573 	struct puffs_kcn	pvnr_cn_targ;		/* OUT	*/
    574 	void			*pvnr_cookie_src;	/* OUT	*/
    575 	void			*pvnr_cookie_targ;	/* OUT	*/
    576 	void			*pvnr_cookie_targdir;	/* OUT	*/
    577 };
    578 
    579 struct puffs_vnreq_symlink {
    580 	struct puffs_req	pvn_pr;
    581 
    582 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    583 	struct vattr		pvnr_va;		/* OUT	*/
    584 	void			*pvnr_newnode;		/* IN	*/
    585 	char			pvnr_link[MAXPATHLEN];	/* OUT	*/
    586 };
    587 
    588 struct puffs_vnreq_readdir {
    589 	struct puffs_req	pvn_pr;
    590 
    591 	struct puffs_cred	pvnr_cred;		/* OUT	  */
    592 	off_t			pvnr_offset;		/* IN/OUT */
    593 	size_t			pvnr_resid;		/* IN/OUT */
    594 	size_t			pvnr_ncookies;		/* IN/OUT */
    595 	int			pvnr_eofflag;		/* IN     */
    596 
    597 	size_t			pvnr_dentoff;		/* OUT    */
    598 	uint8_t			pvnr_data[0]		/* IN  	  */
    599 				    __aligned(ALIGNBYTES+1);
    600 };
    601 
    602 struct puffs_vnreq_readlink {
    603 	struct puffs_req	pvn_pr;
    604 
    605 	struct puffs_cred	pvnr_cred;		/* OUT */
    606 	size_t			pvnr_linklen;		/* IN  */
    607 	char			pvnr_link[MAXPATHLEN];	/* IN, XXX  */
    608 };
    609 
    610 struct puffs_vnreq_reclaim {
    611 	struct puffs_req	pvn_pr;
    612 
    613 	pid_t			pvnr_pid;		/* OUT	*/
    614 };
    615 
    616 struct puffs_vnreq_inactive {
    617 	struct puffs_req	pvn_pr;
    618 
    619 	pid_t			pvnr_pid;		/* OUT	*/
    620 	int			pvnr_backendrefs;	/* IN	*/
    621 };
    622 
    623 struct puffs_vnreq_print {
    624 	struct puffs_req	pvn_pr;
    625 
    626 	/* empty */
    627 };
    628 
    629 struct puffs_vnreq_pathconf {
    630 	struct puffs_req	pvn_pr;
    631 
    632 	int			pvnr_name;		/* OUT	*/
    633 	int			pvnr_retval;		/* IN	*/
    634 };
    635 
    636 struct puffs_vnreq_advlock {
    637 	struct puffs_req	pvn_pr;
    638 
    639 	struct flock		pvnr_fl;		/* OUT	*/
    640 	void			*pvnr_id;		/* OUT	*/
    641 	int			pvnr_op;		/* OUT	*/
    642 	int			pvnr_flags;		/* OUT	*/
    643 };
    644 
    645 struct puffs_vnreq_mmap {
    646 	struct puffs_req	pvn_pr;
    647 
    648 	int			pvnr_fflags;		/* OUT	*/
    649 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    650 	pid_t			pvnr_pid;		/* OUT	*/
    651 };
    652 
    653 
    654 /*
    655  * For cache reports.  Everything is always out-out-out, no replies
    656  */
    657 
    658 struct puffs_cacherun {
    659 	off_t			pcache_runstart;
    660 	off_t			pcache_runend;
    661 };
    662 
    663 /* cache info.  old used for write now */
    664 struct puffs_cacheinfo {
    665 	struct puffs_req	pcache_pr;
    666 
    667 	int			pcache_type;
    668 	size_t			pcache_nruns;
    669 	struct puffs_cacherun	pcache_runs[0];
    670 };
    671 #define PCACHE_TYPE_READ	0
    672 #define PCACHE_TYPE_WRITE	1
    673 
    674 /* notyet */
    675 #if 0
    676 struct puffs_vnreq_kqfilter { };
    677 struct puffs_vnreq_islocked { };
    678 #endif
    679 struct puffs_vnreq_getextattr { };
    680 struct puffs_vnreq_setextattr { };
    681 struct puffs_vnreq_listextattr { };
    682 
    683 #ifdef _KERNEL
    684 #define PUFFS_VFSREQ(a)							\
    685 	struct puffs_vfsreq_##a a##_arg;				\
    686 	memset(&a##_arg, 0, sizeof(struct puffs_vfsreq_##a))
    687 
    688 #define PUFFS_VNREQ(a)							\
    689 	struct puffs_vnreq_##a a##_arg;					\
    690 	memset(&a##_arg, 0, sizeof(struct puffs_vnreq_##a))
    691 #endif
    692 
    693 #endif /* _PUFFS_MSGIF_H_ */
    694