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