1 /* $NetBSD: puffs_msgif.h,v 1.68 2009/10/17 23:22:04 pooka Exp $ */
4 * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
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.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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
32 #ifndef _FS_PUFFS_PUFFS_MSGIF_H_
33 #define _FS_PUFFS_PUFFS_MSGIF_H_
35 #include <sys/param.h>
37 #include <sys/ioccom.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>
45 #include <dev/putter/putter.h>
47 #include <uvm/uvm_prot.h>
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 */
57 #define PUFFSOPFLAG_FAF 0x10 /* fire-and-forget */
58 #define PUFFSOPFLAG_ISRESPONSE 0x20 /* req is actually a resp */
60 #define PUFFSOP_OPCMASK 0x07
61 #define PUFFSOP_OPCLASS(a) ((a) & PUFFSOP_OPCMASK)
62 #define PUFFSOP_WANTREPLY(a) (((a) & PUFFSOPFLAG_FAF) == 0)
64 /* XXX: we don't need everything */
66 PUFFS_VFS_MOUNT
, PUFFS_VFS_START
, PUFFS_VFS_UNMOUNT
,
67 PUFFS_VFS_ROOT
, PUFFS_VFS_STATVFS
, PUFFS_VFS_SYNC
,
68 PUFFS_VFS_VGET
, PUFFS_VFS_FHTOVP
, PUFFS_VFS_VPTOFH
,
69 PUFFS_VFS_INIT
, PUFFS_VFS_DONE
, PUFFS_VFS_SNAPSHOT
,
70 PUFFS_VFS_EXTATTCTL
, PUFFS_VFS_SUSPEND
72 #define PUFFS_VFS_MAX PUFFS_VFS_EXTATTCTL
74 /* moreXXX: we don't need everything here either */
76 PUFFS_VN_LOOKUP
, PUFFS_VN_CREATE
, PUFFS_VN_MKNOD
,
77 PUFFS_VN_OPEN
, PUFFS_VN_CLOSE
, PUFFS_VN_ACCESS
,
78 PUFFS_VN_GETATTR
, PUFFS_VN_SETATTR
, PUFFS_VN_READ
,
79 PUFFS_VN_WRITE
, PUFFS_VN_IOCTL
, PUFFS_VN_FCNTL
,
80 PUFFS_VN_POLL
, PUFFS_VN_KQFILTER
, PUFFS_VN_REVOKE
,
81 PUFFS_VN_MMAP
, PUFFS_VN_FSYNC
, PUFFS_VN_SEEK
,
82 PUFFS_VN_REMOVE
, PUFFS_VN_LINK
, PUFFS_VN_RENAME
,
83 PUFFS_VN_MKDIR
, PUFFS_VN_RMDIR
, PUFFS_VN_SYMLINK
,
84 PUFFS_VN_READDIR
, PUFFS_VN_READLINK
, PUFFS_VN_ABORTOP
,
85 PUFFS_VN_INACTIVE
, PUFFS_VN_RECLAIM
, PUFFS_VN_LOCK
,
86 PUFFS_VN_UNLOCK
, PUFFS_VN_BMAP
, PUFFS_VN_STRATEGY
,
87 PUFFS_VN_PRINT
, PUFFS_VN_ISLOCKED
, PUFFS_VN_PATHCONF
,
88 PUFFS_VN_ADVLOCK
, PUFFS_VN_LEASE
, PUFFS_VN_WHITEOUT
,
89 PUFFS_VN_GETPAGES
, PUFFS_VN_PUTPAGES
, PUFFS_VN_GETEXTATTR
,
90 PUFFS_VN_LISTEXTATTR
, PUFFS_VN_OPENEXTATTR
, PUFFS_VN_DELETEEXTATTR
,
93 #define PUFFS_VN_MAX PUFFS_VN_SETEXTATTR
96 * These signal invalid parameters the file system returned.
99 PUFFS_ERR_MAKENODE
, PUFFS_ERR_LOOKUP
, PUFFS_ERR_READDIR
,
100 PUFFS_ERR_READLINK
, PUFFS_ERR_READ
, PUFFS_ERR_WRITE
,
101 PUFFS_ERR_VPTOFH
, PUFFS_ERR_ERROR
103 #define PUFFS_ERR_MAX PUFFS_ERR_VPTOFH
105 #define PUFFSDEVELVERS 0x80000000
106 #define PUFFSVERSION 29
107 #define PUFFSNAMESIZE 32
109 #define PUFFS_TYPEPREFIX "puffs|"
111 #define PUFFS_TYPELEN (_VFS_NAMELEN - (sizeof(PUFFS_TYPEPREFIX)+1))
112 #define PUFFS_NAMELEN (_VFS_MNAMELEN-1)
115 * Just a weak typedef for code clarity. Additionally, we have a
116 * more appropriate vanity type for puffs:
117 * <uep> it should be croissant, not cookie.
119 typedef void *puffs_cookie_t
;
120 typedef puffs_cookie_t puffs_croissant_t
;
123 unsigned int pa_vers
;
134 puffs_cookie_t pa_root_cookie
;
135 enum vtype pa_root_vtype
;
136 voff_t pa_root_vsize
;
139 struct statvfs pa_svfsb
;
141 char pa_typename
[_VFS_NAMELEN
];
142 char pa_mntfromname
[_VFS_MNAMELEN
];
144 uint8_t pa_vnopmask
[PUFFS_VN_MAX
];
146 #define PUFFS_KFLAG_NOCACHE_NAME 0x01 /* don't use name cache */
147 #define PUFFS_KFLAG_NOCACHE_PAGE 0x02 /* don't use page cache */
148 #define PUFFS_KFLAG_NOCACHE 0x03 /* no cache whatsoever */
149 #define PUFFS_KFLAG_ALLOPS 0x04 /* ignore pa_vnopmask */
150 #define PUFFS_KFLAG_WTCACHE 0x08 /* write-through page cache */
151 #define PUFFS_KFLAG_IAONDEMAND 0x10 /* inactive only on demand */
152 #define PUFFS_KFLAG_LOOKUP_FULLPNBUF 0x20 /* full pnbuf in lookup */
153 #define PUFFS_KFLAG_MASK 0x3f
155 #define PUFFS_FHFLAG_DYNAMIC 0x01
156 #define PUFFS_FHFLAG_NFSV2 0x02
157 #define PUFFS_FHFLAG_NFSV3 0x04
158 #define PUFFS_FHFLAG_PROTOMASK 0x06
159 #define PUFFS_FHFLAG_PASSTHROUGH 0x08
160 #define PUFFS_FHFLAG_MASK 0x0f
162 #define PUFFS_FHSIZE_MAX 1020 /* XXX: FHANDLE_SIZE_MAX - 4 */
165 struct putter_hdr preq_pth
;
168 puffs_cookie_t preq_cookie
;
170 uint16_t preq_opclass
;
171 uint16_t preq_optype
;
174 uint32_t preq_setbacks
;
176 /* Who is making the call? Eventually host id is also needed. */
181 * the following helper pads the struct size to md alignment
182 * multiple (should size_t not cut it). it makes sure that
183 * whatever comes after this struct is aligned
186 uint8_t preq_buf
[0] __aligned(ALIGNBYTES
+1);
189 #define PUFFS_SETBACK_INACT_N1 0x01 /* set VOP_INACTIVE for node 1 */
190 #define PUFFS_SETBACK_INACT_N2 0x02 /* set VOP_INACTIVE for node 2 */
191 #define PUFFS_SETBACK_NOREF_N1 0x04 /* set pn PN_NOREFS for node 1 */
192 #define PUFFS_SETBACK_NOREF_N2 0x08 /* set pn PN_NOREFS for node 2 */
193 #define PUFFS_SETBACK_MASK 0x0f
196 * Flush operation. This can be used to invalidate:
197 * 1) name cache for one node
198 * 2) name cache for all children
199 * 3) name cache for the entire mount
200 * 4) page cache for a set of ranges in one node
201 * 5) page cache for one entire node
203 * It can be used to flush:
204 * 1) page cache for a set of ranges in one node
205 * 2) page cache for one entire node
208 /* XXX: needs restructuring */
210 struct puffs_req pf_req
;
212 puffs_cookie_t pf_cookie
;
218 #define PUFFS_INVAL_NAMECACHE_NODE 0
219 #define PUFFS_INVAL_NAMECACHE_DIR 1
220 #define PUFFS_INVAL_NAMECACHE_ALL 2
221 #define PUFFS_INVAL_PAGECACHE_NODE_RANGE 3
222 #define PUFFS_FLUSH_PAGECACHE_NODE_RANGE 4
224 /* keep this for now */
225 #define PUFFSREQSIZEOP _IOR ('p', 1, size_t)
228 * Credentials for an operation. Can be either struct uucred for
229 * ops called from a credential context or NOCRED/FSCRED for ops
230 * called from within the kernel. It is up to the implementation
231 * if it makes a difference between these two and the super-user.
234 struct uucred pkcr_uuc
;
236 uint8_t pkcr_internal
;
238 #define PUFFCRED_TYPE_UUC 1
239 #define PUFFCRED_TYPE_INTERNAL 2
240 #define PUFFCRED_CRED_NOCRED 1
241 #define PUFFCRED_CRED_FSCRED 2
244 * 2*MAXPHYS is the max size the system will attempt to copy,
245 * else treated as garbage
247 #define PUFFS_MSG_MAXSIZE 2*MAXPHYS
248 #define PUFFS_MSGSTRUCT_MAX 4096 /* XXX: approxkludge */
250 #define PUFFS_TOMOVE(a,b) (MIN((a), b->pmp_msg_maxsize - PUFFS_MSGSTRUCT_MAX))
252 /* puffs struct componentname built by kernel */
255 uint32_t pkcn_nameiop
; /* namei operation */
256 uint32_t pkcn_flags
; /* flags */
258 char pkcn_name
[MAXPATHLEN
]; /* nulterminated path component */
259 size_t pkcn_namelen
; /* current component length */
260 size_t pkcn_consume
; /* IN: extra chars server ate */
265 * Next come the individual requests. They are all subclassed from
266 * puffs_req and contain request-specific fields in addition. Note
267 * that there are some requests which have to handle arbitrary-length
270 * The division is the following: puffs_req is to be touched only
271 * by generic routines while the other stuff is supposed to be
272 * modified only by specific routines.
276 * aux structures for vfs operations.
278 struct puffs_vfsmsg_unmount
{
279 struct puffs_req pvfsr_pr
;
284 struct puffs_vfsmsg_statvfs
{
285 struct puffs_req pvfsr_pr
;
287 struct statvfs pvfsr_sb
;
290 struct puffs_vfsmsg_sync
{
291 struct puffs_req pvfsr_pr
;
293 struct puffs_kcred pvfsr_cred
;
297 struct puffs_vfsmsg_fhtonode
{
298 struct puffs_req pvfsr_pr
;
300 void *pvfsr_fhcookie
; /* IN */
301 enum vtype pvfsr_vtype
; /* IN */
302 voff_t pvfsr_size
; /* IN */
303 dev_t pvfsr_rdev
; /* IN */
305 size_t pvfsr_dsize
; /* OUT */
306 uint8_t pvfsr_data
[0] /* OUT, XXX */
307 __aligned(ALIGNBYTES
+1);
310 struct puffs_vfsmsg_nodetofh
{
311 struct puffs_req pvfsr_pr
;
313 void *pvfsr_fhcookie
; /* OUT */
315 size_t pvfsr_dsize
; /* OUT/IN */
316 uint8_t pvfsr_data
[0] /* IN, XXX */
317 __aligned(ALIGNBYTES
+1);
320 struct puffs_vfsmsg_suspend
{
321 struct puffs_req pvfsr_pr
;
325 #define PUFFS_SUSPEND_START 0
326 #define PUFFS_SUSPEND_SUSPENDED 1
327 #define PUFFS_SUSPEND_RESUME 2
328 #define PUFFS_SUSPEND_ERROR 3
331 * aux structures for vnode operations.
334 struct puffs_vnmsg_lookup
{
335 struct puffs_req pvn_pr
;
337 struct puffs_kcn pvnr_cn
; /* OUT */
338 struct puffs_kcred pvnr_cn_cred
; /* OUT */
340 puffs_cookie_t pvnr_newnode
; /* IN */
341 enum vtype pvnr_vtype
; /* IN */
342 voff_t pvnr_size
; /* IN */
343 dev_t pvnr_rdev
; /* IN */
346 struct puffs_vnmsg_create
{
347 struct puffs_req pvn_pr
;
349 struct puffs_kcn pvnr_cn
; /* OUT */
350 struct puffs_kcred pvnr_cn_cred
; /* OUT */
352 struct vattr pvnr_va
; /* OUT */
353 puffs_cookie_t pvnr_newnode
; /* IN */
356 struct puffs_vnmsg_mknod
{
357 struct puffs_req pvn_pr
;
359 struct puffs_kcn pvnr_cn
; /* OUT */
360 struct puffs_kcred pvnr_cn_cred
; /* OUT */
362 struct vattr pvnr_va
; /* OUT */
363 puffs_cookie_t pvnr_newnode
; /* IN */
366 struct puffs_vnmsg_open
{
367 struct puffs_req pvn_pr
;
369 struct puffs_kcred pvnr_cred
; /* OUT */
370 int pvnr_mode
; /* OUT */
373 struct puffs_vnmsg_close
{
374 struct puffs_req pvn_pr
;
376 struct puffs_kcred pvnr_cred
; /* OUT */
377 int pvnr_fflag
; /* OUT */
380 struct puffs_vnmsg_access
{
381 struct puffs_req pvn_pr
;
383 struct puffs_kcred pvnr_cred
; /* OUT */
384 int pvnr_mode
; /* OUT */
387 #define puffs_vnmsg_setattr puffs_vnmsg_setgetattr
388 #define puffs_vnmsg_getattr puffs_vnmsg_setgetattr
389 struct puffs_vnmsg_setgetattr
{
390 struct puffs_req pvn_pr
;
392 struct puffs_kcred pvnr_cred
; /* OUT */
393 struct vattr pvnr_va
; /* IN/OUT (op depend) */
396 #define puffs_vnmsg_read puffs_vnmsg_rw
397 #define puffs_vnmsg_write puffs_vnmsg_rw
398 struct puffs_vnmsg_rw
{
399 struct puffs_req pvn_pr
;
401 struct puffs_kcred pvnr_cred
; /* OUT */
402 off_t pvnr_offset
; /* OUT */
403 size_t pvnr_resid
; /* IN/OUT */
404 int pvnr_ioflag
; /* OUT */
406 uint8_t pvnr_data
[0]; /* IN/OUT (wr/rd) */
409 #define puffs_vnmsg_ioctl puffs_vnreq_fcnioctl
410 #define puffs_vnmsg_fcntl puffs_vnreq_fcnioctl
411 struct puffs_vnmsg_fcnioctl
{
412 struct puffs_req pvn_pr
;
414 struct puffs_kcred pvnr_cred
;
424 struct puffs_vnmsg_poll
{
425 struct puffs_req pvn_pr
;
427 int pvnr_events
; /* IN/OUT */
430 struct puffs_vnmsg_fsync
{
431 struct puffs_req pvn_pr
;
433 struct puffs_kcred pvnr_cred
; /* OUT */
434 off_t pvnr_offlo
; /* OUT */
435 off_t pvnr_offhi
; /* OUT */
436 int pvnr_flags
; /* OUT */
439 struct puffs_vnmsg_seek
{
440 struct puffs_req pvn_pr
;
442 struct puffs_kcred pvnr_cred
; /* OUT */
443 off_t pvnr_oldoff
; /* OUT */
444 off_t pvnr_newoff
; /* OUT */
447 struct puffs_vnmsg_remove
{
448 struct puffs_req pvn_pr
;
450 struct puffs_kcn pvnr_cn
; /* OUT */
451 struct puffs_kcred pvnr_cn_cred
; /* OUT */
453 puffs_cookie_t pvnr_cookie_targ
; /* OUT */
456 struct puffs_vnmsg_mkdir
{
457 struct puffs_req pvn_pr
;
459 struct puffs_kcn pvnr_cn
; /* OUT */
460 struct puffs_kcred pvnr_cn_cred
; /* OUT */
462 struct vattr pvnr_va
; /* OUT */
463 puffs_cookie_t pvnr_newnode
; /* IN */
466 struct puffs_vnmsg_rmdir
{
467 struct puffs_req pvn_pr
;
469 struct puffs_kcn pvnr_cn
; /* OUT */
470 struct puffs_kcred pvnr_cn_cred
; /* OUT */
472 puffs_cookie_t pvnr_cookie_targ
; /* OUT */
475 struct puffs_vnmsg_link
{
476 struct puffs_req pvn_pr
;
478 struct puffs_kcn pvnr_cn
; /* OUT */
479 struct puffs_kcred pvnr_cn_cred
; /* OUT */
481 puffs_cookie_t pvnr_cookie_targ
; /* OUT */
484 struct puffs_vnmsg_rename
{
485 struct puffs_req pvn_pr
;
487 struct puffs_kcn pvnr_cn_src
; /* OUT */
488 struct puffs_kcred pvnr_cn_src_cred
; /* OUT */
489 struct puffs_kcn pvnr_cn_targ
; /* OUT */
490 struct puffs_kcred pvnr_cn_targ_cred
; /* OUT */
492 puffs_cookie_t pvnr_cookie_src
; /* OUT */
493 puffs_cookie_t pvnr_cookie_targ
; /* OUT */
494 puffs_cookie_t pvnr_cookie_targdir
; /* OUT */
497 struct puffs_vnmsg_symlink
{
498 struct puffs_req pvn_pr
;
500 struct puffs_kcn pvnr_cn
; /* OUT */
501 struct puffs_kcred pvnr_cn_cred
; /* OUT */
503 struct vattr pvnr_va
; /* OUT */
504 puffs_cookie_t pvnr_newnode
; /* IN */
505 char pvnr_link
[MAXPATHLEN
]; /* OUT */
508 struct puffs_vnmsg_readdir
{
509 struct puffs_req pvn_pr
;
511 struct puffs_kcred pvnr_cred
; /* OUT */
512 off_t pvnr_offset
; /* IN/OUT */
513 size_t pvnr_resid
; /* IN/OUT */
514 size_t pvnr_ncookies
; /* IN/OUT */
515 int pvnr_eofflag
; /* IN */
517 size_t pvnr_dentoff
; /* OUT */
518 uint8_t pvnr_data
[0] /* IN */
519 __aligned(ALIGNBYTES
+1);
522 struct puffs_vnmsg_readlink
{
523 struct puffs_req pvn_pr
;
525 struct puffs_kcred pvnr_cred
; /* OUT */
526 size_t pvnr_linklen
; /* IN */
527 char pvnr_link
[MAXPATHLEN
]; /* IN, XXX */
530 struct puffs_vnmsg_reclaim
{
531 struct puffs_req pvn_pr
;
534 struct puffs_vnmsg_inactive
{
535 struct puffs_req pvn_pr
;
538 struct puffs_vnmsg_print
{
539 struct puffs_req pvn_pr
;
544 struct puffs_vnmsg_pathconf
{
545 struct puffs_req pvn_pr
;
547 int pvnr_name
; /* OUT */
548 int pvnr_retval
; /* IN */
551 struct puffs_vnmsg_advlock
{
552 struct puffs_req pvn_pr
;
554 struct flock pvnr_fl
; /* OUT */
555 void *pvnr_id
; /* OUT */
556 int pvnr_op
; /* OUT */
557 int pvnr_flags
; /* OUT */
560 struct puffs_vnmsg_mmap
{
561 struct puffs_req pvn_pr
;
563 vm_prot_t pvnr_prot
; /* OUT */
564 struct puffs_kcred pvnr_cred
; /* OUT */
567 struct puffs_vnmsg_abortop
{
568 struct puffs_req pvn_pr
;
570 struct puffs_kcn pvnr_cn
; /* OUT */
571 struct puffs_kcred pvnr_cn_cred
; /* OUT */
576 * For cache reports. Everything is always out-out-out, no replies
579 struct puffs_cacherun
{
580 off_t pcache_runstart
;
584 /* cache info. old used for write now */
585 struct puffs_cacheinfo
{
586 struct puffs_req pcache_pr
;
590 struct puffs_cacherun pcache_runs
[0];
592 #define PCACHE_TYPE_READ 0
593 #define PCACHE_TYPE_WRITE 1
596 * Error notification. Always outgoing, no response, no remorse.
599 struct puffs_req perr_pr
;
605 #endif /* _FS_PUFFS_PUFFS_MSGIF_H_ */