Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F138032871
D27542.id82805.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D27542.id82805.diff
View Options
Index: libexec/flua/modules/lfs.c
===================================================================
--- libexec/flua/modules/lfs.c
+++ libexec/flua/modules/lfs.c
@@ -122,6 +122,27 @@
#define DIR_METATABLE "directory iterator metatable"
+static int
+lua_dir_iter_pushtype(lua_State *L __unused, const struct dirent *ent __unused)
+{
+
+ /*
+ * This is a non-standard extension to luafilesystem for loader's
+ * benefit. The extra stat() calls to determine the entry type can
+ * be quite expensive on some systems, so this speeds up enumeration of
+ * /boot greatly by providing the type up front.
+ *
+ * This extension is compatible enough with luafilesystem, in that we're
+ * just using an extra return value for the iterator.
+ */
+#ifdef _STANDALONE
+ lua_pushinteger(L, ent->d_type);
+ return 1;
+#else
+ return 0;
+#endif
+}
+
static int
lua_dir_iter_next(lua_State *L)
{
@@ -144,7 +165,7 @@
}
lua_pushstring(L, entry->d_name);
- return 1;
+ return 1 + lua_dir_iter_pushtype(L, entry);
}
static int
@@ -420,5 +441,10 @@
{
register_metatable(L);
luaL_newlib(L, fslib);
+#ifdef _STANDALONE
+ /* Non-standard extension for loader, used with lfs.dir(). */
+ lua_pushinteger(L, DT_DIR);
+ lua_setfield(L, -2, "DT_DIR");
+#endif
return 1;
}
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 ~= lfs.DT_DIR then
+ goto continue
+ end
+ elseif lfs.attributes(fname, "mode") ~= "directory" then
goto continue
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 29, 9:00 AM (10 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26324338
Default Alt Text
D27542.id82805.diff (1 KB)
Attached To
Mode
D27542: stand: lua: enhance lfs.dir() to speed up kernels_autodetect
Attached
Detach File
Event Timeline
Log In to Comment