2006-11-11 Jeroen Dekkers <jeroen@dekkers.cx>

* kern/disk.c (grub_disk_read): When there is a read error, always
	try to read only the necessary data.

	* conf/i386-pc.rmk (grub_probe_SOURCES): Add disk/lvm.c and
	disk/raid.c.
	* include/grub/disk.h [GRUB_UTIL] (grub_raid_init): New
	prototype.
	[GRUB_UTIL] (grub_raid_fini): Likewise.
	[GRUB_UTIL] (grub_lvm_init): Likewise.
	[GRUB_UTIL] (grub_lvm_fini): Likewise.
	* util/i386/pc/grub-probe.c (probe): Check whether DEVICE_NAME is
	RAID device and copy DEVICE_NAME to DRIVE_NAME in that case.
	(main): Call grub_raid_init(), grub_lvm_init(), grub_lvm_fini()
	and grub_raid_fini().
This commit is contained in:
jeroen 2006-11-10 23:31:55 +00:00
parent 03e58196a8
commit 790707f254
6 changed files with 56 additions and 17 deletions

View file

@ -1,3 +1,20 @@
2006-11-11 Jeroen Dekkers <jeroen@dekkers.cx>
* kern/disk.c (grub_disk_read): When there is a read error, always
try to read only the necessary data.
* conf/i386-pc.rmk (grub_probe_SOURCES): Add disk/lvm.c and
disk/raid.c.
* include/grub/disk.h [GRUB_UTIL] (grub_raid_init): New
prototype.
[GRUB_UTIL] (grub_raid_fini): Likewise.
[GRUB_UTIL] (grub_lvm_init): Likewise.
[GRUB_UTIL] (grub_lvm_fini): Likewise.
* util/i386/pc/grub-probe.c (probe): Check whether DEVICE_NAME is
RAID device and copy DEVICE_NAME to DRIVE_NAME in that case.
(main): Call grub_raid_init(), grub_lvm_init(), grub_lvm_fini()
and grub_raid_fini().
2006-11-09 Jeroen Dekkers <jeroen@dekkers.cx>
* include/grub/types.h (__unused): Rename to UNUSED.

View file

