fuser-ng 0.9.2

A higher-level path-oriented FUSE filesystem library with optional async support.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
// Public types exported by FuserNG.
//
// Copyright (c) 2026 by François NT, 2016-2022 by William R. Fraser
//

use crate::KernelConfig;
use std::ffi::{OsStr, OsString};
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::{Duration, SystemTime};

/// Inode number used by the public path-oriented API.
pub type Inode = u64;

/// Info about a request.
#[derive(Clone, Copy, Debug)]
pub struct RequestInfo {
    /// The unique ID assigned to this request by FUSE.
    pub unique: u64,
    /// The user ID of the process making the request.
    pub uid: u32,
    /// The group ID of the process making the request.
    pub gid: u32,
    /// The process ID of the process making the request.
    pub pid: u32,
}

/// A directory entry together with its attributes.
#[derive(Clone, Debug)]
pub struct DirectoryEntry {
    /// Name of the entry.
    pub name: OsString,
    /// Cache time-to-live for the entry and its attributes.
    pub ttl: Duration,
    /// Attributes of the entry.
    pub attr: FileAttr,
}

/// A directory entry without attributes for the legacy FUSE readdir operation.
#[cfg(feature = "legacy_readdir")]
#[derive(Clone, Debug)]
pub struct LegacyDirectoryEntry {
    /// Name of the entry.
    pub name: OsString,
    /// Kind of file (directory, file, pipe, etc.).
    pub kind: crate::FileType,
}

/// Filesystem statistics.
#[derive(Clone, Copy, Debug)]
pub struct Statfs {
    /// Total data blocks in the filesystem
    pub blocks: u64,
    /// Free blocks in filesystem
    pub bfree: u64,
    /// Free blocks available to unprivileged user
    pub bavail: u64,
    /// Total file nodes in filesystem
    pub files: u64,
    /// Free file nodes in filesystem
    pub ffree: u64,
    /// Optimal transfer block size
    pub bsize: u32,
    /// Maximum length of filenames
    pub namelen: u32,
    /// Fragment size
    pub frsize: u32,
}

/// File attributes.
#[derive(Clone, Copy, Debug)]
pub struct FileAttr {
    /// Size in bytes
    pub size: u64,
    /// Size in blocks
    pub blocks: u64,
    /// Time of last access
    pub atime: SystemTime,
    /// Time of last modification
    pub mtime: SystemTime,
    /// Time of last metadata change
    pub ctime: SystemTime,
    /// Time of creation (macOS only)
    pub crtime: SystemTime,
    /// Kind of file (directory, file, pipe, etc.)
    pub kind: crate::FileType,
    /// Permissions
    pub perm: u16,
    /// Number of hard links
    pub nlink: u32,
    /// User ID
    pub uid: u32,
    /// Group ID
    pub gid: u32,
    /// Device ID (if special file)
    pub rdev: u32,
    /// block size
    pub blksize: u32,
    /// Flags (macOS only; see chflags(2))
    pub flags: u32,
}

/// The return value for `create`: contains info on the newly-created file, as well as a handle to
/// the opened file.
#[derive(Clone, Debug)]
pub struct CreatedEntry {
    /// Entry cache time-to-live.
    pub ttl: Duration,
    /// Attributes returned for the created file.
    pub attr: FileAttr,
    /// File handle returned for the opened file.
    pub fh: u64,
    /// Open response flags returned to fuser.
    pub flags: u32,
}

/// Represents the return value from the `listxattr` and `getxattr` calls, which can be either a
/// size or contain data, depending on how they are called.
#[derive(Clone, Debug)]
pub enum Xattr {
    /// Size needed to read the attribute value or name list.
    Size(u32),
    /// Attribute data or null-terminated attribute name list.
    Data(Vec<u8>),
}

#[cfg(target_os = "macos")]
/// Extended timestamps available on macOS.
#[derive(Clone, Debug)]
pub struct XTimes {
    /// Time of the last backup.
    pub bkuptime: SystemTime,
    /// Time of creation.
    pub crtime: SystemTime,
}

