From 6884fee4be0454772793290232515618335415ac Mon Sep 17 00:00:00 2001 From: okuji Date: Sun, 27 Mar 2005 23:20:09 +0000 Subject: [PATCH] 2005-03-28 Yoshinori K. Okuji * lib/device.c (get_drive_geometry): Use ST.ST_SIZE instead of ST.ST_BLOCKS to get the total number of sectors, because st_blocks is not the same if it is a sparse file. --- ChangeLog | 6 ++++++ lib/device.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d8610312..68699faad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-03-28 Yoshinori K. Okuji + + * lib/device.c (get_drive_geometry): Use ST.ST_SIZE instead of + ST.ST_BLOCKS to get the total number of sectors, because st_blocks + is not the same if it is a sparse file. + 2005-03-19 Yoshinori K. Okuji * stage2/stage2.c (cmain): Initialize DEFAULT_FILE to an empty diff --git a/lib/device.c b/lib/device.c index b05f3a906..d0663b396 100644 --- a/lib/device.c +++ b/lib/device.c @@ -1,7 +1,7 @@ /* device.c - Some helper functions for OS devices and BIOS drives */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -248,8 +248,8 @@ partially. This is not fatal." } /* Set the total sectors properly, if we can. */ - if (! fstat (fd, &st) && st.st_blocks) - geom->total_sectors = st.st_blocks; + if (! fstat (fd, &st) && st.st_size) + geom->total_sectors = st.st_size >> SECTOR_BITS; else geom->total_sectors = geom->cylinders * geom->heads * geom->sectors; }