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