This computes the space usage for mounted partitions. It takes in a list of mounted partitions from containerHints and computes the device's disk usage(so each mount must be a separate partition). This is useful for users who mount partitions on containers and store most of the container's persistent data on those partitions.
28 lines
656 B
Go
28 lines
656 B
Go
package fs
|
|
|
|
type DeviceInfo struct {
|
|
Device string
|
|
Major uint
|
|
Minor uint
|
|
}
|
|
|
|
type Fs struct {
|
|
DeviceInfo
|
|
Capacity uint64
|
|
Free uint64
|
|
}
|
|
|
|
type FsInfo interface {
|
|
// Returns capacity and free space, in bytes, of all the ext2, ext3, ext4 filesystems on the host.
|
|
GetGlobalFsInfo() ([]Fs, error)
|
|
|
|
// Returns capacity and free space, in bytes, of the set of mounts passed.
|
|
GetFsInfoForPath(mountSet map[string]bool) ([]Fs, error)
|
|
|
|
// Returns number of bytes occupied by 'dir'.
|
|
GetDirUsage(dir string) (uint64, error)
|
|
|
|
// Returns the block device info of the filesystem on which 'dir' resides.
|
|
GetDirFsDevice(dir string) (*DeviceInfo, error)
|
|
}
|