Example #1
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)
}
Example #2
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
}
Example #3
0
func nodeAttr(ctx context.Context, n Node, attr *fuse.Attr) error {
	attr.Valid = attrValidTime
	attr.Nlink = 1
	attr.Atime = startTime
	attr.Mtime = startTime
	attr.Ctime = startTime
	attr.Crtime = startTime
	if err := n.Attr(ctx, attr); err != nil {
		return err
	}
	return nil
}
Example #4
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
}
Example #5
0
func (d *directory) Attr(ctx context.Context, a *fuse.Attr) (retErr error) {
	defer func() {
		protolog.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)
	return nil
}
Example #6
0
// Attr implements the fs.Node interface for SpecialReadFile.
func (f *SpecialReadFile) Attr(ctx context.Context, a *fuse.Attr) error {
	data, t, err := f.read(ctx)
	if err != nil {
		return err
	}

	// Have a low non-zero value for Valid to avoid being swamped
	// with requests, while still keeping the size up to date.
	a.Valid = 1 * time.Second
	// Some apps (e.g., Chrome) get confused if we use a 0 size
	// here, as is usual for pseudofiles. So return the actual
	// size, even though it may be racy.
	a.Size = uint64(len(data))
	a.Mtime = t
	a.Ctime = t
	a.Mode = 0444
	return nil
}
Example #7
0
func (d *directory) Attr(ctx context.Context, a *fuse.Attr) (retErr error) {
	defer func() {
		if retErr == nil {
			protolion.Debug(&DirectoryAttr{&d.Node, &Attr{uint32(a.Mode)}, errorToString(retErr)})
		} else {
			protolion.Error(&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
}
Example #8
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.Valid = 1 * time.Minute
	a.Nlink = 1
	a.Inode = uint64(n.id)
	a.Mode = os.FileMode(attr.PermMode) & os.ModePerm
	a.Atime = attr.ModifiedT
	a.Mtime = attr.ModifiedT
	a.Ctime = attr.ModifiedT
	a.Crtime = attr.ModifiedT
	a.Size = uint64(attr.Size)
	a.Uid = attr.Uid
	a.Gid = attr.Gid
	return nil
}
Example #9
0
// Attr implements the fs.Node interface for TLF.
func (tlf *TLF) Attr(ctx context.Context, a *fuse.Attr) error {
	dir := tlf.getStoredDir()
	if dir == nil {
		tlf.folder.fs.log.CDebugf(
			ctx, "Faking Attr for TLF %s", tlf.folder.name)
		// Have a low non-zero value for Valid to avoid being
		// swamped with requests, while still not showing
		// stale data for too long if we end up loading the
		// dir.
		a.Valid = 1 * time.Second
		a.Mode = os.ModeDir | 0700
		if tlf.isPublic() {
			a.Mode |= 0055
		}
		return nil
	}

	return dir.Attr(ctx, a)
}
Example #10
0
func (f File) Attr(ctx context.Context, a *fuse.Attr) error {
	lock.Lock()
	defer lock.Unlock()
	log.Debug("Attr(%s,%d)", f.GetPath(), f.PathId)
	a.Valid = time.Second
	a.Inode = 0
	a.Mode = os.ModePerm
	var err error
	a.Size, err = f.getSize()
	if err != nil {
		log.Error("getSize error: %s", err.Error())
		return err
	}
	if attr, err := basicAttr(f.Fs, f.GetPath()); err != nil {
		log.Error("basicAttr error: %s", err.Error())
		return err
	} else {
		a.Mtime = time.Unix(int64(attr.Modified), 0)
		a.Ctime = time.Unix(int64(attr.Created), 0)
		a.Atime = time.Unix(int64(attr.Access), 0)
	}
	log.Debug("size=%d", a.Size)
	return nil
}
Example #11
0
func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = 1
	a.Mode = os.ModeDir | 0555
	a.Valid = time.Second * 1
	return nil
}