diff options
| author | Patrick Schmidt <patrick.schmidt@innogames.com> | 2021-06-02 19:30:55 +0200 |
|---|---|---|
| committer | Patrick Schmidt <patrick.schmidt@innogames.com> | 2021-06-02 21:28:02 +0200 |
| commit | 77100754e60752915af008070e3a951e08a67890 (patch) | |
| tree | d6331c66484209ba516a51bf342b8139b58330bd /weed/command/mount_std.go | |
| parent | cc34475012650bab1d38a248ccdd4cd92a00611f (diff) | |
| download | seaweedfs-77100754e60752915af008070e3a951e08a67890.tar.xz seaweedfs-77100754e60752915af008070e3a951e08a67890.zip | |
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, |
