From b32cf97f1f097e9db8ff05de5ba7001d360c3093 Mon Sep 17 00:00:00 2001 From: longpanda Date: Sun, 5 Jul 2020 22:12:58 +0800 Subject: [PATCH] update --- IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh | 13 +++++++- INSTALL/grub/grub.cfg | 13 ++++---- Ventoy2Disk/Ventoy2Disk/Utility.c | 9 ++++++ Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c | 30 +++++++++---------- 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh b/IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh index 6dd6882b..d2afcc82 100644 --- a/IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh +++ b/IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh @@ -99,7 +99,18 @@ ventoy_udev_disk_common_hook $* # So if ventoy is installed on a non-USB device, we just mount /cdrom here except # for these has boot=live or boot=casper parameter in cmdline # -if echo $ID_BUS | $GREP -q -i usb; then +VT_BUS_USB="" +if [ -n "$ID_BUS" ]; then + if echo $ID_BUS | $GREP -q -i usb; then + VT_BUS_USB="YES" + fi +else + if $BUSYBOX_PATH/ls -l /sys/class/block/${1:0:-1} | $GREP -q -i usb; then + VT_BUS_USB="YES" + fi +fi + +if [ -n "$VT_BUS_USB" ]; then vtlog "$1 is USB device" else vtlog "$1 is NOT USB device (bus $ID_BUS)" diff --git a/INSTALL/grub/grub.cfg b/INSTALL/grub/grub.cfg index 144b78e1..52e8a6b7 100644 --- a/INSTALL/grub/grub.cfg +++ b/INSTALL/grub/grub.cfg @@ -650,15 +650,14 @@ else set gfxmode=1920x1080,1366x768,1024x768 fi -if [ -n "$vtoy_theme" ]; then - set theme=$vtoy_theme -else - set theme=$prefix/themes/ventoy/theme.txt -fi - if [ "$vtoy_display_mode" = "CLI" ]; then terminal_output console -else +else + if [ -n "$vtoy_theme" ]; then + set theme=$vtoy_theme + else + set theme=$prefix/themes/ventoy/theme.txt + fi terminal_output gfxterm fi diff --git a/Ventoy2Disk/Ventoy2Disk/Utility.c b/Ventoy2Disk/Ventoy2Disk/Utility.c index dc8491db..586d2368 100644 --- a/Ventoy2Disk/Ventoy2Disk/Utility.c +++ b/Ventoy2Disk/Ventoy2Disk/Utility.c @@ -549,6 +549,7 @@ int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo) VTOY_GPT_PART_TBL *Table = pInfo->PartTbl; static GUID WindowsDataPartType = { 0xebd0a0a2, 0xb9e5, 0x4433, { 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 } }; static GUID EspPartType = { 0xc12a7328, 0xf81f, 0x11d2, { 0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b } }; + //static GUID BiosGrubPartType = { 0x21686148, 0x6449, 0x6e6f, { 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } }; VentoyFillProtectMBR(DiskSizeBytes, &pInfo->MBR); @@ -588,6 +589,14 @@ int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo) Table[1].Attr = 1; memcpy(Table[1].Name, L"VTOYEFI", 7 * 2); +#if 0 + memcpy(&(Table[2].PartType), &BiosGrubPartType, sizeof(GUID)); + CoCreateGuid(&(Table[2].PartGuid)); + Table[2].StartLBA = 34; + Table[2].LastLBA = 2047; + Table[2].Attr = 0; +#endif + //Update CRC Head->PartTblCrc = VentoyCrc32(Table, sizeof(pInfo->PartTbl)); Head->Crc = VentoyCrc32(Head, Head->Length); diff --git a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c index e6cb741c..2dc33f18 100644 --- a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c +++ b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c @@ -107,6 +107,21 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN return FALSE; } + for (i = 0; i < 4; i++) + { + Log("=========== Partition Table %d ============", i + 1); + Log("PartTbl.Active = 0x%x", MBR.PartTbl[i].Active); + Log("PartTbl.FsFlag = 0x%x", MBR.PartTbl[i].FsFlag); + Log("PartTbl.StartSectorId = %u", MBR.PartTbl[i].StartSectorId); + Log("PartTbl.SectorCount = %u", MBR.PartTbl[i].SectorCount); + Log("PartTbl.StartHead = %u", MBR.PartTbl[i].StartHead); + Log("PartTbl.StartSector = %u", MBR.PartTbl[i].StartSector); + Log("PartTbl.StartCylinder = %u", MBR.PartTbl[i].StartCylinder); + Log("PartTbl.EndHead = %u", MBR.PartTbl[i].EndHead); + Log("PartTbl.EndSector = %u", MBR.PartTbl[i].EndSector); + Log("PartTbl.EndCylinder = %u", MBR.PartTbl[i].EndCylinder); + } + if (MBR.PartTbl[0].FsFlag == 0xEE) { pGpt = malloc(sizeof(VTOY_GPT_INFO)); @@ -143,21 +158,6 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN { CHECK_CLOSE_HANDLE(hDrive); - for (i = 0; i < 4; i++) - { - Log("=========== Partition Table %d ============", i + 1); - Log("PartTbl.Active = 0x%x", MBR.PartTbl[i].Active); - Log("PartTbl.FsFlag = 0x%x", MBR.PartTbl[i].FsFlag); - Log("PartTbl.StartSectorId = %u", MBR.PartTbl[i].StartSectorId); - Log("PartTbl.SectorCount = %u", MBR.PartTbl[i].SectorCount); - Log("PartTbl.StartHead = %u", MBR.PartTbl[i].StartHead); - Log("PartTbl.StartSector = %u", MBR.PartTbl[i].StartSector); - Log("PartTbl.StartCylinder = %u", MBR.PartTbl[i].StartCylinder); - Log("PartTbl.EndHead = %u", MBR.PartTbl[i].EndHead); - Log("PartTbl.EndSector = %u", MBR.PartTbl[i].EndSector); - Log("PartTbl.EndCylinder = %u", MBR.PartTbl[i].EndCylinder); - } - if (MBR.PartTbl[0].StartSectorId != 2048) { Log("Part1 not match %u", MBR.PartTbl[0].StartSectorId);