aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-02-12 01:59:36 -0800
committerchrislu <chris.lu@gmail.com>2022-02-12 01:59:36 -0800
commita10c28ba8290b2d11944dc2a7ec624b9db3649b8 (patch)
treef7b3d7205bf72a04531f384dfe4c1ec2ec2fd143
parentf4d88862c47bdd372c1fc2ac6335b1bed3b24a11 (diff)
downloadseaweedfs-a10c28ba8290b2d11944dc2a7ec624b9db3649b8.tar.xz
seaweedfs-a10c28ba8290b2d11944dc2a7ec624b9db3649b8.zip
simplify
-rw-r--r--weed/mount/weedfs_attr.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/weed/mount/weedfs_attr.go b/weed/mount/weedfs_attr.go
index 41cd29b75..7e53ad506 100644
--- a/weed/mount/weedfs_attr.go
+++ b/weed/mount/weedfs_attr.go
@@ -20,11 +20,9 @@ func (wfs *WFS) GetAttr(cancel <-chan struct{}, input *fuse.GetAttrIn, out *fuse
if status != fuse.OK {
return status
}
- if entry.IsDirectory {
+ wfs.setOutAttr(out, input.NodeId, entry)
- }
-
- return fuse.ENOSYS
+ return fuse.OK
}
func (wfs *WFS) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse.Status) {
@@ -56,7 +54,7 @@ func (wfs *WFS) setRootAttr(out *fuse.AttrOut) {
out.Mtime = now
out.Ctime = now
out.Atime = now
- out.Mode = uint32(syscall.S_IFDIR | wfs.option.MountMode)
+ out.Mode = osToSystemMode(os.ModeDir) | uint32(wfs.option.MountMode)
out.Nlink = 1
}
@@ -65,7 +63,7 @@ func (wfs *WFS) setOutAttr(out *fuse.AttrOut, inode uint64, entry *filer_pb.Entr
out.Ino = inode
out.Uid = entry.Attributes.Uid
out.Gid = entry.Attributes.Gid
- out.Mode = entry.Attributes.FileMode
+ out.Mode = modeToSystemMode(entry.Attributes.FileMode)
out.Mtime = uint64(entry.Attributes.Mtime)
out.Ctime = uint64(entry.Attributes.Mtime)
out.Atime = uint64(entry.Attributes.Mtime)
@@ -78,8 +76,12 @@ func (wfs *WFS) setOutAttr(out *fuse.AttrOut, inode uint64, entry *filer_pb.Entr
out.Nlink = 1
}
+func modeToSystemMode(mode uint32) uint32 {
+ return osToSystemMode(os.FileMode(mode)) | mode
+}
+
func osToSystemMode(mode os.FileMode) uint32 {
- switch mode & 0x7F {
+ switch mode & os.ModeType {
case os.ModeDir:
return syscall.S_IFDIR
case os.ModeSymlink: