plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

dirread.c (623B)


      1 #include <u.h>
      2 #include <libc.h>
      3 #include <fcall.h>
      4 #include <thread.h>
      5 #include <9p.h>
      6 
      7 void
      8 dirread9p(Req *r, Dirgen *gen, void *aux)
      9 {
     10 	int start;
     11 	uchar *p, *ep;
     12 	uint rv;
     13 	Dir d;
     14 
     15 	if(r->ifcall.offset == 0)
     16 		start = 0;
     17 	else
     18 		start = r->fid->dirindex;
     19 
     20 	p = (uchar*)r->ofcall.data;
     21 	ep = p+r->ifcall.count;
     22 
     23 	while(p < ep){
     24 		memset(&d, 0, sizeof d);
     25 		if((*gen)(start, &d, aux) < 0)
     26 			break;
     27 		rv = convD2M(&d, p, ep-p);
     28 		free(d.name);
     29 		free(d.muid);
     30 		free(d.uid);
     31 		free(d.gid);
     32 		if(rv <= BIT16SZ)
     33 			break;
     34 		p += rv;
     35 		start++;
     36 	}
     37 	r->fid->dirindex = start;
     38 	r->ofcall.count = p - (uchar*)r->ofcall.data;
     39 }