core.lua (24a1bd54dc7d8deb3b354f100d36f7b0f43cb610) core.lua (a108046f58d0db8e2c67318282eb7509931a980f)
1--
2-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
3-- All rights reserved.
4--
5-- Redistribution and use in source and binary forms, with or without
6-- modification, are permitted provided that the following conditions
7-- are met:
8-- 1. Redistributions of source code must retain the above copyright

--- 113 unchanged lines hidden (view full) ---

122 core.sm = b;
123end
124
125function core.kernelList()
126 local k = loader.getenv("kernel");
127 local v = loader.getenv("kernels") or "";
128
129 local kernels = {};
1--
2-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
3-- All rights reserved.
4--
5-- Redistribution and use in source and binary forms, with or without
6-- modification, are permitted provided that the following conditions
7-- are met:
8-- 1. Redistributions of source code must retain the above copyright

--- 113 unchanged lines hidden (view full) ---

122 core.sm = b;
123end
124
125function core.kernelList()
126 local k = loader.getenv("kernel");
127 local v = loader.getenv("kernels") or "";
128
129 local kernels = {};
130 local unique = {};
130 local i = 0;
131 if (k ~= nil) then
132 i = i + 1;
133 kernels[i] = k;
131 local i = 0;
132 if (k ~= nil) then
133 i = i + 1;
134 kernels[i] = k;
135 unique[k] = true;
134 end
135
136 for n in v:gmatch("([^; ]+)[; ]?") do
136 end
137
138 for n in v:gmatch("([^; ]+)[; ]?") do
137 if (n ~= k) then
139 if (unique[n] == nil) then
138 i = i + 1;
139 kernels[i] = n;
140 i = i + 1;
141 kernels[i] = n;
142 unique[n] = true;
140 end
141 end
143 end
144 end
145
146 -- Automatically detect other bootable kernel directories using a
147 -- heuristic. Any directory in /boot that contains an ordinary file
148 -- named "kernel" is considered eligible.
149 for file in lfs.dir("/boot") do
150 local fname = "/boot/" .. file;
151
152 if (file == "." or file == "..") then
153 goto continue;
154 end
155
156 if (lfs.attributes(fname, "mode") ~= "directory") then
157 goto continue;
158 end
159
160 if (lfs.attributes(fname .. "/kernel", "mode") ~= "file") then
161 goto continue;
162 end
163
164 if (unique[file] == nil) then
165 i = i + 1;
166 kernels[i] = file;
167 unique[file] = true;
168 end
169
170 ::continue::
171 end
142 return kernels;
143end
144
145function core.setDefaults()
146 core.setACPI(core.getACPIPresent(true));
147 core.setSafeMode(false);
148 core.setSingleUser(false);
149 core.setVerbose(false);

--- 33 unchanged lines hidden ---
172 return kernels;
173end
174
175function core.setDefaults()
176 core.setACPI(core.getACPIPresent(true));
177 core.setSafeMode(false);
178 core.setSingleUser(false);
179 core.setVerbose(false);

--- 33 unchanged lines hidden ---