sys

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: AGPL-3.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

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

View Source
var LoopRegexp = regexp.MustCompile("^loop[0-9]*")

Functions

func FSTypeEqual added in v1.4.5

func FSTypeEqual(fsType1, fsType2 string) bool

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

func GetDirectCSIPath(driveName string) string

GetDirectCSIPath returns Direct CSI path of given drive name.

func GetMajorMinor added in v1.4.0

func GetMajorMinor(device string) (major, minor uint32, err error)

GetMajorMinor gets major/minor number of given device.

func MakeBlockFile added in v1.4.0

func MakeBlockFile(path string, major, minor uint32) error

MakeBlockFile creates device file by it's major/minor number.

func ProbeDevices added in v1.4.5

func ProbeDevices() (devices map[string]*Device, err error)

ProbeDevices probes all devices.

func ProbeMounts added in v1.4.5

func ProbeMounts() (map[string][]MountInfo, error)

ProbeMounts probes mount information from /proc/1/mountinfo.

func ReserveLoopbackDevices added in v1.3.0

func ReserveLoopbackDevices(devCount int) error

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.

func CreateDevice added in v1.4.5

func CreateDevice(event map[string]string) (device *Device, err error)

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"
	MountOptionMSShared      MountOption = "shared"
	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.

type VolumeMounter added in v1.3.0

type VolumeMounter interface {
	MountVolume(ctx context.Context, src, dest string, readOnly bool) error
	UnmountVolume(targetPath string) error
}

VolumeMounter is mount/unmount of volume interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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