mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-08-25 23:21:16 +00:00
1.0.36 release
This commit is contained in:
@@ -330,6 +330,7 @@ static int fatlib_is_secure_boot_enable(void)
|
||||
flfile = fl_fopen("/EFI/BOOT/grubx64_real.efi", "rb");
|
||||
if (flfile)
|
||||
{
|
||||
vlog("/EFI/BOOT/grubx64_real.efi find, secure boot in enabled\n");
|
||||
fl_fclose(flfile);
|
||||
return 1;
|
||||
}
|
||||
@@ -504,7 +505,10 @@ int ventoy_get_vtoy_data(ventoy_disk *info, int *ppartstyle)
|
||||
goto end;
|
||||
}
|
||||
|
||||
vdebug("now check secure boot ...\n");
|
||||
vdebug("ventoy partition layout check OK: [%llu %llu] [%llu %llu]\n",
|
||||
part1_start_sector, part1_sector_count, part2_start_sector, part2_sector_count);
|
||||
|
||||
vdebug("now check secure boot for %s ...\n", info->disk_path);
|
||||
|
||||
g_fatlib_media_fd = fd;
|
||||
g_fatlib_media_offset = part2_start_sector;
|
||||
@@ -546,7 +550,7 @@ int ventoy_get_vtoy_data(ventoy_disk *info, int *ppartstyle)
|
||||
|
||||
rc = 0;
|
||||
end:
|
||||
close(fd);
|
||||
vtoy_safe_close_fd(fd);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@@ -80,6 +80,34 @@ void ventoy_syslog_newline(int level, const char *Fmt, ...)
|
||||
pthread_mutex_unlock(&g_log_mutex);
|
||||
}
|
||||
|
||||
void ventoy_syslog_printf(const char *Fmt, ...)
|
||||
{
|
||||
char log[512];
|
||||
va_list arg;
|
||||
time_t stamp;
|
||||
struct tm ttm;
|
||||
FILE *fp;
|
||||
|
||||
time(&stamp);
|
||||
localtime_r(&stamp, &ttm);
|
||||
|
||||
va_start(arg, Fmt);
|
||||
vsnprintf(log, 512, Fmt, arg);
|
||||
va_end(arg);
|
||||
|
||||
pthread_mutex_lock(&g_log_mutex);
|
||||
fp = fopen(VTOY_LOG_FILE, "a+");
|
||||
if (fp)
|
||||
{
|
||||
fprintf(fp, "[%04u/%02u/%02u %02u:%02u:%02u] %s",
|
||||
ttm.tm_year, ttm.tm_mon, ttm.tm_mday,
|
||||
ttm.tm_hour, ttm.tm_min, ttm.tm_sec,
|
||||
log);
|
||||
fclose(fp);
|
||||
}
|
||||
pthread_mutex_unlock(&g_log_mutex);
|
||||
}
|
||||
|
||||
void ventoy_syslog(int level, const char *Fmt, ...)
|
||||
{
|
||||
char log[512];
|
||||
|
@@ -347,6 +347,7 @@ static int ventoy_fill_gpt_partname(uint16_t Name[36], const char *asciiName)
|
||||
int ventoy_fill_gpt(uint64_t size, uint64_t reserve, int align4k, VTOY_GPT_INFO *gpt)
|
||||
{
|
||||
uint64_t ReservedSector = 33;
|
||||
uint64_t ModSectorCount = 0;
|
||||
uint64_t Part1SectorCount = 0;
|
||||
uint64_t DiskSectorCount = size / 512;
|
||||
VTOY_GPT_HDR *Head = &gpt->Head;
|
||||
@@ -362,18 +363,28 @@ int ventoy_fill_gpt(uint64_t size, uint64_t reserve, int align4k, VTOY_GPT_INFO
|
||||
ReservedSector += reserve / 512;
|
||||
}
|
||||
|
||||
Part1SectorCount = DiskSectorCount - ReservedSector - (VTOYEFI_PART_BYTES / 512) - 2048;
|
||||
|
||||
ModSectorCount = (Part1SectorCount % 8);
|
||||
if (ModSectorCount)
|
||||
{
|
||||
vlog("Part1SectorCount:%llu is not aligned by 4KB (%llu)\n", (_ull)Part1SectorCount, (_ull)ModSectorCount);
|
||||
}
|
||||
|
||||
// check aligned with 4KB
|
||||
if (align4k)
|
||||
{
|
||||
if (DiskSectorCount % 8)
|
||||
if (ModSectorCount)
|
||||
{
|
||||
vdebug("Disk need to align with 4KB %u\n", (uint32_t)(DiskSectorCount % 8));
|
||||
ReservedSector += (DiskSectorCount % 8);
|
||||
vdebug("Disk need to align with 4KB %u\n", (uint32_t)ModSectorCount);
|
||||
Part1SectorCount -= ModSectorCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
vdebug("no need to align with 4KB\n");
|
||||
}
|
||||
}
|
||||
|
||||
Part1SectorCount = DiskSectorCount - ReservedSector - (VTOYEFI_PART_BYTES / 512) - 2048;
|
||||
|
||||
memcpy(Head->Signature, "EFI PART", 8);
|
||||
Head->Version[2] = 0x01;
|
||||
Head->Length = 92;
|
||||
@@ -461,7 +472,7 @@ int VentoyFillMBRLocation(uint64_t DiskSizeInBytes, uint32_t StartSectorId, uint
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ventoy_fill_mbr(uint64_t size, uint64_t reserve, int align4k, int PartStyle, MBR_HEAD *pMBR)
|
||||
int ventoy_fill_mbr(uint64_t size, uint64_t reserve, int align4k, MBR_HEAD *pMBR)
|
||||
{
|
||||
ventoy_guid Guid;
|
||||
uint32_t DiskSignature;
|
||||
@@ -498,11 +509,6 @@ int ventoy_fill_mbr(uint64_t size, uint64_t reserve, int align4k, int PartStyle,
|
||||
ReservedSector = (uint32_t)(reserve / 512);
|
||||
}
|
||||
|
||||
if (PartStyle)
|
||||
{
|
||||
ReservedSector += 33; // backup GPT part table
|
||||
}
|
||||
|
||||
// check aligned with 4KB
|
||||
if (align4k)
|
||||
{
|
||||
@@ -512,11 +518,14 @@ int ventoy_fill_mbr(uint64_t size, uint64_t reserve, int align4k, int PartStyle,
|
||||
vlog("Disk need to align with 4KB %u\n", (uint32_t)(sectors % 8));
|
||||
ReservedSector += (uint32_t)(sectors % 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
vdebug("no need to align with 4KB\n");
|
||||
}
|
||||
}
|
||||
|
||||
vlog("ReservedSector: %u\n", ReservedSector);
|
||||
|
||||
|
||||
//Part1
|
||||
PartStartSector = VTOYIMG_PART_START_SECTOR;
|
||||
PartSectorCount = DiskSectorCount - ReservedSector - VTOYEFI_PART_BYTES / 512 - PartStartSector;
|
||||
|
@@ -46,7 +46,7 @@ int unxz(unsigned char *in, int in_size,
|
||||
int ventoy_read_file_to_buf(const char *FileName, int ExtLen, void **Bufer, int *BufLen);
|
||||
const char * ventoy_get_local_version(void);
|
||||
int ventoy_fill_gpt(uint64_t size, uint64_t reserve, int align4k, VTOY_GPT_INFO *gpt);
|
||||
int ventoy_fill_mbr(uint64_t size, uint64_t reserve, int align4k, int PartStyle, MBR_HEAD *pMBR);
|
||||
int ventoy_fill_mbr(uint64_t size, uint64_t reserve, int align4k, MBR_HEAD *pMBR);
|
||||
|
||||
#endif /* __VENTOY_UTIL_H__ */
|
||||
|
||||
|
Reference in New Issue
Block a user