pkg/misc: add function to return free space for given path
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StringSet map[string]bool
|
type StringSet map[string]bool
|
||||||
@@ -39,3 +40,10 @@ func RelativeSymlinkTargetToDir(symPath string, dir string) (string, error) {
|
|||||||
|
|
||||||
return path, nil
|
return path, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FreeSpace(path string) (uint64, error) {
|
||||||
|
var stat unix.Statfs_t
|
||||||
|
unix.Statfs(path, &stat)
|
||||||
|
size := stat.Bavail * uint64(stat.Bsize)
|
||||||
|
return size, nil
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user