Documentation
¶
Overview ¶
Package flags provides utilities for working with FUSE file open flags.
Index ¶
- Constants
- type FuseFlags
- func (f FuseFlags) AsOsFlags() int
- func (f FuseFlags) IsAppend() bool
- func (f FuseFlags) IsCreate() bool
- func (f FuseFlags) IsCreateExclusive() bool
- func (f FuseFlags) IsEventOnly() bool
- func (f FuseFlags) IsExclusive() bool
- func (f FuseFlags) IsReadOnly() bool
- func (f FuseFlags) IsReadWrite() bool
- func (f FuseFlags) IsTruncate() bool
- func (f FuseFlags) IsWriteOnly() bool
- func (f FuseFlags) String() string
- func (f FuseFlags) Without(remove int) FuseFlags
Constants ¶
const (
// O_EVTONLY is a flag used to indicate that the file is opened for event notifications only.
O_EVTONLY = 0x8000
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FuseFlags ¶
type FuseFlags int
func NewFuseFlags ¶
NewFuseFlags initializes a FuseFlags instance with the given integer flag value.
func (FuseFlags) AsOsFlags ¶
AsOsFlags translates POSIX/FUSE-style open(2) flags carried in FuseFlags into the platform-appropriate flags defined by Go’s os package.
Why this is cross-platform:
- Access mode: FUSE follows POSIX semantics where the lower two bits encode the access mode (O_RDONLY=0, O_WRONLY=1, O_RDWR=2). We mask with 0x3 and map to os.O_RDONLY / os.O_WRONLY / os.O_RDWR. The os package then turns these into the correct native flags for Linux, macOS, and Windows.
- Behavior/creation bits: FUSE flags like O_CREAT, O_EXCL, O_TRUNC, and O_APPEND have direct counterparts in the os package (os.O_CREATE, os.O_EXCL, os.O_TRUNC, os.O_APPEND). OR-ing these through lets the os package handle the per-platform syscall details (including WinFsp on Windows for cgofuse).
How it works:
- Mask the lower two bits (0x3) to select exactly one of R/O, W/O, or R/W.
- OR in any creation/behavior bits that are present.
- Return the composite mask, suitable for passing to os.OpenFile.
Notes:
- O_EVTONLY (macOS) is intentionally ignored here because it’s about event notifications rather than the access/creation mode used by os.OpenFile.
- Add additional mappings here if more FUSE flags need to flow through.
func (FuseFlags) IsCreateExclusive ¶
IsCreateExclusive checks if the flag is set to create and exclusive.
func (FuseFlags) IsEventOnly ¶
IsEventOnly checks if the flag is open for event notifications only.
func (FuseFlags) IsExclusive ¶
IsExclusive checks if the flag is set to exclusive.
func (FuseFlags) IsReadOnly ¶
IsReadOnly checks if the flag is set to read-only.
func (FuseFlags) IsReadWrite ¶
IsReadWrite checks if the flag is set to read-write.
func (FuseFlags) IsTruncate ¶
IsTruncate checks if the flag is set to truncate.
func (FuseFlags) IsWriteOnly ¶
IsWriteOnly checks if the flag is set to write-only.