Home | History | Annotate | Line # | Download | only in puffs
puffs_msgif.h revision 1.32
      1 /*	$NetBSD: puffs_msgif.h,v 1.32 2007/05/18 15:46:09 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_NOREF_N1	0x04	/* set pn PN_NOREFS for node 1 */
    250 #define PUFFS_SETBACK_NOREF_N2	0x08	/* set pn PN_NOREFS for node 2 */
    251 #define PUFFS_SETBACK_MASK	0x0f
    252 
    253 /*
    254  * Some operations have unknown size requirements.  So as the first
    255  * stab at handling it, do an extra bounce between the kernel and
    256  * userspace.
    257  */
    258 struct puffs_sizeop {
    259 	uint64_t	pso_reqid;
    260 
    261 	uint8_t		*pso_userbuf;
    262 	size_t		pso_bufsize;
    263 };
    264 
    265 /*
    266  * Flush operation.  This can be used to invalidate:
    267  * 1) name cache for one node
    268  * 2) name cache for all children
    269  * 3) name cache for the entire mount
    270  * 4) page cache for a set of ranges in one node
    271  * 5) page cache for one entire node
    272  *
    273  * It can be used to flush:
    274  * 1) page cache for a set of ranges in one node
    275  * 2) page cache for one entire node
    276  */
    277 
    278 /* XXX: needs restructuring */
    279 struct puffs_flush {
    280 	void		*pf_cookie;
    281 
    282 	int		pf_op;
    283 	off_t		pf_start;
    284 	off_t		pf_end;
    285 };
    286 #define PUFFS_INVAL_NAMECACHE_NODE		0
    287 #define PUFFS_INVAL_NAMECACHE_DIR		1
    288 #define PUFFS_INVAL_NAMECACHE_ALL		2
    289 #define PUFFS_INVAL_PAGECACHE_NODE_RANGE	3
    290 #define PUFFS_FLUSH_PAGECACHE_NODE_RANGE	4
    291 
    292 
    293 /*
    294  * Available ioctl operations
    295  */
    296 #define PUFFSGETOP		_IOWR('p', 1, struct puffs_reqh_get)
    297 #define PUFFSPUTOP		_IOWR('p', 2, struct puffs_reqh_put)
    298 #define PUFFSSIZEOP		_IOWR('p', 3, struct puffs_sizeop)
    299 #define PUFFSFLUSHOP		_IOW ('p', 4, struct puffs_flush)
    300 #if 0
    301 #define PUFFSFLUSHMULTIOP	_IOW ('p', 5, struct puffs_flushmulti)
    302 #endif
    303 #define PUFFSSUSPENDOP		_IO  ('p', 6)
    304 
    305 
    306 /*
    307  * Credentials for an operation.  Can be either struct uucred for
    308  * ops called from a credential context or NOCRED/FSCRED for ops
    309  * called from within the kernel.  It is up to the implementation
    310  * if it makes a difference between these two and the super-user.
    311  */
    312 struct puffs_cred {
    313 	struct uucred	pcr_uuc;
    314 	uint8_t		pcr_type;
    315 	uint8_t		pcr_internal;
    316 };
    317 #define PUFFCRED_TYPE_UUC	1
    318 #define PUFFCRED_TYPE_INTERNAL	2
    319 #define PUFFCRED_CRED_NOCRED	1
    320 #define PUFFCRED_CRED_FSCRED	2
    321 
    322 /*
    323  * 2*MAXPHYS is the max size the system will attempt to copy,
    324  * else treated as garbage
    325  */
    326 #define PUFFS_REQ_MAXSIZE	2*MAXPHYS
    327 #define PUFFS_REQSTRUCT_MAX	4096 /* XXX: approxkludge */
    328 
    329 #define PUFFS_TOMOVE(a,b) (MIN((a), b->pmp_req_maxsize - PUFFS_REQSTRUCT_MAX))
    330 
    331 /* puffs struct componentname built by kernel */
    332 struct puffs_kcn {
    333 	/* args */
    334 	u_long			pkcn_nameiop;	/* namei operation	*/
    335 	u_long			pkcn_flags;	/* flags		*/
    336 	pid_t			pkcn_pid;	/* caller pid		*/
    337 	struct puffs_cred	pkcn_cred;	/* caller creds		*/
    338 
    339 	char pkcn_name[MAXPATHLEN+1];  /* nul-terminated path component	*/
    340 	long pkcn_namelen;
    341 };
    342 
    343 /*
    344  * XXX: figure out what to do with these, copied from namei.h for now
    345  */
    346 #define	PUFFSLOOKUP_LOOKUP	0	/* perform name lookup only */
    347 #define PUFFSLOOKUP_CREATE	1	/* setup for file creation */
    348 #define PUFFSLOOKUP_DELETE	2	/* setup for file deletion */
    349 #define PUFFSLOOKUP_RENAME	3	/* setup for file renaming */
    350 #define PUFFSLOOKUP_OPMASK	3	/* mask for operation */
    351 
    352 #define PUFFSLOOKUP_FOLLOW	0x00004	/* follow final symlink */
    353 #define PUFFSLOOKUP_NOFOLLOW	0x00008	/* don't follow final symlink */
    354 #define PUFFSLOOKUP_ISLASTCN	0x08000 /* is last component of lookup */
    355 
    356 
    357 /*
    358  * Next come the individual requests.  They are all subclassed from
    359  * puffs_req and contain request-specific fields in addition.  Note
    360  * that there are some requests which have to handle arbitrary-length
    361  * buffers.
    362  *
    363  * The division is the following: puffs_req is to be touched only
    364  * by generic routines while the other stuff is supposed to be
    365  * modified only by specific routines.
    366  */
    367 
    368 /*
    369  * aux structures for vfs operations.
    370  */
    371 struct puffs_vfsreq_unmount {
    372 	struct puffs_req	pvfsr_pr;
    373 
    374 	int			pvfsr_flags;
    375 	pid_t			pvfsr_pid;
    376 };
    377 
    378 struct puffs_vfsreq_statvfs {
    379 	struct puffs_req	pvfsr_pr;
    380 
    381 	struct statvfs		pvfsr_sb;
    382 	pid_t			pvfsr_pid;
    383 };
    384 
    385 struct puffs_vfsreq_sync {
    386 	struct puffs_req	pvfsr_pr;
    387 
    388 	struct puffs_cred	pvfsr_cred;
    389 	pid_t			pvfsr_pid;
    390 	int			pvfsr_waitfor;
    391 };
    392 
    393 struct puffs_vfsreq_fhtonode {
    394 	struct puffs_req	pvfsr_pr;
    395 
    396 	void			*pvfsr_fhcookie;	/* IN	*/
    397 	enum vtype		pvfsr_vtype;		/* IN	*/
    398 	voff_t			pvfsr_size;		/* IN	*/
    399 	dev_t			pvfsr_rdev;		/* IN	*/
    400 
    401 	size_t			pvfsr_dsize;		/* OUT */
    402 	uint8_t			pvfsr_data[0]		/* OUT, XXX */
    403 				    __aligned(ALIGNBYTES+1);
    404 };
    405 
    406 struct puffs_vfsreq_nodetofh {
    407 	struct puffs_req	pvfsr_pr;
    408 
    409 	void			*pvfsr_fhcookie;	/* OUT	*/
    410 
    411 	size_t			pvfsr_dsize;		/* OUT/IN  */
    412 	uint8_t			pvfsr_data[0]		/* IN, XXX */
    413 				    __aligned(ALIGNBYTES+1);
    414 };
    415 
    416 struct puffs_vfsreq_suspend {
    417 	struct puffs_req	pvfsr_pr;
    418 
    419 	int			pvfsr_status;
    420 };
    421 #define PUFFS_SUSPEND_START	0
    422 #define PUFFS_SUSPEND_SUSPENDED	1
    423 #define PUFFS_SUSPEND_RESUME	2
    424 #define PUFFS_SUSPEND_ERROR	3
    425 
    426 /*
    427  * aux structures for vnode operations.
    428  */
    429 
    430 struct puffs_vnreq_lookup {
    431 	struct puffs_req	pvn_pr;
    432 
    433 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    434 	void			*pvnr_newnode;		/* IN	*/
    435 	enum vtype		pvnr_vtype;		/* IN	*/
    436 	voff_t			pvnr_size;		/* IN	*/
    437 	dev_t			pvnr_rdev;		/* IN	*/
    438 };
    439 
    440 struct puffs_vnreq_create {
    441 	struct puffs_req	pvn_pr;
    442 
    443 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    444 	struct vattr		pvnr_va;		/* OUT	*/
    445 	void			*pvnr_newnode;		/* IN	*/
    446 };
    447 
    448 struct puffs_vnreq_mknod {
    449 	struct puffs_req	pvn_pr;
    450 
    451 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    452 	struct vattr		pvnr_va;		/* OUT	*/
    453 	void			*pvnr_newnode;		/* IN	*/
    454 };
    455 
    456 struct puffs_vnreq_open {
    457 	struct puffs_req	pvn_pr;
    458 
    459 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    460 	pid_t			pvnr_pid;		/* OUT	*/
    461 	int			pvnr_mode;		/* OUT	*/
    462 };
    463 
    464 struct puffs_vnreq_close {
    465 	struct puffs_req	pvn_pr;
    466 
    467 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    468 	pid_t			pvnr_pid;		/* OUT	*/
    469 	int			pvnr_fflag;		/* OUT	*/
    470 };
    471 
    472 struct puffs_vnreq_access {
    473 	struct puffs_req	pvn_pr;
    474 
    475 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    476 	pid_t			pvnr_pid;		/* OUT	*/
    477 	int			pvnr_mode;		/* OUT	*/
    478 };
    479 
    480 #define puffs_vnreq_setattr puffs_vnreq_setgetattr
    481 #define puffs_vnreq_getattr puffs_vnreq_setgetattr
    482 struct puffs_vnreq_setgetattr {
    483 	struct puffs_req	pvn_pr;
    484 
    485 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    486 	struct vattr		pvnr_va;		/* IN/OUT (op depend) */
    487 	pid_t			pvnr_pid;		/* OUT	*/
    488 };
    489 
    490 #define puffs_vnreq_read puffs_vnreq_readwrite
    491 #define puffs_vnreq_write puffs_vnreq_readwrite
    492 struct puffs_vnreq_readwrite {
    493 	struct puffs_req	pvn_pr;
    494 
    495 	struct puffs_cred	pvnr_cred;		/* OUT	  */
    496 	off_t			pvnr_offset;		/* OUT	  */
    497 	size_t			pvnr_resid;		/* IN/OUT */
    498 	int			pvnr_ioflag;		/* OUT	  */
    499 
    500 	uint8_t			pvnr_data[0];		/* IN/OUT (wr/rd) */
    501 };
    502 
    503 #define puffs_vnreq_ioctl puffs_vnreq_fcnioctl
    504 #define puffs_vnreq_fcntl puffs_vnreq_fcnioctl
    505 struct puffs_vnreq_fcnioctl {
    506 	struct puffs_req	pvn_pr;
    507 
    508 	struct puffs_cred	pvnr_cred;
    509 	u_long			pvnr_command;
    510 	pid_t			pvnr_pid;
    511 	int			pvnr_fflag;
    512 
    513 	void			*pvnr_data;
    514 	size_t			pvnr_datalen;
    515 	int			pvnr_copyback;
    516 };
    517 
    518 struct puffs_vnreq_poll {
    519 	struct puffs_req	pvn_pr;
    520 
    521 	int			pvnr_events;		/* IN/OUT */
    522 	pid_t			pvnr_pid;		/* OUT	  */
    523 };
    524 
    525 struct puffs_vnreq_fsync {
    526 	struct puffs_req	pvn_pr;
    527 
    528 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    529 	off_t			pvnr_offlo;		/* OUT	*/
    530 	off_t			pvnr_offhi;		/* OUT	*/
    531 	pid_t			pvnr_pid;		/* OUT	*/
    532 	int			pvnr_flags;		/* OUT	*/
    533 };
    534 
    535 struct puffs_vnreq_seek {
    536 	struct puffs_req	pvn_pr;
    537 
    538 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    539 	off_t			pvnr_oldoff;		/* OUT	*/
    540 	off_t			pvnr_newoff;		/* OUT	*/
    541 };
    542 
    543 struct puffs_vnreq_remove {
    544 	struct puffs_req	pvn_pr;
    545 
    546 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    547 	void			*pvnr_cookie_targ;	/* OUT	*/
    548 };
    549 
    550 struct puffs_vnreq_mkdir {
    551 	struct puffs_req	pvn_pr;
    552 
    553 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    554 	struct vattr		pvnr_va;		/* OUT	*/
    555 	void			*pvnr_newnode;		/* IN	*/
    556 };
    557 
    558 struct puffs_vnreq_rmdir {
    559 	struct puffs_req	pvn_pr;
    560 
    561 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    562 	void			*pvnr_cookie_targ;	/* OUT	*/
    563 };
    564 
    565 struct puffs_vnreq_link {
    566 	struct puffs_req	pvn_pr;
    567 
    568 	struct puffs_kcn	pvnr_cn;		/* OUT */
    569 	void			*pvnr_cookie_targ;	/* OUT */
    570 };
    571 
    572 struct puffs_vnreq_rename {
    573 	struct puffs_req	pvn_pr;
    574 
    575 	struct puffs_kcn	pvnr_cn_src;		/* OUT	*/
    576 	struct puffs_kcn	pvnr_cn_targ;		/* OUT	*/
    577 	void			*pvnr_cookie_src;	/* OUT	*/
    578 	void			*pvnr_cookie_targ;	/* OUT	*/
    579 	void			*pvnr_cookie_targdir;	/* OUT	*/
    580 };
    581 
    582 struct puffs_vnreq_symlink {
    583 	struct puffs_req	pvn_pr;
    584 
    585 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
    586 	struct vattr		pvnr_va;		/* OUT	*/
    587 	void			*pvnr_newnode;		/* IN	*/
    588 	char			pvnr_link[MAXPATHLEN];	/* OUT	*/
    589 };
    590 
    591 struct puffs_vnreq_readdir {
    592 	struct puffs_req	pvn_pr;
    593 
    594 	struct puffs_cred	pvnr_cred;		/* OUT	  */
    595 	off_t			pvnr_offset;		/* IN/OUT */
    596 	size_t			pvnr_resid;		/* IN/OUT */
    597 	size_t			pvnr_ncookies;		/* IN/OUT */
    598 	int			pvnr_eofflag;		/* IN     */
    599 
    600 	size_t			pvnr_dentoff;		/* OUT    */
    601 	uint8_t			pvnr_data[0]		/* IN  	  */
    602 				    __aligned(ALIGNBYTES+1);
    603 };
    604 
    605 struct puffs_vnreq_readlink {
    606 	struct puffs_req	pvn_pr;
    607 
    608 	struct puffs_cred	pvnr_cred;		/* OUT */
    609 	size_t			pvnr_linklen;		/* IN  */
    610 	char			pvnr_link[MAXPATHLEN];	/* IN, XXX  */
    611 };
    612 
    613 struct puffs_vnreq_reclaim {
    614 	struct puffs_req	pvn_pr;
    615 
    616 	pid_t			pvnr_pid;		/* OUT	*/
    617 };
    618 
    619 struct puffs_vnreq_inactive {
    620 	struct puffs_req	pvn_pr;
    621 
    622 	pid_t			pvnr_pid;		/* OUT	*/
    623 	int			pvnr_backendrefs;	/* IN	*/
    624 };
    625 
    626 struct puffs_vnreq_print {
    627 	struct puffs_req	pvn_pr;
    628 
    629 	/* empty */
    630 };
    631 
    632 struct puffs_vnreq_pathconf {
    633 	struct puffs_req	pvn_pr;
    634 
    635 	int			pvnr_name;		/* OUT	*/
    636 	int			pvnr_retval;		/* IN	*/
    637 };
    638 
    639 struct puffs_vnreq_advlock {
    640 	struct puffs_req	pvn_pr;
    641 
    642 	struct flock		pvnr_fl;		/* OUT	*/
    643 	void			*pvnr_id;		/* OUT	*/
    644 	int			pvnr_op;		/* OUT	*/
    645 	int			pvnr_flags;		/* OUT	*/
    646 };
    647 
    648 struct puffs_vnreq_mmap {
    649 	struct puffs_req	pvn_pr;
    650 
    651 	int			pvnr_fflags;		/* OUT	*/
    652 	struct puffs_cred	pvnr_cred;		/* OUT	*/
    653 	pid_t			pvnr_pid;		/* OUT	*/
    654 };
    655 
    656 
    657 /*
    658  * For cache reports.  Everything is always out-out-out, no replies
    659  */
    660 
    661 struct puffs_cacherun {
    662 	off_t			pcache_runstart;
    663 	off_t			pcache_runend;
    664 };
    665 
    666 /* cache info.  old used for write now */
    667 struct puffs_cacheinfo {
    668 	struct puffs_req	pcache_pr;
    669 
    670 	int			pcache_type;
    671 	size_t			pcache_nruns;
    672 	struct puffs_cacherun	pcache_runs[0];
    673 };
    674 #define PCACHE_TYPE_READ	0
    675 #define PCACHE_TYPE_WRITE	1
    676 
    677 /* notyet */
    678 #if 0
    679 struct puffs_vnreq_kqfilter { };
    680 struct puffs_vnreq_islocked { };
    681 #endif
    682 struct puffs_vnreq_getextattr { };
    683 struct puffs_vnreq_setextattr { };
    684 struct puffs_vnreq_listextattr { };
    685 
    686 #ifdef _KERNEL
    687 #define PUFFS_VFSREQ(a)							\
    688 	struct puffs_vfsreq_##a a##_arg;				\
    689 	memset(&a##_arg, 0, sizeof(struct puffs_vfsreq_##a))
    690 
    691 #define PUFFS_VNREQ(a)							\
    692 	struct puffs_vnreq_##a a##_arg;					\
    693 	memset(&a##_arg, 0, sizeof(struct puffs_vnreq_##a))
    694 #endif
    695 
    696 #endif /* _PUFFS_MSGIF_H_ */
    697