Fix the boot issue for Fedora/CentOS when file name contains special character (e.g. '(' ) #2360

pull/2336/merge
longpanda 1 year ago
parent 0961ce5624
commit 84b2ee7ee3

@ -125,6 +125,7 @@ fi
#iso-scan (currently only for Fedora) #iso-scan (currently only for Fedora)
if $GREP -q Fedora /etc/os-release; then if $GREP -q Fedora /etc/os-release; then
if /ventoy/tool/vtoydump -a /ventoy/ventoy_os_param; then
if ventoy_iso_scan_check; then if ventoy_iso_scan_check; then
echo "iso_scan process ..." >> $VTLOG echo "iso_scan process ..." >> $VTLOG
@ -139,6 +140,7 @@ if $GREP -q Fedora /etc/os-release; then
exit 0 exit 0
fi fi
fi
fi fi

@ -22,6 +22,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
@ -444,6 +445,29 @@ static int vtoy_vlnk_printf(ventoy_os_param *param, char *diskname)
return 1; return 1;
} }
static int vtoy_check_iso_path_alpnum(ventoy_os_param *param)
{
char c;
int i = 0;
while (param->vtoy_img_path[i])
{
c = param->vtoy_img_path[i];
if (isalnum(c) || c == '_' || c == '-')
{
}
else
{
return 1;
}
i++;
}
return 0;
}
static int vtoy_check_device(ventoy_os_param *param, const char *device) static int vtoy_check_device(ventoy_os_param *param, const char *device)
{ {
unsigned long long size; unsigned long long size;
@ -560,6 +584,7 @@ int vtoydump_main(int argc, char **argv)
int rc; int rc;
int ch; int ch;
int print_path = 0; int print_path = 0;
int check_ascii = 0;
int print_fs = 0; int print_fs = 0;
int vlnk_print = 0; int vlnk_print = 0;
char filename[256] = {0}; char filename[256] = {0};
@ -567,7 +592,7 @@ int vtoydump_main(int argc, char **argv)
char device[64] = {0}; char device[64] = {0};
ventoy_os_param *param = NULL; ventoy_os_param *param = NULL;
while ((ch = getopt(argc, argv, "c:f:p:t:s:v::")) != -1) while ((ch = getopt(argc, argv, "a:c:f:p:t:s:v::")) != -1)
{ {
if (ch == 'f') if (ch == 'f')
{ {
@ -586,6 +611,11 @@ int vtoydump_main(int argc, char **argv)
print_path = 1; print_path = 1;
strncpy(filename, optarg, sizeof(filename) - 1); strncpy(filename, optarg, sizeof(filename) - 1);
} }
else if (ch == 'a')
{
check_ascii = 1;
strncpy(filename, optarg, sizeof(filename) - 1);
}
else if (ch == 't') else if (ch == 't')
{ {
vlnk_print = 1; vlnk_print = 1;
@ -660,6 +690,10 @@ int vtoydump_main(int argc, char **argv)
{ {
rc = vtoy_check_device(param, device); rc = vtoy_check_device(param, device);
} }
else if (check_ascii)
{
rc = vtoy_check_iso_path_alpnum(param);
}
else else
{ {
// print os param, you can change the output format in the function // print os param, you can change the output format in the function

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save