const defaultMountCommand … const sensitiveOptionsRemoved … type Interface … var _ … type MounterForceUnmounter … type MountPoint … type MountErrorType … const FilesystemMismatch … const HasFilesystemErrors … const UnformattedReadOnly … const FormatFailed … const GetDiskFormatFailed … const UnknownMountError … type MountError … func (mountError MountError) String() string { … } func (mountError MountError) Error() string { … } func NewMountError(mountErrorValue MountErrorType, format string, args ...interface{ … } type SafeFormatAndMount … func NewSafeFormatAndMount(mounter Interface, exec utilexec.Interface, opts ...Option) *SafeFormatAndMount { … } type Option … // WithMaxConcurrentFormat sets the maximum number of concurrent format // operations executed by the mounter. The timeout controls the maximum // duration of a format operation before its concurrency token is released. // Once a token is released, it can be acquired by another concurrent format // operation. The original operation is allowed to complete. // If n < 1, concurrency is set to unlimited. func WithMaxConcurrentFormat(n int, timeout time.Duration) Option { … } // FormatAndMount formats the given disk, if needed, and mounts it. // That is if the disk is not formatted and it is not being mounted as // read-only it will format it first then mount it. Otherwise, if the // disk is already formatted or it is being mounted as read-only, it // will be mounted without formatting. // options MUST not contain sensitive material (like passwords). func (mounter *SafeFormatAndMount) FormatAndMount(source string, target string, fstype string, options []string) error { … } // FormatAndMountSensitive is the same as FormatAndMount but this method allows // sensitiveOptions to be passed in a separate parameter from the normal mount // options and ensures the sensitiveOptions are never logged. This method should // be used by callers that pass sensitive material (like passwords) as mount // options. func (mounter *SafeFormatAndMount) FormatAndMountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error { … } // FormatAndMountSensitiveWithFormatOptions behaves exactly the same as // FormatAndMountSensitive, but allows for options to be passed when the disk // is formatted. These options are NOT validated in any way and should never // come directly from untrusted user input as that would be an injection risk. func (mounter *SafeFormatAndMount) FormatAndMountSensitiveWithFormatOptions(source string, target string, fstype string, options []string, sensitiveOptions []string, formatOptions []string) error { … } // getMountRefsByDev finds all references to the device provided // by mountPath; returns a list of paths. // Note that mountPath should be path after the evaluation of any symblolic links. func getMountRefsByDev(mounter Interface, mountPath string) ([]string, error) { … } // IsNotMountPoint determines if a directory is a mountpoint. // It should return ErrNotExist when the directory does not exist. // IsNotMountPoint is more expensive than IsLikelyNotMountPoint // and depends on IsMountPoint. // // If an error occurs, it returns true (assuming it is not a mountpoint) // when ErrNotExist is returned for callers similar to IsLikelyNotMountPoint. // // Deprecated: This function is kept to keep changes backward compatible with // previous library version. Callers should prefer mounter.IsMountPoint. func IsNotMountPoint(mounter Interface, file string) (bool, error) { … } // GetDeviceNameFromMount given a mnt point, find the device from /proc/mounts // returns the device name, reference count, and error code. func GetDeviceNameFromMount(mounter Interface, mountPath string) (string, int, error) { … } // MakeBindOpts detects whether a bind mount is being requested and makes the remount options to // use in case of bind mount, due to the fact that bind mount doesn't respect mount options. // The list equals: // // options - 'bind' + 'remount' (no duplicate) func MakeBindOpts(options []string) (bool, []string, []string) { … } // MakeBindOptsSensitive is the same as MakeBindOpts but this method allows // sensitiveOptions to be passed in a separate parameter from the normal mount // options and ensures the sensitiveOptions are never logged. This method should // be used by callers that pass sensitive material (like passwords) as mount // options. func MakeBindOptsSensitive(options []string, sensitiveOptions []string) (bool, []string, []string, []string) { … } func checkForNetDev(options []string, sensitiveOptions []string) bool { … } // PathWithinBase checks if give path is within given base directory. func PathWithinBase(fullPath, basePath string) bool { … } // StartsWithBackstep checks if the given path starts with a backstep segment. func StartsWithBackstep(rel string) bool { … } // sanitizedOptionsForLogging will return a comma separated string containing // options and sensitiveOptions. Each entry in sensitiveOptions will be // replaced with the string sensitiveOptionsRemoved // e.g. o1,o2,<masked>,<masked> func sanitizedOptionsForLogging(options []string, sensitiveOptions []string) string { … }