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