include "consts.9ps" # 9p protocol proc version(msize, version) { send(Tversion, notag, msize:u32, version:str) } proc attach(fid, afid, uname, aname) { send(Tattach, iota(), fid:u32, afid:u32, uname:str, aname:str) } proc walk(fid, newfid, ...) { send(Twalk, iota(), fid:u32, newfid:u32, vargs:u16, ...) } proc open(fid, mode) { send(Topen, iota(), fid:u32, mode:u8) } proc clunk(fid) { send(Tclunk, iota(), fid:u32) } # useful functions proc mount(fid, path) { version(msize, np2000) m = recv() assert ( m.type == Rversion m.tag == notag m.msize <= msize # m.version == version ) attach(fid, nofid, "op", path) m = recv() assert ( m.type == Rattach m.qid.type == QTDIR ) } proc expect(t) { m = recv() assert m.type == t } proc expect-error() { m = recv() assert m.type == Rerror debug("got expected error", m) }