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.

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