1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/* $OpenBSD: fuse_private.h,v 1.22 2018/11/16 02:16:17 tedu Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _FUSE_SUBR_H_
#define _FUSE_SUBR_H_
#include <sys/dirent.h>
#include <sys/event.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/tree.h>
#include <sys/fusebuf.h>
#include <limits.h>
#include "fuse.h"
struct fuse_args;
struct fuse_vnode {
ino_t ino;
struct fuse_vnode *parent;
unsigned int ref;
char path[NAME_MAX + 1];
SIMPLEQ_ENTRY(fuse_vnode) node; /* for dict */
};
struct fuse_dirhandle {
struct fuse *fuse;
fuse_fill_dir_t filler;
void *buf;
int full;
uint32_t size;
uint32_t start;
uint32_t idx;
off_t off;
};
SIMPLEQ_HEAD(fuse_vn_head, fuse_vnode);
SPLAY_HEAD(dict, dictentry);
SPLAY_HEAD(tree, treeentry);
struct fuse_session {
void *args;
};
struct fuse_chan {
char *dir;
struct fuse_args *args;
int fd;
int dead;
/* kqueue stuff */
int kq;
};
struct fuse_config {
uid_t uid;
gid_t gid;
pid_t pid;
mode_t umask;
int set_mode;
int set_uid;
int set_gid;
int use_ino;
};
struct fuse_core_opts {
char *mp;
int foreground;
};
struct fuse_mount_opts {
char *fsname;
int allow_other;
int def_perms;
int max_read;
int noatime;
int nonempty;
int rdonly;
};
struct fuse {
struct fuse_chan *fc;
struct fuse_operations op;
int compat;
struct tree vnode_tree;
struct dict name_tree;
uint64_t max_ino;
void *private_data;
struct fuse_config conf;
struct fuse_session se;
};
#define FUSE_MAX_OPS 39
#define FUSE_ROOT_INO ((ino_t)1)
/* fuse_ops.c */
int ifuse_exec_opcode(struct fuse *, struct fusebuf *);
/* fuse_subr.c */
struct fuse_vnode *alloc_vn(struct fuse *, const char *, ino_t, ino_t);
void ref_vn(struct fuse_vnode *);
void unref_vn(struct fuse *, struct fuse_vnode *);
struct fuse_vnode *get_vn_by_name_and_parent(struct fuse *, uint8_t *,
ino_t);
void remove_vnode_from_name_tree(struct fuse *,
struct fuse_vnode *);
int set_vn(struct fuse *, struct fuse_vnode *);
char *build_realname(struct fuse *, ino_t);
/* tree.c */
#define tree_init(t) SPLAY_INIT((t))
#define tree_empty(t) SPLAY_EMPTY((t))
int tree_check(struct tree *, uint64_t);
void *tree_set(struct tree *, uint64_t, void *);
void *tree_get(struct tree *, uint64_t);;
void *tree_pop(struct tree *, uint64_t);
/* dict.c */
int dict_check(struct dict *, const char *);
void *dict_set(struct dict *, const char *, void *);
void *dict_get(struct dict *, const char *);;
void *dict_pop(struct dict *, const char *);
#define FUSE_VERSION_PKG_INFO "2.8.0"
#define unused __attribute__ ((unused))
#define PROTO(x) __dso_hidden typeof(x) x asm("__"#x)
#define DEF(x) __strong_alias(x, __##x)
PROTO(fuse_daemonize);
PROTO(fuse_destroy);
PROTO(fuse_get_context);
PROTO(fuse_get_session);
PROTO(fuse_loop);
PROTO(fuse_mount);
PROTO(fuse_new);
PROTO(fuse_opt_add_arg);
PROTO(fuse_opt_free_args);
PROTO(fuse_opt_insert_arg);
PROTO(fuse_opt_match);
PROTO(fuse_opt_parse);
PROTO(fuse_parse_cmdline);
PROTO(fuse_remove_signal_handlers);
PROTO(fuse_setup);
PROTO(fuse_unmount);
#endif /* _FUSE_SUBR_ */
|