From 08a6ab66b0a8779b25f1b9a7427d790752225b48 Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Sat, 27 Aug 2016 14:02:51 +0900 Subject: [PATCH] disk: If could not get Inodes, return empty. --- disk/disk_unix.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/disk/disk_unix.go b/disk/disk_unix.go index 2858008..3d81331 100644 --- a/disk/disk_unix.go +++ b/disk/disk_unix.go @@ -21,6 +21,10 @@ func Usage(path string) (*UsageStat, error) { InodesFree: (uint64(stat.Ffree)), } + // if could not get InodesTotal, return empty + if ret.InodesTotal < ret.InodesFree { + return ret, nil + } ret.InodesUsed = (ret.InodesTotal - ret.InodesFree) ret.InodesUsedPercent = (float64(ret.InodesUsed) / float64(ret.InodesTotal)) * 100.0 ret.Used = (uint64(stat.Blocks) - uint64(stat.Bfree)) * uint64(bsize)