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