hanwen / go-fuse

FUSE bindings for Go
Other
2.04k stars 328 forks source link

Examples get "permission denied" on macOS #373

Closed goldsborough closed 2 years ago

goldsborough commented 4 years ago

I tried to run the examples from godoc.org for the go-fuse/v2/fs package on macOS but they failed pretty much out of the box for me. My steps:

  1. brew cask install osxfuse
  2. sudo reboot
  3. mkdir x && go mod init example.com/x
  4. Copy https://godoc.org/github.com/hanwen/go-fuse/fs#example-package--Dynamic into main.go
  5. go mod vendor
    go: finding module for package github.com/hanwen/go-fuse/v2/fs
    go: finding module for package github.com/hanwen/go-fuse/v2/fuse
    go: found github.com/hanwen/go-fuse/v2/fs in github.com/hanwen/go-fuse/v2 v2.0.3
    go: found github.com/hanwen/go-fuse/v2/fuse in github.com/hanwen/go-fuse/v2 v2.0.3
  6. go run main.go
    
    2020/09/20 19:41:37 rx 2: INIT i0 {7.19 Ra 0x100000 ATOMIC_O_TRUNC,VOL_RENAME,CASE_INSENSITIVE,XTIMES,0x18000000}
    2020/09/20 19:41:37 tx 2:     OK, {7.8 Ra 0x100000  0/0 Wr 0x10000 Tg 0x0}
    2020/09/20 19:41:37 rx 3: STATFS i1
    2020/09/20 19:41:37 rx 2: STATFS i1
    2020/09/20 19:41:37 tx 3:     OK, {blocks (0,0)/0 files 0/0 bs0 nl0 frs0}
    2020/09/20 19:41:37 tx 2:     OK, {blocks (0,0)/0 files 0/0 bs0 nl0 frs0}
    2020/09/20 19:41:37 rx 3: STATFS i1
    2020/09/20 19:41:37 tx 3:     OK, {blocks (0,0)/0 files 0/0 bs0 nl0 frs0}
    2020/09/20 19:41:37 rx 2: STATFS i1
    2020/09/20 19:41:37 tx 2:     OK, {blocks (0,0)/0 files 0/0 bs0 nl0 frs0}
    2020/09/20 19:41:37 rx 3: STATFS i1
    2020/09/20 19:41:37 tx 3:     OK, {blocks (0,0)/0 files 0/0 bs0 nl0 frs0}
    2020/09/20 19:41:37 rx 2: STATFS i1
    2020/09/20 19:41:37 tx 2:     OK, {blocks (0,0)/0 files 0/0 bs0 nl0 frs0}
    2020/09/20 19:41:37 rx 3: ACCESS i1 {u=501 g=20 x}
    2020/09/20 19:41:37 tx 3:     OK
    2020/09/20 19:41:37 rx 2: LOOKUP i1 [".go-fuse-epoll-hack"] 20b
    2020/09/20 19:41:37 tx 2:     2=no such file or directory, {i0 g0 tE=0s tA=0s {M00 SZ=0 L=0 0:0 0 0:0 A 0.000000 M 0.000000 C 0.000000}}
    2020/09/20 19:41:37 rx 3: ACCESS i1 {u=501 g=20 w}
    2020/09/20 19:41:37 tx 3:     13=permission denied
    2020/09/20 19:41:37 permission denied
    panic: permission denied

goroutine 1 [running]: log.Panic(0xc00017fea8, 0x1, 0x1) /usr/local/Cellar/go/1.15/libexec/src/log/log.go:351 +0xae main.main() /Users/goldsborough/Documents/Projects/x/main.go:118 +0x125 exit status 2



Interestingly, the `unionfs` example works. From what I can see it uses the old `nodefs`/`pathfs` APIs while the example above used the new `fs` API. Any thoughts on why the new API is resulting in permission errors?

More hints: It does work if I `sudo go run main.go` but then subsequently I can only access the mounted filesystem as root too. I also tried changing the directory from `/tmp/` to a local folder and that made no difference.
hanwen commented 3 years ago
2020/09/20 19:41:37 rx 3: ACCESS i1 {u=501 g=20 w}
2020/09/20 19:41:37 tx 3:     13=permission denied

have you tried implementing the Access operation?

hanwen commented 3 years ago

oh, wait it's the example, so it should provide the access function.

YoSev commented 3 years ago

I can confirm running into the same problem on MacOS 10.15.6

YoSev commented 3 years ago

Adding the follwing solves the problem for me:

// Implement (handleless) Access
var _ = (fs.NodeAccesser)((*bytesNode)(nil))

func (bn *bytesNode) Access(ctx context.Context, input uint32) (errno syscall.Errno) {
    return 0
}
hanwen commented 3 years ago

sorry for the delay.

I had a closer look. So, for some reason OSX is checking access(W_OK), on mount ie.

2020/09/20 19:41:37 rx 3: ACCESS i1 {u=501 g=20 w}
2020/09/20 19:41:37 tx 3:     13=permission denied

that is actually correct, as the Dynamic example is not a writable filesystem. It's unclear to me why OSXFUSE insists on having a writable root for the mount directory.

hanwen commented 3 years ago

I had a brief look at the OSXFUSE project page on github, but with the project being taken closed-source, it's not clear where to report bugs. Is there someone here who could post the bugreport in the appropriate queue?