1 /*
2  * From: https://code.google.com/p/dutils/
3  *
4  * Licensed under the Apache License 2.0. See
5  * http://www.apache.org/licenses/LICENSE-2.0
6  */
7 module c.fuse.fuse;
8 public import c.fuse.common;
9 
10 import std.stdint;
11 import core.sys.posix.sys.statvfs;
12 import core.sys.posix.fcntl;
13 import core.sys.posix.time;
14 import core.sys.posix.utime;
15 
16 extern (System)
17 {
18     struct fuse;
19 
20     struct fuse_pollhandle;
21     struct fuse_conn_info; /* temporary anonymous struct */
22     struct fuse_dirhandle;
23 
24     alias fuse_dirh_t = fuse_dirhandle*;
25     alias flock _flock;
26     alias fuse_fill_dir_t =
27         int function(void *buf, char *name, stat_t *stbuf, off_t off);
28     alias fuse_dirfil_t =
29         int function(fuse_dirh_t, const char *name, int type, ino_t ino);
30 
31     struct fuse_operations
32     {
33         int function(const char*, stat_t*) getattr;
34         int function(const char*, char *, size_t) readlink;
35         int function(const char*, fuse_dirh_t, fuse_dirfil_t) getdir;
36         int function(const char*, mode_t, dev_t) mknod;
37         int function(const char*, mode_t) mkdir;
38         int function(const char*) unlink;
39         int function(const char*) rmdir;
40         int function(const char*, char*) symlink;
41         int function(const char*, char*) rename;
42         int function(const char*, char*) link;
43         int function(const char*, mode_t) chmod;
44         int function(const char*, uid_t, gid_t) chown;
45         int function(const char*, off_t) truncate;
46         int function(const char*, utimbuf *) utime;
47         int function(const char*, fuse_file_info *) open;
48         int function(const char*, char*, size_t, off_t, fuse_file_info*) read;
49         int function(const char*, char*, size_t, off_t, fuse_file_info*) write;
50         int function(const char*, statvfs_t*) statfs;
51         int function(const char*, fuse_file_info*) flush;
52         int function(const char*, fuse_file_info*) release;
53         int function(const char*, int, fuse_file_info*) fsync;
54         int function(const char*, char*, char*, size_t, int) setxattr;
55         int function(const char*, char*, char*, size_t) getxattr;
56         int function(const char*, char*, size_t) listxattr;
57         int function(const char*, char*) removexattr;
58         int function(const char*, fuse_file_info*) opendir;
59         int function(const char*, void*, fuse_fill_dir_t, off_t,
60                 fuse_file_info*) readdir;
61         int function(const char*, fuse_file_info*) releasedir;
62         int function(const char*, int, fuse_file_info*) fsyncdir;
63         void* function(fuse_conn_info* conn) init;
64         void function(void*) destroy;
65         int function(const char*, int) access;
66         int function(const char*, mode_t, fuse_file_info*) create;
67         int function(const char*, off_t, fuse_file_info*)  ftruncate;
68         int function(const char*, stat_t*, fuse_file_info*) fgetattr;
69         int function(const char*, fuse_file_info*, int cmd, _flock*) lock;
70         int function(const char*, const timespec) utimens;
71         int function(const char*, size_t, uint64_t*) bmap;
72         uint flag_nullpath_ok = 1;
73         uint flag_reserved = 31;
74         int function(const char*, int, void*, fuse_file_info*, uint, void*)
75             ioctl;
76         int function(const char*, fuse_file_info*, fuse_pollhandle*, uint*)
77             poll;
78     }
79 
80     struct fuse_context
81     {
82         /** Pointer to the fuse object */
83         fuse* _fuse;
84 
85         uid_t uid; // User ID of the calling process
86         gid_t gid; // Group ID of the calling process
87         pid_t pid; // Thread ID of the calling process
88 
89         void* private_data; // Private filesystem data
90 
91         mode_t umask; // Umask of the calling process (introduced in version 2.8)
92     }
93 
94     fuse_context* fuse_get_context();
95     int fuse_main_real(int argc, char** argv, fuse_operations* op,
96         size_t op_size, void* user_data);
97 }
98 
99 
100 /* mappping of the fuse_main macro in fuse.h */
101 int fuse_main(int argc, char** argv, fuse_operations* op, void* user_data)
102 {
103     return fuse_main_real(argc, argv, op, fuse_operations.sizeof, user_data);
104 }