Documentation ¶
Index ¶
- Variables
- func ApplyLoopDevice(ctx context.Context, executor exec.Interface, imagePath, symlinkPath string, ...) (bool, error)
- func DeleteLoopDevice(ctx context.Context, executor exec.Interface, ...) error
- func GetBlockSize(device string, sysfsPath string) (int, error)
- func GetDeviceWithName(ctx context.Context, executor exec.Interface, devtmpfsPath, name string) (string, error)
- func MakeFS(ctx context.Context, executor exec.Interface, device string, blockSize int, ...) (bool, error)
- func MakeRAID0(ctx context.Context, executor exec.Interface, ...) (changed bool, err error)
Constants ¶
This section is empty.
Variables ¶
var (
ErrRAIDNotFound = fmt.Errorf("cannot find raid device")
)
Functions ¶
func ApplyLoopDevice ¶ added in v1.12.0
func ApplyLoopDevice(ctx context.Context, executor exec.Interface, imagePath, symlinkPath string, sizeBytes int64) (bool, error)
ApplyLoopDevice creates an image for loop device, actual loop device and symlink associated with provided name. Creation of loop device consist of following steps: 1. Creating an image file for the loop device using the provided image and sizeBytes parameters. 2. Attaching loop device to the created image file. 3. Creating a symbolic link under /dev/loops with the specified name. False is returned when there was nothing to do, meaning such loop device, image and symlink already exists.
func DeleteLoopDevice ¶ added in v1.12.0
func DeleteLoopDevice(ctx context.Context, executor exec.Interface, deviceSymlinkPath, devicePath, imagePath string) error
DeleteLoopDevice removes loop device and files associated with it like image and symlink.
func GetDeviceWithName ¶ added in v1.12.0
func GetDeviceWithName(ctx context.Context, executor exec.Interface, devtmpfsPath, name string) (string, error)
GetDeviceWithName finds a device path to the raid array with given name. Because mdadm - tool used for array creation - doesn't always use the name we provide, we need to find the device using several heuristics. Different versions of mdadm behaves differently, so there are multiple steps of it. 1. Try provided name, it could be a reference to a device - if it exists, resolve and return it. 2. Try expected name and location /dev/md/name - if file exists, that's the device. 3. Try expected name and location /dev/loops/name - if file exists, resolve symlink and return the device it points to. 4. List /dev/disk/by-id/md-name-* files, if name we search for is a suffix, then the symlink points to the raid device. 5. Parse mdadm report and find the device by checking name stored in metadata. It supports passing either a name of raid device, or full /dev/md/name pattern.
Types ¶
This section is empty.