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{}, "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") {
yannickulrich marked this conversation as resolved Outdated

FUSE should be started before the socket (socket should always be last)

FUSE should be started before the socket (socket should always be last)

Done in 3b96901

Done in 3b96901
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 {}