]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
add image_blacklist plugin option
authorlongpanda <admin@ventoy.net>
Tue, 26 Jan 2021 12:50:26 +0000 (20:50 +0800)
committerlongpanda <admin@ventoy.net>
Tue, 26 Jan 2021 12:50:26 +0000 (20:50 +0800)
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
INSTALL/grub/debug.cfg
INSTALL/grub/grub.cfg

index a1a8cf8e8b3711299d0b5303adeb4c835fe94b4a..acf7a2f673366c625f580eda9af8d391a713b332 100644 (file)
@@ -1031,7 +1031,7 @@ int ventoy_cmp_img(img_info *img1, img_info *img2)
     int c1 = 0;
     int c2 = 0;
 
     int c1 = 0;
     int c2 = 0;
 
-    if (g_plugin_image_list)
+    if (g_plugin_image_list == VENTOY_IMG_WHITE_LIST)
     {
         return (img1->plugin_list_index - img2->plugin_list_index);
     }
     {
         return (img1->plugin_list_index - img2->plugin_list_index);
     }
@@ -1069,7 +1069,7 @@ static int ventoy_cmp_subdir(img_iterator_node *node1, img_iterator_node *node2)
     int c1 = 0;
     int c2 = 0;
 
     int c1 = 0;
     int c2 = 0;
 
-    if (g_plugin_image_list)
+    if (g_plugin_image_list == VENTOY_IMG_WHITE_LIST)
     {
         return (node1->plugin_list_index - node2->plugin_list_index);
     }
     {
         return (node1->plugin_list_index - node2->plugin_list_index);
     }
@@ -1173,7 +1173,7 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
             return 0;
         }
 
             return 0;
         }
 
-        if (g_plugin_image_list)
+        if (g_plugin_image_list == VENTOY_IMG_WHITE_LIST)
         {
             grub_snprintf(g_img_swap_tmp_buf, sizeof(g_img_swap_tmp_buf), "%s%s/", node->dir, filename);
             index = ventoy_plugin_get_image_list_index(vtoy_class_directory, g_img_swap_tmp_buf);
         {
             grub_snprintf(g_img_swap_tmp_buf, sizeof(g_img_swap_tmp_buf), "%s%s/", node->dir, filename);
             index = ventoy_plugin_get_image_list_index(vtoy_class_directory, g_img_swap_tmp_buf);
@@ -1275,11 +1275,16 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
         {
             grub_snprintf(g_img_swap_tmp_buf, sizeof(g_img_swap_tmp_buf), "%s%s", node->dir, filename);
             index = ventoy_plugin_get_image_list_index(vtoy_class_image_file, g_img_swap_tmp_buf);
         {
             grub_snprintf(g_img_swap_tmp_buf, sizeof(g_img_swap_tmp_buf), "%s%s", node->dir, filename);
             index = ventoy_plugin_get_image_list_index(vtoy_class_image_file, g_img_swap_tmp_buf);
-            if (index == 0)
+            if (VENTOY_IMG_WHITE_LIST == g_plugin_image_list && index == 0)
             {
                 debug("File %s not found in image_list plugin config...\n", g_img_swap_tmp_buf);
                 return 0; 
             }
             {
                 debug("File %s not found in image_list plugin config...\n", g_img_swap_tmp_buf);
                 return 0; 
             }
+            else if (VENTOY_IMG_BLACK_LIST == g_plugin_image_list && index > 0)
+            {
+                debug("File %s found in image_blacklist plugin config...\n", g_img_swap_tmp_buf);
+                return 0; 
+            }
         }
         
         img = grub_zalloc(sizeof(img_info));
         }
         
         img = grub_zalloc(sizeof(img_info));
index 856cde3373b347941496538f16d386b789a6a057..c074d772ac5e52f55783a77380b6dc8eb920b0b5 100644 (file)
@@ -867,7 +867,11 @@ extern int g_ventoy_iso_uefi_drv;
 extern int g_ventoy_case_insensitive;
 extern grub_uint8_t g_ventoy_chain_type;
 extern int g_vhdboot_enable;
 extern int g_ventoy_case_insensitive;
 extern grub_uint8_t g_ventoy_chain_type;
 extern int g_vhdboot_enable;
+
+#define VENTOY_IMG_WHITE_LIST   1
+#define VENTOY_IMG_BLACK_LIST   2
 extern int g_plugin_image_list;
 extern int g_plugin_image_list;
+
 extern ventoy_gpt_info *g_ventoy_part_info;
 extern grub_uint64_t g_conf_replace_offset;
 extern grub_uint64_t g_svd_replace_offset;
 extern ventoy_gpt_info *g_ventoy_part_info;
 extern grub_uint64_t g_conf_replace_offset;
 extern grub_uint64_t g_svd_replace_offset;
index ef0474a60dc301364f882f5420026e067591576e..1843399b28668e5493b4e16dddf828d679b4f9aa 100644 (file)
@@ -1625,7 +1625,14 @@ static int ventoy_plugin_image_list_entry(VTOY_JSON *json, const char *isodisk)
         g_image_list_head = NULL;
     }
 
         g_image_list_head = NULL;
     }
 
