Exemplo n.º 1
0
Arquivo: fs.go Projeto: hanwen/p4fuse
func (f *p4File) GetAttr(out *fuse.Attr, file nodefs.File, c *fuse.Context) fuse.Status {
	if m, ok := modes[f.stat.HeadType]; ok {
		out.Mode = m
	} else {
		out.Mode = fuse.S_IFREG | 0644
	}

	out.Mtime = uint64(f.stat.HeadTime)
	out.Size = uint64(f.stat.FileSize)
	return fuse.OK
}
Exemplo n.º 2
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
}