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.

217 lines
7.0 KiB

3 years ago
  1. package mount
  2. import (
  3. "github.com/hanwen/go-fuse/v2/fuse"
  4. )
  5. /**
  6. * Read data
  7. *
  8. * Read should send exactly the number of bytes requested except
  9. * on EOF or error, otherwise the rest of the data will be
  10. * substituted with zeroes. An exception to this is when the file
  11. * has been opened in 'direct_io' mode, in which case the return
  12. * value of the read system call will reflect the return value of
  13. * this operation.
  14. *
  15. * fi->fh will contain the value set by the open method, or will
  16. * be undefined if the open method didn't set any value.
  17. *
  18. * Valid replies:
  19. * fuse_reply_buf
  20. * fuse_reply_iov
  21. * fuse_reply_data
  22. * fuse_reply_err
  23. *
  24. * @param req request handle
  25. * @param ino the inode number
  26. * @param size number of bytes to read
  27. * @param off offset to read from
  28. * @param fi file information
  29. */
  30. func (wfs *WFS) Read(cancel <-chan struct{}, in *fuse.ReadIn, buf []byte) (fuse.ReadResult, fuse.Status) {
  31. return nil, fuse.ENOSYS
  32. }
  33. /**
  34. * Write data
  35. *
  36. * Write should return exactly the number of bytes requested
  37. * except on error. An exception to this is when the file has
  38. * been opened in 'direct_io' mode, in which case the return value
  39. * of the write system call will reflect the return value of this
  40. * operation.
  41. *
  42. * Unless FUSE_CAP_HANDLE_KILLPRIV is disabled, this method is
  43. * expected to reset the setuid and setgid bits.
  44. *
  45. * fi->fh will contain the value set by the open method, or will
  46. * be undefined if the open method didn't set any value.
  47. *
  48. * Valid replies:
  49. * fuse_reply_write
  50. * fuse_reply_err
  51. *
  52. * @param req request handle
  53. * @param ino the inode number
  54. * @param buf data to write
  55. * @param size number of bytes to write
  56. * @param off offset to write to
  57. * @param fi file information
  58. */
  59. func (wfs *WFS) Write(cancel <-chan struct{}, in *fuse.WriteIn, data []byte) (written uint32, code fuse.Status) {
  60. return 0, fuse.ENOSYS
  61. }
  62. /**
  63. * Open a file
  64. *
  65. * Open flags are available in fi->flags. The following rules
  66. * apply.
  67. *
  68. * - Creation (O_CREAT, O_EXCL, O_NOCTTY) flags will be
  69. * filtered out / handled by the kernel.
  70. *
  71. * - Access modes (O_RDONLY, O_WRONLY, O_RDWR) should be used
  72. * by the filesystem to check if the operation is
  73. * permitted. If the ``-o default_permissions`` mount
  74. * option is given, this check is already done by the
  75. * kernel before calling open() and may thus be omitted by
  76. * the filesystem.
  77. *
  78. * - When writeback caching is enabled, the kernel may send
  79. * read requests even for files opened with O_WRONLY. The
  80. * filesystem should be prepared to handle this.
  81. *
  82. * - When writeback caching is disabled, the filesystem is
  83. * expected to properly handle the O_APPEND flag and ensure
  84. * that each write is appending to the end of the file.
  85. *
  86. * - When writeback caching is enabled, the kernel will
  87. * handle O_APPEND. However, unless all changes to the file
  88. * come through the kernel this will not work reliably. The
  89. * filesystem should thus either ignore the O_APPEND flag
  90. * (and let the kernel handle it), or return an error
  91. * (indicating that reliably O_APPEND is not available).
  92. *
  93. * Filesystem may store an arbitrary file handle (pointer,
  94. * index, etc) in fi->fh, and use this in other all other file
  95. * operations (read, write, flush, release, fsync).
  96. *
  97. * Filesystem may also implement stateless file I/O and not store
  98. * anything in fi->fh.
  99. *
  100. * There are also some flags (direct_io, keep_cache) which the
  101. * filesystem may set in fi, to change the way the file is opened.
  102. * See fuse_file_info structure in <fuse_common.h> for more details.
  103. *
  104. * If this request is answered with an error code of ENOSYS
  105. * and FUSE_CAP_NO_OPEN_SUPPORT is set in
  106. * `fuse_conn_info.capable`, this is treated as success and
  107. * future calls to open and release will also succeed without being
  108. * sent to the filesystem process.
  109. *
  110. * Valid replies:
  111. * fuse_reply_open
  112. * fuse_reply_err
  113. *
  114. * @param req request handle
  115. * @param ino the inode number
  116. * @param fi file information
  117. */
  118. func (wfs *WFS) Open(cancel <-chan struct{}, in *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) {
  119. return fuse.ENOSYS
  120. }
  121. /**
  122. * Flush method
  123. *
  124. * This is called on each close() of the opened file.
  125. *
  126. * Since file descriptors can be duplicated (dup, dup2, fork), for
  127. * one open call there may be many flush calls.
  128. *
  129. * Filesystems shouldn't assume that flush will always be called
  130. * after some writes, or that if will be called at all.
  131. *
  132. * fi->fh will contain the value set by the open method, or will
  133. * be undefined if the open method didn't set any value.
  134. *
  135. * NOTE: the name of the method is misleading, since (unlike
  136. * fsync) the filesystem is not forced to flush pending writes.
  137. * One reason to flush data is if the filesystem wants to return
  138. * write errors during close. However, such use is non-portable
  139. * because POSIX does not require [close] to wait for delayed I/O to
  140. * complete.
  141. *
  142. * If the filesystem supports file locking operations (setlk,
  143. * getlk) it should remove all locks belonging to 'fi->owner'.
  144. *
  145. * If this request is answered with an error code of ENOSYS,
  146. * this is treated as success and future calls to flush() will
  147. * succeed automatically without being send to the filesystem
  148. * process.
  149. *
  150. * Valid replies:
  151. * fuse_reply_err
  152. *
  153. * @param req request handle
  154. * @param ino the inode number
  155. * @param fi file information
  156. *
  157. * [close]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html
  158. */
  159. func (wfs *WFS) Flush(cancel <-chan struct{}, in *fuse.FlushIn) fuse.Status {
  160. return fuse.ENOSYS
  161. }
  162. /**
  163. * Release an open file
  164. *
  165. * Release is called when there are no more references to an open
  166. * file: all file descriptors are closed and all memory mappings
  167. * are unmapped.
  168. *
  169. * For every open call there will be exactly one release call (unless
  170. * the filesystem is force-unmounted).
  171. *
  172. * The filesystem may reply with an error, but error values are
  173. * not returned to close() or munmap() which triggered the
  174. * release.
  175. *
  176. * fi->fh will contain the value set by the open method, or will
  177. * be undefined if the open method didn't set any value.
  178. * fi->flags will contain the same flags as for open.
  179. *
  180. * Valid replies:
  181. * fuse_reply_err
  182. *
  183. * @param req request handle
  184. * @param ino the inode number
  185. * @param fi file information
  186. */
  187. func (wfs *WFS) Release(cancel <-chan struct{}, in *fuse.ReleaseIn) {
  188. }
  189. /**
  190. * Synchronize file contents
  191. *
  192. * If the datasync parameter is non-zero, then only the user data
  193. * should be flushed, not the meta data.
  194. *
  195. * If this request is answered with an error code of ENOSYS,
  196. * this is treated as success and future calls to fsync() will
  197. * succeed automatically without being send to the filesystem
  198. * process.
  199. *
  200. * Valid replies:
  201. * fuse_reply_err
  202. *
  203. * @param req request handle
  204. * @param ino the inode number
  205. * @param datasync flag indicating if only data should be flushed
  206. * @param fi file information
  207. */
  208. func (wfs *WFS) Fsync(cancel <-chan struct{}, in *fuse.FsyncIn) (code fuse.Status) {
  209. return fuse.ENOSYS
  210. }