diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-04-30 01:49:21 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-04-30 01:49:21 +0200 |
commit | f8478eb4c4a60d0deb9eb3276540d74f1866f878 (patch) | |
tree | e2944be30aff6c16a0efa7e6734a7f46e21ce80b | |
parent | 56611ced3949dba491a6bc7d0271837b3808fb2f (diff) |
lib9p: allow rewinding in 9pfile directories
-rw-r--r-- | sys/include/9p.h | 2 | ||||
-rw-r--r-- | sys/man/2/9pfile | 2 | ||||
-rw-r--r-- | sys/src/lib9p/file.c | 8 | ||||
-rw-r--r-- | sys/src/lib9p/srv.c | 4 |
4 files changed, 10 insertions, 6 deletions
diff --git a/sys/include/9p.h b/sys/include/9p.h index 22d64c57f..c51b1c2b9 100644 --- a/sys/include/9p.h +++ b/sys/include/9p.h @@ -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*); /* diff --git a/sys/man/2/9pfile b/sys/man/2/9pfile index 668d61689..4572b83aa 100644 --- a/sys/man/2/9pfile +++ b/sys/man/2/9pfile @@ -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 diff --git a/sys/src/lib9p/file.c b/sys/src/lib9p/file.c index 53fba67a8..b2e726cbf 100644 --- a/sys/src/lib9p/file.c +++ b/sys/src/lib9p/file.c @@ -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) diff --git a/sys/src/lib9p/srv.c b/sys/src/lib9p/srv.c index 779af8dd0..9090b1a52 100644 --- a/sys/src/lib9p/srv.c +++ b/sys/src/lib9p/srv.c @@ -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 |