From fb7c02c21519887344c197d64344b5d8e127a9fa Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 25 Aug 2009 20:31:21 +0000 Subject: [PATCH] Under Linux use BLKGETSIZE64 to get the device size, now, and only when that fails fall back to HDIO_GETGEO. This hopefully fixes #3122, as I suspect HDIO_GETGEO returned an incorrect size. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32674 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../platform/bios_ia32/makebootable.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bin/makebootable/platform/bios_ia32/makebootable.cpp b/src/bin/makebootable/platform/bios_ia32/makebootable.cpp index 1ee2aafa09..919e42fc91 100644 --- a/src/bin/makebootable/platform/bios_ia32/makebootable.cpp +++ b/src/bin/makebootable/platform/bios_ia32/makebootable.cpp @@ -23,6 +23,7 @@ // Linux and FreeBSD support #ifdef HAIKU_HOST_PLATFORM_LINUX # include +# include # include # include @@ -489,16 +490,22 @@ main(int argc, const char *const *argv) exit(1); } - // get device geometry + // get device size -- try BLKGETSIZE64, but, if it doesn't + // work, fall back to the obsolete HDIO_GETGEO + int64 deviceSize; hd_geometry geometry; - if (ioctl(baseFD, HDIO_GETGEO, &geometry) < 0) { + if (ioctl(baseFD, BLKGETSIZE64, &deviceSize) == 0 + && deviceSize > 0) { + // looks good + } else if (ioctl(baseFD, HDIO_GETGEO, &geometry) == 0) { + deviceSize = (int64)geometry.heads * geometry.sectors + * geometry.cylinders * 512; + } else { fprintf(stderr, "Error: Failed to get device geometry " "for \"%s\": %s\n", baseDeviceName, strerror(errno)); exit(1); } - int64 deviceSize = (int64)geometry.heads * geometry.sectors - * geometry.cylinders * 512; // parse the partition map // TODO: block size!