use statvfs(2) for disk.GetInfo on NetBSD (#10257)

master
Tobias Nygren 4 years ago committed by GitHub
parent a2a5ec93d3
commit 052b5262ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      pkg/disk/stat_netbsd.go

@ -1,7 +1,7 @@
// +build netbsd // +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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,23 @@
package disk package disk
import (
"golang.org/x/sys/unix"
)
// GetInfo returns total and free bytes available in a directory, e.g. `/`. // GetInfo returns total and free bytes available in a directory, e.g. `/`.
func GetInfo(path string) (info Info, err error) { 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
} }
Loading…
Cancel
Save