lib9p: allow rewinding in 9pfile directories

This commit is contained in:
cinap_lenrek 2017-04-30 01:49:21 +02:00
parent 56611ced39
commit f8478eb4c4
4 changed files with 10 additions and 6 deletions

View file

@ -162,7 +162,7 @@ int removefile(File*);
void closefile(File*);
File* walkfile(File*, char*);
Readdir* opendirfile(File*);
long readdirfile(Readdir*, uchar*, long);
long readdirfile(Readdir*, uchar*, long, long);
void closedirfile(Readdir*);
/*

View file

@ -47,7 +47,7 @@ int removefile(File *file)
void closefile(File *file)
File* walkfile(File *dir, char *path)
Readdir* opendirfile(File *dir)
long readdirfile(Readdir *rdir, uchar *buf, long n)
long readdirfile(Readdir *rdir, uchar *buf, long n, long o)
void closedirfile(Readdir *rdir)
int hasperm(File *file, char *uid, int p)
.fi

View file

@ -394,12 +394,16 @@ opendirfile(File *dir)
}
long
readdirfile(Readdir *r, uchar *buf, long n)
readdirfile(Readdir *r, uchar *buf, long n, long o)
{
long x, m;
Filelist *fl;
for(fl=r->fl, m=0; fl && m+2<=n; fl=fl->link, m+=x){
if(o == 0)
fl = r->dir->filelist;
else
fl = r->fl;
for(m=0; fl && m+2<=n; fl=fl->link, m+=x){
if(fl->f == nil)
x = 0;
else if((x=convD2M(fl->f, buf+m, n-m)) <= BIT16SZ)

View file

@ -512,7 +512,7 @@ sread(Srv *srv, Req *r)
return;
}
if((r->fid->qid.type&QTDIR) && r->fid->file){
r->ofcall.count = readdirfile(r->fid->rdir, r->rbuf, r->ifcall.count);
r->ofcall.count = readdirfile(r->fid->rdir, r->rbuf, r->ifcall.count, r->ifcall.offset);
respond(r, nil);
return;
}
@ -525,7 +525,7 @@ static void
rread(Req *r, char *error)
{
if(error==nil && (r->fid->qid.type&QTDIR))
r->fid->diroffset += r->ofcall.count;
r->fid->diroffset = r->ifcall.offset + r->ofcall.count;
}
static void