Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 1 | /* |
| 2 | FUSE: Filesystem in Userspace |
Miklos Szeredi | 95da860 | 2006-01-06 18:29:40 +0000 | [diff] [blame] | 3 | Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu> |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 4 | |
Miklos Szeredi | 8b39a9f | 2002-10-25 12:41:16 +0000 | [diff] [blame] | 5 | This program can be distributed under the terms of the GNU LGPL. |
| 6 | See the file COPYING.LIB. |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
Miklos Szeredi | acd4e06 | 2001-12-08 20:29:20 +0000 | [diff] [blame] | 9 | #ifndef _FUSE_H_ |
| 10 | #define _FUSE_H_ |
| 11 | |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 12 | /* This file defines the library interface of FUSE */ |
| 13 | |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 14 | /* IMPORTANT: you should define FUSE_USE_VERSION before including this |
Miklos Szeredi | a039f8f | 2006-02-24 16:21:58 +0000 | [diff] [blame^] | 15 | header. To use the newest API define it to 26 (recommended for any |
| 16 | new application), to use the old API define it to 21 (default) 22 |
| 17 | or 25, to use the even older 1.X API define it to 11. */ |
Miklos Szeredi | c706ad9 | 2005-11-07 15:30:48 +0000 | [diff] [blame] | 18 | |
| 19 | #ifndef FUSE_USE_VERSION |
| 20 | #define FUSE_USE_VERSION 21 |
| 21 | #endif |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 22 | |
Miklos Szeredi | 76c1752 | 2005-07-13 14:08:19 +0000 | [diff] [blame] | 23 | #include "fuse_common.h" |
| 24 | |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 25 | #include <sys/types.h> |
| 26 | #include <sys/stat.h> |
Miklos Szeredi | 52cb09d | 2005-11-07 11:59:00 +0000 | [diff] [blame] | 27 | #include <sys/statvfs.h> |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 28 | #include <utime.h> |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 29 | |
Miklos Szeredi | 8fb48fe | 2004-11-08 14:48:52 +0000 | [diff] [blame] | 30 | #ifdef __cplusplus |
| 31 | extern "C" { |
| 32 | #endif |
| 33 | |
Miklos Szeredi | cc8c975 | 2001-11-21 10:03:39 +0000 | [diff] [blame] | 34 | /* ----------------------------------------------------------- * |
| 35 | * Basic FUSE API * |
| 36 | * ----------------------------------------------------------- */ |
| 37 | |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 38 | /** Handle for a FUSE filesystem */ |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 39 | struct fuse; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 40 | |
Miklos Szeredi | a148242 | 2005-08-14 23:00:27 +0000 | [diff] [blame] | 41 | /** Structure containing a raw command */ |
| 42 | struct fuse_cmd; |
| 43 | |
Miklos Szeredi | 18fce98 | 2005-04-01 21:07:35 +0000 | [diff] [blame] | 44 | /** Function to add an entry in a readdir() operation |
| 45 | * |
| 46 | * @param buf the buffer passed to the readdir() operation |
| 47 | * @param name the file name of the directory entry |
Miklos Szeredi | ab97456 | 2005-04-07 15:40:21 +0000 | [diff] [blame] | 48 | * @param stat file attributes, can be NULL |
| 49 | * @param off offset of the next entry or zero |
| 50 | * @return 1 if buffer is full, zero otherwise |
Miklos Szeredi | 18fce98 | 2005-04-01 21:07:35 +0000 | [diff] [blame] | 51 | */ |
Miklos Szeredi | ab97456 | 2005-04-07 15:40:21 +0000 | [diff] [blame] | 52 | typedef int (*fuse_fill_dir_t) (void *buf, const char *name, |
Miklos Szeredi | f6e0ec6 | 2005-08-03 09:11:06 +0000 | [diff] [blame] | 53 | const struct stat *stbuf, off_t off); |
Miklos Szeredi | ab97456 | 2005-04-07 15:40:21 +0000 | [diff] [blame] | 54 | |
| 55 | /* Used by deprecated getdir() method */ |
| 56 | typedef struct fuse_dirhandle *fuse_dirh_t; |
| 57 | typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type, |
| 58 | ino_t ino); |
Miklos Szeredi | 18fce98 | 2005-04-01 21:07:35 +0000 | [diff] [blame] | 59 | |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 60 | /** |
| 61 | * The file system operations: |
| 62 | * |
| 63 | * Most of these should work very similarly to the well known UNIX |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 64 | * file system operations. A major exception is that instead of |
| 65 | * returning an error in 'errno', the operation should return the |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 66 | * negated error value (-errno) directly. |
Miklos Szeredi | e56818b | 2004-12-12 11:45:24 +0000 | [diff] [blame] | 67 | * |
| 68 | * All methods are optional, but some are essential for a useful |
Miklos Szeredi | 31066bb | 2005-08-01 14:49:31 +0000 | [diff] [blame] | 69 | * filesystem (e.g. getattr). Open, flush, release, fsync, opendir, |
Miklos Szeredi | f7eec03 | 2005-10-28 13:09:50 +0000 | [diff] [blame] | 70 | * releasedir, fsyncdir, access, create, ftruncate, fgetattr, init and |
| 71 | * destroy are special purpose methods, without which a full featured |
Miklos Szeredi | 11509ce | 2005-10-26 16:04:04 +0000 | [diff] [blame] | 72 | * filesystem can still be implemented. |
Miklos Szeredi | e2e4ac2 | 2004-05-18 08:45:28 +0000 | [diff] [blame] | 73 | */ |
Miklos Szeredi | a181e61 | 2001-11-06 12:03:23 +0000 | [diff] [blame] | 74 | struct fuse_operations { |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 75 | /** Get file attributes. |
| 76 | * |
| 77 | * Similar to stat(). The 'st_dev' and 'st_blksize' fields are |
| 78 | * ignored. The 'st_ino' field is ignored except if the 'use_ino' |
| 79 | * mount option is given. |
| 80 | */ |
| 81 | int (*getattr) (const char *, struct stat *); |
| 82 | |
| 83 | /** Read the target of a symbolic link |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 84 | * |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 85 | * The buffer should be filled with a null terminated string. The |
| 86 | * buffer size argument includes the space for the terminating |
| 87 | * null character. If the linkname is too long to fit in the |
| 88 | * buffer, it should be truncated. The return value should be 0 |
| 89 | * for success. |
| 90 | */ |
| 91 | int (*readlink) (const char *, char *, size_t); |
| 92 | |
Miklos Szeredi | ab97456 | 2005-04-07 15:40:21 +0000 | [diff] [blame] | 93 | /* Deprecated, use readdir() instead */ |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 94 | int (*getdir) (const char *, fuse_dirh_t, fuse_dirfil_t); |
| 95 | |
| 96 | /** Create a file node |
| 97 | * |
| 98 | * There is no create() operation, mknod() will be called for |
| 99 | * creation of all non-directory, non-symlink nodes. |
| 100 | */ |
| 101 | int (*mknod) (const char *, mode_t, dev_t); |
| 102 | |
| 103 | /** Create a directory */ |
| 104 | int (*mkdir) (const char *, mode_t); |
| 105 | |
| 106 | /** Remove a file */ |
| 107 | int (*unlink) (const char *); |
| 108 | |
| 109 | /** Remove a directory */ |
| 110 | int (*rmdir) (const char *); |
| 111 | |
| 112 | /** Create a symbolic link */ |
| 113 | int (*symlink) (const char *, const char *); |
| 114 | |
| 115 | /** Rename a file */ |
| 116 | int (*rename) (const char *, const char *); |
| 117 | |
| 118 | /** Create a hard link to a file */ |
| 119 | int (*link) (const char *, const char *); |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 120 | |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 121 | /** Change the permission bits of a file */ |
| 122 | int (*chmod) (const char *, mode_t); |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 123 | |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 124 | /** Change the owner and group of a file */ |
| 125 | int (*chown) (const char *, uid_t, gid_t); |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 126 | |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 127 | /** Change the size of a file */ |
| 128 | int (*truncate) (const char *, off_t); |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 129 | |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 130 | /** Change the access and/or modification times of a file */ |
| 131 | int (*utime) (const char *, struct utimbuf *); |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 132 | |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 133 | /** File open operation |
| 134 | * |
Miklos Szeredi | b75d4b9 | 2005-10-11 10:12:08 +0000 | [diff] [blame] | 135 | * No creation, or truncation flags (O_CREAT, O_EXCL, O_TRUNC) |
Miklos Szeredi | fa84866 | 2005-09-08 15:16:14 +0000 | [diff] [blame] | 136 | * will be passed to open(). Open should check if the operation |
| 137 | * is permitted for the given flags. Optionally open may also |
Miklos Szeredi | b75d4b9 | 2005-10-11 10:12:08 +0000 | [diff] [blame] | 138 | * return an arbitrary filehandle in the fuse_file_info structure, |
Miklos Szeredi | fa84866 | 2005-09-08 15:16:14 +0000 | [diff] [blame] | 139 | * which will be passed to all file operations. |
Miklos Szeredi | 31066bb | 2005-08-01 14:49:31 +0000 | [diff] [blame] | 140 | * |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 141 | * Changed in version 2.2 |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 142 | */ |
| 143 | int (*open) (const char *, struct fuse_file_info *); |
| 144 | |
| 145 | /** Read data from an open file |
| 146 | * |
| 147 | * Read should return exactly the number of bytes requested except |
| 148 | * on EOF or error, otherwise the rest of the data will be |
| 149 | * substituted with zeroes. An exception to this is when the |
| 150 | * 'direct_io' mount option is specified, in which case the return |
| 151 | * value of the read system call will reflect the return value of |
| 152 | * this operation. |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 153 | * |
| 154 | * Changed in version 2.2 |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 155 | */ |
| 156 | int (*read) (const char *, char *, size_t, off_t, struct fuse_file_info *); |
| 157 | |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 158 | /** Write data to an open file |
| 159 | * |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 160 | * Write should return exactly the number of bytes requested |
| 161 | * except on error. An exception to this is when the 'direct_io' |
| 162 | * mount option is specified (see read operation). |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 163 | * |
| 164 | * Changed in version 2.2 |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 165 | */ |
| 166 | int (*write) (const char *, const char *, size_t, off_t, |
| 167 | struct fuse_file_info *); |
| 168 | |
Miklos Szeredi | c706ad9 | 2005-11-07 15:30:48 +0000 | [diff] [blame] | 169 | /** Just a placeholder, don't set */ |
Miklos Szeredi | 3a77047 | 2005-11-11 21:32:42 +0000 | [diff] [blame] | 170 | /** Get file system statistics |
| 171 | * |
| 172 | * The 'f_frsize', 'f_favail', 'f_fsid' and 'f_flag' fields are ignored |
| 173 | * |
| 174 | * Replaced 'struct statfs' parameter with 'struct statvfs' in |
| 175 | * version 2.5 |
| 176 | */ |
| 177 | int (*statfs) (const char *, struct statvfs *); |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 178 | |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 179 | /** Possibly flush cached data |
| 180 | * |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 181 | * BIG NOTE: This is not equivalent to fsync(). It's not a |
Miklos Szeredi | e56818b | 2004-12-12 11:45:24 +0000 | [diff] [blame] | 182 | * request to sync dirty data. |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 183 | * |
| 184 | * Flush is called on each close() of a file descriptor. So if a |
| 185 | * filesystem wants to return write errors in close() and the file |
| 186 | * has cached dirty data, this is a good place to write back data |
Miklos Szeredi | e56818b | 2004-12-12 11:45:24 +0000 | [diff] [blame] | 187 | * and return any errors. Since many applications ignore close() |
| 188 | * errors this is not always useful. |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 189 | * |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 190 | * NOTE: The flush() method may be called more than once for each |
| 191 | * open(). This happens if more than one file descriptor refers |
| 192 | * to an opened file due to dup(), dup2() or fork() calls. It is |
| 193 | * not possible to determine if a flush is final, so each flush |
| 194 | * should be treated equally. Multiple write-flush sequences are |
| 195 | * relatively rare, so this shouldn't be a problem. |
Miklos Szeredi | 9b813af | 2005-07-21 07:59:37 +0000 | [diff] [blame] | 196 | * |
Miklos Szeredi | b75d4b9 | 2005-10-11 10:12:08 +0000 | [diff] [blame] | 197 | * Filesystems shouldn't assume that flush will always be called |
Miklos Szeredi | 7f54fb4 | 2005-10-10 08:42:17 +0000 | [diff] [blame] | 198 | * after some writes, or that if will be called at all. |
| 199 | * |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 200 | * Changed in version 2.2 |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 201 | */ |
| 202 | int (*flush) (const char *, struct fuse_file_info *); |
| 203 | |
| 204 | /** Release an open file |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 205 | * |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 206 | * Release is called when there are no more references to an open |
| 207 | * file: all file descriptors are closed and all memory mappings |
| 208 | * are unmapped. |
| 209 | * |
| 210 | * For every open() call there will be exactly one release() call |
Miklos Szeredi | e56818b | 2004-12-12 11:45:24 +0000 | [diff] [blame] | 211 | * with the same flags and file descriptor. It is possible to |
| 212 | * have a file opened more than once, in which case only the last |
| 213 | * release will mean, that no more reads/writes will happen on the |
| 214 | * file. The return value of release is ignored. |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 215 | * |
| 216 | * Changed in version 2.2 |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 217 | */ |
| 218 | int (*release) (const char *, struct fuse_file_info *); |
| 219 | |
| 220 | /** Synchronize file contents |
| 221 | * |
| 222 | * If the datasync parameter is non-zero, then only the user data |
| 223 | * should be flushed, not the meta data. |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 224 | * |
| 225 | * Changed in version 2.2 |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 226 | */ |
| 227 | int (*fsync) (const char *, int, struct fuse_file_info *); |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 228 | |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 229 | /** Set extended attributes */ |
| 230 | int (*setxattr) (const char *, const char *, const char *, size_t, int); |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 231 | |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 232 | /** Get extended attributes */ |
| 233 | int (*getxattr) (const char *, const char *, char *, size_t); |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 234 | |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 235 | /** List extended attributes */ |
| 236 | int (*listxattr) (const char *, char *, size_t); |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 237 | |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 238 | /** Remove extended attributes */ |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 239 | int (*removexattr) (const char *, const char *); |
Miklos Szeredi | f43f063 | 2005-02-28 11:46:56 +0000 | [diff] [blame] | 240 | |
Miklos Szeredi | 009b878 | 2005-08-01 13:36:53 +0000 | [diff] [blame] | 241 | /** Open directory |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 242 | * |
Miklos Szeredi | fa84866 | 2005-09-08 15:16:14 +0000 | [diff] [blame] | 243 | * This method should check if the open operation is permitted for |
| 244 | * this directory |
| 245 | * |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 246 | * Introduced in version 2.3 |
Miklos Szeredi | f43f063 | 2005-02-28 11:46:56 +0000 | [diff] [blame] | 247 | */ |
| 248 | int (*opendir) (const char *, struct fuse_file_info *); |
Miklos Szeredi | 159bd7e | 2005-02-28 17:32:16 +0000 | [diff] [blame] | 249 | |
Miklos Szeredi | 18fce98 | 2005-04-01 21:07:35 +0000 | [diff] [blame] | 250 | /** Read directory |
| 251 | * |
Miklos Szeredi | ab97456 | 2005-04-07 15:40:21 +0000 | [diff] [blame] | 252 | * This supersedes the old getdir() interface. New applications |
| 253 | * should use this. |
| 254 | * |
| 255 | * The filesystem may choose between two modes of operation: |
Miklos Szeredi | 21019c9 | 2005-05-09 11:22:41 +0000 | [diff] [blame] | 256 | * |
Miklos Szeredi | ab97456 | 2005-04-07 15:40:21 +0000 | [diff] [blame] | 257 | * 1) The readdir implementation ignores the offset parameter, and |
| 258 | * passes zero to the filler function's offset. The filler |
| 259 | * function will not return '1' (unless an error happens), so the |
| 260 | * whole directory is read in a single readdir operation. This |
| 261 | * works just like the old getdir() method. |
| 262 | * |
| 263 | * 2) The readdir implementation keeps track of the offsets of the |
| 264 | * directory entries. It uses the offset parameter and always |
| 265 | * passes non-zero offset to the filler function. When the buffer |
| 266 | * is full (or an error happens) the filler function will return |
| 267 | * '1'. |
Miklos Szeredi | 9b813af | 2005-07-21 07:59:37 +0000 | [diff] [blame] | 268 | * |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 269 | * Introduced in version 2.3 |
Miklos Szeredi | 18fce98 | 2005-04-01 21:07:35 +0000 | [diff] [blame] | 270 | */ |
Miklos Szeredi | ab97456 | 2005-04-07 15:40:21 +0000 | [diff] [blame] | 271 | int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t, |
Miklos Szeredi | 18fce98 | 2005-04-01 21:07:35 +0000 | [diff] [blame] | 272 | struct fuse_file_info *); |
| 273 | |
Miklos Szeredi | 9b813af | 2005-07-21 07:59:37 +0000 | [diff] [blame] | 274 | /** Release directory |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 275 | * |
| 276 | * Introduced in version 2.3 |
| 277 | */ |
Miklos Szeredi | 18fce98 | 2005-04-01 21:07:35 +0000 | [diff] [blame] | 278 | int (*releasedir) (const char *, struct fuse_file_info *); |
| 279 | |
Miklos Szeredi | 4283ee7 | 2005-03-21 12:09:04 +0000 | [diff] [blame] | 280 | /** Synchronize directory contents |
| 281 | * |
| 282 | * If the datasync parameter is non-zero, then only the user data |
Miklos Szeredi | 18fce98 | 2005-04-01 21:07:35 +0000 | [diff] [blame] | 283 | * should be flushed, not the meta data |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 284 | * |
| 285 | * Introduced in version 2.3 |
Miklos Szeredi | 4283ee7 | 2005-03-21 12:09:04 +0000 | [diff] [blame] | 286 | */ |
| 287 | int (*fsyncdir) (const char *, int, struct fuse_file_info *); |
| 288 | |
Miklos Szeredi | 159bd7e | 2005-02-28 17:32:16 +0000 | [diff] [blame] | 289 | /** |
| 290 | * Initialize filesystem |
| 291 | * |
| 292 | * The return value will passed in the private_data field of |
| 293 | * fuse_context to all file operations and as a parameter to the |
| 294 | * destroy() method. |
Miklos Szeredi | 9b813af | 2005-07-21 07:59:37 +0000 | [diff] [blame] | 295 | * |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 296 | * Introduced in version 2.3 |
Miklos Szeredi | 159bd7e | 2005-02-28 17:32:16 +0000 | [diff] [blame] | 297 | */ |
Miklos Szeredi | 065f222 | 2006-01-20 15:15:21 +0000 | [diff] [blame] | 298 | void *(*init) (struct fuse_conn_info *conn); |
Miklos Szeredi | 159bd7e | 2005-02-28 17:32:16 +0000 | [diff] [blame] | 299 | |
| 300 | /** |
| 301 | * Clean up filesystem |
Miklos Szeredi | 18fce98 | 2005-04-01 21:07:35 +0000 | [diff] [blame] | 302 | * |
Miklos Szeredi | 159bd7e | 2005-02-28 17:32:16 +0000 | [diff] [blame] | 303 | * Called on filesystem exit. |
Miklos Szeredi | 9b813af | 2005-07-21 07:59:37 +0000 | [diff] [blame] | 304 | * |
Miklos Szeredi | 437d811 | 2005-07-06 09:14:20 +0000 | [diff] [blame] | 305 | * Introduced in version 2.3 |
Miklos Szeredi | 159bd7e | 2005-02-28 17:32:16 +0000 | [diff] [blame] | 306 | */ |
| 307 | void (*destroy) (void *); |
Miklos Szeredi | b0b13d1 | 2005-10-26 12:53:25 +0000 | [diff] [blame] | 308 | |
| 309 | /** |
| 310 | * Check file access permissions |
| 311 | * |
Miklos Szeredi | d9079a7 | 2005-10-26 15:29:06 +0000 | [diff] [blame] | 312 | * This will be called for the access() system call. If the |
| 313 | * 'default_permissions' mount option is given, this method is not |
| 314 | * called. |
| 315 | * |
| 316 | * This method is not called under Linux kernel versions 2.4.x |
Miklos Szeredi | b0b13d1 | 2005-10-26 12:53:25 +0000 | [diff] [blame] | 317 | * |
| 318 | * Introduced in version 2.5 |
| 319 | */ |
| 320 | int (*access) (const char *, int); |
Miklos Szeredi | d9079a7 | 2005-10-26 15:29:06 +0000 | [diff] [blame] | 321 | |
| 322 | /** |
| 323 | * Create and open a file |
| 324 | * |
| 325 | * If the file does not exist, first create it with the specified |
| 326 | * mode, and then open it. |
| 327 | * |
| 328 | * If this method is not implemented or under Linux kernel |
| 329 | * versions earlier than 2.6.15, the mknod() and open() methods |
| 330 | * will be called instead. |
| 331 | * |
| 332 | * Introduced in version 2.5 |
| 333 | */ |
| 334 | int (*create) (const char *, mode_t, struct fuse_file_info *); |
Miklos Szeredi | 11509ce | 2005-10-26 16:04:04 +0000 | [diff] [blame] | 335 | |
| 336 | /** |
| 337 | * Change the size of an open file |
| 338 | * |
| 339 | * This method is called instead of the truncate() method if the |
| 340 | * truncation was invoked from an ftruncate() system call. |
| 341 | * |
| 342 | * If this method is not implemented or under Linux kernel |
| 343 | * versions earlier than 2.6.15, the truncate() method will be |
| 344 | * called instead. |
| 345 | * |
| 346 | * Introduced in version 2.5 |
| 347 | */ |
| 348 | int (*ftruncate) (const char *, off_t, struct fuse_file_info *); |
Miklos Szeredi | f7eec03 | 2005-10-28 13:09:50 +0000 | [diff] [blame] | 349 | |
| 350 | /** |
| 351 | * Get attributes from an open file |
| 352 | * |
| 353 | * This method is called instead of the getattr() method if the |
| 354 | * file information is available. |
| 355 | * |
| 356 | * Currently this is only called after the create() method if that |
| 357 | * is implemented (see above). Later it may be called for |
| 358 | * invocations of fstat() too. |
| 359 | * |
| 360 | * Introduced in version 2.5 |
| 361 | */ |
| 362 | int (*fgetattr) (const char *, struct stat *, struct fuse_file_info *); |
Miklos Szeredi | a181e61 | 2001-11-06 12:03:23 +0000 | [diff] [blame] | 363 | }; |
| 364 | |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 365 | /** Extra context that may be needed by some filesystems |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 366 | * |
| 367 | * The uid, gid and pid fields are not filled in case of a writepage |
| 368 | * operation. |
| 369 | */ |
Miklos Szeredi | 2e50d43 | 2001-12-20 12:17:25 +0000 | [diff] [blame] | 370 | struct fuse_context { |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 371 | /** Pointer to the fuse object */ |
Miklos Szeredi | d169f31 | 2004-09-22 08:48:26 +0000 | [diff] [blame] | 372 | struct fuse *fuse; |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 373 | |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 374 | /** User ID of the calling process */ |
Miklos Szeredi | 2e50d43 | 2001-12-20 12:17:25 +0000 | [diff] [blame] | 375 | uid_t uid; |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 376 | |
| 377 | /** Group ID of the calling process */ |
Miklos Szeredi | 2e50d43 | 2001-12-20 12:17:25 +0000 | [diff] [blame] | 378 | gid_t gid; |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 379 | |
| 380 | /** Thread ID of the calling process */ |
Miklos Szeredi | 1f18db5 | 2004-09-27 06:54:49 +0000 | [diff] [blame] | 381 | pid_t pid; |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 382 | |
Miklos Szeredi | 159bd7e | 2005-02-28 17:32:16 +0000 | [diff] [blame] | 383 | /** Private filesystem data */ |
Miklos Szeredi | 8fb48fe | 2004-11-08 14:48:52 +0000 | [diff] [blame] | 384 | void *private_data; |
Miklos Szeredi | 2e50d43 | 2001-12-20 12:17:25 +0000 | [diff] [blame] | 385 | }; |
| 386 | |
Miklos Szeredi | a4b0c77 | 2002-04-19 15:57:02 +0000 | [diff] [blame] | 387 | /* |
Miklos Szeredi | 0e53508 | 2003-10-13 10:08:06 +0000 | [diff] [blame] | 388 | * Main function of FUSE. |
| 389 | * |
| 390 | * This is for the lazy. This is all that has to be called from the |
| 391 | * main() function. |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 392 | * |
Miklos Szeredi | 0e53508 | 2003-10-13 10:08:06 +0000 | [diff] [blame] | 393 | * This function does the following: |
Miklos Szeredi | 307242f | 2004-01-26 11:28:44 +0000 | [diff] [blame] | 394 | * - parses command line options (-d -s and -h) |
Miklos Szeredi | bd7661b | 2004-07-23 17:16:29 +0000 | [diff] [blame] | 395 | * - passes relevant mount options to the fuse_mount() |
Miklos Szeredi | 0e53508 | 2003-10-13 10:08:06 +0000 | [diff] [blame] | 396 | * - installs signal handlers for INT, HUP, TERM and PIPE |
| 397 | * - registers an exit handler to unmount the filesystem on program exit |
Miklos Szeredi | 0e53508 | 2003-10-13 10:08:06 +0000 | [diff] [blame] | 398 | * - creates a fuse handle |
| 399 | * - registers the operations |
| 400 | * - calls either the single-threaded or the multi-threaded event loop |
| 401 | * |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 402 | * Note: this is currently implemented as a macro. |
| 403 | * |
Miklos Szeredi | 0e53508 | 2003-10-13 10:08:06 +0000 | [diff] [blame] | 404 | * @param argc the argument counter passed to the main() function |
| 405 | * @param argv the argument vector passed to the main() function |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 406 | * @param op the file system operation |
Miklos Szeredi | 5dc8a80 | 2004-10-21 09:35:10 +0000 | [diff] [blame] | 407 | * @return 0 on success, nonzero on failure |
Miklos Szeredi | 0e53508 | 2003-10-13 10:08:06 +0000 | [diff] [blame] | 408 | */ |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 409 | /* |
| 410 | int fuse_main(int argc, char *argv[], const struct fuse_operations *op); |
| 411 | */ |
| 412 | #define fuse_main(argc, argv, op) \ |
Miklos Szeredi | f458b8c | 2004-12-07 16:46:42 +0000 | [diff] [blame] | 413 | fuse_main_real(argc, argv, op, sizeof(*(op))) |
Miklos Szeredi | 891b874 | 2004-07-29 09:27:49 +0000 | [diff] [blame] | 414 | |
Miklos Szeredi | 0e53508 | 2003-10-13 10:08:06 +0000 | [diff] [blame] | 415 | /* ----------------------------------------------------------- * |
| 416 | * More detailed API * |
| 417 | * ----------------------------------------------------------- */ |
| 418 | |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 419 | /** |
Miklos Szeredi | 8cffdb9 | 2001-11-09 14:49:18 +0000 | [diff] [blame] | 420 | * Create a new FUSE filesystem. |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 421 | * |
Miklos Szeredi | 8cffdb9 | 2001-11-09 14:49:18 +0000 | [diff] [blame] | 422 | * @param fd the control file descriptor |
Miklos Szeredi | 95da860 | 2006-01-06 18:29:40 +0000 | [diff] [blame] | 423 | * @param args argument vector |
Miklos Szeredi | 2e50d43 | 2001-12-20 12:17:25 +0000 | [diff] [blame] | 424 | * @param op the operations |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 425 | * @param op_size the size of the fuse_operations structure |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 426 | * @return the created FUSE handle |
| 427 | */ |
Miklos Szeredi | 95da860 | 2006-01-06 18:29:40 +0000 | [diff] [blame] | 428 | struct fuse *fuse_new(int fd, struct fuse_args *args, |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 429 | const struct fuse_operations *op, size_t op_size); |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 430 | |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 431 | /** |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 432 | * Destroy the FUSE handle. |
Miklos Szeredi | 0f48a26 | 2002-12-05 14:23:01 +0000 | [diff] [blame] | 433 | * |
| 434 | * The filesystem is not unmounted. |
| 435 | * |
| 436 | * @param f the FUSE handle |
| 437 | */ |
| 438 | void fuse_destroy(struct fuse *f); |
| 439 | |
| 440 | /** |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 441 | * FUSE event loop. |
| 442 | * |
Miklos Szeredi | b75d4b9 | 2005-10-11 10:12:08 +0000 | [diff] [blame] | 443 | * Requests from the kernel are processed, and the appropriate |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 444 | * operations are called. |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 445 | * |
| 446 | * @param f the FUSE handle |
Miklos Szeredi | b75d4b9 | 2005-10-11 10:12:08 +0000 | [diff] [blame] | 447 | * @return 0 if no error occurred, -1 otherwise |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 448 | */ |
Miklos Szeredi | b2cf956 | 2004-09-16 08:42:40 +0000 | [diff] [blame] | 449 | int fuse_loop(struct fuse *f); |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 450 | |
Miklos Szeredi | 0f48a26 | 2002-12-05 14:23:01 +0000 | [diff] [blame] | 451 | /** |
| 452 | * Exit from event loop |
| 453 | * |
| 454 | * @param f the FUSE handle |
| 455 | */ |
| 456 | void fuse_exit(struct fuse *f); |
| 457 | |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 458 | /** |
Miklos Szeredi | fff56ab | 2001-11-16 10:12:59 +0000 | [diff] [blame] | 459 | * FUSE event loop with multiple threads |
| 460 | * |
Miklos Szeredi | b75d4b9 | 2005-10-11 10:12:08 +0000 | [diff] [blame] | 461 | * Requests from the kernel are processed, and the appropriate |
Miklos Szeredi | fff56ab | 2001-11-16 10:12:59 +0000 | [diff] [blame] | 462 | * operations are called. Request are processed in parallel by |
| 463 | * distributing them between multiple threads. |
| 464 | * |
| 465 | * Calling this function requires the pthreads library to be linked to |
| 466 | * the application. |
| 467 | * |
| 468 | * @param f the FUSE handle |
Miklos Szeredi | b75d4b9 | 2005-10-11 10:12:08 +0000 | [diff] [blame] | 469 | * @return 0 if no error occurred, -1 otherwise |
Miklos Szeredi | fff56ab | 2001-11-16 10:12:59 +0000 | [diff] [blame] | 470 | */ |
Miklos Szeredi | b2cf956 | 2004-09-16 08:42:40 +0000 | [diff] [blame] | 471 | int fuse_loop_mt(struct fuse *f); |
Miklos Szeredi | fff56ab | 2001-11-16 10:12:59 +0000 | [diff] [blame] | 472 | |
| 473 | /** |
Miklos Szeredi | 2e50d43 | 2001-12-20 12:17:25 +0000 | [diff] [blame] | 474 | * Get the current context |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 475 | * |
Miklos Szeredi | 2e50d43 | 2001-12-20 12:17:25 +0000 | [diff] [blame] | 476 | * The context is only valid for the duration of a filesystem |
| 477 | * operation, and thus must not be stored and used later. |
| 478 | * |
| 479 | * @param f the FUSE handle |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 480 | * @return the context |
Miklos Szeredi | 2e50d43 | 2001-12-20 12:17:25 +0000 | [diff] [blame] | 481 | */ |
Miklos Szeredi | d169f31 | 2004-09-22 08:48:26 +0000 | [diff] [blame] | 482 | struct fuse_context *fuse_get_context(void); |
Miklos Szeredi | 2e50d43 | 2001-12-20 12:17:25 +0000 | [diff] [blame] | 483 | |
Miklos Szeredi | bd7661b | 2004-07-23 17:16:29 +0000 | [diff] [blame] | 484 | /** |
Miklos Szeredi | 76c1752 | 2005-07-13 14:08:19 +0000 | [diff] [blame] | 485 | * Obsolete, doesn't do anything |
Miklos Szeredi | 9b813af | 2005-07-21 07:59:37 +0000 | [diff] [blame] | 486 | * |
Miklos Szeredi | bd10a7b | 2005-07-15 09:59:59 +0000 | [diff] [blame] | 487 | * @return -EINVAL |
Miklos Szeredi | 5dc8a80 | 2004-10-21 09:35:10 +0000 | [diff] [blame] | 488 | */ |
| 489 | int fuse_invalidate(struct fuse *f, const char *path); |
| 490 | |
Miklos Szeredi | 95da860 | 2006-01-06 18:29:40 +0000 | [diff] [blame] | 491 | /* Deprecated, don't use */ |
Miklos Szeredi | bd7661b | 2004-07-23 17:16:29 +0000 | [diff] [blame] | 492 | int fuse_is_lib_option(const char *opt); |
| 493 | |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 494 | /** |
| 495 | * The real main function |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 496 | * |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 497 | * Do not call this directly, use fuse_main() |
| 498 | */ |
Miklos Szeredi | f458b8c | 2004-12-07 16:46:42 +0000 | [diff] [blame] | 499 | int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, |
| 500 | size_t op_size); |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 501 | |
Miklos Szeredi | cc8c975 | 2001-11-21 10:03:39 +0000 | [diff] [blame] | 502 | /* ----------------------------------------------------------- * |
Miklos Szeredi | 680a69a | 2001-11-16 13:31:14 +0000 | [diff] [blame] | 503 | * Advanced API for event handling, don't worry about this... * |
| 504 | * ----------------------------------------------------------- */ |
Miklos Szeredi | fff56ab | 2001-11-16 10:12:59 +0000 | [diff] [blame] | 505 | |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 506 | /** Function type used to process commands */ |
Miklos Szeredi | f830a7f | 2001-11-16 17:46:45 +0000 | [diff] [blame] | 507 | typedef void (*fuse_processor_t)(struct fuse *, struct fuse_cmd *, void *); |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 508 | |
| 509 | /** This is the part of fuse_main() before the event loop */ |
Miklos Szeredi | 60c69a2 | 2006-01-07 08:51:19 +0000 | [diff] [blame] | 510 | struct fuse *fuse_setup(int argc, char *argv[], |
Miklos Szeredi | f458b8c | 2004-12-07 16:46:42 +0000 | [diff] [blame] | 511 | const struct fuse_operations *op, size_t op_size, |
Miklos Szeredi | 95da860 | 2006-01-06 18:29:40 +0000 | [diff] [blame] | 512 | char **mountpoint, int *multithreaded, int *fd); |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 513 | |
| 514 | /** This is the part of fuse_main() after the event loop */ |
Miklos Szeredi | f458b8c | 2004-12-07 16:46:42 +0000 | [diff] [blame] | 515 | void fuse_teardown(struct fuse *fuse, int fd, char *mountpoint); |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 516 | |
| 517 | /** Read a single command. If none are read, return NULL */ |
Miklos Szeredi | f458b8c | 2004-12-07 16:46:42 +0000 | [diff] [blame] | 518 | struct fuse_cmd *fuse_read_cmd(struct fuse *f); |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 519 | |
| 520 | /** Process a single command */ |
Miklos Szeredi | f458b8c | 2004-12-07 16:46:42 +0000 | [diff] [blame] | 521 | void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd); |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 522 | |
| 523 | /** Multi threaded event loop, which calls the custom command |
| 524 | processor function */ |
Miklos Szeredi | f458b8c | 2004-12-07 16:46:42 +0000 | [diff] [blame] | 525 | int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data); |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 526 | |
| 527 | /** Return the exited flag, which indicates if fuse_exit() has been |
| 528 | called */ |
Miklos Szeredi | e2aa2e2 | 2005-07-15 13:31:36 +0000 | [diff] [blame] | 529 | int fuse_exited(struct fuse *f); |
Miklos Szeredi | d59bb9d | 2004-12-07 10:04:24 +0000 | [diff] [blame] | 530 | |
| 531 | /** Set function which can be used to get the current context */ |
Miklos Szeredi | f458b8c | 2004-12-07 16:46:42 +0000 | [diff] [blame] | 532 | void fuse_set_getcontext_func(struct fuse_context *(*func)(void)); |
Miklos Szeredi | f830a7f | 2001-11-16 17:46:45 +0000 | [diff] [blame] | 533 | |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 534 | /* ----------------------------------------------------------- * |
| 535 | * Compatibility stuff * |
| 536 | * ----------------------------------------------------------- */ |
| 537 | |
Miklos Szeredi | 065f222 | 2006-01-20 15:15:21 +0000 | [diff] [blame] | 538 | #ifdef __FreeBSD__ |
| 539 | # if FUSE_USE_VERSION < 25 |
| 540 | # error On FreeBSD API version 25 or greater must be used |
| 541 | # endif |
| 542 | #endif |
Miklos Szeredi | 9c2ccb4 | 2005-11-17 17:11:48 +0000 | [diff] [blame] | 543 | |
Miklos Szeredi | 065f222 | 2006-01-20 15:15:21 +0000 | [diff] [blame] | 544 | #if FUSE_USE_VERSION == 25 || FUSE_USE_VERSION == 22 || \ |
| 545 | FUSE_USE_VERSION == 21 || FUSE_USE_VERSION == 11 |
Miklos Szeredi | e56818b | 2004-12-12 11:45:24 +0000 | [diff] [blame] | 546 | # include "fuse_compat.h" |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 547 | # undef FUSE_MINOR_VERSION |
Miklos Szeredi | c706ad9 | 2005-11-07 15:30:48 +0000 | [diff] [blame] | 548 | # undef fuse_main |
Miklos Szeredi | 065f222 | 2006-01-20 15:15:21 +0000 | [diff] [blame] | 549 | # if FUSE_USE_VERSION == 25 |
Miklos Szeredi | 83deefd | 2006-01-23 17:11:24 +0000 | [diff] [blame] | 550 | # define FUSE_MINOR_VERSION 5 |
Miklos Szeredi | 065f222 | 2006-01-20 15:15:21 +0000 | [diff] [blame] | 551 | # define fuse_main(argc, argv, op) \ |
| 552 | fuse_main_real_compat25(argc, argv, op, sizeof(*(op))) |
| 553 | # define fuse_new fuse_new_compat25 |
| 554 | # define fuse_setup fuse_setup_compat25 |
| 555 | # define fuse_operations fuse_operations_compat25 |
| 556 | # elif FUSE_USE_VERSION == 22 |
Miklos Szeredi | c706ad9 | 2005-11-07 15:30:48 +0000 | [diff] [blame] | 557 | # define FUSE_MINOR_VERSION 4 |
Miklos Szeredi | 3a77047 | 2005-11-11 21:32:42 +0000 | [diff] [blame] | 558 | # define fuse_main(argc, argv, op) \ |
| 559 | fuse_main_real_compat22(argc, argv, op, sizeof(*(op))) |
| 560 | # define fuse_new fuse_new_compat22 |
| 561 | # define fuse_setup fuse_setup_compat22 |
Miklos Szeredi | c706ad9 | 2005-11-07 15:30:48 +0000 | [diff] [blame] | 562 | # define fuse_operations fuse_operations_compat22 |
Miklos Szeredi | 3a77047 | 2005-11-11 21:32:42 +0000 | [diff] [blame] | 563 | # define fuse_file_info fuse_file_info_compat22 |
Miklos Szeredi | 065f222 | 2006-01-20 15:15:21 +0000 | [diff] [blame] | 564 | # define fuse_mount fuse_mount_compat22 |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 565 | # else |
Miklos Szeredi | c706ad9 | 2005-11-07 15:30:48 +0000 | [diff] [blame] | 566 | # define fuse_dirfil_t fuse_dirfil_t_compat |
| 567 | # define __fuse_read_cmd fuse_read_cmd |
| 568 | # define __fuse_process_cmd fuse_process_cmd |
| 569 | # define __fuse_loop_mt fuse_loop_mt_proc |
| 570 | # if FUSE_USE_VERSION == 21 |
Miklos Szeredi | 065f222 | 2006-01-20 15:15:21 +0000 | [diff] [blame] | 571 | # define FUSE_MINOR_VERSION 1 |
Miklos Szeredi | c706ad9 | 2005-11-07 15:30:48 +0000 | [diff] [blame] | 572 | # define fuse_operations fuse_operations_compat2 |
| 573 | # define fuse_main fuse_main_compat2 |
| 574 | # define fuse_new fuse_new_compat2 |
| 575 | # define __fuse_setup fuse_setup_compat2 |
| 576 | # define __fuse_teardown fuse_teardown |
| 577 | # define __fuse_exited fuse_exited |
| 578 | # define __fuse_set_getcontext_func fuse_set_getcontext_func |
Miklos Szeredi | 065f222 | 2006-01-20 15:15:21 +0000 | [diff] [blame] | 579 | # define fuse_mount fuse_mount_compat22 |
Miklos Szeredi | c706ad9 | 2005-11-07 15:30:48 +0000 | [diff] [blame] | 580 | # else |
Miklos Szeredi | 05c9784 | 2005-11-20 17:05:07 +0000 | [diff] [blame] | 581 | # warning Compatibility with API version 11 is deprecated |
Miklos Szeredi | c706ad9 | 2005-11-07 15:30:48 +0000 | [diff] [blame] | 582 | # undef FUSE_MAJOR_VERSION |
| 583 | # define FUSE_MAJOR_VERSION 1 |
| 584 | # define FUSE_MINOR_VERSION 1 |
| 585 | # define fuse_statfs fuse_statfs_compat1 |
| 586 | # define fuse_operations fuse_operations_compat1 |
| 587 | # define fuse_main fuse_main_compat1 |
| 588 | # define fuse_new fuse_new_compat1 |
| 589 | # define fuse_mount fuse_mount_compat1 |
| 590 | # define FUSE_DEBUG FUSE_DEBUG_COMPAT1 |
| 591 | # endif |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 592 | # endif |
Miklos Szeredi | 83deefd | 2006-01-23 17:11:24 +0000 | [diff] [blame] | 593 | #elif FUSE_USE_VERSION < 26 |
Miklos Szeredi | 065f222 | 2006-01-20 15:15:21 +0000 | [diff] [blame] | 594 | # error Compatibility with API version other than 21, 22, 25 and 11 not supported |
Miklos Szeredi | 0b6a0ad | 2004-12-04 00:40:50 +0000 | [diff] [blame] | 595 | #endif |
| 596 | |
Miklos Szeredi | acd4e06 | 2001-12-08 20:29:20 +0000 | [diff] [blame] | 597 | #ifdef __cplusplus |
| 598 | } |
| 599 | #endif |
| 600 | |
| 601 | #endif /* _FUSE_H_ */ |