mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-08 23:50:43 +02:00
* mount: let volumeName take an explicit override volumeName only ever derived the disk's label from -filer.path, -dir, or the filer address, so a name that happened to collide with something else - e.g. a UNC share's own name - could not be changed without moving what was mounted. Give it an override parameter that wins over all three; nothing passes one yet. * mount: add -volumeName to name the disk explicitly Windows has no equivalent of the "weed fuse" -o passthrough that lets a Linux or macOS mount override its derived volname, so a name picked up from -dir - e.g. a UNC share's own name - could not be changed short of moving what was mounted. -volumeName overrides it on every platform. * mount: document -volumeName * mount: scope -volumeName's help text to macOS and Windows Linux has no volume-label mount option for -volumeName to feed, so the flag's own description says where it applies instead of leaving that unstated. * mount: forward -volumeName through the weed fuse option parser weed fuse (the /etc/fstab helper) turns -o key=value into the same MountOptions weed mount takes, but volumeName had no case, so it fell through to being forwarded as a literal, unrecognized FUSE option instead of ever reaching mountOptions.volumeName. * mount: apply -volumeName to FsName on Linux and FreeBSD FsName only ever took the filer address and -filer.path, so -volumeName had nothing to override there and silently did nothing; the skipAutofs case still forces "fuse", since that name is what util-linux/mount requires to recognize the pseudo filesystem.
68 lines
1.8 KiB
Go
68 lines
1.8 KiB
Go
//go:build darwin || freebsd || linux
|
|
|
|
package command
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestRunFuseDoesNotSkipOptionAfterConcurrentWriters(t *testing.T) {
|
|
oldUmask := mountOptions.umaskString
|
|
oldWriters := mountOptions.concurrentWriters
|
|
oldReaders := mountOptions.concurrentReaders
|
|
oldFuseCommandPid := mountOptions.fuseCommandPid
|
|
oldDir := mountOptions.dir
|
|
defer func() {
|
|
mountOptions.umaskString = oldUmask
|
|
mountOptions.concurrentWriters = oldWriters
|
|
mountOptions.concurrentReaders = oldReaders
|
|
mountOptions.fuseCommandPid = oldFuseCommandPid
|
|
mountOptions.dir = oldDir
|
|
|
|
recovered := recover()
|
|
if recovered == nil {
|
|
t.Fatal("expected invalid concurrentReaders option to be parsed")
|
|
}
|
|
if !strings.Contains(fmt.Sprint(recovered), "concurrentReaders") {
|
|
t.Fatalf("expected concurrentReaders parse error, got %v", recovered)
|
|
}
|
|
}()
|
|
|
|
runFuse(cmdMount, []string{
|
|
"/mnt",
|
|
"-o",
|
|
"child=1,concurrentWriters=2,concurrentReaders=bad,umask=bad",
|
|
})
|
|
}
|
|
|
|
func TestRunFuseSetsVolumeName(t *testing.T) {
|
|
oldVolumeName := mountOptions.volumeName
|
|
oldConcurrentReaders := mountOptions.concurrentReaders
|
|
oldDir := mountOptions.dir
|
|
defer func() {
|
|
gotVolumeName := mountOptions.volumeName
|
|
mountOptions.volumeName = oldVolumeName
|
|
mountOptions.concurrentReaders = oldConcurrentReaders
|
|
mountOptions.dir = oldDir
|
|
|
|
recovered := recover()
|
|
if recovered == nil {
|
|
t.Fatal("expected invalid concurrentReaders option to be parsed")
|
|
}
|
|
if gotVolumeName == nil {
|
|
t.Fatal("expected -o volumeName=MyDisk to set mountOptions.volumeName, got nil")
|
|
}
|
|
if *gotVolumeName != "MyDisk" {
|
|
t.Fatalf("expected -o volumeName=MyDisk to set mountOptions.volumeName, got %q", *gotVolumeName)
|
|
}
|
|
}()
|
|
|
|
runFuse(cmdMount, []string{
|
|
"/mnt",
|
|
"-o",
|
|
"volumeName=MyDisk,concurrentReaders=bad",
|
|
})
|
|
}
|