diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2021-06-02 12:54:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-02 12:54:44 -0700 |
| commit | 0a5388744c6603921319ad54e905ebe381a3ba69 (patch) | |
| tree | 2e4db5cbd91f677192bea5f458ccf42c1eb1746c /weed/command/mount_std.go | |
| parent | 62142ff1d2fd3646f4858c51b904fd6aaf3b3b30 (diff) | |
| parent | 77100754e60752915af008070e3a951e08a67890 (diff) | |
| download | seaweedfs-0a5388744c6603921319ad54e905ebe381a3ba69.tar.xz seaweedfs-0a5388744c6603921319ad54e905ebe381a3ba69.zip | |
Merge pull request #2105 from Woellchen/current_and_parent_dot_directories
Return artificial . and .. directories
Diffstat (limited to 'weed/command/mount_std.go')
| -rw-r--r-- | weed/command/mount_std.go | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go index e72a2f2cf..dce2197d6 100644 --- a/weed/command/mount_std.go +++ b/weed/command/mount_std.go @@ -5,15 +5,18 @@ package command import ( "context" "fmt" - "github.com/chrislusf/seaweedfs/weed/storage/types" "os" "os/user" "path" + "path/filepath" "runtime" "strconv" "strings" + "syscall" "time" + "github.com/chrislusf/seaweedfs/weed/storage/types" + "github.com/chrislusf/seaweedfs/weed/filesys/meta_cache" "github.com/seaweedfs/fuse" @@ -49,6 +52,21 @@ func runMount(cmd *Command, args []string) bool { return RunMount(&mountOptions, os.FileMode(umask)) } +func getParentInode(mountDir string) (uint64, error) { + parentDir := filepath.Clean(filepath.Join(mountDir, "..")) + fi, err := os.Stat(parentDir) + if err != nil { + return 0, err + } + + stat, ok := fi.Sys().(*syscall.Stat_t) + if !ok { + return 0, nil + } + + return stat.Ino, nil +} + func RunMount(option *MountOptions, umask os.FileMode) bool { filers := strings.Split(*option.filer, ",") @@ -85,13 +103,19 @@ func RunMount(option *MountOptions, umask os.FileMode) bool { filerMountRootPath := *option.filerMountRootPath dir := util.ResolvePath(*option.dir) - chunkSizeLimitMB := *mountOptions.chunkSizeLimitMB + parentInode, err := getParentInode(dir) + if err != nil { + glog.Errorf("failed to retrieve inode for parent directory of %s: %v", dir, err) + return true + } fmt.Printf("This is SeaweedFS version %s %s %s\n", util.Version(), runtime.GOOS, runtime.GOARCH) if dir == "" { fmt.Printf("Please specify the mount directory via \"-dir\"") return false } + + chunkSizeLimitMB := *mountOptions.chunkSizeLimitMB if chunkSizeLimitMB <= 0 { fmt.Printf("Please specify a reasonable buffer size.") return false @@ -199,6 +223,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool { MountMode: mountMode, MountCtime: fileInfo.ModTime(), MountMtime: time.Now(), + MountParentInode: parentInode, Umask: umask, VolumeServerAccess: *mountOptions.volumeServerAccess, Cipher: cipher, |
