9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit ea34d4f32a2e60c84f6eb3c5874534918745e206
parent a13c2f1424a23920f1570ca15c89d92f80ee6cad
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 21 Oct 2020 21:02:54 +0200

os9: Fix continue value in devs

Last changes modify how dirread() works, and 0 means go to
the next element and it is not end of file anymore.

Change-Id: If5e8e2bebb8110486e33c30f0865b21c1f8bcf27

Diffstat:
Msrc/os9/dev/dev.c | 11++++++-----
Msrc/os9/dev/devroot.c | 2+-
2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/os9/dev/dev.c b/src/os9/dev/dev.c @@ -327,16 +327,17 @@ dirread(Chan *c, Dirtab *tab, int ntab, Devgen *gen) { - int cnt, i, n; + int cnt, n; Dir dir; cnt = 0; - for (i = c->index; nbytes >= DIRLEN; i++) { - switch ((*gen)(c, tab, ntab, i, &dir)) { + while (nbytes >= DIRLEN) { + switch ((*gen)(c, tab, ntab, c->index++, &dir)) { case 0: continue; case -1: - return (cnt > 0) ? cnt : -1; + /* FIXME: We cannot mark an error in the 1st iteration */ + return (cnt >= 0) ? cnt : -1; case 1: c->offset += DIRLEN; n = dirtop9(&dir, buf + cnt, nbytes); @@ -372,7 +373,7 @@ devgen(Chan *c, Dirtab *tab, int ntab, int n, Dir *dir) Dirtab *dp; if (!tab || n >= ntab) - return 0; + return -1; dp = &tab[n]; mkentry(c, dir, dp->name, dp->length, dp->qid, dp->perm); diff --git a/src/os9/dev/devroot.c b/src/os9/dev/devroot.c @@ -56,7 +56,7 @@ rootgen(Chan *c, Dirtab *tab, int ntab, int n, Dir *dir) ntab = NELEM(blobtab); break; default: - return 0; + return -1; } return devgen(c, tab, ntab, n, dir);