diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 56b345b..551531e 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -212,9 +212,11 @@ COUNT dir_read(REG f_node_ptr fnp) REG UWORD secsize = fnp->f_dpb->dpb_secsize; unsigned new_diroff = fnp->f_diroff; - /* can't have more than 65535 directory entries */ - if (new_diroff == 65535) - return DE_SEEK; + /* can't have more than 65535 directory entries + remove lfn entries may call us with new_diroff == -1 + for root directories though */ + if (!fnp->f_flags.f_droot && new_diroff >= 65535U) + return DE_SEEK; /* Directories need to point to their current offset, not for */ /* next op. Therefore, if it is anything other than the first */ diff --git a/kernel/fatfs.c b/kernel/fatfs.c index e4110c6..0a22f28 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -451,7 +451,9 @@ COUNT remove_lfn_entries(f_node_ptr fnp) if (fnp->f_diroff == 0) break; fnp->f_diroff -= 2; - /* it cannot / should not get below 0 because of '.' and '..' */ + /* it cannot / should not get below 0 because of '.' and '..' + * except for root directories... but then dir_read() makes it 0 + * again */ if (dir_read(fnp) <= 0) { dir_close(fnp); return DE_BLKINVLD;