Beispiel #1
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
}
Beispiel #2
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)
}
Beispiel #3
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
}
Beispiel #4
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
}
Beispiel #5
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
	}))
}
Beispiel #6
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
	}))
}
Beispiel #7
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
}
Beispiel #8
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
}
Beispiel #9
0
func (s staticFileNode) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = 0400
	a.Uid = uint32(os.Getuid())
	a.Gid = uint32(os.Getgid())
	a.Size = uint64(len(s))
	a.Mtime = serverStart
	a.Ctime = serverStart
	a.Crtime = serverStart
	return nil
}
Beispiel #10
0
func copyAttr(dst *fuse.Attr, src *pb.Attr) {
	dst.Inode = src.Inode
	dst.Mode = os.FileMode(src.Mode)
	dst.Size = src.Size
	dst.Mtime = time.Unix(src.Mtime, 0)
	dst.Atime = time.Unix(src.Atime, 0)
	dst.Ctime = time.Unix(src.Ctime, 0)
	dst.Crtime = time.Unix(src.Crtime, 0)
	dst.Uid = src.Uid
	dst.Gid = src.Gid
}
Beispiel #11
0
func (f File) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = f.mode
	a.Size = f.size
	a.Atime = f.Atime
	a.Mtime = f.Mtime
	a.Ctime = f.Ctime
	a.Crtime = f.Ctime
	a.Uid = f.Uid
	a.Gid = f.Gid
	return nil
}
Beispiel #12
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
}
Beispiel #13
0
Datei: dir.go Projekt: ncw/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
	a.Atime = d.modTime
	a.Mtime = d.modTime
	a.Ctime = d.modTime
	a.Crtime = d.modTime
	// FIXME include Valid so get some caching? Also mtime
	return nil
}
Beispiel #14
0
// Attr fills the file attributes for an object node.
func (o *Object) Attr(ctx context.Context, a *fuse.Attr) (err error) {
	a.Size = o.size()
	a.BlockSize = uint32(BlockSize)
	a.Blocks = (a.Size / uint64(a.BlockSize)) * 8
	a.Mode = os.FileMode(DefaultMode)
	a.Gid = uint32(DefaultGID)
	a.Uid = uint32(DefaultUID)
	a.Mtime = getMtime(o.so, o.sh)
	a.Ctime = a.Mtime
	a.Crtime = a.Mtime
	return nil
}
Beispiel #15
0
// Attr fills the file attributes for a symlink node.
func (s *Symlink) Attr(ctx context.Context, a *fuse.Attr) (err error) {
	a.Size = uint64(s.so.Bytes)
	a.BlockSize = 0
	a.Blocks = 0
	a.Mode = os.ModeSymlink | os.FileMode(DefaultMode)
	a.Gid = uint32(DefaultGID)
	a.Uid = uint32(DefaultUID)
	a.Mtime = getMtime(s.so, s.sh)
	a.Ctime = a.Mtime
	a.Crtime = a.Mtime
	return nil
}
Beispiel #16
0
func (l *link) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = l.node.Inode
	a.Mode = l.node.Mode

	if !l.ownerIsRoot {
		a.Uid = l.node.UID
		a.Gid = l.node.GID
	}
	a.Atime = l.node.AccessTime
	a.Ctime = l.node.ChangeTime
	a.Mtime = l.node.ModTime
	return nil
}
Beispiel #17
0
// Converts Attrs datastructure into FUSE represnetation
func (this *Attrs) Attr(a *fuse.Attr) error {
	a.Inode = this.Inode
	a.Mode = this.Mode
	if (a.Mode & os.ModeDir) == 0 {
		a.Size = this.Size
	}
	a.Uid = this.Uid
	a.Gid = this.Gid
	a.Mtime = this.Mtime
	a.Ctime = this.Ctime
	a.Crtime = this.Crtime
	return nil
}
Beispiel #18
0
func (d *dir) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = d.inode
	a.Mode = os.ModeDir | d.node.Mode

	if !d.ownerIsRoot {
		a.Uid = d.node.UID
		a.Gid = d.node.GID
	}
	a.Atime = d.node.AccessTime
	a.Ctime = d.node.ChangeTime
	a.Mtime = d.node.ModTime
	return nil
}
Beispiel #19
0
func (f *file) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = f.node.Inode
	a.Mode = f.node.Mode
	a.Size = f.node.Size

	if !f.ownerIsRoot {
		a.Uid = f.node.UID
		a.Gid = f.node.GID
	}
	a.Atime = f.node.AccessTime
	a.Ctime = f.node.ChangeTime
	a.Mtime = f.node.ModTime
	return nil
}
Beispiel #20
0
func (f File) Attr(ctx context.Context, a *fuse.Attr) error {
	entry, found := f.m.GetEntry(f.folder, f.path)

	// TODO assert file?

	if false == found {
		return fuse.ENOENT
	}

	a.Mode = 0444
	a.Mtime = time.Unix(entry.ModifiedS, 0)
	a.Size = uint64(entry.Size)
	return nil
}
Beispiel #21
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.Inode = uint64(n.id)
	a.Mode = 0666
	a.Atime = time.Now()
	a.Mtime = time.Now()
	a.Ctime = time.Now()
	a.Crtime = time.Now()
	a.Size = uint64(attr.Size)
	return nil
}
Beispiel #22
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
	}

	// 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
}
Beispiel #23
0
func (d *directory) Attr(ctx context.Context, a *fuse.Attr) (retErr error) {
	defer func() {
		protolion.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)
	a.Mtime = prototime.TimestampToTime(d.Modified)
	return nil
}
Beispiel #24
0
// Attr fills file attributes of a directory within the current context.
func (d *Directory) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = os.ModeDir | os.FileMode(DefaultMode)
	a.Gid = uint32(DefaultGID)
	a.Uid = uint32(DefaultUID)
	a.Size = uint64(BlockSize)

	if d.so != nil {
		a.Atime = time.Now()
		a.Mtime = MountTime
		a.Ctime = a.Mtime
		a.Crtime = a.Mtime
	}

	return nil
}
Beispiel #25
0
// lockedAttr fills in an Attr struct for this file. Call when the file's mutex is locked.
func (file *consulFile) lockedAttr(attr *fuse.Attr) {
	attr.Mode = file.ConsulFS.mode()
	if !file.Deleted {
		attr.Nlink = 1
	}
	// Timestamps aren't reflected in Consul, but it doesn't hurt to fake them
	attr.Ctime = file.Ctime
	attr.Mtime = file.Mtime
	attr.Atime = file.Atime
	attr.Uid = file.ConsulFS.UID
	attr.Gid = file.ConsulFS.GID
	if file.IsOpen {
		// Some applications like seeking...
		attr.Size = file.Size
	}
}
Beispiel #26
0
func (d DirNode) Attr(ctx context.Context, a *bfuse.Attr) error {
	log.Printf("DirNode Attr id: %d", d.id)

	attr, err := d.fs.Attr(d.id)
	if err != nil {
		panic("bfs.Attr failed for DirNode")
	}

	a.Inode = uint64(d.id)
	a.Mode = os.ModeDir | 0777
	a.Atime = time.Now()
	a.Mtime = time.Now()
	a.Ctime = time.Now()
	a.Crtime = time.Now()
	a.Size = uint64(attr.Size)
	return nil
}
Beispiel #27
0
func (f *file) Attr(ctx context.Context, a *fuse.Attr) error {
	debug.Log("file.Attr", "Attr(%v)", f.node.Name)
	a.Inode = f.node.Inode
	a.Mode = f.node.Mode
	a.Size = f.node.Size
	a.Blocks = (f.node.Size / blockSize) + 1
	a.BlockSize = blockSize

	if !f.ownerIsRoot {
		a.Uid = f.node.UID
		a.Gid = f.node.GID
	}
	a.Atime = f.node.AccessTime
	a.Ctime = f.node.ChangeTime
	a.Mtime = f.node.ModTime
	return nil
}
Beispiel #28
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
}
Beispiel #29
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
}
Beispiel #30
0
// Attr fills out the attributes for the file
func (f *File) Attr(ctx context.Context, a *fuse.Attr) error {
	f.mu.Lock()
	defer f.mu.Unlock()
	fs.Debug(f.o, "File.Attr")
	a.Gid = gid
	a.Uid = uid
	a.Mode = filePerms
	// if o is nil it isn't valid yet, so return the size so far
	if f.o == nil {
		a.Size = uint64(atomic.LoadInt64(&f.size))
	} else {
		a.Size = uint64(f.o.Size())
		if !noModTime {
			modTime := f.o.ModTime()
			a.Atime = modTime
			a.Mtime = modTime
			a.Ctime = modTime
			a.Crtime = modTime
		}
	}
	return nil
}