From 23babd4510cc8a01986219949896e38e51d48fc5 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Wed, 22 Oct 2008 21:42:11 +0000 Subject: 20081022-2242 --- emu/port/devfs-posix.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'emu/port/devfs-posix.c') diff --git a/emu/port/devfs-posix.c b/emu/port/devfs-posix.c index ead87023..bd1d9a94 100644 --- a/emu/port/devfs-posix.c +++ b/emu/port/devfs-posix.c @@ -29,6 +29,7 @@ struct Fsinfo struct dirent* de; /* directory reading */ int fd; /* open files */ ulong offset; /* offset when reading directory */ + int eod; /* end of directory */ QLock oq; /* mutex for offset */ char* spec; Cname* name; /* Unix's name for file */ @@ -278,6 +279,7 @@ fsopen(Chan *c, int mode) FS(c)->dir = opendir(FS(c)->name->s); if(FS(c)->dir == 0) oserror(); + FS(c)->eod = 0; } else { if(mode & OTRUNC) @@ -333,6 +335,7 @@ fscreate(Chan *c, char *name, int mode, ulong perm) FS(c)->dir = opendir(n->s); if(FS(c)->dir == nil) oserror(); + FS(c)->eod = 0; } else { o = (O_CREAT | O_EXCL) | (mode&3); if(mode & OTRUNC) @@ -752,11 +755,13 @@ fsdirread(Chan *c, uchar *va, int count, vlong offset) if(FS(c)->offset != offset) { seekdir(FS(c)->dir, 0); FS(c)->de = nil; + FS(c)->eod = 0; for(n=0; ndir); if(de == 0) { /* EOF, so stash offset and return 0 */ FS(c)->offset = n; + FS(c)->eod = 1; return 0; } if(de->d_ino==0 || de->d_name[0]==0 || isdots(de->d_name)) @@ -778,6 +783,9 @@ fsdirread(Chan *c, uchar *va, int count, vlong offset) FS(c)->offset = offset; } + if(FS(c)->eod) + return 0; + /* * Take idl on behalf of id2name. Stalling attach, which is a * rare operation, until the readdir completes is probably @@ -789,8 +797,10 @@ fsdirread(Chan *c, uchar *va, int count, vlong offset) FS(c)->de = nil; if(de == nil) de = readdir(FS(c)->dir); - if(de == nil) + if(de == nil){ + FS(c)->eod = 1; break; + } if(de->d_ino==0 || de->d_name[0]==0 || isdots(de->d_name)) continue; -- cgit v1.2.3