示例#1
0
文件: sys.go 项目: suffuse/go-suffuse
func GoFileInfoToFuseAttr(fi os.FileInfo) fuse.Attr {
	a := fuse.Attr{
		// Valid: cachable,
		Size:  uint64(fi.Size()),
		Mode:  fi.Mode(),
		Mtime: fi.ModTime(),
	}

	switch sp := fi.Sys().(type) {
	case *sys.Stat_t:
		AssertEq(StatModeToGoMode(uint64(sp.Mode)), a.Mode)
		// System specific attributes
		SetSysAttributes(sp, &a)
		a.Blocks = uint64(sp.Blocks)
		a.Gid = sp.Gid
		a.Inode = uint64(sp.Ino)
		a.Nlink = uint32(sp.Nlink)
		a.Rdev = uint32(sp.Rdev)
		a.Uid = sp.Uid
	}

	return a
}