aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-05-24 23:51:38 +0200
committerJakob Unterwurzacher2020-05-24 23:51:38 +0200
commit0d522e0d3b1e1ec4543ece4e7a9a0ed99da760c4 (patch)
treef23b0ad5e8614f4ada3dc67037cdd248a6380b28
parent6019598fdb9d223beec7da5848cf950ca90e85e7 (diff)
Add contrib/getdents-debug/readdirnames
Another way to repro the problem in https://github.com/rfjakob/gocryptfs/issues/483
-rw-r--r--contrib/getdents-debug/readdirnames/.gitignore1
-rw-r--r--contrib/getdents-debug/readdirnames/readdirnames.go56
2 files changed, 57 insertions, 0 deletions
diff --git a/contrib/getdents-debug/readdirnames/.gitignore b/contrib/getdents-debug/readdirnames/.gitignore
new file mode 100644
index 0000000..228dbb3
--- /dev/null
+++ b/contrib/getdents-debug/readdirnames/.gitignore
@@ -0,0 +1 @@
+/readdirnames
diff --git a/contrib/getdents-debug/readdirnames/readdirnames.go b/contrib/getdents-debug/readdirnames/readdirnames.go
new file mode 100644
index 0000000..dc33512
--- /dev/null
+++ b/contrib/getdents-debug/readdirnames/readdirnames.go
@@ -0,0 +1,56 @@
+/*
+Small tool to try to debug unix.Getdents problems on CIFS mounts
+( https://github.com/rfjakob/gocryptfs/issues/483 )
+
+Example output:
+
+$ while sleep 1 ; do ./readdirnames /mnt/synology/public/tmp/g1 ; done
+Readdirnames: len=1001, err=<nil>
+Readdirnames: len=1001, err=<nil>
+Readdirnames: len=1001, err=<nil>
+Readdirnames: len=1001, err=<nil>
+Readdirnames: len=868, err=readdirent: no such file or directory
+Readdirnames: len=1001, err=<nil>
+Readdirnames: len=1001, err=<nil>
+Readdirnames: len=1001, err=<nil>
+Readdirnames: len=1001, err=<nil>
+Readdirnames: len=1001, err=<nil>
+Readdirnames: len=1001, err=<nil>
+2020/05/24 23:50:39 os.Open returned err=open /mnt/synology/public/tmp/g1: interrupted system call
+Readdirnames: len=1001, err=<nil>
+Readdirnames: len=1001, err=<nil>
+*/
+
+package main
+
+import (
+ "flag"
+ "fmt"
+ "log"
+ "os"
+)
+
+const (
+ myName = "readdirnames"
+)
+
+func main() {
+ flag.Usage = func() {
+ fmt.Fprintf(os.Stderr, "Usage: %s PATH\n", myName)
+ fmt.Fprintf(os.Stderr, "Run os.File.Readdirnames on PATH\n")
+ os.Exit(1)
+ }
+ flag.Parse()
+ if flag.NArg() != 1 {
+ flag.Usage()
+ }
+ path := flag.Arg(0)
+
+ f, err := os.Open(path)
+ if err != nil {
+ log.Fatalf("os.Open returned err=%v", err)
+ }
+
+ names, err := f.Readdirnames(0)
+ fmt.Printf("Readdirnames: len=%d, err=%v\n", len(names), err)
+}