1 /* $NetBSD: fuse.h,v 1.20 2008/01/14 20:46:11 pooka Exp $ */
4 * Copyright © 2007 Alistair Crooks. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote
15 * products derived from this software without specific prior written
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #define FUSE_H_ 20070123
33 /* set the default version to use for the fuse interface */
34 /* this value determines the API to be used */
35 #ifndef FUSE_USE_VERSION
36 #define FUSE_USE_VERSION 26
39 #include <sys/types.h>
49 struct fuse_args
; /* XXXsupportme */
51 struct fuse_file_info
{
56 uint32_t keep_cache
:1;
63 struct fuse_conn_info
{
68 uint32_t max_readahead
;
69 uint32_t reserved
[27];
72 /* equivalent'ish of puffs_cc */
91 * Initializer for 'struct fuse_args'
93 #define FUSE_ARGS_INIT(argc, argv) { argc, argv, 0 }
95 typedef struct puffs_fuse_dirh
*fuse_dirh_t
;
97 typedef int (*fuse_fill_dir_t
)(void *, const char *, const struct stat
*, off_t
);
98 typedef int (*fuse_dirfil_t
)(fuse_dirh_t
, const char *, int, ino_t
);
100 #define FUSE_VERSION 26
101 #define FUSE_MAJOR_VERSION 2
102 #define FUSE_MINOR_VERSION 6
105 * These operations shadow those in puffs_usermount, and are used
106 * as a table of callbacks to make when file system requests come
109 * NOTE: keep same order as fuse
111 struct fuse_operations
{
112 int (*getattr
)(const char *, struct stat
*);
113 int (*readlink
)(const char *, char *, size_t);
114 int (*getdir
)(const char *, fuse_dirh_t
, fuse_dirfil_t
);
115 int (*mknod
)(const char *, mode_t
, dev_t
);
116 int (*mkdir
)(const char *, mode_t
);
117 int (*unlink
)(const char *);
118 int (*rmdir
)(const char *);
119 int (*symlink
)(const char *, const char *);
120 int (*rename
)(const char *, const char *);
121 int (*link
)(const char *, const char *);
122 int (*chmod
)(const char *, mode_t
);
123 int (*chown
)(const char *, uid_t
, gid_t
);
124 int (*truncate
)(const char *, off_t
);
125 int (*utime
)(const char *, struct utimbuf
*);
126 int (*open
)(const char *, struct fuse_file_info
*);
127 int (*read
)(const char *, char *, size_t, off_t
, struct fuse_file_info
*);
128 int (*write
)(const char *, const char *, size_t, off_t
, struct fuse_file_info
*);
129 int (*statfs
)(const char *, struct statvfs
*);
130 int (*flush
)(const char *, struct fuse_file_info
*);
131 int (*release
)(const char *, struct fuse_file_info
*);
132 int (*fsync
)(const char *, int, struct fuse_file_info
*);
133 int (*setxattr
)(const char *, const char *, const char *, size_t, int);
134 int (*getxattr
)(const char *, const char *, char *, size_t);
135 int (*listxattr
)(const char *, char *, size_t);
136 int (*removexattr
)(const char *, const char *);
137 int (*opendir
)(const char *, struct fuse_file_info
*);
138 int (*readdir
)(const char *, void *, fuse_fill_dir_t
, off_t
, struct fuse_file_info
*);
139 int (*releasedir
)(const char *, struct fuse_file_info
*);
140 int (*fsyncdir
)(const char *, int, struct fuse_file_info
*);
141 void *(*init
)(struct fuse_conn_info
*);
142 void (*destroy
)(void *);
143 int (*access
)(const char *, int);
144 int (*create
)(const char *, mode_t
, struct fuse_file_info
*);
145 int (*ftruncate
)(const char *, off_t
, struct fuse_file_info
*);
146 int (*fgetattr
)(const char *, struct stat
*, struct fuse_file_info
*);
147 int (*lock
)(const char *, struct fuse_file_info
*, int, struct flock
*);
148 int (*utimens
)(const char *, const struct timespec
*);
149 int (*bmap
)(const char *, size_t , uint64_t *);
153 struct fuse_chan
*fuse_mount(const char *, struct fuse_args
*);
154 struct fuse
*fuse_new(struct fuse_chan
*, struct fuse_args
*,
155 const struct fuse_operations
*, size_t, void *);
157 int fuse_main_real(int, char **, const struct fuse_operations
*, size_t, void *);
158 int fuse_loop(struct fuse
*);
159 struct fuse_context
*fuse_get_context(void);
160 void fuse_exit(struct fuse
*);
161 void fuse_destroy(struct fuse
*);
163 void fuse_unmount(const char *, struct fuse_chan
*);
165 struct fuse
*fuse_setup(int, char **, const struct fuse_operations
*,
166 size_t, char **, int *, int *);
167 void fuse_teardown(struct fuse
*, char *);
169 #if FUSE_USE_VERSION == 22
170 #define fuse_unmount fuse_unmount_compat22
173 void fuse_unmount_compat22(const char *);
175 #if FUSE_USE_VERSION >= 26
176 #define fuse_main(argc, argv, op, arg) \
177 fuse_main_real(argc, argv, op, sizeof(*(op)), arg)
178 #define fuse_setup fuse_setup26
180 #define fuse_main(argc, argv, op) \
181 fuse_main_real(argc, argv, op, sizeof(*(op)), NULL)
184 struct fuse
*fuse_setup26(int, char **, const struct fuse_operations
*,
185 size_t, char **, int *, void *);
191 #include <fuse_opt.h>