/// Result for operations that return no data.
pub type ResultEmpty = std::io::Result<()>;
/// Result containing the cache duration and attributes of an entry.
pub type ResultEntry = std::io::Result<(Duration, FileAttr)>;
/// Result containing a file handle and FUSE open response flags.
pub type ResultOpen = std::io::Result<(u64, u32)>;
/// Result containing an owned byte buffer.
pub type ResultData = std::io::Result<Vec<u8>>;
/// Result containing one batch of directory entries and their attributes.
pub type ResultReaddirBatch = std::io::Result<Vec<DirectoryEntry>>;
#[cfg(feature = "legacy_readdir")]
/// Result containing one batch of legacy directory entries without attributes.
pub type ResultLegacyReaddirBatch = std::io::Result<Vec<LegacyDirectoryEntry>>;
/// Result containing a borrowed byte slice.
pub type ResultSlice<'a> = std::io::Result<&'a [u8]>;
/// Result containing the number of bytes written.
pub type ResultWrite = std::io::Result<u32>;
/// Result containing filesystem statistics.
pub type ResultStatfs = std::io::Result<Statfs>;
/// Result containing a newly created and opened entry.
pub type ResultCreate = std::io::Result<CreatedEntry>;
/// Result containing extended attribute data or its required size.
pub type ResultXattr = std::io::Result<Xattr>;

#[cfg(target_os = "macos")]
/// Result containing extended macOS timestamps.
pub type ResultXTimes = std::io::Result<XTimes>;

/// Dummy struct returned by the callback in the `read()` method. Cannot be constructed outside
/// this crate, `read()` requires you to return it, thus ensuring that you don't forget to call the
/// callback.
pub struct CallbackResult {
    pub(crate) _private: std::marker::PhantomData<()>,
}

/// Path resolved from an inode with the current inode number attached.
#[derive(Debug, Clone)]
pub struct ResolvedPath {
    parent: Arc<PathBuf>,
    name: Arc<OsStr>,
    ino: Inode,
}

impl ResolvedPath {
    /// Returns the full path by joining the parent path and entry name.
    pub fn full_path(&self) -> PathBuf {
        self.parent.join(self.name.as_ref())
    }
    /// Returns the final path component.
    pub fn name(&self) -> &OsStr {
        &self.name
    }
    /// Returns the inode associated with this resolved path.
    pub fn ino(&self) -> Inode {
        self.ino
    }
    /// Returns the parent directory path.
    pub fn parent_path(&self) -> Arc<PathBuf> {
        self.parent.clone()
    }
}

/// Entry name resolved relative to a parent directory path.
#[derive(Debug, Clone)]
pub struct EntryName {
    parent: Arc<PathBuf>,
    //parent_ino: Inode,
    name: Arc<OsStr>,
}

impl EntryName {
    /// Attaches an inode to this entry name.
    pub(crate) fn with(self, ino: Inode) -> ResolvedPath {
        ResolvedPath {
            parent: self.parent,
            name: self.name,
            ino,
        }
    }
    /// Creates an entry name from a parent folder path and child name.
    pub(crate) fn new(parent: FolderPath, name: Arc<OsStr>) -> Self {
        Self {
            parent: parent.0,
            name,
        }
    }
    /// Returns the full path by joining the parent path and entry name.
    pub fn full_path(&self) -> PathBuf {
        self.parent.join(self.name.as_ref())
    }
    /// Returns the final path component.
    pub fn name(&self) -> &OsStr {
        &self.name
    }

    /// Returns the parent directory path.
    pub fn parent_path(&self) -> Arc<PathBuf> {
        self.parent.clone()
    }
}

/// Entry path passed to callbacks that may run before or after inode resolution.
///
/// Lookup is used while resolving a parent/name pair before an inode is attached.
/// Resolved is used when the inode table already has an inode for the entry.
#[derive(Debug, Clone)]
pub enum EntryRef {
    /// Entry identified by a parent path and name before inode resolution.
    Lookup(EntryName),
    /// Entry whose inode has already been resolved.
    Resolved(ResolvedPath),
}

impl EntryRef {
    /// Returns the full path by joining the parent path and entry name.
    pub fn full_path(&self) -> PathBuf {
        match self {
            EntryRef::Lookup(this) => this.full_path(),
            EntryRef::Resolved(this) => this.full_path(),
        }
    }
    /// Returns the final path component.
    pub fn name(&self) -> &OsStr {
        match self {
            EntryRef::Lookup(this) => this.name(),
            EntryRef::Resolved(this) => this.name(),
        }
    }
    /// Returns the parent directory path.
    pub fn parent_path(&self) -> Arc<PathBuf> {
        match self {
            EntryRef::Lookup(this) => this.parent_path(),
            EntryRef::Resolved(this) => this.parent_path(),
        }
    }
}

/// Shared path for a directory entry in the inode table.
#[repr(transparent)]
#[derive(Debug)]
pub(crate) struct FolderPath(Arc<PathBuf>);

impl From<Arc<PathBuf>> for FolderPath {
    fn from(value: Arc<PathBuf>) -> Self {
        Self(value)
    }
}

impl From<&OsStr> for FolderPath {
    fn from(value: &OsStr) -> Self {
        Self(Arc::new(value.into()))
    }
}

impl Deref for FolderPath {
    type Target = Arc<PathBuf>;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

fn enosys_error<T>() -> std::io::Result<T> {
    Err(std::io::Error::from_raw_os_error(libc::ENOSYS))
}

/// This trait must be implemented to implement a filesystem with FuserNG.
///
/// Methods have default ENOSYS implementations, so a filesystem can implement only the operations
/// it supports.
///
/// ```no_run
/// use std::io;
/// use std::time::{Duration, SystemTime};
///
/// use fuser_ng::{EntryRef, FileAttr, FileType, Filesystem, RequestInfo, ResultEntry};
///
/// struct RootOnly;
///
/// impl Filesystem for RootOnly {
///     fn getattr(&self, _req: RequestInfo, path: &EntryRef, _fh: Option<u64>) -> ResultEntry {
///         if path.full_path() != std::path::Path::new("/") {
///             return Err(io::Error::from_raw_os_error(libc::ENOENT));
///         }
///
///         let now = SystemTime::now();
///
///         Ok((
///             Duration::from_secs(1),
///             FileAttr {
///                 size: 0,
///                 blocks: 0,
///                 atime: now,
///                 mtime: now,
///                 ctime: now,
///                 crtime: now,
///                 kind: FileType::Directory,
///                 perm: 0o755,
///                 nlink: 2,
///                 uid: 0,
///                 gid: 0,
///                 rdev: 0,
///                 blksize: 512,
///                 flags: 0,
///             },
///         ))
///     }
/// }
/// ```
#[allow(unused_variables)]
pub trait Filesystem {
    /// Called when the filesystem is mounted, before any other operation.
    ///
    /// * `req`: information about the FUSE request.
    /// * `config`: kernel configuration that may be adjusted before mounting.
    fn init(&self, req: RequestInfo, config: &mut KernelConfig) -> ResultEmpty {
        Ok(())
    }

    /// Called when the filesystem is unmounted.
    fn destroy(&self) {
        // Nothing.
    }

    /// Get the attributes of a filesystem entry.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the entry.
    /// * `fh`: a file handle if this is called on an open file.
    fn getattr(&self, req: RequestInfo, path: &EntryRef, fh: Option<u64>) -> ResultEntry {
        enosys_error()
    }

    // The following operations in the FUSE C API are all one kernel call: setattr
    // We split them out to match the C API's behavior.

    /// Change the mode of a filesystem entry.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the entry.
    /// * `fh`: a file handle if this is called on an open file.
    /// * `mode`: the mode to change the file to.
    fn chmod(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: Option<u64>,
        mode: u32,
    ) -> ResultEmpty {
        enosys_error()
    }

    /// Change the owner UID and/or group GID of a filesystem entry.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the entry.
    /// * `fh`: a file handle if this is called on an open file.
    /// * `uid`: new user ID for the file owner. If `None`, leave the UID unchanged.
    /// * `gid`: new group ID for the file. If `None`, leave the GID unchanged.
    fn chown(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: Option<u64>,
        uid: Option<u32>,
        gid: Option<u32>,
    ) -> ResultEmpty {
        enosys_error()
    }

    /// Set the length of a file.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `fh`: a file handle if this is called on an open file.
    /// * `size`: new file length in bytes.
    fn truncate(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: Option<u64>,
        size: u64,
    ) -> ResultEmpty {
        enosys_error()
    }

    /// Set the timestamps of a filesystem entry.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the entry.
    /// * `fh`: a file handle if this is called on an open file.
    /// * `atime`: new access time, or `None` to leave it unchanged.
    /// * `mtime`: new modification time, or `None` to leave it unchanged.
    fn utimens(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: Option<u64>,
        atime: Option<SystemTime>,
        mtime: Option<SystemTime>,
    ) -> ResultEmpty {
        enosys_error()
    }

    /// Set the timestamps of a filesystem entry using the additional macOS options.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the entry.
    /// * `fh`: a file handle if this is called on an open file.
    /// * `crtime`: new creation time, or `None` to leave it unchanged.
    /// * `chgtime`: new metadata change time, or `None` to leave it unchanged.
    /// * `bkuptime`: new backup time, or `None` to leave it unchanged.
    /// * `flags`: new macOS file flags, or `None` to leave them unchanged.
    #[allow(clippy::too_many_arguments)]
    fn utimens_macos(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: Option<u64>,
        crtime: Option<SystemTime>,
        chgtime: Option<SystemTime>,
        bkuptime: Option<SystemTime>,
        flags: Option<u32>,
    ) -> ResultEmpty {
        enosys_error()
    }

    // END OF SETATTR FUNCTIONS

    /// Read a symbolic link.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the symbolic link.
    fn readlink(&self, req: RequestInfo, path: &ResolvedPath) -> ResultData {
        enosys_error()
    }

    /// Create a special file.
    ///
    /// * `req`: information about the FUSE request.
    /// * `entry`: entry name resolved relative to its parent directory.
    /// * `mode`: mode for the new entry.
    /// * `rdev`: device number when mode contains `S_IFCHR` or `S_IFBLK`; ignored otherwise.
    fn mknod(&self, req: RequestInfo, entry: &EntryName, mode: u32, rdev: u32) -> ResultEntry {
        enosys_error()
    }

    /// Create a directory.
    ///
    /// * `req`: information about the FUSE request.
    /// * `entry`: directory name resolved relative to its parent directory.
    /// * `mode`: permissions for the new directory.
    fn mkdir(&self, req: RequestInfo, entry: &EntryName, mode: u32) -> ResultEntry {
        enosys_error()
    }

    /// Remove a file.
    ///
    /// * `req`: information about the FUSE request.
    /// * `entry`: file name resolved relative to its parent directory.
    fn unlink(&self, req: RequestInfo, entry: &EntryName) -> ResultEmpty {
        enosys_error()
    }

    /// Remove a directory.
    ///
    /// * `req`: information about the FUSE request.
    /// * `entry`: directory name resolved relative to its parent directory.
    fn rmdir(&self, req: RequestInfo, entry: &EntryName) -> ResultEmpty {
        enosys_error()
    }

    /// Create a symbolic link.
    ///
    /// * `req`: information about the FUSE request.
    /// * `entry`: symbolic link name resolved relative to its parent directory.
    /// * `target`: path (may be relative or absolute) to the target of the link.
    fn symlink(&self, req: RequestInfo, entry: &EntryName, target: &Path) -> ResultEntry {
        enosys_error()
    }

    /// Rename a filesystem entry.
    ///
    /// * `req`: information about the FUSE request.
    /// * `entry`: current entry name resolved relative to its parent directory.
    /// * `new_entry`: new entry name resolved relative to its parent directory.
    fn rename(&self, req: RequestInfo, entry: &EntryName, new_entry: &EntryName) -> ResultEmpty {
        enosys_error()
    }

    /// Create a hard link.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to an existing file.
    /// * `new_entry`: new link name resolved relative to its parent directory.
    fn link(&self, req: RequestInfo, path: &ResolvedPath, new_entry: &EntryName) -> ResultEntry {
        enosys_error()
    }

    /// Open a file.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `flags`: one of `O_RDONLY`, `O_WRONLY`, or `O_RDWR`, plus any additional flags.
    ///
    /// Return a tuple of (file handle, flags). The file handle will be passed to any subsequent
    /// calls that operate on the file, and can be any value you choose, though it should allow
    /// your filesystem to identify the open file even without path information.
    fn open(&self, req: RequestInfo, path: &ResolvedPath, flags: u32) -> ResultOpen {
        enosys_error()
    }

