Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Aug 2014 20:19:10 GMT
From:      pedrosouza@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r272049 - soc2014/pedrosouza/lua_loader/head/sys/boot/lua
Message-ID:  <201408072019.s77KJA9W053833@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pedrosouza
Date: Thu Aug  7 20:19:09 2014
New Revision: 272049
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272049

Log:
  Added kernel selection menu

Modified:
  soc2014/pedrosouza/lua_loader/head/sys/boot/lua/config.lua
  soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua

Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/config.lua
==============================================================================
--- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/config.lua	Thu Aug  7 18:56:10 2014	(r272048)
+++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/config.lua	Thu Aug  7 20:19:09 2014	(r272049)
@@ -286,4 +286,27 @@
     else
         print("Configurations load failed!\n");
     end
+end
+
+function config.reload(kernel)
+    local res = 1;
+    
+    -- unload all modules
+    print("unloading modules . . .\n");
+    loader.perform("unload");
+    
+    if kernel ~= nil then
+        res = loader.perform("load "..kernel);
+        if res == 0 then print("Kernel '"..kernel.."' loaded!"); end
+    end
+    
+    -- failed to load kernel or it is nil
+    -- then load default
+    if res == 1 then
+        print("loading default kernel\n");
+        config.loadkernel();
+    end
+    
+    -- load modules
+    config.loadmod(modules);
 end
\ No newline at end of file

Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua
==============================================================================
--- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua	Thu Aug  7 18:56:10 2014	(r272048)
+++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua	Thu Aug  7 20:19:09 2014	(r272049)
@@ -1,4 +1,5 @@
 include("/boot/core.lua");
+include("/boot/config.lua");
 include("/boot/screen.lua");
 include("/boot/drawer.lua");
 
@@ -159,7 +160,39 @@
         index = 5, 
         name = "Boot "..color.highlight("O").."ptions", 
         func = function () menu.run(boot_options); return false; end
-    } 
+    },
+    ["6"] = {
+        index = 6,
+        getName = function ()
+            local v = loader.getenv("kernels");
+            if not v then 
+                return "Kernels (not availabe)";
+            end
+            return "Kernels";
+        end,
+        func = function() 
+            local kernels = {};
+            local v = loader.getenv("kernels");
+            local i = 1;
+            
+            if not v then return; end
+            
+            kernels[tostring(i)] = {index = i, name = "Return to menu "..color.highlight("[Backspace]"), func = function() return true; end};
+            kernels.alias = {["\08"] = kernels[tostring(i)]};
+            i = i + 1;
+            
+            for k in v:gmatch("([^;]+);?") do
+                kernels[tostring(i)] = {
+                    index = i,
+                    name = k,
+                    func = function() config.reload(k); end
+                };
+                i = i + 1;
+            end
+            menu.run(kernels);
+            return false;
+        end
+    }
 };
 
 menu.options.alias = {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408072019.s77KJA9W053833>