VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2023-08-19 20:47:43 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2023-08-19 20:47:43 +0200
commit34ef189a92e353392ae5f41718b0ae2ff8fbf5a1 (patch)
treefb69444f8f89d0ded097d19e0da5185fbd47aa61 /src/Platform
parent9d8afdad9342c3e06e796c6b02eadb7f12cb6611 (diff)
downloadVeraCrypt-34ef189a92e353392ae5f41718b0ae2ff8fbf5a1.tar.gz
VeraCrypt-34ef189a92e353392ae5f41718b0ae2ff8fbf5a1.zip
Linux: try use IOCTL BLKGETSIZE64 to get size of device instead of lseek
Diffstat (limited to 'src/Platform')
-rw-r--r--src/Platform/Unix/File.cpp11
1 files changed, 11 insertions, 0 deletions
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
@@ -222,6 +222,17 @@ namespace VeraCrypt
# 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));
SeekEnd (0);