From 34ef189a92e353392ae5f41718b0ae2ff8fbf5a1 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sat, 19 Aug 2023 20:47:43 +0200 Subject: Linux: try use IOCTL BLKGETSIZE64 to get size of device instead of lseek --- src/Platform/Unix/File.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Platform/Unix/File.cpp b/src/Platform/Unix/File.cpp index d3413800..207efb4e 100644 --- a/src/Platform/Unix/File.cpp +++ b/src/Platform/Unix/File.cpp @@ -221,6 +221,17 @@ namespace VeraCrypt return mediaSize; # 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 off_t current = lseek (FileHandle, 0, SEEK_CUR); throw_sys_sub_if (current == -1, wstring (Path)); -- cgit v1.2.3