name string blob *blobs.Blob 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, }
} func (r *Setattrs) RecordedSetattr() fuse.SetattrRequest { val := r.rec.Recorded() if val == nil { return fuse.SetattrRequest{} } return *(val.(*fuse.SetattrRequest)) } // Fsyncs records an Fsync request and its fields. type Fsyncs struct { rec RequestRecorder } var _ = fs.NodeFsyncer(&Fsyncs{}) func (r *Fsyncs) Fsync(req *fuse.FsyncRequest, intr fs.Intr) fuse.Error { tmp := *req r.rec.RecordRequest(&tmp) return nil } func (r *Fsyncs) RecordedFsync() fuse.FsyncRequest { val := r.rec.Recorded() if val == nil { return fuse.FsyncRequest{} } return *(val.(*fuse.FsyncRequest)) }
func (f *File) Setattr(c context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error { log.Debugln("file_setattr:", f.dir.path, f.name, req) f.mu.Lock() defer f.mu.Unlock() if req.Valid.Size() { if req.Size > uint64(maxInt) { return fuse.Errno(syscall.EFBIG) } newLen := int(req.Size) switch { case newLen > len(f.data): f.data = append(f.data, make([]byte, newLen-len(f.data))...) case newLen < len(f.data): f.data = f.data[:newLen] } } return nil } var _ = fs.NodeFsyncer(&File{}) // Here we don't do anything and just handle the request with no error. // This is because we have a simple Put semantic that writes all the data in a single // call. So there's no flushing or marking a commit. func (f *File) Fsync(c context.Context, req *fuse.FsyncRequest) error { return nil }
} func (benchDir) ReadDir(intr fs.Intr) ([]fuse.Dirent, fuse.Error) { 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
} newPath := path.Join(newParent.path, req.NewName) if err := e.fsys.Store.Move(e.path, newPath, true); err != nil { log.Warningf("fuse: entry: mv: %v", err) return err } return nil } // // Compile time checks to see which interfaces we implement: // Please update this list when modifying code here. var _ = fs.Node(&Entry{}) var _ = fs.NodeFsyncer(&Entry{}) var _ = fs.NodeGetxattrer(&Entry{}) var _ = fs.NodeListxattrer(&Entry{}) var _ = fs.NodeOpener(&Entry{}) var _ = fs.NodeSetattrer(&Entry{}) // var _ = fs.NodeRenamer(&Entry{}) //var _ = fs.NodeReadlinker(&Entry{}) //var _ = fs.NodeRemover(&Entry{}) //var _ = fs.NodeRemovexattrer(&Entry{}) // var _ = fs.NodeRequestLookuper(&Entry{}) // var _ = fs.NodeAccesser(&Entry{}) // var _ = fs.NodeForgetter(&Entry{}) //var _ = fs.NodeGetattrer(&Entry{})