return 1;
}
+int ventoy_is_disk_4k_native(const char *disk)
+{
+ int fd;
+ int rc = 0;
+ int logsector = 0;
+ int physector = 0;
+ char diskpath[256] = {0};
+
+ snprintf(diskpath, sizeof(diskpath) - 1, "/dev/%s", disk);
+
+ fd = open(diskpath, O_RDONLY | O_BINARY);
+ if (fd >= 0)
+ {
+ ioctl(fd, BLKSSZGET, &logsector);
+ ioctl(fd, BLKPBSZGET, &physector);
+
+ if (logsector == 4096 && physector == 4096)
+ {
+ rc = 1;
+ }
+ close(fd);
+ }
+
+ vdebug("is 4k native disk <%s> <%d>\n", disk, rc);
+ return rc;
+}
+
uint64_t ventoy_get_disk_size_in_byte(const char *disk)
{
int fd;
vdebug("ventoy partition layout check OK: [%llu %llu] [%llu %llu]\n",
part1_start_sector, part1_sector_count, part2_start_sector, part2_sector_count);
+ vtoy->ventoy_valid = 1;
+
vdebug("now check secure boot for %s ...\n", info->disk_path);
g_fatlib_media_fd = fd;
if (ret == 0 && vtoy->ventoy_ver[0])
{
vtoy->secure_boot_flag = fatlib_is_secure_boot_enable();
- vtoy->ventoy_valid = 1;
}
else
{
g_fatlib_media_fd = -1;
g_fatlib_media_offset = 0;
+ if (vtoy->ventoy_ver[0] == 0)
+ {
+ vtoy->ventoy_ver[0] = '?';
+ }
+
if (0 == vtoy->ventoy_valid)
{
goto end;
scnprintf(info->part2_path, "/dev/%s2", name);
}
+ info->is4kn = ventoy_is_disk_4k_native(name);
info->size_in_byte = ventoy_get_disk_size_in_byte(name);
ventoy_get_disk_devnum(name, &info->major, &info->minor);