History

fix reads of big directories

Benjamin Scher Purcell committed 11 years ago

Commit 03e5da91 parent c45ff902 files · +11 −5Browse files

Unified · Split

2 files
  1. 9p.c +9 −4
  2. 9pfs.c +2 −1
9p.c+9−4
@@ -431,15 +431,20 @@ int · 430 unmodified lines
431431 _9pdirread(int fd, FFid *f, Dir **d)
432432 {
433433 FDir *fdir;
434− uchar buf[DIRMAX];
434+ uchar buf[DIRMAX], *b;
435435 u32int ts, n;
436436
437437 dprint("_9pdirread\n");
438438 n = f->iounit;
439− ts = _9pread(fd, f, buf, n);
440− if(ts <= 0)
439+ b = buf;
440+ while((ts = _9pread(fd, f, b, n)) > 0){
441+ b += ts;
442+ if(b - buf > DIRMAX - n)
443+ break;
444+ }
445+ if(ts < 0)
441446 return ts;
442− ts = dirpackage(buf, ts, d);
447+ ts = dirpackage(buf, b - buf, d);
443448 dprint("_9pdirread about to lookupdir with path %s\n", f->path);
444449 if((fdir = lookupdir(f->path, PUT)) != NULL){
445450 fdir->dirs = *d;
9pfs.c+2−1
@@ -330,7 +330,8 @@ fsreaddir(const char *path, void *data, fuse_fill_dir_t ffd, · 329 unmodified lines
330330
331331 ffd(data, ".", NULL, 0);
332332 ffd(data, "..", NULL, 0);
333− n = _9pdirread(srvfd, (FFid*)ffi->fh, &d);
333+ if((n = _9pdirread(srvfd, (FFid*)ffi->fh, &d)) < 0)
334+ return -EIO;
334335 dprint("fsreaddir returned from _9pdirread ndirs is %d\n", n);
335336 for(e = d; e < d + n; e++){
336337 s.st_ino = e->qid.path;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t