X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/05a1b863a66bf72b26e5d87570c4e0e61b9736cd..3967fb5fb582f93faceb9a3350baca75221741f6:/vtoyfat/vtoyfat_linux.c diff --git a/vtoyfat/vtoyfat_linux.c b/vtoyfat/vtoyfat_linux.c index cf93ebd..55e4e2b 100644 --- a/vtoyfat/vtoyfat_linux.c +++ b/vtoyfat/vtoyfat_linux.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,20 @@ static int vtoy_disk_read(uint32 sector, uint8 *buffer, uint32 sector_count) return 1; } +static int check_secure_boot(void) +{ + void *flfile = NULL; + + flfile = fl_fopen("/EFI/BOOT/grubx64_real.efi", "rb"); + if (flfile) + { + fl_fclose(flfile); + return 0; + } + + return 1; +} + static int get_ventoy_version(void) { int rc = 1; @@ -91,11 +106,14 @@ static int get_ventoy_version(void) int main(int argc, char **argv) { + int op = 0; int rc = 1; + char *disk; - if (argc != 2) + if (argc != 2 && argc != 3) { - printf("Usage: vtoyfat /dev/sdb \n"); + printf("Usage: vtoyfat /dev/sdbs \n"); + printf("Usage: vtoyfat -s /dev/sdbs \n"); return 1; } @@ -104,10 +122,17 @@ int main(int argc, char **argv) return 0; } - g_disk_fd = open(argv[1], O_RDONLY); + disk = argv[1]; + if (argv[1][0] == '-' && argv[1][1] == 's') + { + op = 1; + disk = argv[2]; + } + + g_disk_fd = open(disk, O_RDONLY); if (g_disk_fd < 0) { - printf("Failed to open %s\n", argv[1]); + printf("Failed to open %s\n", disk); return 1; } @@ -115,7 +140,14 @@ int main(int argc, char **argv) if (0 == fl_attach_media(vtoy_disk_read, NULL)) { - rc = get_ventoy_version(); + if (op == 0) + { + rc = get_ventoy_version(); + } + else + { + rc = check_secure_boot(); + } } fl_shutdown();