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.

1093 lines
26 KiB

  1. /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
  2. /*
  3. This file defines the kernel interface of FUSE
  4. Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
  5. This program can be distributed under the terms of the GNU GPL.
  6. See the file COPYING.
  7. This -- and only this -- header file may also be distributed under
  8. the terms of the BSD Licence as follows:
  9. Copyright (C) 2001-2007 Miklos Szeredi. All rights reserved.
  10. Redistribution and use in source and binary forms, with or without
  11. modification, are permitted provided that the following conditions
  12. are met:
  13. 1. Redistributions of source code must retain the above copyright
  14. notice, this list of conditions and the following disclaimer.
  15. 2. Redistributions in binary form must reproduce the above copyright
  16. notice, this list of conditions and the following disclaimer in the
  17. documentation and/or other materials provided with the distribution.
  18. THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  19. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
  22. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. SUCH DAMAGE.
  29. */
  30. /*
  31. * This file defines the kernel interface of FUSE
  32. *
  33. * Protocol changelog:
  34. *
  35. * 7.1:
  36. * - add the following messages:
  37. * FUSE_SETATTR, FUSE_SYMLINK, FUSE_MKNOD, FUSE_MKDIR, FUSE_UNLINK,
  38. * FUSE_RMDIR, FUSE_RENAME, FUSE_LINK, FUSE_OPEN, FUSE_READ, FUSE_WRITE,
  39. * FUSE_RELEASE, FUSE_FSYNC, FUSE_FLUSH, FUSE_SETXATTR, FUSE_GETXATTR,
  40. * FUSE_LISTXATTR, FUSE_REMOVEXATTR, FUSE_OPENDIR, FUSE_READDIR,
  41. * FUSE_RELEASEDIR
  42. * - add padding to messages to accommodate 32-bit servers on 64-bit kernels
  43. *
  44. * 7.2:
  45. * - add FOPEN_DIRECT_IO and FOPEN_KEEP_CACHE flags
  46. * - add FUSE_FSYNCDIR message
  47. *
  48. * 7.3:
  49. * - add FUSE_ACCESS message
  50. * - add FUSE_CREATE message
  51. * - add filehandle to fuse_setattr_in
  52. *
  53. * 7.4:
  54. * - add frsize to fuse_kstatfs
  55. * - clean up request size limit checking
  56. *
  57. * 7.5:
  58. * - add flags and max_write to fuse_init_out
  59. *
  60. * 7.6:
  61. * - add max_readahead to fuse_init_in and fuse_init_out
  62. *
  63. * 7.7:
  64. * - add FUSE_INTERRUPT message
  65. * - add POSIX file lock support
  66. *
  67. * 7.8:
  68. * - add lock_owner and flags fields to fuse_release_in
  69. * - add FUSE_BMAP message
  70. * - add FUSE_DESTROY message
  71. *
  72. * 7.9:
  73. * - new fuse_getattr_in input argument of GETATTR
  74. * - add lk_flags in fuse_lk_in
  75. * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in
  76. * - add blksize field to fuse_attr
  77. * - add file flags field to fuse_read_in and fuse_write_in
  78. * - Add ATIME_NOW and MTIME_NOW flags to fuse_setattr_in
  79. *
  80. * 7.10
  81. * - add nonseekable open flag
  82. *
  83. * 7.11
  84. * - add IOCTL message
  85. * - add unsolicited notification support
  86. * - add POLL message and NOTIFY_POLL notification
  87. *
  88. * 7.12
  89. * - add umask flag to input argument of create, mknod and mkdir
  90. * - add notification messages for invalidation of inodes and
  91. * directory entries
  92. *
  93. * 7.13
  94. * - make max number of background requests and congestion threshold
  95. * tunables
  96. *
  97. * 7.14
  98. * - add splice support to fuse device
  99. *
  100. * 7.15
  101. * - add store notify
  102. * - add retrieve notify
  103. *
  104. * 7.16
  105. * - add BATCH_FORGET request
  106. * - FUSE_IOCTL_UNRESTRICTED shall now return with array of 'struct
  107. * fuse_ioctl_iovec' instead of ambiguous 'struct iovec'
  108. * - add FUSE_IOCTL_32BIT flag
  109. *
  110. * 7.17
  111. * - add FUSE_FLOCK_LOCKS and FUSE_RELEASE_FLOCK_UNLOCK
  112. *
  113. * 7.18
  114. * - add FUSE_IOCTL_DIR flag
  115. * - add FUSE_NOTIFY_DELETE
  116. *
  117. * 7.19
  118. * - add FUSE_FALLOCATE
  119. *
  120. * 7.20
  121. * - add FUSE_AUTO_INVAL_DATA
  122. *
  123. * 7.21
  124. * - add FUSE_READDIRPLUS
  125. * - send the requested events in POLL request
  126. *
  127. * 7.22
  128. * - add FUSE_ASYNC_DIO
  129. *
  130. * 7.23
  131. * - add FUSE_WRITEBACK_CACHE
  132. * - add time_gran to fuse_init_out
  133. * - add reserved space to fuse_init_out
  134. * - add FATTR_CTIME
  135. * - add ctime and ctimensec to fuse_setattr_in
  136. * - add FUSE_RENAME2 request
  137. * - add FUSE_NO_OPEN_SUPPORT flag
  138. *
  139. * 7.24
  140. * - add FUSE_LSEEK for SEEK_HOLE and SEEK_DATA support
  141. *
  142. * 7.25
  143. * - add FUSE_PARALLEL_DIROPS
  144. *
  145. * 7.26
  146. * - add FUSE_HANDLE_KILLPRIV
  147. * - add FUSE_POSIX_ACL
  148. *
  149. * 7.27
  150. * - add FUSE_ABORT_ERROR
  151. *
  152. * 7.28
  153. * - add FUSE_COPY_FILE_RANGE
  154. * - add FOPEN_CACHE_DIR
  155. * - add FUSE_MAX_PAGES, add max_pages to init_out
  156. * - add FUSE_CACHE_SYMLINKS
  157. *
  158. * 7.29
  159. * - add FUSE_NO_OPENDIR_SUPPORT flag
  160. *
  161. * 7.30
  162. * - add FUSE_EXPLICIT_INVAL_DATA
  163. * - add FUSE_IOCTL_COMPAT_X32
  164. *
  165. * 7.31
  166. * - add FUSE_WRITE_KILL_PRIV flag
  167. * - add FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING
  168. * - add map_alignment to fuse_init_out, add FUSE_MAP_ALIGNMENT flag
  169. *
  170. * 7.32
  171. * - add flags to fuse_attr, add FUSE_ATTR_SUBMOUNT, add FUSE_SUBMOUNTS
  172. *
  173. * 7.33
  174. * - add FUSE_HANDLE_KILLPRIV_V2, FUSE_WRITE_KILL_SUIDGID, FATTR_KILL_SUIDGID
  175. * - add FUSE_OPEN_KILL_SUIDGID
  176. * - extend fuse_setxattr_in, add FUSE_SETXATTR_EXT
  177. * - add FUSE_SETXATTR_ACL_KILL_SGID
  178. *
  179. * 7.34
  180. * - add FUSE_SYNCFS
  181. *
  182. * 7.35
  183. * - add FOPEN_NOFLUSH
  184. *
  185. * 7.36
  186. * - extend fuse_init_in with reserved fields, add FUSE_INIT_EXT init flag
  187. * - add flags2 to fuse_init_in and fuse_init_out
  188. * - add FUSE_SECURITY_CTX init flag
  189. * - add security context to create, mkdir, symlink, and mknod requests
  190. * - add FUSE_HAS_INODE_DAX, FUSE_ATTR_DAX
  191. *
  192. * 7.37
  193. * - add FUSE_TMPFILE
  194. *
  195. * 7.38
  196. * - add FUSE_EXPIRE_ONLY flag to fuse_notify_inval_entry
  197. * - add FOPEN_PARALLEL_DIRECT_WRITES
  198. * - add total_extlen to fuse_in_header
  199. * - add FUSE_MAX_NR_SECCTX
  200. * - add extension header
  201. * - add FUSE_EXT_GROUPS
  202. * - add FUSE_CREATE_SUPP_GROUP
  203. */
  204. #ifndef _LINUX_FUSE_H
  205. #define _LINUX_FUSE_H
  206. #ifdef __KERNEL__
  207. #include <linux/types.h>
  208. #else
  209. #include <stdint.h>
  210. #endif
  211. /*
  212. * Version negotiation:
  213. *
  214. * Both the kernel and userspace send the version they support in the
  215. * INIT request and reply respectively.
  216. *
  217. * If the major versions match then both shall use the smallest
  218. * of the two minor versions for communication.
  219. *
  220. * If the kernel supports a larger major version, then userspace shall
  221. * reply with the major version it supports, ignore the rest of the
  222. * INIT message and expect a new INIT message from the kernel with a
  223. * matching major version.
  224. *
  225. * If the library supports a larger major version, then it shall fall
  226. * back to the major protocol version sent by the kernel for
  227. * communication and reply with that major version (and an arbitrary
  228. * supported minor version).
  229. */
  230. /** Version number of this interface */
  231. #define FUSE_KERNEL_VERSION 7
  232. /** Minor version number of this interface */
  233. #define FUSE_KERNEL_MINOR_VERSION 38
  234. /** The node ID of the root inode */
  235. #define FUSE_ROOT_ID 1
  236. /* Make sure all structures are padded to 64bit boundary, so 32bit
  237. userspace works under 64bit kernels */
  238. struct fuse_attr {
  239. uint64_t ino;
  240. uint64_t size;
  241. uint64_t blocks;
  242. uint64_t atime;
  243. uint64_t mtime;
  244. uint64_t ctime;
  245. uint32_t atimensec;
  246. uint32_t mtimensec;
  247. uint32_t ctimensec;
  248. uint32_t mode;
  249. uint32_t nlink;
  250. uint32_t uid;
  251. uint32_t gid;
  252. uint32_t rdev;
  253. uint32_t blksize;
  254. uint32_t flags;
  255. };
  256. struct fuse_kstatfs {
  257. uint64_t blocks;
  258. uint64_t bfree;
  259. uint64_t bavail;
  260. uint64_t files;
  261. uint64_t ffree;
  262. uint32_t bsize;
  263. uint32_t namelen;
  264. uint32_t frsize;
  265. uint32_t padding;
  266. uint32_t spare[6];
  267. };
  268. struct fuse_file_lock {
  269. uint64_t start;
  270. uint64_t end;
  271. uint32_t type;
  272. uint32_t pid; /* tgid */
  273. };
  274. /**
  275. * Bitmasks for fuse_setattr_in.valid
  276. */
  277. #define FATTR_MODE (1 << 0)
  278. #define FATTR_UID (1 << 1)
  279. #define FATTR_GID (1 << 2)
  280. #define FATTR_SIZE (1 << 3)
  281. #define FATTR_ATIME (1 << 4)
  282. #define FATTR_MTIME (1 << 5)
  283. #define FATTR_FH (1 << 6)
  284. #define FATTR_ATIME_NOW (1 << 7)
  285. #define FATTR_MTIME_NOW (1 << 8)
  286. #define FATTR_LOCKOWNER (1 << 9)
  287. #define FATTR_CTIME (1 << 10)
  288. #define FATTR_KILL_SUIDGID (1 << 11)
  289. /**
  290. * Flags returned by the OPEN request
  291. *
  292. * FOPEN_DIRECT_IO: bypass page cache for this open file
  293. * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
  294. * FOPEN_NONSEEKABLE: the file is not seekable
  295. * FOPEN_CACHE_DIR: allow caching this directory
  296. * FOPEN_STREAM: the file is stream-like (no file position at all)
  297. * FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_CACHE)
  298. * FOPEN_PARALLEL_DIRECT_WRITES: Allow concurrent direct writes on the same inode
  299. */
  300. #define FOPEN_DIRECT_IO (1 << 0)
  301. #define FOPEN_KEEP_CACHE (1 << 1)
  302. #define FOPEN_NONSEEKABLE (1 << 2)
  303. #define FOPEN_CACHE_DIR (1 << 3)
  304. #define FOPEN_STREAM (1 << 4)
  305. #define FOPEN_NOFLUSH (1 << 5)
  306. #define FOPEN_PARALLEL_DIRECT_WRITES (1 << 6)
  307. /**
  308. * INIT request/reply flags
  309. *
  310. * FUSE_ASYNC_READ: asynchronous read requests
  311. * FUSE_POSIX_LOCKS: remote locking for POSIX file locks
  312. * FUSE_FILE_OPS: kernel sends file handle for fstat, etc... (not yet supported)
  313. * FUSE_ATOMIC_O_TRUNC: handles the O_TRUNC open flag in the filesystem
  314. * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
  315. * FUSE_BIG_WRITES: filesystem can handle write size larger than 4kB
  316. * FUSE_DONT_MASK: don't apply umask to file mode on create operations
  317. * FUSE_SPLICE_WRITE: kernel supports splice write on the device
  318. * FUSE_SPLICE_MOVE: kernel supports splice move on the device
  319. * FUSE_SPLICE_READ: kernel supports splice read on the device
  320. * FUSE_FLOCK_LOCKS: remote locking for BSD style file locks
  321. * FUSE_HAS_IOCTL_DIR: kernel supports ioctl on directories
  322. * FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages
  323. * FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one)
  324. * FUSE_READDIRPLUS_AUTO: adaptive readdirplus
  325. * FUSE_ASYNC_DIO: asynchronous direct I/O submission
  326. * FUSE_WRITEBACK_CACHE: use writeback cache for buffered writes
  327. * FUSE_NO_OPEN_SUPPORT: kernel supports zero-message opens
  328. * FUSE_PARALLEL_DIROPS: allow parallel lookups and readdir
  329. * FUSE_HANDLE_KILLPRIV: fs handles killing suid/sgid/cap on write/chown/trunc
  330. * FUSE_POSIX_ACL: filesystem supports posix acls
  331. * FUSE_ABORT_ERROR: reading the device after abort returns ECONNABORTED
  332. * FUSE_MAX_PAGES: init_out.max_pages contains the max number of req pages
  333. * FUSE_CACHE_SYMLINKS: cache READLINK responses
  334. * FUSE_NO_OPENDIR_SUPPORT: kernel supports zero-message opendir
  335. * FUSE_EXPLICIT_INVAL_DATA: only invalidate cached pages on explicit request
  336. * FUSE_MAP_ALIGNMENT: init_out.map_alignment contains log2(byte alignment) for
  337. * foffset and moffset fields in struct
  338. * fuse_setupmapping_out and fuse_removemapping_one.
  339. * FUSE_SUBMOUNTS: kernel supports auto-mounting directory submounts
  340. * FUSE_HANDLE_KILLPRIV_V2: fs kills suid/sgid/cap on write/chown/trunc.
  341. * Upon write/truncate suid/sgid is only killed if caller
  342. * does not have CAP_FSETID. Additionally upon
  343. * write/truncate sgid is killed only if file has group
  344. * execute permission. (Same as Linux VFS behavior).
  345. * FUSE_SETXATTR_EXT: Server supports extended struct fuse_setxattr_in
  346. * FUSE_INIT_EXT: extended fuse_init_in request
  347. * FUSE_INIT_RESERVED: reserved, do not use
  348. * FUSE_SECURITY_CTX: add security context to create, mkdir, symlink, and
  349. * mknod
  350. * FUSE_HAS_INODE_DAX: use per inode DAX
  351. * FUSE_CREATE_SUPP_GROUP: add supplementary group info to create, mkdir,
  352. * symlink and mknod (single group that matches parent)
  353. */
  354. #define FUSE_ASYNC_READ (1 << 0)
  355. #define FUSE_POSIX_LOCKS (1 << 1)
  356. #define FUSE_FILE_OPS (1 << 2)
  357. #define FUSE_ATOMIC_O_TRUNC (1 << 3)
  358. #define FUSE_EXPORT_SUPPORT (1 << 4)
  359. #define FUSE_BIG_WRITES (1 << 5)
  360. #define FUSE_DONT_MASK (1 << 6)
  361. #define FUSE_SPLICE_WRITE (1 << 7)
  362. #define FUSE_SPLICE_MOVE (1 << 8)
  363. #define FUSE_SPLICE_READ (1 << 9)
  364. #define FUSE_FLOCK_LOCKS (1 << 10)
  365. #define FUSE_HAS_IOCTL_DIR (1 << 11)
  366. #define FUSE_AUTO_INVAL_DATA (1 << 12)
  367. #define FUSE_DO_READDIRPLUS (1 << 13)
  368. #define FUSE_READDIRPLUS_AUTO (1 << 14)
  369. #define FUSE_ASYNC_DIO (1 << 15)
  370. #define FUSE_WRITEBACK_CACHE (1 << 16)
  371. #define FUSE_NO_OPEN_SUPPORT (1 << 17)
  372. #define FUSE_PARALLEL_DIROPS (1 << 18)
  373. #define FUSE_HANDLE_KILLPRIV (1 << 19)
  374. #define FUSE_POSIX_ACL (1 << 20)
  375. #define FUSE_ABORT_ERROR (1 << 21)
  376. #define FUSE_MAX_PAGES (1 << 22)
  377. #define FUSE_CACHE_SYMLINKS (1 << 23)
  378. #define FUSE_NO_OPENDIR_SUPPORT (1 << 24)
  379. #define FUSE_EXPLICIT_INVAL_DATA (1 << 25)
  380. #define FUSE_MAP_ALIGNMENT (1 << 26)
  381. #define FUSE_SUBMOUNTS (1 << 27)
  382. #define FUSE_HANDLE_KILLPRIV_V2 (1 << 28)
  383. #define FUSE_SETXATTR_EXT (1 << 29)
  384. #define FUSE_INIT_EXT (1 << 30)
  385. #define FUSE_INIT_RESERVED (1 << 31)
  386. /* bits 32..63 get shifted down 32 bits into the flags2 field */
  387. #define FUSE_SECURITY_CTX (1ULL << 32)
  388. #define FUSE_HAS_INODE_DAX (1ULL << 33)
  389. #define FUSE_CREATE_SUPP_GROUP (1ULL << 34)
  390. /**
  391. * CUSE INIT request/reply flags
  392. *
  393. * CUSE_UNRESTRICTED_IOCTL: use unrestricted ioctl
  394. */
  395. #define CUSE_UNRESTRICTED_IOCTL (1 << 0)
  396. /**
  397. * Release flags
  398. */
  399. #define FUSE_RELEASE_FLUSH (1 << 0)
  400. #define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1)
  401. /**
  402. * Getattr flags
  403. */
  404. #define FUSE_GETATTR_FH (1 << 0)
  405. /**
  406. * Lock flags
  407. */
  408. #define FUSE_LK_FLOCK (1 << 0)
  409. /**
  410. * WRITE flags
  411. *
  412. * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed
  413. * FUSE_WRITE_LOCKOWNER: lock_owner field is valid
  414. * FUSE_WRITE_KILL_SUIDGID: kill suid and sgid bits
  415. */
  416. #define FUSE_WRITE_CACHE (1 << 0)
  417. #define FUSE_WRITE_LOCKOWNER (1 << 1)
  418. #define FUSE_WRITE_KILL_SUIDGID (1 << 2)
  419. /* Obsolete alias; this flag implies killing suid/sgid only. */
  420. #define FUSE_WRITE_KILL_PRIV FUSE_WRITE_KILL_SUIDGID
  421. /**
  422. * Read flags
  423. */
  424. #define FUSE_READ_LOCKOWNER (1 << 1)
  425. /**
  426. * Ioctl flags
  427. *
  428. * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
  429. * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed
  430. * FUSE_IOCTL_RETRY: retry with new iovecs
  431. * FUSE_IOCTL_32BIT: 32bit ioctl
  432. * FUSE_IOCTL_DIR: is a directory
  433. * FUSE_IOCTL_COMPAT_X32: x32 compat ioctl on 64bit machine (64bit time_t)
  434. *
  435. * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
  436. */
  437. #define FUSE_IOCTL_COMPAT (1 << 0)
  438. #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
  439. #define FUSE_IOCTL_RETRY (1 << 2)
  440. #define FUSE_IOCTL_32BIT (1 << 3)
  441. #define FUSE_IOCTL_DIR (1 << 4)
  442. #define FUSE_IOCTL_COMPAT_X32 (1 << 5)
  443. #define FUSE_IOCTL_MAX_IOV 256
  444. /**
  445. * Poll flags
  446. *
  447. * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify
  448. */
  449. #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
  450. /**
  451. * Fsync flags
  452. *
  453. * FUSE_FSYNC_FDATASYNC: Sync data only, not metadata
  454. */
  455. #define FUSE_FSYNC_FDATASYNC (1 << 0)
  456. /**
  457. * fuse_attr flags
  458. *
  459. * FUSE_ATTR_SUBMOUNT: Object is a submount root
  460. * FUSE_ATTR_DAX: Enable DAX for this file in per inode DAX mode
  461. */
  462. #define FUSE_ATTR_SUBMOUNT (1 << 0)
  463. #define FUSE_ATTR_DAX (1 << 1)
  464. /**
  465. * Open flags
  466. * FUSE_OPEN_KILL_SUIDGID: Kill suid and sgid if executable
  467. */
  468. #define FUSE_OPEN_KILL_SUIDGID (1 << 0)
  469. /**
  470. * setxattr flags
  471. * FUSE_SETXATTR_ACL_KILL_SGID: Clear SGID when system.posix_acl_access is set
  472. */
  473. #define FUSE_SETXATTR_ACL_KILL_SGID (1 << 0)
  474. /**
  475. * notify_inval_entry flags
  476. * FUSE_EXPIRE_ONLY
  477. */
  478. #define FUSE_EXPIRE_ONLY (1 << 0)
  479. /**
  480. * extension type
  481. * FUSE_MAX_NR_SECCTX: maximum value of &fuse_secctx_header.nr_secctx
  482. * FUSE_EXT_GROUPS: &fuse_supp_groups extension
  483. */
  484. enum fuse_ext_type {
  485. /* Types 0..31 are reserved for fuse_secctx_header */
  486. FUSE_MAX_NR_SECCTX = 31,
  487. FUSE_EXT_GROUPS = 32,
  488. };
  489. enum fuse_opcode {
  490. FUSE_LOOKUP = 1,
  491. FUSE_FORGET = 2, /* no reply */
  492. FUSE_GETATTR = 3,
  493. FUSE_SETATTR = 4,
  494. FUSE_READLINK = 5,
  495. FUSE_SYMLINK = 6,
  496. FUSE_MKNOD = 8,
  497. FUSE_MKDIR = 9,
  498. FUSE_UNLINK = 10,
  499. FUSE_RMDIR = 11,
  500. FUSE_RENAME = 12,
  501. FUSE_LINK = 13,
  502. FUSE_OPEN = 14,
  503. FUSE_READ = 15,
  504. FUSE_WRITE = 16,
  505. FUSE_STATFS = 17,
  506. FUSE_RELEASE = 18,
  507. FUSE_FSYNC = 20,
  508. FUSE_SETXATTR = 21,
  509. FUSE_GETXATTR = 22,
  510. FUSE_LISTXATTR = 23,
  511. FUSE_REMOVEXATTR = 24,
  512. FUSE_FLUSH = 25,
  513. FUSE_INIT = 26,
  514. FUSE_OPENDIR = 27,
  515. FUSE_READDIR = 28,
  516. FUSE_RELEASEDIR = 29,
  517. FUSE_FSYNCDIR = 30,
  518. FUSE_GETLK = 31,
  519. FUSE_SETLK = 32,
  520. FUSE_SETLKW = 33,
  521. FUSE_ACCESS = 34,
  522. FUSE_CREATE = 35,
  523. FUSE_INTERRUPT = 36,
  524. FUSE_BMAP = 37,
  525. FUSE_DESTROY = 38,
  526. FUSE_IOCTL = 39,
  527. FUSE_POLL = 40,
  528. FUSE_NOTIFY_REPLY = 41,
  529. FUSE_BATCH_FORGET = 42,
  530. FUSE_FALLOCATE = 43,
  531. FUSE_READDIRPLUS = 44,
  532. FUSE_RENAME2 = 45,
  533. FUSE_LSEEK = 46,
  534. FUSE_COPY_FILE_RANGE = 47,
  535. FUSE_SETUPMAPPING = 48,
  536. FUSE_REMOVEMAPPING = 49,
  537. FUSE_SYNCFS = 50,
  538. FUSE_TMPFILE = 51,
  539. /* CUSE specific operations */
  540. CUSE_INIT = 4096,
  541. /* Reserved opcodes: helpful to detect structure endian-ness */
  542. CUSE_INIT_BSWAP_RESERVED = 1048576, /* CUSE_INIT << 8 */
  543. FUSE_INIT_BSWAP_RESERVED = 436207616, /* FUSE_INIT << 24 */
  544. };
  545. enum fuse_notify_code {
  546. FUSE_NOTIFY_POLL = 1,
  547. FUSE_NOTIFY_INVAL_INODE = 2,
  548. FUSE_NOTIFY_INVAL_ENTRY = 3,
  549. FUSE_NOTIFY_STORE = 4,
  550. FUSE_NOTIFY_RETRIEVE = 5,
  551. FUSE_NOTIFY_DELETE = 6,
  552. FUSE_NOTIFY_CODE_MAX,
  553. };
  554. /* The read buffer is required to be at least 8k, but may be much larger */
  555. #define FUSE_MIN_READ_BUFFER 8192
  556. #define FUSE_COMPAT_ENTRY_OUT_SIZE 120
  557. struct fuse_entry_out {
  558. uint64_t nodeid; /* Inode ID */
  559. uint64_t generation; /* Inode generation: nodeid:gen must
  560. be unique for the fs's lifetime */
  561. uint64_t entry_valid; /* Cache timeout for the name */
  562. uint64_t attr_valid; /* Cache timeout for the attributes */
  563. uint32_t entry_valid_nsec;
  564. uint32_t attr_valid_nsec;
  565. struct fuse_attr attr;
  566. };
  567. struct fuse_forget_in {
  568. uint64_t nlookup;
  569. };
  570. struct fuse_forget_one {
  571. uint64_t nodeid;
  572. uint64_t nlookup;
  573. };
  574. struct fuse_batch_forget_in {
  575. uint32_t count;
  576. uint32_t dummy;
  577. };
  578. struct fuse_getattr_in {
  579. uint32_t getattr_flags;
  580. uint32_t dummy;
  581. uint64_t fh;
  582. };
  583. #define FUSE_COMPAT_ATTR_OUT_SIZE 96
  584. struct fuse_attr_out {
  585. uint64_t attr_valid; /* Cache timeout for the attributes */
  586. uint32_t attr_valid_nsec;
  587. uint32_t dummy;
  588. struct fuse_attr attr;
  589. };
  590. #define FUSE_COMPAT_MKNOD_IN_SIZE 8
  591. struct fuse_mknod_in {
  592. uint32_t mode;
  593. uint32_t rdev;
  594. uint32_t umask;
  595. uint32_t padding;
  596. };
  597. struct fuse_mkdir_in {
  598. uint32_t mode;
  599. uint32_t umask;
  600. };
  601. struct fuse_rename_in {
  602. uint64_t newdir;
  603. };
  604. struct fuse_rename2_in {
  605. uint64_t newdir;
  606. uint32_t flags;
  607. uint32_t padding;
  608. };
  609. struct fuse_link_in {
  610. uint64_t oldnodeid;
  611. };
  612. struct fuse_setattr_in {
  613. uint32_t valid;
  614. uint32_t padding;
  615. uint64_t fh;
  616. uint64_t size;
  617. uint64_t lock_owner;
  618. uint64_t atime;
  619. uint64_t mtime;
  620. uint64_t ctime;
  621. uint32_t atimensec;
  622. uint32_t mtimensec;
  623. uint32_t ctimensec;
  624. uint32_t mode;
  625. uint32_t unused4;
  626. uint32_t uid;
  627. uint32_t gid;
  628. uint32_t unused5;
  629. };
  630. struct fuse_open_in {
  631. uint32_t flags;
  632. uint32_t open_flags; /* FUSE_OPEN_... */
  633. };
  634. struct fuse_create_in {
  635. uint32_t flags;
  636. uint32_t mode;
  637. uint32_t umask;
  638. uint32_t open_flags; /* FUSE_OPEN_... */
  639. };
  640. struct fuse_open_out {
  641. uint64_t fh;
  642. uint32_t open_flags;
  643. uint32_t padding;
  644. };
  645. struct fuse_release_in {
  646. uint64_t fh;
  647. uint32_t flags;
  648. uint32_t release_flags;
  649. uint64_t lock_owner;
  650. };
  651. struct fuse_flush_in {
  652. uint64_t fh;
  653. uint32_t unused;
  654. uint32_t padding;
  655. uint64_t lock_owner;
  656. };
  657. struct fuse_read_in {
  658. uint64_t fh;
  659. uint64_t offset;
  660. uint32_t size;
  661. uint32_t read_flags;
  662. uint64_t lock_owner;
  663. uint32_t flags;
  664. uint32_t padding;
  665. };
  666. #define FUSE_COMPAT_WRITE_IN_SIZE 24
  667. struct fuse_write_in {
  668. uint64_t fh;
  669. uint64_t offset;
  670. uint32_t size;
  671. uint32_t write_flags;
  672. uint64_t lock_owner;
  673. uint32_t flags;
  674. uint32_t padding;
  675. };
  676. struct fuse_write_out {
  677. uint32_t size;
  678. uint32_t padding;
  679. };
  680. #define FUSE_COMPAT_STATFS_SIZE 48
  681. struct fuse_statfs_out {
  682. struct fuse_kstatfs st;
  683. };
  684. struct fuse_fsync_in {
  685. uint64_t fh;
  686. uint32_t fsync_flags;
  687. uint32_t padding;
  688. };
  689. #define FUSE_COMPAT_SETXATTR_IN_SIZE 8
  690. struct fuse_setxattr_in {
  691. uint32_t size;
  692. uint32_t flags;
  693. uint32_t setxattr_flags;
  694. uint32_t padding;
  695. };
  696. struct fuse_getxattr_in {
  697. uint32_t size;
  698. uint32_t padding;
  699. };
  700. struct fuse_getxattr_out {
  701. uint32_t size;
  702. uint32_t padding;
  703. };
  704. struct fuse_lk_in {
  705. uint64_t fh;
  706. uint64_t owner;
  707. struct fuse_file_lock lk;
  708. uint32_t lk_flags;
  709. uint32_t padding;
  710. };
  711. struct fuse_lk_out {
  712. struct fuse_file_lock lk;
  713. };
  714. struct fuse_access_in {
  715. uint32_t mask;
  716. uint32_t padding;
  717. };
  718. struct fuse_init_in {
  719. uint32_t major;
  720. uint32_t minor;
  721. uint32_t max_readahead;
  722. uint32_t flags;
  723. uint32_t flags2;
  724. uint32_t unused[11];
  725. };
  726. #define FUSE_COMPAT_INIT_OUT_SIZE 8
  727. #define FUSE_COMPAT_22_INIT_OUT_SIZE 24
  728. struct fuse_init_out {
  729. uint32_t major;
  730. uint32_t minor;
  731. uint32_t max_readahead;
  732. uint32_t flags;
  733. uint16_t max_background;
  734. uint16_t congestion_threshold;
  735. uint32_t max_write;
  736. uint32_t time_gran;
  737. uint16_t max_pages;
  738. uint16_t map_alignment;
  739. uint32_t flags2;
  740. uint32_t unused[7];
  741. };
  742. #define CUSE_INIT_INFO_MAX 4096
  743. struct cuse_init_in {
  744. uint32_t major;
  745. uint32_t minor;
  746. uint32_t unused;
  747. uint32_t flags;
  748. };
  749. struct cuse_init_out {
  750. uint32_t major;
  751. uint32_t minor;
  752. uint32_t unused;
  753. uint32_t flags;
  754. uint32_t max_read;
  755. uint32_t max_write;
  756. uint32_t dev_major; /* chardev major */
  757. uint32_t dev_minor; /* chardev minor */
  758. uint32_t spare[10];
  759. };
  760. struct fuse_interrupt_in {
  761. uint64_t unique;
  762. };
  763. struct fuse_bmap_in {
  764. uint64_t block;
  765. uint32_t blocksize;
  766. uint32_t padding;
  767. };
  768. struct fuse_bmap_out {
  769. uint64_t block;
  770. };
  771. struct fuse_ioctl_in {
  772. uint64_t fh;
  773. uint32_t flags;
  774. uint32_t cmd;
  775. uint64_t arg;
  776. uint32_t in_size;
  777. uint32_t out_size;
  778. };
  779. struct fuse_ioctl_iovec {
  780. uint64_t base;
  781. uint64_t len;
  782. };
  783. struct fuse_ioctl_out {
  784. int32_t result;
  785. uint32_t flags;
  786. uint32_t in_iovs;
  787. uint32_t out_iovs;
  788. };
  789. struct fuse_poll_in {
  790. uint64_t fh;
  791. uint64_t kh;
  792. uint32_t flags;
  793. uint32_t events;
  794. };
  795. struct fuse_poll_out {
  796. uint32_t revents;
  797. uint32_t padding;
  798. };
  799. struct fuse_notify_poll_wakeup_out {
  800. uint64_t kh;
  801. };
  802. struct fuse_fallocate_in {
  803. uint64_t fh;
  804. uint64_t offset;
  805. uint64_t length;
  806. uint32_t mode;
  807. uint32_t padding;
  808. };
  809. struct fuse_in_header {
  810. uint32_t len;
  811. uint32_t opcode;
  812. uint64_t unique;
  813. uint64_t nodeid;
  814. uint32_t uid;
  815. uint32_t gid;
  816. uint32_t pid;
  817. uint16_t total_extlen; /* length of extensions in 8byte units */
  818. uint16_t padding;
  819. };
  820. struct fuse_out_header {
  821. uint32_t len;
  822. int32_t error;
  823. uint64_t unique;
  824. };
  825. struct fuse_dirent {
  826. uint64_t ino;
  827. uint64_t off;
  828. uint32_t namelen;
  829. uint32_t type;
  830. char name[];
  831. };
  832. /* Align variable length records to 64bit boundary */
  833. #define FUSE_REC_ALIGN(x) \
  834. (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
  835. #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
  836. #define FUSE_DIRENT_ALIGN(x) FUSE_REC_ALIGN(x)
  837. #define FUSE_DIRENT_SIZE(d) \
  838. FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
  839. struct fuse_direntplus {
  840. struct fuse_entry_out entry_out;
  841. struct fuse_dirent dirent;
  842. };
  843. #define FUSE_NAME_OFFSET_DIRENTPLUS \
  844. offsetof(struct fuse_direntplus, dirent.name)
  845. #define FUSE_DIRENTPLUS_SIZE(d) \
  846. FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen)
  847. struct fuse_notify_inval_inode_out {
  848. uint64_t ino;
  849. int64_t off;
  850. int64_t len;
  851. };
  852. struct fuse_notify_inval_entry_out {
  853. uint64_t parent;
  854. uint32_t namelen;
  855. uint32_t flags;
  856. };
  857. struct fuse_notify_delete_out {
  858. uint64_t parent;
  859. uint64_t child;
  860. uint32_t namelen;
  861. uint32_t padding;
  862. };
  863. struct fuse_notify_store_out {
  864. uint64_t nodeid;
  865. uint64_t offset;
  866. uint32_t size;
  867. uint32_t padding;
  868. };
  869. struct fuse_notify_retrieve_out {
  870. uint64_t notify_unique;
  871. uint64_t nodeid;
  872. uint64_t offset;
  873. uint32_t size;
  874. uint32_t padding;
  875. };
  876. /* Matches the size of fuse_write_in */
  877. struct fuse_notify_retrieve_in {
  878. uint64_t dummy1;
  879. uint64_t offset;
  880. uint32_t size;
  881. uint32_t dummy2;
  882. uint64_t dummy3;
  883. uint64_t dummy4;
  884. };
  885. /* Device ioctls: */
  886. #define FUSE_DEV_IOC_MAGIC 229
  887. #define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t)
  888. struct fuse_lseek_in {
  889. uint64_t fh;
  890. uint64_t offset;
  891. uint32_t whence;
  892. uint32_t padding;
  893. };
  894. struct fuse_lseek_out {
  895. uint64_t offset;
  896. };
  897. struct fuse_copy_file_range_in {
  898. uint64_t fh_in;
  899. uint64_t off_in;
  900. uint64_t nodeid_out;
  901. uint64_t fh_out;
  902. uint64_t off_out;
  903. uint64_t len;
  904. uint64_t flags;
  905. };
  906. #define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0)
  907. #define FUSE_SETUPMAPPING_FLAG_READ (1ull << 1)
  908. struct fuse_setupmapping_in {
  909. /* An already open handle */
  910. uint64_t fh;
  911. /* Offset into the file to start the mapping */
  912. uint64_t foffset;
  913. /* Length of mapping required */
  914. uint64_t len;
  915. /* Flags, FUSE_SETUPMAPPING_FLAG_* */
  916. uint64_t flags;
  917. /* Offset in Memory Window */
  918. uint64_t moffset;
  919. };
  920. struct fuse_removemapping_in {
  921. /* number of fuse_removemapping_one follows */
  922. uint32_t count;
  923. };
  924. struct fuse_removemapping_one {
  925. /* Offset into the dax window start the unmapping */
  926. uint64_t moffset;
  927. /* Length of mapping required */
  928. uint64_t len;
  929. };
  930. #define FUSE_REMOVEMAPPING_MAX_ENTRY \
  931. (PAGE_SIZE / sizeof(struct fuse_removemapping_one))
  932. struct fuse_syncfs_in {
  933. uint64_t padding;
  934. };
  935. /*
  936. * For each security context, send fuse_secctx with size of security context
  937. * fuse_secctx will be followed by security context name and this in turn
  938. * will be followed by actual context label.
  939. * fuse_secctx, name, context
  940. */
  941. struct fuse_secctx {
  942. uint32_t size;
  943. uint32_t padding;
  944. };
  945. /*
  946. * Contains the information about how many fuse_secctx structures are being
  947. * sent and what's the total size of all security contexts (including
  948. * size of fuse_secctx_header).
  949. *
  950. */
  951. struct fuse_secctx_header {
  952. uint32_t size;
  953. uint32_t nr_secctx;
  954. };
  955. /**
  956. * struct fuse_ext_header - extension header
  957. * @size: total size of this extension including this header
  958. * @type: type of extension
  959. *
  960. * This is made compatible with fuse_secctx_header by using type values >
  961. * FUSE_MAX_NR_SECCTX
  962. */
  963. struct fuse_ext_header {
  964. uint32_t size;
  965. uint32_t type;
  966. };
  967. /**
  968. * struct fuse_supp_groups - Supplementary group extension
  969. * @nr_groups: number of supplementary groups
  970. * @groups: flexible array of group IDs
  971. */
  972. struct fuse_supp_groups {
  973. uint32_t nr_groups;
  974. uint32_t groups[];
  975. };
  976. #endif /* _LINUX_FUSE_H */