Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
112c5574
Commit
112c5574
authored
Aug 19, 2021
by
longpanda
Browse files
Show a warning message if the path of /ventoy/ventoy.json case mismatch.
parent
92db873b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
3 deletions
+118
-3
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
+98
-0
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
+6
-0
INSTALL/grub/grub.cfg
INSTALL/grub/grub.cfg
+14
-3
No files found.
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
View file @
112c5574
...
...
@@ -145,6 +145,8 @@ const char *g_menu_prefix[img_type_max] =
static
int
g_vtoy_load_prompt
=
0
;
static
char
g_vtoy_prompt_msg
[
64
];
static
char
g_json_case_mis_path
[
32
];
static
int
ventoy_get_fs_type
(
const
char
*
fs
)
{
if
(
NULL
==
fs
)
...
...
@@ -4695,6 +4697,101 @@ static grub_err_t ventoy_cmd_pop_pager(grub_extcmd_context_t ctxt, int argc, cha
VENTOY_CMD_RETURN
(
GRUB_ERR_NONE
);
}
static
int
ventoy_chk_case_file
(
const
char
*
filename
,
const
struct
grub_dirhook_info
*
info
,
void
*
data
)
{
if
(
g_json_case_mis_path
[
0
])
{
return
1
;
}
if
(
0
==
info
->
dir
&&
grub_strncasecmp
(
filename
,
"ventoy.json"
,
11
)
==
0
)
{
grub_snprintf
(
g_json_case_mis_path
,
32
,
"%s/%s"
,
(
char
*
)
data
,
filename
);
return
1
;
}
return
0
;
}
static
int
ventoy_chk_case_dir
(
const
char
*
filename
,
const
struct
grub_dirhook_info
*
info
,
void
*
data
)
{
char
path
[
16
];
chk_case_fs_dir
*
fs_dir
=
(
chk_case_fs_dir
*
)
data
;
if
(
g_json_case_mis_path
[
0
])
{
return
1
;
}
if
(
info
->
dir
&&
(
filename
[
0
]
==
'v'
||
filename
[
0
]
==
'V'
))
{
if
(
grub_strncasecmp
(
filename
,
"ventoy"
,
6
)
==
0
)
{
grub_snprintf
(
path
,
sizeof
(
path
),
"/%s"
,
filename
);
fs_dir
->
fs
->
fs_dir
(
fs_dir
->
dev
,
path
,
ventoy_chk_case_file
,
path
);
if
(
g_json_case_mis_path
[
0
])
{
return
1
;
}
}
}
return
0
;
}
static
grub_err_t
ventoy_cmd_chk_json_pathcase
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
)
{
int
fstype
=
0
;
char
*
device_name
=
NULL
;
grub_device_t
dev
=
NULL
;
grub_fs_t
fs
=
NULL
;
chk_case_fs_dir
fs_dir
;
(
void
)
ctxt
;
(
void
)
argc
;
(
void
)
args
;
device_name
=
grub_file_get_device_name
(
args
[
0
]);
if
(
!
device_name
)
{
goto
out
;
}
dev
=
grub_device_open
(
device_name
);
if
(
!
dev
)
{
goto
out
;
}
fs
=
grub_fs_probe
(
dev
);
if
(
!
fs
)
{
goto
out
;
}
fstype
=
ventoy_get_fs_type
(
fs
->
name
);
if
(
fstype
==
ventoy_fs_fat
||
fstype
==
ventoy_fs_exfat
||
fstype
>=
ventoy_fs_max
)
{
goto
out
;
}
g_json_case_mis_path
[
0
]
=
0
;
fs_dir
.
dev
=
dev
;
fs_dir
.
fs
=
fs
;
fs
->
fs_dir
(
dev
,
"/"
,
ventoy_chk_case_dir
,
&
fs_dir
);
if
(
g_json_case_mis_path
[
0
])
{
grub_env_set
(
"VTOY_PLUGIN_PATH_CASE_MISMATCH"
,
g_json_case_mis_path
);
}
out:
grub_check_free
(
device_name
);
check_free
(
dev
,
grub_device_close
);
VENTOY_CMD_RETURN
(
GRUB_ERR_NONE
);
}
int
ventoy_env_init
(
void
)
{
char
buf
[
64
];
...
...
@@ -4872,6 +4969,7 @@ static cmd_para ventoy_cmds[] =
{
"vt_search_replace_initrd"
,
ventoy_cmd_search_replace_initrd
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_push_pager"
,
ventoy_cmd_push_pager
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_pop_pager"
,
ventoy_cmd_pop_pager
,
0
,
NULL
,
""
,
""
,
NULL
},
{
"vt_check_json_path_case"
,
ventoy_cmd_chk_json_pathcase
,
0
,
NULL
,
""
,
""
,
NULL
},
};
int
ventoy_register_all_cmd
(
void
)
...
...
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
View file @
112c5574
...
...
@@ -547,6 +547,12 @@ typedef struct replace_fs_dir
int
filecnt
;
}
replace_fs_dir
;
typedef
struct
chk_case_fs_dir
{
grub_device_t
dev
;
grub_fs_t
fs
;
}
chk_case_fs_dir
;
int
ventoy_strcmp
(
const
char
*
pattern
,
const
char
*
str
);
int
ventoy_strncmp
(
const
char
*
pattern
,
const
char
*
str
,
grub_size_t
n
);
void
ventoy_fill_os_param
(
grub_file_t
file
,
ventoy_os_param
*
param
);
...
...
INSTALL/grub/grub.cfg
View file @
112c5574
...
...
@@ -1940,9 +1940,11 @@ vt_load_part_table $vtoydev
#Load Plugin
if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
clear
vt_load_plugin $vtoy_iso_part
clear
clear
vt_load_plugin $vtoy_iso_part
clear
else
vt_check_json_path_case $vtoy_iso_part
fi
if [ -n "$VTOY_MENU_TIMEOUT" ]; then
...
...
@@ -2009,6 +2011,15 @@ if [ -n "$VTOY_DEFAULT_KBD_LAYOUT" ]; then
set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT"
fi
if [ -n "$VTOY_PLUGIN_PATH_CASE_MISMATCH" ]; then
clear
echo "$VTOY_PLUGIN_PATH_CASE_MISMATCH"
echo -e "\n\nPath case does not match! ventoy directory and ventoy.json MUST be all lowercase!"
echo -e "\n路径大小写不匹配!ventoy 目录和 ventoy.json 文件的名字必须是全部小写,请修正!"
echo -e "\n\npress ENTER to continue (请按回车键继续) ..."
read vtInputKey
fi
if [ -n "$VTOY_PLUGIN_SYNTAX_ERROR" ]; then
clear
echo -e "\n Syntax error detected in ventoy.json, please check! \n"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment