Exemplo n.º 1
0
func (sc *serveConn) attrFromFile(file drive_db.File) fuse.Attr {
	var atime, mtime, crtime time.Time
	if err := atime.UnmarshalText([]byte(file.LastViewedByMeDate)); err != nil {
		atime = startup
	}
	if err := mtime.UnmarshalText([]byte(file.ModifiedDate)); err != nil {
		mtime = startup
	}
	if err := crtime.UnmarshalText([]byte(file.CreatedDate)); err != nil {
		crtime = startup
	}
	blocks := file.FileSize / int64(blockSize)
	if r := file.FileSize % int64(blockSize); r > 0 {
		blocks += 1
	}
	attr := fuse.Attr{
		Valid:  *driveMetadataLatency,
		Inode:  file.Inode,
		Atime:  atime,
		Mtime:  mtime,
		Ctime:  mtime,
		Crtime: crtime,
		Uid:    sc.uid,
		Gid:    sc.gid,
		Mode:   0755,
		Size:   uint64(file.FileSize),
		Blocks: uint64(blocks),
	}
	if file.MimeType == driveFolderMimeType {
		attr.Mode = os.ModeDir | 0755
	}
	return attr
}
Exemplo n.º 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
}
Exemplo n.º 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
}
Exemplo n.º 4
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
}
Exemplo n.º 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
}
Exemplo n.º 6
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
}
Exemplo n.º 7
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
}
Exemplo n.º 8
0
// fillAttr sets attributes based on the entry info. It only handles fields
// common to all entryinfo types.
func fillAttr(ei *libkbfs.EntryInfo, a *fuse.Attr) {
	a.Valid = 1 * time.Minute

	a.Size = ei.Size
	a.Mtime = time.Unix(0, ei.Mtime)
	a.Ctime = time.Unix(0, ei.Ctime)
}
Exemplo n.º 9
0
func (f *File) Attr(ctx context.Context, a *fuse.Attr) error {
	//	a.Inode = 2
	fmt.Printf("File.Attr(%s) -> size=%d\n", f.path, f.size)
	a.Mode = 0444
	a.Size = f.size
	return nil
}
Exemplo n.º 10
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
}
Exemplo n.º 11
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
}
Exemplo n.º 12
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
}
Exemplo n.º 13
0
func (f *File) Attr(ctx context.Context, o *fuse.Attr) error {
	f.RLock()
	defer f.RUnlock()

	*o = f.attr

	// calculate size
	if !f.opened {
		if err := f.dir.reconnectKafkaIfNecessary(); err != nil {
			return err
		}

		latestOffset, err := f.dir.GetOffset(f.topic, f.partitionId, sarama.OffsetNewest)
		if err != nil {
			log.Error(err)

			return err
		}
		oldestOffset, err := f.dir.GetOffset(f.topic, f.partitionId, sarama.OffsetOldest)
		if err != nil {
			log.Error(err)

			return err
		}

		o.Size = uint64(latestOffset - oldestOffset)
	} else {
		o.Size = uint64(len(f.content))
	}

	log.Trace("File Attr, topic=%s, partitionId=%d, size=%d", f.topic, f.partitionId, o.Size)

	return nil
}
Exemplo n.º 14
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
}
Exemplo n.º 15
0
// 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
}
Exemplo n.º 16
0
func (f File) Attr(a *fuse.Attr) {
	println(" fac attr")
	data, _ := pluginManager.ProcessFile(f.Path, f.Name)

	length := uint64(len(data))
	a.Mode = 0444
	a.Size = length
}
Exemplo n.º 17
0
// Attr is called to get the stat(2) attributes of a file.
func (e *Entry) Attr(ctx context.Context, a *fuse.Attr) error {
	return Errorize("entry-attr", e.fsys.Store.ViewNode(e.path, func(nd store.Node) error {
		a.Mode = 0755
		a.Size = nd.Size()
		a.Mtime = nd.ModTime()
		return nil
	}))
}
Exemplo n.º 18
0
func (f File) Attr(ctx context.Context, a *fuse.Attr) error {
	entry := f.m.GetEntry(f.folder, f.path)

	a.Mode = 0444
	a.Mtime = time.Unix(entry.Modified, 0)
	a.Size = uint64(entry.Size())
	return nil
}
Exemplo n.º 19
0
// Attr is called to retrieve stat-metadata about the directory.
func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) error {
	return Errorize("dir-attr", d.fsys.Store.ViewNode(d.path, func(nd store.Node) error {
		a.Mode = os.ModeDir | 0755
		a.Size = nd.Size()
		a.Mtime = nd.ModTime()
		return nil
	}))
}
Exemplo n.º 20
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
}
Exemplo n.º 21
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
}
Exemplo n.º 22
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
}
Exemplo n.º 23
0
func (d *directory) Attr(ctx context.Context, a *fuse.Attr) error {
	if d.write {
		a.Mode = os.ModeDir | 0775
	} else {
		a.Mode = os.ModeDir | 0555
	}
	return nil
}
Exemplo n.º 24
0
func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) error {
	if d.host.address == "" {
		// root directory
		a.Mode = os.ModeDir | 0755
		return nil
	}
	a.Mode = os.ModeNamedPipe | 0755
	return nil
}
Exemplo n.º 25
0
func (d Dir) Attr(ctx context.Context, a *fuse.Attr) error {
	if debugFuse {
		l.Debugln("Dir Attr folder", d.folder, "path", d.path)
	}
	entry := d.m.GetEntry(d.folder, d.path)
	a.Mode = os.ModeDir | 0555
	a.Mtime = time.Unix(entry.Modified, 0)
	return nil
}
Exemplo n.º 26
0
// 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
}
Exemplo n.º 27
0
Arquivo: file.go Projeto: a2sdl/etcfs
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
}
Exemplo n.º 28
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
}
Exemplo n.º 29
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
}
Exemplo n.º 30
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
}