[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] 64 bit disk address support (= 8192EiB disks)
From: |
Timothy Baldwin |
Subject: |
[patch] 64 bit disk address support (= 8192EiB disks) |
Date: |
Fri, 21 Oct 2005 14:17:40 +0100 |
User-agent: |
KMail/1.8.2 |
Only 16EiB on RISC OS, openfirmware and grub-emu.
The Linux block device code in util/biosdisk.c still needs fixing or removing.
I am working on a rewrite of the i386 boot sector code which supports 64bit
disk addresses and understands partition tables (PC and GPT) and some
filesystems (maybe only FAT).
RISC OS changes are at:
http://www.majoroak.f2s.com/tim/grub/patches/grub2-patch15.diff.gz
Other changes below and at:
http://www.majoroak.f2s.com/tim/grub/patches/grub2-patch14.diff.gz
2005-10-20 Timothy Baldwin <address@hidden>
Use 64bit disk addresses.
* disk/i386/pc/biosdisk.c: Include limits.h.
(grub_biosdisk_rw): Use grub_lba_t for sector parameter.
Truncate sector to 32 bits for CHS calculation.
(grub_biosdisk_read): Use grub_lba_t for sector parameter.
Avoid 64 bit division calculating len to 100 if
sector >= 0x100000000.
(grub_biosdisk_write): Likewise.
* disk/ieee1275/ofdisk.c (grub_ofdisk_read): Use
grub_lba_t for disk addresses.
(grub_ofdisk_write): Likewise.
* disk/loopback.c (grub_loopback_read): Likewise.
(grub_loopback_write): Likewise.
* include/grub/partition.h (struct grub_partition): Likewise.
(grub_partition_get_start): Likewise.
(grub_partition_get_len): Likewise.
* include/grub/disk.h (struct grub_disk_dev): Likewise.
(struct grub_disk): Likewise.
(grub_disk_read): Likewise.
(grub_disk_write): Likewise.
* include/grub/file.h (struct grub_file): Likewise.
* kern/disk.c (struct grub_disk_cache): Likewise.
(grub_disk_cache_invalidate): Likewise.
(grub_disk_cache_fetch): Likewise.
(grub_disk_cache_unlock): Likewise.
(grub_disk_cache_store): Likewise.
(grub_disk_check_range): Likewise.
(grub_disk_read): Likewise.
(grub_disk_write): Likewise.
* util/i386/pc/biosdisk.c (open_device): Likewise.
(grub_util_biosdisk_read): Likewise.
(grub_util_biosdisk_write): Likewise.
* util/i386/pc/grub-setup.c (save_first_sector): Use
grub_lba_t for sector parameter. Error if disk address
above or equal to 0x100000000.
(save_blocklists): Likewise, and cast disk addresses
to unsigned for display.
* fs/affs.c (grub_affs_read_file): Use grub_lba_t
for disk address parameter of hook function.
* fs/ext2.c (grub_ext2_read_file): Likewise.
* fs/fat.c (grub_fat_read_file): Likewise.
* fs/fshelp.c (grub_fshelp_read_file): Likewise.
* fs/hfs.c (grub_hfs_read_file): Likewise.
* fs/jfs.c (grub_jfs_read_file): Likewise.
* fs/minux.c (grub_minux_read_file): Likewise.
* fs/sfs.c (grub_sfs_read_file): Likewise.
* fs/ufs.c (grub_ufs_read_file): Likewise.
* fs/xfs.c (grub_xfs_read_file): Likewise.
* include/grub/fshelp.h (grub_fshelp_read_file): Likewise.
* partmap/amiga.c (amiga_partition_map_iterate): Use 64 bit
arithmetic to calculate disk addresses.
* partmap/sun.c (sun_partition_map_iterate): Likewise.
* partmap/acorn.c (acorn_partition_map_iterate): Likewise.
(acorn_partition_map_probe): Likewise.
* partmap/pc.c (pc_partition_map_iterate): Cast disk addresses
to unsigned for display.
* include/grub/types.h (grub_lba_t): New typedef.
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/disk/i386/pc/biosdisk.c
grub2-arm/disk/i386/pc/biosdisk.c
--- grub2-submitted/disk/i386/pc/biosdisk.c 2005-03-02 19:20:35.000000000
+0000
+++ grub2-arm/disk/i386/pc/biosdisk.c 2005-10-20 22:21:20.000000000 +0100
@@ -25,6 +25,7 @@
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/term.h>
+#include <limits.h>
/* Drive Parameters. */
struct grub_biosdisk_drp
@@ -162,9 +163,8 @@ grub_biosdisk_open (const char *name, gr
{
data->flags = GRUB_BIOSDISK_FLAG_LBA;
- /* FIXME: 2TB limit. */
if (drp->total_sectors)
- total_sectors = drp->total_sectors & ~0L;
+ total_sectors = drp->total_sectors;
else
/* Some buggy BIOSes doesn't return the total sectors
correctly but returns zero. So if it is zero, compute
@@ -204,7 +204,7 @@ grub_biosdisk_close (grub_disk_t disk)
static grub_err_t
grub_biosdisk_rw (int cmd, grub_disk_t disk,
- unsigned long sector, unsigned long size,
+ grub_lba_t sector, unsigned long size,
unsigned segment)
{
struct grub_biosdisk_data *data = disk->data;
@@ -234,13 +234,14 @@ grub_biosdisk_rw (int cmd, grub_disk_t d
{
unsigned coff, hoff, soff;
unsigned head;
+ unsigned sector32 = sector;
- soff = sector % data->sectors + 1;
- head = sector / data->sectors;
+ soff = sector32 % data->sectors + 1;
+ head = sector32 / data->sectors;
hoff = head % data->heads;
coff = head / data->heads;
- if (coff >= data->cylinders)
+ if (sector > UINT_MAX || coff >= data->cylinders)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk");
if (grub_biosdisk_rw_standard (cmd + 0x02, data->drive,
@@ -260,7 +261,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t d
}
static grub_err_t
-grub_biosdisk_read (grub_disk_t disk, unsigned long sector,
+grub_biosdisk_read (grub_disk_t disk, grub_lba_t sector,
unsigned long size, char *buf)
{
struct grub_biosdisk_data *data = disk->data;
@@ -269,7 +270,11 @@ grub_biosdisk_read (grub_disk_t disk, un
{
unsigned long len;
- len = data->sectors - (sector % data->sectors);
+ if (sector > UINT_MAX)
+ len = 100;
+ else
+ len = data->sectors - ((grub_uint32_t)sector % data->sectors);
+
if (len > size)
len = size;
@@ -288,7 +293,7 @@ grub_biosdisk_read (grub_disk_t disk, un
}
static grub_err_t
-grub_biosdisk_write (grub_disk_t disk, unsigned long sector,
+grub_biosdisk_write (grub_disk_t disk, grub_lba_t sector,
unsigned long size, const char *buf)
{
struct grub_biosdisk_data *data = disk->data;
@@ -297,7 +302,11 @@ grub_biosdisk_write (grub_disk_t disk, u
{
unsigned long len;
- len = data->sectors - (sector % data->sectors);
+ if (sector > UINT_MAX)
+ len = 100;
+ else
+ len = data->sectors - ((grub_uint32_t)sector % data->sectors);
+
if (len > size)
len = size;
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/disk/ieee1275/ofdisk.c
grub2-arm/disk/ieee1275/ofdisk.c
--- grub2-submitted/disk/ieee1275/ofdisk.c 2005-08-22 17:58:16.000000000
+0100
+++ grub2-arm/disk/ieee1275/ofdisk.c 2005-10-20 22:21:20.000000000 +0100
@@ -122,7 +122,7 @@ grub_ofdisk_close (grub_disk_t disk)
}
static grub_err_t
-grub_ofdisk_read (grub_disk_t disk, unsigned long sector,
+grub_ofdisk_read (grub_disk_t disk, grub_lba_t sector,
unsigned long size, char *buf)
{
grub_ssize_t status, actual;
@@ -149,7 +149,7 @@ grub_ofdisk_read (grub_disk_t disk, unsi
static grub_err_t
grub_ofdisk_write (grub_disk_t disk __attribute ((unused)),
- unsigned long sector __attribute ((unused)),
+ grub_lba_t sector __attribute ((unused)),
unsigned long size __attribute ((unused)),
const char *buf __attribute ((unused)))
{
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/disk/loopback.c grub2-arm/disk/loopback.c
--- grub2-submitted/disk/loopback.c 2005-07-17 21:12:03.000000000 +0100
+++ grub2-arm/disk/loopback.c 2005-10-20 22:21:20.000000000 +0100
@@ -193,7 +193,7 @@ grub_loopback_close (grub_disk_t disk)
}
static grub_err_t
-grub_loopback_read (grub_disk_t disk, unsigned long sector,
+grub_loopback_read (grub_disk_t disk, grub_lba_t sector,
unsigned long size, char *buf)
{
grub_file_t file = (grub_file_t) disk->data;
@@ -220,7 +220,7 @@ grub_loopback_read (grub_disk_t disk, un
static grub_err_t
grub_loopback_write (grub_disk_t disk __attribute ((unused)),
- unsigned long sector __attribute ((unused)),
+ grub_lba_t sector __attribute ((unused)),
unsigned long size __attribute ((unused)),
const char *buf __attribute ((unused)))
{
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/fs/affs.c grub2-arm/fs/affs.c
--- grub2-submitted/fs/affs.c 2005-10-07 20:25:46.000000000 +0100
+++ grub2-arm/fs/affs.c 2005-10-20 22:21:20.000000000 +0100
@@ -150,7 +150,7 @@ grub_affs_read_block (grub_fshelp_node_t
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
grub_affs_read_file (grub_fshelp_node_t node,
- void (*read_hook) (unsigned long sector,
+ void (*read_hook) (grub_lba_t sector,
unsigned offset, unsigned length),
int pos, unsigned int len, char *buf)
{
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/fs/ext2.c grub2-arm/fs/ext2.c
--- grub2-submitted/fs/ext2.c 2005-07-20 19:38:10.000000000 +0100
+++ grub2-arm/fs/ext2.c 2005-10-20 22:21:20.000000000 +0100
@@ -252,7 +252,7 @@ grub_ext2_read_block (grub_fshelp_node_t
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
grub_ext2_read_file (grub_fshelp_node_t node,
- void (*read_hook) (unsigned long sector,
+ void (*read_hook) (grub_lba_t sector,
unsigned offset, unsigned length),
int pos, unsigned int len, char *buf)
{
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/fs/fat.c grub2-arm/fs/fat.c
--- grub2-submitted/fs/fat.c 2005-07-31 17:07:28.000000000 +0100
+++ grub2-arm/fs/fat.c 2005-10-20 22:21:20.000000000 +0100
@@ -310,7 +310,7 @@ grub_fat_mount (grub_disk_t disk)
static grub_ssize_t
grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
- void (*read_hook) (unsigned long sector,
+ void (*read_hook) (grub_lba_t sector,
unsigned offset, unsigned length),
grub_ssize_t offset, grub_ssize_t len, char *buf)
{
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/fs/fshelp.c grub2-arm/fs/fshelp.c
--- grub2-submitted/fs/fshelp.c 2005-01-20 17:25:39.000000000 +0000
+++ grub2-arm/fs/fshelp.c 2005-10-20 22:21:20.000000000 +0100
@@ -222,7 +222,7 @@ grub_fshelp_find_file (const char *path,
blocks have a size of LOG2BLOCKSIZE (in log2). */
grub_ssize_t
grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
- void (*read_hook) (unsigned long sector,
+ void (*read_hook) (grub_lba_t sector,
unsigned offset, unsigned length),
int pos, unsigned int len, char *buf,
int (*get_block) (grub_fshelp_node_t node, int block),
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/fs/hfs.c grub2-arm/fs/hfs.c
--- grub2-submitted/fs/hfs.c 2004-11-01 16:14:16.000000000 +0000
+++ grub2-arm/fs/hfs.c 2005-10-20 22:21:20.000000000 +0100
@@ -256,7 +256,7 @@ grub_hfs_block (struct grub_hfs_data *da
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
grub_hfs_read_file (struct grub_hfs_data *data,
- void (*read_hook) (unsigned long sector,
+ void (*read_hook) (grub_lba_t sector,
unsigned offset, unsigned length),
int pos, unsigned int len, char *buf)
{
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/fs/jfs.c grub2-arm/fs/jfs.c
--- grub2-submitted/fs/jfs.c 2004-11-01 16:14:16.000000000 +0000
+++ grub2-arm/fs/jfs.c 2005-10-20 22:21:20.000000000 +0100
@@ -540,7 +540,7 @@ grub_jfs_getent (struct grub_jfs_diropen
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
grub_jfs_read_file (struct grub_jfs_data *data,
- void (*read_hook) (unsigned long sector,
+ void (*read_hook) (grub_lba_t sector,
unsigned offset, unsigned length),
int pos, unsigned int len, char *buf)
{
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/fs/minix.c grub2-arm/fs/minix.c
--- grub2-submitted/fs/minix.c 2005-01-21 22:34:18.000000000 +0000
+++ grub2-arm/fs/minix.c 2005-10-20 22:21:20.000000000 +0100
@@ -187,7 +187,7 @@ grub_minix_get_file_block (struct grub_m
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
grub_minix_read_file (struct grub_minix_data *data,
- void (*read_hook) (unsigned long sector,
+ void (*read_hook) (grub_lba_t sector,
unsigned offset, unsigned length),
int pos, unsigned int len, char *buf)
{
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/fs/sfs.c grub2-arm/fs/sfs.c
--- grub2-submitted/fs/sfs.c 2005-10-11 17:42:32.000000000 +0100
+++ grub2-arm/fs/sfs.c 2005-10-20 22:21:20.000000000 +0100
@@ -259,7 +259,7 @@ grub_sfs_read_block (grub_fshelp_node_t
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
grub_sfs_read_file (grub_fshelp_node_t node,
- void (*read_hook) (unsigned long sector,
+ void (*read_hook) (grub_lba_t sector,
unsigned offset, unsigned length),
int pos, unsigned int len, char *buf)
{
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/fs/ufs.c grub2-arm/fs/ufs.c
--- grub2-submitted/fs/ufs.c 2004-11-01 16:14:16.000000000 +0000
+++ grub2-arm/fs/ufs.c 2005-10-20 22:21:20.000000000 +0100
@@ -241,7 +241,7 @@ grub_ufs_get_file_block (struct grub_ufs
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
grub_ufs_read_file (struct grub_ufs_data *data,
- void (*read_hook) (unsigned long sector,
+ void (*read_hook) (grub_lba_t sector,
unsigned offset, unsigned length),
int pos, unsigned int len, char *buf)
{
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/fs/xfs.c grub2-arm/fs/xfs.c
--- grub2-submitted/fs/xfs.c 2005-10-15 10:20:16.000000000 +0100
+++ grub2-arm/fs/xfs.c 2005-10-20 22:21:20.000000000 +0100
@@ -237,7 +237,7 @@ grub_xfs_read_block (grub_fshelp_node_t
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
grub_xfs_read_file (grub_fshelp_node_t node,
- void (*read_hook) (unsigned long sector,
+ void (*read_hook) (grub_lba_t sector,
unsigned offset, unsigned length),
int pos, unsigned int len, char *buf)
{
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/include/grub/disk.h
grub2-arm/include/grub/disk.h
--- grub2-submitted/include/grub/disk.h 2005-10-20 14:45:22.000000000 +0100
+++ grub2-arm/include/grub/disk.h 2005-10-20 22:21:20.000000000 +0100
@@ -57,11 +57,11 @@ struct grub_disk_dev
void (*close) (struct grub_disk *disk);
/* Read SIZE sectors from the sector SECTOR of the disk DISK into BUF. */
- grub_err_t (*read) (struct grub_disk *disk, unsigned long sector,
+ grub_err_t (*read) (struct grub_disk *disk, grub_lba_t sector,
unsigned long size, char *buf);
/* Write SIZE sectors from BUF into the sector SECTOR of the disk DISK. */
- grub_err_t (*write) (struct grub_disk *disk, unsigned long sector,
+ grub_err_t (*write) (struct grub_disk *disk, grub_lba_t sector,
unsigned long size, const char *buf);
/* The next disk device. */
@@ -81,7 +81,7 @@ struct grub_disk
grub_disk_dev_t dev;
/* The total number of sectors. */
- unsigned long total_sectors;
+ grub_lba_t total_sectors;
/* If partitions can be stored. */
int has_partitions;
@@ -89,11 +89,11 @@ struct grub_disk
/* The id used by the disk cache manager. */
unsigned long id;
- /* The partition information. This is machine-specific. */
+ /* The partition information. This is partition scheme specific. */
struct grub_partition *partition;
/* Called when a sector was read. */
- void (*read_hook) (unsigned long sector, unsigned offset, unsigned length);
+ void (*read_hook) (grub_lba_t sector, unsigned offset, unsigned length);
/* Device-specific data. */
void *data;
@@ -121,12 +121,12 @@ int EXPORT_FUNC(grub_disk_dev_iterate) (
grub_disk_t EXPORT_FUNC(grub_disk_open) (const char *name);
void EXPORT_FUNC(grub_disk_close) (grub_disk_t disk);
grub_err_t EXPORT_FUNC(grub_disk_read) (grub_disk_t disk,
- unsigned long sector,
+ grub_lba_t sector,
unsigned long offset,
unsigned long size,
char *buf);
grub_err_t EXPORT_FUNC(grub_disk_write) (grub_disk_t disk,
- unsigned long sector,
+ grub_lba_t sector,
unsigned long offset,
unsigned long size,
const char *buf);
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/include/grub/file.h
grub2-arm/include/grub/file.h
--- grub2-submitted/include/grub/file.h 2004-04-04 14:46:00.000000000 +0100
+++ grub2-arm/include/grub/file.h 2005-10-20 22:21:20.000000000 +0100
@@ -44,7 +44,7 @@ struct grub_file
void *data;
/* This is called when a sector is read. Used only for a disk device. */
- void (*read_hook) (unsigned long sector, unsigned offset, unsigned length);
+ void (*read_hook) (grub_lba_t sector, unsigned offset, unsigned length);
};
typedef struct grub_file *grub_file_t;
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/include/grub/fshelp.h
grub2-arm/include/grub/fshelp.h
--- grub2-submitted/include/grub/fshelp.h 2004-09-11 12:42:43.000000000
+0100
+++ grub2-arm/include/grub/fshelp.h 2005-10-20 22:21:20.000000000 +0100
@@ -64,7 +64,7 @@ EXPORT_FUNC(grub_fshelp_find_file) (cons
blocks have a size of LOG2BLOCKSIZE (in log2). */
grub_ssize_t
EXPORT_FUNC(grub_fshelp_read_file) (grub_disk_t disk, grub_fshelp_node_t node,
- void (*read_hook) (unsigned long sector,
+ void (*read_hook) (grub_lba_t sector,
unsigned offset,
unsigned length),
int pos, unsigned int len, char *buf,
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/include/grub/partition.h
grub2-arm/include/grub/partition.h
--- grub2-submitted/include/grub/partition.h 2005-10-20 14:46:20.000000000
+0100
+++ grub2-arm/include/grub/partition.h 2005-10-20 22:21:20.000000000 +0100
@@ -52,13 +52,13 @@ typedef struct grub_partition_map *grub_
struct grub_partition
{
/* The start sector. */
- unsigned long start;
+ grub_lba_t start;
/* The length in sector units. */
- unsigned long len;
+ grub_lba_t len;
/* The offset of the partition table. */
- unsigned long offset;
+ grub_lba_t offset;
/* The index of this partition in the partition table. */
int index;
@@ -96,13 +96,13 @@ void grub_acorn_partition_map_init (void
void grub_acorn_partition_map_fini (void);
#endif
-static inline unsigned long
+static inline grub_lba_t
grub_partition_get_start (const grub_partition_t p)
{
return p->start;
}
-static inline unsigned long
+static inline grub_lba_t
grub_partition_get_len (const grub_partition_t p)
{
return p->len;
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/include/grub/types.h
grub2-arm/include/grub/types.h
--- grub2-submitted/include/grub/types.h 2005-10-20 14:45:38.000000000
+0100
+++ grub2-arm/include/grub/types.h 2005-10-20 22:21:20.000000000 +0100
@@ -152,4 +152,7 @@ typedef grub_int32_t grub_ssize_t;
# define grub_be_to_cpu64(x) grub_swap_bytes64(x)
#endif /* ! WORDS_BIGENDIAN */
+/* Data type to hold a disk pointer */
+typedef grub_uint64_t grub_lba_t;
+
#endif /* ! GRUB_TYPES_HEADER */
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/kern/disk.c grub2-arm/kern/disk.c
--- grub2-submitted/kern/disk.c 2005-10-15 18:20:22.000000000 +0100
+++ grub2-arm/kern/disk.c 2005-10-20 22:21:20.000000000 +0100
@@ -37,7 +37,7 @@ struct grub_disk_cache
{
unsigned long dev_id;
unsigned long disk_id;
- unsigned long sector;
+ grub_lba_t sector;
char *data;
int lock;
};
@@ -67,12 +67,12 @@ grub_disk_cache_get_index (unsigned long
static void
grub_disk_cache_invalidate (unsigned long dev_id, unsigned long disk_id,
- unsigned long sector)
+ grub_lba_t sector)
{
unsigned index;
struct grub_disk_cache *cache;
- sector &= ~(GRUB_DISK_CACHE_SIZE - 1);
+ sector &= ~(grub_lba_t)(GRUB_DISK_CACHE_SIZE - 1);
index = grub_disk_cache_get_index (dev_id, disk_id, sector);
cache = grub_disk_cache_table + index;
@@ -105,7 +105,7 @@ grub_disk_cache_invalidate_all (void)
static char *
grub_disk_cache_fetch (unsigned long dev_id, unsigned long disk_id,
- unsigned long sector)
+ grub_lba_t sector)
{
struct grub_disk_cache *cache;
unsigned index;
@@ -132,7 +132,7 @@ grub_disk_cache_fetch (unsigned long dev
static void
grub_disk_cache_unlock (unsigned long dev_id, unsigned long disk_id,
- unsigned long sector)
+ grub_lba_t sector)
{
struct grub_disk_cache *cache;
unsigned index;
@@ -147,7 +147,7 @@ grub_disk_cache_unlock (unsigned long de
static grub_err_t
grub_disk_cache_store (unsigned long dev_id, unsigned long disk_id,
- unsigned long sector, const char *data)
+ grub_lba_t sector, const char *data)
{
unsigned index;
struct grub_disk_cache *cache;
@@ -306,7 +306,7 @@ grub_disk_close (grub_disk_t disk)
}
static grub_err_t
-grub_disk_check_range (grub_disk_t disk, unsigned long *sector,
+grub_disk_check_range (grub_disk_t disk, grub_lba_t *sector,
unsigned long *offset, grub_ssize_t size)
{
*sector += *offset >> GRUB_DISK_SECTOR_BITS;
@@ -337,7 +337,7 @@ grub_disk_check_range (grub_disk_t disk,
/* Read data from the disk. */
grub_err_t
-grub_disk_read (grub_disk_t disk, unsigned long sector,
+grub_disk_read (grub_disk_t disk, grub_lba_t sector,
unsigned long offset, unsigned long size, char *buf)
{
char *tmp_buf;
@@ -355,12 +355,12 @@ grub_disk_read (grub_disk_t disk, unsign
while (size)
{
char *data;
- unsigned long start_sector;
+ grub_lba_t start_sector;
unsigned long len;
unsigned long pos;
/* For reading bulk data. */
- start_sector = sector & ~(GRUB_DISK_CACHE_SIZE - 1);
+ start_sector = sector & ~(grub_lba_t)(GRUB_DISK_CACHE_SIZE - 1);
pos = (sector - start_sector) << GRUB_DISK_SECTOR_BITS;
len = (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS) - pos - offset;
if (len > size)
@@ -424,7 +424,7 @@ grub_disk_read (grub_disk_t disk, unsign
/* Call the read hook, if any. */
if (disk->read_hook)
{
- unsigned long s = sector;
+ grub_lba_t s = sector;
unsigned long l = len;
while (l)
@@ -457,7 +457,7 @@ grub_disk_read (grub_disk_t disk, unsign
}
grub_err_t
-grub_disk_write (grub_disk_t disk, unsigned long sector,
+grub_disk_write (grub_disk_t disk, grub_lba_t sector,
unsigned long offset, unsigned long size, const char *buf)
{
if (grub_disk_check_range (disk, §or, &offset, size) != GRUB_ERR_NONE)
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/partmap/acorn.c grub2-arm/partmap/acorn.c
--- grub2-submitted/partmap/acorn.c 2005-10-20 14:46:20.000000000 +0100
+++ grub2-arm/partmap/acorn.c 2005-10-20 22:21:20.000000000 +0100
@@ -113,7 +113,7 @@ acorn_partition_map_iterate (grub_disk_t
&& map[i].magic != LINUX_SWAP_MAGIC)
return GRUB_ERR_NONE;
- part.start = sector + map[i].start;
+ part.start = (grub_lba_t)sector + map[i].start;
part.len = map[i].size;
part.offset = 6;
part.index = i;
@@ -153,7 +153,7 @@ acorn_partition_map_probe (grub_disk_t d
if (!p)
return 0;
- p->start = sector + map[partnum].start;
+ p->start = (grub_lba_t)sector + map[partnum].start;
p->len = map[partnum].size;
p->offset = 6;
p->index = partnum;
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/partmap/amiga.c grub2-arm/partmap/amiga.c
--- grub2-submitted/partmap/amiga.c 2005-08-18 01:08:21.000000000 +0100
+++ grub2-arm/partmap/amiga.c 2005-10-20 22:21:20.000000000 +0100
@@ -121,10 +121,10 @@ amiga_partition_map_iterate (grub_disk_t
return grub_errno;
/* Calculate the first block and the size of the partition. */
- part.start = (grub_be_to_cpu32 (apart.lowcyl)
+ part.start = ((grub_lba_t)grub_be_to_cpu32 (apart.lowcyl)
* grub_be_to_cpu32 (apart.heads)
* grub_be_to_cpu32 (apart.block_per_track));
- part.len = ((grub_be_to_cpu32 (apart.highcyl)
+ part.len = ((grub_lba_t)(grub_be_to_cpu32 (apart.highcyl)
- grub_be_to_cpu32 (apart.lowcyl) + 1)
* grub_be_to_cpu32 (apart.heads)
* grub_be_to_cpu32 (apart.block_per_track));
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/partmap/pc.c grub2-arm/partmap/pc.c
--- grub2-submitted/partmap/pc.c 2005-08-20 08:14:58.000000000 +0100
+++ grub2-arm/partmap/pc.c 2005-10-20 23:41:22.000000000 +0100
@@ -137,8 +137,9 @@ pc_partition_map_iterate (grub_disk_t di
pcdata.bsd_type = -1;
grub_dprintf ("partition",
- "partition %d: flag 0x%x, type 0x%x, start 0x%lx, len
0x%lx\n",
- p.index, e->flag, pcdata.dos_type, p.start, p.len);
+ "partition %d: flag 0x%x, type 0x%x, start 0x%x, len
0x%x\n",
+ p.index, e->flag, pcdata.dos_type,
+ (unsigned)p.start, (unsigned)p.len);
/* If this partition is a normal one, call the hook. */
if (! grub_pc_partition_is_empty (e->type)
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/partmap/sun.c grub2-arm/partmap/sun.c
--- grub2-submitted/partmap/sun.c 2005-08-18 01:10:05.000000000 +0100
+++ grub2-arm/partmap/sun.c 2005-10-20 22:21:20.000000000 +0100
@@ -115,7 +115,7 @@ sun_partition_map_iterate (grub_disk_t d
if (block.infos[partnum].id == 0 ||
block.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
continue;
- p->start = grub_be_to_cpu32
+ p->start = (grub_lba_t)grub_be_to_cpu32
(block.partitions[partnum].start_cylinder)
* grub_be_to_cpu16 (block.ntrks)
* grub_be_to_cpu16 (block.nsect);
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/util/i386/pc/biosdisk.c
grub2-arm/util/i386/pc/biosdisk.c
--- grub2-submitted/util/i386/pc/biosdisk.c 2005-08-18 00:44:32.000000000
+0100
+++ grub2-arm/util/i386/pc/biosdisk.c 2005-10-20 22:21:20.000000000 +0100
@@ -285,7 +285,7 @@ linux_find_partition (char *dev, unsigne
#endif /* __linux__ */
static int
-open_device (const grub_disk_t disk, unsigned long sector, int flags)
+open_device (const grub_disk_t disk, grub_lba_t sector, int flags)
{
int fd;
@@ -421,7 +421,7 @@ nwrite (int fd, const char *buf, size_t
}
static grub_err_t
-grub_util_biosdisk_read (grub_disk_t disk, unsigned long sector,
+grub_util_biosdisk_read (grub_disk_t disk, grub_lba_t sector,
unsigned long size, char *buf)
{
int fd;
@@ -458,7 +458,7 @@ grub_util_biosdisk_read (grub_disk_t dis
}
static grub_err_t
-grub_util_biosdisk_write (grub_disk_t disk, unsigned long sector,
+grub_util_biosdisk_write (grub_disk_t disk, grub_lba_t sector,
unsigned long size, const char *buf)
{
int fd;
@@ -726,6 +726,7 @@ grub_util_biosdisk_get_grub_dev (const c
partition, so mapping them to GRUB devices is not trivial.
Here, get the start sector of a partition by HDIO_GETGEO, and
compare it with each partition GRUB recognizes. */
+ /* FIXME: 64 bit disk addresses. */
{
char *name;
grub_disk_t disk;
diff -purN -x '*.mk' -x '*~' -x autom4te.cache -x configure -x '.#*' -x
'*.orig' -x CVS grub2-submitted/util/i386/pc/grub-setup.c
grub2-arm/util/i386/pc/grub-setup.c
--- grub2-submitted/util/i386/pc/grub-setup.c 2005-08-18 00:34:44.000000000
+0100
+++ grub2-arm/util/i386/pc/grub-setup.c 2005-10-21 10:09:01.000000000 +0100
@@ -101,9 +101,9 @@ setup (const char *prefix, const char *d
FILE *fp;
unsigned long first_start = ~0UL;
- auto void save_first_sector (unsigned long sector, unsigned offset,
+ auto void save_first_sector (grub_lba_t sector, unsigned offset,
unsigned length);
- auto void save_blocklists (unsigned long sector, unsigned offset,
+ auto void save_blocklists (grub_lba_t sector, unsigned offset,
unsigned length);
auto int find_first_partition_start (grub_disk_t disk,
@@ -122,24 +122,31 @@ setup (const char *prefix, const char *d
return 0;
}
- void save_first_sector (unsigned long sector, unsigned offset,
+ void save_first_sector (grub_lba_t sector, unsigned offset,
unsigned length)
{
grub_util_info ("the fist sector is <%lu,%u,%u>",
sector, offset, length);
+ if (sector >= 0x100000000ULL)
+ grub_util_error ("The first sector of the core file is above 2TiB");
+
if (offset != 0 || length != GRUB_DISK_SECTOR_SIZE)
grub_util_error ("The first sector of the core file is not
sector-aligned");
first_sector = sector;
}
- void save_blocklists (unsigned long sector, unsigned offset, unsigned length)
+ void save_blocklists (grub_lba_t sector, unsigned offset, unsigned length)
{
struct boot_blocklist *prev = block + 1;
- grub_util_info ("saving <%lu,%u,%u> with the segment 0x%x",
- sector, offset, length, (unsigned) current_segment);
+ if (sector >= 0x100000000ULL)
+ grub_util_error ("Part of the core file is above 2TiB");
+
+ grub_util_info ("saving <%u,%u,%u> with the segment 0x%x",
+ (unsigned) sector, offset, length,
+ (unsigned) current_segment);
if (offset != 0 || last_length != GRUB_DISK_SECTOR_SIZE)
grub_util_error ("Non-sector-aligned data is found in the core file");
--
Member AFFS, WYLUG, SWP (UK), UAF, RESPECT, StWC
No to software patents! Victory to the iraqi resistance!
pgpzdP8hwsbNA.pgp
Description: PGP signature
- [patch] 64 bit disk address support (= 8192EiB disks),
Timothy Baldwin <=
- Re: [patch] 64 bit disk address support (= 8192EiB disks), Marco Gerards, 2005/10/21
- Re: [patch] 64 bit disk address support (= 8192EiB disks), Yoshinori K. Okuji, 2005/10/21
- Re: [patch] 64 bit disk address support (= 8192EiB disks), Marco Gerards, 2005/10/21
- Re: [patch] 64 bit disk address support (= 8192EiB disks), Timothy Baldwin, 2005/10/21
- Re: [patch] 64 bit disk address support (= 8192EiB disks), Yoshinori K. Okuji, 2005/10/21
- Re: [patch] 64 bit disk address support (= 8192EiB disks), Timothy Baldwin, 2005/10/22
- Re: [patch] 64 bit disk address support (= 8192EiB disks), Yoshinori K. Okuji, 2005/10/27
- Re: [patch] 64 bit disk address support (= 8192EiB disks), Timothy Baldwin, 2005/10/28
Re: [patch] 64 bit disk address support (= 8192EiB disks), Timothy Baldwin, 2005/10/23