Added FUSE support #55
10
fuse.go
@ -11,7 +11,15 @@ import (
|
|||||||
|
|
||||||
func startFUSE(ctx context.Context, dev *infinitime.Device) error {
|
func startFUSE(ctx context.Context, dev *infinitime.Device) error {
|
||||||
yannickulrich marked this conversation as resolved
Outdated
|
|||||||
// This is where we'll mount the FS
|
// This is where we'll mount the FS
|
||||||
os.Mkdir(k.String("fuse.mountpoint"), 0755)
|
err := os.MkdirAll(k.String("fuse.mountpoint"), 0755)
|
||||||
yannickulrich marked this conversation as resolved
Outdated
Elara6331
commented
Use Use `os.MkdirAll` here instead so that it creates parent directories, and handle the error (just return it).
yannickulrich
commented
This is actually a bit more complicated than that. If the mountpoint already exists, fuse will crash. We also can't delete the mountpoint beforehand ( This is actually a bit more complicated than that. If the mountpoint already exists, fuse will crash. We also can't delete the mountpoint beforehand (`rm: cannot remove '/tmp/itd/mnt': Transport endpoint is not connected`). The best way to solve this should be calling the [unmount function](https://pkg.go.dev/github.com/hanwen/go-fuse/v2@v2.2.0/fuse#Server.Unmount). How would you suggest going about doing this?
Elara6331
commented
Yeah, this one is going to be a bit more complicated. The FUSE library does have a different unmount function that you could call before trying to mount the fs, but it's not exported, so we'll need to do a small hack to get access to it anyway. In the
|
|||||||
|
if err != nil && !os.IsExist(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore the error because nothing might be mounted on the mountpoint
|
||||||
|
_ = fusefs.Unmount(k.String("fuse.mountpoint"))
|
||||||
|
|
||||||
yannickulrich marked this conversation as resolved
Outdated
Elara6331
commented
`err` is returned twice here
yannickulrich
commented
Oh, sorry, fixed now Oh, sorry, fixed now
|
|||||||
|
|
||||||
root, err := fusefs.BuildRootNode(dev)
|
root, err := fusefs.BuildRootNode(dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Building root node failed").
|
log.Error("Building root node failed").
|
||||||
|
This function should be called
startFUSE
instead to adhere to Go naming conventionsThanks, I'm relatively new to Go, sorry for these issues
Done in
673383f