    /// Read from a file.
    ///
    /// Reading past the end of the file is not an error. Return only the available data up to the
    /// end of the file, which may be fewer bytes than requested or even zero bytes. Do not extend
    /// the file in this case.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `fh`: file handle returned from the `open` call.
    /// * `offset`: offset into the file to start reading.
    /// * `size`: number of bytes to read.
    /// * `callback`: a callback that must be invoked to return the result of the operation: either
    ///   the result data as a slice, or an error code.
    ///
    /// Return the return value from the `callback` function.
    fn read(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: u64,
        offset: u64,
        size: u32,
        callback: impl FnOnce(ResultSlice<'_>) -> CallbackResult,
    ) -> CallbackResult {
        callback(enosys_error())
    }

    /// Write to a file.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `fh`: file handle returned from the `open` call.
    /// * `offset`: offset into the file to start writing.
    /// * `data`: data to write.
    /// * flags: file open flags.
    ///
    /// Return the number of bytes written.
    fn write(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: u64,
        offset: u64,
        data: Vec<u8>,
        flags: u32,
    ) -> ResultWrite {
        enosys_error()
    }

    /// Called each time a program calls `close` on an open file.
    ///
    /// Note that because file descriptors can be duplicated (by `dup`, `dup2`, `fork`) this may be
    /// called multiple times for a given file handle. The main use of this function is if the
    /// filesystem would like to return an error to the `close` call. Note that most programs
    /// ignore the return value of `close`, though.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `fh`: file handle returned from the `open` call.
    /// * `lock_owner`: if the filesystem supports locking (`setlk`, `getlk`), remove all locks
    ///   belonging to this lock owner.
    fn flush(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: u64,
        lock_owner: u64,
    ) -> ResultEmpty {
        enosys_error()
    }

    /// Called when an open file is closed.
    ///
    /// There will be one of these for each `open` call. After `release`, no more calls will be
    /// made with the given file handle.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `fh`: file handle returned from the `open` call.
    /// * `flags`: the flags passed when the file was opened.
    /// * `lock_owner`: if the filesystem supports locking (`setlk`, `getlk`), remove all locks
    ///   belonging to this lock owner.
    /// * `flush`: whether pending data must be flushed or not.
    fn release(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: u64,
        flags: u32,
        lock_owner: u64,
        flush: bool,
    ) -> ResultEmpty {
        enosys_error()
    }

    /// Write out any pending changes to a file.
    ///
    /// When this returns, data should be written to persistent storage.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `fh`: file handle returned from the `open` call.
    /// * `datasync`: if `false`, also write metadata; otherwise, write only file data.
    fn fsync(&self, req: RequestInfo, path: &ResolvedPath, fh: u64, datasync: bool) -> ResultEmpty {
        enosys_error()
    }

    /// Open a directory.
    ///
    /// Analogous to the `opendir` call.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the directory.
    /// * `flags`: file access flags. Will contain `O_DIRECTORY` at least.
    ///
    /// Return a tuple of (file handle, flags). The file handle will be passed to any subsequent
    /// calls that operate on the directory, and can be any value you choose, though it should
    /// allow your filesystem to identify the open directory even without path information.
    fn opendir(&self, req: RequestInfo, path: &ResolvedPath, flags: u32) -> ResultOpen {
        enosys_error()
    }

    /// Gets directory entries together with their attributes.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the directory.
    /// * `fh`: file handle returned from the `opendir` call.
    ///
    /// Results are produced in batches and retained by FuserNG until releasedir, allowing
    /// offsets previously returned to FUSE to be revisited.
    fn readdir(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: u64,
    ) -> impl Iterator<Item = ResultReaddirBatch> + Send + 'static {
        std::iter::once(enosys_error())
    }

    /// Gets directory entries without attributes for the legacy FUSE readdir operation.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the directory.
    /// * `fh`: file handle returned from the `opendir` call.
    ///
    /// Results are produced in batches and retained by FuserNG until releasedir, allowing
    /// offsets previously returned to FUSE to be revisited.
    #[cfg(feature = "legacy_readdir")]
    fn legacy_readdir(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: u64,
    ) -> impl Iterator<Item = ResultLegacyReaddirBatch> + Send + 'static {
        std::iter::once(enosys_error())
    }

