lib9p: allow rewinding in 9pfile directories
This commit is contained in:
parent
56611ced39
commit
f8478eb4c4
4 changed files with 10 additions and 6 deletions
|
@ -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*);
|
||||
|
||||
/*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue