From e43909c66daf6c2587081e74b30d47c6577cf51a Mon Sep 17 00:00:00 2001 From: okuji Date: Sun, 23 May 2004 16:45:45 +0000 Subject: [PATCH] 2004-05-23 Yoshinori K. Okuji * stage2/char_io.c (grub_isspace): Use a switch sentense instead of an if sentense, because that reduces the size. * lib/device.c (read_device_map): Change the max number of DRIVE to 127 from 8. This was too strict. * stage2/asm.S (stop_floppy): Call pusha and popa outside the block of real mode code. Reported by Guillem Jover . --- ChangeLog | 12 ++++++++++++ grub/Makefile.in | 9 +++++---- lib/device.c | 15 +++++++++++++-- lib/device.h | 3 ++- stage2/asm.S | 6 +++--- stage2/char_io.c | 12 ++++++++++-- stage2/disk_io.c | 3 ++- 7 files changed, 47 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index c42bd08a9..8e05224d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-05-23 Yoshinori K. Okuji + + * stage2/char_io.c (grub_isspace): Use a switch sentense instead + of an if sentense, because that reduces the size. + + * lib/device.c (read_device_map): Change the max number of DRIVE + to 127 from 8. This was too strict. + + * stage2/asm.S (stop_floppy): Call pusha and popa outside the + block of real mode code. Reported by Guillem Jover + . + 2004-05-20 Damian Ivereigh * netboot/main.c: Fixed bootp only code so that options diff --git a/grub/Makefile.in b/grub/Makefile.in index 6f611a642..ed348746f 100644 --- a/grub/Makefile.in +++ b/grub/Makefile.in @@ -142,13 +142,14 @@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ sbin_PROGRAMS = grub -@SERIAL_SPEED_SIMULATION_FALSE@SERIAL_FLAGS = -DSUPPORT_SERIAL=1 @SERIAL_SPEED_SIMULATION_TRUE@SERIAL_FLAGS = -DSUPPORT_SERIAL=1 -DSIMULATE_SLOWNESS_OF_SERIAL=1 +@SERIAL_SPEED_SIMULATION_FALSE@SERIAL_FLAGS = -DSUPPORT_SERIAL=1 -AM_CPPFLAGS = -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 \ - -DFSYS_UFS2=1 \ - -DFSYS_FFS=1 -DFSYS_MINIX=1 -DSUPPORT_HERCULES=1 \ +AM_CPPFLAGS = -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \ + -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \ + -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \ + -DUSE_MD5_PASSWORDS=1 -DSUPPORT_HERCULES=1 \ $(SERIAL_FLAGS) -I$(top_srcdir)/stage2 \ -I$(top_srcdir)/stage1 -I$(top_srcdir)/lib diff --git a/lib/device.c b/lib/device.c index b9cc28ad2..4a49001ce 100644 --- a/lib/device.c +++ b/lib/device.c @@ -558,7 +558,7 @@ read_device_map (FILE *fp, char **map, const char *map_file) show_error (line_number, "Bad device number"); return 0; } - else if (drive > 8) + else if (drive > 127) { show_warning (line_number, "Ignoring %cd%d due to a BIOS limitation", @@ -821,9 +821,20 @@ restore_device_map (char **map) } #ifdef __linux__ -/* Linux-only function, because Linux has a bug that the disk cache for +/* Linux-only functions, because Linux has a bug that the disk cache for a whole disk is not consistent with the one for a partition of the disk. */ +int +is_disk_device (char **map, int drive) +{ + struct stat st; + + assert (map[drive] != 0); + assert (stat (map[drive], &st) == 0); + /* For now, disk devices under Linux are all block devices. */ + return S_ISBLK (st.st_mode); +} + int write_to_partition (char **map, int drive, int partition, int sector, int size, const char *buf) diff --git a/lib/device.h b/lib/device.h index e616e4bdf..02ffce8e8 100644 --- a/lib/device.h +++ b/lib/device.h @@ -1,7 +1,7 @@ /* device.h - Define macros and declare prototypes for device.c */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999, 2000 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2004 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 @@ -40,6 +40,7 @@ extern int init_device_map (char ***map, const char *map_file, extern void restore_device_map (char **map); #ifdef __linux__ +extern int is_disk_device (char **map, int drive); extern int write_to_partition (char **map, int drive, int partition, int offset, int size, const char *buf); #endif /* __linux__ */ diff --git a/stage2/asm.S b/stage2/asm.S index 2dd07088e..b4db6d58c 100644 --- a/stage2/asm.S +++ b/stage2/asm.S @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2004 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 @@ -211,14 +211,14 @@ ENTRY(hard_stop) * jumped to with a known state. */ ENTRY(stop_floppy) + pusha call EXT_C(prot_to_real) .code16 - pusha xorb %dl, %dl int $0x13 - popa DATA32 call EXT_C(real_to_prot) .code32 + popa ret /* diff --git a/stage2/char_io.c b/stage2/char_io.c index 3ff110bbc..d2960238f 100644 --- a/stage2/char_io.c +++ b/stage2/char_io.c @@ -912,8 +912,16 @@ grub_tolower (int c) int grub_isspace (int c) { - if (c == ' ' || c == '\t' || c == '\r' || c == '\n') - return 1; + switch (c) + { + case ' ': + case '\t': + case '\r': + case '\n': + return 1; + default: + break; + } return 0; } diff --git a/stage2/disk_io.c b/stage2/disk_io.c index 9b63d243e..b9bc52643 100644 --- a/stage2/disk_io.c +++ b/stage2/disk_io.c @@ -366,7 +366,8 @@ int devwrite (int sector, int sector_count, char *buf) { #if defined(GRUB_UTIL) && defined(__linux__) - if (current_partition != 0xFFFFFF) + if (current_partition != 0xFFFFFF + && is_disk_device (device_map, current_drive)) { /* If the grub shell is running under Linux and the user wants to embed a Stage 1.5 into a partition instead of a MBR, use system