Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples get "permission denied" on macOS #373

Closed
goldsborough opened this issue Sep 21, 2020 · 6 comments
Closed

Examples get "permission denied" on macOS #373

goldsborough opened this issue Sep 21, 2020 · 6 comments

Comments

@goldsborough
Copy link

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
  1. 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.

@goldsborough goldsborough changed the title Examples get permission denied on macOS Examples get "permission denied" on macOS Sep 21, 2020
@hanwen
Copy link
Owner

hanwen commented Dec 2, 2020

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
Copy link
Owner

hanwen commented Dec 8, 2020

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

@YoSev
Copy link

YoSev commented Dec 16, 2020

I can confirm running into the same problem on MacOS 10.15.6

@YoSev
Copy link

YoSev commented Dec 16, 2020

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
Copy link
Owner

hanwen commented Dec 27, 2020

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
Copy link
Owner

hanwen commented Dec 27, 2020

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?

adrianjagielak added a commit to adrianjagielak/go-fuse that referenced this issue Apr 5, 2022
Ports commit fee50bf to poll_darwin.go in order to allow read-only mounts on Darwin as well.

Fixes rfjakob/gocryptfs#595 where we can't use gocryptfs -ro or gocryptfs -reverse on macOS because go-fuse tries to write to the read-only mountpoint during initial mount.

Cheers!

Edit: signed the CLA and re-pushed so automated checks pass

Edit: potentially fixes hanwen#373

hanwen#420
@hanwen hanwen closed this as completed in 58a7e14 Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants