1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 02:58:02 -06:00

Linux: try use IOCTL BLKGETSIZE64 to get size of device instead of lseek

This commit is contained in:
Mounir IDRASSI
2023-08-19 20:47:43 +02:00
parent 9d8afdad93
commit 34ef189a92

View File

@@ -221,6 +221,17 @@ namespace VeraCrypt
return mediaSize; return mediaSize;
# endif # endif
} }
#endif
#ifdef TC_LINUX
// On Linux, try to use BLKGETSIZE64 for devices
if (Path.IsDevice())
{
uint64 mediaSize;
if (ioctl (FileHandle, BLKGETSIZE64, &mediaSize) != -1)
{
return mediaSize;
}
}
#endif #endif
off_t current = lseek (FileHandle, 0, SEEK_CUR); off_t current = lseek (FileHandle, 0, SEEK_CUR);
throw_sys_sub_if (current == -1, wstring (Path)); throw_sys_sub_if (current == -1, wstring (Path));