예제 #1
0
func (d *listSnaps) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = tokens.InodeSnap
	a.Mode = os.ModeDir | 0755
	a.Uid = env.MyUID
	a.Gid = env.MyGID
	return nil
}
예제 #2
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
}
예제 #3
0
func (n *mutDir) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = n.permanode.Sum64()
	a.Mode = os.ModeDir | 0700
	a.Uid = uint32(os.Getuid())
	a.Gid = uint32(os.Getgid())
	return nil
}
예제 #4
0
파일: file.go 프로젝트: conductant/gohm
func (f *File) Attr(c context.Context, a *fuse.Attr) error {
	defer log.Debugln("file_attr:", f.dir.path, f.name, a)

	f.mu.Lock()
	defer f.mu.Unlock()

	return f.dir.fs.backend.View(c, func(ctx Context) error {
		b, err := ctx.Dir(f.dir.path)
		if err != nil {
			return err
		}
		meta, err := b.Meta(f.name)
		if err != nil {
			return err
		}
		a.Uid = meta.Uid
		a.Gid = meta.Gid
		a.Mode = meta.Perm
		a.Nlink = f.links
		if f.link {
			a.Mode = a.Mode | os.ModeSymlink
		}
		a.Size = uint64(len(f.data))
		if f.writers == 0 {
			// not in memory, fetch correct size.
			// Attr can't fail, so ignore errors
			_ = f.load(c, func(buff []byte) { a.Size = uint64(len(buff)) })
		}
		return nil
	})
}
예제 #5
0
파일: dir.go 프로젝트: marcopaganini/rclone
// Attr updates the attribes of a directory
func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) error {
	fs.Debug(d.path, "Dir.Attr")
	a.Gid = gid
	a.Uid = uid
	a.Mode = os.ModeDir | dirPerms
	// FIXME include Valid so get some caching? Also mtime
	return nil
}
예제 #6
0
파일: fs.go 프로젝트: bwester/consulfs
// Attr implements the Node interface. It is called when fetching the inode attribute for
// this directory (e.g., to service stat(2)).
func (dir *consulDir) Attr(ctx context.Context, attr *fuse.Attr) error {
	attr.Mode = dir.mode()
	// Nlink should technically include all the files in the directory, but VFS seems fine
	// with the constant "2".
	attr.Nlink = 2
	attr.Uid = dir.ConsulFS.UID
	attr.Gid = dir.ConsulFS.GID
	return nil
}
예제 #7
0
func (sn *SnapshotsDir) Attr(ctx context.Context, attr *fuse.Attr) error {
	attr.Inode = 0
	attr.Mode = os.ModeDir | 0555

	if !sn.ownerIsRoot {
		attr.Uid = uint32(os.Getuid())
		attr.Gid = uint32(os.Getgid())
	}
	return nil
}
예제 #8
0
func (s staticFileNode) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = 0400
	a.Uid = uint32(os.Getuid())
	a.Gid = uint32(os.Getgid())
	a.Size = uint64(len(s))
	a.Mtime = serverStart
	a.Ctime = serverStart
	a.Crtime = serverStart
	return nil
}
예제 #9
0
파일: jpgfs.go 프로젝트: solarnz/jpgfs
func (f File) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = f.mode
	a.Size = f.size
	a.Atime = f.Atime
	a.Mtime = f.Mtime
	a.Ctime = f.Ctime
	a.Crtime = f.Ctime
	a.Uid = f.Uid
	a.Gid = f.Gid
	return nil
}
예제 #10
0
func copyAttr(dst *fuse.Attr, src *pb.Attr) {
	dst.Inode = src.Inode
	dst.Mode = os.FileMode(src.Mode)
	dst.Size = src.Size
	dst.Mtime = time.Unix(src.Mtime, 0)
	dst.Atime = time.Unix(src.Atime, 0)
	dst.Ctime = time.Unix(src.Ctime, 0)
	dst.Crtime = time.Unix(src.Crtime, 0)
	dst.Uid = src.Uid
	dst.Gid = src.Gid
}
예제 #11
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
}
예제 #12
0
파일: file.go 프로젝트: read-later/bazil
func (f *file) Attr(ctx context.Context, a *fuse.Attr) error {
	f.mu.Lock()
	defer f.mu.Unlock()

	a.Inode = f.inode
	a.Mode = 0644
	a.Uid = env.MyUID
	a.Gid = env.MyGID
	a.Size = f.blob.Size()
	return nil
}
예제 #13
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
}
예제 #14
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
}
예제 #15
0
파일: dir.go 프로젝트: dankomiocevic/mulifs
func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) error {
	glog.Infof("Entered Attr dir: Artist: %s, Album: %s\n", d.artist, d.album)
	a.Mode = os.ModeDir | 0777
	if config_params.uid != 0 {
		a.Uid = uint32(config_params.uid)
	}
	if config_params.gid != 0 {
		a.Gid = uint32(config_params.gid)
	}
	a.Size = 4096
	return nil
}
예제 #16
0
// Converts Attrs datastructure into FUSE represnetation
func (this *Attrs) Attr(a *fuse.Attr) error {
	a.Inode = this.Inode
	a.Mode = this.Mode
	if (a.Mode & os.ModeDir) == 0 {
		a.Size = this.Size
	}
	a.Uid = this.Uid
	a.Gid = this.Gid
	a.Mtime = this.Mtime
	a.Ctime = this.Ctime
	a.Crtime = this.Crtime
	return nil
}
예제 #17
0
파일: link.go 프로젝트: fawick/restic
func (l *link) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = l.node.Inode
	a.Mode = l.node.Mode

	if !l.ownerIsRoot {
		a.Uid = l.node.UID
		a.Gid = l.node.GID
	}
	a.Atime = l.node.AccessTime
	a.Ctime = l.node.ChangeTime
	a.Mtime = l.node.ModTime
	return nil
}
예제 #18
0
파일: dir.go 프로젝트: fawick/restic
func (d *dir) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = d.inode
	a.Mode = os.ModeDir | d.node.Mode

	if !d.ownerIsRoot {
		a.Uid = d.node.UID
		a.Gid = d.node.GID
	}
	a.Atime = d.node.AccessTime
	a.Ctime = d.node.ChangeTime
	a.Mtime = d.node.ModTime
	return nil
}
예제 #19
0
// Attr sets the fuse attributes for the directory
func (d *Dir) Attr(ctx context.Context, attr *fuse.Attr) (err error) {
	if d.resource == nil {
		attr.Mode = os.ModeDir | 0555
	} else {
		attr.Mode = d.resource.Mode()
	}

	attr.Uid = d.uid
	attr.Gid = d.gid
	attr.Inode = d.inode

	return nil
}
예제 #20
0
파일: file.go 프로젝트: klauspost/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

	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
}
예제 #21
0
파일: directory.go 프로젝트: ovh/svfs
// Attr fills file attributes of a directory within the current context.
func (d *Directory) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = os.ModeDir | os.FileMode(DefaultMode)
	a.Gid = uint32(DefaultGID)
	a.Uid = uint32(DefaultUID)
	a.Size = uint64(BlockSize)

	if d.so != nil {
		a.Atime = time.Now()
		a.Mtime = MountTime
		a.Ctime = a.Mtime
		a.Crtime = a.Mtime
	}

	return nil
}
예제 #22
0
파일: fs.go 프로젝트: bwester/consulfs
// lockedAttr fills in an Attr struct for this file. Call when the file's mutex is locked.
func (file *consulFile) lockedAttr(attr *fuse.Attr) {
	attr.Mode = file.ConsulFS.mode()
	if !file.Deleted {
		attr.Nlink = 1
	}
	// Timestamps aren't reflected in Consul, but it doesn't hurt to fake them
	attr.Ctime = file.Ctime
	attr.Mtime = file.Mtime
	attr.Atime = file.Atime
	attr.Uid = file.ConsulFS.UID
	attr.Gid = file.ConsulFS.GID
	if file.IsOpen {
		// Some applications like seeking...
		attr.Size = file.Size
	}
}
예제 #23
0
func (f *file) Attr(ctx context.Context, a *fuse.Attr) error {
	debug.Log("file.Attr", "Attr(%v)", f.node.Name)
	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
}
예제 #24
0
// Attr sets the fuse attribute for the file
func (f *File) Attr(ctx context.Context, attr *fuse.Attr) (err error) {
	// Set attributes from resource metadata
	attr.Mode = f.resource.Mode()
	attr.Uid = f.uid
	attr.Gid = f.gid

	if rf, ok := f.resource.(continuity.RegularFile); ok {
		attr.Nlink = uint32(len(rf.Paths()))
		attr.Size = uint64(rf.Size())
	} else {
		attr.Nlink = 1
	}

	attr.Inode = f.inode

	return nil
}
예제 #25
0
파일: dir.go 프로젝트: conductant/gohm
func (d *Dir) Attr(c context.Context, a *fuse.Attr) error {
	defer log.Debugln("dir_attr:", d.path, a)
	return d.fs.backend.View(c, func(ctx Context) error {
		b, err := ctx.Dir(d.path)
		if err != nil {
			return err
		}
		meta, err := b.DirMeta()
		if err != nil {
			return err
		}
		a.Uid = meta.Uid
		a.Gid = meta.Gid
		a.Mode = os.ModeDir | meta.Perm
		return nil
	})
}
예제 #26
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
}
예제 #27
0
파일: file.go 프로젝트: postfix/otaru
func (n FileNode) Attr(ctx context.Context, a *bfuse.Attr) error {
	attr, err := n.fs.Attr(n.id)
	if err != nil {
		panic("fs.Attr failed for FileNode")
	}

	a.Valid = 1 * time.Minute
	a.Nlink = 1
	a.Inode = uint64(n.id)
	a.Mode = os.FileMode(attr.PermMode) & os.ModePerm
	a.Atime = attr.ModifiedT
	a.Mtime = attr.ModifiedT
	a.Ctime = attr.ModifiedT
	a.Crtime = attr.ModifiedT
	a.Size = uint64(attr.Size)
	a.Uid = attr.Uid
	a.Gid = attr.Gid
	return nil
}
예제 #28
0
// Attr fills out the attributes for the file
func (f *File) Attr(ctx context.Context, a *fuse.Attr) error {
	f.mu.Lock()
	defer f.mu.Unlock()
	fs.Debug(f.o, "File.Attr")
	a.Gid = gid
	a.Uid = uid
	a.Mode = filePerms
	// if o is nil it isn't valid yet, so return the size so far
	if f.o == nil {
		a.Size = uint64(atomic.LoadInt64(&f.size))
	} else {
		a.Size = uint64(f.o.Size())
		if !noModTime {
			modTime := f.o.ModTime()
			a.Atime = modTime
			a.Mtime = modTime
			a.Ctime = modTime
			a.Crtime = modTime
		}
	}
	return nil
}
예제 #29
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
}
예제 #30
0
func (n *rootsDir) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = os.ModeDir | n.dirMode()
	a.Uid = uint32(os.Getuid())
	a.Gid = uint32(os.Getgid())
	return nil
}