@ -353,12 +353,12 @@ grub_probe_SOURCES = util/i386/pc/grub-probe.c \
kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \
fs/ext2.c kern/parser.c kern/partition.c partmap/pc.c fs/ufs.c \
fs/minix.c fs/hfs.c fs/jfs.c kern/fs.c kern/env.c fs/fshelp.c \
fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c
CLEANFILES += grub-probe grub_probe-util_i386_pc_grub_probe.o grub_probe-util_i386_pc_biosdisk.o grub_probe-util_misc.o grub_probe-util_i386_pc_getroot.o grub_probe-kern_device.o grub_probe-kern_disk.o grub_probe-kern_err.o grub_probe-kern_misc.o grub_probe-fs_fat.o grub_probe-fs_ext2.o grub_probe-kern_parser.o grub_probe-kern_partition.o grub_probe-partmap_pc.o grub_probe-fs_ufs.o grub_probe-fs_minix.o grub_probe-fs_hfs.o grub_probe-fs_jfs.o grub_probe-kern_fs.o grub_probe-kern_env.o grub_probe-fs_fshelp.o grub_probe-fs_xfs.o grub_probe-fs_affs.o grub_probe-fs_sfs.o grub_probe-fs_hfsplus.o
MOSTLYCLEANFILES += grub_probe-util_i386_pc_grub_probe.d grub_probe-util_i386_pc_biosdisk.d grub_probe-util_misc.d grub_probe-util_i386_pc_getroot.d grub_probe-kern_device.d grub_probe-kern_disk.d grub_probe-kern_err.d grub_probe-kern_misc.d grub_probe-fs_fat.d grub_probe-fs_ext2.d grub_probe-kern_parser.d grub_probe-kern_partition.d grub_probe-partmap_pc.d grub_probe-fs_ufs.d grub_probe-fs_minix.d grub_probe-fs_hfs.d grub_probe-fs_jfs.d grub_probe-kern_fs.d grub_probe-kern_env.d grub_probe-fs_fshelp.d grub_probe-fs_xfs.d grub_probe-fs_affs.d grub_probe-fs_sfs.d grub_probe-fs_hfsplus.d
fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c disk/lvm.c disk/raid.c
CLEANFILES += grub-probe grub_probe-util_i386_pc_grub_probe.o grub_probe-util_i386_pc_biosdisk.o grub_probe-util_misc.o grub_probe-util_i386_pc_getroot.o grub_probe-kern_device.o grub_probe-kern_disk.o grub_probe-kern_err.o grub_probe-kern_misc.o grub_probe-fs_fat.o grub_probe-fs_ext2.o grub_probe-kern_parser.o grub_probe-kern_partition.o grub_probe-partmap_pc.o grub_probe-fs_ufs.o grub_probe-fs_minix.o grub_probe-fs_hfs.o grub_probe-fs_jfs.o grub_probe-kern_fs.o grub_probe-kern_env.o grub_probe-fs_fshelp.o grub_probe-fs_xfs.o grub_probe-fs_affs.o grub_probe-fs_sfs.o grub_probe-fs_hfsplus.o grub_probe-disk_lvm.o grub_probe-disk_raid.o
MOSTLYCLEANFILES += grub_probe-util_i386_pc_grub_probe.d grub_probe-util_i386_pc_biosdisk.d grub_probe-util_misc.d grub_probe-util_i386_pc_getroot.d grub_probe-kern_device.d grub_probe-kern_disk.d grub_probe-kern_err.d grub_probe-kern_misc.d grub_probe-fs_fat.d grub_probe-fs_ext2.d grub_probe-kern_parser.d grub_probe-kern_partition.d grub_probe-partmap_pc.d grub_probe-fs_ufs.d grub_probe-fs_minix.d grub_probe-fs_hfs.d grub_probe-fs_jfs.d grub_probe-kern_fs.d grub_probe-kern_env.d grub_probe-fs_fshelp.d grub_probe-fs_xfs.d grub_probe-fs_affs.d grub_probe-fs_sfs.d grub_probe-fs_hfsplus.d grub_probe-disk_lvm.d grub_probe-disk_raid.d
grub-probe: $(grub_probe_DEPENDENCIES) grub_probe-util_i386_pc_grub_probe.o grub_probe-util_i386_pc_biosdisk.o grub_probe-util_misc.o grub_probe-util_i386_pc_getroot.o grub_probe-kern_device.o grub_probe-kern_disk.o grub_probe-kern_err.o grub_probe-kern_misc.o grub_probe-fs_fat.o grub_probe-fs_ext2.o grub_probe-kern_parser.o grub_probe-kern_partition.o grub_probe-partmap_pc.o grub_probe-fs_ufs.o grub_probe-fs_minix.o grub_probe-fs_hfs.o grub_probe-fs_jfs.o grub_probe-kern_fs.o grub_probe-kern_env.o grub_probe-fs_fshelp.o grub_probe-fs_xfs.o grub_probe-fs_affs.o grub_probe-fs_sfs.o grub_probe-fs_hfsplus.o
$(CC) -o $@ grub_probe-util_i386_pc_grub_probe.o grub_probe-util_i386_pc_biosdisk.o grub_probe-util_misc.o grub_probe-util_i386_pc_getroot.o grub_probe-kern_device.o grub_probe-kern_disk.o grub_probe-kern_err.o grub_probe-kern_misc.o grub_probe-fs_fat.o grub_probe-fs_ext2.o grub_probe-kern_parser.o grub_probe-kern_partition.o grub_probe-partmap_pc.o grub_probe-fs_ufs.o grub_probe-fs_minix.o grub_probe-fs_hfs.o grub_probe-fs_jfs.o grub_probe-kern_fs.o grub_probe-kern_env.o grub_probe-fs_fshelp.o grub_probe-fs_xfs.o grub_probe-fs_affs.o grub_probe-fs_sfs.o grub_probe-fs_hfsplus.o $(LDFLAGS) $(grub_probe_LDFLAGS)
grub-probe: $(grub_probe_DEPENDENCIES) grub_probe-util_i386_pc_grub_probe.o grub_probe-util_i386_pc_biosdisk.o grub_probe-util_misc.o grub_probe-util_i386_pc_getroot.o grub_probe-kern_device.o grub_probe-kern_disk.o grub_probe-kern_err.o grub_probe-kern_misc.o grub_probe-fs_fat.o grub_probe-fs_ext2.o grub_probe-kern_parser.o grub_probe-kern_partition.o grub_probe-partmap_pc.o grub_probe-fs_ufs.o grub_probe-fs_minix.o grub_probe-fs_hfs.o grub_probe-fs_jfs.o grub_probe-kern_fs.o grub_probe-kern_env.o grub_probe-fs_fshelp.o grub_probe-fs_xfs.o grub_probe-fs_affs.o grub_probe-fs_sfs.o grub_probe-fs_hfsplus.o grub_probe-disk_lvm.o grub_probe-disk_raid.o
$(CC) -o $@ grub_probe-util_i386_pc_grub_probe.o grub_probe-util_i386_pc_biosdisk.o grub_probe-util_misc.o grub_probe-util_i386_pc_getroot.o grub_probe-kern_device.o grub_probe-kern_disk.o grub_probe-kern_err.o grub_probe-kern_misc.o grub_probe-fs_fat.o grub_probe-fs_ext2.o grub_probe-kern_parser.o grub_probe-kern_partition.o grub_probe-partmap_pc.o grub_probe-fs_ufs.o grub_probe-fs_minix.o grub_probe-fs_hfs.o grub_probe-fs_jfs.o grub_probe-kern_fs.o grub_probe-kern_env.o grub_probe-fs_fshelp.o grub_probe-fs_xfs.o grub_probe-fs_affs.o grub_probe-fs_sfs.o grub_probe-fs_hfsplus.o grub_probe-disk_lvm.o grub_probe-disk_raid.o $(LDFLAGS) $(grub_probe_LDFLAGS)
grub_probe-util_i386_pc_grub_probe.o: util/i386/pc/grub-probe.c
$(CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_probe_CFLAGS) -MD -c -o $@ $<
@ -456,6 +456,14 @@ grub_probe-fs_hfsplus.o: fs/hfsplus.c
$(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_probe_CFLAGS) -MD -c -o $@ $<
-include grub_probe-fs_hfsplus.d
grub_probe-disk_lvm.o: disk/lvm.c
$(CC) -Idisk -I$(srcdir)/disk $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_probe_CFLAGS) -MD -c -o $@ $<
-include grub_probe-disk_lvm.d
grub_probe-disk_raid.o: disk/raid.c
$(CC) -Idisk -I$(srcdir)/disk $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_probe_CFLAGS) -MD -c -o $@ $<
-include grub_probe-disk_raid.d
# For grub-emu.
grub_emu_DEPENDENCIES = grub_script.tab.c grub_script.tab.h \

