Documentation
¶
Overview ¶
Package mountlib provides the mount command.
Index ¶
- Constants
- Variables
- func AddFlags(flagSet *pflag.FlagSet)
- func AddRc(mountUtilName string, mountFunction MountFn)
- func CheckAllowNonEmpty(mountpoint string, opt *Options) error
- func CheckMountEmpty(mountpoint string) error
- func CheckMountReady(mountpoint string) error
- func CheckOverlap(f fs.Fs, mountpoint string) error
- func ClipBlocks(b *uint64)
- func NewMountCommand(commandName string, hidden bool, mount MountFn) *cobra.Command
- func WaitMountReady(mountpoint string, timeout time.Duration, daemon *os.Process) (err error)
- type MountFn
- type MountInfo
- type MountPoint
- type Options
- type UnmountFn
Constants ¶
const (
MaxLeafSize = 1024 // don't pass file names longer than this
)
Global constants
Variables ¶
var CanCheckMountReady = true
CanCheckMountReady is set if CheckMountReady is functional
var OptionsInfo = fs.Options{{ Name: "debug_fuse", Default: false, Help: "Debug the FUSE internals - needs -v", Groups: "Mount", }, { Name: "attr_timeout", Default: fs.Duration(1 * time.Second), Help: "Time for which file/directory attributes are cached", Groups: "Mount", }, { Name: "option", Default: []string{}, Help: "Option for libfuse/WinFsp (repeat if required)", Groups: "Mount", ShortOpt: "o", }, { Name: "fuse_flag", Default: []string{}, Help: "Flags or arguments to be passed direct to libfuse/WinFsp (repeat if required)", Groups: "Mount", }, { Name: "daemon", Default: false, Help: "Run mount in background and exit parent process (as background output is suppressed, use --log-file with --log-format=pid,... to monitor) (not supported on Windows)", Groups: "Mount", }, { Name: "daemon_timeout", Default: func() fs.Duration { if runtime.GOOS == "darwin" { return fs.Duration(10 * time.Minute) } return 0 }(), Help: "Time limit for rclone to respond to kernel (not supported on Windows)", Groups: "Mount", }, { Name: "default_permissions", Default: false, Help: "Makes kernel enforce access control based on the file mode (not supported on Windows)", Groups: "Mount", }, { Name: "allow_non_empty", Default: false, Help: "Allow mounting over a non-empty directory (not supported on Windows)", Groups: "Mount", }, { Name: "allow_root", Default: false, Help: "Allow access to root user (not supported on Windows)", Groups: "Mount", }, { Name: "allow_other", Default: false, Help: "Allow access to other users (not supported on Windows)", Groups: "Mount", }, { Name: "async_read", Default: true, Help: "Use asynchronous reads (not supported on Windows)", Groups: "Mount", }, { Name: "max_read_ahead", Default: fs.SizeSuffix(128 * 1024), Help: "The number of bytes that can be prefetched for sequential reads (not supported on Windows)", Groups: "Mount", }, { Name: "write_back_cache", Default: false, Help: "Makes kernel buffer writes before sending them to rclone (without this, writethrough caching is used) (not supported on Windows)", Groups: "Mount", }, { Name: "devname", Default: "", Help: "Set the device name - default is remote:path", Groups: "Mount", }, { Name: "mount_case_insensitive", Default: fs.Tristate{}, Help: "Tell the OS the mount is case insensitive (true) or sensitive (false) regardless of the backend (auto)", Groups: "Mount", }, { Name: "direct_io", Default: false, Help: "Use Direct IO, disables caching of data", Groups: "Mount", }, { Name: "volname", Default: "", Help: "Set the volume name (supported on Windows and OSX only)", Groups: "Mount", }, { Name: "noappledouble", Default: true, Help: "Ignore Apple Double (._) and .DS_Store files (supported on OSX only)", Groups: "Mount", }, { Name: "noapplexattr", Default: false, Help: "Ignore all \"com.apple.*\" extended attributes (supported on OSX only)", Groups: "Mount", }, { Name: "network_mode", Default: false, Help: "Mount as remote network drive, instead of fixed disk drive (supported on Windows only)", Groups: "Mount", }, { Name: "daemon_wait", Default: func() fs.Duration { switch runtime.GOOS { case "linux": return fs.Duration(60 * time.Second) case "darwin", "openbsd", "freebsd", "netbsd": return fs.Duration(5 * time.Second) } return 0 }(), Help: "Time to wait for ready mount from daemon (maximum time on Linux, constant sleep time on OSX/BSD) (not supported on Windows)", Groups: "Mount", }}
OptionsInfo describes the Options in use
Functions ¶
func CheckAllowNonEmpty ¶ added in v1.62.0
CheckAllowNonEmpty checks --allow-non-empty flag, and if not used verifies that mountpoint is empty.
func CheckMountEmpty ¶ added in v1.56.0
CheckMountEmpty checks if folder is not already a mountpoint. On Linux we use the OS-specific /proc/self/mountinfo API so the check won't access the path. Directories marked as "mounted" by autofs are considered not mounted.
func CheckMountReady ¶ added in v1.57.0
CheckMountReady checks whether mountpoint is mounted by rclone. Only mounts with type "rclone" or "fuse.rclone" count.
func CheckOverlap ¶ added in v1.62.0
CheckOverlap checks that root doesn't overlap with a mountpoint
func NewMountCommand ¶
NewMountCommand makes a mount command with the given name and Mount function
Types ¶
type MountFn ¶ added in v1.52.0
type MountFn func(VFS *vfs.VFS, mountpoint string, opt *Options) (<-chan error, func() error, string, error)
MountFn is called to mount the file system
It returns the errChan, unmount function, the actual mountpoint (which may differ from the input, e.g. on Windows when "*" is used to auto-assign a drive letter) and an error.
func ResolveMountMethod ¶ added in v1.56.0
ResolveMountMethod returns mount function by name
type MountInfo ¶ added in v1.53.0
type MountInfo struct {
Fs string `json:"Fs"`
MountPoint string `json:"MountPoint"`
MountedOn time.Time `json:"MountedOn"`
}
MountInfo is a transitional structure for json marshaling
type MountPoint ¶ added in v1.56.0
type MountPoint struct {
MountPoint string
MountedOn time.Time
MountOpt Options
VFSOpt vfscommon.Options
Fs fs.Fs
VFS *vfs.VFS
MountFn MountFn
UnmountFn UnmountFn
ErrChan <-chan error
}
MountPoint represents a mount with options and runtime state
func NewMountPoint ¶ added in v1.58.1
func NewMountPoint(mount MountFn, mountPoint string, f fs.Fs, mountOpt *Options, vfsOpt *vfscommon.Options) *MountPoint
NewMountPoint makes a new mounting structure
func (*MountPoint) Mount ¶ added in v1.56.0
func (m *MountPoint) Mount() (mountDaemon *os.Process, err error)
Mount the remote at mountpoint
func (*MountPoint) SetDeviceName ¶ added in v1.58.0
func (m *MountPoint) SetDeviceName(dev string)
SetDeviceName with sensible default
func (*MountPoint) SetVolumeName ¶ added in v1.56.0
func (m *MountPoint) SetVolumeName(vol string)
SetVolumeName with sensible default
func (*MountPoint) Unmount ¶ added in v1.56.0
func (m *MountPoint) Unmount() (err error)
Unmount the specified mountpoint
type Options ¶ added in v1.53.0
type Options struct {
DebugFUSE bool `config:"debug_fuse"`
AllowNonEmpty bool `config:"allow_non_empty"`
AllowRoot bool `config:"allow_root"`
AllowOther bool `config:"allow_other"`
DefaultPermissions bool `config:"default_permissions"`
WritebackCache bool `config:"write_back_cache"`
Daemon bool `config:"daemon"`
DaemonWait fs.Duration `config:"daemon_wait"` // time to wait for ready mount from daemon, maximum on Linux or constant on macOS/BSD
MaxReadAhead fs.SizeSuffix `config:"max_read_ahead"`
ExtraOptions []string `config:"option"`
ExtraFlags []string `config:"fuse_flag"`
AttrTimeout fs.Duration `config:"attr_timeout"` // how long the kernel caches attribute for
DeviceName string `config:"devname"`
VolumeName string `config:"volname"`
NoAppleDouble bool `config:"noappledouble"`
NoAppleXattr bool `config:"noapplexattr"`
DaemonTimeout fs.Duration `config:"daemon_timeout"` // OSXFUSE only
AsyncRead bool `config:"async_read"`
NetworkMode bool `config:"network_mode"` // Windows only
DirectIO bool `config:"direct_io"` // use Direct IO for file access
CaseInsensitive fs.Tristate `config:"mount_case_insensitive"`
}
Options for creating the mount
var Opt Options
Opt contains options set by command line flags
func (*Options) SetVolumeName ¶ added in v1.56.0
SetVolumeName removes special characters from volume name if necessary