summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--emu/port/devfs-posix.c12
2 files changed, 14 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 072845f3..20afd1a2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+20081022
+ sh: ignore leading white space in fail: strings, and change empty tail to "failed"
+ /emu/port/devfs-posix.c don't call readdir after it has returned end of file
20081021
/appl/cmd/auth/ai2key.b new command to convert authinfo files to factotum keys
/appl/cmd/auth/factotum/proto/infauth.b allow new key format
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; n<offset; ) {
de = readdir(FS(c)->dir);
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;