1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-16 00:04:40 +00: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:
Nick Craig-Wood
2022-04-21 20:28:09 +01:00
parent 06598531e0
commit 5605e34f7b
4 changed files with 33 additions and 38 deletions

View File

@@ -102,16 +102,15 @@ func RunTests(t *testing.T, useVFS bool, fn mountlib.MountFn) {
// Run holds the remotes for a test run
type Run struct {
os Oser
vfs *vfs.VFS
useVFS bool // set if we are testing a VFS not a mount
mountPath string
fremote fs.Fs
fremoteName string
cleanRemote func()
umountResult <-chan error
umountFn mountlib.UnmountFn
skip bool
os Oser
vfs *vfs.VFS
useVFS bool // set if we are testing a VFS not a mount
mnt *mountlib.MountPoint
mountPath string
fremote fs.Fs
fremoteName string
cleanRemote func()
skip bool
}
// run holds the master Run data
@@ -125,8 +124,7 @@ var run *Run
// Finalise() will tidy them away when done.
func newRun(useVFS bool) *Run {
r := &Run{
useVFS: useVFS,
umountResult: make(chan error, 1),
useVFS: useVFS,
}
fstest.Initialise()
@@ -173,14 +171,16 @@ func findMountPath() string {
func (r *Run) mount() {
log.Printf("mount %q %q", r.fremote, r.mountPath)
var err error
r.vfs = vfs.New(r.fremote, &vfsflags.Opt)
r.umountResult, r.umountFn, err = mountFn(r.vfs, r.mountPath, &mountlib.Opt)
r.mnt = mountlib.NewMountPoint(mountFn, r.mountPath, r.fremote, &mountlib.Opt, &vfsflags.Opt)
_, err = r.mnt.Mount()
if err != nil {
log.Printf("mount FAILED: %v", err)
r.skip = true
} else {
log.Printf("mount OK")
}
r.vfs = r.mnt.VFS
if r.useVFS {
r.os = vfsOs{r.vfs}
} else {
@@ -202,17 +202,17 @@ func (r *Run) umount() {
}
*/
log.Printf("Unmounting %q", r.mountPath)
err := r.umountFn()
err := r.mnt.Unmount()
if err != nil {
log.Printf("signal to umount failed - retrying: %v", err)
time.Sleep(3 * time.Second)
err = r.umountFn()
err = r.mnt.Unmount()
}
if err != nil {
log.Fatalf("signal to umount failed: %v", err)
}
log.Printf("Waiting for umount")
err = <-r.umountResult
err = <-r.mnt.ErrChan
if err != nil {
log.Fatalf("umount failed: %v", err)
}