mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 18:04:55 +01:00
mount: fix --devname and fusermount: unknown option 'fsname' when mounting via rc
In this commit
f4c40bf79d
mount: add --devname to set the device name sent to FUSE for mount display
The --devname parameter was added. However it was soon noticed that
attempting to mount via the rc gave this error:
mount helper error: fusermount: unknown option 'fsname'
mount FAILED: fusermount: exit status 1
This was because the DeviceName (and VolumeName) parameter was never
being initialised when the mount was called via the rc.
The fix for this was to refactor the rc interface so it called the
same Mount method as the command line mount which initialised the
DeviceName and VolumeName parameters properly.
This also fixes the cmd/mount tests which were breaking in the same
way but since they aren't normally run on the CI we didn't notice.
Fixes #6044
This commit is contained in:
parent
06598531e0
commit
5605e34f7b
@ -78,6 +78,17 @@ type MountPoint struct {
|
|||||||
ErrChan <-chan error
|
ErrChan <-chan error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewMountPoint makes a new mounting structure
|
||||||
|
func NewMountPoint(mount MountFn, mountPoint string, f fs.Fs, mountOpt *Options, vfsOpt *vfscommon.Options) *MountPoint {
|
||||||
|
return &MountPoint{
|
||||||
|
MountFn: mount,
|
||||||
|
MountPoint: mountPoint,
|
||||||
|
Fs: f,
|
||||||
|
MountOpt: *mountOpt,
|
||||||
|
VFSOpt: *vfsOpt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Global constants
|
// Global constants
|
||||||
const (
|
const (
|
||||||
MaxLeafSize = 1024 // don't pass file names longer than this
|
MaxLeafSize = 1024 // don't pass file names longer than this
|
||||||
@ -167,14 +178,7 @@ func NewMountCommand(commandName string, hidden bool, mount MountFn) *cobra.Comm
|
|||||||
defer cmd.StartStats()()
|
defer cmd.StartStats()()
|
||||||
}
|
}
|
||||||
|
|
||||||
mnt := &MountPoint{
|
mnt := NewMountPoint(mount, args[1], cmd.NewFsDir(args), &Opt, &vfsflags.Opt)
|
||||||
MountFn: mount,
|
|
||||||
MountPoint: args[1],
|
|
||||||
Fs: cmd.NewFsDir(args),
|
|
||||||
MountOpt: Opt,
|
|
||||||
VFSOpt: vfsflags.Opt,
|
|
||||||
}
|
|
||||||
|
|
||||||
daemon, err := mnt.Mount()
|
daemon, err := mnt.Mount()
|
||||||
|
|
||||||
// Wait for foreground mount, if any...
|
// Wait for foreground mount, if any...
|
||||||
@ -253,6 +257,7 @@ func (m *MountPoint) Mount() (daemon *os.Process, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to mount FUSE fs: %w", err)
|
return nil, fmt.Errorf("failed to mount FUSE fs: %w", err)
|
||||||
}
|
}
|
||||||
|
m.MountedOn = time.Now()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
"github.com/rclone/rclone/fs"
|
"github.com/rclone/rclone/fs"
|
||||||
"github.com/rclone/rclone/fs/rc"
|
"github.com/rclone/rclone/fs/rc"
|
||||||
"github.com/rclone/rclone/vfs"
|
|
||||||
"github.com/rclone/rclone/vfs/vfsflags"
|
"github.com/rclone/rclone/vfs/vfsflags"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -117,23 +116,15 @@ func mountRc(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
VFS := vfs.New(fdst, &vfsOpt)
|
mnt := NewMountPoint(mountFn, mountPoint, fdst, &mountOpt, &vfsOpt)
|
||||||
_, unmountFn, err := mountFn(VFS, mountPoint, &mountOpt)
|
_, err = mnt.Mount()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("mount FAILED: %v", err)
|
log.Printf("mount FAILED: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add mount to list if mount point was successfully created
|
// Add mount to list if mount point was successfully created
|
||||||
liveMounts[mountPoint] = &MountPoint{
|
liveMounts[mountPoint] = mnt
|
||||||
MountPoint: mountPoint,
|
|
||||||
MountedOn: time.Now(),
|
|
||||||
MountFn: mountFn,
|
|
||||||
UnmountFn: unmountFn,
|
|
||||||
MountOpt: mountOpt,
|
|
||||||
VFSOpt: vfsOpt,
|
|
||||||
Fs: fdst,
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.Debugf(nil, "Mount for %s created at %s using %s", fdst.String(), mountPoint, mountType)
|
fs.Debugf(nil, "Mount for %s created at %s using %s", fdst.String(), mountPoint, mountType)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -274,7 +274,6 @@ func (vol *Volume) mount(id string) error {
|
|||||||
if _, err := vol.mnt.Mount(); err != nil {
|
if _, err := vol.mnt.Mount(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
vol.mnt.MountedOn = time.Now()
|
|
||||||
vol.mountReqs[id] = nil
|
vol.mountReqs[id] = nil
|
||||||
vol.drv.monChan <- false // ask monitor to refresh channels
|
vol.drv.monChan <- false // ask monitor to refresh channels
|
||||||
return nil
|
return nil
|
||||||
|
@ -102,16 +102,15 @@ func RunTests(t *testing.T, useVFS bool, fn mountlib.MountFn) {
|
|||||||
|
|
||||||
// Run holds the remotes for a test run
|
// Run holds the remotes for a test run
|
||||||
type Run struct {
|
type Run struct {
|
||||||
os Oser
|
os Oser
|
||||||
vfs *vfs.VFS
|
vfs *vfs.VFS
|
||||||
useVFS bool // set if we are testing a VFS not a mount
|
useVFS bool // set if we are testing a VFS not a mount
|
||||||
mountPath string
|
mnt *mountlib.MountPoint
|
||||||
fremote fs.Fs
|
mountPath string
|
||||||
fremoteName string
|
fremote fs.Fs
|
||||||
cleanRemote func()
|
fremoteName string
|
||||||
umountResult <-chan error
|
cleanRemote func()
|
||||||
umountFn mountlib.UnmountFn
|
skip bool
|
||||||
skip bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// run holds the master Run data
|
// run holds the master Run data
|
||||||
@ -125,8 +124,7 @@ var run *Run
|
|||||||
// Finalise() will tidy them away when done.
|
// Finalise() will tidy them away when done.
|
||||||
func newRun(useVFS bool) *Run {
|
func newRun(useVFS bool) *Run {
|
||||||
r := &Run{
|
r := &Run{
|
||||||
useVFS: useVFS,
|
useVFS: useVFS,
|
||||||
umountResult: make(chan error, 1),
|
|
||||||
}
|
}
|
||||||
fstest.Initialise()
|
fstest.Initialise()
|
||||||
|
|
||||||
@ -173,14 +171,16 @@ func findMountPath() string {
|
|||||||
func (r *Run) mount() {
|
func (r *Run) mount() {
|
||||||
log.Printf("mount %q %q", r.fremote, r.mountPath)
|
log.Printf("mount %q %q", r.fremote, r.mountPath)
|
||||||
var err error
|
var err error
|
||||||
r.vfs = vfs.New(r.fremote, &vfsflags.Opt)
|
r.mnt = mountlib.NewMountPoint(mountFn, r.mountPath, r.fremote, &mountlib.Opt, &vfsflags.Opt)
|
||||||
r.umountResult, r.umountFn, err = mountFn(r.vfs, r.mountPath, &mountlib.Opt)
|
|
||||||
|
_, err = r.mnt.Mount()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("mount FAILED: %v", err)
|
log.Printf("mount FAILED: %v", err)
|
||||||
r.skip = true
|
r.skip = true
|
||||||
} else {
|
} else {
|
||||||
log.Printf("mount OK")
|
log.Printf("mount OK")
|
||||||
}
|
}
|
||||||
|
r.vfs = r.mnt.VFS
|
||||||
if r.useVFS {
|
if r.useVFS {
|
||||||
r.os = vfsOs{r.vfs}
|
r.os = vfsOs{r.vfs}
|
||||||
} else {
|
} else {
|
||||||
@ -202,17 +202,17 @@ func (r *Run) umount() {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
log.Printf("Unmounting %q", r.mountPath)
|
log.Printf("Unmounting %q", r.mountPath)
|
||||||
err := r.umountFn()
|
err := r.mnt.Unmount()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("signal to umount failed - retrying: %v", err)
|
log.Printf("signal to umount failed - retrying: %v", err)
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
err = r.umountFn()
|
err = r.mnt.Unmount()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("signal to umount failed: %v", err)
|
log.Fatalf("signal to umount failed: %v", err)
|
||||||
}
|
}
|
||||||
log.Printf("Waiting for umount")
|
log.Printf("Waiting for umount")
|
||||||
err = <-r.umountResult
|
err = <-r.mnt.ErrChan
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("umount failed: %v", err)
|
log.Fatalf("umount failed: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user