libfuse
fuse.h
Go to the documentation of this file.
1/*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
4
5 This program can be distributed under the terms of the GNU LGPLv2.
6 See the file COPYING.LIB.
7*/
8
9#ifndef FUSE_H_
10#define FUSE_H_
11
19#include "fuse_common.h"
20
21#include <fcntl.h>
22#include <time.h>
23#include <sys/types.h>
24#include <sys/stat.h>
25#include <sys/statvfs.h>
26#include <sys/uio.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/* ----------------------------------------------------------- *
33 * Basic FUSE API *
34 * ----------------------------------------------------------- */
35
37struct fuse;
38
51 FUSE_READDIR_PLUS = (1 << 0)
52};
53
67 FUSE_FILL_DIR_PLUS = (1 << 1)
68};
69
85typedef int (*fuse_fill_dir_t) (void *buf, const char *name,
86 const struct stat *stbuf, off_t off,
87 enum fuse_fill_dir_flags flags);
102 unsigned int gid;
103
109 unsigned int uid;
110
116 unsigned int umask;
117
123
133
139
143 int intr;
144
151
163
181
194
203
222
241
249
257
264 double ac_attr_timeout;
265
291
297 char *modules;
298 int debug;
299};
300
301
336 int (*getattr) (const char *, struct stat *, struct fuse_file_info *fi);
337
346 int (*readlink) (const char *, char *, size_t);
347
354 int (*mknod) (const char *, mode_t, dev_t);
355
362 int (*mkdir) (const char *, mode_t);
363
365 int (*unlink) (const char *);
366
368 int (*rmdir) (const char *);
369
371 int (*symlink) (const char *, const char *);
372
382 int (*rename) (const char *, const char *, unsigned int flags);
383
385 int (*link) (const char *, const char *);
386
392 int (*chmod) (const char *, mode_t, struct fuse_file_info *fi);
393
402 int (*chown) (const char *, uid_t, gid_t, struct fuse_file_info *fi);
403
412 int (*truncate) (const char *, off_t, struct fuse_file_info *fi);
413
461 int (*open) (const char *, struct fuse_file_info *);
462
472 int (*read) (const char *, char *, size_t, off_t,
473 struct fuse_file_info *);
474
484 int (*write) (const char *, const char *, size_t, off_t,
485 struct fuse_file_info *);
486
491 int (*statfs) (const char *, struct statvfs *);
492
521 int (*flush) (const char *, struct fuse_file_info *);
522
535 int (*release) (const char *, struct fuse_file_info *);
536
542 int (*fsync) (const char *, int, struct fuse_file_info *);
543
545 int (*setxattr) (const char *, const char *, const char *, size_t, int);
546
548 int (*getxattr) (const char *, const char *, char *, size_t);
549
551 int (*listxattr) (const char *, char *, size_t);
552
554 int (*removexattr) (const char *, const char *);
555
564 int (*opendir) (const char *, struct fuse_file_info *);
565
588 int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t,
589 struct fuse_file_info *, enum fuse_readdir_flags);
590
596 int (*releasedir) (const char *, struct fuse_file_info *);
597
606 int (*fsyncdir) (const char *, int, struct fuse_file_info *);
607
616 void *(*init) (struct fuse_conn_info *conn,
617 struct fuse_config *cfg);
618
624 void (*destroy) (void *private_data);
625
635 int (*access) (const char *, int);
636
647 int (*create) (const char *, mode_t, struct fuse_file_info *);
648
679 int (*lock) (const char *, struct fuse_file_info *, int cmd,
680 struct flock *);
681
694 int (*utimens) (const char *, const struct timespec tv[2],
695 struct fuse_file_info *fi);
696
703 int (*bmap) (const char *, size_t blocksize, uint64_t *idx);
704
705#if FUSE_USE_VERSION < 35
706 int (*ioctl) (const char *, int cmd, void *arg,
707 struct fuse_file_info *, unsigned int flags, void *data);
708#else
725 int (*ioctl) (const char *, unsigned int cmd, void *arg,
726 struct fuse_file_info *, unsigned int flags, void *data);
727#endif
728
744 int (*poll) (const char *, struct fuse_file_info *,
745 struct fuse_pollhandle *ph, unsigned *reventsp);
746
756 int (*write_buf) (const char *, struct fuse_bufvec *buf, off_t off,
757 struct fuse_file_info *);
758
773 int (*read_buf) (const char *, struct fuse_bufvec **bufp,
774 size_t size, off_t off, struct fuse_file_info *);
793 int (*flock) (const char *, struct fuse_file_info *, int op);
794
803 int (*fallocate) (const char *, int, off_t, off_t,
804 struct fuse_file_info *);
805
818 ssize_t (*copy_file_range) (const char *path_in,
819 struct fuse_file_info *fi_in,
820 off_t offset_in, const char *path_out,
821 struct fuse_file_info *fi_out,
822 off_t offset_out, size_t size, int flags);
823
827 off_t (*lseek) (const char *, off_t off, int whence, struct fuse_file_info *);
828};
829
837 struct fuse *fuse;
838
840 uid_t uid;
841
843 gid_t gid;
844
846 pid_t pid;
847
850
852 mode_t umask;
853};
854
909/*
910 int fuse_main(int argc, char *argv[], const struct fuse_operations *op,
911 void *private_data);
912*/
913#define fuse_main(argc, argv, op, private_data) \
914 fuse_main_real(argc, argv, op, sizeof(*(op)), private_data)
915
916/* ----------------------------------------------------------- *
917 * More detailed API *
918 * ----------------------------------------------------------- */
919
931void fuse_lib_help(struct fuse_args *args);
932
960#if FUSE_USE_VERSION == 30
961struct fuse *fuse_new_30(struct fuse_args *args, const struct fuse_operations *op,
962 size_t op_size, void *private_data);
963#define fuse_new(args, op, size, data) fuse_new_30(args, op, size, data)
964#else
965#if (defined(LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS))
966struct fuse *fuse_new(struct fuse_args *args, const struct fuse_operations *op,
967 size_t op_size, void *private_data);
968#else /* LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS */
969struct fuse *fuse_new_31(struct fuse_args *args,
970 const struct fuse_operations *op,
971 size_t op_size, void *private_data);
972#define fuse_new(args, op, size, data) fuse_new_31(args, op, size, data)
973#endif /* LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS */
974#endif
975
984int fuse_mount(struct fuse *f, const char *mountpoint);
985
993void fuse_unmount(struct fuse *f);
994
1003void fuse_destroy(struct fuse *f);
1004
1020int fuse_loop(struct fuse *f);
1021
1030void fuse_exit(struct fuse *f);
1031
1032#if FUSE_USE_VERSION < 32
1033int fuse_loop_mt_31(struct fuse *f, int clone_fd);
1034#define fuse_loop_mt(f, clone_fd) fuse_loop_mt_31(f, clone_fd)
1035#elif FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 12)
1036int fuse_loop_mt_32(struct fuse *f, struct fuse_loop_config *config);
1037#define fuse_loop_mt(f, config) fuse_loop_mt_32(f, config)
1038#else
1070#if (defined(LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS))
1071int fuse_loop_mt(struct fuse *f, struct fuse_loop_config *config);
1072#else
1073#define fuse_loop_mt(f, config) fuse_loop_mt_312(f, config)
1074#endif /* LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS */
1075#endif
1076
1077
1086struct fuse_context *fuse_get_context(void);
1087
1106int fuse_getgroups(int size, gid_t list[]);
1107
1113int fuse_interrupted(void);
1114
1126int fuse_invalidate_path(struct fuse *f, const char *path);
1127
1133int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
1134 size_t op_size, void *private_data);
1135
1144
1151void fuse_stop_cleanup_thread(struct fuse *fuse);
1152
1162int fuse_clean_cache(struct fuse *fuse);
1163
1164/*
1165 * Stacking API
1166 */
1167
1173struct fuse_fs;
1174
1175/*
1176 * These functions call the relevant filesystem operation, and return
1177 * the result.
1178 *
1179 * If the operation is not defined, they return -ENOSYS, with the
1180 * exception of fuse_fs_open, fuse_fs_release, fuse_fs_opendir,
1181 * fuse_fs_releasedir and fuse_fs_statfs, which return 0.
1182 */
1183
1184int fuse_fs_getattr(struct fuse_fs *fs, const char *path, struct stat *buf,
1185 struct fuse_file_info *fi);
1186int fuse_fs_rename(struct fuse_fs *fs, const char *oldpath,
1187 const char *newpath, unsigned int flags);
1188int fuse_fs_unlink(struct fuse_fs *fs, const char *path);
1189int fuse_fs_rmdir(struct fuse_fs *fs, const char *path);
1190int fuse_fs_symlink(struct fuse_fs *fs, const char *linkname,
1191 const char *path);
1192int fuse_fs_link(struct fuse_fs *fs, const char *oldpath, const char *newpath);
1193int fuse_fs_release(struct fuse_fs *fs, const char *path,
1194 struct fuse_file_info *fi);
1195int fuse_fs_open(struct fuse_fs *fs, const char *path,
1196 struct fuse_file_info *fi);
1197int fuse_fs_read(struct fuse_fs *fs, const char *path, char *buf, size_t size,
1198 off_t off, struct fuse_file_info *fi);
1199int fuse_fs_read_buf(struct fuse_fs *fs, const char *path,
1200 struct fuse_bufvec **bufp, size_t size, off_t off,
1201 struct fuse_file_info *fi);
1202int fuse_fs_write(struct fuse_fs *fs, const char *path, const char *buf,
1203 size_t size, off_t off, struct fuse_file_info *fi);
1204int fuse_fs_write_buf(struct fuse_fs *fs, const char *path,
1205 struct fuse_bufvec *buf, off_t off,
1206 struct fuse_file_info *fi);
1207int fuse_fs_fsync(struct fuse_fs *fs, const char *path, int datasync,
1208 struct fuse_file_info *fi);
1209int fuse_fs_flush(struct fuse_fs *fs, const char *path,
1210 struct fuse_file_info *fi);
1211int fuse_fs_statfs(struct fuse_fs *fs, const char *path, struct statvfs *buf);
1212int fuse_fs_opendir(struct fuse_fs *fs, const char *path,
1213 struct fuse_file_info *fi);
1214int fuse_fs_readdir(struct fuse_fs *fs, const char *path, void *buf,
1215 fuse_fill_dir_t filler, off_t off,
1216 struct fuse_file_info *fi, enum fuse_readdir_flags flags);
1217int fuse_fs_fsyncdir(struct fuse_fs *fs, const char *path, int datasync,
1218 struct fuse_file_info *fi);
1219int fuse_fs_releasedir(struct fuse_fs *fs, const char *path,
1220 struct fuse_file_info *fi);
1221int fuse_fs_create(struct fuse_fs *fs, const char *path, mode_t mode,
1222 struct fuse_file_info *fi);
1223int fuse_fs_lock(struct fuse_fs *fs, const char *path,
1224 struct fuse_file_info *fi, int cmd, struct flock *lock);
1225int fuse_fs_flock(struct fuse_fs *fs, const char *path,
1226 struct fuse_file_info *fi, int op);
1227int fuse_fs_chmod(struct fuse_fs *fs, const char *path, mode_t mode,
1228 struct fuse_file_info *fi);
1229int fuse_fs_chown(struct fuse_fs *fs, const char *path, uid_t uid, gid_t gid,
1230 struct fuse_file_info *fi);
1231int fuse_fs_truncate(struct fuse_fs *fs, const char *path, off_t size,
1232 struct fuse_file_info *fi);
1233int fuse_fs_utimens(struct fuse_fs *fs, const char *path,
1234 const struct timespec tv[2], struct fuse_file_info *fi);
1235int fuse_fs_access(struct fuse_fs *fs, const char *path, int mask);
1236int fuse_fs_readlink(struct fuse_fs *fs, const char *path, char *buf,
1237 size_t len);
1238int fuse_fs_mknod(struct fuse_fs *fs, const char *path, mode_t mode,
1239 dev_t rdev);
1240int fuse_fs_mkdir(struct fuse_fs *fs, const char *path, mode_t mode);
1241int fuse_fs_setxattr(struct fuse_fs *fs, const char *path, const char *name,
1242 const char *value, size_t size, int flags);
1243int fuse_fs_getxattr(struct fuse_fs *fs, const char *path, const char *name,
1244 char *value, size_t size);
1245int fuse_fs_listxattr(struct fuse_fs *fs, const char *path, char *list,
1246 size_t size);
1247int fuse_fs_removexattr(struct fuse_fs *fs, const char *path,
1248 const char *name);
1249int fuse_fs_bmap(struct fuse_fs *fs, const char *path, size_t blocksize,
1250 uint64_t *idx);
1251#if FUSE_USE_VERSION < 35
1252int fuse_fs_ioctl(struct fuse_fs *fs, const char *path, int cmd,
1253 void *arg, struct fuse_file_info *fi, unsigned int flags,
1254 void *data);
1255#else
1256int fuse_fs_ioctl(struct fuse_fs *fs, const char *path, unsigned int cmd,
1257 void *arg, struct fuse_file_info *fi, unsigned int flags,
1258 void *data);
1259#endif
1260int fuse_fs_poll(struct fuse_fs *fs, const char *path,
1261 struct fuse_file_info *fi, struct fuse_pollhandle *ph,
1262 unsigned *reventsp);
1263int fuse_fs_fallocate(struct fuse_fs *fs, const char *path, int mode,
1264 off_t offset, off_t length, struct fuse_file_info *fi);
1265ssize_t fuse_fs_copy_file_range(struct fuse_fs *fs, const char *path_in,
1266 struct fuse_file_info *fi_in, off_t off_in,
1267 const char *path_out,
1268 struct fuse_file_info *fi_out, off_t off_out,
1269 size_t len, int flags);
1270off_t fuse_fs_lseek(struct fuse_fs *fs, const char *path, off_t off, int whence,
1271 struct fuse_file_info *fi);
1272void fuse_fs_init(struct fuse_fs *fs, struct fuse_conn_info *conn,
1273 struct fuse_config *cfg);
1274void fuse_fs_destroy(struct fuse_fs *fs);
1275
1276int fuse_notify_poll(struct fuse_pollhandle *ph);
1277
1291struct fuse_fs *fuse_fs_new(const struct fuse_operations *op, size_t op_size,
1292 void *private_data);
1293
1308typedef struct fuse_fs *(*fuse_module_factory_t)(struct fuse_args *args,
1309 struct fuse_fs *fs[]);
1320#define FUSE_REGISTER_MODULE(name_, factory_) \
1321 fuse_module_factory_t fuse_module_ ## name_ ## _factory = factory_
1322
1324struct fuse_session *fuse_get_session(struct fuse *f);
1325
1334int fuse_open_channel(const char *mountpoint, const char *options);
1335
1336#ifdef __cplusplus
1337}
1338#endif
1339
1340#endif /* FUSE_H_ */
int fuse_getgroups(int size, gid_t list[])
Definition: fuse.c:4618
int fuse_mount(struct fuse *f, const char *mountpoint)
Definition: fuse.c:5110
int fuse_interrupted(void)
Definition: fuse.c:4627
void fuse_destroy(struct fuse *f)
Definition: fuse.c:5059
int fuse_start_cleanup_thread(struct fuse *fuse)
Definition: fuse.c:4862
int fuse_invalidate_path(struct fuse *f, const char *path)
Definition: fuse.c:4637
struct fuse_context * fuse_get_context(void)
Definition: fuse.c:4608
int fuse_loop(struct fuse *f)
Definition: fuse.c:4541
int(* fuse_fill_dir_t)(void *buf, const char *name, const struct stat *stbuf, off_t off, enum fuse_fill_dir_flags flags)
Definition: fuse.h:85
void fuse_exit(struct fuse *f)
Definition: fuse.c:4603
int fuse_clean_cache(struct fuse *fuse)
Definition: fuse.c:4397
void fuse_lib_help(struct fuse_args *args)
Definition: fuse.c:4704
int fuse_open_channel(const char *mountpoint, const char *options)
Definition: helper.c:461
struct fuse_session * fuse_get_session(struct fuse *f)
Definition: fuse.c:4484
void fuse_unmount(struct fuse *f)
Definition: fuse.c:5115
struct fuse * fuse_new_31(struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *private_data)
Definition: fuse.c:4882
struct fuse_fs * fuse_fs_new(const struct fuse_operations *op, size_t op_size, void *private_data)
Definition: fuse.c:4814
void fuse_stop_cleanup_thread(struct fuse *fuse)
Definition: fuse.c:4870
int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, void *private_data)
Definition: helper.c:307
fuse_fill_dir_flags
Definition: fuse.h:57
@ FUSE_FILL_DIR_PLUS
Definition: fuse.h:67
fuse_readdir_flags
Definition: fuse.h:42
@ FUSE_READDIR_PLUS
Definition: fuse.h:51
size_t off
Definition: fuse_common.h:803
struct fuse_buf buf[1]
Definition: fuse_common.h:808
int remember
Definition: fuse.h:162
int set_uid
Definition: fuse.h:108
int set_gid
Definition: fuse.h:101
int ac_attr_timeout_set
Definition: fuse.h:263
double entry_timeout
Definition: fuse.h:122
int intr_signal
Definition: fuse.h:150
int intr
Definition: fuse.h:143
int auto_cache
Definition: fuse.h:248
int parallel_direct_writes
Definition: fuse.h:290
double negative_timeout
Definition: fuse.h:132
int kernel_cache
Definition: fuse.h:240
int set_mode
Definition: fuse.h:115
int readdir_ino
Definition: fuse.h:202
int nullpath_ok
Definition: fuse.h:276
int use_ino
Definition: fuse.h:193
int no_rofd_flush
Definition: fuse.h:256
int direct_io
Definition: fuse.h:221
double attr_timeout
Definition: fuse.h:138
int hard_remove
Definition: fuse.h:180
int show_help
Definition: fuse.h:296
void * private_data
Definition: fuse.h:849
uid_t uid
Definition: fuse.h:840
pid_t pid
Definition: fuse.h:846
struct fuse * fuse
Definition: fuse.h:837
gid_t gid
Definition: fuse.h:843
mode_t umask
Definition: fuse.h:852
int(* mknod)(const char *, mode_t, dev_t)
Definition: fuse.h:354
int(* open)(const char *, struct fuse_file_info *)
Definition: fuse.h:461
int(* readlink)(const char *, char *, size_t)
Definition: fuse.h:346
int(* write)(const char *, const char *, size_t, off_t, struct fuse_file_info *)
Definition: fuse.h:484
int(* fallocate)(const char *, int, off_t, off_t, struct fuse_file_info *)
Definition: fuse.h:803
int(* read)(const char *, char *, size_t, off_t, struct fuse_file_info *)
Definition: fuse.h:472
int(* symlink)(const char *, const char *)
Definition: fuse.h:371
int(* write_buf)(const char *, struct fuse_bufvec *buf, off_t off, struct fuse_file_info *)
Definition: fuse.h:756
int(* release)(const char *, struct fuse_file_info *)
Definition: fuse.h:535
int(* access)(const char *, int)
Definition: fuse.h:635
int(* lock)(const char *, struct fuse_file_info *, int cmd, struct flock *)
Definition: fuse.h:679
int(* fsyncdir)(const char *, int, struct fuse_file_info *)
Definition: fuse.h:606
int(* mkdir)(const char *, mode_t)
Definition: fuse.h:362
int(* chown)(const char *, uid_t, gid_t, struct fuse_file_info *fi)
Definition: fuse.h:402
int(* unlink)(const char *)
Definition: fuse.h:365
int(* flush)(const char *, struct fuse_file_info *)
Definition: fuse.h:521
int(* listxattr)(const char *, char *, size_t)
Definition: fuse.h:551
int(* truncate)(const char *, off_t, struct fuse_file_info *fi)
Definition: fuse.h:412
int(* statfs)(const char *, struct statvfs *)
Definition: fuse.h:491
ssize_t(* copy_file_range)(const char *path_in, struct fuse_file_info *fi_in, off_t offset_in, const char *path_out, struct fuse_file_info *fi_out, off_t offset_out, size_t size, int flags)
Definition: fuse.h:818
int(* create)(const char *, mode_t, struct fuse_file_info *)
Definition: fuse.h:647
int(* utimens)(const char *, const struct timespec tv[2], struct fuse_file_info *fi)
Definition: fuse.h:694
off_t(* lseek)(const char *, off_t off, int whence, struct fuse_file_info *)
Definition: fuse.h:827
int(* getxattr)(const char *, const char *, char *, size_t)
Definition: fuse.h:548
int(* setxattr)(const char *, const char *, const char *, size_t, int)
Definition: fuse.h:545
int(* poll)(const char *, struct fuse_file_info *, struct fuse_pollhandle *ph, unsigned *reventsp)
Definition: fuse.h:744
int(* fsync)(const char *, int, struct fuse_file_info *)
Definition: fuse.h:542
int(* chmod)(const char *, mode_t, struct fuse_file_info *fi)
Definition: fuse.h:392
int(* opendir)(const char *, struct fuse_file_info *)
Definition: fuse.h:564
int(* rmdir)(const char *)
Definition: fuse.h:368
int(* releasedir)(const char *, struct fuse_file_info *)
Definition: fuse.h:596
int(* getattr)(const char *, struct stat *, struct fuse_file_info *fi)
Definition: fuse.h:336
int(* read_buf)(const char *, struct fuse_bufvec **bufp, size_t size, off_t off, struct fuse_file_info *)
Definition: fuse.h:773
int(* link)(const char *, const char *)
Definition: fuse.h:385
int(* flock)(const char *, struct fuse_file_info *, int op)
Definition: fuse.h:793
int(* removexattr)(const char *, const char *)
Definition: fuse.h:554
int(* ioctl)(const char *, unsigned int cmd, void *arg, struct fuse_file_info *, unsigned int flags, void *data)
Definition: fuse.h:725
int(* rename)(const char *, const char *, unsigned int flags)
Definition: fuse.h:382
int(* readdir)(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *, enum fuse_readdir_flags)
Definition: fuse.h:588
void(* destroy)(void *private_data)
Definition: fuse.h:624
int(* bmap)(const char *, size_t blocksize, uint64_t *idx)
Definition: fuse.h:703