aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/9pfuse
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-08-01 14:38:30 +0000
committerrsc <devnull@localhost>2006-08-01 14:38:30 +0000
commitca6a2d95acc005ef9a50e3f962ef0bbaa7876751 (patch)
tree50186bb887c82e3d4f845e5ba4c1ec41189e2553 /src/cmd/9pfuse
parentbe8b4b397af631bad302ef2646477f228b4537b5 (diff)
downloadplan9port-ca6a2d95acc005ef9a50e3f962ef0bbaa7876751.tar.gz
plan9port-ca6a2d95acc005ef9a50e3f962ef0bbaa7876751.tar.bz2
plan9port-ca6a2d95acc005ef9a50e3f962ef0bbaa7876751.zip
break from readdir properly (Lou Kamenov)
Diffstat (limited to 'src/cmd/9pfuse')
-rw-r--r--src/cmd/9pfuse/main.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c
index 567b6770..789c963b 100644
--- a/src/cmd/9pfuse/main.c
+++ b/src/cmd/9pfuse/main.c
@@ -825,24 +825,26 @@ fusereaddir(FuseMsg *m)
p = buf;
ep = buf + n;
for(;;){
- if(ff->nd == 0){
- free(ff->d0);
- ff->d0 = nil;
- ff->d = nil;
- if((ff->nd = fsdirread(ff->fid, &ff->d0)) < 0){
- replyfuseerrstr(m);
- return;
- }
- if(ff->nd == 0)
- break;
- ff->d = ff->d0;
- }
- while(ff->nd > 0 && canpack(ff->d, ff->off, &p, ep)){
+ while(ff->nd > 0){
+ if(!canpack(ff->d, ff->off, &p, ep))
+ goto out;
ff->off++;
ff->d++;
ff->nd--;
}
- }
+ free(ff->d0);
+ ff->d0 = nil;
+ ff->d = nil;
+ if((ff->nd = fsdirread(ff->fid, &ff->d0)) < 0){
+ replyfuseerrstr(m);
+ free(buf);
+ return;
+ }
+ if(ff->nd == 0)
+ break;
+ ff->d = ff->d0;
+ }
+out:
replyfuse(m, buf, p - buf);
free(buf);
}