From fe11b298f6a7ca17be198343971a995d067791aa Mon Sep 17 00:00:00 2001 From: robertmh Date: Fri, 28 Mar 2008 13:22:28 +0000 Subject: [PATCH] 2008-03-28 Robert Millan Surpass 1 TiB disk addressing limit. Note: there are no plans to handle the 2 TiB disk limit in GRUB Legacy, since that would need considerable rework. If you have >2TiB disks, use GRUB 2 instead. * grub/asmstub.c (biosdisk): Add unsigned qualifier to `sector'. * stage2/bios.c (biosdisk): Likewise. * stage2/disk_io.c (rawread, devread, rawwrite, devwrite): Likewise. * stage2/shared.h (rawread, devread, rawwrite, devwrite): Likewise. * lib/device.c (get_drive_geometry): Replace BLKGETSIZE with BLKGETSIZE64. --- ChangeLog | 13 +++++++++++++ grub/asmstub.c | 2 +- lib/device.c | 12 ++++++------ stage2/bios.c | 2 +- stage2/disk_io.c | 10 +++++----- stage2/shared.h | 10 +++++----- 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index f1fb42120..816315a20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2008-03-28 Robert Millan + + Surpass 1 TiB disk addressing limit. Note: there are no plans to handle + the 2 TiB disk limit in GRUB Legacy, since that would need considerable + rework. If you have >2TiB disks, use GRUB 2 instead. + + * grub/asmstub.c (biosdisk): Add unsigned qualifier to `sector'. + * stage2/bios.c (biosdisk): Likewise. + * stage2/disk_io.c (rawread, devread, rawwrite, devwrite): Likewise. + * stage2/shared.h (rawread, devread, rawwrite, devwrite): Likewise. + * lib/device.c (get_drive_geometry): Replace BLKGETSIZE with + BLKGETSIZE64. + 2007-10-29 Pavel Roskin * configure.ac: Test if '--build-id=none' is supported by the diff --git a/grub/asmstub.c b/grub/asmstub.c index bcb4fae92..88d704e5e 100644 --- a/grub/asmstub.c +++ b/grub/asmstub.c @@ -962,7 +962,7 @@ hex_dump (void *buf, size_t size) int biosdisk (int subfunc, int drive, struct geometry *geometry, - int sector, int nsec, int segment) + unsigned int sector, int nsec, int segment) { char *buf; int fd = geometry->flags; diff --git a/lib/device.c b/lib/device.c index 8abd2a907..d04b54ef7 100644 --- a/lib/device.c +++ b/lib/device.c @@ -69,9 +69,9 @@ struct hd_geometry # ifndef CDROM_GET_CAPABILITY # define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */ # endif /* ! CDROM_GET_CAPABILITY */ -# ifndef BLKGETSIZE -# define BLKGETSIZE _IO(0x12,96) /* return device size */ -# endif /* ! BLKGETSIZE */ +# ifndef BLKGETSIZE64 +# define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size */ +# endif /* ! BLKGETSIZE64 */ #endif /* __linux__ */ /* Use __FreeBSD_kernel__ instead of __FreeBSD__ for compatibility with @@ -152,19 +152,19 @@ get_drive_geometry (struct geometry *geom, char **map, int drive) /* Linux */ { struct hd_geometry hdg; - unsigned long nr; + unsigned long long nr; if (ioctl (fd, HDIO_GETGEO, &hdg)) goto fail; - if (ioctl (fd, BLKGETSIZE, &nr)) + if (ioctl (fd, BLKGETSIZE64, &nr)) goto fail; /* Got the geometry, so save it. */ geom->cylinders = hdg.cylinders; geom->heads = hdg.heads; geom->sectors = hdg.sectors; - geom->total_sectors = nr; + geom->total_sectors = nr / 512; goto success; } diff --git a/stage2/bios.c b/stage2/bios.c index 2d85e40b9..f3665caf0 100644 --- a/stage2/bios.c +++ b/stage2/bios.c @@ -47,7 +47,7 @@ extern int get_diskinfo_floppy (int drive, return the error number. Otherwise, return 0. */ int biosdisk (int read, int drive, struct geometry *geometry, - int sector, int nsec, int segment) + unsigned int sector, int nsec, int segment) { int err; diff --git a/stage2/disk_io.c b/stage2/disk_io.c index b9bc52643..800e0fbe1 100644 --- a/stage2/disk_io.c +++ b/stage2/disk_io.c @@ -137,7 +137,7 @@ log2 (unsigned long word) } int -rawread (int drive, int sector, int byte_offset, int byte_len, char *buf) +rawread (int drive, unsigned int sector, int byte_offset, int byte_len, char *buf) { int slen, sectors_per_vtrack; int sector_size_bits = log2 (buf_geom.sector_size); @@ -261,7 +261,7 @@ rawread (int drive, int sector, int byte_offset, int byte_len, char *buf) */ if (disk_read_func) { - int sector_num = sector; + unsigned int sector_num = sector; int length = buf_geom.sector_size - byte_offset; if (length > size) length = size; @@ -291,7 +291,7 @@ rawread (int drive, int sector, int byte_offset, int byte_len, char *buf) int -devread (int sector, int byte_offset, int byte_len, char *buf) +devread (unsigned int sector, int byte_offset, int byte_len, char *buf) { /* * Check partition boundaries @@ -330,7 +330,7 @@ devread (int sector, int byte_offset, int byte_len, char *buf) #ifndef STAGE1_5 int -rawwrite (int drive, int sector, char *buf) +rawwrite (int drive, unsigned int sector, char *buf) { if (sector == 0) { @@ -363,7 +363,7 @@ rawwrite (int drive, int sector, char *buf) } int -devwrite (int sector, int sector_count, char *buf) +devwrite (unsigned int sector, int sector_count, char *buf) { #if defined(GRUB_UTIL) && defined(__linux__) if (current_partition != 0xFFFFFF diff --git a/stage2/shared.h b/stage2/shared.h index 609549a50..2db6cc662 100644 --- a/stage2/shared.h +++ b/stage2/shared.h @@ -811,7 +811,7 @@ int checkkey (void); /* Low-level disk I/O */ int get_diskinfo (int drive, struct geometry *geometry); int biosdisk (int subfunc, int drive, struct geometry *geometry, - int sector, int nsec, int segment); + unsigned int sector, int nsec, int segment); void stop_floppy (void); /* Command-line interface functions. */ @@ -924,10 +924,10 @@ int gunzip_test_header (void); int gunzip_read (char *buf, int len); #endif /* NO_DECOMPRESSION */ -int rawread (int drive, int sector, int byte_offset, int byte_len, char *buf); -int devread (int sector, int byte_offset, int byte_len, char *buf); -int rawwrite (int drive, int sector, char *buf); -int devwrite (int sector, int sector_len, char *buf); +int rawread (int drive, unsigned int sector, int byte_offset, int byte_len, char *buf); +int devread (unsigned int sector, int byte_offset, int byte_len, char *buf); +int rawwrite (int drive, unsigned int sector, char *buf); +int devwrite (unsigned int sector, int sector_len, char *buf); /* Parse a device string and initialize the global parameters. */ char *set_device (char *device);