Index: libexec/flua/modules/lfs.c =================================================================== --- libexec/flua/modules/lfs.c +++ libexec/flua/modules/lfs.c @@ -122,6 +122,32 @@ #define DIR_METATABLE "directory iterator metatable" +static int +lua_dir_iter_pushtype(lua_State *L __unused, struct dirent *entry __unused) +{ + +#ifdef _STANDALONE + const char *typestr; + + switch (entry->d_type) { + case DT_REG: + typestr = "REG"; + break; + case DT_DIR: + typestr = "DIR"; + break; + default: + typestr = "UNKNOWN"; + break; + } + + lua_pushstring(L, typestr); + return 1; +#else + return 0; +#endif +} + static int lua_dir_iter_next(lua_State *L) { @@ -144,7 +170,7 @@ } lua_pushstring(L, entry->d_name); - return 1; + return 1 + lua_dir_iter_pushtype(L, entry); } static int Index: stand/lua/core.lua =================================================================== --- stand/lua/core.lua +++ stand/lua/core.lua @@ -240,14 +240,18 @@ -- Automatically detect other bootable kernel directories using a -- heuristic. Any directory in /boot that contains an ordinary file -- named "kernel" is considered eligible. - for file in lfs.dir("/boot") do + for file, ftype in lfs.dir("/boot") do local fname = "/boot/" .. file if file == "." or file == ".." then goto continue end - if lfs.attributes(fname, "mode") ~= "directory" then + if ftype then + if ftype ~= "DIR" then + goto continue + end + elseif lfs.attributes(fname, "mode") ~= "directory" then goto continue end