Skip to content

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.

set mount point to existing permissions

Chris Lu03c7447ad670
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go
index e238fafbfc..9ab21010e7 100644
--- a/weed/command/mount_std.go
+++ b/weed/command/mount_std.go
@@ -4,7 +4,10 @@ package command
import (
"fmt"
+ "os"
+ "os/user"
"runtime"
+ "strconv"
"strings"
"time"
@@ -28,6 +31,24 @@ func runMount(cmd *Command, args []string) bool {
fuse.Unmount(*mountOptions.dir)
+ // detect mount folder mode
+ mountMode := os.ModeDir | 0755
+ if fileInfo, err := os.Stat(*mountOptions.dir); err == nil {
+ mountMode = os.ModeDir | fileInfo.Mode()
+ println(*mountOptions.dir, "mount mode", mountMode)
+ }
+
+ // detect current user
+ uid, gid := uint32(0), uint32(0)
+ if u, err := user.Current(); err == nil {
+ if parsedId, pe := strconv.ParseUint(u.Uid, 10, 32); pe == nil {
+ uid = uint32(parsedId)
+ }
+ if parsedId, pe := strconv.ParseUint(u.Gid, 10, 32); pe == nil {
+ gid = uint32(parsedId)
+ }
+ }
+
util.SetupProfiling(*mountCpuProfile, *mountMemProfile)
c, err := fuse.Mount(
@@ -77,6 +98,9 @@ func runMount(cmd *Command, args []string) bool {
DataCenter: *mountOptions.dataCenter,
DirListingLimit: *mountOptions.dirListingLimit,
EntryCacheTtl: 3 * time.Second,
+ MountUid: uid,
+ MountGid: gid,
+ MountMode: mountMode,
}))
if err != nil {
fuse.Unmount(*mountOptions.dir)
diff --git a/weed/filesys/dir.go b/weed/filesys/dir.go
index 14905d4c44..f3291a3d92 100644
--- a/weed/filesys/dir.go
+++ b/weed/filesys/dir.go
@@ -34,8 +34,10 @@ func (dir *Dir) Attr(context context.Context, attr *fuse.Attr) error {
// https://github.com/bazil/fuse/issues/196
attr.Valid = time.Second
- if dir.Path == "/" {
- attr.Mode = os.ModeDir | 0777
+ if dir.Path == dir.wfs.option.FilerMountRootPath {
+ attr.Uid = dir.wfs.option.MountUid
+ attr.Gid = dir.wfs.option.MountGid
+ attr.Mode = dir.wfs.option.MountMode
return nil
}
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go
index 9808c560e5..95256f8b77 100644
--- a/weed/filesys/wfs.go
+++ b/weed/filesys/wfs.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math"
+ "os"
"sync"
"time"
@@ -26,6 +27,10 @@ type Option struct {
DataCenter string
DirListingLimit int
EntryCacheTtl time.Duration
+
+ MountUid uint32
+ MountGid uint32
+ MountMode os.FileMode
}
var _ = fs.FS(&WFS{})