-    g_plugin_image_list = 1;
+    if (grub_strcmp(json->pcName, "image_blacklist") == 0)
+    {
+        g_plugin_image_list = VENTOY_IMG_BLACK_LIST;
+    }
+    else
+    {
+        g_plugin_image_list = VENTOY_IMG_WHITE_LIST;
+    }
 
     for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
     {
 
     for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
     {
@@ -1693,6 +1700,7 @@ static plugin_entry g_plugin_entries[] =
     { "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check },
     { "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check },
     { "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
     { "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check },
     { "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check },
     { "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
+    { "image_blacklist", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
     { "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check },
     { "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check },
     { "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check },
     { "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check },
     { "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check },
     { "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check },
index 19e4733ba09a53bbe522521b5f2a8e6dd9463e4a..e91f525c42369f7529d15ac31715339adde3783b 100644 (file)
@@ -139,6 +139,15 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
         unset pager
     }
     
         unset pager
     }
     
+    menuentry 'Check image blacklist plugin configuration' --class=debug_imageblacklist {
+        set pager=1
+        vt_check_plugin_json $vt_plugin_path image_blacklist $vtoy_iso_part
+        
+        echo -e "\npress ENTER to exit ..."
+        read vtInputKey
+        unset pager
+    }
+    
     menuentry 'Check boot conf replace plugin configuration' --class=debug_bootconf_replace {
         set pager=1
         vt_check_plugin_json $vt_plugin_path conf_replace $vtoy_iso_part
     menuentry 'Check boot conf replace plugin configuration' --class=debug_bootconf_replace {
         set pager=1
         vt_check_plugin_json $vt_plugin_path conf_replace $vtoy_iso_part
index 349b0b46837da1a263326045ef62524ba56dce02..15fe1e61f34bf4f74c9a529b21e03b8cefa3bc34 100644 (file)
@@ -1631,6 +1631,17 @@ if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then
     read vtInputKey 
 fi
 
     read vtInputKey 
 fi
 
+for vtTFile in ventoy.json ventoy_grub.cfg; do
+    if [ -f $vtoy_efi_part/ventoy/$vtTFile ]; then
+        clear
+        echo -e "\n You need to put $vtTFile in the 1st partition which hold the ISO files.\n"
+        echo -e " $vtTFile 放错分区了,请放到镜像分区里的 ventoy 目录下(此目录需要手动创建)!\n"
+        echo -e "\n press ENTER to continue (请按 回车 键继续) ..."
+        read vtInputKey
+    fi
+done
+
+
 #export necessary variable
 export theme
 export gfxmode
 #export necessary variable
 export theme
 export gfxmode