Documentation ¶
Index ¶
- Constants
- Variables
- func FSTypeEqual(fsType1, fsType2 string) bool
- func FlushLoopBackReservations() error
- func ForceUnmount(target string)
- func GetDirectCSIPath(driveName string) string
- func GetMajorMinor(device string) (major, minor uint32, err error)
- func MakeBlockFile(path string, major, minor uint32) error
- func ProbeDevices() (devices map[string]*Device, err error)
- func ProbeMounts() (map[string][]MountInfo, error)
- func ReserveLoopbackDevices(devCount int) error
- func SafeUnmount(target string, opts []UnmountOption) error
- func Unmount(target string, opts []UnmountOption) error
- type DefaultDriveFormatter
- type DefaultDriveMounter
- type DefaultDriveStatter
- type DefaultVolumeMounter
- type Device
- type DriveFormatter
- type DriveMounter
- type DriveStatter
- type FSType
- type MountInfo
- type MountOption
- type UnmountOption
- type VolumeMounter
Constants ¶
const ( // HostDevRoot is "/dev" directory. HostDevRoot = "/dev" // MountRoot is "/var/lib/direct-csi/mnt" directory. MountRoot = "/var/lib/direct-csi/mnt" // DirectCSIDevRoot is "/var/lib/direct-csi/devices" directory. DirectCSIDevRoot = "/var/lib/direct-csi/devices" // DirectCSIPartitionInfix is partition infix value. DirectCSIPartitionInfix = "-part-" // HostPartitionInfix is host infix value. HostPartitionInfix = "p" )
Variables ¶
var LoopRegexp = regexp.MustCompile("^loop[0-9]*")
Functions ¶
func FSTypeEqual ¶ added in v1.4.5
func FlushLoopBackReservations ¶ added in v1.3.0
func FlushLoopBackReservations() error
FlushLoopBackReservations does umount/detach/remove loopback devices and associated files.
func ForceUnmount ¶ added in v1.4.5
func ForceUnmount(target string)
func GetDirectCSIPath ¶ added in v1.4.0
GetDirectCSIPath returns Direct CSI path of given drive name.
func GetMajorMinor ¶ added in v1.4.0
GetMajorMinor gets major/minor number of given device.
func MakeBlockFile ¶ added in v1.4.0
MakeBlockFile creates device file by it's major/minor number.
func ProbeDevices ¶ added in v1.4.5
ProbeDevices probes all devices.
func ProbeMounts ¶ added in v1.4.5
ProbeMounts probes mount information from /proc/1/mountinfo.
func ReserveLoopbackDevices ¶ added in v1.3.0
ReserveLoopbackDevices creates loopback devices.
func SafeUnmount ¶
func SafeUnmount(target string, opts []UnmountOption) error
SafeUnmount unmounts of a target directory if it is a mountpoint.
func Unmount ¶
func Unmount(target string, opts []UnmountOption) error
Unmount unmounts given mountpoint.
Types ¶
type DefaultDriveFormatter ¶ added in v1.3.0
type DefaultDriveFormatter struct{}
DefaultDriveFormatter is a default filesystem making interface.
func (*DefaultDriveFormatter) FormatDrive ¶ added in v1.3.0
func (c *DefaultDriveFormatter) FormatDrive(ctx context.Context, uuid, path string, force bool) error
FormatDrive makes XFS filesystem on given device.
func (*DefaultDriveFormatter) MakeBlockFile ¶ added in v1.4.0
func (c *DefaultDriveFormatter) MakeBlockFile(path string, major, minor uint32) error
MakeBlockFile creates device file by it's major/minor number.
type DefaultDriveMounter ¶ added in v1.3.0
type DefaultDriveMounter struct{}
DefaultDriveMounter is a default mount/unmount drive interface.
func (*DefaultDriveMounter) MountDrive ¶ added in v1.3.0
func (c *DefaultDriveMounter) MountDrive(source, target string, mountOpts []string) error
MountDrive mounts a drive into given mountpoint.
func (*DefaultDriveMounter) UnmountDrive ¶ added in v1.3.0
func (c *DefaultDriveMounter) UnmountDrive(path string) error
UnmountDrive unmounts given mountpoint.
type DefaultDriveStatter ¶ added in v1.3.0
type DefaultDriveStatter struct{}
DefaultDriveStatter is a default interface to get free capacity of a drive.
func (*DefaultDriveStatter) GetFreeCapacityFromStatfs ¶ added in v1.3.0
func (c *DefaultDriveStatter) GetFreeCapacityFromStatfs(path string) (int64, error)
GetFreeCapacityFromStatfs gets free capacity of a drive.
type DefaultVolumeMounter ¶ added in v1.3.0
type DefaultVolumeMounter struct{}
DefaultVolumeMounter is a default mount/unmount of volume interface.
func (*DefaultVolumeMounter) MountVolume ¶ added in v1.3.0
func (c *DefaultVolumeMounter) MountVolume(ctx context.Context, src, dest string, readOnly bool) error
MountVolume mounts a volume.
func (*DefaultVolumeMounter) UnmountVolume ¶ added in v1.3.0
func (c *DefaultVolumeMounter) UnmountVolume(targetPath string) error
UnmountVolume unmounts a volume.
type Device ¶ added in v1.4.5
type Device struct { // Populated from /sys Name string Major int Minor int Removable bool ReadOnly bool Virtual bool // Populated from /run/udev/data/b<Major>:<Minor> Size uint64 Partition int WWID string Model string Serial string Vendor string DMName string DMUUID string MDUUID string PTUUID string PTType string PartUUID string FSUUID string FSType string UeventSerial string UeventFSUUID string // Computed Parent string Master string Partitioned bool // Populated by reading device TotalCapacity uint64 FreeCapacity uint64 LogicalBlockSize uint64 PhysicalBlockSize uint64 SwapOn bool // Populated from /proc/1/mountinfo MountPoints []string FirstMountPoint string FirstMountOptions []string }
Device is a block device information.
type DriveFormatter ¶ added in v1.3.0
type DriveFormatter interface { FormatDrive(ctx context.Context, uuid, path string, force bool) error MakeBlockFile(path string, major, minor uint32) error }
DriveFormatter denotes filesystem making interface.
type DriveMounter ¶ added in v1.3.0
type DriveMounter interface { MountDrive(source, target string, mountOpts []string) error UnmountDrive(path string) error }
DriveMounter is mount/unmount drive interface.
type DriveStatter ¶ added in v1.3.0
type DriveStatter interface {
GetFreeCapacityFromStatfs(path string) (freeCapacity int64, err error)
}
DriveStatter denotes function to get free capacity of a drive.
type FSType ¶
type FSType string
FSType is filesystem type.
const ( // FSTypeXFS is XFS filesystem type. FSTypeXFS FSType = "xfs" )
type MountInfo ¶
type MountInfo struct { MountPoint string // contains filtered or unexported fields }
MountInfo is a device mount information.
type MountOption ¶
type MountOption string
MountOption denotes device mount options.
const ( MountOptionMSRemount MountOption = "remount" MountOptionMSBind MountOption = "bind" MountOptionMSPrivate MountOption = "private" MountOptionMSSlave MountOption = "slave" MountOptionMSUnBindable MountOption = "unbindable" MountOptionMSMove MountOption = "move" MountOptionMSDirSync MountOption = "dirsync" MountOptionMSMandLock MountOption = "mand" MountOptionMSNoATime MountOption = "noatime" MountOptionMSNoDev MountOption = "nodev" MountOptionMSNoDirATime MountOption = "nodiratime" MountOptionMSNoExec MountOption = "noexec" MountOptionMSNoSUID MountOption = "nosuid" MountOptionMSReadOnly MountOption = "ro" MountOptionMSRelatime MountOption = "relatime" MountOptionMSRecursive MountOption = "recursive" MountOptionMSSilent MountOption = "silent" MountOptionMSStrictATime MountOption = "strictatime" MountOptionMSSynchronous MountOption = "sync" )
Mount options.
type UnmountOption ¶
type UnmountOption string
UnmountOption denotes device unmount options.
const ( UnmountOptionForce UnmountOption = "force" UnmountOptionDetach UnmountOption = "detach" UnmountOptionExpire UnmountOption = "expire" )
Unmount options.