mirror of
https://github.com/PhoenixPE/vtoydump.git
synced 2026-08-13 13:04:33 -07:00
fix bug
This commit is contained in:
@@ -265,6 +265,11 @@ static int vtoy_find_disk_by_size(unsigned long long size, char *diskname, int b
|
||||
int rc = 0;
|
||||
|
||||
dir = opendir("/sys/block");
|
||||
if (!dir)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ((p = readdir(dir)) != NULL)
|
||||
{
|
||||
if (!vtoy_is_possible_blkdev(p->d_name))
|
||||
@@ -294,6 +299,11 @@ static int vtoy_find_disk_by_guid(uint8_t *guid, char *diskname, int buflen)
|
||||
uint8_t vtguid[16];
|
||||
|
||||
dir = opendir("/sys/block");
|
||||
if (!dir)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ((p = readdir(dir)) != NULL)
|
||||
{
|
||||
if (!vtoy_is_possible_blkdev(p->d_name))
|
||||
@@ -324,6 +334,11 @@ int vtoy_find_disk(ventoy_os_param *param, char *diskname, int buflen)
|
||||
{
|
||||
cnt = vtoy_find_disk_by_guid(param->vtoy_disk_guid, diskname, buflen);
|
||||
}
|
||||
else if (cnt == 0)
|
||||
{
|
||||
cnt = vtoy_find_disk_by_guid(param->vtoy_disk_guid, diskname, buflen);
|
||||
debug("find 0 disk by size, try with guid cnt=%d...\n", cnt);
|
||||
}
|
||||
|
||||
if (cnt > 1)
|
||||
{
|
||||
|
||||
@@ -336,6 +336,7 @@ int vtoy_find_disk(ventoy_os_param *param, char *diskname, int buflen)
|
||||
CHAR *Pos = NULL;
|
||||
CHAR *StringBuf = NULL;
|
||||
UINT8 UUID[16];
|
||||
CHAR FilePath[512];
|
||||
|
||||
vtoy_dump_uuid("Find disk for UUID: ", param->vtoy_disk_guid);
|
||||
debug("\n");
|
||||
@@ -367,6 +368,18 @@ int vtoy_find_disk(ventoy_os_param *param, char *diskname, int buflen)
|
||||
debug("OK\n");
|
||||
|
||||
sprintf_s(diskname, buflen, "%s", Pos);
|
||||
|
||||
sprintf_s(FilePath, sizeof(FilePath), "%s%s", diskname, param->vtoy_img_path + 1);
|
||||
if (!vtoy_is_file_exist(FilePath))
|
||||
{
|
||||
debug("File %s not exist ...\n", FilePath);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("File %s exist ...\n", FilePath);
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user