xref: /netbsd/sys/fs/puffs/puffs_msgif.h (revision dfe5bcf7)
1 /*	$NetBSD: puffs_msgif.h,v 1.87 2021/12/03 13:08:10 pho Exp $	*/
2 
3 /*
4  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
5  *
6  * Development of this software was supported by the
7  * Google Summer of Code program and the Ulla Tuominen Foundation.
8  * The Google SoC project was mentored by Bill Studenmund.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
20  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 
32 #ifndef _FS_PUFFS_PUFFS_MSGIF_H_
33 #define _FS_PUFFS_PUFFS_MSGIF_H_
34 
35 #include <sys/param.h>
36 #include <sys/time.h>
37 #include <sys/ioccom.h>
38 #include <sys/uio.h>
39 #include <sys/vnode.h>
40 #include <sys/ucred.h>
41 #include <sys/statvfs.h>
42 #include <sys/dirent.h>
43 #include <sys/fcntl.h>
44 
45 #include <dev/putter/putter.h>
46 
47 #include <uvm/uvm_prot.h>
48 
49 #define PUFFSOP_VFS		0x01	/* kernel-> */
50 #define PUFFSOP_VN		0x02	/* kernel-> */
51 #define PUFFSOP_CACHE		0x03	/* only kernel-> */
52 #define PUFFSOP_ERROR		0x04	/* only kernel-> */
53 #define PUFFSOP_FLUSH		0x05	/* ->kernel */
54 #define PUFFSOP_SUSPEND		0x06	/* ->kernel */
55 #define PUFFSOP_UNMOUNT		0x07	/* ->kernel */
56 
57 #define PUFFSOPFLAG_FAF		0x10	/* fire-and-forget */
58 #define PUFFSOPFLAG_ISRESPONSE	0x20	/* req is actually a resp */
59 
60 #define PUFFSOP_OPCMASK		0x07
61 #define PUFFSOP_OPCLASS(a)	((a) & PUFFSOP_OPCMASK)
62 #define PUFFSOP_WANTREPLY(a)	(((a) & PUFFSOPFLAG_FAF) == 0)
63 
64 enum puffs_vfs {
65 	PUFFS_VFS_MOUNT,	PUFFS_VFS_START,	PUFFS_VFS_UNMOUNT,
66 	PUFFS_VFS_ROOT,		PUFFS_VFS_QUOTACTL,	PUFFS_VFS_STATVFS,
67 	PUFFS_VFS_SYNC,		PUFFS_VFS_VGET,		PUFFS_VFS_FHTOVP,
68 	PUFFS_VFS_VPTOFH,	PUFFS_VFS_INIT,		PUFFS_VFS_DONE,
69 	PUFFS_VFS_SNAPSHOT,	PUFFS_VFS_EXTATTRCTL,	PUFFS_VFS_SUSPEND
70 };
71 #define PUFFS_VFS_MAX PUFFS_VFS_SUSPEND
72 
73 enum puffs_vn {
74 	PUFFS_VN_LOOKUP,	PUFFS_VN_CREATE,	PUFFS_VN_MKNOD,
75 	PUFFS_VN_OPEN,		PUFFS_VN_CLOSE,		PUFFS_VN_ACCESS,
76 	PUFFS_VN_GETATTR,	PUFFS_VN_SETATTR,	PUFFS_VN_READ,
77 	PUFFS_VN_WRITE,		PUFFS_VN_IOCTL,		PUFFS_VN_FCNTL,
78 	PUFFS_VN_POLL,		PUFFS_VN_KQFILTER,	PUFFS_VN_REVOKE,
79 	PUFFS_VN_MMAP,		PUFFS_VN_FSYNC,		PUFFS_VN_SEEK,
80 	PUFFS_VN_REMOVE,	PUFFS_VN_LINK,		PUFFS_VN_RENAME,
81 	PUFFS_VN_MKDIR,		PUFFS_VN_RMDIR,		PUFFS_VN_SYMLINK,
82 	PUFFS_VN_READDIR,	PUFFS_VN_READLINK,	PUFFS_VN_ABORTOP,
83 	PUFFS_VN_INACTIVE,	PUFFS_VN_RECLAIM,	PUFFS_VN_LOCK,
84 	PUFFS_VN_UNLOCK,	PUFFS_VN_BMAP,		PUFFS_VN_STRATEGY,
85 	PUFFS_VN_PRINT,		PUFFS_VN_ISLOCKED,	PUFFS_VN_PATHCONF,
86 	PUFFS_VN_ADVLOCK,	PUFFS_VN_LEASE,		PUFFS_VN_WHITEOUT,
87 	PUFFS_VN_GETPAGES,	PUFFS_VN_PUTPAGES,	PUFFS_VN_GETEXTATTR,
88 	PUFFS_VN_LISTEXTATTR,	PUFFS_VN_OPENEXTATTR,	PUFFS_VN_DELETEEXTATTR,
89 	PUFFS_VN_SETEXTATTR,	PUFFS_VN_CLOSEEXTATTR,	PUFFS_VN_FALLOCATE,
90 	PUFFS_VN_FDISCARD,
91 	/* NOTE: If you add an op, decrement PUFFS_VN_SPARE accordingly */
92 };
93 #define PUFFS_VN_MAX PUFFS_VN_FDISCARD
94 #define PUFFS_VN_SPARE 30
95 
96 /*
97  * These signal invalid parameters the file system returned.
98  */
99 enum puffs_err {
100 	PUFFS_ERR_ERROR,
101 	PUFFS_ERR_MAKENODE,	PUFFS_ERR_LOOKUP,	PUFFS_ERR_READDIR,
102 	PUFFS_ERR_READLINK,	PUFFS_ERR_READ,		PUFFS_ERR_WRITE,
103 	PUFFS_ERR_VPTOFH,	PUFFS_ERR_GETEXTATTR,	PUFFS_ERR_LISTEXTATTR
104 };
105 #define PUFFS_ERR_MAX PUFFS_ERR_LISTEXTATTR
106 
107 #define PUFFSVERSION	30
108 #define PUFFSNAMESIZE	32
109 
110 #define PUFFS_TYPEPREFIX "puffs|"
111 
112 #define PUFFS_TYPELEN (_VFS_NAMELEN - (sizeof(PUFFS_TYPEPREFIX)+1))
113 #define PUFFS_NAMELEN (_VFS_MNAMELEN-1)
114 
115 /* really statvfs90 */
116 struct puffs_statvfs {
117 	unsigned long	f_flag;		/* copy of mount exported flags */
118 	unsigned long	f_bsize;	/* file system block size */
119 	unsigned long	f_frsize;	/* fundamental file system block size */
120 	unsigned long	f_iosize;	/* optimal file system block size */
121 
122 	/* The following are in units of f_frsize */
123 	fsblkcnt_t	f_blocks;	/* number of blocks in file system, */
124 	fsblkcnt_t	f_bfree;	/* free blocks avail in file system */
125 	fsblkcnt_t	f_bavail;	/* free blocks avail to non-root */
126 	fsblkcnt_t	f_bresvd;	/* blocks reserved for root */
127 
128 	fsfilcnt_t	f_files;	/* total file nodes in file system */
129 	fsfilcnt_t	f_ffree;	/* free file nodes in file system */
130 	fsfilcnt_t	f_favail;	/* free file nodes avail to non-root */
131 	fsfilcnt_t	f_fresvd;	/* file nodes reserved for root */
132 
133 	uint64_t  	f_syncreads;	/* count of sync reads since mount */
134 	uint64_t  	f_syncwrites;	/* count of sync writes since mount */
135 
136 	uint64_t  	f_asyncreads;	/* count of async reads since mount */
137 	uint64_t  	f_asyncwrites;	/* count of async writes since mount */
138 
139 	fsid_t		f_fsidx;	/* NetBSD compatible fsid */
140 	unsigned long	f_fsid;		/* Posix compatible fsid */
141 	unsigned long	f_namemax;	/* maximum filename length */
142 	uid_t		f_owner;	/* user that mounted the file system */
143 
144 	uint32_t	f_spare[4];	/* spare space */
145 
146 	char	f_fstypename[_VFS_NAMELEN]; /* fs type name */
147 	char	f_mntonname[_VFS_MNAMELEN];  /* directory on which mounted */
148 	char	f_mntfromname[_VFS_MNAMELEN];  /* mounted file system */
149 };
150 
151 #ifndef _KERNEL
152 #include <string.h>
153 #endif
154 
155 static __inline void
statvfs_to_puffs_statvfs(const struct statvfs * s,struct puffs_statvfs * ps)156 statvfs_to_puffs_statvfs(const struct statvfs *s, struct puffs_statvfs *ps)
157 {
158 	ps->f_flag = s->f_flag;
159 	ps->f_bsize = s->f_bsize;
160 	ps->f_frsize = s->f_frsize;
161 	ps->f_iosize = s->f_iosize;
162 
163 	ps->f_blocks = s->f_blocks;
164 	ps->f_bfree = s->f_bfree;
165 	ps->f_bavail = s->f_bavail;
166 	ps->f_bresvd = s->f_bresvd;
167 
168 	ps->f_files = s->f_files;
169 	ps->f_ffree = s->f_ffree;
170 	ps->f_favail = s->f_favail;
171 	ps->f_fresvd = s->f_fresvd;
172 
173 	ps->f_syncreads = s->f_syncreads;
174 	ps->f_syncwrites = s->f_syncwrites;
175 
176 	ps->f_asyncreads = s->f_asyncreads;
177 	ps->f_asyncwrites = s->f_asyncwrites;
178 
179 	ps->f_fsidx = s->f_fsidx;
180 	ps->f_fsid = s->f_fsid;
181 	ps->f_namemax = s->f_namemax;
182 	ps->f_owner = s->f_owner;
183 
184 	memset(ps->f_spare, 0, sizeof(ps->f_spare));
185 
186 	memcpy(ps->f_fstypename, s->f_fstypename, sizeof(ps->f_fstypename));
187 	memcpy(ps->f_mntonname, s->f_mntonname, sizeof(ps->f_mntonname));
188 	memcpy(ps->f_mntfromname, s->f_mntfromname, sizeof(ps->f_mntfromname));
189 }
190 
191 static __inline void
puffs_statvfs_to_statvfs(const struct puffs_statvfs * ps,struct statvfs * s)192 puffs_statvfs_to_statvfs(const struct puffs_statvfs *ps, struct statvfs *s)
193 {
194 	s->f_flag = ps->f_flag;
195 	s->f_bsize = ps->f_bsize;
196 	s->f_frsize = ps->f_frsize;
197 	s->f_iosize = ps->f_iosize;
198 
199 	s->f_blocks = ps->f_blocks;
200 	s->f_bfree = ps->f_bfree;
201 	s->f_bavail = ps->f_bavail;
202 	s->f_bresvd = ps->f_bresvd;
203 
204 	s->f_files = ps->f_files;
205 	s->f_ffree = ps->f_ffree;
206 	s->f_favail = ps->f_favail;
207 	s->f_fresvd = ps->f_fresvd;
208 
209 	s->f_syncreads = ps->f_syncreads;
210 	s->f_syncwrites = ps->f_syncwrites;
211 
212 	s->f_asyncreads = ps->f_asyncreads;
213 	s->f_asyncwrites = ps->f_asyncwrites;
214 
215 	s->f_fsidx = ps->f_fsidx;
216 	s->f_fsid = ps->f_fsid;
217 	s->f_namemax = ps->f_namemax;
218 	s->f_owner = ps->f_owner;
219 
220 	memset(s->f_spare, 0, sizeof(s->f_spare));
221 
222 	memcpy(s->f_fstypename, ps->f_fstypename, sizeof(s->f_fstypename));
223 	memcpy(s->f_mntonname, ps->f_mntonname, sizeof(s->f_mntonname));
224 	memcpy(s->f_mntfromname, ps->f_mntfromname, sizeof(s->f_mntfromname));
225 	memset(s->f_mntfromlabel, 0, sizeof(s->f_mntfromlabel));
226 }
227 
228 /*
229  * Just a weak typedef for code clarity.  Additionally, we have a
230  * more appropriate vanity type for puffs:
231  * <uep> it should be croissant, not cookie.
232  */
233 typedef void *puffs_cookie_t;
234 typedef puffs_cookie_t puffs_croissant_t;
235 
236 struct puffs_kargs {
237 	unsigned int	pa_vers;
238 	int		pa_fd;
239 
240 	uint32_t	pa_flags;
241 
242 	size_t		pa_maxmsglen;
243 	int		pa_nhashbuckets;
244 
245 	size_t		pa_fhsize;
246 	int		pa_fhflags;
247 
248 	uint8_t		pa_vnopmask[PUFFS_VN_MAX + PUFFS_VN_SPARE];
249 
250 	char		pa_typename[_VFS_NAMELEN];
251 	char		pa_mntfromname[_VFS_MNAMELEN];
252 
253 	puffs_cookie_t	pa_root_cookie;
254 	enum vtype	pa_root_vtype;
255 	voff_t		pa_root_vsize;
256 	union {
257 		dev_t		dev;
258 		uint64_t	container;
259 	} devunion;
260 
261 	struct puffs_statvfs	pa_svfsb;
262 
263 	uint32_t	pa_time32;
264 
265 	uint32_t	pa_spare[127];
266 };
267 #define pa_root_rdev devunion.dev
268 
269 #define PUFFS_KFLAG_NOCACHE_NAME	0x001	/* don't use name cache     */
270 #define PUFFS_KFLAG_NOCACHE_PAGE	0x002	/* don't use page cache	    */
271 #define PUFFS_KFLAG_NOCACHE		0x003	/* no cache whatsoever      */
272 #define PUFFS_KFLAG_ALLOPS		0x004	/* ignore pa_vnopmask       */
273 #define PUFFS_KFLAG_WTCACHE		0x008	/* write-through page cache */
274 #define PUFFS_KFLAG_IAONDEMAND		0x010	/* inactive only on demand  */
275 #define PUFFS_KFLAG_LOOKUP_FULLPNBUF	0x020	/* full pnbuf in lookup     */
276 #define PUFFS_KFLAG_NOCACHE_ATTR	0x040	/* no attrib cache (unused) */
277 #define PUFFS_KFLAG_CACHE_FS_TTL	0x080	/* cache use TTL from FS    */
278 #define PUFFS_KFLAG_CACHE_DOTDOT	0x100	/* don't send lookup for .. */
279 #define PUFFS_KFLAG_NOFLUSH_META	0x200	/* don't flush metadata cache*/
280 #define PUFFS_KFLAG_MASK		0x3bf
281 
282 #define PUFFS_FHFLAG_DYNAMIC		0x01
283 #define PUFFS_FHFLAG_NFSV2		0x02
284 #define PUFFS_FHFLAG_NFSV3		0x04
285 #define PUFFS_FHFLAG_PROTOMASK		0x06
286 #define PUFFS_FHFLAG_PASSTHROUGH	0x08
287 #define PUFFS_FHFLAG_MASK		0x0f
288 
289 #define PUFFS_FHSIZE_MAX	1020	/* FHANDLE_SIZE_MAX - 4 */
290 
291 struct puffs_req {
292 	struct putter_hdr	preq_pth;
293 
294 	uint64_t		preq_id;
295 	puffs_cookie_t		preq_cookie;
296 
297 	uint16_t		preq_opclass;
298 	uint16_t		preq_optype;
299 	int			preq_rv;
300 
301 	uint32_t		preq_setbacks;
302 
303 	/* Who is making the call?  Eventually host id is also needed. */
304 	pid_t			preq_pid;
305 	lwpid_t			preq_lid;
306 
307 	/*
308 	 * the following helper pads the struct size to md alignment
309 	 * multiple (should size_t not cut it).  it makes sure that
310 	 * whatever comes after this struct is aligned
311 	 */
312 	size_t  		preq_buflen;
313 	uint8_t	preq_buf[0] __aligned(ALIGNBYTES+1);
314 };
315 
316 #define PUFFS_SETBACK_INACT_N1	0x01	/* set VOP_INACTIVE for node 1 */
317 #define PUFFS_SETBACK_INACT_N2	0x02	/* set VOP_INACTIVE for node 2 */
318 #define PUFFS_SETBACK_NOREF_N1	0x04	/* set pn PN_NOREFS for node 1 */
319 #define PUFFS_SETBACK_NOREF_N2	0x08	/* set pn PN_NOREFS for node 2 */
320 #define PUFFS_SETBACK_MASK	0x0f
321 
322 /*
323  * Flush operation.  This can be used to invalidate:
324  * 1) name cache for one node
325  * 2) name cache for all children
326  * 3) name cache for the entire mount
327  * 4) page cache for a set of ranges in one node
328  * 5) page cache for one entire node
329  *
330  * It can be used to flush:
331  * 1) page cache for a set of ranges in one node
332  * 2) page cache for one entire node
333  */
334 
335 struct puffs_flush {
336 	struct puffs_req	pf_req;
337 
338 	puffs_cookie_t		pf_cookie;
339 
340 	int			pf_op;
341 	off_t			pf_start;
342 	off_t			pf_end;
343 };
344 #define PUFFS_INVAL_NAMECACHE_NODE		0
345 #define PUFFS_INVAL_NAMECACHE_DIR		1
346 #define PUFFS_INVAL_NAMECACHE_ALL		2
347 #define PUFFS_INVAL_PAGECACHE_NODE_RANGE	3
348 #define PUFFS_FLUSH_PAGECACHE_NODE_RANGE	4
349 
350 /*
351  * Credentials for an operation.  Can be either struct uucred for
352  * ops called from a credential context or NOCRED/FSCRED for ops
353  * called from within the kernel.  It is up to the implementation
354  * if it makes a difference between these two and the super-user.
355  */
356 struct puffs_kcred {
357 	struct uucred	pkcr_uuc;
358 	uint8_t		pkcr_type;
359 	uint8_t		pkcr_internal;
360 };
361 #define PUFFCRED_TYPE_UUC	1
362 #define PUFFCRED_TYPE_INTERNAL	2
363 #define PUFFCRED_CRED_NOCRED	1
364 #define PUFFCRED_CRED_FSCRED	2
365 
366 /*
367  * 2*MAXPHYS is the max size the system will attempt to copy,
368  * else treated as garbage
369  */
370 #define PUFFS_MSG_MAXSIZE	2*MAXPHYS
371 #define PUFFS_MSGSTRUCT_MAX	4096 /* approximate */
372 
373 #define PUFFS_EXTNAMELEN KERNEL_NAME_MAX /* currently same as EXTATTR_MAXNAMELEN */
374 
375 #define PUFFS_TOMOVE(a,b) (MIN((a), b->pmp_msg_maxsize - PUFFS_MSGSTRUCT_MAX))
376 
377 /* puffs struct componentname built by kernel */
378 struct puffs_kcn {
379 	/* args */
380 	uint32_t		pkcn_nameiop;	/* namei operation	*/
381 	uint32_t		pkcn_flags;	/* flags		*/
382 
383 	char pkcn_name[MAXPATHLEN];	/* nulterminated path component */
384 	size_t pkcn_namelen;		/* current component length	*/
385 	size_t pkcn_consume;		/* IN: extra chars server ate   */
386 };
387 
388 
389 /*
390  * Next come the individual requests.  They are all subclassed from
391  * puffs_req and contain request-specific fields in addition.  Note
392  * that there are some requests which have to handle arbitrary-length
393  * buffers.
394  *
395  * The division is the following: puffs_req is to be touched only
396  * by generic routines while the other stuff is supposed to be
397  * modified only by specific routines.
398  */
399 
400 /*
401  * aux structures for vfs operations.
402  */
403 struct puffs_vfsmsg_unmount {
404 	struct puffs_req	pvfsr_pr;
405 
406 	int			pvfsr_flags;
407 };
408 
409 struct puffs_vfsmsg_statvfs {
410 	struct puffs_req	pvfsr_pr;
411 
412 	struct puffs_statvfs	pvfsr_sb;
413 };
414 
415 struct puffs_vfsmsg_sync {
416 	struct puffs_req	pvfsr_pr;
417 
418 	struct puffs_kcred	pvfsr_cred;
419 	int			pvfsr_waitfor;
420 };
421 
422 struct puffs_vfsmsg_fhtonode {
423 	struct puffs_req	pvfsr_pr;
424 
425 	void			*pvfsr_fhcookie;	/* IN	*/
426 	enum vtype		pvfsr_vtype;		/* IN	*/
427 	voff_t			pvfsr_size;		/* IN	*/
428 	dev_t			pvfsr_rdev;		/* IN	*/
429 
430 	size_t			pvfsr_dsize;		/* OUT */
431 	uint8_t			pvfsr_data[0]		/* OUT, XXX */
432 				    __aligned(ALIGNBYTES+1);
433 };
434 
435 struct puffs_vfsmsg_nodetofh {
436 	struct puffs_req	pvfsr_pr;
437 
438 	void			*pvfsr_fhcookie;	/* OUT	*/
439 
440 	size_t			pvfsr_dsize;		/* OUT/IN  */
441 	uint8_t			pvfsr_data[0]		/* IN, XXX */
442 				    __aligned(ALIGNBYTES+1);
443 };
444 
445 struct puffs_vfsmsg_suspend {
446 	struct puffs_req	pvfsr_pr;
447 
448 	int			pvfsr_status;
449 };
450 #define PUFFS_SUSPEND_START	0
451 #define PUFFS_SUSPEND_SUSPENDED	1
452 #define PUFFS_SUSPEND_RESUME	2
453 #define PUFFS_SUSPEND_ERROR	3
454 
455 #define PUFFS_EXTATTRCTL_HASNODE	0x01
456 #define PUFFS_EXTATTRCTL_HASATTRNAME	0x02
457 
458 #define	PUFFS_OPEN_IO_DIRECT	0x01
459 
460 struct puffs_vfsmsg_extattrctl {
461 	struct puffs_req	pvfsr_pr;
462 
463 	int			pvfsr_cmd;			  /* OUT */
464 	int			pvfsr_attrnamespace;		  /* OUT */
465 	int			pvfsr_flags;			  /* OUT */
466 	char			pvfsr_attrname[PUFFS_EXTNAMELEN]; /* OUT */
467 };
468 
469 /*
470  * aux structures for vnode operations.
471  */
472 
473 struct puffs_vnmsg_lookup {
474 	struct puffs_req	pvn_pr;
475 
476 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
477 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
478 
479 	puffs_cookie_t		pvnr_newnode;		/* IN	*/
480 	enum vtype		pvnr_vtype;		/* IN	*/
481 	voff_t			pvnr_size;		/* IN	*/
482 	dev_t			pvnr_rdev;		/* IN	*/
483 	/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
484 	struct vattr		pvnr_va;		/* IN	*/
485 	struct timespec		pvnr_va_ttl;		/* IN	*/
486 	struct timespec		pvnr_cn_ttl;		/* IN	*/
487 };
488 
489 struct puffs_vnmsg_create {
490 	struct puffs_req	pvn_pr;
491 
492 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
493 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
494 
495 	struct vattr		pvnr_va;		/* OUT	*/
496 	puffs_cookie_t		pvnr_newnode;		/* IN	*/
497 	/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
498 	struct timespec		pvnr_va_ttl;		/* IN	*/
499 	struct timespec		pvnr_cn_ttl;		/* IN	*/
500 };
501 
502 struct puffs_vnmsg_mknod {
503 	struct puffs_req	pvn_pr;
504 
505 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
506 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
507 
508 	struct vattr		pvnr_va;		/* OUT	*/
509 	puffs_cookie_t		pvnr_newnode;		/* IN	*/
510 	/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
511 	struct timespec		pvnr_va_ttl;		/* IN	*/
512 	struct timespec		pvnr_cn_ttl;		/* IN	*/
513 };
514 
515 struct puffs_vnmsg_open {
516 	struct puffs_req	pvn_pr;
517 
518 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
519 	int			pvnr_mode;		/* OUT	*/
520 	int			pvnr_oflags;		/* IN	*/
521 };
522 
523 struct puffs_vnmsg_close {
524 	struct puffs_req	pvn_pr;
525 
526 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
527 	int			pvnr_fflag;		/* OUT	*/
528 };
529 
530 struct puffs_vnmsg_access {
531 	struct puffs_req	pvn_pr;
532 
533 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
534 	int			pvnr_mode;		/* OUT	*/
535 };
536 
537 #define puffs_vnmsg_setattr puffs_vnmsg_setgetattr
538 #define puffs_vnmsg_getattr puffs_vnmsg_setgetattr
539 struct puffs_vnmsg_setgetattr {
540 	struct puffs_req	pvn_pr;
541 
542 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
543 	struct vattr		pvnr_va;		/* IN/OUT (op depend) */
544 	/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
545 	struct timespec		pvnr_va_ttl;		/* IN	*/
546 };
547 
548 #define puffs_vnmsg_read puffs_vnmsg_rw
549 #define puffs_vnmsg_write puffs_vnmsg_rw
550 struct puffs_vnmsg_rw {
551 	struct puffs_req	pvn_pr;
552 
553 	struct puffs_kcred	pvnr_cred;		/* OUT	  */
554 	off_t			pvnr_offset;		/* OUT	  */
555 	size_t			pvnr_resid;		/* IN/OUT */
556 	int			pvnr_ioflag;		/* OUT	  */
557 
558 	uint8_t			pvnr_data[0];		/* IN/OUT (wr/rd) */
559 };
560 
561 #define puffs_vnmsg_ioctl puffs_vnreq_fcnioctl
562 #define puffs_vnmsg_fcntl puffs_vnreq_fcnioctl
563 struct puffs_vnmsg_fcnioctl {
564 	struct puffs_req	pvn_pr;
565 
566 	struct puffs_kcred	pvnr_cred;
567 	u_long			pvnr_command;
568 	pid_t			pvnr_pid;
569 	int			pvnr_fflag;
570 
571 	void			*pvnr_data;
572 	size_t			pvnr_datalen;
573 	int			pvnr_copyback;
574 };
575 
576 struct puffs_vnmsg_poll {
577 	struct puffs_req	pvn_pr;
578 
579 	int			pvnr_events;		/* IN/OUT */
580 };
581 
582 struct puffs_vnmsg_fsync {
583 	struct puffs_req	pvn_pr;
584 
585 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
586 	off_t			pvnr_offlo;		/* OUT	*/
587 	off_t			pvnr_offhi;		/* OUT	*/
588 	int			pvnr_flags;		/* OUT	*/
589 };
590 
591 struct puffs_vnmsg_seek {
592 	struct puffs_req	pvn_pr;
593 
594 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
595 	off_t			pvnr_oldoff;		/* OUT	*/
596 	off_t			pvnr_newoff;		/* OUT	*/
597 };
598 
599 struct puffs_vnmsg_remove {
600 	struct puffs_req	pvn_pr;
601 
602 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
603 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
604 
605 	puffs_cookie_t		pvnr_cookie_targ;	/* OUT	*/
606 };
607 
608 struct puffs_vnmsg_mkdir {
609 	struct puffs_req	pvn_pr;
610 
611 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
612 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
613 
614 	struct vattr		pvnr_va;		/* OUT	*/
615 	puffs_cookie_t		pvnr_newnode;		/* IN	*/
616 	/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
617 	struct timespec		pvnr_va_ttl;		/* IN	*/
618 	struct timespec		pvnr_cn_ttl;		/* IN	*/
619 };
620 
621 struct puffs_vnmsg_rmdir {
622 	struct puffs_req	pvn_pr;
623 
624 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
625 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
626 
627 	puffs_cookie_t		pvnr_cookie_targ;	/* OUT	*/
628 };
629 
630 struct puffs_vnmsg_link {
631 	struct puffs_req	pvn_pr;
632 
633 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
634 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
635 
636 	puffs_cookie_t		pvnr_cookie_targ;	/* OUT	*/
637 };
638 
639 struct puffs_vnmsg_rename {
640 	struct puffs_req	pvn_pr;
641 
642 	struct puffs_kcn	pvnr_cn_src;		/* OUT	*/
643 	struct puffs_kcred	pvnr_cn_src_cred;	/* OUT	*/
644 	struct puffs_kcn	pvnr_cn_targ;		/* OUT	*/
645 	struct puffs_kcred	pvnr_cn_targ_cred;	/* OUT	*/
646 
647 	puffs_cookie_t		pvnr_cookie_src;	/* OUT	*/
648 	puffs_cookie_t		pvnr_cookie_targ;	/* OUT	*/
649 	puffs_cookie_t		pvnr_cookie_targdir;	/* OUT	*/
650 };
651 
652 struct puffs_vnmsg_symlink {
653 	struct puffs_req	pvn_pr;
654 
655 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
656 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
657 
658 	struct vattr		pvnr_va;		/* OUT	*/
659 	puffs_cookie_t		pvnr_newnode;		/* IN	*/
660 	char			pvnr_link[MAXPATHLEN];	/* OUT	*/
661 	/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
662 	struct timespec		pvnr_va_ttl;		/* IN	*/
663 	struct timespec		pvnr_cn_ttl;		/* IN	*/
664 };
665 
666 struct puffs_vnmsg_readdir {
667 	struct puffs_req	pvn_pr;
668 
669 	struct puffs_kcred	pvnr_cred;		/* OUT	  */
670 	off_t			pvnr_offset;		/* IN/OUT */
671 	size_t			pvnr_resid;		/* IN/OUT */
672 	size_t			pvnr_ncookies;		/* IN/OUT */
673 	int			pvnr_eofflag;		/* IN     */
674 
675 	size_t			pvnr_dentoff;		/* OUT    */
676 	uint8_t			pvnr_data[0]		/* IN  	  */
677 				    __aligned(ALIGNBYTES+1);
678 };
679 
680 struct puffs_vnmsg_readlink {
681 	struct puffs_req	pvn_pr;
682 
683 	struct puffs_kcred	pvnr_cred;		/* OUT */
684 	size_t			pvnr_linklen;		/* IN  */
685 	char			pvnr_link[MAXPATHLEN];	/* IN  */
686 };
687 
688 struct puffs_vnmsg_reclaim {
689 	struct puffs_req	pvn_pr;
690 
691 	int			pvnr_nlookup;		/* OUT */
692 };
693 
694 struct puffs_vnmsg_inactive {
695 	struct puffs_req	pvn_pr;
696 };
697 
698 struct puffs_vnmsg_print {
699 	struct puffs_req	pvn_pr;
700 
701 	/* empty */
702 };
703 
704 struct puffs_vnmsg_pathconf {
705 	struct puffs_req	pvn_pr;
706 
707 	int			pvnr_name;		/* OUT	*/
708 	__register_t		pvnr_retval;		/* IN	*/
709 };
710 
711 struct puffs_vnmsg_advlock {
712 	struct puffs_req	pvn_pr;
713 
714 	struct flock		pvnr_fl;		/* OUT	*/
715 	void			*pvnr_id;		/* OUT	*/
716 	int			pvnr_op;		/* OUT	*/
717 	int			pvnr_flags;		/* OUT	*/
718 };
719 
720 struct puffs_vnmsg_mmap {
721 	struct puffs_req	pvn_pr;
722 
723 	vm_prot_t		pvnr_prot;		/* OUT	*/
724 	struct puffs_kcred	pvnr_cred;		/* OUT	*/
725 };
726 
727 struct puffs_vnmsg_abortop {
728 	struct puffs_req	pvn_pr;
729 
730 	struct puffs_kcn	pvnr_cn;		/* OUT	*/
731 	struct puffs_kcred	pvnr_cn_cred;		/* OUT	*/
732 };
733 
734 struct puffs_vnmsg_getextattr {
735 	struct puffs_req	pvn_pr;
736 
737 	int			pvnr_attrnamespace;		/* OUT	  */
738 	char			pvnr_attrname[PUFFS_EXTNAMELEN];/* OUT	  */
739 
740 	struct puffs_kcred	pvnr_cred;			/* OUT	  */
741 	size_t			pvnr_datasize;			/* IN	  */
742 
743 	size_t			pvnr_resid;			/* IN/OUT */
744 	uint8_t			pvnr_data[0]			/* IN	  */
745 				    __aligned(ALIGNBYTES+1);
746 };
747 
748 struct puffs_vnmsg_setextattr {
749 	struct puffs_req	pvn_pr;
750 
751 	int			pvnr_attrnamespace;		/* OUT	  */
752 	char			pvnr_attrname[PUFFS_EXTNAMELEN];/* OUT	  */
753 
754 	struct puffs_kcred	pvnr_cred;			/* OUT	*/
755 
756 	size_t			pvnr_resid;			/* IN/OUT */
757 	uint8_t			pvnr_data[0]			/* OUT	  */
758 				    __aligned(ALIGNBYTES+1);
759 };
760 
761 struct puffs_vnmsg_listextattr {
762 	struct puffs_req	pvn_pr;
763 
764 	int			pvnr_attrnamespace;		/* OUT	  */
765 
766 	struct puffs_kcred	pvnr_cred;			/* OUT	*/
767 	size_t			pvnr_datasize;			/* IN	  */
768 
769 	size_t			pvnr_resid;			/* IN/OUT */
770 	int			pvnr_flag;			/* OUT */
771 	uint8_t			pvnr_data[0]			/* IN	  */
772 				    __aligned(ALIGNBYTES+1);
773 };
774 
775 struct puffs_vnmsg_deleteextattr {
776 	struct puffs_req	pvn_pr;
777 
778 	int			pvnr_attrnamespace;		/* OUT	  */
779 	char			pvnr_attrname[PUFFS_EXTNAMELEN];/* OUT	  */
780 
781 	struct puffs_kcred	pvnr_cred;			/* OUT	*/
782 };
783 
784 #define PUFFS_HAVE_FALLOCATE 1
785 struct puffs_vnmsg_fallocate {
786 	struct puffs_req	pvn_pr;
787 	off_t			pvnr_off;			/* OUT    */
788 	off_t			pvnr_len;			/* OUT    */
789 };
790 
791 struct puffs_vnmsg_fdiscard {
792 	struct puffs_req	pvn_pr;
793 	off_t			pvnr_off;			/* OUT    */
794 	off_t			pvnr_len;			/* OUT    */
795 };
796 
797 /*
798  * For cache reports.  Everything is always out-out-out, no replies
799  */
800 
801 struct puffs_cacherun {
802 	off_t			pcache_runstart;
803 	off_t			pcache_runend;
804 };
805 
806 /* cache info.  old used for write now */
807 struct puffs_cacheinfo {
808 	struct puffs_req	pcache_pr;
809 
810 	int			pcache_type;
811 	size_t			pcache_nruns;
812 	struct puffs_cacherun	pcache_runs[0];
813 };
814 #define PCACHE_TYPE_READ	0
815 #define PCACHE_TYPE_WRITE	1
816 
817 /*
818  * Error notification.  Always outgoing, no response, no remorse.
819  */
820 struct puffs_error {
821 	struct puffs_req	perr_pr;
822 
823 	int			perr_error;
824 	char			perr_str[256];
825 };
826 
827 #endif /* _FS_PUFFS_PUFFS_MSGIF_H_ */
828