func (n *Server) Open(req *go9ps.Req) { fmt.Printf("Open fid=%d wname=%v\n", req.Tc.Fid, req.Tc.Wname) if req.Fid.Aux == nil { req.RespondError(go9ps.Enoent) return } e, ok := req.Fid.Aux.(*FileEntry) if !ok { req.RespondError(go9ps.Enoent) return } if e.h == nil { req.RespondError(go9ps.Enoent) return } if e.h.IsDir() { // FIXME: wrap dir operations in a readwriter to the 9p dir entry serialized format. } else { var err error e.openrw, err = e.h.OpenRW() if err != nil { req.RespondError(err) return } } qids := newQids(req.Tc.Mode) req.RespondRopen(&qids[0], 0) }
func (*Ufs) Open(req *srv.Req) { fid := req.Fid.Aux.(*Fid) tc := req.Tc err := fid.stat() if err != nil { req.RespondError(err) return } var e error fid.file, e = os.OpenFile(fid.path, omode2uflags(tc.Mode), 0) if e != nil { req.RespondError(toError(e)) return } req.RespondRopen(dir2Qid(fid.st), 0) }