libgocryptfs/contrib/getdents-debug/readdirnames/readdirnames.go
Jakob Unterwurzacher 34d8a498c4 Unbreak hyperlinks broken by go mod v2 conversion
Commit

  69d88505fd go mod: declare module version v2

translated all instances of "github.com/rfjakob/gocryptfs/" to
"github.com/rfjakob/gocryptfs/v2/".

Unfortunately, this included hyperlinks.

Unbreak the hyperlinks like this:

  find . -name \*.go | xargs sed -i s%https://github.com/rfjakob/gocryptfs/v2/%https://github.com/rfjakob/gocryptfs/v2/%
2021-08-30 11:31:01 +02:00

57 lines
1.3 KiB
Go

/*
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)
}