作者:hatchlin
项目:fuse_gdriv
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
}
作者:pombredann
项目:camlistor
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
}
作者:chenchu
项目:cgroupf
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
}
作者:chenchu
项目:cgroupf
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
}
作者:chenchu
项目:cgroupf
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
}
作者:read-late
项目:bazi
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
}
作者:goze
项目:kbfs-bet
// 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)
}
作者:pg
项目:singlepl
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
}
作者:port
项目:simple-network-fus
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
}
作者:Meroviu
项目:etcdf
// 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
}
作者:saakaifoundr
项目:pachyder
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
}
作者:funkyga
项目:gafk
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
}
作者:read-late
项目:fus
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
}
作者:marcopaganin
项目:rclon
// 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
}
作者:tiberiu
项目:web-compile
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
}
作者:disorganize
项目:bri
// 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
}))
}
作者:jk-tod
项目:syncthing-fus
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
}
作者:disorganize
项目:bri
// 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
}))
}
作者:mou
项目:fuse-snm
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
}
作者:thingswis
项目:gocf
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
}