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 }
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 }
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 }
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 }
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 }
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 }
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 }
// 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) }
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 }
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 }
// 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 }
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 }
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 }
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 }
// 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 }
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 }
// 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 })) }
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 }
// 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 })) }
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 }
// 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 }
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 }
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 }
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 }
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 }
// 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 }
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 }
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 }
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 }
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 }