Home | History | Annotate | Line # | Download | only in puffs
puffs_msgif.h revision 1.37
      1 /*	$NetBSD: puffs_msgif.h,v 1.37 2007/07/01 17:22:13 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	12
     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_NOCACHE		0x03	/* no cache whatsoever      */
    112 #define PUFFS_KFLAG_ALLOPS		0x04	/* ignore pa_vnopmask       */
    113 #define PUFFS_KFLAG_WTCACHE		0x08	/* write-through page cache */
    114 #define PUFFS_KFLAG_IAONDEMAND		0x10	/* inactive only on demand  */
    115 #define PUFFS_KFLAG_MASK		0x1f
    116 
    117 #define PUFFS_FHFLAG_DYNAMIC	0x01
    118 #define PUFFS_FHFLAG_NFSV2	0x02
    119 #define PUFFS_FHFLAG_NFSV3	0x04
    120 #define PUFFS_FHFLAG_PROTOMASK	0x06
    121 
    122 #define PUFFS_FHSIZE_MAX	1020	/* XXX: FHANDLE_SIZE_MAX - 4 */
    123 
    124 /*
    125  * This is the device minor number for the cloning device.  Make it
    126  * a high number "just in case", even though we don't want to open
    127  * any specific devices currently.
    128  */
    129 #define PUFFS_CLONER 0x7ffff
    130 
    131 struct puffs_reqh_get {
    132 	void	*phg_buf;	/* user buffer		*/
    133 	size_t	phg_buflen;	/* user buffer length	*/
    134 
    135 	int	phg_nops;	/* max ops user wants / number delivered */
    136 	int	phg_more;	/* advisory: more ops available? */
    137 };
    138 
    139 struct puffs_reqh_put {
    140 	int		php_nops;	/* ops available / ops handled */
    141 
    142 	/* these describe the first request */
    143 	uint64_t	php_id;		/* request id */
    144 	void		*php_buf;	/* user buffer address */
    145 	size_t		php_buflen;	/* user buffer length, hdr NOT incl. */
    146 };
    147 
    148 /*
    149  * The requests work as follows:
    150  *
    151  *  + GETOP: When fetching operations from the kernel, the user server
    152  *           supplies a flat buffer into which operations are written.
    153  *           The number of operations written to the buffer is
    154  *           MIN(prhg_nops, requests waiting, space in buffer).
    155  *
    156  *           Operations follow each other and each one is described
    157  *           by the puffs_req structure, which is immediately followed
    158  *           by the aligned request data buffer in preq_buf.  The next
    159  *           puffs_req can be found at preq + preq_buflen.
    160  *
    161  *           Visually, the server should expect:
    162  *
    163  *           |<-- preq_buflen -->|
    164  *           ---------------------------------------------------------------
    165  *           |hdr|  buffer |align|hdr| buffer |hdr| ....   |buffer|        |
    166  *           ---------------------------------------------------------------
    167  *           ^ start       ^ unaligned        ^ aligned    ^ always aligned
    168  *
    169  *           The server is allowed to modify the contents of the buffers.
    170  *           Since the headers are the same size for both get and put, it
    171  *           is possible to handle all operations simply by doing in-place
    172  *           modification.  Where more input is expected that what was put
    173  *           out, the kernel leaves a hole in the buffer.  This hole size
    174  *           is derived from the operational semantics known by the vnode
    175  *           layer.  The hole size is included in preq_buflen.  The
    176  *           amount of relevant information in the buffer is call-specific
    177  *           and can be deduced by the server from the call type.
    178  *
    179  *  + PUTOP: When returning the results of an operation to the kernel, the
    180  *           user server is allowed to input results in a scatter-gather
    181  *           fashion.  Each request is made up of a header and the buffer.
    182  *           The header describes the *NEXT* request for copyin, *NOT* the
    183  *           current one.  The first request is described in puffs_reqh_put
    184  *           and the last one is left uninterpreted.  This is to halve the
    185  *           amount of copyin's required.
    186  *
    187  *           Fans of my ascii art, rejoice:
    188  *               /-------------------->| preq_buflen     |
    189  *           ---^----------------------------------------------------------
    190  *           |hdr|buffer| empty spaces |hdr|    buffer   |                |
    191  *           --v-----------------------^-v---------------------------------
    192  *             \------- preq_buf -----/  \------- preq_buf ....
    193  *
    194  *           This scheme also allows for better in-place modification of the
    195  *           request buffer when handling requests.  The vision is that
    196  *           operations which can be immediately satisfied will be edited
    197  *           in-place while ones which can't will be left blank.  Also,
    198  *           requests from async operations which have been satisfied
    199  *           meanwhile can be included.
    200  *
    201  *           The total number of operations is given by the ioctl control
    202  *           structure puffs_reqh.  The values in the header in the final
    203  *           are not used.
    204  */
    205 struct puffs_req {
    206 	uint64_t	preq_id;		/* get: cur, put: next */
    207 
    208 	union u {
    209 		struct {
    210 			uint8_t	opclass;	/* cur */
    211 			uint8_t	optype;		/* cur */
    212 
    213 			/*
    214 			 * preq_cookie is the node cookie associated with
    215 			 * the request.  It always maps 1:1 to a vnode
    216 			 * and could map to a userspace struct puffs_node.
    217 			 * The cookie usually describes the first
    218 			 * vnode argument of the VOP_POP() in question.
    219 			 */
    220 
    221 			void	*cookie;	/* cur */
    222 		} out;
    223 		struct {
    224 			int	rv;		/* cur */
    225 			int	setbacks;	/* cur */
    226 			void	*buf;		/* next */
    227 		} in;
    228 	} u;
    229 
    230 	size_t  preq_buflen;			/* get: cur, put: next */
    231 	/*
    232 	 * the following helper pads the struct size to md alignment
    233 	 * multiple (should size_t not cut it).  it makes sure that
    234 	 * whatever comes after this struct is aligned
    235 	 */
    236 	uint8_t	preq_buf[0] __aligned(ALIGNBYTES+1);
    237 };
    238 #define preq_opclass	u.out.opclass
    239 #define preq_optype	u.out.optype
    240 #define preq_cookie	u.out.cookie
    241 #define preq_rv		u.in.rv
    242 #define preq_setbacks	u.in.setbacks
    243 #define preq_nextbuf	u.in.buf
    244 
    245 #define PUFFS_SETBACK_INACT_N1	0x01	/* set VOP_INACTIVE for node 1 */
    246 #define PUFFS_SETBACK_INACT_N2	0x02	/* set VOP_INACTIVE for node 2 */
    247 #define PUFFS_SETBACK_NOREF_N1	0x04	/* set pn PN_NOREFS for node 1 */
    248 #define PUFFS_SETBACK_NOREF_N2	0x08	/* set pn PN_NOREFS for node 2 */
    249 #define PUFFS_SETBACK_MASK	0x0f
    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_kcred {
    311 	struct uucred	pkcr_uuc;
    312 	uint8_t		pkcr_type;
    313 	uint8_t		pkcr_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 /* caller id */
    330 struct puffs_kcid {
    331 	int	pkcid_type;
    332 	pid_t	pkcid_pid;
    333 	lwpid_t	pkcid_lwpid;
    334 };
    335 #define PUFFCID_TYPE_REAL	1
    336 #define PUFFCID_TYPE_FAKE	2
    337 
    338 /* puffs struct componentname built by kernel */
    339 struct puffs_kcn {
    340 	/* args */
    341 	u_long			pkcn_nameiop;	/* namei operation	*/
    342 	u_long			pkcn_flags;	/* flags		*/
    343 
    344 	char pkcn_name[MAXPATHLEN+1];  /* nul-terminated path component	*/
    345 	long pkcn_namelen;
    346 };
    347 
    348 /*
    349  * XXX: figure out what to do with these, copied from namei.h for now
    350  */
    351 #define	PUFFSLOOKUP_LOOKUP	0	/* perform name lookup only */
    352 #define PUFFSLOOKUP_CREATE	1	/* setup for file creation */
    353 #define PUFFSLOOKUP_DELETE	2	/* setup for file deletion */
    354 #define PUFFSLOOKUP_RENAME	3	/* setup for file renaming */
    355 #define PUFFSLOOKUP_OPMASK	3	/* mask for operation */
    356 
    357 #define PUFFSLOOKUP_FOLLOW	0x00004	/* follow final symlink */
    358 #define PUFFSLOOKUP_NOFOLLOW	0x00008	/* don't follow final symlink */
    359 #define PUFFSLOOKUP_ISLASTCN	0x08000 /* is last component of lookup */
    360 
    361 
    362 /*
    363  * Next come the individual requests.  They are all subclassed from
    364  * puffs_req and contain request-specific fields in addition.  Note
    365  * that there are some requests which have to handle arbitrary-length
    366  * buffers.
    367  *
    368  * The division is the following: puffs_req is to be touched only
    369  * by generic routines while the other stuff is supposed to be
    370  * modified only by specific routines.
    371  */
    372 
    373 /*
    374  * aux structures for vfs operations.
    375  */
    376 struct puffs_vfsreq_unmount {
    377 	struct puffs_req	pvfsr_pr;
    378 
    379 	int			pvfsr_flags;
    380 	struct puffs_kcid	pvfsr_cid;
    381 };
    382 
    383 struct puffs_vfsreq_statvfs {
    384 	struct puffs_req	pvfsr_pr;
    385 
    386 	struct statvfs		pvfsr_sb;
    387 	struct puffs_kcid	pvfsr_cid;
    388 };
    389 
    390 struct puffs_vfsreq_sync {
    391 	struct puffs_req	pvfsr_pr;
    392 
    393 	struct puffs_kcred	pvfsr_cred;
    394 	struct puffs_kcid	pvfsr_cid;
    395 	int			pvfsr_waitfor;
    396 };
    397 
    398 struct puffs_vfsreq_fhtonode {
    399 	struct puffs_req	pvfsr_pr;
    400 
    401 	void			*pvfsr_fhcookie;	/* IN	*/
    402 	enum vtype		pvfsr_vtype;		/* IN	*/
    403 	voff_t			pvfsr_size;		/* IN	*/
    404 	dev_t			pvfsr_rdev;		/* IN	*/
    405 
    406 	size_t			pvfsr_dsize;		/* OUT */
    407 	uint8_t			pvfsr_data[0]		/* OUT, XXX */
    408 				    __aligned(ALIGNBYTES+1);
    409 };
    410 
    411 struct puffs_vfsreq_nodetofh {
    412 	struct puffs_req	pvfsr_pr;
    413 
    414 	void			*pvfsr_fhcookie;	/* OUT	*/
    415 
    416 	size_t			pvfsr_dsize;		/* OUT/IN  */
    417 	uint8_t			pvfsr_data[0]		/* IN, XXX */
    418 				    __aligned(ALIGNBYTES+1);
    419 };
    420 
    421 struct puffs_vfsreq_suspend {
    422 	struct puffs_req	pvfsr_pr;
    423 
    424 	int			pvfsr_status;
    425 };
    426 #define PUFFS_SUSPEND_START	0
    427 #define PUFFS_SUSPEND_SUSPENDED	1
    428 #define PUFFS_SUSPEND_RESUME	2
    429 #define PUFFS_SUSPEND_ERROR	3
    430 
    431 /*
    432  * aux structures for vnode operations.
    433  */
    434 
    435 struct puffs_vnreq_lookup {
    436 	struct puffs_req	pvn_pr;
    437 
    438 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    439 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
    440 	struct puffs_kcid	pvnr_cn_cid;		/* OUT	*/
    441 
    442 	void			*pvnr_newnode;		/* IN	*/
    443 	enum vtype		pvnr_vtype;		/* IN	*/
    444 	voff_t			pvnr_size;		/* IN	*/
    445 	dev_t			pvnr_rdev;		/* IN	*/
    446 };
    447 
    448 struct puffs_vnreq_create {
    449 	struct puffs_req	pvn_pr;
    450 
    451 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    452 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
    453 	struct puffs_kcid	pvnr_cn_cid;		/* OUT	*/
    454 
    455 	struct vattr		pvnr_va;		/* OUT	*/
    456 	void			*pvnr_newnode;		/* IN	*/
    457 };
    458 
    459 struct puffs_vnreq_mknod {
    460 	struct puffs_req	pvn_pr;
    461 
    462 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    463 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
    464 	struct puffs_kcid	pvnr_cn_cid;		/* OUT	*/
    465 
    466 	struct vattr		pvnr_va;		/* OUT	*/
    467 	void			*pvnr_newnode;		/* IN	*/
    468 };
    469 
    470 struct puffs_vnreq_open {
    471 	struct puffs_req	pvn_pr;
    472 
    473 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
    474 	struct puffs_kcid	pvnr_cid;		/* OUT	*/
    475 	int			pvnr_mode;		/* OUT	*/
    476 };
    477 
    478 struct puffs_vnreq_close {
    479 	struct puffs_req	pvn_pr;
    480 
    481 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
    482 	struct puffs_kcid	pvnr_cid;		/* OUT	*/
    483 	int			pvnr_fflag;		/* OUT	*/
    484 };
    485 
    486 struct puffs_vnreq_access {
    487 	struct puffs_req	pvn_pr;
    488 
    489 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
    490 	struct puffs_kcid	pvnr_cid;		/* OUT	*/
    491 	int			pvnr_mode;		/* OUT	*/
    492 };
    493 
    494 #define puffs_vnreq_setattr puffs_vnreq_setgetattr
    495 #define puffs_vnreq_getattr puffs_vnreq_setgetattr
    496 struct puffs_vnreq_setgetattr {
    497 	struct puffs_req	pvn_pr;
    498 
    499 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
    500 	struct puffs_kcid	pvnr_cid;		/* OUT	*/
    501 	struct vattr		pvnr_va;		/* IN/OUT (op depend) */
    502 };
    503 
    504 #define puffs_vnreq_read puffs_vnreq_readwrite
    505 #define puffs_vnreq_write puffs_vnreq_readwrite
    506 struct puffs_vnreq_readwrite {
    507 	struct puffs_req	pvn_pr;
    508 
    509 	struct puffs_kcred	pvnr_cred;		/* OUT	  */
    510 	off_t			pvnr_offset;		/* OUT	  */
    511 	size_t			pvnr_resid;		/* IN/OUT */
    512 	int			pvnr_ioflag;		/* OUT	  */
    513 
    514 	uint8_t			pvnr_data[0];		/* IN/OUT (wr/rd) */
    515 };
    516 
    517 #define puffs_vnreq_ioctl puffs_vnreq_fcnioctl
    518 #define puffs_vnreq_fcntl puffs_vnreq_fcnioctl
    519 struct puffs_vnreq_fcnioctl {
    520 	struct puffs_req	pvn_pr;
    521 
    522 	struct puffs_kcred	pvnr_cred;
    523 	u_long			pvnr_command;
    524 	pid_t			pvnr_pid;
    525 	int			pvnr_fflag;
    526 
    527 	void			*pvnr_data;
    528 	size_t			pvnr_datalen;
    529 	int			pvnr_copyback;
    530 };
    531 
    532 struct puffs_vnreq_poll {
    533 	struct puffs_req	pvn_pr;
    534 
    535 	int			pvnr_events;		/* IN/OUT */
    536 	struct puffs_kcid	pvnr_cid;		/* OUT    */
    537 };
    538 
    539 struct puffs_vnreq_fsync {
    540 	struct puffs_req	pvn_pr;
    541 
    542 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
    543 	struct puffs_kcid	pvnr_cid;		/* OUT	*/
    544 	off_t			pvnr_offlo;		/* OUT	*/
    545 	off_t			pvnr_offhi;		/* OUT	*/
    546 	int			pvnr_flags;		/* OUT	*/
    547 };
    548 
    549 struct puffs_vnreq_seek {
    550 	struct puffs_req	pvn_pr;
    551 
    552 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
    553 	off_t			pvnr_oldoff;		/* OUT	*/
    554 	off_t			pvnr_newoff;		/* OUT	*/
    555 };
    556 
    557 struct puffs_vnreq_remove {
    558 	struct puffs_req	pvn_pr;
    559 
    560 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    561 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
    562 	struct puffs_kcid	pvnr_cn_cid;		/* OUT	*/
    563 
    564 	void			*pvnr_cookie_targ;	/* OUT	*/
    565 };
    566 
    567 struct puffs_vnreq_mkdir {
    568 	struct puffs_req	pvn_pr;
    569 
    570 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    571 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
    572 	struct puffs_kcid	pvnr_cn_cid;		/* OUT	*/
    573 
    574 	struct vattr		pvnr_va;		/* OUT	*/
    575 	void			*pvnr_newnode;		/* IN	*/
    576 };
    577 
    578 struct puffs_vnreq_rmdir {
    579 	struct puffs_req	pvn_pr;
    580 
    581 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    582 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
    583 	struct puffs_kcid	pvnr_cn_cid;		/* OUT	*/
    584 
    585 	void			*pvnr_cookie_targ;	/* OUT	*/
    586 };
    587 
    588 struct puffs_vnreq_link {
    589 	struct puffs_req	pvn_pr;
    590 
    591 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    592 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
    593 	struct puffs_kcid	pvnr_cn_cid;		/* OUT	*/
    594 
    595 	void			*pvnr_cookie_targ;	/* OUT	*/
    596 };
    597 
    598 struct puffs_vnreq_rename {
    599 	struct puffs_req	pvn_pr;
    600 
    601 	struct puffs_kcn	pvnr_cn_src;		/* OUT	*/
    602 	struct puffs_kcred	pvnr_cn_src_cred;	/* OUT	*/
    603 	struct puffs_kcid	pvnr_cn_src_cid;	/* OUT	*/
    604 	struct puffs_kcn	pvnr_cn_targ;		/* OUT	*/
    605 	struct puffs_kcred	pvnr_cn_targ_cred;	/* OUT	*/
    606 	struct puffs_kcid	pvnr_cn_targ_cid;	/* OUT	*/
    607 
    608 	void			*pvnr_cookie_src;	/* OUT	*/
    609 	void			*pvnr_cookie_targ;	/* OUT	*/
    610 	void			*pvnr_cookie_targdir;	/* OUT	*/
    611 };
    612 
    613 struct puffs_vnreq_symlink {
    614 	struct puffs_req	pvn_pr;
    615 
    616 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    617 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
    618 	struct puffs_kcid	pvnr_cn_cid;		/* OUT	*/
    619 
    620 	struct vattr		pvnr_va;		/* OUT	*/
    621 	void			*pvnr_newnode;		/* IN	*/
    622 	char			pvnr_link[MAXPATHLEN];	/* OUT	*/
    623 };
    624 
    625 struct puffs_vnreq_readdir {
    626 	struct puffs_req	pvn_pr;
    627 
    628 	struct puffs_kcred	pvnr_cred;		/* OUT	  */
    629 	off_t			pvnr_offset;		/* IN/OUT */
    630 	size_t			pvnr_resid;		/* IN/OUT */
    631 	size_t			pvnr_ncookies;		/* IN/OUT */
    632 	int			pvnr_eofflag;		/* IN     */
    633 
    634 	size_t			pvnr_dentoff;		/* OUT    */
    635 	uint8_t			pvnr_data[0]		/* IN  	  */
    636 				    __aligned(ALIGNBYTES+1);
    637 };
    638 
    639 struct puffs_vnreq_readlink {
    640 	struct puffs_req	pvn_pr;
    641 
    642 	struct puffs_kcred	pvnr_cred;		/* OUT */
    643 	size_t			pvnr_linklen;		/* IN  */
    644 	char			pvnr_link[MAXPATHLEN];	/* IN, XXX  */
    645 };
    646 
    647 struct puffs_vnreq_reclaim {
    648 	struct puffs_req	pvn_pr;
    649 
    650 	struct puffs_kcid	pvnr_cid;		/* OUT	*/
    651 };
    652 
    653 struct puffs_vnreq_inactive {
    654 	struct puffs_req	pvn_pr;
    655 
    656 	struct puffs_kcid	pvnr_cid;		/* OUT	*/
    657 	int			pvnr_backendrefs;	/* IN	*/
    658 };
    659 
    660 struct puffs_vnreq_print {
    661 	struct puffs_req	pvn_pr;
    662 
    663 	/* empty */
    664 };
    665 
    666 struct puffs_vnreq_pathconf {
    667 	struct puffs_req	pvn_pr;
    668 
    669 	int			pvnr_name;		/* OUT	*/
    670 	int			pvnr_retval;		/* IN	*/
    671 };
    672 
    673 struct puffs_vnreq_advlock {
    674 	struct puffs_req	pvn_pr;
    675 
    676 	struct flock		pvnr_fl;		/* OUT	*/
    677 	void			*pvnr_id;		/* OUT	*/
    678 	int			pvnr_op;		/* OUT	*/
    679 	int			pvnr_flags;		/* OUT	*/
    680 };
    681 
    682 struct puffs_vnreq_mmap {
    683 	struct puffs_req	pvn_pr;
    684 
    685 	int			pvnr_fflags;		/* OUT	*/
    686 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
    687 	struct puffs_kcid	pvnr_cid;		/* OUT	*/
    688 };
    689 
    690 
    691 /*
    692  * For cache reports.  Everything is always out-out-out, no replies
    693  */
    694 
    695 struct puffs_cacherun {
    696 	off_t			pcache_runstart;
    697 	off_t			pcache_runend;
    698 };
    699 
    700 /* cache info.  old used for write now */
    701 struct puffs_cacheinfo {
    702 	struct puffs_req	pcache_pr;
    703 
    704 	int			pcache_type;
    705 	size_t			pcache_nruns;
    706 	struct puffs_cacherun	pcache_runs[0];
    707 };
    708 #define PCACHE_TYPE_READ	0
    709 #define PCACHE_TYPE_WRITE	1
    710 
    711 /* notyet */
    712 #if 0
    713 struct puffs_vnreq_kqfilter { };
    714 struct puffs_vnreq_islocked { };
    715 #endif
    716 struct puffs_vnreq_getextattr { };
    717 struct puffs_vnreq_setextattr { };
    718 struct puffs_vnreq_listextattr { };
    719 
    720 #ifdef _KERNEL
    721 #define PUFFS_VFSREQ(a)							\
    722 	struct puffs_vfsreq_##a a##_arg;				\
    723 	memset(&a##_arg, 0, sizeof(struct puffs_vfsreq_##a))
    724 
    725 #define PUFFS_VNREQ(a)							\
    726 	struct puffs_vnreq_##a a##_arg;					\
    727 	memset(&a##_arg, 0, sizeof(struct puffs_vnreq_##a))
    728 #endif
    729 
    730 #endif /* _PUFFS_MSGIF_H_ */
    731