View file

@ -75,7 +75,7 @@ grub_probe_SOURCES = util/i386/pc/grub-probe.c \
kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \
fs/ext2.c kern/parser.c kern/partition.c partmap/pc.c fs/ufs.c \
fs/minix.c fs/hfs.c fs/jfs.c kern/fs.c kern/env.c fs/fshelp.c \
fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c
fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c disk/lvm.c disk/raid.c
# For grub-emu.
grub_emu_DEPENDENCIES = grub_script.tab.c grub_script.tab.h \

View file

@ -136,4 +136,11 @@ grub_err_t EXPORT_FUNC(grub_disk_write) (grub_disk_t disk,
grub_uint64_t EXPORT_FUNC(grub_disk_get_size) (grub_disk_t disk);
#ifdef GRUB_UTIL
void grub_raid_init (void);
void grub_raid_fini (void);
void grub_lvm_init (void);
void grub_lvm_fini (void);
#endif
#endif /* ! GRUB_DISK_HEADER */

View file

@ -412,11 +412,6 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_errno = GRUB_ERR_NONE;
/* If more data is required, no way. */
if (pos + size
>= (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS))
goto finish;
num = ((size + GRUB_DISK_SECTOR_SIZE - 1)
>> GRUB_DISK_SECTOR_BITS);
if ((disk->dev->read) (disk, sector, num, tmp_buf))

View file

@ -97,13 +97,21 @@ probe (const char *path)
goto end;
}
drive_name = grub_util_biosdisk_get_grub_dev (device_name);
if (! drive_name)
if (device_name[0] == 'm' && device_name[1] == 'd'
&& device_name[2] >= '0' && device_name[2] <= '9')
{
fprintf (stderr, "cannot find a GRUB drive for %s.\n", device_name);
goto end;
drive_name = xstrdup (device_name);
}
else
{
drive_name = grub_util_biosdisk_get_grub_dev (device_name);
if (! drive_name)
{
fprintf (stderr, "cannot find a GRUB drive for %s.\n", device_name);
goto end;
}
}
if (print == PRINT_DRIVE)
{
printf ("(%s)\n", drive_name);
@ -236,7 +244,9 @@ main (int argc, char *argv[])
/* Initialize the emulated biosdisk driver. */
grub_util_biosdisk_init (dev_map ? : DEFAULT_DEVICE_MAP);
grub_pc_partition_map_init ();
grub_raid_init ();
grub_lvm_init ();
/* Initialize filesystems. */
grub_fat_init ();
grub_ext2_init ();
@ -256,6 +266,8 @@ main (int argc, char *argv[])
grub_jfs_fini ();
grub_xfs_fini ();
grub_lvm_fini ();
grub_raid_fini ();
grub_pc_partition_map_fini ();
grub_util_biosdisk_fini ();