fuse.h revision 1.3 1 1.1 agc /*
2 1.1 agc * Copyright 2007 Alistair Crooks. All rights reserved.
3 1.1 agc *
4 1.1 agc * Redistribution and use in source and binary forms, with or without
5 1.1 agc * modification, are permitted provided that the following conditions
6 1.1 agc * are met:
7 1.1 agc * 1. Redistributions of source code must retain the above copyright
8 1.1 agc * notice, this list of conditions and the following disclaimer.
9 1.1 agc * 2. Redistributions in binary form must reproduce the above copyright
10 1.1 agc * notice, this list of conditions and the following disclaimer in the
11 1.1 agc * documentation and/or other materials provided with the distribution.
12 1.1 agc * 3. The name of the author may not be used to endorse or promote
13 1.1 agc * products derived from this software without specific prior written
14 1.1 agc * permission.
15 1.1 agc *
16 1.1 agc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
17 1.1 agc * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 1.1 agc * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.1 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20 1.1 agc * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.1 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 1.1 agc * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1 agc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 1.1 agc * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 1.1 agc * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 1.1 agc * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 1.1 agc */
28 1.1 agc #ifndef FUSE_H_
29 1.1 agc #define FUSE_H_ 20070123
30 1.1 agc
31 1.1 agc #include <sys/types.h>
32 1.1 agc
33 1.1 agc #include <puffs.h>
34 1.1 agc #include <utime.h>
35 1.1 agc
36 1.1 agc #ifdef __cplusplus
37 1.1 agc extern "C" {
38 1.1 agc #endif
39 1.1 agc
40 1.1 agc struct fuse_file_info {
41 1.1 agc int32_t flags;
42 1.1 agc uint32_t fh_old;
43 1.1 agc int32_t writepage;
44 1.1 agc uint32_t direct_io:1;
45 1.1 agc uint32_t keep_cache:1;
46 1.1 agc uint32_t flush:1;
47 1.1 agc uint32_t padding:29;
48 1.1 agc uint64_t fh;
49 1.1 agc uint64_t lock_owner;
50 1.1 agc };
51 1.1 agc
52 1.1 agc struct fuse_conn_info {
53 1.1 agc uint32_t proto_major;
54 1.1 agc uint32_t proto_minor;
55 1.1 agc uint32_t async_read;
56 1.1 agc uint32_t max_write;
57 1.1 agc uint32_t max_readahead;
58 1.1 agc uint32_t reserved[27];
59 1.1 agc };
60 1.1 agc
61 1.1 agc struct fuse_opt {
62 1.1 agc const char *templ;
63 1.1 agc uint32_t offset;
64 1.1 agc int32_t value;
65 1.1 agc };
66 1.1 agc
67 1.3 pooka /* equivalent'ish of puffs_cc */
68 1.3 pooka struct fuse_context {
69 1.3 pooka struct fuse *fuse;
70 1.3 pooka uid_t uid;
71 1.3 pooka gid_t gid;
72 1.3 pooka pid_t pid;
73 1.3 pooka void *private_data;
74 1.3 pooka };
75 1.3 pooka
76 1.1 agc #define FUSE_OPT_KEY(templ, key) { templ, -1U, key }
77 1.1 agc
78 1.1 agc #define FUSE_OPT_END { .templ = NULL }
79 1.1 agc
80 1.1 agc /**
81 1.1 agc * Argument list
82 1.1 agc */
83 1.1 agc struct fuse_args {
84 1.1 agc int argc;
85 1.1 agc char **argv;
86 1.1 agc int allocated;
87 1.1 agc };
88 1.1 agc
89 1.1 agc /**
90 1.1 agc * Initializer for 'struct fuse_args'
91 1.1 agc */
92 1.1 agc #define FUSE_ARGS_INIT(argc, argv) { argc, argv, 0 }
93 1.1 agc
94 1.1 agc enum {
95 1.1 agc FUSE_OPT_KEY_OPT = -1,
96 1.1 agc FUSE_OPT_KEY_NONOPT = -2,
97 1.1 agc FUSE_OPT_KEY_KEEP = -3,
98 1.1 agc FUSE_OPT_KEY_DISCARD = -4
99 1.1 agc };
100 1.1 agc
101 1.2 pooka typedef struct fuse_dirh *fuse_dirh_t;
102 1.2 pooka
103 1.1 agc typedef int (*fuse_fill_dir_t)(void *, const char *, const struct stat *, off_t);
104 1.2 pooka typedef int (*fuse_dirfil_t)(fuse_dirh_t, const char *, int, ino_t);
105 1.1 agc
106 1.1 agc #define FUSE_VERSION 26
107 1.1 agc
108 1.1 agc /*
109 1.1 agc * These operations shadow those in puffs_usermount, and are used
110 1.1 agc * as a table of callbacks to make when file system requests come
111 1.1 agc * in.
112 1.1 agc */
113 1.1 agc struct fuse_operations {
114 1.1 agc int (*getattr)(const char *, struct stat *);
115 1.1 agc int (*readlink)(const char *, char *, size_t);
116 1.1 agc int (*mknod)(const char *, mode_t, dev_t);
117 1.1 agc int (*mkdir)(const char *, mode_t);
118 1.1 agc int (*unlink)(const char *);
119 1.1 agc int (*rmdir)(const char *);
120 1.1 agc int (*symlink)(const char *, const char *);
121 1.1 agc int (*rename)(const char *, const char *);
122 1.1 agc int (*link)(const char *, const char *);
123 1.1 agc int (*chmod)(const char *, mode_t);
124 1.1 agc int (*chown)(const char *, uid_t, gid_t);
125 1.1 agc int (*truncate)(const char *, off_t);
126 1.1 agc int (*utime)(const char *, struct utimbuf *);
127 1.1 agc int (*open)(const char *, struct fuse_file_info *);
128 1.1 agc int (*read)(const char *, char *, size_t, off_t, struct fuse_file_info *);
129 1.1 agc int (*write)(const char *, const char *, size_t, off_t, struct fuse_file_info *);
130 1.1 agc int (*statfs)(const char *, struct statvfs *);
131 1.1 agc int (*flush)(const char *, struct fuse_file_info *);
132 1.1 agc int (*release)(const char *, struct fuse_file_info *);
133 1.1 agc int (*fsync)(const char *, int, struct fuse_file_info *);
134 1.1 agc int (*setxattr)(const char *, const char *, const char *, size_t, int);
135 1.1 agc int (*getxattr)(const char *, const char *, char *, size_t);
136 1.1 agc int (*listxattr)(const char *, char *, size_t);
137 1.1 agc int (*removexattr)(const char *, const char *);
138 1.1 agc int (*opendir)(const char *, struct fuse_file_info *);
139 1.1 agc int (*readdir)(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *);
140 1.2 pooka int (*getdir)(const char *, fuse_dirh_t, fuse_dirfil_t);
141 1.1 agc int (*releasedir)(const char *, struct fuse_file_info *);
142 1.1 agc int (*fsyncdir)(const char *, int, struct fuse_file_info *);
143 1.1 agc void *(*init)(struct fuse_conn_info *);
144 1.1 agc void (*destroy)(void *);
145 1.1 agc int (*access)(const char *, int);
146 1.1 agc int (*create)(const char *, mode_t, struct fuse_file_info *);
147 1.1 agc int (*ftruncate)(const char *, off_t, struct fuse_file_info *);
148 1.1 agc int (*fgetattr)(const char *, struct stat *, struct fuse_file_info *);
149 1.1 agc int (*lock)(const char *, struct fuse_file_info *, int, struct flock *);
150 1.1 agc int (*utimens)(const char *, const struct timespec *);
151 1.1 agc int (*bmap)(const char *, size_t , uint64_t *);
152 1.1 agc struct puffs_ops puffs_ops; /* pointer to puffs operations */
153 1.1 agc };
154 1.1 agc
155 1.1 agc
156 1.1 agc typedef int (*fuse_opt_proc_t)(void *, const char *, int, struct fuse_args *);
157 1.1 agc
158 1.1 agc
159 1.1 agc int fuse_opt_add_arg(struct fuse_args *, const char *);
160 1.1 agc int fuse_opt_parse(struct fuse_args *, void *, const struct fuse_opt *, fuse_opt_proc_t);
161 1.1 agc int fuse_main_real(int, char **, const struct fuse_operations *, size_t, void *);
162 1.3 pooka struct fuse_context *fuse_get_context(void);
163 1.1 agc
164 1.1 agc
165 1.1 agc #define fuse_main(argc, argv, op) \
166 1.1 agc fuse_main_real(argc, argv, op, sizeof(*(op)), NULL)
167 1.1 agc
168 1.1 agc
169 1.1 agc #ifdef __cplusplus
170 1.1 agc }
171 1.1 agc #endif
172 1.1 agc
173 1.1 agc #endif
174