"bazil.org/bazil/fs/snap/wire" "bazil.org/bazil/util/env" "bazil.org/fuse" fusefs "bazil.org/fuse/fs" "golang.org/x/net/context" ) type fuseFile struct { de *wire.Dirent rat io.ReaderAt } var _ = fusefs.Node(fuseFile{}) var _ = fusefs.NodeOpener(fuseFile{}) var _ = fusefs.Handle(fuseFile{}) var _ = fusefs.HandleReader(fuseFile{}) func (e fuseFile) Attr(ctx context.Context, a *fuse.Attr) error { a.Mode = 0444 a.Uid = env.MyUID a.Gid = env.MyGID a.Size = e.de.File.Manifest.Size // a.Mtime = e.Meta.Written.UTC() // a.Ctime = e.Meta.Written.UTC() // a.Crtime = e.Meta.Written.UTC() a.Blocks = statBlocks(e.de.File.Manifest.Size) // TODO .Space? return nil } func (e fuseFile) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fusefs.Handle, error) {
"bazil.org/bazil/fs/wire" "bazil.org/bazil/tokens" "bazil.org/bazil/util/env" "bazil.org/fuse" "bazil.org/fuse/fs" ) type listSnaps struct { fs *Volume rootDir *dir } var _ = fs.Node(&listSnaps{}) var _ = fs.NodeMkdirer(&listSnaps{}) var _ = fs.NodeStringLookuper(&listSnaps{}) var _ = fs.Handle(&listSnaps{}) var _ = fs.HandleReadDirer(&listSnaps{}) func (d *listSnaps) Attr() fuse.Attr { return fuse.Attr{ Inode: tokens.InodeSnap, Mode: os.ModeDir | 0755, Nlink: 1, Uid: env.MyUID, Gid: env.MyGID, } } var _ = fs.NodeStringLookuper(&listSnaps{}) func (d *listSnaps) Lookup(name string, intr fs.Intr) (fs.Node, fuse.Error) {
resp.MaxReadahead = 64 * 1024 * 1024 resp.Flags |= fuse.InitAsyncRead return nil } func (f benchFS) Root() (fs.Node, fuse.Error) { return benchDir{conf: f.conf}, nil } type benchDir struct { conf *benchConfig } var _ = fs.Node(benchDir{}) var _ = fs.NodeStringLookuper(benchDir{}) var _ = fs.Handle(benchDir{}) var _ = fs.HandleReadDirer(benchDir{}) func (benchDir) Attr() fuse.Attr { return fuse.Attr{Inode: 1, Mode: os.ModeDir | 0555} } func (d benchDir) Lookup(name string, intr fs.Intr) (fs.Node, fuse.Error) { if name == "bench" { return benchFile{conf: d.conf}, nil } return nil, fuse.ENOENT } func (benchDir) ReadDir(intr fs.Intr) ([]fuse.Dirent, fuse.Error) { l := []fuse.Dirent{
return child, nil default: return nil, fmt.Errorf("unknown entry in tree, %v", de) } } type fuseDir struct { chunkStore chunks.Store reader *Reader } var _ = fusefs.Node(fuseDir{}) var _ = fusefs.NodeStringLookuper(fuseDir{}) var _ = fusefs.NodeCreater(fuseDir{}) var _ = fusefs.Handle(fuseDir{}) var _ = fusefs.HandleReadDirAller(fuseDir{}) func (d fuseDir) Attr(ctx context.Context, a *fuse.Attr) error { a.Mode = os.ModeDir | 0555 a.Uid = env.MyUID a.Gid = env.MyGID return nil } const _MAX_INT64 = 9223372036854775807 func (d fuseDir) Lookup(ctx context.Context, name string) (fusefs.Node, error) { de, err := d.reader.Lookup(name) if err != nil { if os.IsNotExist(err) {
dir *Dir name string mu sync.Mutex // number of write-capable handles currently open writers uint // only valid if writers > 0 data []byte link bool target string links uint32 } var _ = fs.Node(&File{}) var _ = fs.Handle(&File{}) func (f *File) same_path(o *File) bool { p1 := strings.Join(append(f.dir.path, f.name), "/") p2 := strings.Join(append(o.dir.path, o.name), "/") return p1 == p2 } // load calls fn inside a View with the contents of the file. Caller // must make a copy of the data if needed. func (f *File) load(c context.Context, fn func([]byte)) error { defer log.Debugln("load:", f.dir.path, f.name) err := f.dir.fs.backend.View(c, func(ctx Context) error { b, err := ctx.Dir(f.dir.path) if err != nil { return err