Added FUSE support #55

Merged
Elara6331 merged 65 commits from yannickulrich/itd:fuse into master 2023-03-25 22:23:52 +00:00
3 changed files with 12 additions and 8 deletions
Showing only changes of commit 8f57a0be8d - Show all commits

View File

@ -106,5 +106,8 @@ func setCfgDefaults() {
"notifs.ignore.body": []string{},
"music.vol.interval": 5,
"fuse.enabled": false,
"fuse.mountpoint": "/tmp/itd/mnt",
}, "."), nil)
}

View File

@ -520,10 +520,9 @@ func (f *ITNode) Rmdir(ctx context.Context, name string) syscall.Errno {
func startFuse(ctx context.Context, dev *infinitime.Device) error {
// This is where we'll mount the FS
mntDir := "/tmp/x"
os.Mkdir(mntDir, 0755)
os.Mkdir(k.String("fuse.mountpoint"), 0755)
root := &ITNode{kind: 0}
server, err := fs.Mount(mntDir, root, &fs.Options{
server, err := fs.Mount(k.String("fuse.mountpoint"), root, &fs.Options{
MountOptions: fuse.MountOptions{
// Set to true to see how the file system works.
Debug: false,
@ -532,14 +531,14 @@ func startFuse(ctx context.Context, dev *infinitime.Device) error {
})
if err != nil {
log.Error("Mounting failed").
Str("target", mntDir).
Str("target", k.String("fuse.mountpoint")).
Err(err).
Send()
return err
}
log.Info("Mounted on target").
Str("target", mntDir).
Str("target", k.String("fuse.mountpoint")).
Send()
mydev := Device{dev : dev};

View File

@ -187,9 +187,11 @@ func main() {
log.Error("Error starting socket").Err(err).Send()
}
// Start fuse socket
if k.Bool("fuse.enabled") {
err = startFuse(ctx, dev)
if err != nil {
log.Error("Error starting socket").Err(err).Send()
log.Error("Error starting fuse socket").Err(err).Send()
}
}
// Block forever
select {}