Skip to main content

fuser_ng/
types.rs

1// Public types exported by FuserNG.
2//
3// Copyright (c) 2026 by François NT, 2016-2022 by William R. Fraser
4//
5
6use crate::KernelConfig;
7use std::ffi::{OsStr, OsString};
8use std::ops::Deref;
9use std::path::{Path, PathBuf};
10use std::sync::Arc;
11use std::time::{Duration, SystemTime};
12
13/// Inode number used by the public path-oriented API.
14pub type Inode = u64;
15
16/// Info about a request.
17#[derive(Clone, Copy, Debug)]
18pub struct RequestInfo {
19    /// The unique ID assigned to this request by FUSE.
20    pub unique: u64,
21    /// The user ID of the process making the request.
22    pub uid: u32,
23    /// The group ID of the process making the request.
24    pub gid: u32,
25    /// The process ID of the process making the request.
26    pub pid: u32,
27}
28
29/// A directory entry together with its attributes.
30#[derive(Clone, Debug)]
31pub struct DirectoryEntry {
32    /// Name of the entry.
33    pub name: OsString,
34    /// Cache time-to-live for the entry and its attributes.
35    pub ttl: Duration,
36    /// Attributes of the entry.
37    pub attr: FileAttr,
38}
39
40/// A directory entry without attributes for the legacy FUSE readdir operation.
41#[cfg(feature = "legacy_readdir")]
42#[derive(Clone, Debug)]
43pub struct LegacyDirectoryEntry {
44    /// Name of the entry.
45    pub name: OsString,
46    /// Kind of file (directory, file, pipe, etc.).
47    pub kind: crate::FileType,
48}
49
50/// Filesystem statistics.
51#[derive(Clone, Copy, Debug)]
52pub struct Statfs {
53    /// Total data blocks in the filesystem
54    pub blocks: u64,
55    /// Free blocks in filesystem
56    pub bfree: u64,
57    /// Free blocks available to unprivileged user
58    pub bavail: u64,
59    /// Total file nodes in filesystem
60    pub files: u64,
61    /// Free file nodes in filesystem
62    pub ffree: u64,
63    /// Optimal transfer block size
64    pub bsize: u32,
65    /// Maximum length of filenames
66    pub namelen: u32,
67    /// Fragment size
68    pub frsize: u32,
69}
70
71/// File attributes.
72#[derive(Clone, Copy, Debug)]
73pub struct FileAttr {
74    /// Size in bytes
75    pub size: u64,
76    /// Size in blocks
77    pub blocks: u64,
78    /// Time of last access
79    pub atime: SystemTime,
80    /// Time of last modification
81    pub mtime: SystemTime,
82    /// Time of last metadata change
83    pub ctime: SystemTime,
84    /// Time of creation (macOS only)
85    pub crtime: SystemTime,
86    /// Kind of file (directory, file, pipe, etc.)
87    pub kind: crate::FileType,
88    /// Permissions
89    pub perm: u16,
90    /// Number of hard links
91    pub nlink: u32,
92    /// User ID
93    pub uid: u32,
94    /// Group ID
95    pub gid: u32,
96    /// Device ID (if special file)
97    pub rdev: u32,
98    /// block size
99    pub blksize: u32,
100    /// Flags (macOS only; see chflags(2))
101    pub flags: u32,
102}
103
104/// The return value for `create`: contains info on the newly-created file, as well as a handle to
105/// the opened file.
106#[derive(Clone, Debug)]
107pub struct CreatedEntry {
108    /// Entry cache time-to-live.
109    pub ttl: Duration,
110    /// Attributes returned for the created file.
111    pub attr: FileAttr,
112    /// File handle returned for the opened file.
113    pub fh: u64,
114    /// Open response flags returned to fuser.
115    pub flags: u32,
116}
117
118/// Represents the return value from the `listxattr` and `getxattr` calls, which can be either a
119/// size or contain data, depending on how they are called.
120#[derive(Clone, Debug)]
121pub enum Xattr {
122    /// Size needed to read the attribute value or name list.
123    Size(u32),
124    /// Attribute data or null-terminated attribute name list.
125    Data(Vec<u8>),
126}
127
128#[cfg(target_os = "macos")]
129/// Extended timestamps available on macOS.
130#[derive(Clone, Debug)]
131pub struct XTimes {
132    /// Time of the last backup.
133    pub bkuptime: SystemTime,
134    /// Time of creation.
135    pub crtime: SystemTime,
136}
137
138/// Result for operations that return no data.
139pub type ResultEmpty = std::io::Result<()>;
140/// Result containing the cache duration and attributes of an entry.
141pub type ResultEntry = std::io::Result<(Duration, FileAttr)>;
142/// Result containing a file handle and FUSE open response flags.
143pub type ResultOpen = std::io::Result<(u64, u32)>;
144/// Result containing an owned byte buffer.
145pub type ResultData = std::io::Result<Vec<u8>>;
146/// Result containing one batch of directory entries and their attributes.
147pub type ResultReaddirBatch = std::io::Result<Vec<DirectoryEntry>>;
148#[cfg(feature = "legacy_readdir")]
149/// Result containing one batch of legacy directory entries without attributes.
150pub type ResultLegacyReaddirBatch = std::io::Result<Vec<LegacyDirectoryEntry>>;
151/// Result containing a borrowed byte slice.
152pub type ResultSlice<'a> = std::io::Result<&'a [u8]>;
153/// Result containing the number of bytes written.
154pub type ResultWrite = std::io::Result<u32>;
155/// Result containing filesystem statistics.
156pub type ResultStatfs = std::io::Result<Statfs>;
157/// Result containing a newly created and opened entry.
158pub type ResultCreate = std::io::Result<CreatedEntry>;
159/// Result containing extended attribute data or its required size.
160pub type ResultXattr = std::io::Result<Xattr>;
161
162#[cfg(target_os = "macos")]
163/// Result containing extended macOS timestamps.
164pub type ResultXTimes = std::io::Result<XTimes>;
165
166/// Dummy struct returned by the callback in the `read()` method. Cannot be constructed outside
167/// this crate, `read()` requires you to return it, thus ensuring that you don't forget to call the
168/// callback.
169pub struct CallbackResult {
170    pub(crate) _private: std::marker::PhantomData<()>,
171}
172
173/// Path resolved from an inode with the current inode number attached.
174#[derive(Debug, Clone)]
175pub struct ResolvedPath {
176    parent: Arc<PathBuf>,
177    name: Arc<OsStr>,
178    ino: Inode,
179}
180
181impl ResolvedPath {
182    /// Returns the full path by joining the parent path and entry name.
183    pub fn full_path(&self) -> PathBuf {
184        self.parent.join(self.name.as_ref())
185    }
186    /// Returns the final path component.
187    pub fn name(&self) -> &OsStr {
188        &self.name
189    }
190    /// Returns the inode associated with this resolved path.
191    pub fn ino(&self) -> Inode {
192        self.ino
193    }
194    /// Returns the parent directory path.
195    pub fn parent_path(&self) -> Arc<PathBuf> {
196        self.parent.clone()
197    }
198}
199
200/// Entry name resolved relative to a parent directory path.
201#[derive(Debug, Clone)]
202pub struct EntryName {
203    parent: Arc<PathBuf>,
204    //parent_ino: Inode,
205    name: Arc<OsStr>,
206}
207
208impl EntryName {
209    /// Attaches an inode to this entry name.
210    pub(crate) fn with(self, ino: Inode) -> ResolvedPath {
211        ResolvedPath {
212            parent: self.parent,
213            name: self.name,
214            ino,
215        }
216    }
217    /// Creates an entry name from a parent folder path and child name.
218    pub(crate) fn new(parent: FolderPath, name: Arc<OsStr>) -> Self {
219        Self {
220            parent: parent.0,
221            name,
222        }
223    }
224    /// Returns the full path by joining the parent path and entry name.
225    pub fn full_path(&self) -> PathBuf {
226        self.parent.join(self.name.as_ref())
227    }
228    /// Returns the final path component.
229    pub fn name(&self) -> &OsStr {
230        &self.name
231    }
232
233    /// Returns the parent directory path.
234    pub fn parent_path(&self) -> Arc<PathBuf> {
235        self.parent.clone()
236    }
237}
238
239/// Entry path passed to callbacks that may run before or after inode resolution.
240///
241/// Lookup is used while resolving a parent/name pair before an inode is attached.
242/// Resolved is used when the inode table already has an inode for the entry.
243#[derive(Debug, Clone)]
244pub enum EntryRef {
245    /// Entry identified by a parent path and name before inode resolution.
246    Lookup(EntryName),
247    /// Entry whose inode has already been resolved.
248    Resolved(ResolvedPath),
249}
250
251impl EntryRef {
252    /// Returns the full path by joining the parent path and entry name.
253    pub fn full_path(&self) -> PathBuf {
254        match self {
255            EntryRef::Lookup(this) => this.full_path(),
256            EntryRef::Resolved(this) => this.full_path(),
257        }
258    }
259    /// Returns the final path component.
260    pub fn name(&self) -> &OsStr {
261        match self {
262            EntryRef::Lookup(this) => this.name(),
263            EntryRef::Resolved(this) => this.name(),
264        }
265    }
266    /// Returns the parent directory path.
267    pub fn parent_path(&self) -> Arc<PathBuf> {
268        match self {
269            EntryRef::Lookup(this) => this.parent_path(),
270            EntryRef::Resolved(this) => this.parent_path(),
271        }
272    }
273}
274
275/// Shared path for a directory entry in the inode table.
276#[repr(transparent)]
277#[derive(Debug)]
278pub(crate) struct FolderPath(Arc<PathBuf>);
279
280impl From<Arc<PathBuf>> for FolderPath {
281    fn from(value: Arc<PathBuf>) -> Self {
282        Self(value)
283    }
284}
285
286impl From<&OsStr> for FolderPath {
287    fn from(value: &OsStr) -> Self {
288        Self(Arc::new(value.into()))
289    }
290}
291
292impl Deref for FolderPath {
293    type Target = Arc<PathBuf>;
294    fn deref(&self) -> &Self::Target {
295        &self.0
296    }
297}
298
299fn enosys_error<T>() -> std::io::Result<T> {
300    Err(std::io::Error::from_raw_os_error(libc::ENOSYS))
301}
302
303/// This trait must be implemented to implement a filesystem with FuserNG.
304///
305/// Methods have default ENOSYS implementations, so a filesystem can implement only the operations
306/// it supports.
307///
308/// ```no_run
309/// use std::io;
310/// use std::time::{Duration, SystemTime};
311///
312/// use fuser_ng::{EntryRef, FileAttr, FileType, Filesystem, RequestInfo, ResultEntry};
313///
314/// struct RootOnly;
315///
316/// impl Filesystem for RootOnly {
317///     fn getattr(&self, _req: RequestInfo, path: &EntryRef, _fh: Option<u64>) -> ResultEntry {
318///         if path.full_path() != std::path::Path::new("/") {
319///             return Err(io::Error::from_raw_os_error(libc::ENOENT));
320///         }
321///
322///         let now = SystemTime::now();
323///
324///         Ok((
325///             Duration::from_secs(1),
326///             FileAttr {
327///                 size: 0,
328///                 blocks: 0,
329///                 atime: now,
330///                 mtime: now,
331///                 ctime: now,
332///                 crtime: now,
333///                 kind: FileType::Directory,
334///                 perm: 0o755,
335///                 nlink: 2,
336///                 uid: 0,
337///                 gid: 0,
338///                 rdev: 0,
339///                 blksize: 512,
340///                 flags: 0,
341///             },
342///         ))
343///     }
344/// }
345/// ```
346#[allow(unused_variables)]
347pub trait Filesystem {
348    /// Called when the filesystem is mounted, before any other operation.
349    ///
350    /// * `req`: information about the FUSE request.
351    /// * `config`: kernel configuration that may be adjusted before mounting.
352    fn init(&self, req: RequestInfo, config: &mut KernelConfig) -> ResultEmpty {
353        Ok(())
354    }
355
356    /// Called when the filesystem is unmounted.
357    fn destroy(&self) {
358        // Nothing.
359    }
360
361    /// Get the attributes of a filesystem entry.
362    ///
363    /// * `req`: information about the FUSE request.
364    /// * `path`: path to the entry.
365    /// * `fh`: a file handle if this is called on an open file.
366    fn getattr(&self, req: RequestInfo, path: &EntryRef, fh: Option<u64>) -> ResultEntry {
367        enosys_error()
368    }
369
370    // The following operations in the FUSE C API are all one kernel call: setattr
371    // We split them out to match the C API's behavior.
372
373    /// Change the mode of a filesystem entry.
374    ///
375    /// * `req`: information about the FUSE request.
376    /// * `path`: path to the entry.
377    /// * `fh`: a file handle if this is called on an open file.
378    /// * `mode`: the mode to change the file to.
379    fn chmod(
380        &self,
381        req: RequestInfo,
382        path: &ResolvedPath,
383        fh: Option<u64>,
384        mode: u32,
385    ) -> ResultEmpty {
386        enosys_error()
387    }
388
389    /// Change the owner UID and/or group GID of a filesystem entry.
390    ///
391    /// * `req`: information about the FUSE request.
392    /// * `path`: path to the entry.
393    /// * `fh`: a file handle if this is called on an open file.
394    /// * `uid`: new user ID for the file owner. If `None`, leave the UID unchanged.
395    /// * `gid`: new group ID for the file. If `None`, leave the GID unchanged.
396    fn chown(
397        &self,
398        req: RequestInfo,
399        path: &ResolvedPath,
400        fh: Option<u64>,
401        uid: Option<u32>,
402        gid: Option<u32>,
403    ) -> ResultEmpty {
404        enosys_error()
405    }
406
407    /// Set the length of a file.
408    ///
409    /// * `req`: information about the FUSE request.
410    /// * `path`: path to the file.
411    /// * `fh`: a file handle if this is called on an open file.
412    /// * `size`: new file length in bytes.
413    fn truncate(
414        &self,
415        req: RequestInfo,
416        path: &ResolvedPath,
417        fh: Option<u64>,
418        size: u64,
419    ) -> ResultEmpty {
420        enosys_error()
421    }
422
423    /// Set the timestamps of a filesystem entry.
424    ///
425    /// * `req`: information about the FUSE request.
426    /// * `path`: path to the entry.
427    /// * `fh`: a file handle if this is called on an open file.
428    /// * `atime`: new access time, or `None` to leave it unchanged.
429    /// * `mtime`: new modification time, or `None` to leave it unchanged.
430    fn utimens(
431        &self,
432        req: RequestInfo,
433        path: &ResolvedPath,
434        fh: Option<u64>,
435        atime: Option<SystemTime>,
436        mtime: Option<SystemTime>,
437    ) -> ResultEmpty {
438        enosys_error()
439    }
440
441    /// Set the timestamps of a filesystem entry using the additional macOS options.
442    ///
443    /// * `req`: information about the FUSE request.
444    /// * `path`: path to the entry.
445    /// * `fh`: a file handle if this is called on an open file.
446    /// * `crtime`: new creation time, or `None` to leave it unchanged.
447    /// * `chgtime`: new metadata change time, or `None` to leave it unchanged.
448    /// * `bkuptime`: new backup time, or `None` to leave it unchanged.
449    /// * `flags`: new macOS file flags, or `None` to leave them unchanged.
450    #[allow(clippy::too_many_arguments)]
451    fn utimens_macos(
452        &self,
453        req: RequestInfo,
454        path: &ResolvedPath,
455        fh: Option<u64>,
456        crtime: Option<SystemTime>,
457        chgtime: Option<SystemTime>,
458        bkuptime: Option<SystemTime>,
459        flags: Option<u32>,
460    ) -> ResultEmpty {
461        enosys_error()
462    }
463
464    // END OF SETATTR FUNCTIONS
465
466    /// Read a symbolic link.
467    ///
468    /// * `req`: information about the FUSE request.
469    /// * `path`: path to the symbolic link.
470    fn readlink(&self, req: RequestInfo, path: &ResolvedPath) -> ResultData {
471        enosys_error()
472    }
473
474    /// Create a special file.
475    ///
476    /// * `req`: information about the FUSE request.
477    /// * `entry`: entry name resolved relative to its parent directory.
478    /// * `mode`: mode for the new entry.
479    /// * `rdev`: device number when mode contains `S_IFCHR` or `S_IFBLK`; ignored otherwise.
480    fn mknod(&self, req: RequestInfo, entry: &EntryName, mode: u32, rdev: u32) -> ResultEntry {
481        enosys_error()
482    }
483
484    /// Create a directory.
485    ///
486    /// * `req`: information about the FUSE request.
487    /// * `entry`: directory name resolved relative to its parent directory.
488    /// * `mode`: permissions for the new directory.
489    fn mkdir(&self, req: RequestInfo, entry: &EntryName, mode: u32) -> ResultEntry {
490        enosys_error()
491    }
492
493    /// Remove a file.
494    ///
495    /// * `req`: information about the FUSE request.
496    /// * `entry`: file name resolved relative to its parent directory.
497    fn unlink(&self, req: RequestInfo, entry: &EntryName) -> ResultEmpty {
498        enosys_error()
499    }
500
501    /// Remove a directory.
502    ///
503    /// * `req`: information about the FUSE request.
504    /// * `entry`: directory name resolved relative to its parent directory.
505    fn rmdir(&self, req: RequestInfo, entry: &EntryName) -> ResultEmpty {
506        enosys_error()
507    }
508
509    /// Create a symbolic link.
510    ///
511    /// * `req`: information about the FUSE request.
512    /// * `entry`: symbolic link name resolved relative to its parent directory.
513    /// * `target`: path (may be relative or absolute) to the target of the link.
514    fn symlink(&self, req: RequestInfo, entry: &EntryName, target: &Path) -> ResultEntry {
515        enosys_error()
516    }
517
518    /// Rename a filesystem entry.
519    ///
520    /// * `req`: information about the FUSE request.
521    /// * `entry`: current entry name resolved relative to its parent directory.
522    /// * `new_entry`: new entry name resolved relative to its parent directory.
523    fn rename(&self, req: RequestInfo, entry: &EntryName, new_entry: &EntryName) -> ResultEmpty {
524        enosys_error()
525    }
526
527    /// Create a hard link.
528    ///
529    /// * `req`: information about the FUSE request.
530    /// * `path`: path to an existing file.
531    /// * `new_entry`: new link name resolved relative to its parent directory.
532    fn link(&self, req: RequestInfo, path: &ResolvedPath, new_entry: &EntryName) -> ResultEntry {
533        enosys_error()
534    }
535
536    /// Open a file.
537    ///
538    /// * `req`: information about the FUSE request.
539    /// * `path`: path to the file.
540    /// * `flags`: one of `O_RDONLY`, `O_WRONLY`, or `O_RDWR`, plus any additional flags.
541    ///
542    /// Return a tuple of (file handle, flags). The file handle will be passed to any subsequent
543    /// calls that operate on the file, and can be any value you choose, though it should allow
544    /// your filesystem to identify the open file even without path information.
545    fn open(&self, req: RequestInfo, path: &ResolvedPath, flags: u32) -> ResultOpen {
546        enosys_error()
547    }
548
549    /// Read from a file.
550    ///
551    /// Reading past the end of the file is not an error. Return only the available data up to the
552    /// end of the file, which may be fewer bytes than requested or even zero bytes. Do not extend
553    /// the file in this case.
554    ///
555    /// * `req`: information about the FUSE request.
556    /// * `path`: path to the file.
557    /// * `fh`: file handle returned from the `open` call.
558    /// * `offset`: offset into the file to start reading.
559    /// * `size`: number of bytes to read.
560    /// * `callback`: a callback that must be invoked to return the result of the operation: either
561    ///   the result data as a slice, or an error code.
562    ///
563    /// Return the return value from the `callback` function.
564    fn read(
565        &self,
566        req: RequestInfo,
567        path: &ResolvedPath,
568        fh: u64,
569        offset: u64,
570        size: u32,
571        callback: impl FnOnce(ResultSlice<'_>) -> CallbackResult,
572    ) -> CallbackResult {
573        callback(enosys_error())
574    }
575
576    /// Write to a file.
577    ///
578    /// * `req`: information about the FUSE request.
579    /// * `path`: path to the file.
580    /// * `fh`: file handle returned from the `open` call.
581    /// * `offset`: offset into the file to start writing.
582    /// * `data`: data to write.
583    /// * flags: file open flags.
584    ///
585    /// Return the number of bytes written.
586    fn write(
587        &self,
588        req: RequestInfo,
589        path: &ResolvedPath,
590        fh: u64,
591        offset: u64,
592        data: Vec<u8>,
593        flags: u32,
594    ) -> ResultWrite {
595        enosys_error()
596    }
597
598    /// Called each time a program calls `close` on an open file.
599    ///
600    /// Note that because file descriptors can be duplicated (by `dup`, `dup2`, `fork`) this may be
601    /// called multiple times for a given file handle. The main use of this function is if the
602    /// filesystem would like to return an error to the `close` call. Note that most programs
603    /// ignore the return value of `close`, though.
604    ///
605    /// * `req`: information about the FUSE request.
606    /// * `path`: path to the file.
607    /// * `fh`: file handle returned from the `open` call.
608    /// * `lock_owner`: if the filesystem supports locking (`setlk`, `getlk`), remove all locks
609    ///   belonging to this lock owner.
610    fn flush(
611        &self,
612        req: RequestInfo,
613        path: &ResolvedPath,
614        fh: u64,
615        lock_owner: u64,
616    ) -> ResultEmpty {
617        enosys_error()
618    }
619
620    /// Called when an open file is closed.
621    ///
622    /// There will be one of these for each `open` call. After `release`, no more calls will be
623    /// made with the given file handle.
624    ///
625    /// * `req`: information about the FUSE request.
626    /// * `path`: path to the file.
627    /// * `fh`: file handle returned from the `open` call.
628    /// * `flags`: the flags passed when the file was opened.
629    /// * `lock_owner`: if the filesystem supports locking (`setlk`, `getlk`), remove all locks
630    ///   belonging to this lock owner.
631    /// * `flush`: whether pending data must be flushed or not.
632    fn release(
633        &self,
634        req: RequestInfo,
635        path: &ResolvedPath,
636        fh: u64,
637        flags: u32,
638        lock_owner: u64,
639        flush: bool,
640    ) -> ResultEmpty {
641        enosys_error()
642    }
643
644    /// Write out any pending changes to a file.
645    ///
646    /// When this returns, data should be written to persistent storage.
647    ///
648    /// * `req`: information about the FUSE request.
649    /// * `path`: path to the file.
650    /// * `fh`: file handle returned from the `open` call.
651    /// * `datasync`: if `false`, also write metadata; otherwise, write only file data.
652    fn fsync(&self, req: RequestInfo, path: &ResolvedPath, fh: u64, datasync: bool) -> ResultEmpty {
653        enosys_error()
654    }
655
656    /// Open a directory.
657    ///
658    /// Analogous to the `opendir` call.
659    ///
660    /// * `req`: information about the FUSE request.
661    /// * `path`: path to the directory.
662    /// * `flags`: file access flags. Will contain `O_DIRECTORY` at least.
663    ///
664    /// Return a tuple of (file handle, flags). The file handle will be passed to any subsequent
665    /// calls that operate on the directory, and can be any value you choose, though it should
666    /// allow your filesystem to identify the open directory even without path information.
667    fn opendir(&self, req: RequestInfo, path: &ResolvedPath, flags: u32) -> ResultOpen {
668        enosys_error()
669    }
670
671    /// Gets directory entries together with their attributes.
672    ///
673    /// * `req`: information about the FUSE request.
674    /// * `path`: path to the directory.
675    /// * `fh`: file handle returned from the `opendir` call.
676    ///
677    /// Batching allows initial results to be returned before directory enumeration completes.
678    /// FuserNG deliberately retains consumed entries until releasedir so earlier offsets can be
679    /// replayed without restarting enumeration or repeating backend requests. This history
680    /// trades memory for fast replay; batching is intended to reduce result delivery latency.
681    fn readdir(
682        &self,
683        req: RequestInfo,
684        path: &ResolvedPath,
685        fh: u64,
686    ) -> impl Iterator<Item = ResultReaddirBatch> + Send + 'static {
687        std::iter::once(enosys_error())
688    }
689
690    /// Gets directory entries without attributes for the legacy FUSE readdir operation.
691    ///
692    /// * `req`: information about the FUSE request.
693    /// * `path`: path to the directory.
694    /// * `fh`: file handle returned from the `opendir` call.
695    ///
696    /// Batching allows initial results to be returned before directory enumeration completes.
697    /// FuserNG deliberately retains consumed entries until releasedir so earlier offsets can be
698    /// replayed without restarting enumeration or repeating backend requests. This history
699    /// trades memory for fast replay; batching is intended to reduce result delivery latency.
700    #[cfg(feature = "legacy_readdir")]
701    fn legacy_readdir(
702        &self,
703        req: RequestInfo,
704        path: &ResolvedPath,
705        fh: u64,
706    ) -> impl Iterator<Item = ResultLegacyReaddirBatch> + Send + 'static {
707        std::iter::once(enosys_error())
708    }
709
710    /// Close an open directory.
711    ///
712    /// This will be called exactly once for each `opendir` call.
713    ///
714    /// * `req`: information about the FUSE request.
715    /// * `path`: path to the directory.
716    /// * `fh`: file handle returned from the `opendir` call.
717    /// * `flags`: the file access flags passed to the `opendir` call.
718    fn releasedir(
719        &self,
720        req: RequestInfo,
721        path: &ResolvedPath,
722        fh: u64,
723        flags: u32,
724    ) -> ResultEmpty {
725        enosys_error()
726    }
727
728    /// Write out any pending changes to a directory.
729    ///
730    /// Analogous to the `fsync` call.
731    ///
732    /// * `req`: information about the FUSE request.
733    /// * `path`: path to the directory.
734    /// * `fh`: file handle returned from the `opendir` call.
735    /// * `datasync`: if `false`, also write metadata; otherwise, write only directory data.
736    fn fsyncdir(
737        &self,
738        req: RequestInfo,
739        path: &ResolvedPath,
740        fh: u64,
741        datasync: bool,
742    ) -> ResultEmpty {
743        enosys_error()
744    }
745
746    /// Get filesystem statistics.
747    ///
748    /// * `req`: information about the FUSE request.
749    /// * `path`: path to a directory in the filesystem.
750    ///
751    /// See the `Statfs` struct for more details.
752    fn statfs(&self, req: RequestInfo, path: &ResolvedPath) -> ResultStatfs {
753        enosys_error()
754    }
755
756    /// Set an extended attribute on a file.
757    ///
758    /// * `req`: information about the FUSE request.
759    /// * `path`: path to the file.
760    /// * `name`: attribute name.
761    /// * `value`: the data to set the value to.
762    /// * `flags`: can be either `XATTR_CREATE` or `XATTR_REPLACE`.
763    /// * `position`: offset into the attribute value to write data.
764    fn setxattr(
765        &self,
766        req: RequestInfo,
767        path: &ResolvedPath,
768        name: &OsStr,
769        value: &[u8],
770        flags: u32,
771        position: u32,
772    ) -> ResultEmpty {
773        enosys_error()
774    }
775
776    /// Get an extended attribute from a file.
777    ///
778    /// * `req`: information about the FUSE request.
779    /// * `path`: path to the file.
780    /// * `name`: attribute name.
781    /// * `size`: the maximum number of bytes to read.
782    ///
783    /// If `size` is 0, return `Xattr::Size(n)` where `n` is the size of the attribute data.
784    /// Otherwise, return `Xattr::Data(data)` with the requested data.
785    fn getxattr(
786        &self,
787        req: RequestInfo,
788        path: &ResolvedPath,
789        name: &OsStr,
790        size: u32,
791    ) -> ResultXattr {
792        enosys_error()
793    }
794
795    /// List extended attributes for a file.
796    ///
797    /// * `req`: information about the FUSE request.
798    /// * `path`: path to the file.
799    /// * `size`: maximum number of bytes to return.
800    ///
801    /// If `size` is 0, return `Xattr::Size(n)` where `n` is the size required for the list of
802    /// attribute names.
803    /// Otherwise, return `Xattr::Data(data)` where `data` is all the null-terminated attribute
804    /// names.
805    fn listxattr(&self, req: RequestInfo, path: &ResolvedPath, size: u32) -> ResultXattr {
806        enosys_error()
807    }
808
809    /// Remove an extended attribute from a file.
810    ///
811    /// * `req`: information about the FUSE request.
812    /// * `path`: path to the file.
813    /// * `name`: name of the attribute to remove.
814    fn removexattr(&self, req: RequestInfo, path: &ResolvedPath, name: &OsStr) -> ResultEmpty {
815        enosys_error()
816    }
817
818    /// Check for access to a file.
819    ///
820    /// * `req`: information about the FUSE request.
821    /// * `path`: path to the file.
822    /// * `mask`: mode bits to check for access to.
823    ///
824    /// Return `Ok(())` if all requested permissions are allowed, otherwise return `Err(EACCES)`
825    /// or another appropriate error code (e.g. `ENOENT` if the file doesn't exist).
826    fn access(&self, req: RequestInfo, path: &ResolvedPath, mask: u32) -> ResultEmpty {
827        enosys_error()
828    }
829
830    /// Create and open a new file.
831    ///
832    /// * `req`: information about the FUSE request.
833    /// * `path`: path to the new file.
834    /// * `mode`: the mode to set on the new file.
835    /// * `flags`: flags that would be passed to `open`.
836    ///
837    /// Return a `CreatedEntry` containing the new file's attributes and a file handle. See the
838    /// documentation for `open` for more information about file handles.
839    fn create(&self, req: RequestInfo, path: &ResolvedPath, mode: u32, flags: u32) -> ResultCreate {
840        enosys_error()
841    }
842
843    // getlk
844
845    // setlk
846
847    // bmap
848
849    /// macOS only: Rename the volume.
850    ///
851    /// * `req`: information about the FUSE request.
852    /// * `name`: new name for the volume.
853    #[cfg(target_os = "macos")]
854    fn setvolname(&self, req: RequestInfo, name: &OsStr) -> ResultEmpty {
855        enosys_error()
856    }
857
858    // exchange (macOS only, undocumented)
859
860    /// macOS only: Query extended times (bkuptime and crtime).
861    ///
862    /// * `req`: information about the FUSE request.
863    /// * `path`: path to the file to get the times for.
864    ///
865    /// Return an `XTimes` struct containing the times, or an appropriate error.
866    #[cfg(target_os = "macos")]
867    fn getxtimes(&self, req: RequestInfo, path: &ResolvedPath) -> ResultXTimes {
868        Err(libc::ENOSYS)
869    }
870}