dirread9p is very useful for Read calls on directories. an example in go is
below, as i have used in my fileserver. it could just be called srv.Dirread.
type Dirgen func(uint64, interface{}) *p.Dir
func Dirread9p(req *srv.Req, gen Dirgen, i interface{}) {
var start uint64
var count uint32
p.InitRread(req.Rc, req.Tc.Count)
if req.Tc.Offset == 0 {
start = 0
} else {
start = req.Fid.Diroffset
}
b := req.Rc.Data
for len(b) > 0 {
d := gen(start, i)
if d == nil {
break
}
sz := p.PackDir(d, b, req.Conn.Dotu)
if sz == 0 {
break
}
b = b[sz:]
count += uint32(sz)
start++
}
req.Fid.Diroffset = start
p.SetRreadCount(req.Rc, uint32(count))
req.Respond()
}
Original issue reported on code.google.com by mischief@offblast.org on 10 Mar 2014 at 12:34
Original issue reported on code.google.com by
mischief@offblast.org
on 10 Mar 2014 at 12:34