disk

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// GetDiskFreeSpaceEx - https://msdn.microsoft.com/en-us/library/windows/desktop/aa364937(v=vs.85).aspx
	// Retrieves information about the amount of space that is available on a disk volume,
	// which is the total amount of space, the total amount of free space, and the total
	// amount of free space available to the user that is associated with the calling thread.
	GetDiskFreeSpaceEx = kernel32.NewProc("GetDiskFreeSpaceExW")

	// GetDiskFreeSpace - https://msdn.microsoft.com/en-us/library/windows/desktop/aa364935(v=vs.85).aspx
	// Retrieves information about the specified disk, including the amount of free space on the disk.
	GetDiskFreeSpace = kernel32.NewProc("GetDiskFreeSpaceW")
)
View Source
var (
	// GetVolumeInformation provides windows drive volume information.
	GetVolumeInformation = kernel32.NewProc("GetVolumeInformationW")
)

Functions

func AlignedBlock

func AlignedBlock(BlockSize int) []byte

AlignedBlock simply returns an unaligned buffer for systems that do not support DirectIO.

func DisableDirectIO

func DisableDirectIO(f *os.File) error

DisableDirectIO is a no-op

func Fdatasync

func Fdatasync(f *os.File) error

Fdatasync is a no-op

func GetHealthInfo

func GetHealthInfo(ctx context.Context, drive, fsPath string) (Latency, Throughput, error)

GetHealthInfo about the drive

func IsRootDisk

func IsRootDisk(diskPath string, rootDisk string) (bool, error)

IsRootDisk returns if diskPath belongs to root-disk, i.e the disk mounted at "/"

func OpenFileDirectIO

func OpenFileDirectIO(filePath string, flag int, perm os.FileMode) (*os.File, error)

OpenFileDirectIO wrapper around os.OpenFile nothing special

func SameDisk

func SameDisk(disk1, disk2 string) (bool, error)

SameDisk reports whether di1 and di2 describe the same disk.

Types

type Info

type Info struct {
	Total  uint64
	Free   uint64
	Used   uint64
	Files  uint64
	Ffree  uint64
	FSType string
}

Info stat fs struct is container which holds following values Total - total size of the volume / disk Free - free size of the volume / disk Files - total inodes available Ffree - free inodes available FSType - file system type

func GetInfo

func GetInfo(path string) (info Info, err error)

GetInfo returns total and free bytes available in a directory, e.g. `C:\`. It returns free space available to the user (including quota limitations)

https://msdn.microsoft.com/en-us/library/windows/desktop/aa364937(v=vs.85).aspx

type Latency

type Latency struct {
	Avg          float64 `json:"avg_secs,omitempty"`
	Percentile50 float64 `json:"percentile50_secs,omitempty"`
	Percentile90 float64 `json:"percentile90_secs,omitempty"`
	Percentile99 float64 `json:"percentile99_secs,omitempty"`
	Min          float64 `json:"min_secs,omitempty"`
	Max          float64 `json:"max_secs,omitempty"`
}

Latency holds latency information for write operations to the drive

type Throughput

type Throughput struct {
	Avg          float64 `json:"avg_bytes_per_sec,omitempty"`
	Percentile50 float64 `json:"percentile50_bytes_per_sec,omitempty"`
	Percentile90 float64 `json:"percentile90_bytes_per_sec,omitempty"`
	Percentile99 float64 `json:"percentile99_bytes_per_sec,omitempty"`
	Min          float64 `json:"min_bytes_per_sec,omitempty"`
	Max          float64 `json:"max_bytes_per_sec,omitempty"`
}

Throughput holds throughput information for write operations to the drive

Jump to

Keyboard shortcuts

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