1 /* $OpenBSD: fuse_private.h,v 1.14 2016/09/07 17:53:35 natano 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/event.h> 23 #include <sys/mount.h> 24 #include <sys/stat.h> 25 #include <sys/statvfs.h> 26 #include <sys/tree.h> 27 #include <sys/fusebuf.h> 28 #include <limits.h> 29 30 #include "fuse.h" 31 32 struct fuse_dirhandle; 33 struct fuse_args; 34 35 struct fuse_vnode { 36 ino_t ino; 37 struct fuse_vnode *parent; 38 unsigned int ref; 39 40 char path[NAME_MAX + 1]; 41 struct fuse_dirhandle *fd; 42 43 SIMPLEQ_ENTRY(fuse_vnode) node; /* for dict */ 44 }; 45 46 SIMPLEQ_HEAD(fuse_vn_head, fuse_vnode); 47 SPLAY_HEAD(dict, dictentry); 48 SPLAY_HEAD(tree, treeentry); 49 50 struct fuse_session { 51 void *args; 52 }; 53 54 struct fuse_chan { 55 char *dir; 56 struct fuse_args *args; 57 58 int fd; 59 int dead; 60 61 /* kqueue stuff */ 62 int kq; 63 struct kevent event; 64 }; 65 66 struct fuse_config { 67 uid_t uid; 68 gid_t gid; 69 pid_t pid; 70 mode_t umask; 71 int set_mode; 72 int set_uid; 73 int set_gid; 74 }; 75 76 struct fuse_core_opt { 77 char *mp; 78 }; 79 80 struct fuse { 81 struct fuse_chan *fc; 82 struct fuse_operations op; 83 84 int compat; 85 86 struct tree vnode_tree; 87 struct dict name_tree; 88 uint64_t max_ino; 89 void *private_data; 90 91 struct fuse_config conf; 92 struct fuse_session se; 93 }; 94 95 #define FUSE_MAX_OPS 39 96 #define FUSE_ROOT_INO ((ino_t)1) 97 98 /* fuse_ops.c */ 99 int ifuse_exec_opcode(struct fuse *, struct fusebuf *); 100 101 /* fuse_subr.c */ 102 struct fuse_vnode *alloc_vn(struct fuse *, const char *, ino_t, ino_t); 103 void ref_vn(struct fuse_vnode *); 104 void unref_vn(struct fuse *, struct fuse_vnode *); 105 struct fuse_vnode *get_vn_by_name_and_parent(struct fuse *, uint8_t *, 106 ino_t); 107 void remove_vnode_from_name_tree(struct fuse *, 108 struct fuse_vnode *); 109 int set_vn(struct fuse *, struct fuse_vnode *); 110 char *build_realname(struct fuse *, ino_t); 111 112 /* tree.c */ 113 #define tree_init(t) SPLAY_INIT((t)) 114 #define tree_empty(t) SPLAY_EMPTY((t)) 115 int tree_check(struct tree *, uint64_t); 116 void *tree_set(struct tree *, uint64_t, void *); 117 void *tree_get(struct tree *, uint64_t);; 118 void *tree_pop(struct tree *, uint64_t); 119 120 /* dict.c */ 121 int dict_check(struct dict *, const char *); 122 void *dict_set(struct dict *, const char *, void *); 123 void *dict_get(struct dict *, const char *);; 124 void *dict_pop(struct dict *, const char *); 125 126 #define FUSE_VERSION_PKG_INFO "2.8.0" 127 #define unused __attribute__ ((unused)) 128 129 #endif /* _FUSE_SUBR_ */ 130