diff options
author | Russ Cox <rsc@swtch.com> | 2008-01-12 11:04:41 -0500 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2008-01-12 11:04:41 -0500 |
commit | 52abe8e13010b21ae13d05f1428caca05aa24bdf (patch) | |
tree | f014fd554fd5922d6a3324fb2ab0acac2c482ab7 /src/libdiskfs | |
parent | 1a4b58ebd8421085ce3e8f9f3f513b12e4547271 (diff) | |
download | plan9port-52abe8e13010b21ae13d05f1428caca05aa24bdf.tar.gz plan9port-52abe8e13010b21ae13d05f1428caca05aa24bdf.tar.bz2 plan9port-52abe8e13010b21ae13d05f1428caca05aa24bdf.zip |
libdiskfs: fix ext2 directory reading bug (Mike Mammarella)
Diffstat (limited to 'src/libdiskfs')
-rw-r--r-- | src/libdiskfs/ext2.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/libdiskfs/ext2.c b/src/libdiskfs/ext2.c index d0ea65e2..afd95222 100644 --- a/src/libdiskfs/ext2.c +++ b/src/libdiskfs/ext2.c @@ -568,7 +568,7 @@ ext2readdir(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int coo { u32int nblock; u32int i; - int off, done; + int off, outofspace; uchar *data, *dp, *dep, *p, *ep, *ndp; Dirent de; Inode ino; @@ -588,6 +588,9 @@ ext2readdir(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int coo if((ok = inoperm(&ino, au, AREAD)) != Nfs3Ok) return ok; + if(debug) print("readdir cookie %#llux ino.size %#llux\n", + (u64int)cookie, (u64int)ino.size); + if(cookie >= ino.size){ *peof = 1; *pcount = 0; @@ -604,8 +607,8 @@ ext2readdir(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int coo nblock = (ino.size+fs->blocksize-1) / fs->blocksize; i = cookie/fs->blocksize; off = cookie%fs->blocksize; - done = 0; - for(; i<nblock && !done; i++){ + outofspace = 0; + for(; i<nblock && !outofspace; i++, off=0){ if(i==nblock-1) want = ino.size % fs->blocksize; else @@ -642,16 +645,16 @@ ext2readdir(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int coo e.name = de.name; e.namelen = de.namlen; e.cookie = (u64int)i*fs->blocksize + (p - b->data); + if(debug) print("%.*s %#llux\n", utfnlen(e.name, e.namelen), e.name, (u64int)e.cookie); if(nfs3entrypack(dp, dep, &ndp, &e) < 0){ - done = 1; + outofspace = 1; break; } dp = ndp; } - off = 0; blockput(b); } - if(i==nblock) + if(i==nblock && !outofspace) *peof = 1; *pcount = dp - data; |