Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dirread9p to srv #27

Open
GoogleCodeExporter opened this issue Mar 14, 2015 · 0 comments
Open

add dirread9p to srv #27

GoogleCodeExporter opened this issue Mar 14, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 10 Mar 2014 at 12:34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant