Added fuse to config

This commit is contained in:
Yannick Ulrich 2023-02-26 13:40:44 +00:00
parent 4389609500
commit 8f57a0be8d
3 changed files with 12 additions and 8 deletions

View File

@ -106,5 +106,8 @@ func setCfgDefaults() {
"notifs.ignore.body": []string{}, "notifs.ignore.body": []string{},
"music.vol.interval": 5, "music.vol.interval": 5,
"fuse.enabled": false,
"fuse.mountpoint": "/tmp/itd/mnt",
}, "."), nil) }, "."), 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 { func startFuse(ctx context.Context, dev *infinitime.Device) error {
// This is where we'll mount the FS // This is where we'll mount the FS
mntDir := "/tmp/x" os.Mkdir(k.String("fuse.mountpoint"), 0755)
os.Mkdir(mntDir, 0755)
root := &ITNode{kind: 0} 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{ MountOptions: fuse.MountOptions{
// Set to true to see how the file system works. // Set to true to see how the file system works.
Debug: false, Debug: false,
@ -532,14 +531,14 @@ func startFuse(ctx context.Context, dev *infinitime.Device) error {
}) })
if err != nil { if err != nil {
log.Error("Mounting failed"). log.Error("Mounting failed").
Str("target", mntDir). Str("target", k.String("fuse.mountpoint")).
Err(err). Err(err).
Send() Send()
return err return err
} }
log.Info("Mounted on target"). log.Info("Mounted on target").
Str("target", mntDir). Str("target", k.String("fuse.mountpoint")).
Send() Send()
mydev := Device{dev : dev}; mydev := Device{dev : dev};

View File

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