Skip to content

Commit

Permalink
Add VTOY_MAX_SEARCH_LEVEL option in global control plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ventoy committed Mar 2, 2021
1 parent 324c978 commit bb7e10d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ int g_ventoy_img_count = 0;

grub_device_t g_enum_dev = NULL;
grub_fs_t g_enum_fs = NULL;
int g_img_max_search_level = -1;
img_iterator_node g_img_iterator_head;
img_iterator_node *g_img_iterator_tail = NULL;

Expand Down Expand Up @@ -1194,6 +1195,11 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh

if (info->dir)
{
if (node->level + 1 > g_img_max_search_level)
{
return 0;
}

if ((len == 1 && filename[0] == '.') ||
(len == 2 && filename[0] == '.' && filename[1] == '.'))
{
Expand Down Expand Up @@ -1224,6 +1230,7 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
new_node = grub_zalloc(sizeof(img_iterator_node));
if (new_node)
{
new_node->level = node->level + 1;
new_node->plugin_list_index = index;
new_node->dirlen = grub_snprintf(new_node->dir, sizeof(new_node->dir), "%s%s/", node->dir, filename);

Expand Down Expand Up @@ -2054,6 +2061,16 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char

g_img_iterator_head.tail = &tail;

if (g_img_max_search_level < 0)
{
g_img_max_search_level = GRUB_INT_MAX;
strdata = ventoy_get_env("VTOY_MAX_SEARCH_LEVEL");
if (strdata && ventoy_is_decimal(strdata))
{
g_img_max_search_level = (int)grub_strtoul(strdata, NULL, 10);
}
}

for (node = &g_img_iterator_head; node; node = node->next)
{
fs->fs_dir(dev, node->dir, ventoy_collect_img_files, node);
Expand Down
1 change: 1 addition & 0 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ typedef struct img_iterator_node
img_info **tail;
char dir[400];
int dirlen;
int level;
int isocnt;
int done;
int select;
Expand Down

0 comments on commit bb7e10d

Please sign in to comment.