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
FUSE mount: make "nonempty" optional
Chris Lu7c111f7b75ba
diff --git a/weed/command/mount.go b/weed/command/mount.goindex f1448c6ccf..d4a4ba7464 100644--- a/weed/command/mount.go+++ b/weed/command/mount.go@@ -12,6 +12,7 @@ type MountOptions struct {dataCenter *stringallowOthers *boolumaskString *string+ nonempty *booloutsideContainerClusterMode *bool}@@ -34,6 +35,7 @@ func init() {mountOptions.dataCenter = cmdMount.Flag.String("dataCenter", "", "prefer to write to the data center")mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system")mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")+ mountOptions.nonempty = cmdMount.Flag.Bool("nonempty", false, "allows the mounting over a non-empty directory")mountCpuProfile = cmdMount.Flag.String("cpuprofile", "", "cpu profile output file")mountMemProfile = cmdMount.Flag.String("memprofile", "", "memory profile output file")mountOptions.outsideContainerClusterMode = cmdMount.Flag.Bool("outsideContainerClusterMode", false, "allows other users to access the file system")diff --git a/weed/command/mount_linux.go b/weed/command/mount_linux.goindex 80a5f9da49..25c4f72cf4 100644--- a/weed/command/mount_linux.go+++ b/weed/command/mount_linux.go@@ -138,9 +138,7 @@ func parseInfoFile(r io.Reader) ([]*Info, error) {}func osSpecificMountOptions() []fuse.MountOption {- return []fuse.MountOption{- fuse.AllowNonEmptyMount(),- }+ return []fuse.MountOption{}}func checkMountPointAvailable(dir string) bool {diff --git a/weed/command/mount_std.go b/weed/command/mount_std.goindex 9177091a56..22ddd1f071 100644--- a/weed/command/mount_std.go+++ b/weed/command/mount_std.go@@ -35,24 +35,15 @@ func runMount(cmd *Command, args []string) bool {return false}- return RunMount(- *mountOptions.filer,- *mountOptions.filerMountRootPath,- *mountOptions.dir,- *mountOptions.collection,- *mountOptions.replication,- *mountOptions.dataCenter,- *mountOptions.chunkSizeLimitMB,- *mountOptions.allowOthers,- *mountOptions.ttlSec,- *mountOptions.dirListCacheLimit,- os.FileMode(umask),- *mountOptions.outsideContainerClusterMode,- )+ return RunMount(&mountOptions, os.FileMode(umask))}-func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCenter string, chunkSizeLimitMB int,- allowOthers bool, ttlSec int, dirListCacheLimit int64, umask os.FileMode, outsideContainerClusterMode bool) bool {+func RunMount(option *MountOptions, umask os.FileMode) bool {++ filer := *option.filer+ filerMountRootPath := *option.filerMountRootPath+ dir := *option.dir+ chunkSizeLimitMB := *mountOptions.chunkSizeLimitMButil.LoadConfiguration("security", false)@@ -114,14 +105,16 @@ func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCentefuse.MaxReadahead(1024 * 128),fuse.AsyncRead(),fuse.WritebackCache(),- fuse.AllowNonEmptyMount(),}options = append(options, osSpecificMountOptions()...)- if allowOthers {+ if *option.allowOthers {options = append(options, fuse.AllowOther())}+ if *option.nonempty {+ options = append(options, fuse.AllowNonEmptyMount())+ }c, err := fuse.Mount(dir, options...)if err != nil {@@ -171,12 +164,12 @@ func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCenteFilerGrpcAddress: filerGrpcAddress,GrpcDialOption: grpcDialOption,FilerMountRootPath: mountRoot,- Collection: collection,- Replication: replication,- TtlSec: int32(ttlSec),+ Collection: *option.collection,+ Replication: *option.replication,+ TtlSec: int32(*option.ttlSec),ChunkSizeLimit: int64(chunkSizeLimitMB) * 1024 * 1024,- DataCenter: dataCenter,- DirListCacheLimit: dirListCacheLimit,+ DataCenter: *option.dataCenter,+ DirListCacheLimit: *option.dirListCacheLimit,EntryCacheTtl: 3 * time.Second,MountUid: uid,MountGid: gid,@@ -184,7 +177,7 @@ func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCenteMountCtime: fileInfo.ModTime(),MountMtime: time.Now(),Umask: umask,- OutsideContainerClusterMode: outsideContainerClusterMode,+ OutsideContainerClusterMode: *mountOptions.outsideContainerClusterMode,Cipher: cipher,}))if err != nil {