flags

package
v3.2.261 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package flags provides utilities for working with FUSE file open flags.

Index

Constants

View Source
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

func NewFuseFlags(flags int) FuseFlags

NewFuseFlags initializes a FuseFlags instance with the given integer flag value.

func (FuseFlags) AsOsFlags

func (f FuseFlags) AsOsFlags() int

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:

  1. Mask the lower two bits (0x3) to select exactly one of R/O, W/O, or R/W.
  2. OR in any creation/behavior bits that are present.
  3. 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) IsAppend

func (f FuseFlags) IsAppend() bool

IsAppend checks if the flag is set to append.

func (FuseFlags) IsCreate

func (f FuseFlags) IsCreate() bool

IsCreate checks if the flag is set to create.

func (FuseFlags) IsCreateExclusive

func (f FuseFlags) IsCreateExclusive() bool

IsCreateExclusive checks if the flag is set to create and exclusive.

func (FuseFlags) IsEventOnly

func (f FuseFlags) IsEventOnly() bool

IsEventOnly checks if the flag is open for event notifications only.

func (FuseFlags) IsExclusive

func (f FuseFlags) IsExclusive() bool

IsExclusive checks if the flag is set to exclusive.

func (FuseFlags) IsReadOnly

func (f FuseFlags) IsReadOnly() bool

IsReadOnly checks if the flag is set to read-only.

func (FuseFlags) IsReadWrite

func (f FuseFlags) IsReadWrite() bool

IsReadWrite checks if the flag is set to read-write.

func (FuseFlags) IsTruncate

func (f FuseFlags) IsTruncate() bool

IsTruncate checks if the flag is set to truncate.

func (FuseFlags) IsWriteOnly

func (f FuseFlags) IsWriteOnly() bool

IsWriteOnly checks if the flag is set to write-only.

func (FuseFlags) String

func (f FuseFlags) String() string

String returns a string representation of the FuseFlags.

func (FuseFlags) Without

func (f FuseFlags) Without(remove int) FuseFlags

Without returns a new FuseFlags instance with the specified flags removed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL