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