コード例 #1
0
ファイル: fuse_fs.go プロジェクト: hatchling/fuse_gdrive
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
}
コード例 #2
0
ファイル: mut.go プロジェクト: pombredanne/camlistore
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
ファイル: mut.go プロジェクト: pombredanne/camlistore
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
ファイル: diskstats.go プロジェクト: chenchun/cgroupfs
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
}
コード例 #5
0
ファイル: vmstat.go プロジェクト: chenchun/cgroupfs
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
}
コード例 #6
0
ファイル: meminfo.go プロジェクト: chenchun/cgroupfs
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
}
コード例 #7
0
ファイル: dot-snap.go プロジェクト: read-later/bazil
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
}
コード例 #8
0
ファイル: common.go プロジェクト: gozes/kbfs-beta
// 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)
}
コード例 #9
0
ファイル: pull.go プロジェクト: pgm/singleply
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
}
コード例 #10
0
ファイル: file.go プロジェクト: porty/simple-network-fuse
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
}
コード例 #11
0
ファイル: etcdfs.go プロジェクト: Merovius/etcdfs
// 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
}
コード例 #12
0
ファイル: filesystem.go プロジェクト: saakaifoundry/pachyderm
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
}
コード例 #13
0
ファイル: file.go プロジェクト: funkygao/gafka
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
}
コード例 #14
0
ファイル: clockfs.go プロジェクト: read-later/fuse
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
}
コード例 #15
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
}
コード例 #16
0
ファイル: fuse.go プロジェクト: tiberiuc/web-compiler
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
}
コード例 #17
0
ファイル: entry.go プロジェクト: disorganizer/brig
// 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
	}))
}
コード例 #18
0
ファイル: fuse.go プロジェクト: jk-todo/syncthing-fuse
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
}
コード例 #19
0
ファイル: directory.go プロジェクト: disorganizer/brig
// 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
	}))
}
コード例 #20
0
ファイル: main.go プロジェクト: moul/fuse-snmp
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
}
コード例 #21
0
ファイル: etcdfs.go プロジェクト: Merovius/etcdfs
// 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
}
コード例 #22
0
ファイル: gocfs.go プロジェクト: thingswise/gocfs
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
}
コード例 #23
0
ファイル: filesystem.go プロジェクト: sr/pachyderm
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
}
コード例 #24
0
ファイル: fs.go プロジェクト: cholcombe973/scannerfs
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
}
コード例 #25
0
ファイル: fuse.go プロジェクト: jk-todo/syncthing-fuse
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
}
コード例 #26
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
}
コード例 #27
0
ファイル: file.go プロジェクト: 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
}
コード例 #28
0
ファイル: tree.go プロジェクト: Reisender/acdfuse
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
}
コード例 #29
0
ファイル: snapshot.go プロジェクト: klauspost/restic
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
}
コード例 #30
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
}