diff options
Diffstat (limited to 'weed/filesys')
| -rw-r--r-- | weed/filesys/dir.go | 55 | ||||
| -rw-r--r-- | weed/filesys/wfs.go | 18 | ||||
| -rw-r--r-- | weed/filesys/xattr.go | 15 |
3 files changed, 56 insertions, 32 deletions
diff --git a/weed/filesys/dir.go b/weed/filesys/dir.go index 72e41247f..904999c43 100644 --- a/weed/filesys/dir.go +++ b/weed/filesys/dir.go @@ -54,28 +54,27 @@ func (dir *Dir) Id() uint64 { func (dir *Dir) Attr(ctx context.Context, attr *fuse.Attr) error { - // https://github.com/bazil/fuse/issues/196 - attr.Valid = time.Second - - if dir.FullPath() == dir.wfs.option.FilerMountRootPath { - dir.setRootDirAttributes(attr) - glog.V(3).Infof("root dir Attr %s, attr: %+v", dir.FullPath(), attr) - return nil - } - entry, err := dir.maybeLoadEntry() if err != nil { - glog.V(3).Infof("dir Attr %s,err: %+v", dir.FullPath(), err) + glog.V(3).Infof("dir Attr %s, err: %+v", dir.FullPath(), err) return err } + // https://github.com/bazil/fuse/issues/196 + attr.Valid = time.Second attr.Inode = dir.Id() attr.Mode = os.FileMode(entry.Attributes.FileMode) | os.ModeDir attr.Mtime = time.Unix(entry.Attributes.Mtime, 0) attr.Crtime = time.Unix(entry.Attributes.Crtime, 0) + attr.Ctime = time.Unix(entry.Attributes.Crtime, 0) + attr.Atime = time.Unix(entry.Attributes.Mtime, 0) attr.Gid = entry.Attributes.Gid attr.Uid = entry.Attributes.Uid + if dir.FullPath() == dir.wfs.option.FilerMountRootPath { + attr.BlockSize = blockSize + } + glog.V(4).Infof("dir Attr %s, attr: %+v", dir.FullPath(), attr) return nil @@ -93,20 +92,6 @@ func (dir *Dir) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *f return getxattr(entry, req, resp) } -func (dir *Dir) setRootDirAttributes(attr *fuse.Attr) { - // attr.Inode = 1 // filer2.FullPath(dir.Path).AsInode() - attr.Valid = time.Second - attr.Inode = dir.Id() - attr.Uid = dir.wfs.option.MountUid - attr.Gid = dir.wfs.option.MountGid - attr.Mode = dir.wfs.option.MountMode - attr.Crtime = dir.wfs.option.MountCtime - attr.Ctime = dir.wfs.option.MountCtime - attr.Mtime = dir.wfs.option.MountMtime - attr.Atime = dir.wfs.option.MountMtime - attr.BlockSize = blockSize -} - func (dir *Dir) Fsync(ctx context.Context, req *fuse.FsyncRequest) error { // fsync works at OS level // write the file chunks to the filerGrpcAddress @@ -375,6 +360,28 @@ func (dir *Dir) ReadDirAll(ctx context.Context) (ret []fuse.Dirent, err error) { glog.Errorf("list meta cache: %v", listErr) return nil, fuse.EIO } + + // create proper . and .. directories + ret = append(ret, fuse.Dirent{ + Inode: dirPath.AsInode(), + Name: ".", + Type: fuse.DT_Dir, + }) + + // return the correct parent inode for the mount root + var inode uint64 + if string(dirPath) == dir.wfs.option.FilerMountRootPath { + inode = dir.wfs.option.MountParentInode + } else { + inode = util.FullPath(dir.parent.FullPath()).AsInode() + } + + ret = append(ret, fuse.Dirent{ + Inode: inode, + Name: "..", + Type: fuse.DT_Dir, + }) + return } diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index 8f864a123..178e4e497 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -3,9 +3,6 @@ package filesys import ( "context" "fmt" - "github.com/chrislusf/seaweedfs/weed/filer" - "github.com/chrislusf/seaweedfs/weed/storage/types" - "github.com/chrislusf/seaweedfs/weed/wdclient" "math" "math/rand" "os" @@ -14,6 +11,10 @@ import ( "sync" "time" + "github.com/chrislusf/seaweedfs/weed/filer" + "github.com/chrislusf/seaweedfs/weed/storage/types" + "github.com/chrislusf/seaweedfs/weed/wdclient" + "google.golang.org/grpc" "github.com/chrislusf/seaweedfs/weed/util/grace" @@ -46,11 +47,12 @@ type Option struct { DataCenter string Umask os.FileMode - MountUid uint32 - MountGid uint32 - MountMode os.FileMode - MountCtime time.Time - MountMtime time.Time + MountUid uint32 + MountGid uint32 + MountMode os.FileMode + MountCtime time.Time + MountMtime time.Time + MountParentInode uint64 VolumeServerAccess string // how to access volume servers Cipher bool // whether encrypt data on volume server diff --git a/weed/filesys/xattr.go b/weed/filesys/xattr.go index 92e43b675..473805116 100644 --- a/weed/filesys/xattr.go +++ b/weed/filesys/xattr.go @@ -113,6 +113,21 @@ func (wfs *WFS) maybeLoadEntry(dir, name string) (entry *filer_pb.Entry, err err fullpath := util.NewFullPath(dir, name) // glog.V(3).Infof("read entry cache miss %s", fullpath) + // return a valid entry for the mount root + if string(fullpath) == wfs.option.FilerMountRootPath { + return &filer_pb.Entry{ + Name: wfs.option.FilerMountRootPath, + IsDirectory: true, + Attributes: &filer_pb.FuseAttributes{ + Mtime: wfs.option.MountMtime.Unix(), + FileMode: uint32(wfs.option.MountMode), + Uid: wfs.option.MountUid, + Gid: wfs.option.MountGid, + Crtime: wfs.option.MountCtime.Unix(), + }, + }, nil + } + // read from async meta cache meta_cache.EnsureVisited(wfs.metaCache, wfs, util.FullPath(dir)) cachedEntry, cacheErr := wfs.metaCache.FindEntry(context.Background(), fullpath) |
