You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

877 lines
29 KiB

  1. /*
  2. FUSE: Filesystem in Userspace
  3. Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
  4. This program can be distributed under the terms of the GNU LGPLv2.
  5. See the file COPYING.LIB.
  6. */
  7. #ifndef _FUSE_H_
  8. #define _FUSE_H_
  9. /** @file
  10. *
  11. * This file defines the library interface of FUSE
  12. *
  13. * IMPORTANT: you should define FUSE_USE_VERSION before including this
  14. * header. To use the newest API define it to 26 (recommended for any
  15. * new application), to use the old API define it to 21 (default) 22
  16. * or 25, to use the even older 1.X API define it to 11.
  17. */
  18. #ifndef FUSE_USE_VERSION
  19. #define FUSE_USE_VERSION 21
  20. #endif
  21. #include "extern_c.h"
  22. #include "fuse_common.h"
  23. #include <fcntl.h>
  24. #include <time.h>
  25. #include <utime.h>
  26. #include <sys/types.h>
  27. #include <sys/stat.h>
  28. #include <sys/statvfs.h>
  29. #include <sys/uio.h>
  30. EXTERN_C_BEGIN
  31. /* ----------------------------------------------------------- *
  32. * Basic FUSE API *
  33. * ----------------------------------------------------------- */
  34. /** Handle for a FUSE filesystem */
  35. struct fuse;
  36. /** Structure containing a raw command */
  37. struct fuse_cmd;
  38. struct fuse_dirents_t;
  39. typedef struct fuse_dirents_t fuse_dirents_t;
  40. /**
  41. * The file system operations:
  42. *
  43. * Most of these should work very similarly to the well known UNIX
  44. * file system operations. A major exception is that instead of
  45. * returning an error in 'errno', the operation should return the
  46. * negated error value (-errno) directly.
  47. *
  48. * All methods are optional, but some are essential for a useful
  49. * filesystem (e.g. getattr). Open, flush, release, fsync, opendir,
  50. * releasedir, fsyncdir, access, create, ftruncate, fgetattr, lock,
  51. * init and destroy are special purpose methods, without which a full
  52. * featured filesystem can still be implemented.
  53. *
  54. * Almost all operations take a path which can be of any length.
  55. *
  56. * Changed in fuse 2.8.0 (regardless of API version)
  57. * Previously, paths were limited to a length of PATH_MAX.
  58. *
  59. * See http://fuse.sourceforge.net/wiki/ for more information. There
  60. * is also a snapshot of the relevant wiki pages in the doc/ folder.
  61. */
  62. struct fuse_operations
  63. {
  64. /** Get file attributes.
  65. *
  66. * Similar to stat(). The 'st_dev' and 'st_blksize' fields are
  67. * ignored. The 'st_ino' field is ignored except if the 'use_ino'
  68. * mount option is given.
  69. */
  70. int (*getattr) (const char *, struct stat *, fuse_timeouts_t *);
  71. /** Read the target of a symbolic link
  72. *
  73. * The buffer should be filled with a null terminated string. The
  74. * buffer size argument includes the space for the terminating
  75. * null character. If the linkname is too long to fit in the
  76. * buffer, it should be truncated. The return value should be 0
  77. * for success.
  78. */
  79. int (*readlink) (const char *, char *, size_t);
  80. /** Create a file node
  81. *
  82. * This is called for creation of all non-directory, non-symlink
  83. * nodes. If the filesystem defines a create() method, then for
  84. * regular files that will be called instead.
  85. */
  86. int (*mknod) (const char *, mode_t, dev_t);
  87. /** Create a directory
  88. *
  89. * Note that the mode argument may not have the type specification
  90. * bits set, i.e. S_ISDIR(mode) can be false. To obtain the
  91. * correct directory type bits use mode|S_IFDIR
  92. * */
  93. int (*mkdir) (const char *, mode_t);
  94. /** Hide files unlinked / renamed over
  95. *
  96. * Allows storing of a file handle when a file is unlinked
  97. * while open. Helps manage the fact the kernel usually does
  98. * not send fh with getattr requests.
  99. */
  100. int (*prepare_hide)(const char *name_, uint64_t *fh_);
  101. int (*free_hide)(const uint64_t fh_);
  102. /** Remove a file */
  103. int (*unlink) (const char *);
  104. /** Remove a directory */
  105. int (*rmdir) (const char *);
  106. /** Create a symbolic link */
  107. int (*symlink) (const char *, const char *, struct stat *, fuse_timeouts_t *);
  108. /** Rename a file */
  109. int (*rename) (const char *, const char *);
  110. /** Create a hard link to a file */
  111. int (*link) (const char *, const char *, struct stat *, fuse_timeouts_t *);
  112. /** Change the permission bits of a file */
  113. int (*chmod) (const char *, mode_t);
  114. int (*fchmod)(const fuse_file_info_t *, const mode_t);
  115. /** Change the owner and group of a file */
  116. int (*chown) (const char *, uid_t, gid_t);
  117. int (*fchown)(const fuse_file_info_t *, const uid_t, const gid_t);
  118. /** Change the size of a file */
  119. int (*truncate) (const char *, off_t);
  120. /** File open operation
  121. *
  122. * No creation (O_CREAT, O_EXCL) and by default also no
  123. * truncation (O_TRUNC) flags will be passed to open(). If an
  124. * application specifies O_TRUNC, fuse first calls truncate()
  125. * and then open(). Only if 'atomic_o_trunc' has been
  126. * specified and kernel version is 2.6.24 or later, O_TRUNC is
  127. * passed on to open.
  128. *
  129. * Unless the 'default_permissions' mount option is given,
  130. * open should check if the operation is permitted for the
  131. * given flags. Optionally open may also return an arbitrary
  132. * filehandle in the fuse_file_info structure, which will be
  133. * passed to all file operations.
  134. *
  135. * Changed in version 2.2
  136. */
  137. int (*open) (const char *, fuse_file_info_t *);
  138. /** Get file system statistics
  139. *
  140. * The 'f_frsize', 'f_favail', 'f_fsid' and 'f_flag' fields are ignored
  141. *
  142. * Replaced 'struct statfs' parameter with 'struct statvfs' in
  143. * version 2.5
  144. */
  145. int (*statfs) (const char *, struct statvfs *);
  146. /** Possibly flush cached data
  147. *
  148. * BIG NOTE: This is not equivalent to fsync(). It's not a
  149. * request to sync dirty data.
  150. *
  151. * Flush is called on each close() of a file descriptor. So if a
  152. * filesystem wants to return write errors in close() and the file
  153. * has cached dirty data, this is a good place to write back data
  154. * and return any errors. Since many applications ignore close()
  155. * errors this is not always useful.
  156. *
  157. * NOTE: The flush() method may be called more than once for each
  158. * open(). This happens if more than one file descriptor refers
  159. * to an opened file due to dup(), dup2() or fork() calls. It is
  160. * not possible to determine if a flush is final, so each flush
  161. * should be treated equally. Multiple write-flush sequences are
  162. * relatively rare, so this shouldn't be a problem.
  163. *
  164. * Filesystems shouldn't assume that flush will always be called
  165. * after some writes, or that if will be called at all.
  166. *
  167. * Changed in version 2.2
  168. */
  169. int (*flush) (const fuse_file_info_t *);
  170. /** Release an open file
  171. *
  172. * Release is called when there are no more references to an open
  173. * file: all file descriptors are closed and all memory mappings
  174. * are unmapped.
  175. *
  176. * For every open() call there will be exactly one release() call
  177. * with the same flags and file descriptor. It is possible to
  178. * have a file opened more than once, in which case only the last
  179. * release will mean, that no more reads/writes will happen on the
  180. * file. The return value of release is ignored.
  181. *
  182. * Changed in version 2.2
  183. */
  184. int (*release) (const fuse_file_info_t *);
  185. /** Synchronize file contents
  186. *
  187. * If the datasync parameter is non-zero, then only the user data
  188. * should be flushed, not the meta data.
  189. *
  190. * Changed in version 2.2
  191. */
  192. int (*fsync) (const fuse_file_info_t *, int);
  193. /** Set extended attributes */
  194. int (*setxattr) (const char *, const char *, const char *, size_t, int);
  195. /** Get extended attributes */
  196. int (*getxattr) (const char *, const char *, char *, size_t);
  197. /** List extended attributes */
  198. int (*listxattr) (const char *, char *, size_t);
  199. /** Remove extended attributes */
  200. int (*removexattr) (const char *, const char *);
  201. /** Open directory
  202. *
  203. * Unless the 'default_permissions' mount option is given,
  204. * this method should check if opendir is permitted for this
  205. * directory. Optionally opendir may also return an arbitrary
  206. * filehandle in the fuse_file_info structure, which will be
  207. * passed to readdir, closedir and fsyncdir.
  208. *
  209. * Introduced in version 2.3
  210. */
  211. int (*opendir) (const char *,
  212. fuse_file_info_t *);
  213. /** Read directory
  214. *
  215. * This supersedes the old getdir() interface. New applications
  216. * should use this.
  217. *
  218. * The filesystem may choose between two modes of operation:
  219. *
  220. * 1) The readdir implementation ignores the offset parameter, and
  221. * passes zero to the filler function's offset. The filler
  222. * function will not return '1' (unless an error happens), so the
  223. * whole directory is read in a single readdir operation. This
  224. * works just like the old getdir() method.
  225. *
  226. * 2) The readdir implementation keeps track of the offsets of the
  227. * directory entries. It uses the offset parameter and always
  228. * passes non-zero offset to the filler function. When the buffer
  229. * is full (or an error happens) the filler function will return
  230. * '1'.
  231. *
  232. * Introduced in version 2.3
  233. */
  234. int (*readdir)(const fuse_file_info_t *,
  235. fuse_dirents_t *);
  236. int (*readdir_plus)(const fuse_file_info_t *,
  237. fuse_dirents_t *);
  238. /** Release directory
  239. *
  240. * Introduced in version 2.3
  241. */
  242. int (*releasedir) (const fuse_file_info_t *);
  243. /** Synchronize directory contents
  244. *
  245. * If the datasync parameter is non-zero, then only the user data
  246. * should be flushed, not the meta data
  247. *
  248. * Introduced in version 2.3
  249. */
  250. int (*fsyncdir) (const fuse_file_info_t *, int);
  251. /**
  252. * Initialize filesystem
  253. *
  254. * The return value will passed in the private_data field of
  255. * fuse_context to all file operations and as a parameter to the
  256. * destroy() method.
  257. *
  258. * Introduced in version 2.3
  259. * Changed in version 2.6
  260. */
  261. void *(*init) (struct fuse_conn_info *conn);
  262. /**
  263. * Clean up filesystem
  264. *
  265. * Called on filesystem exit.
  266. *
  267. * Introduced in version 2.3
  268. */
  269. void (*destroy) (void);
  270. /**
  271. * Check file access permissions
  272. *
  273. * This will be called for the access() system call. If the
  274. * 'default_permissions' mount option is given, this method is not
  275. * called.
  276. *
  277. * This method is not called under Linux kernel versions 2.4.x
  278. *
  279. * Introduced in version 2.5
  280. */
  281. int (*access) (const char *, int);
  282. /**
  283. * Create and open a file
  284. *
  285. * If the file does not exist, first create it with the specified
  286. * mode, and then open it.
  287. *
  288. * If this method is not implemented or under Linux kernel
  289. * versions earlier than 2.6.15, the mknod() and open() methods
  290. * will be called instead.
  291. *
  292. * Introduced in version 2.5
  293. */
  294. int (*create) (const char *, mode_t, fuse_file_info_t *);
  295. /**
  296. * Change the size of an open file
  297. *
  298. * This method is called instead of the truncate() method if the
  299. * truncation was invoked from an ftruncate() system call.
  300. *
  301. * If this method is not implemented or under Linux kernel
  302. * versions earlier than 2.6.15, the truncate() method will be
  303. * called instead.
  304. *
  305. * Introduced in version 2.5
  306. */
  307. int (*ftruncate) (const fuse_file_info_t *, off_t);
  308. /**
  309. * Get attributes from an open file
  310. *
  311. * This method is called instead of the getattr() method if the
  312. * file information is available.
  313. *
  314. * Currently this is only called after the create() method if that
  315. * is implemented (see above). Later it may be called for
  316. * invocations of fstat() too.
  317. *
  318. * Introduced in version 2.5
  319. */
  320. int (*fgetattr) (const fuse_file_info_t *, struct stat *, fuse_timeouts_t *);
  321. /**
  322. * Perform POSIX file locking operation
  323. *
  324. * The cmd argument will be either F_GETLK, F_SETLK or F_SETLKW.
  325. *
  326. * For the meaning of fields in 'struct flock' see the man page
  327. * for fcntl(2). The l_whence field will always be set to
  328. * SEEK_SET.
  329. *
  330. * For checking lock ownership, the 'fuse_file_info->owner'
  331. * argument must be used.
  332. *
  333. * For F_GETLK operation, the library will first check currently
  334. * held locks, and if a conflicting lock is found it will return
  335. * information without calling this method. This ensures, that
  336. * for local locks the l_pid field is correctly filled in. The
  337. * results may not be accurate in case of race conditions and in
  338. * the presence of hard links, but it's unlikely that an
  339. * application would rely on accurate GETLK results in these
  340. * cases. If a conflicting lock is not found, this method will be
  341. * called, and the filesystem may fill out l_pid by a meaningful
  342. * value, or it may leave this field zero.
  343. *
  344. * For F_SETLK and F_SETLKW the l_pid field will be set to the pid
  345. * of the process performing the locking operation.
  346. *
  347. * Note: if this method is not implemented, the kernel will still
  348. * allow file locking to work locally. Hence it is only
  349. * interesting for network filesystems and similar.
  350. *
  351. * Introduced in version 2.6
  352. */
  353. int (*lock) (const fuse_file_info_t *,
  354. int cmd,
  355. struct flock *);
  356. /**
  357. * Change the access and modification times of a file with
  358. * nanosecond resolution
  359. *
  360. * This supersedes the old utime() interface. New applications
  361. * should use this.
  362. *
  363. * See the utimensat(2) man page for details.
  364. *
  365. * Introduced in version 2.6
  366. */
  367. int (*utimens)(const char *, const struct timespec tv[2]);
  368. int (*futimens)(const fuse_file_info_t *ffi_, const struct timespec tv_[2]);
  369. /**
  370. * Map block index within file to block index within device
  371. *
  372. * Note: This makes sense only for block device backed filesystems
  373. * mounted with the 'blkdev' option
  374. *
  375. * Introduced in version 2.6
  376. */
  377. int (*bmap) (const char *, size_t blocksize, uint64_t *idx);
  378. /**
  379. * Ioctl
  380. *
  381. * flags will have FUSE_IOCTL_COMPAT set for 32bit ioctls in
  382. * 64bit environment. The size and direction of data is
  383. * determined by _IOC_*() decoding of cmd. For _IOC_NONE,
  384. * data will be NULL, for _IOC_WRITE data is out area, for
  385. * _IOC_READ in area and if both are set in/out area. In all
  386. * non-NULL cases, the area is of _IOC_SIZE(cmd) bytes.
  387. *
  388. * If flags has FUSE_IOCTL_DIR then the fuse_file_info refers to a
  389. * directory file handle.
  390. *
  391. * Introduced in version 2.8
  392. */
  393. int (*ioctl) (const fuse_file_info_t *ffi,
  394. unsigned long cmd,
  395. void *arg,
  396. unsigned int flags,
  397. void *data,
  398. uint32_t *out_bufsz);
  399. /**
  400. * Poll for IO readiness events
  401. *
  402. * Note: If ph is non-NULL, the client should notify
  403. * when IO readiness events occur by calling
  404. * fuse_notify_poll() with the specified ph.
  405. *
  406. * Regardless of the number of times poll with a non-NULL ph
  407. * is received, single notification is enough to clear all.
  408. * Notifying more times incurs overhead but doesn't harm
  409. * correctness.
  410. *
  411. * The callee is responsible for destroying ph with
  412. * fuse_pollhandle_destroy() when no longer in use.
  413. *
  414. * Introduced in version 2.8
  415. */
  416. int (*poll) (const fuse_file_info_t *ffi,
  417. fuse_pollhandle_t *ph,
  418. unsigned *reventsp);
  419. /** Write contents of buffer to an open file
  420. *
  421. * Similar to the write() method, but data is supplied in a
  422. * generic buffer. Use fuse_buf_copy() to transfer data to
  423. * the destination.
  424. *
  425. * Introduced in version 2.9
  426. */
  427. int (*write_buf) (const fuse_file_info_t *ffi,
  428. struct fuse_bufvec *buf,
  429. off_t off);
  430. /** Store data from an open file in a buffer
  431. *
  432. * Similar to the read() method, but data is stored and
  433. * returned in a generic buffer.
  434. *
  435. * No actual copying of data has to take place, the source
  436. * file descriptor may simply be stored in the buffer for
  437. * later data transfer.
  438. *
  439. * The buffer must be allocated dynamically and stored at the
  440. * location pointed to by bufp. If the buffer contains memory
  441. * regions, they too must be allocated using malloc(). The
  442. * allocated memory will be freed by the caller.
  443. *
  444. * Introduced in version 2.9
  445. */
  446. int (*read_buf) (const fuse_file_info_t *ffi,
  447. struct fuse_bufvec **bufp,
  448. size_t size,
  449. off_t off);
  450. /**
  451. * Perform BSD file locking operation
  452. *
  453. * The op argument will be either LOCK_SH, LOCK_EX or LOCK_UN
  454. *
  455. * Nonblocking requests will be indicated by ORing LOCK_NB to
  456. * the above operations
  457. *
  458. * For more information see the flock(2) manual page.
  459. *
  460. * Additionally fi->owner will be set to a value unique to
  461. * this open file. This same value will be supplied to
  462. * ->release() when the file is released.
  463. *
  464. * Note: if this method is not implemented, the kernel will still
  465. * allow file locking to work locally. Hence it is only
  466. * interesting for network filesystems and similar.
  467. *
  468. * Introduced in version 2.9
  469. */
  470. int (*flock) (const fuse_file_info_t *, int op);
  471. /**
  472. * Allocates space for an open file
  473. *
  474. * This function ensures that required space is allocated for specified
  475. * file. If this function returns success then any subsequent write
  476. * request to specified range is guaranteed not to fail because of lack
  477. * of space on the file system media.
  478. *
  479. * Introduced in version 2.9.1
  480. */
  481. int (*fallocate) (const fuse_file_info_t *, int, off_t, off_t);
  482. /**
  483. * Copy a range of data from one file to another
  484. *
  485. * Performs an optimized copy between two file descriptors without
  486. * the additional cost of transferring data through the FUSE kernel
  487. * module to user space (glibc) and then back into the FUSE filesystem
  488. * again.
  489. *
  490. * In case this method is not implemented, glibc falls back to
  491. * reading data from the source and writing to the
  492. * destination. Effectively doing an inefficient copy of the
  493. * data.
  494. */
  495. ssize_t (*copy_file_range)(const fuse_file_info_t *fi_in,
  496. off_t offset_in,
  497. const fuse_file_info_t *fi_out,
  498. off_t offset_out,
  499. size_t size,
  500. int flags);
  501. };
  502. /** Extra context that may be needed by some filesystems
  503. *
  504. * The uid, gid and pid fields are not filled in case of a writepage
  505. * operation.
  506. */
  507. struct fuse_context
  508. {
  509. /** Pointer to the fuse object */
  510. struct fuse *fuse;
  511. /** User ID of the calling process */
  512. uid_t uid;
  513. /** Group ID of the calling process */
  514. gid_t gid;
  515. /** Thread ID of the calling process */
  516. pid_t pid;
  517. /** Umask of the calling process (introduced in version 2.8) */
  518. mode_t umask;
  519. };
  520. /**
  521. * Main function of FUSE.
  522. *
  523. * This is for the lazy. This is all that has to be called from the
  524. * main() function.
  525. *
  526. * This function does the following:
  527. * - parses command line options (-d -s and -h)
  528. * - passes relevant mount options to the fuse_mount()
  529. * - installs signal handlers for INT, HUP, TERM and PIPE
  530. * - registers an exit handler to unmount the filesystem on program exit
  531. * - creates a fuse handle
  532. * - registers the operations
  533. * - calls either the single-threaded or the multi-threaded event loop
  534. *
  535. * Note: this is currently implemented as a macro.
  536. *
  537. * @param argc the argument counter passed to the main() function
  538. * @param argv the argument vector passed to the main() function
  539. * @param op the file system operation
  540. * @return 0 on success, nonzero on failure
  541. */
  542. /*
  543. int fuse_main(int argc, char *argv[], const struct fuse_operations *op);
  544. */
  545. #define fuse_main(argc, argv, op) \
  546. fuse_main_real(argc, argv, op, sizeof(*(op)))
  547. /* ----------------------------------------------------------- *
  548. * More detailed API *
  549. * ----------------------------------------------------------- */
  550. /**
  551. * Create a new FUSE filesystem.
  552. *
  553. * @param ch the communication channel
  554. * @param args argument vector
  555. * @param op the filesystem operations
  556. * @param op_size the size of the fuse_operations structure
  557. * @return the created FUSE handle
  558. */
  559. struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args,
  560. const struct fuse_operations *op, size_t op_size);
  561. /**
  562. * Destroy the FUSE handle.
  563. *
  564. * The communication channel attached to the handle is also destroyed.
  565. *
  566. * NOTE: This function does not unmount the filesystem. If this is
  567. * needed, call fuse_unmount() before calling this function.
  568. *
  569. * @param f the FUSE handle
  570. */
  571. void fuse_destroy(struct fuse *f);
  572. /**
  573. * Exit from event loop
  574. *
  575. * @param f the FUSE handle
  576. */
  577. void fuse_exit(struct fuse *f);
  578. int fuse_config_num_threads(const struct fuse *fuse_);
  579. /**
  580. * FUSE event loop with multiple threads
  581. *
  582. * Requests from the kernel are processed, and the appropriate
  583. * operations are called. Request are processed in parallel by
  584. * distributing them between multiple threads.
  585. *
  586. * Calling this function requires the pthreads library to be linked to
  587. * the application.
  588. *
  589. * @param f the FUSE handle
  590. * @return 0 if no error occurred, -1 otherwise
  591. */
  592. int fuse_loop_mt(struct fuse *f);
  593. /**
  594. * Get the current context
  595. *
  596. * The context is only valid for the duration of a filesystem
  597. * operation, and thus must not be stored and used later.
  598. *
  599. * @return the context
  600. */
  601. struct fuse_context *fuse_get_context(void);
  602. /**
  603. * Check if the current request has already been interrupted
  604. *
  605. * @return 1 if the request has been interrupted, 0 otherwise
  606. */
  607. int fuse_interrupted(void);
  608. /**
  609. * Obsolete, doesn't do anything
  610. *
  611. * @return -EINVAL
  612. */
  613. int fuse_invalidate(struct fuse *f, const char *path);
  614. /* Deprecated, don't use */
  615. int fuse_is_lib_option(const char *opt);
  616. /**
  617. * The real main function
  618. *
  619. * Do not call this directly, use fuse_main()
  620. */
  621. int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, size_t op_size);
  622. int fuse_start_maintenance_thread(struct fuse *fuse);
  623. void fuse_stop_maintenance_thread(struct fuse *fuse);
  624. /**
  625. * Iterate over cache removing stale entries
  626. * use in conjunction with "-oremember"
  627. *
  628. * NOTE: This is already done for the standard sessions
  629. *
  630. * @param fuse struct fuse pointer for fuse instance
  631. * @return the number of seconds until the next cleanup
  632. */
  633. int fuse_clean_cache(struct fuse *fuse);
  634. /*
  635. * Stacking API
  636. */
  637. /**
  638. * Fuse filesystem object
  639. *
  640. * This is opaque object represents a filesystem layer
  641. */
  642. struct fuse_fs;
  643. /*
  644. * These functions call the relevant filesystem operation, and return
  645. * the result.
  646. *
  647. * If the operation is not defined, they return -ENOSYS, with the
  648. * exception of fuse_fs_open, fuse_fs_release, fuse_fs_opendir,
  649. * fuse_fs_releasedir and fuse_fs_statfs, which return 0.
  650. */
  651. int fuse_fs_getattr(struct fuse_fs *fs,
  652. const char *path,
  653. struct stat *buf,
  654. fuse_timeouts_t *timeout);
  655. int fuse_fs_fgetattr(struct fuse_fs *fs,
  656. struct stat *buf,
  657. fuse_file_info_t *fi,
  658. fuse_timeouts_t *timeout);
  659. int fuse_fs_rename(struct fuse_fs *fs, const char *oldpath,
  660. const char *newpath);
  661. int fuse_fs_unlink(struct fuse_fs *fs, const char *path);
  662. int fuse_fs_rmdir(struct fuse_fs *fs, const char *path);
  663. int fuse_fs_symlink(struct fuse_fs *fs,
  664. const char *linkname,
  665. const char *path,
  666. struct stat *st,
  667. fuse_timeouts_t *timeouts);
  668. int fuse_fs_link(struct fuse_fs *fs,
  669. const char *oldpath,
  670. const char *newpath,
  671. struct stat *st,
  672. fuse_timeouts_t *timeouts);
  673. int fuse_fs_release(struct fuse_fs *fs,
  674. fuse_file_info_t *fi);
  675. int fuse_fs_open(struct fuse_fs *fs, const char *path,
  676. fuse_file_info_t *fi);
  677. int fuse_fs_read_buf(struct fuse_fs *fs,
  678. struct fuse_bufvec **bufp, size_t size, off_t off,
  679. fuse_file_info_t *fi);
  680. int fuse_fs_write_buf(struct fuse_fs *fs,
  681. struct fuse_bufvec *buf, off_t off,
  682. fuse_file_info_t *fi);
  683. int fuse_fs_fsync(struct fuse_fs *fs, int datasync,
  684. fuse_file_info_t *fi);
  685. int fuse_fs_flush(struct fuse_fs *fs,
  686. fuse_file_info_t *fi);
  687. int fuse_fs_statfs(struct fuse_fs *fs, const char *path, struct statvfs *buf);
  688. int fuse_fs_opendir(struct fuse_fs *fs, const char *path,
  689. fuse_file_info_t *fi);
  690. int fuse_fs_readdir(struct fuse_fs *fs,
  691. fuse_file_info_t *fi,
  692. fuse_dirents_t *buf);
  693. int fuse_fs_fsyncdir(struct fuse_fs *fs, int datasync,
  694. fuse_file_info_t *fi);
  695. int fuse_fs_releasedir(struct fuse_fs *fs,
  696. fuse_file_info_t *fi);
  697. int fuse_fs_create(struct fuse_fs *fs, const char *path, mode_t mode,
  698. fuse_file_info_t *fi);
  699. int fuse_fs_lock(struct fuse_fs *fs,
  700. fuse_file_info_t *fi, int cmd, struct flock *lock);
  701. int fuse_fs_flock(struct fuse_fs *fs,
  702. fuse_file_info_t *fi, int op);
  703. int fuse_fs_chmod(struct fuse_fs *fs, const char *path, mode_t mode);
  704. int fuse_fs_chown(struct fuse_fs *fs, const char *path, uid_t uid, gid_t gid);
  705. int fuse_fs_truncate(struct fuse_fs *fs, const char *path, off_t size);
  706. int fuse_fs_ftruncate(struct fuse_fs *fs, off_t size,
  707. fuse_file_info_t *fi);
  708. int fuse_fs_utimens(struct fuse_fs *fs, const char *path,
  709. const struct timespec tv[2]);
  710. int fuse_fs_access(struct fuse_fs *fs, const char *path, int mask);
  711. int fuse_fs_readlink(struct fuse_fs *fs, const char *path, char *buf,
  712. size_t len);
  713. int fuse_fs_mknod(struct fuse_fs *fs, const char *path, mode_t mode,
  714. dev_t rdev);
  715. int fuse_fs_mkdir(struct fuse_fs *fs, const char *path, mode_t mode);
  716. int fuse_fs_setxattr(struct fuse_fs *fs, const char *path, const char *name,
  717. const char *value, size_t size, int flags);
  718. int fuse_fs_getxattr(struct fuse_fs *fs, const char *path, const char *name,
  719. char *value, size_t size);
  720. int fuse_fs_listxattr(struct fuse_fs *fs, const char *path, char *list,
  721. size_t size);
  722. int fuse_fs_removexattr(struct fuse_fs *fs, const char *path,
  723. const char *name);
  724. int fuse_fs_bmap(struct fuse_fs *fs, const char *path, size_t blocksize,
  725. uint64_t *idx);
  726. int fuse_fs_ioctl(struct fuse_fs *fs, unsigned long cmd, void *arg,
  727. fuse_file_info_t *fi, unsigned int flags,
  728. void *data, uint32_t *out_bufsz);
  729. int fuse_fs_poll(struct fuse_fs *fs,
  730. fuse_file_info_t *fi, fuse_pollhandle_t *ph,
  731. unsigned *reventsp);
  732. int fuse_fs_fallocate(struct fuse_fs *fs, int mode,
  733. off_t offset, off_t length, fuse_file_info_t *fi);
  734. void fuse_fs_init(struct fuse_fs *fs, struct fuse_conn_info *conn);
  735. void fuse_fs_destroy(struct fuse_fs *fs);
  736. int fuse_fs_prepare_hide(struct fuse_fs *fs, const char *path, uint64_t *fh);
  737. int fuse_fs_free_hide(struct fuse_fs *fs, uint64_t fh);
  738. ssize_t fuse_fs_copy_file_range(struct fuse_fs *fs,
  739. fuse_file_info_t *fi_in, off_t off_in,
  740. fuse_file_info_t *fi_out, off_t off_out,
  741. size_t len, int flags);
  742. int fuse_notify_poll(fuse_pollhandle_t *ph);
  743. /**
  744. * Create a new fuse filesystem object
  745. *
  746. * This is usually called from the factory of a fuse module to create
  747. * a new instance of a filesystem.
  748. *
  749. * @param op the filesystem operations
  750. * @param op_size the size of the fuse_operations structure
  751. * @return a new filesystem object
  752. */
  753. struct fuse_fs *fuse_fs_new(const struct fuse_operations *op, size_t op_size);
  754. /* ----------------------------------------------------------- *
  755. * Advanced API for event handling, don't worry about this... *
  756. * ----------------------------------------------------------- */
  757. /* NOTE: the following functions are deprecated, and will be removed
  758. from the 3.0 API. Use the lowlevel session functions instead */
  759. /** Function type used to process commands */
  760. typedef void (*fuse_processor_t)(struct fuse *, struct fuse_cmd *, void *);
  761. /** This is the part of fuse_main() before the event loop */
  762. struct fuse *fuse_setup(int argc, char *argv[],
  763. const struct fuse_operations *op, size_t op_size,
  764. char **mountpoint);
  765. /** This is the part of fuse_main() after the event loop */
  766. void fuse_teardown(struct fuse *fuse, char *mountpoint);
  767. /** Read a single command. If none are read, return NULL */
  768. struct fuse_cmd *fuse_read_cmd(struct fuse *f);
  769. /** Process a single command */
  770. void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd);
  771. /** Multi threaded event loop, which calls the custom command
  772. processor function */
  773. int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data);
  774. /** Return the exited flag, which indicates if fuse_exit() has been
  775. called */
  776. int fuse_exited(struct fuse *f);
  777. /** This function is obsolete and implemented as a no-op */
  778. void fuse_set_getcontext_func(struct fuse_context *(*func)(void));
  779. /** Get session from fuse object */
  780. struct fuse_session *fuse_get_session(struct fuse *f);
  781. EXTERN_C_END
  782. #endif /* _FUSE_H_ */