pkgin_all: script to auto-install all packages
[minix.git] / lib / libpuffs / puffs_msgif.h
blob092e1dd27bac4b79716852c410adfc1f7fcc3072
1 /* $NetBSD: puffs_msgif.h,v 1.65.20.2 2009/12/14 19:36:57 sborrill Exp $ */
3 /*
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
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.
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.
32 #ifndef _FS_PUFFS_PUFFS_MSGIF_H_
33 #define _FS_PUFFS_PUFFS_MSGIF_H_
35 #include <sys/param.h>
36 #include <sys/time.h>
37 #include <sys/uio.h>
38 #include <sys/statvfs.h>
39 #include <sys/ucred.h>
41 #include <time.h>
44 #define PUFFSOP_VFS 0x01 /* kernel-> */
45 #define PUFFSOP_VN 0x02 /* kernel-> */
46 #define PUFFSOP_CACHE 0x03 /* only kernel-> */
47 #define PUFFSOP_ERROR 0x04 /* only kernel-> */
48 #define PUFFSOP_FLUSH 0x05 /* ->kernel */
49 #define PUFFSOP_SUSPEND 0x06 /* ->kernel */
51 #define PUFFSOPFLAG_FAF 0x10 /* fire-and-forget */
52 #define PUFFSOPFLAG_ISRESPONSE 0x20 /* req is actually a resp */
54 #define PUFFSOP_OPCMASK 0x07
55 #define PUFFSOP_OPCLASS(a) ((a) & PUFFSOP_OPCMASK)
56 #define PUFFSOP_WANTREPLY(a) (((a) & PUFFSOPFLAG_FAF) == 0)
58 /* XXX: we don't need everything */
59 enum {
60 PUFFS_VFS_MOUNT, PUFFS_VFS_START, PUFFS_VFS_UNMOUNT,
61 PUFFS_VFS_ROOT, PUFFS_VFS_STATVFS, PUFFS_VFS_SYNC,
62 PUFFS_VFS_VGET, PUFFS_VFS_FHTOVP, PUFFS_VFS_VPTOFH,
63 PUFFS_VFS_INIT, PUFFS_VFS_DONE, PUFFS_VFS_SNAPSHOT,
64 PUFFS_VFS_EXTATTCTL, PUFFS_VFS_SUSPEND
66 #define PUFFS_VFS_MAX PUFFS_VFS_EXTATTCTL
68 /* moreXXX: we don't need everything here either */
69 enum {
70 PUFFS_VN_LOOKUP, PUFFS_VN_CREATE, PUFFS_VN_MKNOD,
71 PUFFS_VN_OPEN, PUFFS_VN_CLOSE, PUFFS_VN_ACCESS,
72 PUFFS_VN_GETATTR, PUFFS_VN_SETATTR, PUFFS_VN_READ,
73 PUFFS_VN_WRITE, PUFFS_VN_IOCTL, PUFFS_VN_FCNTL,
74 PUFFS_VN_POLL, PUFFS_VN_KQFILTER, PUFFS_VN_REVOKE,
75 PUFFS_VN_MMAP, PUFFS_VN_FSYNC, PUFFS_VN_SEEK,
76 PUFFS_VN_REMOVE, PUFFS_VN_LINK, PUFFS_VN_RENAME,
77 PUFFS_VN_MKDIR, PUFFS_VN_RMDIR, PUFFS_VN_SYMLINK,
78 PUFFS_VN_READDIR, PUFFS_VN_READLINK, PUFFS_VN_ABORTOP,
79 PUFFS_VN_INACTIVE, PUFFS_VN_RECLAIM, PUFFS_VN_LOCK,
80 PUFFS_VN_UNLOCK, PUFFS_VN_BMAP, PUFFS_VN_STRATEGY,
81 PUFFS_VN_PRINT, PUFFS_VN_ISLOCKED, PUFFS_VN_PATHCONF,
82 PUFFS_VN_ADVLOCK, PUFFS_VN_LEASE, PUFFS_VN_WHITEOUT,
83 PUFFS_VN_GETPAGES, PUFFS_VN_PUTPAGES, PUFFS_VN_GETEXTATTR,
84 PUFFS_VN_LISTEXTATTR, PUFFS_VN_OPENEXTATTR, PUFFS_VN_DELETEEXTATTR,
85 PUFFS_VN_SETEXTATTR
87 #define PUFFS_VN_MAX PUFFS_VN_SETEXTATTR
90 * These signal invalid parameters the file system returned.
92 enum {
93 PUFFS_ERR_MAKENODE, PUFFS_ERR_LOOKUP, PUFFS_ERR_READDIR,
94 PUFFS_ERR_READLINK, PUFFS_ERR_READ, PUFFS_ERR_WRITE,
95 PUFFS_ERR_VPTOFH, PUFFS_ERR_ERROR
97 #define PUFFS_ERR_MAX PUFFS_ERR_VPTOFH
99 #define PUFFSDEVELVERS 0x80000000
100 #define PUFFSVERSION 26
101 #define PUFFSNAMESIZE 32
103 #define PUFFS_TYPEPREFIX "puffs|"
105 #if 0
106 #define PUFFS_TYPELEN (_VFS_NAMELEN - (sizeof(PUFFS_TYPEPREFIX)+1))
107 #define PUFFS_NAMELEN (_VFS_MNAMELEN-1)
108 #endif
111 * Just a weak typedef for code clarity. Additionally, we have a
112 * more appropriate vanity type for puffs:
113 * <uep> it should be croissant, not cookie.
115 typedef void *puffs_cookie_t;
116 typedef puffs_cookie_t puffs_croissant_t;
118 /* FIXME: move? */
119 typedef off_t voff_t;
121 /* other netbsd stuff
122 * FIXME: move to some other place?
124 typedef int32_t lwpid_t; /* LWP id */
125 typedef unsigned long vsize_t;
126 typedef int vm_prot_t;
127 typedef uint64_t u_quad_t; /* quads */
130 /* FIXME: from sys/vnode.h, which is commented. */
132 * Vnode attributes. A field value of VNOVAL represents a field whose value
133 * is unavailable (getattr) or which is not to be changed (setattr).
135 enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };
136 struct vattr {
137 enum vtype va_type; /* vnode type (for create) */
138 mode_t va_mode; /* files access mode and type */
139 nlink_t va_nlink; /* number of references to file */
140 uid_t va_uid; /* owner user id */
141 gid_t va_gid; /* owner group id */
142 long va_fsid; /* file system id (dev for now) */
143 ino_t va_fileid; /* file id */
144 u_quad_t va_size; /* file size in bytes */
145 long va_blocksize; /* blocksize preferred for i/o */
146 struct timespec va_atime; /* time of last access */
147 struct timespec va_mtime; /* time of last modification */
148 struct timespec va_ctime; /* time file changed */
149 struct timespec va_birthtime; /* time file created */
150 u_long va_gen; /* generation number of file */
151 u_long va_flags; /* flags defined for file */
152 dev_t va_rdev; /* device the special file represents */
153 u_quad_t va_bytes; /* bytes of disk space held by file */
154 u_quad_t va_filerev; /* file modification number */
155 u_int va_vaflags; /* operations flags, see below */
156 long va_spare; /* remain quad aligned */
159 struct puffs_kargs {
160 unsigned int pa_vers;
161 int pa_fd;
163 uint32_t pa_flags;
165 size_t pa_maxmsglen;
166 int pa_nhashbuckets;
168 size_t pa_fhsize;
169 int pa_fhflags;
171 puffs_cookie_t pa_root_cookie;
172 enum vtype pa_root_vtype;
173 voff_t pa_root_vsize;
174 dev_t pa_root_rdev;
176 struct statvfs pa_svfsb;
178 char pa_typename[NAME_MAX + 1];
179 char pa_mntfromname[NAME_MAX + 1];
181 uint8_t pa_vnopmask[PUFFS_VN_MAX];
186 #define PUFFS_KFLAG_NOCACHE_NAME 0x01 /* don't use name cache */
187 #define PUFFS_KFLAG_NOCACHE_PAGE 0x02 /* don't use page cache */
188 #define PUFFS_KFLAG_NOCACHE 0x03 /* no cache whatsoever */
189 #define PUFFS_KFLAG_ALLOPS 0x04 /* ignore pa_vnopmask */
190 #define PUFFS_KFLAG_WTCACHE 0x08 /* write-through page cache */
191 #define PUFFS_KFLAG_IAONDEMAND 0x10 /* inactive only on demand */
192 #define PUFFS_KFLAG_LOOKUP_FULLPNBUF 0x20 /* full pnbuf in lookup */
193 #define PUFFS_KFLAG_MASK 0x3f
195 #define PUFFS_FHFLAG_DYNAMIC 0x01
196 #define PUFFS_FHFLAG_NFSV2 0x02
197 #define PUFFS_FHFLAG_NFSV3 0x04
198 #define PUFFS_FHFLAG_PROTOMASK 0x06
199 #define PUFFS_FHFLAG_PASSTHROUGH 0x08
200 #define PUFFS_FHFLAG_MASK 0x0f
202 #define PUFFS_FHSIZE_MAX 1020 /* XXX: FHANDLE_SIZE_MAX - 4 */
204 #define PUFFS_SETBACK_INACT_N1 0x01 /* set VOP_INACTIVE for node 1 */
205 #define PUFFS_SETBACK_INACT_N2 0x02 /* set VOP_INACTIVE for node 2 */
206 #define PUFFS_SETBACK_NOREF_N1 0x04 /* set pn PN_NOREFS for node 1 */
207 #define PUFFS_SETBACK_NOREF_N2 0x08 /* set pn PN_NOREFS for node 2 */
208 #define PUFFS_SETBACK_MASK 0x0f
210 #define PUFFS_INVAL_NAMECACHE_NODE 0
211 #define PUFFS_INVAL_NAMECACHE_DIR 1
212 #define PUFFS_INVAL_NAMECACHE_ALL 2
213 #define PUFFS_INVAL_PAGECACHE_NODE_RANGE 3
214 #define PUFFS_FLUSH_PAGECACHE_NODE_RANGE 4
216 /* keep this for now */
217 #define PUFFSREQSIZEOP _IOR ('p', 1, size_t)
219 #define PUFFCRED_TYPE_UUC 1
220 #define PUFFCRED_TYPE_INTERNAL 2
221 #define PUFFCRED_CRED_NOCRED 1
222 #define PUFFCRED_CRED_FSCRED 2
225 * 2*MAXPHYS is the max size the system will attempt to copy,
226 * else treated as garbage
228 #define PUFFS_MSG_MAXSIZE 2*MAXPHYS
229 #define PUFFS_MSGSTRUCT_MAX 4096 /* XXX: approxkludge */
231 #define PUFFS_TOMOVE(a,b) (MIN((a), b->pmp_msg_maxsize - PUFFS_MSGSTRUCT_MAX))
233 /* puffs struct componentname built by kernel */
234 struct puffs_kcn {
235 /* args */
236 uint32_t pkcn_nameiop; /* namei operation */
237 uint32_t pkcn_flags; /* flags */
239 char pkcn_name[MAXPATHLEN]; /* nulterminated path component */
240 size_t pkcn_namelen; /* current component length */
241 size_t pkcn_consume; /* IN: extra chars server ate */
245 * Credentials for an operation. Can be either struct uucred for
246 * ops called from a credential context or NOCRED/FSCRED for ops
247 * called from within the kernel. It is up to the implementation
248 * if it makes a difference between these two and the super-user.
250 struct puffs_kcred {
251 struct uucred pkcr_uuc;
252 uint8_t pkcr_type;
253 uint8_t pkcr_internal;
255 #define PUFFCRED_TYPE_UUC 1
256 #define PUFFCRED_TYPE_INTERNAL 2
257 #define PUFFCRED_CRED_NOCRED 1
258 #define PUFFCRED_CRED_FSCRED 2
261 #endif /* _FS_PUFFS_PUFFS_MSGIF_H_ */