* Change file size units from SI to IEC 80000-13:2025 Increase left-padded (%S) file size string length to 5 characters Co-authored-by: Joe Lim <50560759+joelim-work@users.noreply.github.com> * Add note about used IEC units for file size in docs --------- Co-authored-by: Joe Lim <50560759+joelim-work@users.noreply.github.com>
20 lines
353 B
Go
20 lines
353 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func diskFree(wd string) string {
|
|
var stat unix.Statfs_t
|
|
|
|
if err := unix.Statfs(wd, &stat); err != nil {
|
|
log.Printf("diskfree: %s", err)
|
|
return ""
|
|
}
|
|
|
|
// Available blocks * size per block = available space in bytes
|
|
return "df: " + humanize(uint64(stat.F_bavail)*uint64(stat.F_bsize))
|
|
}
|