expand: use FUZIX low level readdir functionality
authorAlan Cox <alan@linux.intel.com>
Mon, 11 May 2015 21:24:01 +0000 (22:24 +0100)
committerAlan Cox <alan@linux.intel.com>
Mon, 11 May 2015 21:24:01 +0000 (22:24 +0100)
Applications/V7/cmd/sh/expand.c

index e468336..ba93010 100644 (file)
@@ -37,8 +37,9 @@ int expand(char *as, int rflg)
        STRING rescan = 0;
        register char *s, *cs;
        ARGPTR schain = gchain;
-       struct dirent entry;
        STATBUF statb;
+       /* Use the internal API to avoid sucking in readdir and thus malloc */
+       struct __dirent entry;
 
        if (trapnote & SIGSET)
                return (0);
@@ -96,8 +97,9 @@ int expand(char *as, int rflg)
                        }
                } while (*rs++);
 
-               // FIXME: readdir
-               while (read(dirf, (void *) &entry, 32) == 32 && (trapnote & SIGSET) == 0) {
+               /* We don't want to use opendir as it uses calloc and sucks in malloc so we get
+                  down and dirty */
+               while (_getdirent(dirf, (void *) &entry, 32) == 32 && (trapnote & SIGSET) == 0) {
                        if (entry.d_ino == 0 || (*entry.d_name == '.' && *cs != '.'))
                                continue;
                        if (gmatch(entry.d_name, cs)) {