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.

1573 lines
46 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_LOWLEVEL_H_
  8. #define _FUSE_LOWLEVEL_H_
  9. /** @file
  10. *
  11. * Low level API
  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 24 (default) or
  16. * 25
  17. */
  18. #ifndef FUSE_USE_VERSION
  19. #define FUSE_USE_VERSION 24
  20. #endif
  21. #include "extern_c.h"
  22. #include "fuse_common.h"
  23. #include <fcntl.h>
  24. #include <stdint.h>
  25. #include <sys/stat.h>
  26. #include <sys/statvfs.h>
  27. #include <sys/types.h>
  28. #include <sys/uio.h>
  29. #include <utime.h>
  30. EXTERN_C_BEGIN
  31. /* ----------------------------------------------------------- *
  32. * Miscellaneous definitions *
  33. * ----------------------------------------------------------- */
  34. /** The node ID of the root inode */
  35. #define FUSE_ROOT_ID 1
  36. /** Request pointer type */
  37. typedef struct fuse_req *fuse_req_t;
  38. /**
  39. * Session
  40. *
  41. * This provides hooks for processing requests, and exiting
  42. */
  43. struct fuse_session;
  44. /**
  45. * Channel
  46. *
  47. * A communication channel, providing hooks for sending and receiving
  48. * messages
  49. */
  50. struct fuse_chan;
  51. /** Directory entry parameters supplied to fuse_reply_entry() */
  52. struct fuse_entry_param
  53. {
  54. /** Unique inode number
  55. *
  56. * In lookup, zero means negative entry (from version 2.5)
  57. * Returning ENOENT also means negative entry, but by setting zero
  58. * ino the kernel may cache negative entries for entry_timeout
  59. * seconds.
  60. */
  61. uint64_t ino;
  62. /** Generation number for this entry.
  63. *
  64. * If the file system will be exported over NFS, the
  65. * ino/generation pairs need to be unique over the file
  66. * system's lifetime (rather than just the mount time). So if
  67. * the file system reuses an inode after it has been deleted,
  68. * it must assign a new, previously unused generation number
  69. * to the inode at the same time.
  70. *
  71. * The generation must be non-zero, otherwise FUSE will treat
  72. * it as an error.
  73. *
  74. */
  75. uint64_t generation;
  76. /** Inode attributes.
  77. *
  78. * Even if attr_timeout == 0, attr must be correct. For example,
  79. * for open(), FUSE uses attr.st_size from lookup() to determine
  80. * how many bytes to request. If this value is not correct,
  81. * incorrect data will be returned.
  82. */
  83. struct stat attr;
  84. fuse_timeouts_t timeout;
  85. };
  86. /** Additional context associated with requests */
  87. struct fuse_ctx
  88. {
  89. /** User ID of the calling process */
  90. uid_t uid;
  91. /** Group ID of the calling process */
  92. gid_t gid;
  93. /** Thread ID of the calling process */
  94. pid_t pid;
  95. /** Umask of the calling process (introduced in version 2.8) */
  96. mode_t umask;
  97. };
  98. struct fuse_forget_data
  99. {
  100. uint64_t ino;
  101. uint64_t nlookup;
  102. };
  103. /* ----------------------------------------------------------- *
  104. * Request methods and replies *
  105. * ----------------------------------------------------------- */
  106. /**
  107. * Low level filesystem operations
  108. *
  109. * Most of the methods (with the exception of init and destroy)
  110. * receive a request handle (fuse_req_t) as their first argument.
  111. * This handle must be passed to one of the specified reply functions.
  112. *
  113. * This may be done inside the method invocation, or after the call
  114. * has returned. The request handle is valid until one of the reply
  115. * functions is called.
  116. *
  117. * Other pointer arguments (name, fuse_file_info, etc) are not valid
  118. * after the call has returned, so if they are needed later, their
  119. * contents have to be copied.
  120. *
  121. * The filesystem sometimes needs to handle a return value of -ENOENT
  122. * from the reply function, which means, that the request was
  123. * interrupted, and the reply discarded. For example if
  124. * fuse_reply_open() return -ENOENT means, that the release method for
  125. * this file will not be called.
  126. */
  127. struct fuse_lowlevel_ops
  128. {
  129. /**
  130. * Initialize filesystem
  131. *
  132. * Called before any other filesystem method
  133. *
  134. * There's no reply to this function
  135. *
  136. * @param userdata the user data passed to fuse_lowlevel_new()
  137. */
  138. void (*init)(void *userdata, struct fuse_conn_info *conn);
  139. /**
  140. * Clean up filesystem
  141. *
  142. * Called on filesystem exit
  143. *
  144. * There's no reply to this function
  145. *
  146. * @param userdata the user data passed to fuse_lowlevel_new()
  147. */
  148. void (*destroy)(void *userdata);
  149. /**
  150. * Look up a directory entry by name and get its attributes.
  151. *
  152. * Valid replies:
  153. * fuse_reply_entry
  154. * fuse_reply_err
  155. *
  156. * @param req request handle
  157. * @param parent inode number of the parent directory
  158. * @param name the name to look up
  159. */
  160. void (*lookup)(fuse_req_t req, uint64_t parent, const char *name);
  161. /**
  162. * Forget about an inode
  163. *
  164. * This function is called when the kernel removes an inode
  165. * from its internal caches.
  166. *
  167. * The inode's lookup count increases by one for every call to
  168. * fuse_reply_entry and fuse_reply_create. The nlookup parameter
  169. * indicates by how much the lookup count should be decreased.
  170. *
  171. * Inodes with a non-zero lookup count may receive request from
  172. * the kernel even after calls to unlink, rmdir or (when
  173. * overwriting an existing file) rename. Filesystems must handle
  174. * such requests properly and it is recommended to defer removal
  175. * of the inode until the lookup count reaches zero. Calls to
  176. * unlink, remdir or rename will be followed closely by forget
  177. * unless the file or directory is open, in which case the
  178. * kernel issues forget only after the release or releasedir
  179. * calls.
  180. *
  181. * Note that if a file system will be exported over NFS the
  182. * inodes lifetime must extend even beyond forget. See the
  183. * generation field in struct fuse_entry_param above.
  184. *
  185. * On unmount the lookup count for all inodes implicitly drops
  186. * to zero. It is not guaranteed that the file system will
  187. * receive corresponding forget messages for the affected
  188. * inodes.
  189. *
  190. * Valid replies:
  191. * fuse_reply_none
  192. *
  193. * @param req request handle
  194. * @param ino the inode number
  195. * @param nlookup the number of lookups to forget
  196. */
  197. void (*forget)(fuse_req_t req, uint64_t ino, uint64_t nlookup);
  198. /**
  199. * Get file attributes
  200. *
  201. * Valid replies:
  202. * fuse_reply_attr
  203. * fuse_reply_err
  204. *
  205. * @param req request handle
  206. * @param ino the inode number
  207. * @param fi for future use, currently always NULL
  208. */
  209. void (*getattr)(fuse_req_t req, uint64_t ino, fuse_file_info_t *fi);
  210. /**
  211. * Set file attributes
  212. *
  213. * In the 'attr' argument only members indicated by the 'to_set'
  214. * bitmask contain valid values. Other members contain undefined
  215. * values.
  216. *
  217. * If the setattr was invoked from the ftruncate() system call
  218. * under Linux kernel versions 2.6.15 or later, the fi->fh will
  219. * contain the value set by the open method or will be undefined
  220. * if the open method didn't set any value. Otherwise (not
  221. * ftruncate call, or kernel version earlier than 2.6.15) the fi
  222. * parameter will be NULL.
  223. *
  224. * Valid replies:
  225. * fuse_reply_attr
  226. * fuse_reply_err
  227. *
  228. * @param req request handle
  229. * @param ino the inode number
  230. * @param attr the attributes
  231. * @param to_set bit mask of attributes which should be set
  232. * @param fi file information, or NULL
  233. *
  234. * Changed in version 2.5:
  235. * file information filled in for ftruncate
  236. */
  237. void (*setattr)(fuse_req_t req, uint64_t ino, struct stat *attr,
  238. int to_set, fuse_file_info_t *fi);
  239. /**
  240. * Read symbolic link
  241. *
  242. * Valid replies:
  243. * fuse_reply_readlink
  244. * fuse_reply_err
  245. *
  246. * @param req request handle
  247. * @param ino the inode number
  248. */
  249. void (*readlink)(fuse_req_t req, uint64_t ino);
  250. /**
  251. * Create file node
  252. *
  253. * Create a regular file, character device, block device, fifo or
  254. * socket node.
  255. *
  256. * Valid replies:
  257. * fuse_reply_entry
  258. * fuse_reply_err
  259. *
  260. * @param req request handle
  261. * @param parent inode number of the parent directory
  262. * @param name to create
  263. * @param mode file type and mode with which to create the new file
  264. * @param rdev the device number (only valid if created file is a device)
  265. */
  266. void (*mknod)(fuse_req_t req, uint64_t parent, const char *name,
  267. mode_t mode, dev_t rdev);
  268. /**
  269. * Create a directory
  270. *
  271. * Valid replies:
  272. * fuse_reply_entry
  273. * fuse_reply_err
  274. *
  275. * @param req request handle
  276. * @param parent inode number of the parent directory
  277. * @param name to create
  278. * @param mode with which to create the new file
  279. */
  280. void (*mkdir)(fuse_req_t req, uint64_t parent, const char *name,
  281. mode_t mode);
  282. /**
  283. * Remove a file
  284. *
  285. * If the file's inode's lookup count is non-zero, the file
  286. * system is expected to postpone any removal of the inode
  287. * until the lookup count reaches zero (see description of the
  288. * forget function).
  289. *
  290. * Valid replies:
  291. * fuse_reply_err
  292. *
  293. * @param req request handle
  294. * @param parent inode number of the parent directory
  295. * @param name to remove
  296. */
  297. void (*unlink)(fuse_req_t req, uint64_t parent, const char *name);
  298. /**
  299. * Remove a directory
  300. *
  301. * If the directory's inode's lookup count is non-zero, the
  302. * file system is expected to postpone any removal of the
  303. * inode until the lookup count reaches zero (see description
  304. * of the forget function).
  305. *
  306. * Valid replies:
  307. * fuse_reply_err
  308. *
  309. * @param req request handle
  310. * @param parent inode number of the parent directory
  311. * @param name to remove
  312. */
  313. void (*rmdir)(fuse_req_t req, uint64_t parent, const char *name);
  314. /**
  315. * Create a symbolic link
  316. *
  317. * Valid replies:
  318. * fuse_reply_entry
  319. * fuse_reply_err
  320. *
  321. * @param req request handle
  322. * @param link the contents of the symbolic link
  323. * @param parent inode number of the parent directory
  324. * @param name to create
  325. */
  326. void (*symlink)(fuse_req_t req, const char *link, uint64_t parent,
  327. const char *name);
  328. /** Rename a file
  329. *
  330. * If the target exists it should be atomically replaced. If
  331. * the target's inode's lookup count is non-zero, the file
  332. * system is expected to postpone any removal of the inode
  333. * until the lookup count reaches zero (see description of the
  334. * forget function).
  335. *
  336. * Valid replies:
  337. * fuse_reply_err
  338. *
  339. * @param req request handle
  340. * @param parent inode number of the old parent directory
  341. * @param name old name
  342. * @param newparent inode number of the new parent directory
  343. * @param newname new name
  344. */
  345. void (*rename)(fuse_req_t req, uint64_t parent, const char *name,
  346. uint64_t newparent, const char *newname);
  347. /**
  348. * Create a hard link
  349. *
  350. * Valid replies:
  351. * fuse_reply_entry
  352. * fuse_reply_err
  353. *
  354. * @param req request handle
  355. * @param ino the old inode number
  356. * @param newparent inode number of the new parent directory
  357. * @param newname new name to create
  358. */
  359. void (*link)(fuse_req_t req, uint64_t ino, uint64_t newparent,
  360. const char *newname);
  361. /**
  362. * Open a file
  363. *
  364. * Open flags (with the exception of O_CREAT, O_EXCL, O_NOCTTY and
  365. * O_TRUNC) are available in fi->flags.
  366. *
  367. * Filesystem may store an arbitrary file handle (pointer, index,
  368. * etc) in fi->fh, and use this in other all other file operations
  369. * (read, write, flush, release, fsync).
  370. *
  371. * Filesystem may also implement stateless file I/O and not store
  372. * anything in fi->fh.
  373. *
  374. * There are also some flags (direct_io, keep_cache) which the
  375. * filesystem may set in fi, to change the way the file is opened.
  376. * See fuse_file_info structure in <fuse_common.h> for more details.
  377. *
  378. * Valid replies:
  379. * fuse_reply_open
  380. * fuse_reply_err
  381. *
  382. * @param req request handle
  383. * @param ino the inode number
  384. * @param fi file information
  385. */
  386. void (*open)(fuse_req_t req, uint64_t ino,
  387. fuse_file_info_t *fi);
  388. /**
  389. * Read data
  390. *
  391. * Read should send exactly the number of bytes requested except
  392. * on EOF or error, otherwise the rest of the data will be
  393. * substituted with zeroes. An exception to this is when the file
  394. * has been opened in 'direct_io' mode, in which case the return
  395. * value of the read system call will reflect the return value of
  396. * this operation.
  397. *
  398. * fi->fh will contain the value set by the open method, or will
  399. * be undefined if the open method didn't set any value.
  400. *
  401. * Valid replies:
  402. * fuse_reply_buf
  403. * fuse_reply_iov
  404. * fuse_reply_data
  405. * fuse_reply_err
  406. *
  407. * @param req request handle
  408. * @param ino the inode number
  409. * @param size number of bytes to read
  410. * @param off offset to read from
  411. * @param fi file information
  412. */
  413. void (*read)(fuse_req_t req, uint64_t ino, size_t size, off_t off,
  414. fuse_file_info_t *fi);
  415. /**
  416. * Write data
  417. *
  418. * Write should return exactly the number of bytes requested
  419. * except on error. An exception to this is when the file has
  420. * been opened in 'direct_io' mode, in which case the return value
  421. * of the write system call will reflect the return value of this
  422. * operation.
  423. *
  424. * fi->fh will contain the value set by the open method, or will
  425. * be undefined if the open method didn't set any value.
  426. *
  427. * Valid replies:
  428. * fuse_reply_write
  429. * fuse_reply_err
  430. *
  431. * @param req request handle
  432. * @param ino the inode number
  433. * @param buf data to write
  434. * @param size number of bytes to write
  435. * @param off offset to write to
  436. * @param fi file information
  437. */
  438. void (*write)(fuse_req_t req, uint64_t ino, const char *buf,
  439. size_t size, off_t off, fuse_file_info_t *fi);
  440. /**
  441. * Flush method
  442. *
  443. * This is called on each close() of the opened file.
  444. *
  445. * Since file descriptors can be duplicated (dup, dup2, fork), for
  446. * one open call there may be many flush calls.
  447. *
  448. * Filesystems shouldn't assume that flush will always be called
  449. * after some writes, or that if will be called at all.
  450. *
  451. * fi->fh will contain the value set by the open method, or will
  452. * be undefined if the open method didn't set any value.
  453. *
  454. * NOTE: the name of the method is misleading, since (unlike
  455. * fsync) the filesystem is not forced to flush pending writes.
  456. * One reason to flush data, is if the filesystem wants to return
  457. * write errors.
  458. *
  459. * If the filesystem supports file locking operations (setlk,
  460. * getlk) it should remove all locks belonging to 'fi->owner'.
  461. *
  462. * Valid replies:
  463. * fuse_reply_err
  464. *
  465. * @param req request handle
  466. * @param ino the inode number
  467. * @param fi file information
  468. */
  469. void (*flush)(fuse_req_t req, uint64_t ino,
  470. fuse_file_info_t *fi);
  471. /**
  472. * Release an open file
  473. *
  474. * Release is called when there are no more references to an open
  475. * file: all file descriptors are closed and all memory mappings
  476. * are unmapped.
  477. *
  478. * For every open call there will be exactly one release call.
  479. *
  480. * The filesystem may reply with an error, but error values are
  481. * not returned to close() or munmap() which triggered the
  482. * release.
  483. *
  484. * fi->fh will contain the value set by the open method, or will
  485. * be undefined if the open method didn't set any value.
  486. * fi->flags will contain the same flags as for open.
  487. *
  488. * Valid replies:
  489. * fuse_reply_err
  490. *
  491. * @param req request handle
  492. * @param ino the inode number
  493. * @param fi file information
  494. */
  495. void (*release)(fuse_req_t req, uint64_t ino,
  496. fuse_file_info_t *fi);
  497. /**
  498. * Synchronize file contents
  499. *
  500. * If the datasync parameter is non-zero, then only the user data
  501. * should be flushed, not the meta data.
  502. *
  503. * Valid replies:
  504. * fuse_reply_err
  505. *
  506. * @param req request handle
  507. * @param ino the inode number
  508. * @param datasync flag indicating if only data should be flushed
  509. * @param fi file information
  510. */
  511. void (*fsync)(fuse_req_t req, uint64_t ino, int datasync,
  512. fuse_file_info_t *fi);
  513. /**
  514. * Open a directory
  515. *
  516. * Filesystem may store an arbitrary file handle (pointer, index,
  517. * etc) in fi->fh, and use this in other all other directory
  518. * stream operations (readdir, releasedir, fsyncdir).
  519. *
  520. * Filesystem may also implement stateless directory I/O and not
  521. * store anything in fi->fh, though that makes it impossible to
  522. * implement standard conforming directory stream operations in
  523. * case the contents of the directory can change between opendir
  524. * and releasedir.
  525. *
  526. * Valid replies:
  527. * fuse_reply_open
  528. * fuse_reply_err
  529. *
  530. * @param req request handle
  531. * @param ino the inode number
  532. * @param fi file information
  533. */
  534. void (*opendir)(fuse_req_t req, uint64_t ino,
  535. fuse_file_info_t *fi);
  536. /**
  537. * Read directory
  538. *
  539. * Send a buffer filled using fuse_add_direntry(), with size not
  540. * exceeding the requested size. Send an empty buffer on end of
  541. * stream.
  542. *
  543. * fi->fh will contain the value set by the opendir method, or
  544. * will be undefined if the opendir method didn't set any value.
  545. *
  546. * Valid replies:
  547. * fuse_reply_buf
  548. * fuse_reply_data
  549. * fuse_reply_err
  550. *
  551. * @param req request handle
  552. * @param ino the inode number
  553. * @param size maximum number of bytes to send
  554. * @param off offset to continue reading the directory stream
  555. * @param fi file information
  556. */
  557. void (*readdir)(fuse_req_t req, uint64_t ino, size_t size, off_t off,
  558. fuse_file_info_t *llffi);
  559. void (*readdir_plus)(fuse_req_t req, uint64_t ino,
  560. size_t size, off_t off,
  561. fuse_file_info_t *ffi);
  562. /**
  563. * Release an open directory
  564. *
  565. * For every opendir call there will be exactly one releasedir
  566. * call.
  567. *
  568. * fi->fh will contain the value set by the opendir method, or
  569. * will be undefined if the opendir method didn't set any value.
  570. *
  571. * Valid replies:
  572. * fuse_reply_err
  573. *
  574. * @param req request handle
  575. * @param ino the inode number
  576. * @param fi file information
  577. */
  578. void (*releasedir)(fuse_req_t req, uint64_t ino,
  579. fuse_file_info_t *fi);
  580. /**
  581. * Synchronize directory contents
  582. *
  583. * If the datasync parameter is non-zero, then only the directory
  584. * contents should be flushed, not the meta data.
  585. *
  586. * fi->fh will contain the value set by the opendir method, or
  587. * will be undefined if the opendir method didn't set any value.
  588. *
  589. * Valid replies:
  590. * fuse_reply_err
  591. *
  592. * @param req request handle
  593. * @param ino the inode number
  594. * @param datasync flag indicating if only data should be flushed
  595. * @param fi file information
  596. */
  597. void (*fsyncdir)(fuse_req_t req, uint64_t ino, int datasync,
  598. fuse_file_info_t *fi);
  599. /**
  600. * Get file system statistics
  601. *
  602. * Valid replies:
  603. * fuse_reply_statfs
  604. * fuse_reply_err
  605. *
  606. * @param req request handle
  607. * @param ino the inode number, zero means "undefined"
  608. */
  609. void (*statfs)(fuse_req_t req, uint64_t ino);
  610. /**
  611. * Set an extended attribute
  612. *
  613. * Valid replies:
  614. * fuse_reply_err
  615. */
  616. void (*setxattr)(fuse_req_t req, uint64_t ino, const char *name,
  617. const char *value, size_t size, int flags);
  618. /**
  619. * Get an extended attribute
  620. *
  621. * If size is zero, the size of the value should be sent with
  622. * fuse_reply_xattr.
  623. *
  624. * If the size is non-zero, and the value fits in the buffer, the
  625. * value should be sent with fuse_reply_buf.
  626. *
  627. * If the size is too small for the value, the ERANGE error should
  628. * be sent.
  629. *
  630. * Valid replies:
  631. * fuse_reply_buf
  632. * fuse_reply_data
  633. * fuse_reply_xattr
  634. * fuse_reply_err
  635. *
  636. * @param req request handle
  637. * @param ino the inode number
  638. * @param name of the extended attribute
  639. * @param size maximum size of the value to send
  640. */
  641. void (*getxattr)(fuse_req_t req, uint64_t ino, const char *name,
  642. size_t size);
  643. /**
  644. * List extended attribute names
  645. *
  646. * If size is zero, the total size of the attribute list should be
  647. * sent with fuse_reply_xattr.
  648. *
  649. * If the size is non-zero, and the null character separated
  650. * attribute list fits in the buffer, the list should be sent with
  651. * fuse_reply_buf.
  652. *
  653. * If the size is too small for the list, the ERANGE error should
  654. * be sent.
  655. *
  656. * Valid replies:
  657. * fuse_reply_buf
  658. * fuse_reply_data
  659. * fuse_reply_xattr
  660. * fuse_reply_err
  661. *
  662. * @param req request handle
  663. * @param ino the inode number
  664. * @param size maximum size of the list to send
  665. */
  666. void (*listxattr)(fuse_req_t req, uint64_t ino, size_t size);
  667. /**
  668. * Remove an extended attribute
  669. *
  670. * Valid replies:
  671. * fuse_reply_err
  672. *
  673. * @param req request handle
  674. * @param ino the inode number
  675. * @param name of the extended attribute
  676. */
  677. void (*removexattr)(fuse_req_t req, uint64_t ino, const char *name);
  678. /**
  679. * Check file access permissions
  680. *
  681. * This will be called for the access() system call. If the
  682. * 'default_permissions' mount option is given, this method is not
  683. * called.
  684. *
  685. * This method is not called under Linux kernel versions 2.4.x
  686. *
  687. * Introduced in version 2.5
  688. *
  689. * Valid replies:
  690. * fuse_reply_err
  691. *
  692. * @param req request handle
  693. * @param ino the inode number
  694. * @param mask requested access mode
  695. */
  696. void (*access)(fuse_req_t req, uint64_t ino, int mask);
  697. /**
  698. * Create and open a file
  699. *
  700. * If the file does not exist, first create it with the specified
  701. * mode, and then open it.
  702. *
  703. * Open flags (with the exception of O_NOCTTY) are available in
  704. * fi->flags.
  705. *
  706. * Filesystem may store an arbitrary file handle (pointer, index,
  707. * etc) in fi->fh, and use this in other all other file operations
  708. * (read, write, flush, release, fsync).
  709. *
  710. * There are also some flags (direct_io, keep_cache) which the
  711. * filesystem may set in fi, to change the way the file is opened.
  712. * See fuse_file_info structure in <fuse_common.h> for more details.
  713. *
  714. * If this method is not implemented or under Linux kernel
  715. * versions earlier than 2.6.15, the mknod() and open() methods
  716. * will be called instead.
  717. *
  718. * Introduced in version 2.5
  719. *
  720. * Valid replies:
  721. * fuse_reply_create
  722. * fuse_reply_err
  723. *
  724. * @param req request handle
  725. * @param parent inode number of the parent directory
  726. * @param name to create
  727. * @param mode file type and mode with which to create the new file
  728. * @param fi file information
  729. */
  730. void (*create)(fuse_req_t req, uint64_t parent, const char *name,
  731. mode_t mode, fuse_file_info_t *fi);
  732. /**
  733. * Test for a POSIX file lock
  734. *
  735. * Introduced in version 2.6
  736. *
  737. * Valid replies:
  738. * fuse_reply_lock
  739. * fuse_reply_err
  740. *
  741. * @param req request handle
  742. * @param ino the inode number
  743. * @param fi file information
  744. * @param lock the region/type to test
  745. */
  746. void (*getlk)(fuse_req_t req, uint64_t ino,
  747. fuse_file_info_t *fi, struct flock *lock);
  748. /**
  749. * Acquire, modify or release a POSIX file lock
  750. *
  751. * For POSIX threads (NPTL) there's a 1-1 relation between pid and
  752. * owner, but otherwise this is not always the case. For checking
  753. * lock ownership, 'fi->owner' must be used. The l_pid field in
  754. * 'struct flock' should only be used to fill in this field in
  755. * getlk().
  756. *
  757. * Note: if the locking methods are not implemented, the kernel
  758. * will still allow file locking to work locally. Hence these are
  759. * only interesting for network filesystems and similar.
  760. *
  761. * Introduced in version 2.6
  762. *
  763. * Valid replies:
  764. * fuse_reply_err
  765. *
  766. * @param req request handle
  767. * @param ino the inode number
  768. * @param fi file information
  769. * @param lock the region/type to set
  770. * @param sleep locking operation may sleep
  771. */
  772. void (*setlk)(fuse_req_t req, uint64_t ino,
  773. fuse_file_info_t *fi,
  774. struct flock *lock, int sleep);
  775. /**
  776. * Map block index within file to block index within device
  777. *
  778. * Note: This makes sense only for block device backed filesystems
  779. * mounted with the 'blkdev' option
  780. *
  781. * Introduced in version 2.6
  782. *
  783. * Valid replies:
  784. * fuse_reply_bmap
  785. * fuse_reply_err
  786. *
  787. * @param req request handle
  788. * @param ino the inode number
  789. * @param blocksize unit of block index
  790. * @param idx block index within file
  791. */
  792. void (*bmap)(fuse_req_t req, uint64_t ino, size_t blocksize,
  793. uint64_t idx);
  794. /**
  795. * Ioctl
  796. *
  797. * Note: For unrestricted ioctls (not allowed for FUSE
  798. * servers), data in and out areas can be discovered by giving
  799. * iovs and setting FUSE_IOCTL_RETRY in @flags. For
  800. * restricted ioctls, kernel prepares in/out data area
  801. * according to the information encoded in cmd.
  802. *
  803. * Introduced in version 2.8
  804. *
  805. * Valid replies:
  806. * fuse_reply_ioctl_retry
  807. * fuse_reply_ioctl
  808. * fuse_reply_ioctl_iov
  809. * fuse_reply_err
  810. *
  811. * @param req request handle
  812. * @param ino the inode number
  813. * @param cmd ioctl command
  814. * @param arg ioctl argument
  815. * @param fi file information
  816. * @param flags for FUSE_IOCTL_* flags
  817. * @param in_buf data fetched from the caller
  818. * @param in_bufsz number of fetched bytes
  819. * @param out_bufsz maximum size of output data
  820. */
  821. void (*ioctl)(fuse_req_t req, uint64_t ino, unsigned long cmd, void *arg,
  822. fuse_file_info_t *fi, unsigned flags,
  823. const void *in_buf, uint32_t in_bufsz, uint32_t out_bufsz);
  824. /**
  825. * Poll for IO readiness
  826. *
  827. * Introduced in version 2.8
  828. *
  829. * Note: If ph is non-NULL, the client should notify
  830. * when IO readiness events occur by calling
  831. * fuse_lowelevel_notify_poll() with the specified ph.
  832. *
  833. * Regardless of the number of times poll with a non-NULL ph
  834. * is received, single notification is enough to clear all.
  835. * Notifying more times incurs overhead but doesn't harm
  836. * correctness.
  837. *
  838. * The callee is responsible for destroying ph with
  839. * fuse_pollhandle_destroy() when no longer in use.
  840. *
  841. * Valid replies:
  842. * fuse_reply_poll
  843. * fuse_reply_err
  844. *
  845. * @param req request handle
  846. * @param ino the inode number
  847. * @param fi file information
  848. * @param ph poll handle to be used for notification
  849. */
  850. void (*poll)(fuse_req_t req,
  851. uint64_t ino,
  852. fuse_file_info_t *fi,
  853. fuse_pollhandle_t *ph);
  854. /**
  855. * Write data made available in a buffer
  856. *
  857. * This is a more generic version of the ->write() method. If
  858. * FUSE_CAP_SPLICE_READ is set in fuse_conn_info.want and the
  859. * kernel supports splicing from the fuse device, then the
  860. * data will be made available in pipe for supporting zero
  861. * copy data transfer.
  862. *
  863. * buf->count is guaranteed to be one (and thus buf->idx is
  864. * always zero). The write_buf handler must ensure that
  865. * bufv->off is correctly updated (reflecting the number of
  866. * bytes read from bufv->buf[0]).
  867. *
  868. * Introduced in version 2.9
  869. *
  870. * Valid replies:
  871. * fuse_reply_write
  872. * fuse_reply_err
  873. *
  874. * @param req request handle
  875. * @param ino the inode number
  876. * @param bufv buffer containing the data
  877. * @param off offset to write to
  878. * @param fi file information
  879. */
  880. void (*write_buf)(fuse_req_t req, uint64_t ino,
  881. struct fuse_bufvec *bufv, off_t off,
  882. fuse_file_info_t *fi);
  883. /**
  884. * Callback function for the retrieve request
  885. *
  886. * Introduced in version 2.9
  887. *
  888. * Valid replies:
  889. * fuse_reply_none
  890. *
  891. * @param req request handle
  892. * @param cookie user data supplied to fuse_lowlevel_notify_retrieve()
  893. * @param ino the inode number supplied to fuse_lowlevel_notify_retrieve()
  894. * @param offset the offset supplied to fuse_lowlevel_notify_retrieve()
  895. * @param bufv the buffer containing the returned data
  896. */
  897. void (*retrieve_reply)(fuse_req_t req,
  898. void *cookie,
  899. uint64_t ino,
  900. off_t offset);
  901. /**
  902. * Forget about multiple inodes
  903. *
  904. * See description of the forget function for more
  905. * information.
  906. *
  907. * Introduced in version 2.9
  908. *
  909. * Valid replies:
  910. * fuse_reply_none
  911. *
  912. * @param req request handle
  913. */
  914. void (*forget_multi)(fuse_req_t req, size_t count,
  915. struct fuse_forget_data *forgets);
  916. /**
  917. * Acquire, modify or release a BSD file lock
  918. *
  919. * Note: if the locking methods are not implemented, the kernel
  920. * will still allow file locking to work locally. Hence these are
  921. * only interesting for network filesystems and similar.
  922. *
  923. * Introduced in version 2.9
  924. *
  925. * Valid replies:
  926. * fuse_reply_err
  927. *
  928. * @param req request handle
  929. * @param ino the inode number
  930. * @param fi file information
  931. * @param op the locking operation, see flock(2)
  932. */
  933. void (*flock)(fuse_req_t req, uint64_t ino,
  934. fuse_file_info_t *fi, int op);
  935. /**
  936. * Allocate requested space. If this function returns success then
  937. * subsequent writes to the specified range shall not fail due to the lack
  938. * of free space on the file system storage media.
  939. *
  940. * Introduced in version 2.9
  941. *
  942. * Valid replies:
  943. * fuse_reply_err
  944. *
  945. * @param req request handle
  946. * @param ino the inode number
  947. * @param offset starting point for allocated region
  948. * @param length size of allocated region
  949. * @param mode determines the operation to be performed on the given range,
  950. * see fallocate(2)
  951. */
  952. void (*fallocate)(fuse_req_t req, uint64_t ino, int mode,
  953. off_t offset, off_t length, fuse_file_info_t *fi);
  954. /**
  955. * Copy a range of data from one file to another
  956. *
  957. * Performs an optimized copy between two file descriptors without
  958. * the
  959. * additional cost of transferring data through the FUSE kernel
  960. * module
  961. * to user space (glibc) and then back into the FUSE filesystem
  962. * again.
  963. *
  964. * In case this method is not implemented, glibc falls back to
  965. * reading
  966. * data from the source and writing to the destination. Effectively
  967. * doing an inefficient copy of the data.
  968. *
  969. * If this request is answered with an error code of ENOSYS, this is
  970. * treated as a permanent failure with error code EOPNOTSUPP,
  971. * i.e. all
  972. * future copy_file_range() requests will fail with EOPNOTSUPP
  973. * without
  974. * being send to the filesystem process.
  975. *
  976. * Valid replies:
  977. * fuse_reply_write
  978. * fuse_reply_err
  979. *
  980. * @param req request handle
  981. * @param ino_in the inode number of the source file
  982. * @param off_in starting point from were the data should be read
  983. * @param fi_in file information of the source file
  984. * @param ino_out the inode number of the destination file
  985. * @param off_out starting point where the data should be written
  986. * @param fi_out file information of the destination file
  987. * @param len maximum size of the data to copy
  988. * @param flags passed along with the copy_file_range() syscall
  989. */
  990. void (*copy_file_range)(fuse_req_t req,
  991. uint64_t ino_in,
  992. off_t off_in,
  993. fuse_file_info_t *fi_in,
  994. uint64_t ino_out,
  995. off_t off_out,
  996. fuse_file_info_t *fi_out,
  997. size_t len,
  998. int flags);
  999. };
  1000. /**
  1001. * Reply with an error code or success
  1002. *
  1003. * Possible requests:
  1004. * all except forget
  1005. *
  1006. * unlink, rmdir, rename, flush, release, fsync, fsyncdir, setxattr,
  1007. * removexattr and setlk may send a zero code
  1008. *
  1009. * @param req request handle
  1010. * @param err the positive error value, or zero for success
  1011. * @return zero for success, -errno for failure to send reply
  1012. */
  1013. int fuse_reply_err(fuse_req_t req, int err);
  1014. /**
  1015. * Don't send reply
  1016. *
  1017. * Possible requests:
  1018. * forget
  1019. *
  1020. * @param req request handle
  1021. */
  1022. void fuse_reply_none(fuse_req_t req);
  1023. /**
  1024. * Reply with a directory entry
  1025. *
  1026. * Possible requests:
  1027. * lookup, mknod, mkdir, symlink, link
  1028. *
  1029. * Side effects:
  1030. * increments the lookup count on success
  1031. *
  1032. * @param req request handle
  1033. * @param e the entry parameters
  1034. * @return zero for success, -errno for failure to send reply
  1035. */
  1036. int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e);
  1037. /**
  1038. * Reply with a directory entry and open parameters
  1039. *
  1040. * currently the following members of 'fi' are used:
  1041. * fh, direct_io, keep_cache
  1042. *
  1043. * Possible requests:
  1044. * create
  1045. *
  1046. * Side effects:
  1047. * increments the lookup count on success
  1048. *
  1049. * @param req request handle
  1050. * @param e the entry parameters
  1051. * @param fi file information
  1052. * @return zero for success, -errno for failure to send reply
  1053. */
  1054. int fuse_reply_create(fuse_req_t req, const struct fuse_entry_param *e,
  1055. const fuse_file_info_t *fi);
  1056. /**
  1057. * Reply with attributes
  1058. *
  1059. * Possible requests:
  1060. * getattr, setattr
  1061. *
  1062. * @param req request handle
  1063. * @param attr the attributes
  1064. * @param attr_timeout validity timeout (in seconds) for the attributes
  1065. * @return zero for success, -errno for failure to send reply
  1066. */
  1067. int fuse_reply_attr(fuse_req_t req,
  1068. const struct stat *attr,
  1069. const uint64_t timeout);
  1070. /**
  1071. * Reply with the contents of a symbolic link
  1072. *
  1073. * Possible requests:
  1074. * readlink
  1075. *
  1076. * @param req request handle
  1077. * @param link symbolic link contents
  1078. * @return zero for success, -errno for failure to send reply
  1079. */
  1080. int fuse_reply_readlink(fuse_req_t req, const char *link);
  1081. /**
  1082. * Reply with open parameters
  1083. *
  1084. * currently the following members of 'fi' are used:
  1085. * fh, direct_io, keep_cache
  1086. *
  1087. * Possible requests:
  1088. * open, opendir
  1089. *
  1090. * @param req request handle
  1091. * @param fi file information
  1092. * @return zero for success, -errno for failure to send reply
  1093. */
  1094. int fuse_reply_open(fuse_req_t req, const fuse_file_info_t *fi);
  1095. /**
  1096. * Reply with number of bytes written
  1097. *
  1098. * Possible requests:
  1099. * write
  1100. *
  1101. * @param req request handle
  1102. * @param count the number of bytes written
  1103. * @return zero for success, -errno for failure to send reply
  1104. */
  1105. int fuse_reply_write(fuse_req_t req, size_t count);
  1106. /**
  1107. * Reply with data
  1108. *
  1109. * Possible requests:
  1110. * read, readdir, getxattr, listxattr
  1111. *
  1112. * @param req request handle
  1113. * @param buf buffer containing data
  1114. * @param size the size of data in bytes
  1115. * @return zero for success, -errno for failure to send reply
  1116. */
  1117. int fuse_reply_buf(fuse_req_t req, const char *buf, size_t size);
  1118. /**
  1119. * Reply with data copied/moved from buffer(s)
  1120. *
  1121. * Possible requests:
  1122. * read, readdir, getxattr, listxattr
  1123. *
  1124. * @param req request handle
  1125. * @param bufv buffer vector
  1126. * @param flags flags controlling the copy
  1127. * @return zero for success, -errno for failure to send reply
  1128. */
  1129. int fuse_reply_data(fuse_req_t req, struct fuse_bufvec *bufv,
  1130. enum fuse_buf_copy_flags flags);
  1131. /**
  1132. * Reply with data vector
  1133. *
  1134. * Possible requests:
  1135. * read, readdir, getxattr, listxattr
  1136. *
  1137. * @param req request handle
  1138. * @param iov the vector containing the data
  1139. * @param count the size of vector
  1140. * @return zero for success, -errno for failure to send reply
  1141. */
  1142. int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count);
  1143. /**
  1144. * Reply with filesystem statistics
  1145. *
  1146. * Possible requests:
  1147. * statfs
  1148. *
  1149. * @param req request handle
  1150. * @param stbuf filesystem statistics
  1151. * @return zero for success, -errno for failure to send reply
  1152. */
  1153. int fuse_reply_statfs(fuse_req_t req, const struct statvfs *stbuf);
  1154. /**
  1155. * Reply with needed buffer size
  1156. *
  1157. * Possible requests:
  1158. * getxattr, listxattr
  1159. *
  1160. * @param req request handle
  1161. * @param count the buffer size needed in bytes
  1162. * @return zero for success, -errno for failure to send reply
  1163. */
  1164. int fuse_reply_xattr(fuse_req_t req, size_t count);
  1165. /**
  1166. * Reply with file lock information
  1167. *
  1168. * Possible requests:
  1169. * getlk
  1170. *
  1171. * @param req request handle
  1172. * @param lock the lock information
  1173. * @return zero for success, -errno for failure to send reply
  1174. */
  1175. int fuse_reply_lock(fuse_req_t req, const struct flock *lock);
  1176. /**
  1177. * Reply with block index
  1178. *
  1179. * Possible requests:
  1180. * bmap
  1181. *
  1182. * @param req request handle
  1183. * @param idx block index within device
  1184. * @return zero for success, -errno for failure to send reply
  1185. */
  1186. int fuse_reply_bmap(fuse_req_t req, uint64_t idx);
  1187. /**
  1188. * Reply to ask for data fetch and output buffer preparation. ioctl
  1189. * will be retried with the specified input data fetched and output
  1190. * buffer prepared.
  1191. *
  1192. * Possible requests:
  1193. * ioctl
  1194. *
  1195. * @param req request handle
  1196. * @param in_iov iovec specifying data to fetch from the caller
  1197. * @param in_count number of entries in in_iov
  1198. * @param out_iov iovec specifying addresses to write output to
  1199. * @param out_count number of entries in out_iov
  1200. * @return zero for success, -errno for failure to send reply
  1201. */
  1202. int fuse_reply_ioctl_retry(fuse_req_t req,
  1203. const struct iovec *in_iov, size_t in_count,
  1204. const struct iovec *out_iov, size_t out_count);
  1205. /**
  1206. * Reply to finish ioctl
  1207. *
  1208. * Possible requests:
  1209. * ioctl
  1210. *
  1211. * @param req request handle
  1212. * @param result result to be passed to the caller
  1213. * @param buf buffer containing output data
  1214. * @param size length of output data
  1215. */
  1216. int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, uint32_t size);
  1217. /**
  1218. * Reply to finish ioctl with iov buffer
  1219. *
  1220. * Possible requests:
  1221. * ioctl
  1222. *
  1223. * @param req request handle
  1224. * @param result result to be passed to the caller
  1225. * @param iov the vector containing the data
  1226. * @param count the size of vector
  1227. */
  1228. int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov,
  1229. int count);
  1230. /**
  1231. * Reply with poll result event mask
  1232. *
  1233. * @param req request handle
  1234. * @param revents poll result event mask
  1235. */
  1236. int fuse_reply_poll(fuse_req_t req, unsigned revents);
  1237. /* ----------------------------------------------------------- *
  1238. * Notification *
  1239. * ----------------------------------------------------------- */
  1240. /**
  1241. * Notify IO readiness event
  1242. *
  1243. * For more information, please read comment for poll operation.
  1244. *
  1245. * @param ph poll handle to notify IO readiness event for
  1246. */
  1247. int fuse_lowlevel_notify_poll(fuse_pollhandle_t *ph);
  1248. /**
  1249. * Notify to invalidate cache for an inode
  1250. *
  1251. * @param ch the channel through which to send the invalidation
  1252. * @param ino the inode number
  1253. * @param off the offset in the inode where to start invalidating
  1254. * or negative to invalidate attributes only
  1255. * @param len the amount of cache to invalidate or 0 for all
  1256. * @return zero for success, -errno for failure
  1257. */
  1258. int fuse_lowlevel_notify_inval_inode(struct fuse_chan *ch, uint64_t ino,
  1259. off_t off, off_t len);
  1260. /**
  1261. * Notify to invalidate parent attributes and the dentry matching
  1262. * parent/name
  1263. *
  1264. * To avoid a deadlock don't call this function from a filesystem operation and
  1265. * don't call it with a lock held that can also be held by a filesystem
  1266. * operation.
  1267. *
  1268. * @param ch the channel through which to send the invalidation
  1269. * @param parent inode number
  1270. * @param name file name
  1271. * @param namelen strlen() of file name
  1272. * @return zero for success, -errno for failure
  1273. */
  1274. int fuse_lowlevel_notify_inval_entry(struct fuse_chan *ch, uint64_t parent,
  1275. const char *name, size_t namelen);
  1276. /**
  1277. * Notify to invalidate parent attributes and delete the dentry matching
  1278. * parent/name if the dentry's inode number matches child (otherwise it
  1279. * will invalidate the matching dentry).
  1280. *
  1281. * To avoid a deadlock don't call this function from a filesystem operation and
  1282. * don't call it with a lock held that can also be held by a filesystem
  1283. * operation.
  1284. *
  1285. * @param ch the channel through which to send the notification
  1286. * @param parent inode number
  1287. * @param child inode number
  1288. * @param name file name
  1289. * @param namelen strlen() of file name
  1290. * @return zero for success, -errno for failure
  1291. */
  1292. int fuse_lowlevel_notify_delete(struct fuse_chan *ch,
  1293. uint64_t parent, uint64_t child,
  1294. const char *name, size_t namelen);
  1295. /**
  1296. * Store data to the kernel buffers
  1297. *
  1298. * Synchronously store data in the kernel buffers belonging to the
  1299. * given inode. The stored data is marked up-to-date (no read will be
  1300. * performed against it, unless it's invalidated or evicted from the
  1301. * cache).
  1302. *
  1303. * If the stored data overflows the current file size, then the size
  1304. * is extended, similarly to a write(2) on the filesystem.
  1305. *
  1306. * If this function returns an error, then the store wasn't fully
  1307. * completed, but it may have been partially completed.
  1308. *
  1309. * @param ch the channel through which to send the invalidation
  1310. * @param ino the inode number
  1311. * @param offset the starting offset into the file to store to
  1312. * @param bufv buffer vector
  1313. * @param flags flags controlling the copy
  1314. * @return zero for success, -errno for failure
  1315. */
  1316. int fuse_lowlevel_notify_store(struct fuse_chan *ch, uint64_t ino,
  1317. off_t offset, struct fuse_bufvec *bufv,
  1318. enum fuse_buf_copy_flags flags);
  1319. /**
  1320. * Retrieve data from the kernel buffers
  1321. *
  1322. * Retrieve data in the kernel buffers belonging to the given inode.
  1323. * If successful then the retrieve_reply() method will be called with
  1324. * the returned data.
  1325. *
  1326. * Only present pages are returned in the retrieve reply. Retrieving
  1327. * stops when it finds a non-present page and only data prior to that is
  1328. * returned.
  1329. *
  1330. * If this function returns an error, then the retrieve will not be
  1331. * completed and no reply will be sent.
  1332. *
  1333. * This function doesn't change the dirty state of pages in the kernel
  1334. * buffer. For dirty pages the write() method will be called
  1335. * regardless of having been retrieved previously.
  1336. *
  1337. * @param ch the channel through which to send the invalidation
  1338. * @param ino the inode number
  1339. * @param size the number of bytes to retrieve
  1340. * @param offset the starting offset into the file to retrieve from
  1341. * @param cookie user data to supply to the reply callback
  1342. * @return zero for success, -errno for failure
  1343. */
  1344. int fuse_lowlevel_notify_retrieve(struct fuse_chan *ch, uint64_t ino,
  1345. size_t size, off_t offset, void *cookie);
  1346. /* ----------------------------------------------------------- *
  1347. * Utility functions *
  1348. * ----------------------------------------------------------- */
  1349. /**
  1350. * Get the userdata from the request
  1351. *
  1352. * @param req request handle
  1353. * @return the user data passed to fuse_lowlevel_new()
  1354. */
  1355. void *fuse_req_userdata(fuse_req_t req);
  1356. /**
  1357. * Get the context from the request
  1358. *
  1359. * The pointer returned by this function will only be valid for the
  1360. * request's lifetime
  1361. *
  1362. * @param req request handle
  1363. * @return the context structure
  1364. */
  1365. const struct fuse_ctx *fuse_req_ctx(fuse_req_t req);
  1366. /**
  1367. * Get the current supplementary group IDs for the specified request
  1368. *
  1369. * Similar to the getgroups(2) system call, except the return value is
  1370. * always the total number of group IDs, even if it is larger than the
  1371. * specified size.
  1372. *
  1373. * The current fuse kernel module in linux (as of 2.6.30) doesn't pass
  1374. * the group list to userspace, hence this function needs to parse
  1375. * "/proc/$TID/task/$TID/status" to get the group IDs.
  1376. *
  1377. * This feature may not be supported on all operating systems. In
  1378. * such a case this function will return -ENOSYS.
  1379. *
  1380. * @param req request handle
  1381. * @param size size of given array
  1382. * @param list array of group IDs to be filled in
  1383. * @return the total number of supplementary group IDs or -errno on failure
  1384. */
  1385. int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[]);
  1386. /* ----------------------------------------------------------- *
  1387. * Filesystem setup *
  1388. * ----------------------------------------------------------- */
  1389. /* Deprecated, don't use */
  1390. int fuse_lowlevel_is_lib_option(const char *opt);
  1391. /**
  1392. * Create a low level session
  1393. *
  1394. * @param args argument vector
  1395. * @param op the low level filesystem operations
  1396. * @param op_size sizeof(struct fuse_lowlevel_ops)
  1397. * @param userdata user data
  1398. * @return the created session object, or NULL on failure
  1399. */
  1400. struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,
  1401. const struct fuse_lowlevel_ops *op,
  1402. size_t op_size, void *userdata);
  1403. /* ----------------------------------------------------------- *
  1404. * Session interface *
  1405. * ----------------------------------------------------------- */
  1406. struct fuse_session *fuse_session_new(void *data,
  1407. void *receive_buf,
  1408. void *process_buf,
  1409. void *destroy);
  1410. void fuse_session_add_chan(struct fuse_session *se, struct fuse_chan *ch);
  1411. void fuse_session_remove_chan(struct fuse_chan *ch);
  1412. void fuse_session_destroy(struct fuse_session *se);
  1413. void fuse_session_exit(struct fuse_session *se);
  1414. int fuse_session_exited(struct fuse_session *se);
  1415. void fuse_session_reset(struct fuse_session *se);
  1416. void *fuse_session_data(struct fuse_session *se);
  1417. int fuse_session_receive(struct fuse_session *se,
  1418. struct fuse_buf *buf);
  1419. void fuse_session_process(struct fuse_session *se,
  1420. const struct fuse_buf *buf);
  1421. int fuse_session_loop_mt(struct fuse_session *se, const int threads);
  1422. /* ----------------------------------------------------------- *
  1423. * Channel interface *
  1424. * ----------------------------------------------------------- */
  1425. struct fuse_chan *fuse_chan_new(int fd, size_t bufsize);
  1426. /**
  1427. * Query the file descriptor of the channel
  1428. *
  1429. * @param ch the channel
  1430. * @return the file descriptor passed to fuse_chan_new()
  1431. */
  1432. int fuse_chan_fd(struct fuse_chan *ch);
  1433. /**
  1434. * Query the minimal receive buffer size
  1435. *
  1436. * @param ch the channel
  1437. * @return the buffer size passed to fuse_chan_new()
  1438. */
  1439. size_t fuse_chan_bufsize(struct fuse_chan *ch);
  1440. /**
  1441. * Query the user data
  1442. *
  1443. * @param ch the channel
  1444. * @return the user data passed to fuse_chan_new()
  1445. */
  1446. void *fuse_chan_data(struct fuse_chan *ch);
  1447. /**
  1448. * Query the session to which this channel is assigned
  1449. *
  1450. * @param ch the channel
  1451. * @return the session, or NULL if the channel is not assigned
  1452. */
  1453. struct fuse_session *fuse_chan_session(struct fuse_chan *ch);
  1454. int fuse_chan_recv(struct fuse_chan *ch,
  1455. char *buf,
  1456. size_t size);
  1457. int fuse_chan_send(struct fuse_chan *ch,
  1458. const struct iovec iov[],
  1459. size_t count);
  1460. void fuse_chan_destroy(struct fuse_chan *ch);
  1461. EXTERN_C_END
  1462. #endif /* _FUSE_LOWLEVEL_H_ */