fuse_kernel.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. // See the file LICENSE for copyright and licensing information.
  2. // Derived from FUSE's fuse_kernel.h, which carries this notice:
  3. /*
  4. This file defines the kernel interface of FUSE
  5. Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
  6. This -- and only this -- header file may also be distributed under
  7. the terms of the BSD Licence as follows:
  8. Copyright (C) 2001-2007 Miklos Szeredi. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions
  11. are met:
  12. 1. Redistributions of source code must retain the above copyright
  13. notice, this list of conditions and the following disclaimer.
  14. 2. Redistributions in binary form must reproduce the above copyright
  15. notice, this list of conditions and the following disclaimer in the
  16. documentation and/or other materials provided with the distribution.
  17. THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  18. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
  21. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. SUCH DAMAGE.
  28. */
  29. package fusekernel
  30. import (
  31. "fmt"
  32. "syscall"
  33. "unsafe"
  34. )
  35. // The FUSE version implemented by the package.
  36. const (
  37. ProtoVersionMinMajor = 7
  38. ProtoVersionMinMinor = 8
  39. ProtoVersionMaxMajor = 7
  40. ProtoVersionMaxMinor = 12
  41. )
  42. const (
  43. RootID = 1
  44. )
  45. type Kstatfs struct {
  46. Blocks uint64
  47. Bfree uint64
  48. Bavail uint64
  49. Files uint64
  50. Ffree uint64
  51. Bsize uint32
  52. Namelen uint32
  53. Frsize uint32
  54. Padding uint32
  55. Spare [6]uint32
  56. }
  57. type fileLock struct {
  58. Start uint64
  59. End uint64
  60. Type uint32
  61. Pid uint32
  62. }
  63. // GetattrFlags are bit flags that can be seen in GetattrRequest.
  64. type GetattrFlags uint32
  65. const (
  66. // Indicates the handle is valid.
  67. GetattrFh GetattrFlags = 1 << 0
  68. )
  69. var getattrFlagsNames = []flagName{
  70. {uint32(GetattrFh), "GetattrFh"},
  71. }
  72. func (fl GetattrFlags) String() string {
  73. return flagString(uint32(fl), getattrFlagsNames)
  74. }
  75. // The SetattrValid are bit flags describing which fields in the SetattrRequest
  76. // are included in the change.
  77. type SetattrValid uint32
  78. const (
  79. SetattrMode SetattrValid = 1 << 0
  80. SetattrUid SetattrValid = 1 << 1
  81. SetattrGid SetattrValid = 1 << 2
  82. SetattrSize SetattrValid = 1 << 3
  83. SetattrAtime SetattrValid = 1 << 4
  84. SetattrMtime SetattrValid = 1 << 5
  85. SetattrHandle SetattrValid = 1 << 6
  86. // Linux only(?)
  87. SetattrAtimeNow SetattrValid = 1 << 7
  88. SetattrMtimeNow SetattrValid = 1 << 8
  89. SetattrLockOwner SetattrValid = 1 << 9 // http://www.mail-archive.com/git-commits-head@vger.kernel.org/msg27852.html
  90. // OS X only
  91. SetattrCrtime SetattrValid = 1 << 28
  92. SetattrChgtime SetattrValid = 1 << 29
  93. SetattrBkuptime SetattrValid = 1 << 30
  94. SetattrFlags SetattrValid = 1 << 31
  95. )
  96. func (fl SetattrValid) Mode() bool { return fl&SetattrMode != 0 }
  97. func (fl SetattrValid) Uid() bool { return fl&SetattrUid != 0 }
  98. func (fl SetattrValid) Gid() bool { return fl&SetattrGid != 0 }
  99. func (fl SetattrValid) Size() bool { return fl&SetattrSize != 0 }
  100. func (fl SetattrValid) Atime() bool { return fl&SetattrAtime != 0 }
  101. func (fl SetattrValid) Mtime() bool { return fl&SetattrMtime != 0 }
  102. func (fl SetattrValid) Handle() bool { return fl&SetattrHandle != 0 }
  103. func (fl SetattrValid) AtimeNow() bool { return fl&SetattrAtimeNow != 0 }
  104. func (fl SetattrValid) MtimeNow() bool { return fl&SetattrMtimeNow != 0 }
  105. func (fl SetattrValid) LockOwner() bool { return fl&SetattrLockOwner != 0 }
  106. func (fl SetattrValid) Crtime() bool { return fl&SetattrCrtime != 0 }
  107. func (fl SetattrValid) Chgtime() bool { return fl&SetattrChgtime != 0 }
  108. func (fl SetattrValid) Bkuptime() bool { return fl&SetattrBkuptime != 0 }
  109. func (fl SetattrValid) Flags() bool { return fl&SetattrFlags != 0 }
  110. func (fl SetattrValid) String() string {
  111. return flagString(uint32(fl), setattrValidNames)
  112. }
  113. var setattrValidNames = []flagName{
  114. {uint32(SetattrMode), "SetattrMode"},
  115. {uint32(SetattrUid), "SetattrUid"},
  116. {uint32(SetattrGid), "SetattrGid"},
  117. {uint32(SetattrSize), "SetattrSize"},
  118. {uint32(SetattrAtime), "SetattrAtime"},
  119. {uint32(SetattrMtime), "SetattrMtime"},
  120. {uint32(SetattrHandle), "SetattrHandle"},
  121. {uint32(SetattrAtimeNow), "SetattrAtimeNow"},
  122. {uint32(SetattrMtimeNow), "SetattrMtimeNow"},
  123. {uint32(SetattrLockOwner), "SetattrLockOwner"},
  124. {uint32(SetattrCrtime), "SetattrCrtime"},
  125. {uint32(SetattrChgtime), "SetattrChgtime"},
  126. {uint32(SetattrBkuptime), "SetattrBkuptime"},
  127. {uint32(SetattrFlags), "SetattrFlags"},
  128. }
  129. // Flags that can be seen in OpenRequest.Flags.
  130. const (
  131. // Access modes. These are not 1-bit flags, but alternatives where
  132. // only one can be chosen. See the IsReadOnly etc convenience
  133. // methods.
  134. OpenReadOnly OpenFlags = syscall.O_RDONLY
  135. OpenWriteOnly OpenFlags = syscall.O_WRONLY
  136. OpenReadWrite OpenFlags = syscall.O_RDWR
  137. OpenAppend OpenFlags = syscall.O_APPEND
  138. OpenCreate OpenFlags = syscall.O_CREAT
  139. OpenExclusive OpenFlags = syscall.O_EXCL
  140. OpenSync OpenFlags = syscall.O_SYNC
  141. OpenTruncate OpenFlags = syscall.O_TRUNC
  142. )
  143. // OpenAccessModeMask is a bitmask that separates the access mode
  144. // from the other flags in OpenFlags.
  145. const OpenAccessModeMask OpenFlags = syscall.O_ACCMODE
  146. // OpenFlags are the O_FOO flags passed to open/create/etc calls. For
  147. // example, os.O_WRONLY | os.O_APPEND.
  148. type OpenFlags uint32
  149. func (fl OpenFlags) String() string {
  150. // O_RDONLY, O_RWONLY, O_RDWR are not flags
  151. s := accModeName(fl & OpenAccessModeMask)
  152. flags := uint32(fl &^ OpenAccessModeMask)
  153. if flags != 0 {
  154. s = s + "+" + flagString(flags, openFlagNames)
  155. }
  156. return s
  157. }
  158. // Return true if OpenReadOnly is set.
  159. func (fl OpenFlags) IsReadOnly() bool {
  160. return fl&OpenAccessModeMask == OpenReadOnly
  161. }
  162. // Return true if OpenWriteOnly is set.
  163. func (fl OpenFlags) IsWriteOnly() bool {
  164. return fl&OpenAccessModeMask == OpenWriteOnly
  165. }
  166. // Return true if OpenReadWrite is set.
  167. func (fl OpenFlags) IsReadWrite() bool {
  168. return fl&OpenAccessModeMask == OpenReadWrite
  169. }
  170. func accModeName(flags OpenFlags) string {
  171. switch flags {
  172. case OpenReadOnly:
  173. return "OpenReadOnly"
  174. case OpenWriteOnly:
  175. return "OpenWriteOnly"
  176. case OpenReadWrite:
  177. return "OpenReadWrite"
  178. default:
  179. return ""
  180. }
  181. }
  182. var openFlagNames = []flagName{
  183. {uint32(OpenCreate), "OpenCreate"},
  184. {uint32(OpenExclusive), "OpenExclusive"},
  185. {uint32(OpenTruncate), "OpenTruncate"},
  186. {uint32(OpenAppend), "OpenAppend"},
  187. {uint32(OpenSync), "OpenSync"},
  188. }
  189. // The OpenResponseFlags are returned in the OpenResponse.
  190. type OpenResponseFlags uint32
  191. const (
  192. OpenDirectIO OpenResponseFlags = 1 << 0 // bypass page cache for this open file
  193. OpenKeepCache OpenResponseFlags = 1 << 1 // don't invalidate the data cache on open
  194. OpenNonSeekable OpenResponseFlags = 1 << 2 // mark the file as non-seekable (not supported on OS X)
  195. OpenPurgeAttr OpenResponseFlags = 1 << 30 // OS X
  196. OpenPurgeUBC OpenResponseFlags = 1 << 31 // OS X
  197. )
  198. func (fl OpenResponseFlags) String() string {
  199. return flagString(uint32(fl), openResponseFlagNames)
  200. }
  201. var openResponseFlagNames = []flagName{
  202. {uint32(OpenDirectIO), "OpenDirectIO"},
  203. {uint32(OpenKeepCache), "OpenKeepCache"},
  204. {uint32(OpenNonSeekable), "OpenNonSeekable"},
  205. {uint32(OpenPurgeAttr), "OpenPurgeAttr"},
  206. {uint32(OpenPurgeUBC), "OpenPurgeUBC"},
  207. }
  208. // The InitFlags are used in the Init exchange.
  209. type InitFlags uint32
  210. const (
  211. InitAsyncRead InitFlags = 1 << 0
  212. InitPosixLocks InitFlags = 1 << 1
  213. InitFileOps InitFlags = 1 << 2
  214. InitAtomicTrunc InitFlags = 1 << 3
  215. InitExportSupport InitFlags = 1 << 4
  216. InitBigWrites InitFlags = 1 << 5
  217. InitDontMask InitFlags = 1 << 6
  218. InitSpliceWrite InitFlags = 1 << 7
  219. InitSpliceMove InitFlags = 1 << 8
  220. InitSpliceRead InitFlags = 1 << 9
  221. InitFlockLocks InitFlags = 1 << 10
  222. InitHasIoctlDir InitFlags = 1 << 11
  223. InitAutoInvalData InitFlags = 1 << 12
  224. InitDoReaddirplus InitFlags = 1 << 13
  225. InitReaddirplusAuto InitFlags = 1 << 14
  226. InitAsyncDIO InitFlags = 1 << 15
  227. InitWritebackCache InitFlags = 1 << 16
  228. InitNoOpenSupport InitFlags = 1 << 17
  229. InitCaseSensitive InitFlags = 1 << 29 // OS X only
  230. InitVolRename InitFlags = 1 << 30 // OS X only
  231. InitXtimes InitFlags = 1 << 31 // OS X only
  232. )
  233. type flagName struct {
  234. bit uint32
  235. name string
  236. }
  237. var initFlagNames = []flagName{
  238. {uint32(InitAsyncRead), "InitAsyncRead"},
  239. {uint32(InitPosixLocks), "InitPosixLocks"},
  240. {uint32(InitFileOps), "InitFileOps"},
  241. {uint32(InitAtomicTrunc), "InitAtomicTrunc"},
  242. {uint32(InitExportSupport), "InitExportSupport"},
  243. {uint32(InitBigWrites), "InitBigWrites"},
  244. {uint32(InitDontMask), "InitDontMask"},
  245. {uint32(InitSpliceWrite), "InitSpliceWrite"},
  246. {uint32(InitSpliceMove), "InitSpliceMove"},
  247. {uint32(InitSpliceRead), "InitSpliceRead"},
  248. {uint32(InitFlockLocks), "InitFlockLocks"},
  249. {uint32(InitHasIoctlDir), "InitHasIoctlDir"},
  250. {uint32(InitAutoInvalData), "InitAutoInvalData"},
  251. {uint32(InitDoReaddirplus), "InitDoReaddirplus"},
  252. {uint32(InitReaddirplusAuto), "InitReaddirplusAuto"},
  253. {uint32(InitAsyncDIO), "InitAsyncDIO"},
  254. {uint32(InitWritebackCache), "InitWritebackCache"},
  255. {uint32(InitNoOpenSupport), "InitNoOpenSupport"},
  256. {uint32(InitCaseSensitive), "InitCaseSensitive"},
  257. {uint32(InitVolRename), "InitVolRename"},
  258. {uint32(InitXtimes), "InitXtimes"},
  259. }
  260. func (fl InitFlags) String() string {
  261. return flagString(uint32(fl), initFlagNames)
  262. }
  263. func flagString(f uint32, names []flagName) string {
  264. var s string
  265. if f == 0 {
  266. return "0"
  267. }
  268. for _, n := range names {
  269. if f&n.bit != 0 {
  270. s += "+" + n.name
  271. f &^= n.bit
  272. }
  273. }
  274. if f != 0 {
  275. s += fmt.Sprintf("%+#x", f)
  276. }
  277. return s[1:]
  278. }
  279. // The ReleaseFlags are used in the Release exchange.
  280. type ReleaseFlags uint32
  281. const (
  282. ReleaseFlush ReleaseFlags = 1 << 0
  283. )
  284. func (fl ReleaseFlags) String() string {
  285. return flagString(uint32(fl), releaseFlagNames)
  286. }
  287. var releaseFlagNames = []flagName{
  288. {uint32(ReleaseFlush), "ReleaseFlush"},
  289. }
  290. // Opcodes
  291. const (
  292. OpLookup = 1
  293. OpForget = 2 // no reply
  294. OpGetattr = 3
  295. OpSetattr = 4
  296. OpReadlink = 5
  297. OpSymlink = 6
  298. OpMknod = 8
  299. OpMkdir = 9
  300. OpUnlink = 10
  301. OpRmdir = 11
  302. OpRename = 12
  303. OpLink = 13
  304. OpOpen = 14
  305. OpRead = 15
  306. OpWrite = 16
  307. OpStatfs = 17
  308. OpRelease = 18
  309. OpFsync = 20
  310. OpSetxattr = 21
  311. OpGetxattr = 22
  312. OpListxattr = 23
  313. OpRemovexattr = 24
  314. OpFlush = 25
  315. OpInit = 26
  316. OpOpendir = 27
  317. OpReaddir = 28
  318. OpReleasedir = 29
  319. OpFsyncdir = 30
  320. OpGetlk = 31
  321. OpSetlk = 32
  322. OpSetlkw = 33
  323. OpAccess = 34
  324. OpCreate = 35
  325. OpInterrupt = 36
  326. OpBmap = 37
  327. OpDestroy = 38
  328. OpIoctl = 39 // Linux?
  329. OpPoll = 40 // Linux?
  330. // OS X
  331. OpSetvolname = 61
  332. OpGetxtimes = 62
  333. OpExchange = 63
  334. )
  335. type EntryOut struct {
  336. Nodeid uint64 // Inode ID
  337. Generation uint64 // Inode generation
  338. EntryValid uint64 // Cache timeout for the name
  339. AttrValid uint64 // Cache timeout for the attributes
  340. EntryValidNsec uint32
  341. AttrValidNsec uint32
  342. Attr Attr
  343. }
  344. func EntryOutSize(p Protocol) uintptr {
  345. switch {
  346. case p.LT(Protocol{7, 9}):
  347. return unsafe.Offsetof(EntryOut{}.Attr) + unsafe.Offsetof(EntryOut{}.Attr.Blksize)
  348. default:
  349. return unsafe.Sizeof(EntryOut{})
  350. }
  351. }
  352. type ForgetIn struct {
  353. Nlookup uint64
  354. }
  355. type GetattrIn struct {
  356. GetattrFlags uint32
  357. dummy uint32
  358. Fh uint64
  359. }
  360. type AttrOut struct {
  361. AttrValid uint64 // Cache timeout for the attributes
  362. AttrValidNsec uint32
  363. Dummy uint32
  364. Attr Attr
  365. }
  366. func AttrOutSize(p Protocol) uintptr {
  367. switch {
  368. case p.LT(Protocol{7, 9}):
  369. return unsafe.Offsetof(AttrOut{}.Attr) + unsafe.Offsetof(AttrOut{}.Attr.Blksize)
  370. default:
  371. return unsafe.Sizeof(AttrOut{})
  372. }
  373. }
  374. // OS X
  375. type GetxtimesOut struct {
  376. Bkuptime uint64
  377. Crtime uint64
  378. BkuptimeNsec uint32
  379. CrtimeNsec uint32
  380. }
  381. type MknodIn struct {
  382. Mode uint32
  383. Rdev uint32
  384. Umask uint32
  385. padding uint32
  386. // "filename\x00" follows.
  387. }
  388. func MknodInSize(p Protocol) uintptr {
  389. switch {
  390. case p.LT(Protocol{7, 12}):
  391. return unsafe.Offsetof(MknodIn{}.Umask)
  392. default:
  393. return unsafe.Sizeof(MknodIn{})
  394. }
  395. }
  396. type MkdirIn struct {
  397. Mode uint32
  398. Umask uint32
  399. // filename follows
  400. }
  401. func MkdirInSize(p Protocol) uintptr {
  402. switch {
  403. case p.LT(Protocol{7, 12}):
  404. return unsafe.Offsetof(MkdirIn{}.Umask) + 4
  405. default:
  406. return unsafe.Sizeof(MkdirIn{})
  407. }
  408. }
  409. type RenameIn struct {
  410. Newdir uint64
  411. // "oldname\x00newname\x00" follows
  412. }
  413. // OS X
  414. type ExchangeIn struct {
  415. Olddir uint64
  416. Newdir uint64
  417. Options uint64
  418. }
  419. type LinkIn struct {
  420. Oldnodeid uint64
  421. }
  422. type setattrInCommon struct {
  423. Valid uint32
  424. Padding uint32
  425. Fh uint64
  426. Size uint64
  427. LockOwner uint64 // unused on OS X?
  428. Atime uint64
  429. Mtime uint64
  430. Unused2 uint64
  431. AtimeNsec uint32
  432. MtimeNsec uint32
  433. Unused3 uint32
  434. Mode uint32
  435. Unused4 uint32
  436. Uid uint32
  437. Gid uint32
  438. Unused5 uint32
  439. }
  440. type OpenIn struct {
  441. Flags uint32
  442. Unused uint32
  443. }
  444. type OpenOut struct {
  445. Fh uint64
  446. OpenFlags uint32
  447. Padding uint32
  448. }
  449. type CreateIn struct {
  450. Flags uint32
  451. Mode uint32
  452. Umask uint32
  453. padding uint32
  454. }
  455. func CreateInSize(p Protocol) uintptr {
  456. switch {
  457. case p.LT(Protocol{7, 12}):
  458. return unsafe.Offsetof(CreateIn{}.Umask)
  459. default:
  460. return unsafe.Sizeof(CreateIn{})
  461. }
  462. }
  463. type ReleaseIn struct {
  464. Fh uint64
  465. Flags uint32
  466. ReleaseFlags uint32
  467. LockOwner uint32
  468. }
  469. type FlushIn struct {
  470. Fh uint64
  471. FlushFlags uint32
  472. Padding uint32
  473. LockOwner uint64
  474. }
  475. type ReadIn struct {
  476. Fh uint64
  477. Offset uint64
  478. Size uint32
  479. ReadFlags uint32
  480. LockOwner uint64
  481. Flags uint32
  482. padding uint32
  483. }
  484. func ReadInSize(p Protocol) uintptr {
  485. switch {
  486. case p.LT(Protocol{7, 9}):
  487. return unsafe.Offsetof(ReadIn{}.ReadFlags) + 4
  488. default:
  489. return unsafe.Sizeof(ReadIn{})
  490. }
  491. }
  492. // The ReadFlags are passed in ReadRequest.
  493. type ReadFlags uint32
  494. const (
  495. // LockOwner field is valid.
  496. ReadLockOwner ReadFlags = 1 << 1
  497. )
  498. var readFlagNames = []flagName{
  499. {uint32(ReadLockOwner), "ReadLockOwner"},
  500. }
  501. func (fl ReadFlags) String() string {
  502. return flagString(uint32(fl), readFlagNames)
  503. }
  504. type WriteIn struct {
  505. Fh uint64
  506. Offset uint64
  507. Size uint32
  508. WriteFlags uint32
  509. LockOwner uint64
  510. Flags uint32
  511. padding uint32
  512. }
  513. func WriteInSize(p Protocol) uintptr {
  514. switch {
  515. case p.LT(Protocol{7, 9}):
  516. return unsafe.Offsetof(WriteIn{}.LockOwner)
  517. default:
  518. return unsafe.Sizeof(WriteIn{})
  519. }
  520. }
  521. type WriteOut struct {
  522. Size uint32
  523. Padding uint32
  524. }
  525. // The WriteFlags are passed in WriteRequest.
  526. type WriteFlags uint32
  527. const (
  528. WriteCache WriteFlags = 1 << 0
  529. // LockOwner field is valid.
  530. WriteLockOwner WriteFlags = 1 << 1
  531. )
  532. var writeFlagNames = []flagName{
  533. {uint32(WriteCache), "WriteCache"},
  534. {uint32(WriteLockOwner), "WriteLockOwner"},
  535. }
  536. func (fl WriteFlags) String() string {
  537. return flagString(uint32(fl), writeFlagNames)
  538. }
  539. const compatStatfsSize = 48
  540. type StatfsOut struct {
  541. St Kstatfs
  542. }
  543. type FsyncIn struct {
  544. Fh uint64
  545. FsyncFlags uint32
  546. Padding uint32
  547. }
  548. type setxattrInCommon struct {
  549. Size uint32
  550. Flags uint32
  551. }
  552. func (setxattrInCommon) GetPosition() uint32 {
  553. return 0
  554. }
  555. type getxattrInCommon struct {
  556. Size uint32
  557. Padding uint32
  558. }
  559. func (getxattrInCommon) GetPosition() uint32 {
  560. return 0
  561. }
  562. type GetxattrOut struct {
  563. Size uint32
  564. Padding uint32
  565. }
  566. type ListxattrIn struct {
  567. Size uint32
  568. Padding uint32
  569. }
  570. type LkIn struct {
  571. Fh uint64
  572. Owner uint64
  573. Lk fileLock
  574. LkFlags uint32
  575. padding uint32
  576. }
  577. func LkInSize(p Protocol) uintptr {
  578. switch {
  579. case p.LT(Protocol{7, 9}):
  580. return unsafe.Offsetof(LkIn{}.LkFlags)
  581. default:
  582. return unsafe.Sizeof(LkIn{})
  583. }
  584. }
  585. type LkOut struct {
  586. Lk fileLock
  587. }
  588. type AccessIn struct {
  589. Mask uint32
  590. Padding uint32
  591. }
  592. type InitIn struct {
  593. Major uint32
  594. Minor uint32
  595. MaxReadahead uint32
  596. Flags uint32
  597. }
  598. const InitInSize = int(unsafe.Sizeof(InitIn{}))
  599. type InitOut struct {
  600. Major uint32
  601. Minor uint32
  602. MaxReadahead uint32
  603. Flags uint32
  604. Unused uint32
  605. MaxWrite uint32
  606. }
  607. type InterruptIn struct {
  608. Unique uint64
  609. }
  610. type BmapIn struct {
  611. Block uint64
  612. BlockSize uint32
  613. Padding uint32
  614. }
  615. type BmapOut struct {
  616. Block uint64
  617. }
  618. type InHeader struct {
  619. Len uint32
  620. Opcode uint32
  621. Unique uint64
  622. Nodeid uint64
  623. Uid uint32
  624. Gid uint32
  625. Pid uint32
  626. Padding uint32
  627. }
  628. const InHeaderSize = int(unsafe.Sizeof(InHeader{}))
  629. type OutHeader struct {
  630. Len uint32
  631. Error int32
  632. Unique uint64
  633. }
  634. type Dirent struct {
  635. Ino uint64
  636. Off uint64
  637. Namelen uint32
  638. Type uint32
  639. Name [0]byte
  640. }
  641. const DirentSize = 8 + 8 + 4 + 4
  642. const (
  643. NotifyCodePoll int32 = 1
  644. NotifyCodeInvalInode int32 = 2
  645. NotifyCodeInvalEntry int32 = 3
  646. )
  647. type NotifyInvalInodeOut struct {
  648. Ino uint64
  649. Off int64
  650. Len int64
  651. }
  652. type NotifyInvalEntryOut struct {
  653. Parent uint64
  654. Namelen uint32
  655. padding uint32
  656. }