filesystem

package
v0.0.0-...-eec02a6 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Filesystem types
	Xfs           = "xfs"
	Ext3          = "ext3"
	Ext4          = "ext4"
	Raw           = "raw"
	UnknownFstype = "<unknown>"
)
View Source
const (
	FormatOptionsSeparator = " "
)

Variables

This section is empty.

Functions

func DetermineFSType

func DetermineFSType(publishInfoType, existingType, volumeMode string) (string, error)

DetermineFSType resolves the effective filesystem type to use for a volume. Priority order:

  1. publishInfoType — use it as-is when provided (explicit caller intent).
  2. existingType — adopt the type already on disk when it is known (non-empty, non-UnknownFstype), so that subsequent format/mount logic stays consistent.
  3. volumeMode fallback — when no usable on-disk type is available, default to ext4 for Filesystem volumes or raw for Block volumes. A Filesystem volume whose on-disk type is UnknownFstype still defaults to ext4 but also returns an error because the LUN's existing format is unrecognisable.

func GetDeviceFilePath

func GetDeviceFilePath(ctx context.Context, path, volumeId string) (string, error)

GetDeviceFilePath returns the staging path for volume.

func ValidateOctalUnixPermissions

func ValidateOctalUnixPermissions(perms string) error

func VerifyFilesystemSupport

func VerifyFilesystemSupport(fs string) (string, error)

VerifyFilesystemSupport checks for a supported file system type

Types

type FSClient

type FSClient struct {
	// contains filtered or unexported fields
}

func New

func New(mount Mount) *FSClient

func NewDetailed

func NewDetailed(command tridentexec.Command, osFs afero.Fs, mount Mount) *FSClient

func (*FSClient) DeleteFile

func (f *FSClient) DeleteFile(ctx context.Context, filepath, fileDescription string) (string, error)

DeleteFile deletes the file at the provided path, and provides additional logging.

func (*FSClient) ExpandFilesystemOnNode

func (f *FSClient) ExpandFilesystemOnNode(
	ctx context.Context, publishInfo *models.VolumePublishInfo, devicePath, stagedTargetPath, fsType, mountOptions string,
	targetSizeBytes int64,
) (int64, error)

ExpandFilesystemOnNode expands the filesystem after the volume capacity step.

func (*FSClient) FormatVolume

func (f *FSClient) FormatVolume(ctx context.Context, device, fstype, options string) error

FormatVolume creates a filesystem for the supplied device of the supplied type.

func (*FSClient) GetDFOutput

func (f *FSClient) GetDFOutput(ctx context.Context) ([]models.DFInfo, error)

GetDFOutput returns parsed DF output

func (*FSClient) GetFilesystemSize

func (f *FSClient) GetFilesystemSize(ctx context.Context, path string) (int64, error)

GetFilesystemSize returns the total capacity in bytes of the filesystem at the given path.

func (*FSClient) GetFilesystemStats

func (f *FSClient) GetFilesystemStats(
	ctx context.Context, path string,
) (available, capacity, usage, inodes, inodesFree, inodesUsed int64, err error)

GetFilesystemStats returns the size of the filesystem for the given path. The caller of the func is responsible for verifying the mountPoint existence and readiness.

func (*FSClient) GetUnmountPath

func (f *FSClient) GetUnmountPath(ctx context.Context, trackingInfo *models.VolumeTrackingInfo) (string, error)

GetUnmountPath is a dummy added for compilation

func (*FSClient) RepairVolume

func (f *FSClient) RepairVolume(ctx context.Context, device, fstype string)

RepairVolume runs fsck on a volume. This is best-effort, does not return error.

func (*FSClient) ScanDir

func (f *FSClient) ScanDir(path string) ([]os.FileInfo, error)

func (*FSClient) ScanFile

func (f *FSClient) ScanFile(filename string) ([]byte, error)

type Filesystem

type Filesystem interface {
	GetDFOutput(ctx context.Context) ([]models.DFInfo, error)
	FormatVolume(ctx context.Context, device, fstype, options string) error
	RepairVolume(ctx context.Context, device, fstype string)
	ExpandFilesystemOnNode(
		ctx context.Context, publishInfo *models.VolumePublishInfo, devicePath, stagedTargetPath, fsType, mountOptions string,
		targetSizeBytes int64,
	) (int64, error)
	DeleteFile(ctx context.Context, filepath, fileDescription string) (string, error)
	GetFilesystemStats(
		ctx context.Context, path string,
	) (available, capacity, usage, inodes, inodesFree, inodesUsed int64, err error)
	GetFilesystemSize(ctx context.Context, path string) (int64, error)
	GetUnmountPath(ctx context.Context, trackingInfo *models.VolumeTrackingInfo) (string, error)
	ScanFile(filename string) ([]byte, error)
	ScanDir(path string) ([]os.FileInfo, error)
}

type JSONReaderWriter

type JSONReaderWriter interface {
	WriteJSONFile(ctx context.Context, fileContents interface{}, filepath, fileDescription string) error
	ReadJSONFile(ctx context.Context, fileContents interface{}, filepath, fileDescription string) error
}

func NewJSONReaderWriter

func NewJSONReaderWriter(osFs afero.Fs) JSONReaderWriter

type Mount

type Mount interface {
	MountFilesystemForResize(ctx context.Context, devicePath, stagedTargetPath, mountOptions string) (string, error)
	RemoveMountPoint(ctx context.Context, mountPointPath string) error
}

Jump to

Keyboard shortcuts

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