vm, kernel, top: report memory usage of vm, kernel
[minix.git] / lib / libpuffs / puffs.h
blob09d177b2d6b2f5ba70d0ba8b5c75132bb1c89a2d
1 /* $NetBSD: puffs.h,v 1.108.4.4 2009/10/27 20:37:38 bouyer 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 _PUFFS_H_
33 #define _PUFFS_H_
35 #include <sys/param.h>
36 #include <sys/types.h>
37 #include <sys/mount.h>
38 #include <sys/stat.h>
39 #include <sys/statvfs.h>
40 #include <sys/time.h>
41 #include <sys/queue.h>
43 #include "puffs_msgif.h"
45 #include <mntopts.h>
46 #include <time.h>
48 #include <stdbool.h>
49 #include <string.h>
50 #include <stdint.h>
52 #include <dirent.h>
55 /* MINIX forwards */
56 struct flock;
57 struct dirent;
59 /* XXX: from sys/fstypes.h
60 * Flags for various system call interfaces.
62 * waitfor flags to vfs_sync() and getvfsstat()
64 #define MNT_WAIT 1 /* synchronously wait for I/O to complete */
65 #define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */
66 #define MNT_LAZY 3 /* push data not written by filesystem syncer */
68 #define MNT_RDONLY 0x00000001 /* read only filesystem */
69 #define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */
70 #define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */
71 #define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */
72 #define MNT_NODEV 0x00000010 /* don't interpret special files */
73 #define MNT_UNION 0x00000020 /* union with underlying filesystem */
74 #define MNT_ASYNC 0x00000040 /* file system written asynchronously */
75 #define MNT_NOCOREDUMP 0x00008000 /* don't write core dumps to this FS */
76 #define MNT_IGNORE 0x00100000 /* don't show entry in df */
77 #define MNT_LOG 0x02000000 /* Use logging */
78 #define MNT_NOATIME 0x04000000 /* Never update access times in fs */
79 #define MNT_SYMPERM 0x20000000 /* recognize symlink permission */
80 #define MNT_NODEVMTIME 0x40000000 /* Never update mod times for devs */
81 #define MNT_SOFTDEP 0x80000000 /* Use soft dependencies */
83 /* XXX from machine/param.h */
84 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
85 #define DEV_BSIZE (1 << DEV_BSHIFT)
88 /* FIXME: move?
89 * some stuff from sys/dirent.h.
91 #define DT_UNKNOWN 0
92 #define DT_FIFO 1
93 #define DT_CHR 2
94 #define DT_DIR 4
95 #define DT_BLK 6
96 #define DT_REG 8
97 #define DT_LNK 10
98 #define DT_SOCK 12
99 #define DT_WHT 14
101 * The _DIRENT_ALIGN macro returns the alignment of struct dirent.
102 * struct direct and struct dirent12 used 4 byte alignment but
103 * struct dirent uses 8.
105 /* FIXME: in mfs code sizeof(long) and not d_ino */
106 #undef _DIRENT_ALIGN
107 #define _DIRENT_ALIGN(dp) (sizeof((dp)->d_ino) - 1)
109 * The _DIRENT_NAMEOFF macro returns the offset of the d_name field in
110 * struct dirent
112 #define _DIRENT_NAMEOFF(dp) \
113 ((char *)(void *)&(dp)->d_name - (char *)(void *)dp)
115 * The _DIRENT_RECLEN macro gives the minimum record length which will hold
116 * a name of size "namlen". This requires the amount of space in struct dirent
117 * without the d_name field, plus enough space for the name with a terminating
118 * null byte (namlen+1), rounded up to a the appropriate byte boundary.
120 /* FIXME */
121 #undef _DIRENT_RECLEN
122 #define _DIRENT_RECLEN(dp, namlen) \
123 ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + _DIRENT_ALIGN(dp)) & \
124 ~_DIRENT_ALIGN(dp))
126 * The _DIRENT_NEXT macro advances to the next dirent record.
128 #define _DIRENT_NEXT(dp) ((void *)((char *)(void *)(dp) + (dp)->d_reclen))
133 /* forwards */
134 struct puffs_cc;
136 struct puffs_getreq;
137 struct puffs_cred;
138 struct puffs_newinfo;
140 /* paths */
141 struct puffs_pathobj {
142 void *po_path;
143 size_t po_len;
144 uint32_t po_hash;
147 /* for prefix rename */
148 struct puffs_pathinfo {
149 struct puffs_pathobj *pi_old;
150 struct puffs_pathobj *pi_new;
153 /* describes one segment cached in the kernel */
154 struct puffs_kcache {
155 off_t pkc_start;
156 off_t pkc_end;
158 LIST_ENTRY(puffs_kcache) pkc_entries;
161 /* XXX: might disappear from here into a private header */
162 struct puffs_node {
163 off_t pn_size;
164 int pn_flags;
165 struct vattr pn_va;
167 void *pn_data; /* private data */
169 struct puffs_pathobj pn_po; /* PUFFS_FLAG_BUILDPATH */
171 struct puffs_usermount *pn_mnt;
172 LIST_ENTRY(puffs_node) pn_entries;
174 LIST_HEAD(,puffs_kcache)pn_cacheinfo; /* PUFFS_KFLAG_CACHE */
176 /* MINIX fields */
177 char pn_mountpoint; /* true if mounted on */
178 int pn_count; /* # times inode used */
181 #define PUFFS_NODE_REMOVED 0x01 /* not on entry list */
184 struct puffs_usermount;
187 * megaXXX: these are values from inside _KERNEL
188 * need to work on the translation for ALL the necessary values.
190 #define PUFFS_VNOVAL (-1)
192 #define PUFFS_IO_APPEND 0x020
193 #define PUFFS_IO_NDELAY 0x100
195 #define PUFFS_VEXEC 01
196 #define PUFFS_VWRITE 02
197 #define PUFFS_VREAD 04
199 #define PUFFS_FSYNC_DATAONLY 0x0002
200 #define PUFFS_FSYNC_CACHE 0x0100
203 * Magic constants
205 #define PUFFS_CC_STACKSHIFT_DEFAULT 18
207 struct puffs_cn {
208 struct puffs_kcn *pcn_pkcnp; /* kernel input */
209 struct puffs_cred *pcn_cred; /* cred used for lookup */
211 struct puffs_pathobj pcn_po_full; /* PUFFS_FLAG_BUILDPATH */
213 #define pcn_nameiop pcn_pkcnp->pkcn_nameiop
214 #define pcn_flags pcn_pkcnp->pkcn_flags
215 #define pcn_name pcn_pkcnp->pkcn_name
216 #define pcn_namelen pcn_pkcnp->pkcn_namelen
217 #define pcn_consume pcn_pkcnp->pkcn_consume
220 * Puffs options to mount
222 /* kernel */
223 #define PUFFSMOPT_NAMECACHE { "namecache", 1, PUFFS_KFLAG_NOCACHE_NAME, 1 }
224 #define PUFFSMOPT_PAGECACHE { "pagecache", 1, PUFFS_KFLAG_NOCACHE_PAGE, 1 }
225 #define PUFFSMOPT_CACHE { "cache", 1, PUFFS_KFLAG_NOCACHE, 1 }
226 #define PUFFSMOPT_ALLOPS { "allops", 0, PUFFS_KFLAG_ALLOPS, 1 }
228 /* libpuffs */
229 #define PUFFSMOPT_DUMP { "dump", 0, PUFFS_FLAG_OPDUMP, 1 }
231 #define PUFFSMOPT_STD \
232 PUFFSMOPT_NAMECACHE, \
233 PUFFSMOPT_PAGECACHE, \
234 PUFFSMOPT_CACHE, \
235 PUFFSMOPT_ALLOPS, \
236 PUFFSMOPT_DUMP
238 extern const struct mntopt puffsmopts[]; /* puffs.c */
240 /* callbacks for operations */
241 struct puffs_ops {
242 int (*puffs_fs_unmount)(struct puffs_usermount *, int);
243 int (*puffs_fs_statvfs)(struct puffs_usermount *, struct statvfs *);
244 int (*puffs_fs_sync)(struct puffs_usermount *, int,
245 const struct puffs_cred *);
246 int (*puffs_fs_fhtonode)(struct puffs_usermount *, void *, size_t,
247 struct puffs_newinfo *);
248 int (*puffs_fs_nodetofh)(struct puffs_usermount *, puffs_cookie_t,
249 void *, size_t *);
250 void (*puffs_fs_suspend)(struct puffs_usermount *, int);
252 int (*puffs_node_lookup)(struct puffs_usermount *,
253 puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *);
254 int (*puffs_node_create)(struct puffs_usermount *,
255 puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *,
256 const struct vattr *);
257 int (*puffs_node_mknod)(struct puffs_usermount *,
258 puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *,
259 const struct vattr *);
260 int (*puffs_node_open)(struct puffs_usermount *,
261 puffs_cookie_t, int, const struct puffs_cred *);
262 int (*puffs_node_close)(struct puffs_usermount *,
263 puffs_cookie_t, int, const struct puffs_cred *);
264 int (*puffs_node_access)(struct puffs_usermount *,
265 puffs_cookie_t, int, const struct puffs_cred *);
266 int (*puffs_node_getattr)(struct puffs_usermount *,
267 puffs_cookie_t, struct vattr *, const struct puffs_cred *);
268 int (*puffs_node_setattr)(struct puffs_usermount *,
269 puffs_cookie_t, const struct vattr *, const struct puffs_cred *);
270 int (*puffs_node_poll)(struct puffs_usermount *, puffs_cookie_t, int *);
271 int (*puffs_node_mmap)(struct puffs_usermount *,
272 puffs_cookie_t, vm_prot_t, const struct puffs_cred *);
273 int (*puffs_node_fsync)(struct puffs_usermount *,
274 puffs_cookie_t, const struct puffs_cred *, int, off_t, off_t);
275 int (*puffs_node_seek)(struct puffs_usermount *,
276 puffs_cookie_t, off_t, off_t, const struct puffs_cred *);
277 int (*puffs_node_remove)(struct puffs_usermount *,
278 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
279 int (*puffs_node_link)(struct puffs_usermount *,
280 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
281 int (*puffs_node_rename)(struct puffs_usermount *,
282 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *,
283 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
284 int (*puffs_node_mkdir)(struct puffs_usermount *,
285 puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *,
286 const struct vattr *);
287 int (*puffs_node_rmdir)(struct puffs_usermount *,
288 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
289 int (*puffs_node_symlink)(struct puffs_usermount *,
290 puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *,
291 const struct vattr *,
292 const char *);
293 int (*puffs_node_readdir)(struct puffs_usermount *,
294 puffs_cookie_t, struct dirent *, off_t *, size_t *,
295 const struct puffs_cred *, int *, off_t *, size_t *);
296 int (*puffs_node_readlink)(struct puffs_usermount *,
297 puffs_cookie_t, const struct puffs_cred *, char *, size_t *);
298 int (*puffs_node_reclaim)(struct puffs_usermount *, puffs_cookie_t);
299 int (*puffs_node_inactive)(struct puffs_usermount *, puffs_cookie_t);
300 int (*puffs_node_print)(struct puffs_usermount *, puffs_cookie_t);
301 int (*puffs_node_pathconf)(struct puffs_usermount *,
302 puffs_cookie_t, int, int *);
303 int (*puffs_node_advlock)(struct puffs_usermount *,
304 puffs_cookie_t, void *, int, struct flock *, int);
305 int (*puffs_node_read)(struct puffs_usermount *, puffs_cookie_t,
306 uint8_t *, off_t, size_t *, const struct puffs_cred *, int);
307 int (*puffs_node_write)(struct puffs_usermount *, puffs_cookie_t,
308 uint8_t *, off_t, size_t *, const struct puffs_cred *, int);
309 int (*puffs_node_abortop)(struct puffs_usermount *, puffs_cookie_t,
310 const struct puffs_cn *);
312 #if 0
313 /* enable next time this structure is changed */
314 void *puffs_ops_spare[32];
315 #endif
318 typedef int (*pu_pathbuild_fn)(struct puffs_usermount *,
319 const struct puffs_pathobj *,
320 const struct puffs_pathobj *, size_t,
321 struct puffs_pathobj *);
322 typedef int (*pu_pathtransform_fn)(struct puffs_usermount *,
323 const struct puffs_pathobj *,
324 const struct puffs_cn *,
325 struct puffs_pathobj *);
326 typedef int (*pu_pathcmp_fn)(struct puffs_usermount *, struct puffs_pathobj *,
327 struct puffs_pathobj *, size_t, int);
328 typedef void (*pu_pathfree_fn)(struct puffs_usermount *,
329 struct puffs_pathobj *);
330 typedef int (*pu_namemod_fn)(struct puffs_usermount *,
331 struct puffs_pathobj *, struct puffs_cn *);
333 typedef void (*pu_errnotify_fn)(struct puffs_usermount *,
334 uint8_t, int, const char *, puffs_cookie_t);
336 typedef void (*pu_prepost_fn)(struct puffs_usermount *);
338 typedef struct puffs_node *(*pu_cmap_fn)(struct puffs_usermount *,
339 puffs_cookie_t);
341 enum {
342 PUFFS_STATE_BEFOREMOUNT, PUFFS_STATE_RUNNING,
343 PUFFS_STATE_UNMOUNTING, PUFFS_STATE_UNMOUNTED
346 #define PUFFS_FLAG_BUILDPATH 0x80000000 /* node paths in pnode */
347 #define PUFFS_FLAG_OPDUMP 0x40000000 /* dump all operations */
348 #define PUFFS_FLAG_HASHPATH 0x20000000 /* speedup: hash paths */
349 #define PUFFS_FLAG_MASK 0xe0000000
351 #define PUFFS_FLAG_KERN(a) ((a) & PUFFS_KFLAG_MASK)
352 #define PUFFS_FLAG_LIB(a) ((a) & PUFFS_FLAG_MASK)
354 /* blocking mode argument */
355 #define PUFFSDEV_BLOCK 0
356 #define PUFFSDEV_NONBLOCK 1
358 #define PUFFS_STACKSIZE_DEFAULT (1<<PUFFS_CC_STACKSHIFT_DEFAULT)
359 #define PUFFS_STACKSIZE_MIN ((size_t)-1)
361 #define DENT_DOT 0
362 #define DENT_DOTDOT 1
363 #define DENT_ADJ(a) ((a)-2) /* nth request means dir's n-2th */
367 * protos
370 #define PUFFSOP_PROTOS(fsname) \
371 int fsname##_fs_unmount(struct puffs_usermount *, int); \
372 int fsname##_fs_statvfs(struct puffs_usermount *, \
373 struct statvfs *); \
374 int fsname##_fs_sync(struct puffs_usermount *, int, \
375 const struct puffs_cred *cred); \
376 int fsname##_fs_fhtonode(struct puffs_usermount *, void *, \
377 size_t, struct puffs_newinfo *); \
378 int fsname##_fs_nodetofh(struct puffs_usermount *, \
379 puffs_cookie_t, void *, size_t *); \
380 void fsname##_fs_suspend(struct puffs_usermount *, int); \
382 int fsname##_node_lookup(struct puffs_usermount *, \
383 puffs_cookie_t, struct puffs_newinfo *, \
384 const struct puffs_cn *); \
385 int fsname##_node_create(struct puffs_usermount *, \
386 puffs_cookie_t, struct puffs_newinfo *, \
387 const struct puffs_cn *, const struct vattr *); \
388 int fsname##_node_mknod(struct puffs_usermount *, \
389 puffs_cookie_t, struct puffs_newinfo *, \
390 const struct puffs_cn *, const struct vattr *); \
391 int fsname##_node_open(struct puffs_usermount *, \
392 puffs_cookie_t, int, const struct puffs_cred *); \
393 int fsname##_node_close(struct puffs_usermount *, \
394 puffs_cookie_t, int, const struct puffs_cred *); \
395 int fsname##_node_access(struct puffs_usermount *, \
396 puffs_cookie_t, int, const struct puffs_cred *); \
397 int fsname##_node_getattr(struct puffs_usermount *, \
398 puffs_cookie_t, struct vattr *, const struct puffs_cred *); \
399 int fsname##_node_setattr(struct puffs_usermount *, \
400 puffs_cookie_t, const struct vattr *, \
401 const struct puffs_cred *); \
402 int fsname##_node_poll(struct puffs_usermount *, \
403 puffs_cookie_t, int *); \
404 int fsname##_node_mmap(struct puffs_usermount *, \
405 puffs_cookie_t, vm_prot_t, const struct puffs_cred *); \
406 int fsname##_node_fsync(struct puffs_usermount *, \
407 puffs_cookie_t, const struct puffs_cred *, int, \
408 off_t, off_t); \
409 int fsname##_node_seek(struct puffs_usermount *, \
410 puffs_cookie_t, off_t, off_t, const struct puffs_cred *); \
411 int fsname##_node_remove(struct puffs_usermount *, \
412 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *); \
413 int fsname##_node_link(struct puffs_usermount *, \
414 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *); \
415 int fsname##_node_rename(struct puffs_usermount *, \
416 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *, \
417 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *); \
418 int fsname##_node_mkdir(struct puffs_usermount *, \
419 puffs_cookie_t, struct puffs_newinfo *, \
420 const struct puffs_cn *, const struct vattr *); \
421 int fsname##_node_rmdir(struct puffs_usermount *, \
422 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *); \
423 int fsname##_node_symlink(struct puffs_usermount *, \
424 puffs_cookie_t, struct puffs_newinfo *, \
425 const struct puffs_cn *, const struct vattr *, \
426 const char *); \
427 int fsname##_node_readdir(struct puffs_usermount *, \
428 puffs_cookie_t, struct dirent *, off_t *, size_t *, \
429 const struct puffs_cred *, int *, off_t *, size_t *); \
430 int fsname##_node_readlink(struct puffs_usermount *, \
431 puffs_cookie_t, const struct puffs_cred *, char *, \
432 size_t *); \
433 int fsname##_node_reclaim(struct puffs_usermount *, \
434 puffs_cookie_t); \
435 int fsname##_node_inactive(struct puffs_usermount *, \
436 puffs_cookie_t); \
437 int fsname##_node_print(struct puffs_usermount *, \
438 puffs_cookie_t); \
439 int fsname##_node_pathconf(struct puffs_usermount *, \
440 puffs_cookie_t, int, int *); \
441 int fsname##_node_advlock(struct puffs_usermount *, \
442 puffs_cookie_t, void *, int, struct flock *, int); \
443 int fsname##_node_read(struct puffs_usermount *, puffs_cookie_t,\
444 uint8_t *, off_t, size_t *, const struct puffs_cred *, int);\
445 int fsname##_node_write(struct puffs_usermount *, \
446 puffs_cookie_t, uint8_t *, off_t, size_t *, \
447 const struct puffs_cred *, int); \
448 int fsname##_node_abortop(struct puffs_usermount *, \
449 puffs_cookie_t, const struct puffs_cn *);
451 #define PUFFSOP_INIT(ops) \
452 ops = malloc(sizeof(struct puffs_ops)); \
453 memset(ops, 0, sizeof(struct puffs_ops))
454 #define PUFFSOP_SET(ops, fsname, fsornode, opname) \
455 (ops)->puffs_##fsornode##_##opname = fsname##_##fsornode##_##opname
456 #define PUFFSOP_SETFSNOP(ops, opname) \
457 (ops)->puffs_fs_##opname = puffs_fsnop_##opname
459 PUFFSOP_PROTOS(puffs_null) /* XXX */
461 #define PUFFS_DEVEL_LIBVERSION 34
462 #define puffs_init(a,b,c,d,e) \
463 _puffs_init(PUFFS_DEVEL_LIBVERSION,a,b,c,d,e)
466 #define PNPATH(pnode) ((pnode)->pn_po.po_path)
467 #define PNPLEN(pnode) ((pnode)->pn_po.po_len)
468 #define PCNPATH(pcnode) ((pcnode)->pcn_po_full.po_path)
469 #define PCNPLEN(pcnode) ((pcnode)->pcn_po_full.po_len)
470 #define PCNISDOTDOT(pcnode) \
471 ((pcnode)->pcn_namelen == 2 && strcmp((pcnode)->pcn_name, "..") == 0)
473 #define PUFFS_STORE_DCOOKIE(cp, ncp, off) \
474 if (cp) { \
475 *((cp)++) = off; \
476 (*(ncp))++; \
479 /* mainloop */
480 typedef void (*puffs_ml_loop_fn)(struct puffs_usermount *);
482 /* framebuf stuff */
483 struct puffs_framebuf;
484 typedef int (*puffs_framev_readframe_fn)(struct puffs_usermount *,
485 struct puffs_framebuf *,
486 int, int *);
487 typedef int (*puffs_framev_writeframe_fn)(struct puffs_usermount *,
488 struct puffs_framebuf *,
489 int, int *);
490 typedef int (*puffs_framev_cmpframe_fn)(struct puffs_usermount *,
491 struct puffs_framebuf *,
492 struct puffs_framebuf *,
493 int *);
494 typedef void (*puffs_framev_fdnotify_fn)(struct puffs_usermount *, int, int);
495 typedef void (*puffs_framev_gotframe_fn)(struct puffs_usermount *,
496 struct puffs_framebuf *);
497 typedef void (*puffs_framev_cb)(struct puffs_usermount *,
498 struct puffs_framebuf *,
499 void *, int);
500 #define PUFFS_FBIO_READ 0x01
501 #define PUFFS_FBIO_WRITE 0x02
502 #define PUFFS_FBIO_ERROR 0x04
504 #define PUFFS_FBQUEUE_URGENT 0x01
507 __BEGIN_DECLS
509 #define PUFFS_DEFER ((void *)-1)
510 struct puffs_usermount *_puffs_init(int, struct puffs_ops *, const char *,
511 const char *, void *, uint32_t);
512 int puffs_mount(struct puffs_usermount *, const char *, int, void*);
513 int puffs_exit(struct puffs_usermount *, int);
514 void puffs_cancel(struct puffs_usermount *, int);
515 int puffs_mainloop(struct puffs_usermount *);
518 int puffs_getstate(struct puffs_usermount *);
519 void puffs_setstacksize(struct puffs_usermount *, size_t);
521 void puffs_ml_setloopfn(struct puffs_usermount *, puffs_ml_loop_fn);
522 void puffs_ml_settimeout(struct puffs_usermount *, struct timespec *);
524 void puffs_setroot(struct puffs_usermount *,
525 struct puffs_node *);
526 struct puffs_node *puffs_getroot(struct puffs_usermount *);
527 void puffs_setrootinfo(struct puffs_usermount *,
528 enum vtype, vsize_t, dev_t);
530 void *puffs_getspecific(struct puffs_usermount *);
531 void puffs_setspecific(struct puffs_usermount *, void *);
532 void puffs_setmaxreqlen(struct puffs_usermount *, size_t);
533 size_t puffs_getmaxreqlen(struct puffs_usermount *);
534 void puffs_setfhsize(struct puffs_usermount *, size_t, int);
535 void puffs_setmntinfo(struct puffs_usermount *,
536 const char *, const char *);
538 void puffs_setncookiehash(struct puffs_usermount *, int);
540 struct puffs_pathobj *puffs_getrootpathobj(struct puffs_usermount *);
542 struct puffs_node *puffs_pn_new(struct puffs_usermount *, void *);
543 void puffs_pn_remove(struct puffs_node *);
544 void puffs_pn_put(struct puffs_node *);
545 struct vattr *puffs_pn_getvap(struct puffs_node *);
546 void * puffs_pn_getpriv(struct puffs_node *);
547 void puffs_pn_setpriv(struct puffs_node *, void *);
548 struct puffs_pathobj *puffs_pn_getpo(struct puffs_node *);
549 struct puffs_usermount *puffs_pn_getmnt(struct puffs_node *);
551 void puffs_newinfo_setcookie(struct puffs_newinfo *, puffs_cookie_t);
552 void puffs_newinfo_setvtype(struct puffs_newinfo *, enum vtype);
553 void puffs_newinfo_setsize(struct puffs_newinfo *, voff_t);
554 void puffs_newinfo_setrdev(struct puffs_newinfo *, dev_t);
556 void *puffs_pn_getmntspecific(struct puffs_node *);
558 typedef void * (*puffs_nodewalk_fn)(struct puffs_usermount *,
559 struct puffs_node *, void *);
560 void *puffs_pn_nodewalk(struct puffs_usermount *,
561 puffs_nodewalk_fn, void *);
562 void *puffs_pn_nodeprint(struct puffs_usermount *pu,
563 struct puffs_node *pn, void *arg);
564 void puffs_pn_nodeprintall(struct puffs_usermount *pu);
566 void puffs_setvattr(struct vattr *, const struct vattr *);
567 void puffs_vattr_null(struct vattr *);
569 void puffs_null_setops(struct puffs_ops *);
571 int puffs_dispatch_create(struct puffs_usermount *,
572 struct puffs_framebuf *,
573 struct puffs_cc **);
574 int puffs_dispatch_exec(struct puffs_cc *,
575 struct puffs_framebuf **);
578 * generic/dummy routines applicable for some file systems
580 int puffs_fsnop_unmount(struct puffs_usermount *, int);
581 int puffs_fsnop_statvfs(struct puffs_usermount *, struct statvfs *);
582 void puffs_zerostatvfs(struct statvfs *);
583 int puffs_fsnop_sync(struct puffs_usermount *, int waitfor,
584 const struct puffs_cred *);
586 int puffs_genfs_node_getattr(struct puffs_usermount *, puffs_cookie_t,
587 struct vattr *, const struct puffs_cred *);
588 int puffs_genfs_node_reclaim(struct puffs_usermount *, puffs_cookie_t);
591 * Subroutine stuff
594 int puffs_gendotdent(struct dirent **, ino_t, int, size_t *);
595 int puffs_nextdent(struct dirent **, const char *, ino_t,
596 uint8_t, size_t *);
597 int puffs_vtype2dt(enum vtype);
598 enum vtype puffs_mode2vt(mode_t);
599 void puffs_stat2vattr(struct vattr *va, const struct stat *);
600 mode_t puffs_addvtype2mode(mode_t, enum vtype);
604 * credentials & permissions
607 /* Credential fetch */
608 int puffs_cred_getuid(const struct puffs_cred *, uid_t *);
609 int puffs_cred_getgid(const struct puffs_cred *, gid_t *);
610 int puffs_cred_getgroups(const struct puffs_cred *, gid_t *, short *);
612 /* Credential check */
613 bool puffs_cred_isuid(const struct puffs_cred *, uid_t);
614 bool puffs_cred_hasgroup(const struct puffs_cred *, gid_t);
615 bool puffs_cred_isregular(const struct puffs_cred *);
616 bool puffs_cred_iskernel(const struct puffs_cred *);
617 bool puffs_cred_isfs(const struct puffs_cred *);
618 bool puffs_cred_isjuggernaut(const struct puffs_cred *);
620 /* misc */
621 int puffs_access(enum vtype, mode_t, uid_t, gid_t, mode_t,
622 const struct puffs_cred *);
623 int puffs_access_chown(uid_t, gid_t, uid_t, gid_t,
624 const struct puffs_cred *);
625 int puffs_access_chmod(uid_t, gid_t, enum vtype, mode_t,
626 const struct puffs_cred *);
627 int puffs_access_times(uid_t, gid_t, mode_t, int,
628 const struct puffs_cred *);
632 * Call Context interfaces relevant for user.
635 void puffs_cc_yield(struct puffs_cc *);
636 void puffs_cc_continue(struct puffs_cc *);
637 void puffs_cc_schedule(struct puffs_cc *);
638 int puffs_cc_getcaller(struct puffs_cc *,pid_t *,lwpid_t *);
639 struct puffs_cc *puffs_cc_getcc(struct puffs_usermount *);
642 * Flushing / invalidation routines
645 int puffs_inval_namecache_dir(struct puffs_usermount *, puffs_cookie_t);
646 int puffs_inval_namecache_all(struct puffs_usermount *);
648 int puffs_inval_pagecache_node(struct puffs_usermount *, puffs_cookie_t);
649 int puffs_inval_pagecache_node_range(struct puffs_usermount *,
650 puffs_cookie_t, off_t, off_t);
651 int puffs_flush_pagecache_node(struct puffs_usermount *, puffs_cookie_t);
652 int puffs_flush_pagecache_node_range(struct puffs_usermount *,
653 puffs_cookie_t, off_t, off_t);
656 * Path constructicons
659 int puffs_stdpath_buildpath(struct puffs_usermount *,
660 const struct puffs_pathobj *,
661 const struct puffs_pathobj *, size_t,
662 struct puffs_pathobj *);
663 int puffs_stdpath_cmppath(struct puffs_usermount *, struct puffs_pathobj *,
664 struct puffs_pathobj *, size_t, int);
665 void puffs_stdpath_freepath(struct puffs_usermount *,struct puffs_pathobj *);
667 void *puffs_path_walkcmp(struct puffs_usermount *,
668 struct puffs_node *, void *);
669 void *puffs_path_prefixadj(struct puffs_usermount *,
670 struct puffs_node *, void *);
671 int puffs_path_pcnbuild(struct puffs_usermount *,
672 struct puffs_cn *, void *);
673 void puffs_path_buildhash(struct puffs_usermount *, struct puffs_pathobj *);
674 void puffs_set_pathbuild(struct puffs_usermount *, pu_pathbuild_fn); void puffs_set_pathtransform(struct puffs_usermount *, pu_pathtransform_fn);
675 void puffs_set_pathcmp(struct puffs_usermount *, pu_pathcmp_fn);
676 void puffs_set_pathfree(struct puffs_usermount *, pu_pathfree_fn);
677 void puffs_set_namemod(struct puffs_usermount *, pu_namemod_fn);
679 void puffs_set_errnotify(struct puffs_usermount *, pu_errnotify_fn);
680 void puffs_set_prepost(struct puffs_usermount *,
681 pu_prepost_fn, pu_prepost_fn);
682 void puffs_set_cmap(struct puffs_usermount *, pu_cmap_fn);
685 * Suspension
688 int puffs_fs_suspend(struct puffs_usermount *);
691 * Frame buffering
694 void puffs_framev_init(struct puffs_usermount *,
695 puffs_framev_readframe_fn,
696 puffs_framev_writeframe_fn,
697 puffs_framev_cmpframe_fn,
698 puffs_framev_gotframe_fn,
699 puffs_framev_fdnotify_fn);
701 struct puffs_framebuf *puffs_framebuf_make(void);
702 void puffs_framebuf_destroy(struct puffs_framebuf *);
703 int puffs_framebuf_dup(struct puffs_framebuf *,
704 struct puffs_framebuf **);
705 void puffs_framebuf_recycle(struct puffs_framebuf *);
706 int puffs_framebuf_reserve_space(struct puffs_framebuf *,
707 size_t);
709 int puffs_framebuf_putdata(struct puffs_framebuf *, const void *, size_t);
710 int puffs_framebuf_putdata_atoff(struct puffs_framebuf *, size_t,
711 const void *, size_t);
712 int puffs_framebuf_getdata(struct puffs_framebuf *, void *, size_t);
713 int puffs_framebuf_getdata_atoff(struct puffs_framebuf *, size_t,
714 void *, size_t);
716 size_t puffs_framebuf_telloff(struct puffs_framebuf *);
717 size_t puffs_framebuf_tellsize(struct puffs_framebuf *);
718 size_t puffs_framebuf_remaining(struct puffs_framebuf *);
719 int puffs_framebuf_seekset(struct puffs_framebuf *, size_t);
720 int puffs_framebuf_getwindow(struct puffs_framebuf *, size_t,
721 void **, size_t *);
723 int puffs_framev_enqueue_cc(struct puffs_cc *, int,
724 struct puffs_framebuf *, int);
725 int puffs_framev_enqueue_cb(struct puffs_usermount *, int,
726 struct puffs_framebuf *,
727 puffs_framev_cb, void *, int);
728 int puffs_framev_enqueue_justsend(struct puffs_usermount *, int,
729 struct puffs_framebuf *, int, int);
730 int puffs_framev_enqueue_directreceive(struct puffs_cc *, int,
731 struct puffs_framebuf *, int);
732 int puffs_framev_enqueue_directsend(struct puffs_cc *, int,
733 struct puffs_framebuf *, int);
734 int puffs_framev_enqueue_waitevent(struct puffs_cc *, int, int *);
735 int puffs_framev_framebuf_ccpromote(struct puffs_framebuf *,
736 struct puffs_cc *);
738 int puffs_framev_addfd(struct puffs_usermount *, int, int);
739 int puffs_framev_enablefd(struct puffs_usermount *, int, int);
740 int puffs_framev_disablefd(struct puffs_usermount *, int, int);
741 int puffs_framev_removefd(struct puffs_usermount *, int, int);
742 void puffs_framev_removeonclose(struct puffs_usermount *, int, int);
743 void puffs_framev_unmountonclose(struct puffs_usermount *, int, int);
745 __END_DECLS
747 #endif /* _PUFFS_H_ */