diff --git a/pkg/disk/stat_bsd.go b/pkg/disk/stat_bsd.go index 0d803f0e7..3dee0d455 100644 --- a/pkg/disk/stat_bsd.go +++ b/pkg/disk/stat_bsd.go @@ -29,11 +29,13 @@ func GetInfo(path string) (info Info, err error) { if err != nil { return Info{}, err } - info = Info{} - info.Total = uint64(s.Bsize) * uint64(s.Blocks) - info.Free = uint64(s.Bsize) * uint64(s.Bavail) - info.Files = uint64(s.Files) - info.Ffree = uint64(s.Ffree) - info.FSType = getFSType(s.Fstypename) + fsReservedBlocks := uint64(s.Bfree) - uint64(s.Bavail) + info = Info{ + Total: uint64(s.Bsize) * (uint64(s.Blocks) - fsReservedBlocks), + Free: uint64(s.Bsize) * uint64(s.Bavail), + Files: uint64(s.Files), + Ffree: uint64(s.Ffree), + FSType: getFSType(s.Fstypename), + } return info, nil } diff --git a/pkg/disk/stat_linux.go b/pkg/disk/stat_linux.go index 1ecfc48ee..a4de8f9ac 100644 --- a/pkg/disk/stat_linux.go +++ b/pkg/disk/stat_linux.go @@ -29,11 +29,13 @@ func GetInfo(path string) (info Info, err error) { if err != nil { return Info{}, err } - info = Info{} - info.Total = uint64(s.Bsize) * uint64(s.Blocks) - info.Free = uint64(s.Bsize) * uint64(s.Bavail) - info.Files = uint64(s.Files) - info.Ffree = uint64(s.Ffree) - info.FSType = getFSType(int64(s.Type)) + fsReservedBlocks := uint64(s.Bfree) - uint64(s.Bavail) + info = Info{ + Total: uint64(s.Bsize) * (uint64(s.Blocks) - fsReservedBlocks), + Free: uint64(s.Bsize) * uint64(s.Bavail), + Files: uint64(s.Files), + Ffree: uint64(s.Ffree), + FSType: getFSType(int64(s.Type)), + } return info, nil } diff --git a/pkg/disk/stat_openbsd.go b/pkg/disk/stat_openbsd.go index b341dec93..eabb368fc 100644 --- a/pkg/disk/stat_openbsd.go +++ b/pkg/disk/stat_openbsd.go @@ -29,11 +29,13 @@ func GetInfo(path string) (info Info, err error) { if err != nil { return Info{}, err } - info = Info{} - info.Total = uint64(s.F_bsize) * uint64(s.F_blocks) - info.Free = uint64(s.F_bsize) * uint64(s.F_bavail) - info.Files = uint64(s.F_files) - info.Ffree = uint64(s.F_ffree) - info.FSType = getFSType(s.F_fstypename) + fsReservedBlocks := uint64(s.F_bfree) - uint64(s.F_bavail) + info = Info{ + Total: uint64(s.F_bsize) * (uint64(s.F_blocks) - fsReservedBlocks), + Free: uint64(s.F_bsize) * uint64(s.F_bavail), + Files: uint64(s.F_files), + Ffree: uint64(s.F_ffree), + FSType: getFSType(s.F_fstypename), + } return info, nil }