1 /* $OpenBSD: fuse_private.h,v 1.11 2015/01/16 16:48:51 deraadt Exp $ */ 2 /* 3 * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #ifndef _FUSE_SUBR_H_ 19 #define _FUSE_SUBR_H_ 20 21 #include <sys/dirent.h> 22 #include <sys/mount.h> 23 #include <sys/statvfs.h> 24 #include <sys/vnode.h> 25 #include <sys/fusebuf.h> 26 #include <limits.h> 27 28 #include "fuse.h" 29 30 struct fuse_dirhandle; 31 struct fuse_args; 32 33 struct fuse_vnode { 34 ino_t ino; 35 ino_t parent; 36 37 char path[NAME_MAX + 1]; 38 struct fuse_dirhandle *fd; 39 40 SIMPLEQ_ENTRY(fuse_vnode) node; /* for dict */ 41 }; 42 43 SIMPLEQ_HEAD(fuse_vn_head, fuse_vnode); 44 SPLAY_HEAD(dict, dictentry); 45 SPLAY_HEAD(tree, treeentry); 46 47 struct fuse_session { 48 void *args; 49 }; 50 51 struct fuse_chan { 52 char *dir; 53 struct fuse_args *args; 54 55 int fd; 56 int dead; 57 58 /* kqueue stuff */ 59 int kq; 60 struct kevent event; 61 }; 62 63 struct fuse_config { 64 uid_t uid; 65 gid_t gid; 66 pid_t pid; 67 mode_t umask; 68 int set_mode; 69 int set_uid; 70 int set_gid; 71 }; 72 73 struct fuse_core_opt { 74 char *mp; 75 }; 76 77 struct fuse { 78 struct fuse_chan *fc; 79 struct fuse_operations op; 80 81 int compat; 82 83 struct tree vnode_tree; 84 struct dict name_tree; 85 uint64_t max_ino; 86 void *private_data; 87 88 struct fuse_config conf; 89 struct fuse_session se; 90 }; 91 92 #define FUSE_MAX_OPS 39 93 #define FUSE_ROOT_INO ((ino_t)1) 94 95 /* fuse_ops.c */ 96 int ifuse_exec_opcode(struct fuse *, struct fusebuf *); 97 98 /* fuse_subr.c */ 99 struct fuse_vnode *alloc_vn(struct fuse *, const char *, ino_t, ino_t); 100 struct fuse_vnode *get_vn_by_name_and_parent(struct fuse *, uint8_t *, 101 ino_t); 102 void remove_vnode_from_name_tree(struct fuse *, 103 struct fuse_vnode *); 104 int set_vn(struct fuse *, struct fuse_vnode *); 105 char *build_realname(struct fuse *, ino_t); 106 107 /* tree.c */ 108 #define tree_init(t) SPLAY_INIT((t)) 109 #define tree_empty(t) SPLAY_EMPTY((t)) 110 int tree_check(struct tree *, uint64_t); 111 void *tree_set(struct tree *, uint64_t, void *); 112 void *tree_get(struct tree *, uint64_t);; 113 void *tree_pop(struct tree *, uint64_t); 114 115 /* dict.c */ 116 int dict_check(struct dict *, const char *); 117 void *dict_set(struct dict *, const char *, void *); 118 void *dict_get(struct dict *, const char *);; 119 void *dict_pop(struct dict *, const char *); 120 121 #define FUSE_VERSION_PKG_INFO "2.8.0" 122 #define unused __attribute__ ((unused)) 123 124 #endif /* _FUSE_SUBR_ */ 125