]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Auto use memdisk mode when booting iKuai OS.
authorlongpanda <admin@ventoy.net>
Tue, 31 May 2022 09:39:54 +0000 (17:39 +0800)
committerlongpanda <admin@ventoy.net>
Tue, 31 May 2022 09:39:54 +0000 (17:39 +0800)
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
INSTALL/grub/grub.cfg

index fdb929613bf8a2065c175e688719c5942fefc09a..51d11c9998d77c533b5edf4413cf895237e209b4 100644 (file)
@@ -2612,24 +2612,38 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
 {
     char value[32];
     char *pos = NULL;
+    char *last = NULL;
     const char *id = NULL;
     img_info *cur = NULL;
 
     (void)ctxt;
     
-    if (argc < 1 || argc > 2)
+    if (argc < 1 || argc > 3)
     {
         return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {var}", cmd_raw_name);
     }
 
     if (g_fake_vlnk_src[0] && g_fake_vlnk_dst[0])
     {
-        grub_env_set(args[0], grub_strchr(g_fake_vlnk_src, '/'));
+        pos = grub_strchr(g_fake_vlnk_src, '/');
+        grub_env_set(args[0], pos);
         if (argc > 1)
         {
             grub_snprintf(value, sizeof(value), "%llu", (ulonglong)(g_fake_vlnk_size));
             grub_env_set(args[1], value);        
         }
+        
+        if (argc > 2)
+        {
+            for (last = pos; *pos; pos++)
+            {
+                if (*pos == '/')
+                {
+                    last = pos;
+                }
+            }
+            grub_env_set(args[2], last + 1);
+        }
 
         goto end;
     }
@@ -2658,6 +2672,12 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
         grub_snprintf(value, sizeof(value), "%llu", (ulonglong)(cur->size));
         grub_env_set(args[1], value);        
     }
+    
+    if (argc > 2)
+    {
+        grub_snprintf(value, sizeof(value), "%llu", (ulonglong)(cur->size));
+        grub_env_set(args[2], cur->name);
+    }
 
 end:
     g_svd_replace_offset = 0;
index 3f6af71467ed83aeb9e8201fece142c9844a217c..72afa13cc9cd01c45ad9325b03aa111e6b3ead0e 100644 (file)
@@ -1301,7 +1301,7 @@ function iso_common_menuentry {
     unset vt_system_id
     unset vt_volume_id
     
-    vt_chosen_img_path vt_chosen_path vt_chosen_size
+    vt_chosen_img_path vt_chosen_path vt_chosen_size vt_chosen_name
 
     vt_parse_iso_volume "${vtoy_iso_part}${vt_chosen_path}" vt_system_id vt_volume_id vt_volume_space
     if [ $vt_volume_space -ne $vt_chosen_size ]; then        
@@ -1349,10 +1349,17 @@ function iso_common_menuentry {
             elif vt_iso_vd_id_begin 0 1 "KolibriOS"; then
                 set vtMemDiskBoot=1
             fi
-        fi 
+        fi
+        
+        #For iKuai8 (<64MB)
+        if [ $vt_chosen_size -le 67108864 ]; then
+            if vt_str_begin "$vt_chosen_name" "iKuai"; then
+                set vtMemDiskBoot=1
+            fi
+        fi
     fi
     vt_iso_vd_id_clear
-        
+
 
     if [ "$grub_platform" = "pc" ]; then
         if [ -n "$vtMemDiskBoot" ]; then