Пример #1
0
func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	var fi *fuse.Attr
	if file == nil {
		// called on a deleted files.
		file = n.Inode().AnyFile()
	}

	if file != nil {
		code = file.GetAttr(out)
	}

	if file == nil || code == fuse.ENOSYS || code == fuse.EBADF {
		fi, code = n.fs.GetAttr(n.GetPath(), context)
	}

	if fi != nil {
		n.setClientInode(fi.Ino)
	}

	if fi != nil && !fi.IsDir() && fi.Nlink == 0 {
		fi.Nlink = 1
	}

	if fi != nil {
		*out = *fi
	}
	return code
}
Пример #2
0
func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	var fi *fuse.Attr
	if file == nil {
		// Linux currently (tested on v4.4) does not pass a file descriptor for
		// fstat. To be able to stat a deleted file we have to find ourselves
		// an open fd.
		file = n.Inode().AnyFile()
	}

	if file != nil {
		code = file.GetAttr(out)
	}

	if file == nil || code == fuse.ENOSYS || code == fuse.EBADF {
		fi, code = n.fs.GetAttr(n.GetPath(), context)
	}

	if fi != nil {
		n.setClientInode(fi.Ino)
	}

	if fi != nil && !fi.IsDir() && fi.Nlink == 0 {
		fi.Nlink = 1
	}

	if fi != nil {
		*out = *fi
	}
	return code
}
Пример #3
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
}
Пример #4
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
}
Пример #5
0
func (f *AzukiFile) GetAttr(a *fuse.Attr) fuse.Status {
	st := syscall.Stat_t{}
	f.lock.Lock()
	err := syscall.Fstat(int(f.File.Fd()), &st)
	f.lock.Unlock()
	if err != nil {
		return fuse.ToStatus(err)
	}
	a.FromStat(&st)
	return fuse.OK
}
Пример #6
0
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
}
Пример #7
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
}
Пример #8
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
}
Пример #9
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
}
Пример #10
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
}
Пример #11
0
// fileAttr constructs a generic file fuse.Attr with the given parameters.
func (kwfs KeywhizFs) fileAttr(size uint64, mode uint32) *fuse.Attr {
	created := uint64(kwfs.StartTime.Unix())
	attr := fuse.Attr{
		Size:  size,
		Atime: created,
		Mtime: created,
		Ctime: created,
		Mode:  fuse.S_IFREG | mode,
	}
	attr.Uid = kwfs.Ownership.Uid
	attr.Gid = kwfs.Ownership.Gid
	return &attr
}
Пример #12
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
}
Пример #13
0
func (f *file) GetAttr(a *fuse.Attr) fuse.Status {
	cryptfs.Debug.Printf("file.GetAttr()\n")
	st := syscall.Stat_t{}
	f.lock.Lock()
	err := syscall.Fstat(int(f.fd.Fd()), &st)
	f.lock.Unlock()
	if err != nil {
		return fuse.ToStatus(err)
	}
	a.FromStat(&st)
	a.Size = f.cfs.PlainSize(a.Size)

	return fuse.OK
}
Пример #14
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
}
Пример #15
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
}
Пример #16
0
func (f *file) GetAttr(a *fuse.Attr) fuse.Status {
	f.fdLock.RLock()
	defer f.fdLock.RUnlock()

	tlog.Debug.Printf("file.GetAttr()")
	st := syscall.Stat_t{}
	err := syscall.Fstat(int(f.fd.Fd()), &st)
	if err != nil {
		return fuse.ToStatus(err)
	}
	a.FromStat(&st)
	a.Size = f.contentEnc.CipherSizeToPlainSize(a.Size)

	return fuse.OK
}
Пример #17
0
func (o *ObjectFile) GetAttr(a *fuse.Attr) fuse.Status {
	log.Debugf("[objectfile] GetAttr(obj) %s", o.name)

	stat, err := o.localfile.Stat()
	if err != nil {
		return fuse.EIO
	}
	st, ok := stat.Sys().(*syscall.Stat_t)
	if !ok {
		return fuse.ENODEV
	}
	a.FromStat(st)

	return fuse.OK
}
Пример #18
0
func (fs *unionFsFile) GetAttr(out *fuse.Attr) fuse.Status {
	code := fs.File.GetAttr(out)
	if code.Ok() {
		out.Mode |= 0200
	}
	return code
}
Пример #19
0
func (f *rpcFsFile) GetAttr(a *fuse.Attr) fuse.Status {
	*a = f.attr
	if a.Size > 0 {
		a.Ino = hashIno(f.hash)
	}
	return fuse.OK
}
Пример #20
0
// directoryAttr constructs a generic directory fuse.Attr with the given parameters.
func (kwfs KeywhizFs) directoryAttr(subdirCount, mode uint32) *fuse.Attr {
	// 4K is typically the minimum size of inode storage for a directory.
	const directoryInodeSize = 4096
	created := uint64(kwfs.StartTime.Unix())

	attr := fuse.Attr{
		Size:  directoryInodeSize,
		Atime: created,
		Mtime: created,
		Ctime: created,
		Mode:  fuse.S_IFDIR | mode,
		Nlink: 2 + subdirCount, // '.', '..', and any other subdirectories
	}
	attr.Uid = kwfs.Ownership.Uid
	attr.Gid = kwfs.Ownership.Gid
	return &attr
}
Пример #21
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
}
Пример #22
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
}
Пример #23
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
}
Пример #24
0
func (me *UnionFs) Create(name string, flags uint32, mode uint32, context *fuse.Context) (fuseFile fuse.File, code fuse.Status) {
	writable := me.fileSystems[0]

	code = me.promoteDirsTo(name)
	if code != fuse.OK {
		return nil, code
	}
	fuseFile, code = writable.Create(name, flags, mode, context)
	if code.Ok() {
		fuseFile = me.newUnionFsFile(fuseFile, 0)
		me.removeDeletion(name)

		now := time.Now()
		a := fuse.Attr{
			Mode: fuse.S_IFREG | mode,
		}
		a.SetTimes(nil, &now, &now)
		me.branchCache.Set(name, branchResult{&a, fuse.OK, 0})
	}
	return fuseFile, code
}
Пример #25
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)
}
Пример #26
0
func (n *pathInode) findChild(fi *fuse.Attr, name string, fullPath string) (out *pathInode) {
	if fi.Ino > 0 {
		n.pathFs.pathLock.RLock()
		r := n.pathFs.clientInodeMap[fi.Ino]
		if r != nil {
			out = r.node
			r.refCount++
			if fi.Nlink == 1 {
				log.Printf("Found linked inode, but Nlink == 1, ino=%d, fullPath=%q", fi.Ino, fullPath)
			}
		}
		n.pathFs.pathLock.RUnlock()
	}

	if out == nil {
		out = n.createChild(name, fi.IsDir())
		out.setClientInode(fi.Ino)
	} else {
		n.Inode().AddChild(name, out.Inode())
	}
	return out
}
Пример #27
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
}
Пример #28
0
func (n *pathInode) findChild(fi *fuse.Attr, name string, fullPath string) (out *pathInode) {
	if fi.Ino > 0 {
		unlock := n.RLockTree()
		v := n.pathFs.clientInodeMap[fi.Ino]
		if len(v) > 0 {
			out = v[0].node

			if fi.Nlink == 1 {
				log.Println("Found linked inode, but Nlink == 1", fullPath)
			}
		}
		unlock()
	}

	if out == nil {
		out = n.createChild(fi.IsDir())
		out.clientInode = fi.Ino
		n.addChild(name, out)
	} else {
		// should add 'out' as a child to n ?
	}
	return out
}
Пример #29
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
}
Пример #30
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
}