    /// Close an open directory.
    ///
    /// This will be called exactly once for each `opendir` call.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the directory.
    /// * `fh`: file handle returned from the `opendir` call.
    /// * `flags`: the file access flags passed to the `opendir` call.
    fn releasedir(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: u64,
        flags: u32,
    ) -> ResultEmpty {
        enosys_error()
    }

    /// Write out any pending changes to a directory.
    ///
    /// Analogous to the `fsync` call.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the directory.
    /// * `fh`: file handle returned from the `opendir` call.
    /// * `datasync`: if `false`, also write metadata; otherwise, write only directory data.
    fn fsyncdir(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        fh: u64,
        datasync: bool,
    ) -> ResultEmpty {
        enosys_error()
    }

    /// Get filesystem statistics.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to a directory in the filesystem.
    ///
    /// See the `Statfs` struct for more details.
    fn statfs(&self, req: RequestInfo, path: &ResolvedPath) -> ResultStatfs {
        enosys_error()
    }

    /// Set an extended attribute on a file.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `name`: attribute name.
    /// * `value`: the data to set the value to.
    /// * `flags`: can be either `XATTR_CREATE` or `XATTR_REPLACE`.
    /// * `position`: offset into the attribute value to write data.
    fn setxattr(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        name: &OsStr,
        value: &[u8],
        flags: u32,
        position: u32,
    ) -> ResultEmpty {
        enosys_error()
    }

    /// Get an extended attribute from a file.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `name`: attribute name.
    /// * `size`: the maximum number of bytes to read.
    ///
    /// If `size` is 0, return `Xattr::Size(n)` where `n` is the size of the attribute data.
    /// Otherwise, return `Xattr::Data(data)` with the requested data.
    fn getxattr(
        &self,
        req: RequestInfo,
        path: &ResolvedPath,
        name: &OsStr,
        size: u32,
    ) -> ResultXattr {
        enosys_error()
    }

    /// List extended attributes for a file.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `size`: maximum number of bytes to return.
    ///
    /// If `size` is 0, return `Xattr::Size(n)` where `n` is the size required for the list of
    /// attribute names.
    /// Otherwise, return `Xattr::Data(data)` where `data` is all the null-terminated attribute
    /// names.
    fn listxattr(&self, req: RequestInfo, path: &ResolvedPath, size: u32) -> ResultXattr {
        enosys_error()
    }

    /// Remove an extended attribute from a file.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `name`: name of the attribute to remove.
    fn removexattr(&self, req: RequestInfo, path: &ResolvedPath, name: &OsStr) -> ResultEmpty {
        enosys_error()
    }

    /// Check for access to a file.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file.
    /// * `mask`: mode bits to check for access to.
    ///
    /// Return `Ok(())` if all requested permissions are allowed, otherwise return `Err(EACCES)`
    /// or another appropriate error code (e.g. `ENOENT` if the file doesn't exist).
    fn access(&self, req: RequestInfo, path: &ResolvedPath, mask: u32) -> ResultEmpty {
        enosys_error()
    }

    /// Create and open a new file.
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the new file.
    /// * `mode`: the mode to set on the new file.
    /// * `flags`: flags that would be passed to `open`.
    ///
    /// Return a `CreatedEntry` containing the new file's attributes and a file handle. See the
    /// documentation for `open` for more information about file handles.
    fn create(&self, req: RequestInfo, path: &ResolvedPath, mode: u32, flags: u32) -> ResultCreate {
        enosys_error()
    }

    // getlk

    // setlk

    // bmap

    /// macOS only: Rename the volume.
    ///
    /// * `req`: information about the FUSE request.
    /// * `name`: new name for the volume.
    #[cfg(target_os = "macos")]
    fn setvolname(&self, req: RequestInfo, name: &OsStr) -> ResultEmpty {
        enosys_error()
    }

    // exchange (macOS only, undocumented)

    /// macOS only: Query extended times (bkuptime and crtime).
    ///
    /// * `req`: information about the FUSE request.
    /// * `path`: path to the file to get the times for.
    ///
    /// Return an `XTimes` struct containing the times, or an appropriate error.
    #[cfg(target_os = "macos")]
    fn getxtimes(&self, req: RequestInfo, path: &ResolvedPath) -> ResultXTimes {
        Err(libc::ENOSYS)
    }
}