git: 28d2b8b70047 - stable/13 - loader: lua: test that /boot exists first

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Thu, 13 Jan 2022 09:49:08 UTC
The branch stable/13 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=28d2b8b70047f6f3a6cc0d02c5090d333f7a61cb

commit 28d2b8b70047f6f3a6cc0d02c5090d333f7a61cb
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2021-12-13 13:18:12 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-01-13 07:58:54 +0000

    loader: lua: test that /boot exists first
    
    Otherwise on fs like tftp where no directory listing is possible we fail
    on the .dir method.
    
    Reviewed by:    imp, kevans
    MFC after:      2 weeks
    Sponsored by:   Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D33414
    
    (cherry picked from commit c4dc907254a4275d8f3ecd9a6b615c6e2a2438e9)
---
 stand/lua/core.lua | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/stand/lua/core.lua b/stand/lua/core.lua
index 55c26e0d6d39..67d51b992858 100644
--- a/stand/lua/core.lua
+++ b/stand/lua/core.lua
@@ -229,6 +229,13 @@ function core.kernelList()
 		end
 	end
 
+	-- Do not attempt to autodetect if underlying filesystem
+	-- do not support directory listing (e.g. tftp, http)
+	if not lfs.attributes("/boot", "mode") then
+		autodetect = "no"
+		loader.setenv("kernels_autodetect", "NO")
+	end
+
 	-- Base whether we autodetect kernels or not on a loader.conf(5)
 	-- setting, kernels_autodetect. If it's set to 'yes', we'll add
 	-- any kernels we detect based on the criteria described.