1 |
/* device.c - Some helper functions for OS devices and BIOS drives */ |
/* device.c - Some helper functions for OS devices and BIOS drives */ |
2 |
/* |
/* |
3 |
* GRUB -- GRand Unified Bootloader |
* GRUB -- GRand Unified Bootloader |
4 |
* 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. |
5 |
* |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
248 |
} |
} |
249 |
|
|
250 |
/* Set the total sectors properly, if we can. */ |
/* Set the total sectors properly, if we can. */ |
251 |
if (! fstat (fd, &st) && st.st_blocks) |
if (! fstat (fd, &st) && st.st_size) |
252 |
geom->total_sectors = st.st_blocks; |
geom->total_sectors = st.st_size >> SECTOR_BITS; |
253 |
else |
else |
254 |
geom->total_sectors = geom->cylinders * geom->heads * geom->sectors; |
geom->total_sectors = geom->cylinders * geom->heads * geom->sectors; |
255 |
} |
} |