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