Skip to main content

libfuse_fs/util/
open_options.rs

1use bitflags::bitflags;
2
3// Flags use by the OPEN request/reply.
4/// Bypass page cache for this open file.
5const FOPEN_DIRECT_IO: u32 = 1;
6
7/// Don't invalidate the data cache on open.
8const FOPEN_KEEP_CACHE: u32 = 2;
9
10/// The file is not seekable.
11const FOPEN_NONSEEKABLE: u32 = 4;
12
13/// allow caching this directory
14const FOPEN_CACHE_DIR: u32 = 8;
15
16/// the file is stream-like (no file position at all)
17const FOPEN_STREAM: u32 = 16;
18
19/// Instructs the kernel not to send an implicit FLUSH request when the last file handle is closed.
20/// This delegates the responsibility of persisting data entirely to the FUSE daemon.
21const FOPEN_NOFLUSH: u32 = 32;
22
23/// Indicates that the filesystem can handle parallel direct writes to the same file from multiple threads.
24/// The kernel will not serialize writes, so the FUSE daemon itself MUST implement locking
25const FOPEN_PARALLEL_DIRECT_WRITES: u32 = 64;
26
27/// Enables passthrough I/O. After open, subsequent I/O calls (read, write) will be sent
28/// directly to the underlying file by the kernel, bypassing the FUSE daemon for maximum performance.
29/// The daemon will not receive further I/O requests for this file handle.
30const FOPEN_PASSTHROUGH: u32 = 128;
31
32bitflags! {
33    /// Options controlling the behavior of files opened by the server in response
34    /// to an open or create request.
35    pub struct OpenOptions: u32 {
36        /// Bypass page cache for this open file.
37        const DIRECT_IO = FOPEN_DIRECT_IO;
38        /// Don't invalidate the data cache on open.
39        const KEEP_CACHE = FOPEN_KEEP_CACHE;
40        /// The file is not seekable.
41        const NONSEEKABLE = FOPEN_NONSEEKABLE;
42        /// allow caching this directory
43        const CACHE_DIR = FOPEN_CACHE_DIR;
44        /// the file is stream-like (no file position at all)
45        const STREAM = FOPEN_STREAM;
46        /// Instructs the kernel not to send an implicit FLUSH request when the last file handle is closed.
47        const NOFLUSH = FOPEN_NOFLUSH;
48        /// Indicates that the filesystem can handle parallel direct writes to the same file from multiple threads.
49        const PARALLEL_DIRECT_WRITES = FOPEN_PARALLEL_DIRECT_WRITES;
50        /// Enables passthrough I/O. After open, subsequent I/O calls (read, write) will be sent
51        const PASSTROUGH = FOPEN_PASSTHROUGH;
52    }
53}