Beispiel #1
0
func (mi MemInfoFile) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = INODE_MEMINFO
	a.Mode = 0444
	data, _ := mi.readAll()
	a.Size = uint64(len(data))
	return nil
}
Beispiel #2
0
// Attr implements fs.Node.
func (d *etcdDir) Attr(ctx context.Context, attr *fuse.Attr) error {
	attr.Inode = inode(d.n.Key)
	attr.Mode = os.ModeDir | 0555
	//	attr.Uid = uint32(os.Getuid())
	//	attr.Gid = uint32(os.Getgid())
	return nil
}
Beispiel #3
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
}
Beispiel #4
0
func (f *File) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = 2
	a.Mode = 0444
	t := f.content.Load().(string)
	a.Size = uint64(len(t))
	return nil
}
Beispiel #5
0
func (v VMStatFile) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = INODE_VMSTAT
	a.Mode = 0444
	data, _ := v.readAll()
	a.Size = uint64(len(data))
	return nil
}
Beispiel #6
0
func (f *file) Attr(ctx context.Context, a *fuse.Attr) (retErr error) {
	defer func() {
		if retErr == nil {
			protolion.Debug(&FileAttr{&f.Node, &Attr{uint32(a.Mode)}, errorToString(retErr)})
		} else {
			protolion.Error(&FileAttr{&f.Node, &Attr{uint32(a.Mode)}, errorToString(retErr)})
		}
	}()
	fileInfo, err := f.fs.apiClient.InspectFileUnsafe(
		f.File.Commit.Repo.Name,
		f.File.Commit.ID,
		f.File.Path,
		f.fs.getFromCommitID(f.getRepoOrAliasName()),
		f.Shard,
		f.fs.handleID,
	)
	if err != nil {
		return err
	}
	if fileInfo != nil {
		a.Size = fileInfo.SizeBytes
		a.Mtime = prototime.TimestampToTime(fileInfo.Modified)
	}
	a.Mode = 0666
	a.Inode = f.fs.inode(f.File)
	return nil
}
Beispiel #7
0
func (f File) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = 0
	a.Mode = f.info.Mode
	a.Size = uint64(f.info.Size)
	a.Mtime = f.info.ModTime
	return nil
}
Beispiel #8
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
}
Beispiel #9
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
}
Beispiel #10
0
func (sn *serveNode) attr(ctx context.Context, attr *fuse.Attr) error {
	err := nodeAttr(ctx, sn.node, attr)
	if attr.Inode == 0 {
		attr.Inode = sn.inode
	}
	return err
}
Beispiel #11
0
func (ds DiskStatsFile) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = INODE_DISKSTATS
	a.Mode = 0444
	data, _ := ds.readAll()
	a.Size = uint64(len(data))
	return nil
}
Beispiel #12
0
// Attr implements fs.Node.
func (f *etcdFile) Attr(ctx context.Context, attr *fuse.Attr) error {
	attr.Inode = inode(f.n.Key)
	attr.Size = uint64(len(f.n.Value))
	attr.Mode = 0444
	//	attr.Uid = uint32(os.Getuid())
	//	attr.Gid = uint32(os.Getgid())
	return nil
}
Beispiel #13
0
func (f *File) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = f.Inode
	// FIXME: compute the size dynamically
	a.Size = uint64(100)
	a.Mode = 0444
	logrus.Infof("File.Attr: ctx=%q, a=%q", ctx, a)
	return nil
}
Beispiel #14
0
func (d Dir) Attr(ctx context.Context, a *fuse.Attr) error {
	// no need to lock since no cassandra access
	log.Debug("Dir.Attr(%s)", d.GetPath())
	a.Valid = time.Second
	a.Inode = 0
	a.Mode = os.ModeDir | os.ModePerm
	return nil
}
Beispiel #15
0
func (f File) Attr(ctx context.Context, attr *fuse.Attr) error {
	val, err := f.KV.Get("web/nginxkey")
	if err != nil {
		return err
	}
	attr.Inode = 2
	attr.Mode = 0444
	attr.Size = uint64(len(val))
	return nil
}
Beispiel #16
0
func (this *TreeEntry) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = this.E.Inode
	a.Mode = this.Mode

	if this.E.Type == fuse.DT_File {
		a.Size = this.sizeCallback(this)
	}

	return nil
}
Beispiel #17
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
}
Beispiel #18
0
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
}
Beispiel #19
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
}
Beispiel #20
0
func (d *directory) Attr(ctx context.Context, a *fuse.Attr) (retErr error) {
	defer func() {
		protolog.Info(&DirectoryAttr{&d.Node, &Attr{uint32(a.Mode)}, errorToString(retErr)})
	}()
	if d.Write {
		a.Mode = os.ModeDir | 0775
	} else {
		a.Mode = os.ModeDir | 0555
	}
	a.Inode = d.fs.inode(d.File)
	return nil
}
Beispiel #21
0
func (f *File) Attr(ctx context.Context, a *fuse.Attr) error {
	log.Debugf("path: %s", f.path)

	f.fs.files[f.path] = f

	a.Inode = 2
	a.Mode = 0444
	a.Size = uint64(len(f.content))
	a.Valid = time.Second * 1

	return nil
}
Beispiel #22
0
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
}
Beispiel #23
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
}
Beispiel #24
0
// Attr returns attributes about this Secret
func (s Secret) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = s.inode
	a.Mode = 0444

	content, err := s.ReadAll(ctx)
	if err != nil {
		logrus.WithError(err).Error("could not determine content length")
		return fuse.EIO
	}

	a.Size = uint64(len(content))
	return nil
}
Beispiel #25
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
}
Beispiel #26
0
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
}
Beispiel #27
0
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
}
Beispiel #28
0
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.Inode = uint64(n.id)
	a.Mode = 0666
	a.Atime = time.Now()
	a.Mtime = time.Now()
	a.Ctime = time.Now()
	a.Crtime = time.Now()
	a.Size = uint64(attr.Size)
	return nil
}
Beispiel #29
0
func (d *directory) Attr(ctx context.Context, a *fuse.Attr) (retErr error) {
	defer func() {
		protolion.Debug(&DirectoryAttr{&d.Node, &Attr{uint32(a.Mode)}, errorToString(retErr)})
	}()

	a.Valid = time.Nanosecond
	if d.Write {
		a.Mode = os.ModeDir | 0775
	} else {
		a.Mode = os.ModeDir | 0555
	}
	a.Inode = d.fs.inode(d.File)
	a.Mtime = prototime.TimestampToTime(d.Modified)
	return nil
}
Beispiel #30
0
func (d DirNode) Attr(ctx context.Context, a *bfuse.Attr) error {
	log.Printf("DirNode Attr id: %d", d.id)

	attr, err := d.fs.Attr(d.id)
	if err != nil {
		panic("bfs.Attr failed for DirNode")
	}

	a.Inode = uint64(d.id)
	a.Mode = os.ModeDir | 0777
	a.Atime = time.Now()
	a.Mtime = time.Now()
	a.Ctime = time.Now()
	a.Crtime = time.Now()
	a.Size = uint64(attr.Size)
	return nil
}