Beispiel #1
0
func (f *file) GetAttr(out *fuse.Attr) fuse.Status {
	logrus.Debugf("FGetAttr %s", f.kv.Key)
	now := time.Now()
	out.Mtime = uint64(now.Unix())
	out.Mtimensec = uint32(now.UnixNano())
	out.Atime = uint64(now.Unix())
	out.Atimensec = uint32(now.UnixNano())
	out.Ctime = uint64(now.Unix())
	out.Ctimensec = uint32(now.UnixNano())

	if f.kv == nil || strings.HasSuffix(f.kv.Key, "/") || f.kv.Key == "" {
		out.Mode = fuse.S_IFDIR | 0755
		return fuse.OK
	}

	if len(f.kv.Value) > 0 {
		out.Mode = fuse.S_IFREG | 0644
		out.Size = uint64(len(f.kv.Value))
	}
	return fuse.OK
}