Example #1
0
// GetAttr - FUSE call
func (f *virtualFile) GetAttr(a *fuse.Attr) fuse.Status {
	var st syscall.Stat_t
	err := syscall.Lstat(f.parentFile, &st)
	if err != nil {
		fmt.Printf("Lstat %q: %v\n", f.parentFile, err)
		return fuse.ToStatus(err)
	}
	st.Ino = f.ino
	st.Size = int64(len(f.content))
	st.Mode = syscall.S_IFREG | 0400
	st.Nlink = 1
	a.FromStat(&st)
	return fuse.OK
}
Example #2
0
func (constor *Constor) Lstat(li int, id string, stat *syscall.Stat_t) error {
	path := constor.getPath(li, id)
	if err := syscall.Lstat(path, stat); err != nil {
		return err
	}
	count := 1
	linksbyte, err := Lgetxattr(path, LINKSXATTR)
	if err == nil && len(linksbyte) != 0 {
		linksstr := string(linksbyte)
		linksint, err := strconv.Atoi(linksstr)
		if err != nil {
			constor.error("%s : %s", id, err)
			return err
		}
		count = linksint
	}
	stat.Nlink = uint64(count)
	stat.Ino = idtoino(id)
	return nil
}