dirty dirtiness handles uint32 // when was this entry last changed // TODO: written time.Time } var _ = node(&file{}) var _ = fs.Node(&file{}) var _ = fs.NodeForgetter(&file{}) var _ = fs.NodeOpener(&file{}) var _ = fs.NodeSetattrer(&file{}) var _ = fs.NodeFsyncer(&file{}) var _ = fs.HandleFlusher(&file{}) var _ = fs.HandleReader(&file{}) var _ = fs.HandleWriter(&file{}) var _ = fs.HandleReleaser(&file{}) func (f *file) setName(name string) { f.mu.Lock() defer f.mu.Unlock() f.name = name } func (f *file) marshalInternal() (*wire.Dirent, error) { de := &wire.Dirent{ Inode: f.inode, } manifest, err := f.blob.Save() if err != nil { return nil, err
package record import ( "sync" "sync/atomic" "bazil.org/fuse" "bazil.org/fuse/fs" ) // Writes gathers data from FUSE Write calls. type Writes struct { buf Buffer } var _ = fs.HandleWriter(&Writes{}) func (w *Writes) Write(req *fuse.WriteRequest, resp *fuse.WriteResponse, intr fs.Intr) fuse.Error { n, err := w.buf.Write(req.Data) resp.Size = n if err != nil { // TODO hiding error return fuse.EIO } return nil } func (w *Writes) RecordedWriteData() []byte { return w.buf.Bytes() }
l := []fuse.Dirent{ {Inode: 2, Name: "bench", Type: fuse.DT_File}, } return l, nil } type benchFile struct { conf *benchConfig } var _ = fs.Node(benchFile{}) var _ = fs.NodeOpener(benchFile{}) var _ = fs.NodeFsyncer(benchFile{}) var _ = fs.Handle(benchFile{}) var _ = fs.HandleReader(benchFile{}) var _ = fs.HandleWriter(benchFile{}) func (benchFile) Attr() fuse.Attr { return fuse.Attr{Inode: 2, Mode: 0644, Size: 9999999999999999} } func (f benchFile) Open(req *fuse.OpenRequest, resp *fuse.OpenResponse, intr fs.Intr) (fs.Handle, fuse.Error) { if f.conf.directIO { resp.Flags |= fuse.OpenDirectIO } // TODO configurable? resp.Flags |= fuse.OpenKeepCache return f, nil } func (benchFile) Read(req *fuse.ReadRequest, resp *fuse.ReadResponse, intr fs.Intr) fuse.Error {
glog.Infof("Reading file: %s.\n", fh.r.Name()) if _, err := fh.r.Seek(req.Offset, 0); err != nil { return err } buf := make([]byte, req.Size) n, err := fh.r.Read(buf) resp.Data = buf[:n] if err != nil && err != io.EOF { glog.Error(err) return err } return nil } var _ = fs.HandleWriter(&FileHandle{}) func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error { glog.Infof("Entered Write\n") //TODO: Check if we need to add something here for playlists and drop directories. if fh.r == nil { if fh.f.name == ".description" { glog.Errorf("Not allowed to write description file.\n") //TODO: Allow to write description return nil } return fuse.EIO } glog.Infof("Writing file: %s.\n", fh.r.Name()) if _, err := fh.r.Seek(req.Offset, 0); err != nil {
n, err := h.layer.Seek(0, os.SEEK_SET) if err != nil { log.Warningf("Seek failed on flush: %v", err) return fuse.ENODATA } if n != 0 { log.Warningf("Seek offset is not 0") } err = h.fsys.Store.StageFromReader(h.path, h.layer, compress.AlgoSnappy) if err != nil && err != store.ErrNoChange { log.Warningf("Add failed: %v", err) return fuse.ENODATA } if err := h.layer.Close(); err != nil { log.Warningf("Close failed: %v", err) return fuse.ENODATA } return nil } // Compiler checks to see if we got all the interfaces right: var _ = fs.HandleFlusher(&Handle{}) var _ = fs.HandleReader(&Handle{}) var _ = fs.HandleReleaser(&Handle{}) var _ = fs.HandleWriter(&Handle{})