diff --git a/pkg/disk/stat_fallback.go b/pkg/disk/stat_netbsd.go similarity index 60% rename from pkg/disk/stat_fallback.go rename to pkg/disk/stat_netbsd.go index 66f7c6f69..5591cc5a8 100644 --- a/pkg/disk/stat_fallback.go +++ b/pkg/disk/stat_netbsd.go @@ -1,7 +1,7 @@ // +build netbsd /* - * MinIO Cloud Storage, (C) 2017 MinIO, Inc. + * MinIO Cloud Storage, (C) 2020 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,23 @@ package disk +import ( + "golang.org/x/sys/unix" +) + // GetInfo returns total and free bytes available in a directory, e.g. `/`. func GetInfo(path string) (info Info, err error) { - return Info{}, nil + s := unix.Statvfs_t{} + if err = unix.Statvfs(path, &s); err != nil { + return Info{}, err + } + reservedBlocks := uint64(s.Bfree) - uint64(s.Bavail) + info = Info{ + Total: uint64(s.Frsize) * (uint64(s.Blocks) - reservedBlocks), + Free: uint64(s.Frsize) * uint64(s.Bavail), + Files: uint64(s.Files), + Ffree: uint64(s.Ffree), + FSType: string(s.Fstypename[:]), + } + return info, nil }