SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
mount: name the disk after the mounted path (#10958)
Chris Lu7658305c76c1
diff --git a/weed/command/mount.go b/weed/command/mount.goindex 8bbdca2dad..c42dfcdcf1 100644--- a/weed/command/mount.go+++ b/weed/command/mount.go@@ -199,6 +199,10 @@ var cmdMount = &Command{at the desktop; the network path form is reachable from every session, andeach user can map their own drive letter to it.+ Where the platform labels the disk, in Finder and in Explorer, the mounted+ path names it: -filer.path="/Image Disk" shows up as "Image Disk". Mounting+ the whole tree labels it with the filer address instead.+RDMA Acceleration:For ultra-fast reads, enable RDMA acceleration with an RDMA sidecar:weed mount -filer=localhost:8888 -dir=/mnt/seaweedfs \diff --git a/weed/command/mount_common.go b/weed/command/mount_common.goindex c3ac11d3b0..c61912955f 100644--- a/weed/command/mount_common.go+++ b/weed/command/mount_common.go@@ -283,3 +283,14 @@ func resolveCacheDirs(option *MountOptions) (string, string) {}return cacheDirForRead, cacheDirForWrite}++// volumeName labels the mount where the platform shows one, in Finder and in+// Explorer. The mounted path names the disk; the filer address, which every+// mount from one filer shares, is only the whole-tree fallback.+func volumeName(filer, filerMountRootPath string) string {+ name := path.Base(filerMountRootPath)+ if name == "/" || name == "." {+ name = filer+ }+ return strings.ReplaceAll(name, ",", "+")+}diff --git a/weed/command/mount_common_test.go b/weed/command/mount_common_test.gonew file mode 100644index 0000000000..b5b3226b79--- /dev/null+++ b/weed/command/mount_common_test.go@@ -0,0 +1,58 @@+//go:build linux || darwin || freebsd || windows++package command++import "testing"++func Test_volumeName(t *testing.T) {+ tests := []struct {+ name string+ filer string+ filerMountRootPath string+ expected string+ }{+ {+ name: "whole tree falls back to the filer",+ filer: "127.0.0.1:8888",+ filerMountRootPath: "/",+ 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: "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); got != tt.expected {+ t.Errorf("volumeName(%q, %q) = %q, want %q", tt.filer, tt.filerMountRootPath, got, tt.expected)+ }+ })+ }+}diff --git a/weed/command/mount_std.go b/weed/command/mount_std.goindex b352aea955..f29c51ddde 100644--- a/weed/command/mount_std.go+++ b/weed/command/mount_std.go@@ -134,7 +134,6 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {// mount fusefuseMountOptions := &fuse.MountOptions{AllowOther: *option.allowOthers,- Options: option.extraOptions,MaxBackground: maxBackground,CongestionThreshold: congestionThreshold,MaxWrite: 1024 * 1024 * 2,@@ -180,9 +179,12 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {fuseMountOptions.Options = append(fuseMountOptions.Options, "novncache")}fuseMountOptions.Options = append(fuseMountOptions.Options, "slow_statfs")- fuseMountOptions.Options = append(fuseMountOptions.Options, "volname="+serverFriendlyName)+ fuseMountOptions.Options = append(fuseMountOptions.Options, "volname="+volumeName(*option.filer, filerMountRootPath))fuseMountOptions.Options = append(fuseMountOptions.Options, fmt.Sprintf("iosize=%d", ioSizeMB*1024*1024))}+ // Last, so an option given on the command line wins over the default+ // this mount picked for it.+ fuseMountOptions.Options = append(fuseMountOptions.Options, option.extraOptions...)if option.writebackCache != nil {fuseMountOptions.EnableWriteback = *option.writebackCachediff --git a/weed/command/mount_windows.go b/weed/command/mount_windows.goindex fe52e565f9..e32019f2ee 100644--- a/weed/command/mount_windows.go+++ b/weed/command/mount_windows.go@@ -104,7 +104,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {}host := winfsp.New(seaweedFileSystem, winfsp.Options{- VolumeName: strings.ReplaceAll(*option.filer, ",", "+"),+ VolumeName: volumeName(*option.filer, *option.filerMountRootPath),Uid: ownedByMounter,Gid: ownedByMounter,CacheTimeout: windowsCacheTimeout,