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.
105 lines
3.1 KiB
Go
105 lines
3.1 KiB
Go
//go:build linux || darwin || freebsd || windows
|
|
|
|
package command
|
|
|
|
import "testing"
|
|
|
|
func Test_volumeName(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
filer string
|
|
filerMountRootPath string
|
|
dir string
|
|
override string
|
|
expected string
|
|
}{
|
|
{
|
|
name: "an override outranks the mounted path and the mount point",
|
|
filer: "127.0.0.1:8888",
|
|
filerMountRootPath: "/buckets/videos",
|
|
dir: `\\seaweedfs\Images`,
|
|
override: "MyDisk",
|
|
expected: "MyDisk",
|
|
},
|
|
{
|
|
name: "an override still gets commas replaced",
|
|
filer: "127.0.0.1:8888",
|
|
filerMountRootPath: "/",
|
|
override: "My, Disk",
|
|
expected: "My+ Disk",
|
|
},
|
|
{
|
|
name: "a drive letter leaves only the filer to fall back on",
|
|
filer: "127.0.0.1:8888",
|
|
filerMountRootPath: "/",
|
|
dir: "S:",
|
|
expected: "127.0.0.1:8888",
|
|
},
|
|
{
|
|
name: "empty path falls back to the filer",
|
|
filer: "127.0.0.1:8888",
|
|
filerMountRootPath: "",
|
|
expected: "127.0.0.1:8888",
|
|
},
|
|
{
|
|
name: "several filers stay parseable as one option",
|
|
filer: "127.0.0.1:8888,127.0.0.1:8889",
|
|
filerMountRootPath: "/",
|
|
expected: "127.0.0.1:8888+127.0.0.1:8889",
|
|
},
|
|
{
|
|
name: "a whole-tree mount takes the name of its network share",
|
|
filer: "127.0.0.1:8888",
|
|
filerMountRootPath: "/",
|
|
dir: `\\seaweedfs\Images`,
|
|
expected: "Images",
|
|
},
|
|
{
|
|
name: "a whole-tree mount takes the name of its directory",
|
|
filer: "127.0.0.1:8888",
|
|
filerMountRootPath: "/",
|
|
dir: "/mnt/seaweedfs",
|
|
expected: "seaweedfs",
|
|
},
|
|
{
|
|
name: "the mounted path outranks the mount point",
|
|
filer: "127.0.0.1:8888",
|
|
filerMountRootPath: "/buckets/videos",
|
|
dir: "/mnt/seaweedfs",
|
|
expected: "videos",
|
|
},
|
|
{
|
|
name: "a relative mount point is not a name",
|
|
filer: "127.0.0.1:8888",
|
|
filerMountRootPath: "/",
|
|
dir: ".",
|
|
expected: "127.0.0.1:8888",
|
|
},
|
|
{
|
|
name: "mounted directory names the disk",
|
|
filer: "127.0.0.1:8888",
|
|
filerMountRootPath: "/buckets/images",
|
|
expected: "images",
|
|
},
|
|
{
|
|
name: "trailing slash is not a name",
|
|
filer: "127.0.0.1:8888",
|
|
filerMountRootPath: "/buckets/videos/",
|
|
expected: "videos",
|
|
},
|
|
{
|
|
name: "spaces are kept, commas are not",
|
|
filer: "127.0.0.1:8888",
|
|
filerMountRootPath: "/Image, Disk",
|
|
expected: "Image+ Disk",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := volumeName(tt.filer, tt.filerMountRootPath, tt.dir, tt.override); got != tt.expected {
|
|
t.Errorf("volumeName(%q, %q, %q, %q) = %q, want %q", tt.filer, tt.filerMountRootPath, tt.dir, tt.override, got, tt.expected)
|
|
}
|
|
})
|
|
}
|
|
}
|