aboutsummaryrefslogtreecommitdiff
path: root/contrib/statfs
diff options
context:
space:
mode:
authorJakob Unterwurzacher2019-03-17 12:48:44 +0100
committerJakob Unterwurzacher2019-03-17 12:48:44 +0100
commit5857521b40c3d7b9a8f92d6116d398553db10a2e (patch)
tree8b8e116562a978c0375769749dc67157f56f9102 /contrib/statfs
parentcd7a6862116dc3bac11d2a67fe93f20a7afc7284 (diff)
Add contrib/statfs tool
This should help debugging https://github.com/rfjakob/gocryptfs/issues/375 and https://github.com/rfjakob/gocryptfs/issues/274 , as MacOS does not have "stat -f".
Diffstat (limited to 'contrib/statfs')
-rw-r--r--contrib/statfs/.gitignore1
-rw-r--r--contrib/statfs/statfs.go34
2 files changed, 35 insertions, 0 deletions
diff --git a/contrib/statfs/.gitignore b/contrib/statfs/.gitignore
new file mode 100644
index 0000000..1ad5baa
--- /dev/null
+++ b/contrib/statfs/.gitignore
@@ -0,0 +1 @@
+/statfs
diff --git a/contrib/statfs/statfs.go b/contrib/statfs/statfs.go
new file mode 100644
index 0000000..5dcbd07
--- /dev/null
+++ b/contrib/statfs/statfs.go
@@ -0,0 +1,34 @@
+package main
+
+import (
+ "encoding/json"
+ "flag"
+ "fmt"
+ "os"
+ "syscall"
+)
+
+const (
+ myName = "statfs"
+)
+
+func main() {
+ flag.Usage = func() {
+ fmt.Fprintf(os.Stderr, "Usage: %s PATH\n", myName)
+ fmt.Fprintf(os.Stderr, "Dump the statfs information for PATH to the console, JSON format.\n")
+ os.Exit(1)
+ }
+ flag.Parse()
+ if flag.NArg() != 1 {
+ flag.Usage()
+ }
+ path := flag.Arg(0)
+ var st syscall.Statfs_t
+ err := syscall.Statfs(path, &st)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "statfs syscall returned error: %v\n", err)
+ os.Exit(2)
+ }
+ jsn, _ := json.MarshalIndent(st, "", "\t")
+ fmt.Println(string(jsn))
+}