Example #1
0
func (f *File) Attr(c context.Context, a *fuse.Attr) error {
	defer log.Debugln("file_attr:", f.dir.path, f.name, a)

	f.mu.Lock()
	defer f.mu.Unlock()

	return f.dir.fs.backend.View(c, func(ctx Context) error {
		b, err := ctx.Dir(f.dir.path)
		if err != nil {
			return err
		}
		meta, err := b.Meta(f.name)
		if err != nil {
			return err
		}
		a.Uid = meta.Uid
		a.Gid = meta.Gid
		a.Mode = meta.Perm
		a.Nlink = f.links
		if f.link {
			a.Mode = a.Mode | os.ModeSymlink
		}
		a.Size = uint64(len(f.data))
		if f.writers == 0 {
			// not in memory, fetch correct size.
			// Attr can't fail, so ignore errors
			_ = f.load(c, func(buff []byte) { a.Size = uint64(len(buff)) })
		}
		return nil
	})
}
Example #2
0
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
}
Example #3
0
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
}
Example #4
0
func (d *directory) Attr(ctx context.Context, a *fuse.Attr) (retErr error) {
	defer func() {
		protolog.Info(&DirectoryAttr{&d.Node, &Attr{uint32(a.Mode)}, errorToString(retErr)})
	}()
	if d.Write {
		a.Mode = os.ModeDir | 0775
	} else {
		a.Mode = os.ModeDir | 0555
	}
	return nil
}
Example #5
0
// Attr sets the fuse attributes for the directory
func (d *Dir) Attr(ctx context.Context, attr *fuse.Attr) (err error) {
	if d.resource == nil {
		attr.Mode = os.ModeDir | 0555
	} else {
		attr.Mode = d.resource.Mode()
	}

	attr.Uid = d.uid
	attr.Gid = d.gid
	attr.Inode = d.inode

	return nil
}
Example #6
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 #7
0
func (file StupidFile) Attr(ctx context.Context, attr *fuse.Attr) error {
	log.Println("StupidFile Attr")

	// XXX figure out some Inode scheme.

	if file.Mode != 0 {
		attr.Mode = file.Mode
	} else {
		attr.Mode = 0444
	}

	attr.Size = uint64(len(file.Contents))
	return nil
}
Example #8
0
// 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
}
Example #9
0
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
}
Example #10
0
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
}
Example #11
0
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
}
Example #12
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
}
Example #13
0
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
}
Example #14
0
func (f *File) attr(ctx context.Context, a *fuse.Attr) (err error) {
	de, err := f.folder.fs.config.KBFSOps().Stat(ctx, f.node)
	if err != nil {
		if _, ok := err.(libkbfs.NoSuchNameError); ok {
			return fuse.ESTALE
		}
		return err
	}

	fillAttr(&de, a)
	a.Mode = 0644
	if de.Type == libkbfs.Exec {
		a.Mode |= 0111
	}
	return nil
}
Example #15
0
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
}
Example #16
0
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
}
Example #17
0
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
}
Example #18
0
func (d *Dir) attr(ctx context.Context, a *fuse.Attr) (err error) {
	de, err := d.folder.fs.config.KBFSOps().Stat(ctx, d.node)
	if err != nil {
		if _, ok := err.(libkbfs.NoSuchNameError); ok {
			return fuse.ESTALE
		}
		return err
	}
	fillAttr(&de, a)

	a.Mode = os.ModeDir | 0700
	if d.folder.folderBranch.Tlf.IsPublic() {
		a.Mode |= 0055
	}
	return nil
}
Example #19
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
}
Example #20
0
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
}
Example #21
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
}
Example #22
0
func (stf STFolder) Attr(ctx context.Context, a *fuse.Attr) error {
	if debugFuse {
		l.Debugln("stf Attr")
	}
	a.Mode = os.ModeDir | 0555
	return nil
}
Example #23
0
File: fs.go Project: nzbfs/go-nzbfs
func attrFromStat(stat syscall.Stat_t) fuse.Attr {
	attr := fuse.Attr{
		Inode:  stat.Ino,
		Size:   uint64(stat.Size),
		Blocks: uint64(stat.Blocks),
		Atime:  timespecToTime(stat.Atim),
		Mtime:  timespecToTime(stat.Mtim),
		Ctime:  timespecToTime(stat.Ctim),
		Crtime: timespecToTime(stat.Ctim),
		Mode:   os.FileMode(stat.Mode),
		Nlink:  uint32(stat.Nlink),
		Uid:    stat.Uid,
		Gid:    stat.Gid,
		Rdev:   uint32(stat.Rdev),
		Flags:  0,
	}

	// Set attr.Mode like they do in pkg/os/stat_linux.go, since apparently
	// the stat.Mode uint32 is not the same as the os.FileMode uint32.
	attr.Mode = os.FileMode(stat.Mode & 0777)
	switch stat.Mode & syscall.S_IFMT {
	case syscall.S_IFBLK:
		attr.Mode |= os.ModeDevice
	case syscall.S_IFCHR:
		attr.Mode |= os.ModeDevice | os.ModeCharDevice
	case syscall.S_IFDIR:
		attr.Mode |= os.ModeDir
	case syscall.S_IFIFO:
		attr.Mode |= os.ModeNamedPipe
	case syscall.S_IFLNK:
		attr.Mode |= os.ModeSymlink
	case syscall.S_IFREG:
		// nothing to do
	case syscall.S_IFSOCK:
		attr.Mode |= os.ModeSocket
	}
	if stat.Mode&syscall.S_ISGID != 0 {
		attr.Mode |= os.ModeSetgid
	}
	if stat.Mode&syscall.S_ISUID != 0 {
		attr.Mode |= os.ModeSetuid
	}
	if stat.Mode&syscall.S_ISVTX != 0 {
		attr.Mode |= os.ModeSticky
	}
	return attr
}
Example #24
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
	}))
}
Example #25
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 #26
0
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
}
Example #27
0
// 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
}
Example #28
0
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
}
Example #29
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
}
Example #30
0
// Attr implements the fs.Node interface for EmptyFolder.
func (ef *EmptyFolder) Attr(ctx context.Context, a *fuse.Attr) (err error) {
	ctx = NewContextWithOpID(ctx, ef.fs.log)
	ef.fs.log.CDebugf(ctx, "Empty folder Attr")
	defer func() { ef.fs.reportErr(ctx, err) }()

	a.Mode = os.ModeDir | 0700
	return nil
}