Esempio n. 1
0
func (n *defaultNode) GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) {
	if n.Inode().IsDir() {
		out.Mode = fuse.S_IFDIR | 0755
	} else {
		out.Mode = fuse.S_IFREG | 0644
	}
	return fuse.OK
}
Esempio n. 2
0
func (n *nodeReadNode) GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) {
	if n.dir {
		out.Mode = fuse.S_IFDIR | 0755
	} else {
		out.Mode = fuse.S_IFREG | 0644
	}
	out.Size = uint64(len(n.data))
	return fuse.OK
}
Esempio n. 3
0
File: fs.go Progetto: 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
}
Esempio n. 4
0
func (m *MNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	/*if file!=nil {
		return file.GetAttr(out)
	}*/
	reg,isReg := m.obj.Obj.(*joinf.JoinFile)
	if isReg {
		out.Mode = fuse.S_IFREG | 0666
		out.Size = uint64(reg.F.FLength)
	}else{
		out.Mode = fuse.S_IFDIR | 0777
	}
	return fuse.OK
}
Esempio n. 5
0
func (me *DropboxFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
	path := get_path(name)
	log.Printf("GetAttr: '%s'\n", name)
	attr := fuse.Attr{}
	// XXX: handle this error
	data, _ := Cache.Metadata.Get(path)
	if data.IsDir {
		attr.Mode = fuse.S_IFDIR | 0755
	} else {
		attr.Mode = fuse.S_IFREG | 0644
		attr.Size = uint64(len(path))
	}
	return &attr, fuse.OK
}
Esempio n. 6
0
func (n *fileNode) GetAttr(out *fuse.Attr, file fuse.File, context *fuse.Context) (code fuse.Status) {
	if file != nil {
		return file.GetAttr(out)
	}

	out.Mode = fuse.S_IFREG | 0644
	f := n.File()
	if n.backing != "" {
		fi, err := os.Stat(n.backing)
		if err != nil {
			return fuse.ToStatus(err)
		}
		out.Size = uint64(fi.Size())
		t := f.Mtime()
		if n.dirty {
			t = fi.ModTime()
		}
		out.SetTimes(&t, &t, &t)
	} else if f != nil {
		out.Size = uint64(f.filesize)

		t := f.Mtime()
		out.SetTimes(&t, &t, &t)
	}

	return fuse.OK
}
Esempio n. 7
0
func (fs *unionFsFile) GetAttr(out *fuse.Attr) fuse.Status {
	code := fs.File.GetAttr(out)
	if code.Ok() {
		out.Mode |= 0200
	}
	return code
}
Esempio n. 8
0
func HeaderToFileInfo(out *fuse.Attr, h *tar.Header) {
	out.Mode = uint32(h.Mode)
	out.Size = uint64(h.Size)
	out.Uid = uint32(h.Uid)
	out.Gid = uint32(h.Gid)
	out.SetTimes(&h.AccessTime, &h.ModTime, &h.ChangeTime)
}
Esempio n. 9
0
func (n *memNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) fuse.Status {
	if n.Inode().IsDir() {
		out.Mode = fuse.S_IFDIR | 0777
		return fuse.OK
	}
	n.file.Stat(out)
	return fuse.OK
}
Esempio n. 10
0
func (c *FileSystemConnector) lookupMountUpdate(out *fuse.Attr, mount *fileSystemMount) (node *Inode, code fuse.Status) {
	code = mount.mountInode.Node().GetAttr(out, nil, nil)
	if !code.Ok() {
		log.Println("Root getattr should not return error", code)
		out.Mode = fuse.S_IFDIR | 0755
		return mount.mountInode, fuse.OK
	}

	return mount.mountInode, fuse.OK
}
Esempio n. 11
0
func (n *mtpNodeImpl) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	out.Mode = fuse.S_IFREG | 0644
	f := n.obj
	if f != nil {
		out.Size = uint64(n.Size)
		t := f.ModificationDate
		out.SetTimes(&t, &t, &t)
	}

	return fuse.OK
}
Esempio n. 12
0
func (sn *StrNode) GetAttr(
	out *fuse.Attr,
	file nodefs.File,
	context *fuse.Context) (code fuse.Status) {
	out.Mode = 0444 | syscall.S_IFREG
	owner := getDefaultOwner()
	out.Uid = owner.Uid
	out.Gid = owner.Gid
	out.Nlink = 1
	out.Size = uint64(len(sn.s))
	return fuse.OK
}
Esempio n. 13
0
func (fs *FSetAttrFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
	if name == "" {
		return &fuse.Attr{Mode: fuse.S_IFDIR | 0700}, fuse.OK
	}
	if name == "file" && fs.file != nil {
		var a fuse.Attr
		fs.file.getAttr(&a)
		a.Mode |= fuse.S_IFREG
		return &a, fuse.OK
	}
	return nil, fuse.ENOENT
}
Esempio n. 14
0
func (dn *DirNode) GetAttr(
	out *fuse.Attr,
	file nodefs.File,
	context *fuse.Context) (code fuse.Status) {
	out.Mode = 0755 | syscall.S_IFDIR
	out.Nlink = 2
	out.Size = 1
	out.Uid = dn.owner.Uid
	out.Gid = dn.owner.Gid
	out.SetTimes(&dn.time, &dn.time, &dn.time)
	return fuse.OK
}
Esempio n. 15
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
}
Esempio n. 16
0
func (f *etcdFile) GetAttr(out *fuse.Attr) fuse.Status {
	res, err := f.etcdClient.Get(f.path, false, false)

	if err != nil {
		log.Println("Error:", err)
		return fuse.EIO
	}

	out.Mode = fuse.S_IFREG | 0666
	out.Size = uint64(len(res.Node.Value))
	return fuse.OK
}
Esempio n. 17
0
func (tn *ThreadNode) GetAttr(
	out *fuse.Attr,
	file nodefs.File,
	context *fuse.Context) (code fuse.Status) {
	out.Mode = 0755 | syscall.S_IFDIR
	out.Nlink = 1
	owner := getDefaultOwner()
	out.Uid = owner.Uid
	out.Gid = owner.Gid
	out.Size = uint64(tn.thread.Size())
	t := tn.thread.Time()
	out.SetTimes(&t, &t, &t)
	return fuse.OK
}
Esempio n. 18
0
func (gitfs *GitFs) getGitAttrByPath(repoPath string, path string) (*fuse.Attr, fuse.Status) {
	repo, _, _, tree, err := gitfs.getMasterTreeFromRepo(repoPath)
	if err != nil {
		return nil, fuse.EPERM
	}

	repoInfo, err := os.Stat(repoPath)
	if err != nil {
		gitfs.logger.Debugf("Failed to Stat %s due to %s", repoPath, err)
		return nil, fuse.ToStatus(err)
	}

	if path == "" {
		attr := fuse.ToAttr(repoInfo)
		attr.Mode &= ^uint32(0222)
		attr.Nlink = 2 + gitfs.treeEntryCount(tree, repoPath)
		return attr, fuse.OK
	}

	entry, err := tree.EntryByPath(path)
	if err != nil {
		gitfs.logger.Debugf("Cannot find path %s from tree %s of Git Repository %s due to %s", path, tree.Id().String(), repoPath, err)
		return nil, fuse.ENOENT
	}
	gitfs.logger.Debugf("Found path %s from tree %s of Git Repository %s", path, tree.Id().String(), repoPath)

	var attr fuse.Attr
	attr.Mode = toFileMode(entry.Filemode)
	if stat, ok := repoInfo.Sys().(*syscall.Stat_t); ok {
		attr.Uid = stat.Uid
		attr.Gid = stat.Gid
		attr.Blksize = uint32(stat.Blksize)
		attr.Rdev = uint32(stat.Rdev)
	}
	attr.Ino = crc64.Checksum(entry.Id[:], crc64.MakeTable(crc64.ECMA))
	now := time.Now()
	attr.SetTimes(&now, &now, &now)

	switch entry.Type {
	case libgit2.ObjectTree:
		tree, err := repo.LookupTree(entry.Id)
		if err != nil {
			gitfs.logger.Errorf("Failed to find tree %s from Git Repository %s", entry.Id, repoPath)
			return nil, fuse.EPERM
		}
		defer tree.Free()
		gitfs.logger.Debugf("Found tree %s of Git Repository %s", tree.Id().String(), repoPath)
		attr.Size = 4096
		attr.Nlink = 2 + gitfs.treeEntryCount(tree, repoPath)
	case libgit2.ObjectBlob:
		blob, err := repo.LookupBlob(entry.Id)
		if err != nil {
			gitfs.logger.Errorf("Failed to find blob %s from Git Repository %s", entry.Id, repoPath)
			return nil, fuse.EPERM
		}
		defer blob.Free()
		gitfs.logger.Debugf("Found blob %s of Git Repository %s", blob.Id().String(), repoPath)
		attr.Nlink = 1
		attr.Size = uint64(blob.Size())
	default:
		gitfs.logger.Debugf("GetAttr: Unsupported object type %s of %s from Git Repository %s", entry.Type.String(), entry.Id, repoPath)
		return nil, fuse.ENOENT
	}
	attr.Blocks = (attr.Size + 511) / 512
	return &attr, fuse.OK
}
Esempio n. 19
0
func (n *nodeReadNode) Lookup(out *fuse.Attr, name string, context *fuse.Context) (*Inode, fuse.Status) {
	out.Mode = fuse.S_IFREG | 0644
	out.Size = uint64(len(name))
	ch := n.Inode().NewChild(name, false, newNodeReadNode(n.noOpen, []byte(name)))
	return ch, fuse.OK
}
Esempio n. 20
0
func (f *ZipFile) Stat(out *fuse.Attr) {
	// TODO - do something intelligent with timestamps.
	out.Mode = fuse.S_IFREG | 0444
	out.Size = uint64(f.File.UncompressedSize)
}
Esempio n. 21
0
File: fs.go Progetto: hanwen/gitfs
func (n *blobNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	out.Mode = uint32(n.mode)
	out.Size = uint64(n.size)
	return fuse.OK
}
Esempio n. 22
0
func (f *dataFile) GetAttr(out *fuse.Attr) fuse.Status {
	out.Mode = fuse.S_IFREG | 0644
	out.Size = uint64(len(f.data))
	return fuse.OK
}
Esempio n. 23
0
File: fs.go Progetto: hanwen/gitfs
func (n *mutableLink) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	out.Mode = fuse.S_IFLNK
	return fuse.OK
}
Esempio n. 24
0
func (f *FileNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	out.Mode = fuse.S_IFREG | 0666
	out.Size = uint64(f.File.Size())
	return fuse.OK
}
Esempio n. 25
0
File: main.go Progetto: c-fs/cfuse
func (f *CFile) GetAttr(out *fuse.Attr) fuse.Status {
	stat, _ := f.client.Stat(ctx.TODO(), f.name)
	out.Mode = fuse.S_IFREG | 0644
	out.Size = uint64(stat.TotalSize)
	return fuse.OK
}
Esempio n. 26
0
func (n *folderNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	out.Mode = fuse.S_IFDIR | 0755
	return fuse.OK
}
Esempio n. 27
0
func (n *gitConfigNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	out.Mode = syscall.S_IFLNK
	return fuse.OK
}
Esempio n. 28
0
File: fs.go Progetto: hanwen/p4fuse
func (f *p4Link) GetAttr(out *fuse.Attr, file nodefs.File, c *fuse.Context) fuse.Status {
	out.Mode = fuse.S_IFLNK
	return fuse.OK
}
Esempio n. 29
0
func (f *TarFile) Stat(out *fuse.Attr) {
	HeaderToFileInfo(out, &f.Header)
	out.Mode |= syscall.S_IFREG
}
Esempio n. 30
0
File: fs.go Progetto: hanwen/p4fuse
func (f *p4Folder) GetAttr(out *fuse.Attr, file nodefs.File, c *fuse.Context) fuse.Status {
	out.Mode = fuse.S_IFDIR | 0755
	return fuse.OK
}