aboutsummaryrefslogtreecommitdiff
path: root/weed/mount/weedfs_attr.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/mount/weedfs_attr.go')
-rw-r--r--weed/mount/weedfs_attr.go27
1 files changed, 20 insertions, 7 deletions
diff --git a/weed/mount/weedfs_attr.go b/weed/mount/weedfs_attr.go
index be504f5e2..dc7a3bc85 100644
--- a/weed/mount/weedfs_attr.go
+++ b/weed/mount/weedfs_attr.go
@@ -16,15 +16,16 @@ func (wfs *WFS) GetAttr(cancel <-chan struct{}, input *fuse.GetAttrIn, out *fuse
return fuse.OK
}
- _, _, entry, status := wfs.maybeReadEntry(input.NodeId)
+ inode := input.NodeId
+ _, _, entry, inode, status := wfs.maybeReadEntry(inode, false)
if status == fuse.OK {
out.AttrValid = 1
- wfs.setAttrByPbEntry(&out.Attr, input.NodeId, entry)
+ wfs.setAttrByPbEntry(&out.Attr, inode, entry)
return status
} else {
- if fh, found := wfs.fhmap.FindFileHandle(input.NodeId); found {
+ if fh, found := wfs.fhmap.FindFileHandle(inode); found {
out.AttrValid = 1
- wfs.setAttrByPbEntry(&out.Attr, input.NodeId, fh.entry)
+ wfs.setAttrByPbEntry(&out.Attr, inode, fh.entry)
out.Nlink = 0
return fuse.OK
}
@@ -39,7 +40,7 @@ func (wfs *WFS) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse
return fuse.Status(syscall.ENOSPC)
}
- path, fh, entry, status := wfs.maybeReadEntry(input.NodeId)
+ path, fh, entry, inode, status := wfs.maybeReadEntry(input.NodeId, false)
if status != fuse.OK {
return status
}
@@ -48,7 +49,7 @@ func (wfs *WFS) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse
defer fh.entryLock.Unlock()
}
- if size, ok := input.GetSize(); ok {
+ if size, ok := input.GetSize(); ok && entry != nil {
glog.V(4).Infof("%v setattr set size=%v chunks=%d", path, size, len(entry.Chunks))
if size < filer.FileSize(entry) {
// fmt.Printf("truncate %v \n", fullPath)
@@ -111,7 +112,7 @@ func (wfs *WFS) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse
}
out.AttrValid = 1
- wfs.setAttrByPbEntry(&out.Attr, input.NodeId, entry)
+ wfs.setAttrByPbEntry(&out.Attr, inode, entry)
if fh != nil {
fh.dirtyMetadata = true
@@ -138,9 +139,18 @@ func (wfs *WFS) setRootAttr(out *fuse.AttrOut) {
func (wfs *WFS) setAttrByPbEntry(out *fuse.Attr, inode uint64, entry *filer_pb.Entry) {
out.Ino = inode
+ if entry.Attributes != nil && entry.Attributes.Inode != 0 {
+ out.Ino = entry.Attributes.Inode
+ }
out.Size = filer.FileSize(entry)
+ if entry.FileMode()&os.ModeSymlink != 0 {
+ out.Size = uint64(len(entry.Attributes.SymlinkTarget))
+ }
out.Blocks = (out.Size + blockSize - 1) / blockSize
setBlksize(out, blockSize)
+ if entry == nil {
+ return
+ }
out.Mtime = uint64(entry.Attributes.Mtime)
out.Ctime = uint64(entry.Attributes.Mtime)
out.Atime = uint64(entry.Attributes.Mtime)
@@ -158,6 +168,9 @@ func (wfs *WFS) setAttrByPbEntry(out *fuse.Attr, inode uint64, entry *filer_pb.E
func (wfs *WFS) setAttrByFilerEntry(out *fuse.Attr, inode uint64, entry *filer.Entry) {
out.Ino = inode
out.Size = entry.FileSize
+ if entry.Mode&os.ModeSymlink != 0 {
+ out.Size = uint64(len(entry.SymlinkTarget))
+ }
out.Blocks = (out.Size + blockSize - 1) / blockSize
setBlksize(out, blockSize)
out.Atime = uint64(entry.Attr.Mtime.Unix())