mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-06 15:55:48 +08:00
剩余空间使用free blocks代替available blocks
This commit is contained in:
@@ -65,8 +65,8 @@ func NewStatResult(rawStat *unix.Statfs_t) *StatResult {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *StatResult) AvailableSize() uint64 {
|
||||
return this.rawStat.Bavail * this.blockSize
|
||||
func (this *StatResult) FreeSize() uint64 {
|
||||
return this.rawStat.Bfree * this.blockSize
|
||||
}
|
||||
|
||||
func (this *StatResult) TotalSize() uint64 {
|
||||
@@ -74,8 +74,8 @@ func (this *StatResult) TotalSize() uint64 {
|
||||
}
|
||||
|
||||
func (this *StatResult) UsedSize() uint64 {
|
||||
if this.rawStat.Bavail <= this.rawStat.Blocks {
|
||||
return (this.rawStat.Blocks - this.rawStat.Bavail) * this.blockSize
|
||||
if this.rawStat.Bfree <= this.rawStat.Blocks {
|
||||
return (this.rawStat.Blocks - this.rawStat.Bfree) * this.blockSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ func TestStat(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log("available:", stat.AvailableSize()/(1<<30), "total:", stat.TotalSize()/(1<<30), "used:", stat.UsedSize()/(1<<30))
|
||||
t.Log("free:", stat.FreeSize()/(1<<30), "total:", stat.TotalSize()/(1<<30), "used:", stat.UsedSize()/(1<<30))
|
||||
}
|
||||
|
||||
func TestStatCache(t *testing.T) {
|
||||
@@ -23,7 +23,7 @@ func TestStatCache(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log("available:", stat.AvailableSize()/(1<<30), "total:", stat.TotalSize()/(1<<30), "used:", stat.UsedSize()/(1<<30))
|
||||
t.Log("free:", stat.FreeSize()/(1<<30), "total:", stat.TotalSize()/(1<<30), "used:", stat.UsedSize()/(1<<30))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user