Big refactor
This commit is contained in:
@@ -1,54 +1,18 @@
|
||||
package zfs
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"bazil.org/fuse"
|
||||
"bazil.org/fuse/fs"
|
||||
"github.com/debridmediamanager.com/zurg/internal/config"
|
||||
"github.com/debridmediamanager.com/zurg/internal/torrent"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/logutil"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"github.com/winfsp/cgofuse/fuse"
|
||||
)
|
||||
|
||||
func Mount(mountpoint string, cfg config.ConfigInterface, tMgr *torrent.TorrentManager) error {
|
||||
log := logutil.NewLogger().Named("zfs")
|
||||
|
||||
options := []fuse.MountOption{
|
||||
fuse.AllowOther(),
|
||||
fuse.AllowNonEmptyMount(),
|
||||
fuse.MaxReadahead(uint32(128 << 10)),
|
||||
fuse.DefaultPermissions(),
|
||||
fuse.FSName("zurgfs"),
|
||||
}
|
||||
conn, err := fuse.Mount(mountpoint, options...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
srv := fs.New(conn, nil)
|
||||
|
||||
filesys := &FS{
|
||||
uid: uint32(unix.Geteuid()),
|
||||
gid: uint32(unix.Getegid()),
|
||||
umask: os.FileMode(0),
|
||||
config: cfg,
|
||||
tMgr: tMgr,
|
||||
log: log,
|
||||
initTime: time.Now(),
|
||||
}
|
||||
|
||||
if err := srv.Serve(filesys); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
func Mount(host *fuse.FileSystemHost, cfg config.ConfigInterface) error {
|
||||
host.SetCapCaseInsensitive(false)
|
||||
host.SetCapReaddirPlus(false)
|
||||
host.Mount(cfg.GetMountPoint(), []string{})
|
||||
return nil
|
||||
}
|
||||
|
||||
func Unmount(mountpoint string) error {
|
||||
fuse.Unmount(mountpoint)
|
||||
func Unmount(host *fuse.FileSystemHost) error {
|
||||
_ = host.Unmount()
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user