|
|
@ -66,7 +66,8 @@ func (wfs *WFS) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse |
|
|
|
} |
|
|
|
|
|
|
|
if mode, ok := input.GetMode(); ok { |
|
|
|
entry.Attributes.FileMode = mode & 07777 |
|
|
|
glog.V(4).Infof("setAttr mode %o", mode) |
|
|
|
entry.Attributes.FileMode = chmod(entry.Attributes.FileMode, mode) |
|
|
|
} |
|
|
|
|
|
|
|
if uid, ok := input.GetUID(); ok { |
|
|
@ -108,7 +109,7 @@ func (wfs *WFS) setRootAttr(out *fuse.AttrOut) { |
|
|
|
out.Mtime = now |
|
|
|
out.Ctime = now |
|
|
|
out.Atime = now |
|
|
|
out.Mode = toSystemType(os.ModeDir) | uint32(wfs.option.MountMode) |
|
|
|
out.Mode = toSyscallType(os.ModeDir) | uint32(wfs.option.MountMode) |
|
|
|
out.Nlink = 1 |
|
|
|
} |
|
|
|
|
|
|
@ -120,7 +121,7 @@ func (wfs *WFS) setAttrByPbEntry(out *fuse.Attr, inode uint64, entry *filer_pb.E |
|
|
|
out.Mtime = uint64(entry.Attributes.Mtime) |
|
|
|
out.Ctime = uint64(entry.Attributes.Mtime) |
|
|
|
out.Atime = uint64(entry.Attributes.Mtime) |
|
|
|
out.Mode = toSystemMode(os.FileMode(entry.Attributes.FileMode)) |
|
|
|
out.Mode = toSyscallMode(os.FileMode(entry.Attributes.FileMode)) |
|
|
|
if entry.HardLinkCounter > 0 { |
|
|
|
out.Nlink = uint32(entry.HardLinkCounter) |
|
|
|
} else { |
|
|
@ -138,7 +139,7 @@ func (wfs *WFS) setAttrByFilerEntry(out *fuse.Attr, inode uint64, entry *filer.E |
|
|
|
out.Atime = uint64(entry.Attr.Mtime.Unix()) |
|
|
|
out.Mtime = uint64(entry.Attr.Mtime.Unix()) |
|
|
|
out.Ctime = uint64(entry.Attr.Mtime.Unix()) |
|
|
|
out.Mode = toSystemMode(entry.Attr.Mode) |
|
|
|
out.Mode = toSyscallMode(entry.Attr.Mode) |
|
|
|
if entry.HardLinkCounter > 0 { |
|
|
|
out.Nlink = uint32(entry.HardLinkCounter) |
|
|
|
} else { |
|
|
@ -164,11 +165,15 @@ func (wfs *WFS) outputFilerEntry(out *fuse.EntryOut, inode uint64, entry *filer. |
|
|
|
wfs.setAttrByFilerEntry(&out.Attr, inode, entry) |
|
|
|
} |
|
|
|
|
|
|
|
func toSystemMode(mode os.FileMode) uint32 { |
|
|
|
return toSystemType(mode) | uint32(mode) |
|
|
|
func chmod(existing uint32, mode uint32) uint32 { |
|
|
|
return existing&^07777 | mode&07777 |
|
|
|
} |
|
|
|
|
|
|
|
func toSystemType(mode os.FileMode) uint32 { |
|
|
|
func toSyscallMode(mode os.FileMode) uint32 { |
|
|
|
return toSyscallType(mode) | uint32(mode) |
|
|
|
} |
|
|
|
|
|
|
|
func toSyscallType(mode os.FileMode) uint32 { |
|
|
|
switch mode & os.ModeType { |
|
|
|
case os.ModeDir: |
|
|
|
return syscall.S_IFDIR |
|
|
@ -187,7 +192,7 @@ func toSystemType(mode os.FileMode) uint32 { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func toFileType(mode uint32) os.FileMode { |
|
|
|
func toOsFileType(mode uint32) os.FileMode { |
|
|
|
switch mode & (syscall.S_IFMT & 0xffff) { |
|
|
|
case syscall.S_IFDIR: |
|
|
|
return os.ModeDir |
|
|
@ -206,6 +211,6 @@ func toFileType(mode uint32) os.FileMode { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func toFileMode(mode uint32) os.FileMode { |
|
|
|
return toFileType(mode) | os.FileMode(mode&07777) |
|
|
|
func toOsFileMode(mode uint32) os.FileMode { |
|
|
|
return toOsFileType(mode) | os.FileMode(mode&07777) |
|
|
|
} |