SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
//go:build !windows && !openbsd && !netbsd && !plan9 && !solaris
package stats
import (
"syscall"
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
)
func fillInDiskStatus(disk *volume_server_pb.DiskStatus) error {
fs := syscall.Statfs_t{}
if err := syscall.Statfs(disk.Dir, &fs); err != nil {
return err
}
disk.All = fs.Blocks * uint64(fs.Bsize)
// https://man7.org/linux/man-pages/man3/statvfs.3.html
// fs.Bfree: Number of free blocks
// fs.Bavail: Number of free blocks for unprivileged users
disk.Free = uint64(fs.Bavail) * uint64(fs.Bsize)
disk.Used = disk.All - disk.Free
disk.PercentFree = float32(float64(disk.Free) / float64(disk.All) * 100)
disk.PercentUsed = float32(float64(disk.Used) / float64(disk.All) * 100)
return nil
}