blob: d16135e12c72bfeeb7a4e9f1e59ee375d44fdb38 [file] [log] [blame]
Miklos Szeredi85c74fc2001-10-28 19:44:14 +00001/*
2 FUSE: Filesystem in Userspace
Miklos Szeredi149f6072005-01-10 12:29:28 +00003 Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
Miklos Szeredi85c74fc2001-10-28 19:44:14 +00004
Miklos Szeredi8b39a9f2002-10-25 12:41:16 +00005 This program can be distributed under the terms of the GNU LGPL.
6 See the file COPYING.LIB.
Miklos Szeredi85c74fc2001-10-28 19:44:14 +00007*/
8
Miklos Szerediacd4e062001-12-08 20:29:20 +00009#ifndef _FUSE_H_
10#define _FUSE_H_
11
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000012/* This file defines the library interface of FUSE */
13
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +000014/* IMPORTANT: you should define FUSE_USE_VERSION before including this
15 header. To use the new API define it to 22 (recommended for any
Miklos Szeredid59bb9d2004-12-07 10:04:24 +000016 new application), to use the old API define it to 21 (this is the
17 default), to use the even older 1.X API define it to 11. */
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +000018
Miklos Szeredi76c17522005-07-13 14:08:19 +000019#include "fuse_common.h"
20
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000021#include <sys/types.h>
22#include <sys/stat.h>
Miklos Szeredi18e75e42004-02-19 14:23:27 +000023#include <sys/statfs.h>
Miklos Szeredi5e183482001-10-31 14:52:35 +000024#include <utime.h>
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000025
Miklos Szeredi8fb48fe2004-11-08 14:48:52 +000026#ifdef __cplusplus
27extern "C" {
28#endif
29
Miklos Szeredicc8c9752001-11-21 10:03:39 +000030/* ----------------------------------------------------------- *
31 * Basic FUSE API *
32 * ----------------------------------------------------------- */
33
Miklos Szeredi2df1c042001-11-06 15:07:17 +000034/** Handle for a FUSE filesystem */
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000035struct fuse;
Miklos Szeredi2df1c042001-11-06 15:07:17 +000036
Miklos Szeredia1482422005-08-14 23:00:27 +000037/** Structure containing a raw command */
38struct fuse_cmd;
39
Miklos Szeredi18fce982005-04-01 21:07:35 +000040/** Function to add an entry in a readdir() operation
41 *
42 * @param buf the buffer passed to the readdir() operation
43 * @param name the file name of the directory entry
Miklos Szerediab974562005-04-07 15:40:21 +000044 * @param stat file attributes, can be NULL
45 * @param off offset of the next entry or zero
46 * @return 1 if buffer is full, zero otherwise
Miklos Szeredi18fce982005-04-01 21:07:35 +000047 */
Miklos Szerediab974562005-04-07 15:40:21 +000048typedef int (*fuse_fill_dir_t) (void *buf, const char *name,
Miklos Szeredif6e0ec62005-08-03 09:11:06 +000049 const struct stat *stbuf, off_t off);
Miklos Szerediab974562005-04-07 15:40:21 +000050
51/* Used by deprecated getdir() method */
52typedef struct fuse_dirhandle *fuse_dirh_t;
53typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type,
54 ino_t ino);
Miklos Szeredi18fce982005-04-01 21:07:35 +000055
Miklos Szeredi2df1c042001-11-06 15:07:17 +000056/**
57 * The file system operations:
58 *
59 * Most of these should work very similarly to the well known UNIX
Miklos Szeredid59bb9d2004-12-07 10:04:24 +000060 * file system operations. A major exception is that instead of
61 * returning an error in 'errno', the operation should return the
Miklos Szeredie5183742005-02-02 11:14:04 +000062 * negated error value (-errno) directly.
Miklos Szeredie56818b2004-12-12 11:45:24 +000063 *
64 * All methods are optional, but some are essential for a useful
Miklos Szeredi31066bb2005-08-01 14:49:31 +000065 * filesystem (e.g. getattr). Open, flush, release, fsync, opendir,
66 * releasedir, fsyncdir, init and destroy are special purpose methods,
67 * without which a full featured filesystem can still be implemented.
Miklos Szeredie2e4ac22004-05-18 08:45:28 +000068 */
Miklos Szeredia181e612001-11-06 12:03:23 +000069struct fuse_operations {
Miklos Szeredid59bb9d2004-12-07 10:04:24 +000070 /** Get file attributes.
71 *
72 * Similar to stat(). The 'st_dev' and 'st_blksize' fields are
73 * ignored. The 'st_ino' field is ignored except if the 'use_ino'
74 * mount option is given.
75 */
76 int (*getattr) (const char *, struct stat *);
77
78 /** Read the target of a symbolic link
Miklos Szeredie5183742005-02-02 11:14:04 +000079 *
Miklos Szeredid59bb9d2004-12-07 10:04:24 +000080 * The buffer should be filled with a null terminated string. The
81 * buffer size argument includes the space for the terminating
82 * null character. If the linkname is too long to fit in the
83 * buffer, it should be truncated. The return value should be 0
84 * for success.
85 */
86 int (*readlink) (const char *, char *, size_t);
87
Miklos Szerediab974562005-04-07 15:40:21 +000088 /* Deprecated, use readdir() instead */
Miklos Szeredid59bb9d2004-12-07 10:04:24 +000089 int (*getdir) (const char *, fuse_dirh_t, fuse_dirfil_t);
90
91 /** Create a file node
92 *
93 * There is no create() operation, mknod() will be called for
94 * creation of all non-directory, non-symlink nodes.
95 */
96 int (*mknod) (const char *, mode_t, dev_t);
97
98 /** Create a directory */
99 int (*mkdir) (const char *, mode_t);
100
101 /** Remove a file */
102 int (*unlink) (const char *);
103
104 /** Remove a directory */
105 int (*rmdir) (const char *);
106
107 /** Create a symbolic link */
108 int (*symlink) (const char *, const char *);
109
110 /** Rename a file */
111 int (*rename) (const char *, const char *);
112
113 /** Create a hard link to a file */
114 int (*link) (const char *, const char *);
Miklos Szeredie5183742005-02-02 11:14:04 +0000115
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000116 /** Change the permission bits of a file */
117 int (*chmod) (const char *, mode_t);
Miklos Szeredie5183742005-02-02 11:14:04 +0000118
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000119 /** Change the owner and group of a file */
120 int (*chown) (const char *, uid_t, gid_t);
Miklos Szeredie5183742005-02-02 11:14:04 +0000121
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000122 /** Change the size of a file */
123 int (*truncate) (const char *, off_t);
Miklos Szeredie5183742005-02-02 11:14:04 +0000124
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000125 /** Change the access and/or modification times of a file */
126 int (*utime) (const char *, struct utimbuf *);
Miklos Szeredie5183742005-02-02 11:14:04 +0000127
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000128 /** File open operation
129 *
130 * No creation, or trunctation flags (O_CREAT, O_EXCL, O_TRUNC)
Miklos Szeredifa848662005-09-08 15:16:14 +0000131 * will be passed to open(). Open should check if the operation
132 * is permitted for the given flags. Optionally open may also
133 * return an arbitary filehandle in the fuse_file_info structure,
134 * which will be passed to all file operations.
Miklos Szeredi31066bb2005-08-01 14:49:31 +0000135 *
Miklos Szeredi437d8112005-07-06 09:14:20 +0000136 * Changed in version 2.2
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000137 */
138 int (*open) (const char *, struct fuse_file_info *);
139
140 /** Read data from an open file
141 *
142 * Read should return exactly the number of bytes requested except
143 * on EOF or error, otherwise the rest of the data will be
144 * substituted with zeroes. An exception to this is when the
145 * 'direct_io' mount option is specified, in which case the return
146 * value of the read system call will reflect the return value of
147 * this operation.
Miklos Szeredi437d8112005-07-06 09:14:20 +0000148 *
149 * Changed in version 2.2
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000150 */
151 int (*read) (const char *, char *, size_t, off_t, struct fuse_file_info *);
152
Miklos Szeredie5183742005-02-02 11:14:04 +0000153 /** Write data to an open file
154 *
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000155 * Write should return exactly the number of bytes requested
156 * except on error. An exception to this is when the 'direct_io'
157 * mount option is specified (see read operation).
Miklos Szeredi437d8112005-07-06 09:14:20 +0000158 *
159 * Changed in version 2.2
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000160 */
161 int (*write) (const char *, const char *, size_t, off_t,
162 struct fuse_file_info *);
163
164 /** Get file system statistics
Miklos Szeredie5183742005-02-02 11:14:04 +0000165 *
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000166 * The 'f_type' and 'f_fsid' fields are ignored
167 */
168 int (*statfs) (const char *, struct statfs *);
169
Miklos Szeredie5183742005-02-02 11:14:04 +0000170 /** Possibly flush cached data
171 *
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000172 * BIG NOTE: This is not equivalent to fsync(). It's not a
Miklos Szeredie56818b2004-12-12 11:45:24 +0000173 * request to sync dirty data.
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000174 *
175 * Flush is called on each close() of a file descriptor. So if a
176 * filesystem wants to return write errors in close() and the file
177 * has cached dirty data, this is a good place to write back data
Miklos Szeredie56818b2004-12-12 11:45:24 +0000178 * and return any errors. Since many applications ignore close()
179 * errors this is not always useful.
Miklos Szeredie5183742005-02-02 11:14:04 +0000180 *
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000181 * NOTE: The flush() method may be called more than once for each
182 * open(). This happens if more than one file descriptor refers
183 * to an opened file due to dup(), dup2() or fork() calls. It is
184 * not possible to determine if a flush is final, so each flush
185 * should be treated equally. Multiple write-flush sequences are
186 * relatively rare, so this shouldn't be a problem.
Miklos Szeredi9b813af2005-07-21 07:59:37 +0000187 *
Miklos Szeredi7f54fb42005-10-10 08:42:17 +0000188 * Filesystems shouldn't assume that flush will allways be called
189 * after some writes, or that if will be called at all.
190 *
Miklos Szeredi437d8112005-07-06 09:14:20 +0000191 * Changed in version 2.2
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000192 */
193 int (*flush) (const char *, struct fuse_file_info *);
194
195 /** Release an open file
Miklos Szeredie5183742005-02-02 11:14:04 +0000196 *
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000197 * Release is called when there are no more references to an open
198 * file: all file descriptors are closed and all memory mappings
199 * are unmapped.
200 *
201 * For every open() call there will be exactly one release() call
Miklos Szeredie56818b2004-12-12 11:45:24 +0000202 * with the same flags and file descriptor. It is possible to
203 * have a file opened more than once, in which case only the last
204 * release will mean, that no more reads/writes will happen on the
205 * file. The return value of release is ignored.
Miklos Szeredi437d8112005-07-06 09:14:20 +0000206 *
207 * Changed in version 2.2
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000208 */
209 int (*release) (const char *, struct fuse_file_info *);
210
211 /** Synchronize file contents
212 *
213 * If the datasync parameter is non-zero, then only the user data
214 * should be flushed, not the meta data.
Miklos Szeredi437d8112005-07-06 09:14:20 +0000215 *
216 * Changed in version 2.2
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000217 */
218 int (*fsync) (const char *, int, struct fuse_file_info *);
Miklos Szeredie5183742005-02-02 11:14:04 +0000219
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000220 /** Set extended attributes */
221 int (*setxattr) (const char *, const char *, const char *, size_t, int);
Miklos Szeredie5183742005-02-02 11:14:04 +0000222
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000223 /** Get extended attributes */
224 int (*getxattr) (const char *, const char *, char *, size_t);
Miklos Szeredie5183742005-02-02 11:14:04 +0000225
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000226 /** List extended attributes */
227 int (*listxattr) (const char *, char *, size_t);
Miklos Szeredie5183742005-02-02 11:14:04 +0000228
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000229 /** Remove extended attributes */
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000230 int (*removexattr) (const char *, const char *);
Miklos Szeredif43f0632005-02-28 11:46:56 +0000231
Miklos Szeredi009b8782005-08-01 13:36:53 +0000232 /** Open directory
Miklos Szeredi437d8112005-07-06 09:14:20 +0000233 *
Miklos Szeredifa848662005-09-08 15:16:14 +0000234 * This method should check if the open operation is permitted for
235 * this directory
236 *
Miklos Szeredi437d8112005-07-06 09:14:20 +0000237 * Introduced in version 2.3
Miklos Szeredif43f0632005-02-28 11:46:56 +0000238 */
239 int (*opendir) (const char *, struct fuse_file_info *);
Miklos Szeredi159bd7e2005-02-28 17:32:16 +0000240
Miklos Szeredi18fce982005-04-01 21:07:35 +0000241 /** Read directory
242 *
Miklos Szerediab974562005-04-07 15:40:21 +0000243 * This supersedes the old getdir() interface. New applications
244 * should use this.
245 *
246 * The filesystem may choose between two modes of operation:
Miklos Szeredi21019c92005-05-09 11:22:41 +0000247 *
Miklos Szerediab974562005-04-07 15:40:21 +0000248 * 1) The readdir implementation ignores the offset parameter, and
249 * passes zero to the filler function's offset. The filler
250 * function will not return '1' (unless an error happens), so the
251 * whole directory is read in a single readdir operation. This
252 * works just like the old getdir() method.
253 *
254 * 2) The readdir implementation keeps track of the offsets of the
255 * directory entries. It uses the offset parameter and always
256 * passes non-zero offset to the filler function. When the buffer
257 * is full (or an error happens) the filler function will return
258 * '1'.
Miklos Szeredi9b813af2005-07-21 07:59:37 +0000259 *
Miklos Szeredi437d8112005-07-06 09:14:20 +0000260 * Introduced in version 2.3
Miklos Szeredi18fce982005-04-01 21:07:35 +0000261 */
Miklos Szerediab974562005-04-07 15:40:21 +0000262 int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t,
Miklos Szeredi18fce982005-04-01 21:07:35 +0000263 struct fuse_file_info *);
264
Miklos Szeredi9b813af2005-07-21 07:59:37 +0000265 /** Release directory
Miklos Szeredi437d8112005-07-06 09:14:20 +0000266 *
267 * Introduced in version 2.3
268 */
Miklos Szeredi18fce982005-04-01 21:07:35 +0000269 int (*releasedir) (const char *, struct fuse_file_info *);
270
Miklos Szeredi4283ee72005-03-21 12:09:04 +0000271 /** Synchronize directory contents
272 *
273 * If the datasync parameter is non-zero, then only the user data
Miklos Szeredi18fce982005-04-01 21:07:35 +0000274 * should be flushed, not the meta data
Miklos Szeredi437d8112005-07-06 09:14:20 +0000275 *
276 * Introduced in version 2.3
Miklos Szeredi4283ee72005-03-21 12:09:04 +0000277 */
278 int (*fsyncdir) (const char *, int, struct fuse_file_info *);
279
Miklos Szeredi159bd7e2005-02-28 17:32:16 +0000280 /**
281 * Initialize filesystem
282 *
283 * The return value will passed in the private_data field of
284 * fuse_context to all file operations and as a parameter to the
285 * destroy() method.
Miklos Szeredi9b813af2005-07-21 07:59:37 +0000286 *
Miklos Szeredi437d8112005-07-06 09:14:20 +0000287 * Introduced in version 2.3
Miklos Szeredi159bd7e2005-02-28 17:32:16 +0000288 */
289 void *(*init) (void);
290
291 /**
292 * Clean up filesystem
Miklos Szeredi18fce982005-04-01 21:07:35 +0000293 *
Miklos Szeredi159bd7e2005-02-28 17:32:16 +0000294 * Called on filesystem exit.
Miklos Szeredi9b813af2005-07-21 07:59:37 +0000295 *
Miklos Szeredi437d8112005-07-06 09:14:20 +0000296 * Introduced in version 2.3
Miklos Szeredi159bd7e2005-02-28 17:32:16 +0000297 */
298 void (*destroy) (void *);
Miklos Szeredia181e612001-11-06 12:03:23 +0000299};
300
Miklos Szeredie5183742005-02-02 11:14:04 +0000301/** Extra context that may be needed by some filesystems
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000302 *
303 * The uid, gid and pid fields are not filled in case of a writepage
304 * operation.
305 */
Miklos Szeredi2e50d432001-12-20 12:17:25 +0000306struct fuse_context {
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000307 /** Pointer to the fuse object */
Miklos Szeredid169f312004-09-22 08:48:26 +0000308 struct fuse *fuse;
Miklos Szeredie5183742005-02-02 11:14:04 +0000309
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000310 /** User ID of the calling process */
Miklos Szeredi2e50d432001-12-20 12:17:25 +0000311 uid_t uid;
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000312
313 /** Group ID of the calling process */
Miklos Szeredi2e50d432001-12-20 12:17:25 +0000314 gid_t gid;
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000315
316 /** Thread ID of the calling process */
Miklos Szeredi1f18db52004-09-27 06:54:49 +0000317 pid_t pid;
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000318
Miklos Szeredi159bd7e2005-02-28 17:32:16 +0000319 /** Private filesystem data */
Miklos Szeredi8fb48fe2004-11-08 14:48:52 +0000320 void *private_data;
Miklos Szeredi2e50d432001-12-20 12:17:25 +0000321};
322
Miklos Szeredia4b0c772002-04-19 15:57:02 +0000323/*
Miklos Szeredi0e535082003-10-13 10:08:06 +0000324 * Main function of FUSE.
325 *
326 * This is for the lazy. This is all that has to be called from the
327 * main() function.
Miklos Szeredie5183742005-02-02 11:14:04 +0000328 *
Miklos Szeredi0e535082003-10-13 10:08:06 +0000329 * This function does the following:
Miklos Szeredi307242f2004-01-26 11:28:44 +0000330 * - parses command line options (-d -s and -h)
Miklos Szeredibd7661b2004-07-23 17:16:29 +0000331 * - passes relevant mount options to the fuse_mount()
Miklos Szeredi0e535082003-10-13 10:08:06 +0000332 * - installs signal handlers for INT, HUP, TERM and PIPE
333 * - registers an exit handler to unmount the filesystem on program exit
Miklos Szeredi0e535082003-10-13 10:08:06 +0000334 * - creates a fuse handle
335 * - registers the operations
336 * - calls either the single-threaded or the multi-threaded event loop
337 *
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000338 * Note: this is currently implemented as a macro.
339 *
Miklos Szeredi0e535082003-10-13 10:08:06 +0000340 * @param argc the argument counter passed to the main() function
341 * @param argv the argument vector passed to the main() function
Miklos Szeredie5183742005-02-02 11:14:04 +0000342 * @param op the file system operation
Miklos Szeredi5dc8a802004-10-21 09:35:10 +0000343 * @return 0 on success, nonzero on failure
Miklos Szeredi0e535082003-10-13 10:08:06 +0000344 */
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000345/*
346int fuse_main(int argc, char *argv[], const struct fuse_operations *op);
347*/
348#define fuse_main(argc, argv, op) \
Miklos Szeredif458b8c2004-12-07 16:46:42 +0000349 fuse_main_real(argc, argv, op, sizeof(*(op)))
Miklos Szeredi891b8742004-07-29 09:27:49 +0000350
Miklos Szeredi0e535082003-10-13 10:08:06 +0000351/* ----------------------------------------------------------- *
352 * More detailed API *
353 * ----------------------------------------------------------- */
354
Miklos Szeredi2df1c042001-11-06 15:07:17 +0000355/**
Miklos Szeredi8cffdb92001-11-09 14:49:18 +0000356 * Create a new FUSE filesystem.
Miklos Szeredi2df1c042001-11-06 15:07:17 +0000357 *
Miklos Szeredi8cffdb92001-11-09 14:49:18 +0000358 * @param fd the control file descriptor
Miklos Szeredibd7661b2004-07-23 17:16:29 +0000359 * @param opts mount options to be used by the library
Miklos Szeredi2e50d432001-12-20 12:17:25 +0000360 * @param op the operations
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000361 * @param op_size the size of the fuse_operations structure
Miklos Szeredi2df1c042001-11-06 15:07:17 +0000362 * @return the created FUSE handle
363 */
Miklos Szeredie5183742005-02-02 11:14:04 +0000364struct fuse *fuse_new(int fd, const char *opts,
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000365 const struct fuse_operations *op, size_t op_size);
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000366
Miklos Szeredi2df1c042001-11-06 15:07:17 +0000367/**
Miklos Szeredie5183742005-02-02 11:14:04 +0000368 * Destroy the FUSE handle.
Miklos Szeredi0f48a262002-12-05 14:23:01 +0000369 *
370 * The filesystem is not unmounted.
371 *
372 * @param f the FUSE handle
373 */
374void fuse_destroy(struct fuse *f);
375
376/**
Miklos Szeredi2df1c042001-11-06 15:07:17 +0000377 * FUSE event loop.
378 *
379 * Requests from the kernel are processed, and the apropriate
Miklos Szeredie5183742005-02-02 11:14:04 +0000380 * operations are called.
Miklos Szeredi2df1c042001-11-06 15:07:17 +0000381 *
382 * @param f the FUSE handle
Miklos Szeredib2cf9562004-09-16 08:42:40 +0000383 * @return 0 if no error occured, -1 otherwise
Miklos Szeredi2df1c042001-11-06 15:07:17 +0000384 */
Miklos Szeredib2cf9562004-09-16 08:42:40 +0000385int fuse_loop(struct fuse *f);
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000386
Miklos Szeredi0f48a262002-12-05 14:23:01 +0000387/**
388 * Exit from event loop
389 *
390 * @param f the FUSE handle
391 */
392void fuse_exit(struct fuse *f);
393
Miklos Szeredi2df1c042001-11-06 15:07:17 +0000394/**
Miklos Szeredifff56ab2001-11-16 10:12:59 +0000395 * FUSE event loop with multiple threads
396 *
397 * Requests from the kernel are processed, and the apropriate
398 * operations are called. Request are processed in parallel by
399 * distributing them between multiple threads.
400 *
401 * Calling this function requires the pthreads library to be linked to
402 * the application.
403 *
404 * @param f the FUSE handle
Miklos Szeredib2cf9562004-09-16 08:42:40 +0000405 * @return 0 if no error occured, -1 otherwise
Miklos Szeredifff56ab2001-11-16 10:12:59 +0000406 */
Miklos Szeredib2cf9562004-09-16 08:42:40 +0000407int fuse_loop_mt(struct fuse *f);
Miklos Szeredifff56ab2001-11-16 10:12:59 +0000408
409/**
Miklos Szeredi2e50d432001-12-20 12:17:25 +0000410 * Get the current context
Miklos Szeredie5183742005-02-02 11:14:04 +0000411 *
Miklos Szeredi2e50d432001-12-20 12:17:25 +0000412 * The context is only valid for the duration of a filesystem
413 * operation, and thus must not be stored and used later.
414 *
415 * @param f the FUSE handle
Miklos Szeredie5183742005-02-02 11:14:04 +0000416 * @return the context
Miklos Szeredi2e50d432001-12-20 12:17:25 +0000417 */
Miklos Szeredid169f312004-09-22 08:48:26 +0000418struct fuse_context *fuse_get_context(void);
Miklos Szeredi2e50d432001-12-20 12:17:25 +0000419
Miklos Szeredibd7661b2004-07-23 17:16:29 +0000420/**
Miklos Szeredi76c17522005-07-13 14:08:19 +0000421 * Obsolete, doesn't do anything
Miklos Szeredi9b813af2005-07-21 07:59:37 +0000422 *
Miklos Szeredibd10a7b2005-07-15 09:59:59 +0000423 * @return -EINVAL
Miklos Szeredi5dc8a802004-10-21 09:35:10 +0000424 */
425int fuse_invalidate(struct fuse *f, const char *path);
426
427/**
Miklos Szeredibd7661b2004-07-23 17:16:29 +0000428 * Check whether a mount option should be passed to the kernel or the
429 * library
430 *
431 * @param opt the option to check
432 * @return 1 if it is a library option, 0 otherwise
433 */
434int fuse_is_lib_option(const char *opt);
435
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000436/**
437 * The real main function
Miklos Szeredie5183742005-02-02 11:14:04 +0000438 *
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000439 * Do not call this directly, use fuse_main()
440 */
Miklos Szeredif458b8c2004-12-07 16:46:42 +0000441int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
442 size_t op_size);
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000443
Miklos Szeredicc8c9752001-11-21 10:03:39 +0000444/* ----------------------------------------------------------- *
Miklos Szeredi680a69a2001-11-16 13:31:14 +0000445 * Advanced API for event handling, don't worry about this... *
446 * ----------------------------------------------------------- */
Miklos Szeredifff56ab2001-11-16 10:12:59 +0000447
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000448/** Function type used to process commands */
Miklos Szeredif830a7f2001-11-16 17:46:45 +0000449typedef void (*fuse_processor_t)(struct fuse *, struct fuse_cmd *, void *);
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000450
451/** This is the part of fuse_main() before the event loop */
Miklos Szeredif458b8c2004-12-07 16:46:42 +0000452struct fuse *fuse_setup(int argc, char *argv[],
453 const struct fuse_operations *op, size_t op_size,
Miklos Szeredi5dc8a802004-10-21 09:35:10 +0000454 char **mountpoint, int *multithreaded, int *fd);
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000455
456/** This is the part of fuse_main() after the event loop */
Miklos Szeredif458b8c2004-12-07 16:46:42 +0000457void fuse_teardown(struct fuse *fuse, int fd, char *mountpoint);
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000458
459/** Read a single command. If none are read, return NULL */
Miklos Szeredif458b8c2004-12-07 16:46:42 +0000460struct fuse_cmd *fuse_read_cmd(struct fuse *f);
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000461
462/** Process a single command */
Miklos Szeredif458b8c2004-12-07 16:46:42 +0000463void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd);
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000464
465/** Multi threaded event loop, which calls the custom command
466 processor function */
Miklos Szeredif458b8c2004-12-07 16:46:42 +0000467int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data);
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000468
469/** Return the exited flag, which indicates if fuse_exit() has been
470 called */
Miklos Szeredie2aa2e22005-07-15 13:31:36 +0000471int fuse_exited(struct fuse *f);
Miklos Szeredid59bb9d2004-12-07 10:04:24 +0000472
473/** Set function which can be used to get the current context */
Miklos Szeredif458b8c2004-12-07 16:46:42 +0000474void fuse_set_getcontext_func(struct fuse_context *(*func)(void));
Miklos Szeredif830a7f2001-11-16 17:46:45 +0000475
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000476/* ----------------------------------------------------------- *
477 * Compatibility stuff *
478 * ----------------------------------------------------------- */
479
480#if FUSE_USE_VERSION == 21 || FUSE_USE_VERSION == 11
Miklos Szeredie56818b2004-12-12 11:45:24 +0000481# include "fuse_compat.h"
Miklos Szeredif458b8c2004-12-07 16:46:42 +0000482# define fuse_dirfil_t fuse_dirfil_t_compat
483# define __fuse_read_cmd fuse_read_cmd
484# define __fuse_process_cmd fuse_process_cmd
485# define __fuse_loop_mt fuse_loop_mt_proc
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000486# undef fuse_main
487# undef FUSE_MINOR_VERSION
488# undef FUSE_MAJOR_VERSION
489# if FUSE_USE_VERSION == 21
490# define FUSE_MAJOR_VERSION 2
491# define FUSE_MINOR_VERSION 1
Miklos Szeredif458b8c2004-12-07 16:46:42 +0000492# define fuse_operations fuse_operations_compat2
493# define fuse_main fuse_main_compat2
494# define fuse_new fuse_new_compat2
495# define __fuse_setup fuse_setup_compat2
496# define __fuse_teardown fuse_teardown
497# define __fuse_exited fuse_exited
498# define __fuse_set_getcontext_func fuse_set_getcontext_func
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000499# else
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000500# define FUSE_MAJOR_VERSION 1
501# define FUSE_MINOR_VERSION 1
Miklos Szeredif458b8c2004-12-07 16:46:42 +0000502# define fuse_statfs fuse_statfs_compat1
503# define fuse_operations fuse_operations_compat1
504# define fuse_main fuse_main_compat1
505# define fuse_new fuse_new_compat1
506# define fuse_mount fuse_mount_compat1
507# define FUSE_DEBUG FUSE_DEBUG_COMPAT1
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000508# endif
Miklos Szeredi799993c2004-12-04 21:20:05 +0000509#elif FUSE_USE_VERSION < 22
510# error Compatibility with API version other than 21 and 11 not supported
Miklos Szeredi0b6a0ad2004-12-04 00:40:50 +0000511#endif
512
Miklos Szerediacd4e062001-12-08 20:29:20 +0000513#ifdef __cplusplus
514}
515#endif
516
517#endif /* _FUSE_H_ */