示例#1
0
func (n *mutFile) Attr(ctx context.Context, a *fuse.Attr) error {
	// TODO: don't grab n.mu three+ times in here.
	var mode os.FileMode = 0600 // writable

	n.mu.Lock()
	size := n.size
	var blocks uint64
	if size > 0 {
		blocks = uint64(size)/512 + 1
	}
	inode := n.permanode.Sum64()
	if n.symLink {
		mode |= os.ModeSymlink
	}
	n.mu.Unlock()

	a.Inode = inode
	a.Mode = mode
	a.Uid = uint32(os.Getuid())
	a.Gid = uint32(os.Getgid())
	a.Size = uint64(size)
	a.Blocks = blocks
	a.Mtime = n.modTime()
	a.Atime = n.accessTime()
	a.Ctime = serverStart
	a.Crtime = serverStart
	return nil
}
示例#2
0
func (e fuseFile) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = 0444
	a.Uid = env.MyUID
	a.Gid = env.MyGID
	a.Size = e.de.File.Manifest.Size
	// a.Mtime = e.Meta.Written.UTC()
	// a.Ctime = e.Meta.Written.UTC()
	// a.Crtime = e.Meta.Written.UTC()
	a.Blocks = statBlocks(e.de.File.Manifest.Size) // TODO .Space?
	return nil
}
示例#3
0
文件: symlink.go 项目: ovh/svfs
// Attr fills the file attributes for a symlink node.
func (s *Symlink) Attr(ctx context.Context, a *fuse.Attr) (err error) {
	a.Size = uint64(s.so.Bytes)
	a.BlockSize = 0
	a.Blocks = 0
	a.Mode = os.ModeSymlink | os.FileMode(DefaultMode)
	a.Gid = uint32(DefaultGID)
	a.Uid = uint32(DefaultUID)
	a.Mtime = getMtime(s.so, s.sh)
	a.Ctime = a.Mtime
	a.Crtime = a.Mtime
	return nil
}
示例#4
0
文件: object.go 项目: ovh/svfs
// Attr fills the file attributes for an object node.
func (o *Object) Attr(ctx context.Context, a *fuse.Attr) (err error) {
	a.Size = o.size()
	a.BlockSize = uint32(BlockSize)
	a.Blocks = (a.Size / uint64(a.BlockSize)) * 8
	a.Mode = os.FileMode(DefaultMode)
	a.Gid = uint32(DefaultGID)
	a.Uid = uint32(DefaultUID)
	a.Mtime = getMtime(o.so, o.sh)
	a.Ctime = a.Mtime
	a.Crtime = a.Mtime
	return nil
}
示例#5
0
文件: file.go 项目: fawick/restic
func (f *file) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = f.node.Inode
	a.Mode = f.node.Mode
	a.Size = f.node.Size
	a.Blocks = (f.node.Size / blockSize) + 1
	a.BlockSize = blockSize

	if !f.ownerIsRoot {
		a.Uid = f.node.UID
		a.Gid = f.node.GID
	}
	a.Atime = f.node.AccessTime
	a.Ctime = f.node.ChangeTime
	a.Mtime = f.node.ModTime
	return nil
}
示例#6
0
文件: node.go 项目: chzyer/simsata
func (t *Node) Attr(ctx context.Context, a *fuse.Attr) error {
	fi, err := os.Stat(t.getTargetPath(""))
	if err != nil {
		return err
	}
	st := fi.Sys().(*syscall.Stat_t)
	a.Nlink = uint32(st.Nlink)
	a.Size = uint64(st.Size)
	a.Gid = st.Gid
	a.Uid = st.Uid
	a.Ctime = time.Unix(st.Ctimespec.Unix())
	a.Blocks = uint64(st.Blocks)
	a.BlockSize = uint32(st.Blksize)
	a.Inode = st.Ino
	a.Mode = fi.Mode()
	logex.Struct(a)
	return nil
}
示例#7
0
文件: sys.go 项目: suffuse/go-suffuse
func GoFileInfoToFuseAttr(fi os.FileInfo) fuse.Attr {
	a := fuse.Attr{
		// Valid: cachable,
		Size:  uint64(fi.Size()),
		Mode:  fi.Mode(),
		Mtime: fi.ModTime(),
	}

	switch sp := fi.Sys().(type) {
	case *sys.Stat_t:
		AssertEq(StatModeToGoMode(uint64(sp.Mode)), a.Mode)
		// System specific attributes
		SetSysAttributes(sp, &a)
		a.Blocks = uint64(sp.Blocks)
		a.Gid = sp.Gid
		a.Inode = uint64(sp.Ino)
		a.Nlink = uint32(sp.Nlink)
		a.Rdev = uint32(sp.Rdev)
		a.Uid = sp.Uid
	}

	return a
}