diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2020-10-10 13:07:57 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-10 13:07:57 +0800 |
| commit | 411e49f96494629fa3da334e8dc7cc15bd4d19cd (patch) | |
| tree | 1756f0a2f86c871a6db67df7ecbd509c9df32233 /weed/command/mount_std.go | |
| parent | ac162fc85769cb1b2a1f8694f9644eae7d0ce6c8 (diff) | |
| parent | 4a15e9c830de1b654515308e5be8380ffa34aefa (diff) | |
| download | seaweedfs-411e49f96494629fa3da334e8dc7cc15bd4d19cd.tar.xz seaweedfs-411e49f96494629fa3da334e8dc7cc15bd4d19cd.zip | |
Merge pull request #23 from chrislusf/master
sync
Diffstat (limited to 'weed/command/mount_std.go')
| -rw-r--r-- | weed/command/mount_std.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go index 7c0f56d3a..14374eb5c 100644 --- a/weed/command/mount_std.go +++ b/weed/command/mount_std.go @@ -7,6 +7,7 @@ import ( "fmt" "github.com/chrislusf/seaweedfs/weed/filesys/meta_cache" "os" + "os/user" "path" "runtime" "strconv" @@ -92,6 +93,29 @@ func RunMount(option *MountOptions, umask os.FileMode) bool { } fileInfo, err := os.Stat(dir) + uid, gid := uint32(0), uint32(0) + mountMode := os.ModeDir | 0777 + if err == nil { + mountMode = os.ModeDir | fileInfo.Mode() + uid, gid = util.GetFileUidGid(fileInfo) + fmt.Printf("mount point owner uid=%d gid=%d mode=%s\n", uid, gid, fileInfo.Mode()) + } else { + fmt.Printf("can not stat %s\n", dir) + return false + } + + if uid == 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) + } + fmt.Printf("current uid=%d gid=%d\n", uid, gid) + } + } + // mapping uid, gid uidGidMapper, err := meta_cache.NewUidGidMapper(*option.uidMap, *option.gidMap) if err != nil { @@ -150,6 +174,9 @@ func RunMount(option *MountOptions, umask os.FileMode) bool { CacheSizeMB: *option.cacheSizeMB, DataCenter: *option.dataCenter, EntryCacheTtl: 3 * time.Second, + MountUid: uid, + MountGid: gid, + MountMode: mountMode, MountCtime: fileInfo.ModTime(), MountMtime: time.Now(), Umask: umask, |
