source:
patches/grub-0.97-disk_geometry-1.patch@
2da4918
Last change on this file since 2da4918 was 94053a6, checked in by , 18 years ago | |
---|---|
|
|
File size: 27.7 KB |
-
configure
Submitted By: Jim Gifford <jim@linuxfromscratch.org> Date: 05-28-2008 Initial Package Version: 0.97 Upstream Status: Unknown Origin: Fedora and Mandriva Description: This patch fixes issues with disk geometry not being detected properly. Part of this patch also fixes gcc 4 compile errors, which are a part of the issue. diff -Naur grub-0.97.orig/configure grub-0.97/configure
old new 3485 3485 echo "$as_me:$LINENO: result: $size_flag" >&5 3486 3486 echo "${ECHO_T}$size_flag" >&6 3487 3487 if test "x$size_flag" = xyes; then 3488 STAGE2_CFLAGS="-Os "3488 STAGE2_CFLAGS="-Os -fno-strict-aliasing" 3489 3489 else 3490 STAGE2_CFLAGS="-O2 -fno-str ength-reduce -fno-unroll-loops"3490 STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops" 3491 3491 fi 3492 3492 # OpenBSD has a GCC extension for protecting applications from 3493 3493 # stack smashing attacks, but GRUB doesn't want this feature. -
configure.ac
diff -Naur grub-0.97.orig/configure.ac grub-0.97/configure.ac
old new 93 93 CFLAGS=$saved_CFLAGS 94 94 ]) 95 95 if test "x$size_flag" = xyes; then 96 STAGE2_CFLAGS="-Os "96 STAGE2_CFLAGS="-Os -fno-strict-aliasing" 97 97 else 98 STAGE2_CFLAGS="-O2 -fno-str ength-reduce -fno-unroll-loops"98 STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops" 99 99 fi 100 100 # OpenBSD has a GCC extension for protecting applications from 101 101 # stack smashing attacks, but GRUB doesn't want this feature. -
lib/device.c
diff -Naur grub-0.97.orig/lib/device.c grub-0.97/lib/device.c
old new 131 131 #include <shared.h> 132 132 #include <device.h> 133 133 134 #if defined(__linux__) 135 /* The 2.6 kernel has removed all of the geometry handling for IDE drives 136 * that did fixups for LBA, etc. This means that the geometry we get 137 * with the ioctl has a good chance of being wrong. So, we get to 138 * also know about partition tables and try to read what the geometry 139 * is there. *grumble* Very closely based on code from cfdisk 140 */ 141 static void get_kernel_geometry(int fd, long long *cyl, int *heads, int *sectors) { 142 struct hd_geometry hdg; 143 144 if (ioctl (fd, HDIO_GETGEO, &hdg)) 145 return; 146 147 *cyl = hdg.cylinders; 148 *heads = hdg.heads; 149 *sectors = hdg.sectors; 150 } 151 152 struct partition { 153 unsigned char boot_ind; /* 0x80 - active */ 154 unsigned char head; /* starting head */ 155 unsigned char sector; /* starting sector */ 156 unsigned char cyl; /* starting cylinder */ 157 unsigned char sys_ind; /* What partition type */ 158 unsigned char end_head; /* end head */ 159 unsigned char end_sector; /* end sector */ 160 unsigned char end_cyl; /* end cylinder */ 161 unsigned char start4[4]; /* starting sector counting from 0 */ 162 unsigned char size4[4]; /* nr of sectors in partition */ 163 }; 164 165 #define ALIGNMENT 2 166 typedef union { 167 struct { 168 unsigned char align[ALIGNMENT]; 169 unsigned char b[SECTOR_SIZE]; 170 } c; 171 struct { 172 unsigned char align[ALIGNMENT]; 173 unsigned char buffer[0x1BE]; 174 struct partition part[4]; 175 unsigned char magicflag[2]; 176 } p; 177 } partition_table; 178 179 #define PART_TABLE_FLAG0 0x55 180 #define PART_TABLE_FLAG1 0xAA 181 182 static void 183 get_partition_table_geometry(partition_table *bufp, long long *cyl, int *heads, 184 int *sectors) { 185 struct partition *p; 186 int i,h,s,hh,ss; 187 int first = 1; 188 int bad = 0; 189 190 if (bufp->p.magicflag[0] != PART_TABLE_FLAG0 || 191 bufp->p.magicflag[1] != PART_TABLE_FLAG1) { 192 /* Matthew Wilcox: slightly friendlier version of 193 fatal(_("Bad signature on partition table"), 3); 194 */ 195 fprintf(stderr, "Unknown partition table signature\n"); 196 return; 197 } 198 199 hh = ss = 0; 200 for (i=0; i<4; i++) { 201 p = &(bufp->p.part[i]); 202 if (p->sys_ind != 0) { 203 h = p->end_head + 1; 204 s = (p->end_sector & 077); 205 if (first) { 206 hh = h; 207 ss = s; 208 first = 0; 209 } else if (hh != h || ss != s) 210 bad = 1; 211 } 212 } 213 214 if (!first && !bad) { 215 *heads = hh; 216 *sectors = ss; 217 } 218 } 219 220 static long long my_lseek (unsigned int fd, long long offset, 221 unsigned int origin) 222 { 223 #if defined(__linux__) && (!defined(__GLIBC__) || \ 224 ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))) 225 /* Maybe libc doesn't have large file support. */ 226 loff_t offset, result; 227 static int _llseek (uint filedes, ulong hi, ulong lo, 228 loff_t *res, uint wh); 229 _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo, 230 loff_t *, res, uint, wh); 231 232 if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET) < 0) 233 return (long long) -1; 234 return result; 235 #else 236 return lseek(fd, offset, SEEK_SET); 237 #endif 238 } 239 240 static void get_linux_geometry (int fd, struct geometry *geom) { 241 long long kern_cyl = 0; int kern_head = 0, kern_sectors = 0; 242 long long pt_cyl = 0; int pt_head = 0, pt_sectors = 0; 243 partition_table bufp; 244 char *buff, *buf_unaligned; 245 246 buf_unaligned = malloc(sizeof(partition_table) + 4095); 247 buff = (char *) (((unsigned long)buf_unaligned + 4096 - 1) & 248 (~(4096-1))); 249 250 get_kernel_geometry(fd, &kern_cyl, &kern_head, &kern_sectors); 251 252 if (my_lseek (fd, 0*SECTOR_SIZE, SEEK_SET) < 0) { 253 fprintf(stderr, "Unable to seek"); 254 } 255 256 if (read(fd, buff, SECTOR_SIZE) == SECTOR_SIZE) { 257 memcpy(bufp.c.b, buff, SECTOR_SIZE); 258 get_partition_table_geometry(&bufp, &pt_cyl, &pt_head, &pt_sectors); 259 } else { 260 fprintf(stderr, "Unable to read partition table: %s\n", strerror(errno)); 261 } 262 263 if (pt_head && pt_sectors) { 264 int cyl_size; 265 266 geom->heads = pt_head; 267 geom->sectors = pt_sectors; 268 cyl_size = pt_head * pt_sectors; 269 geom->cylinders = geom->total_sectors/cyl_size; 270 } else { 271 geom->heads = kern_head; 272 geom->sectors = kern_sectors; 273 geom->cylinders = kern_cyl; 274 } 275 276 return; 277 } 278 #endif 279 134 280 /* Get the geometry of a drive DRIVE. */ 135 281 void 136 282 get_drive_geometry (struct geometry *geom, char **map, int drive) … … 151 297 #if defined(__linux__) 152 298 /* Linux */ 153 299 { 154 struct hd_geometry hdg;155 300 unsigned long nr; 156 157 if (ioctl (fd, HDIO_GETGEO, &hdg))158 goto fail;159 301 160 302 if (ioctl (fd, BLKGETSIZE, &nr)) 161 303 goto fail; 162 304 163 305 /* Got the geometry, so save it. */ 164 geom->cylinders = hdg.cylinders;165 geom->heads = hdg.heads;166 geom->sectors = hdg.sectors;167 306 geom->total_sectors = nr; 168 307 get_linux_geometry(fd, geom); 308 if (!geom->heads && !geom->cylinders && !geom->sectors) 309 goto fail; 169 310 goto success; 170 311 } 171 312 … … 844 985 { 845 986 char dev[PATH_MAX]; /* XXX */ 846 987 int fd; 988 off_t offset = (off_t) sector * (off_t) SECTOR_SIZE; 847 989 848 990 if ((partition & 0x00FF00) != 0x00FF00) 849 991 { … … 870 1012 errnum = ERR_NO_PART; 871 1013 return 0; 872 1014 } 873 874 #if defined(__linux__) && (!defined(__GLIBC__) || \875 ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))876 /* Maybe libc doesn't have large file support. */877 {878 loff_t offset, result;879 static int _llseek (uint filedes, ulong hi, ulong lo,880 loff_t *res, uint wh);881 _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,882 loff_t *, res, uint, wh);883 1015 884 offset = (loff_t) sector * (loff_t) SECTOR_SIZE;885 if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))886 {887 errnum = ERR_DEV_VALUES;888 return 0;889 }890 }891 #else892 {893 off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;894 1016 895 if (lseek (fd, offset, SEEK_SET) != offset) 896 { 897 errnum = ERR_DEV_VALUES; 898 return 0; 899 } 900 } 901 #endif 1017 if (my_lseek(fd, offset, SEEK_SET) != offset) 1018 { 1019 errnum = ERR_DEV_VALUES; 1020 return 0; 1021 } 902 1022 903 1023 if (write (fd, buf, size * SECTOR_SIZE) != (size * SECTOR_SIZE)) 904 1024 { -
stage2/Makefile.am
diff -Naur grub-0.97.orig/stage2/Makefile.am grub-0.97/stage2/Makefile.am
old new 24 24 -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \ 25 25 -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \ 26 26 -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \ 27 -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 27 -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 \ 28 -fno-strict-aliasing 28 29 29 30 # Stage 2 and Stage 1.5's. 30 31 pkglibdir = $(libdir)/$(PACKAGE)/$(host_cpu)-$(host_vendor) -
stage2/boot.c
diff -Naur grub-0.97.orig/stage2/boot.c grub-0.97/stage2/boot.c
old new 55 55 pu; 56 56 /* presuming that MULTIBOOT_SEARCH is large enough to encompass an 57 57 executable header */ 58 unsignedchar buffer[MULTIBOOT_SEARCH];58 char buffer[MULTIBOOT_SEARCH]; 59 59 60 60 /* sets the header pointer to point to the beginning of the 61 61 buffer by default */ … … 98 98 /* ELF loading supported if multiboot, FreeBSD and NetBSD. */ 99 99 if ((type == KERNEL_TYPE_MULTIBOOT 100 100 || pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD 101 || grub_strcmp ( pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0101 || grub_strcmp ((char *) pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0 102 102 || suggested_type == KERNEL_TYPE_NETBSD) 103 103 && len > sizeof (Elf32_Ehdr) 104 104 && BOOTABLE_I386_ELF ((*((Elf32_Ehdr *) buffer)))) … … 824 824 moveto = (mbi.mem_upper + 0x400) << 10; 825 825 826 826 moveto = (moveto - len) & 0xfffff000; 827 #if 0 827 828 max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203 828 829 ? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS); 830 #else 831 max_addr = LINUX_INITRD_MAX_ADDRESS; 832 #endif 829 833 if (moveto + len >= max_addr) 830 834 moveto = (max_addr - len) & 0xfffff000; 831 835 -
stage2/disk_io.c
diff -Naur grub-0.97.orig/stage2/disk_io.c grub-0.97/stage2/disk_io.c
old new 127 127 int filepos; 128 128 int filemax; 129 129 130 static inline unsigned long 131 log2 (unsigned long word) 130 #define log2(n) ffz(~(n)) 131 132 /* include/asm-i386/bitops.h */ 133 /* 134 * ffz = Find First Zero in word. Undefined if no zero exists, 135 * so code should check against ~0UL first.. 136 */ 137 static __inline__ unsigned long 138 ffz (unsigned long word) 132 139 { 133 asm volatile("bsfl %1,%0"134 :"=r" (word)135 : "r" (word));140 __asm__ ("bsfl %1,%0" 141 : "=r" (word) 142 : "r" (~word)); 136 143 return word; 137 144 } 138 145 -
stage2/freebsd.h
diff -Naur grub-0.97.orig/stage2/freebsd.h grub-0.97/stage2/freebsd.h
old new 78 78 struct bootinfo 79 79 { 80 80 unsigned int bi_version; 81 unsignedchar *bi_kernelname;81 char *bi_kernelname; 82 82 struct nfs_diskless *bi_nfs_diskless; 83 83 /* End of fields that are always present. */ 84 84 #define bi_endcommon bi_n_bios_used -
stage2/fsys_fat.c
diff -Naur grub-0.97.orig/stage2/fsys_fat.c grub-0.97/stage2/fsys_fat.c
old new 54 54 55 55 #define FAT_CACHE_SIZE 2048 56 56 57 #define log2(n) ffz(~(n)) 58 59 /* include/asm-i386/bitops.h */ 60 /* 61 * ffz = Find First Zero in word. Undefined if no zero exists, 62 * so code should check against ~0UL first.. 63 */ 57 64 static __inline__ unsigned long 58 log2(unsigned long word)65 ffz (unsigned long word) 59 66 { 60 67 __asm__ ("bsfl %1,%0" 61 :"=r" (word)62 : "r" (word));68 : "=r" (word) 69 : "r" (~word)); 63 70 return word; 64 71 } 65 72 -
stage2/fsys_iso9660.c
diff -Naur grub-0.97.orig/stage2/fsys_iso9660.c grub-0.97/stage2/fsys_iso9660.c
old new 55 55 #define RRCONT_BUF ((unsigned char *)(FSYS_BUF + 6144)) 56 56 #define NAME_BUF ((unsigned char *)(FSYS_BUF + 8192)) 57 57 58 #define log2(n) ffz(~(n)) 58 59 59 static inline unsigned long 60 log2 (unsigned long word) 60 /* include/asm-i386/bitops.h */ 61 /* 62 * ffz = Find First Zero in word. Undefined if no zero exists, 63 * so code should check against ~0UL first.. 64 */ 65 static __inline__ unsigned long 66 ffz (unsigned long word) 61 67 { 62 asm volatile("bsfl %1,%0"63 :"=r" (word)64 : "r" (word));68 __asm__ ("bsfl %1,%0" 69 : "=r" (word) 70 : "r" (~word)); 65 71 return word; 66 72 } 67 73 … … 120 126 break; 121 127 /* check ISO_VD_PRIMARY and ISO_STANDARD_ID */ 122 128 if (PRIMDESC->type.l == ISO_VD_PRIMARY 123 && !memcmp( PRIMDESC->id, ISO_STANDARD_ID, sizeof(PRIMDESC->id)))129 && !memcmp((char *) PRIMDESC->id, ISO_STANDARD_ID, sizeof(PRIMDESC->id))) 124 130 { 125 131 ISO_SUPER->vol_sector = sector; 126 132 INODE->file_start = 0; … … 175 181 for (; idr->length.l > 0; 176 182 idr = (struct iso_directory_record *)((char *)idr + idr->length.l) ) 177 183 { 178 const char*name = idr->name;184 const u_int8_t *name = idr->name; 179 185 unsigned int name_len = idr->name_len.l; 180 186 181 187 file_type = (idr->flags.l & 2) ? ISO_DIRECTORY : ISO_REGULAR; … … 198 204 rr_len = (idr->length.l - idr->name_len.l 199 205 - sizeof(struct iso_directory_record) 200 206 + sizeof(idr->name)); 201 rr_ptr.ptr = (( unsignedchar *)idr + idr->name_len.l207 rr_ptr.ptr = ((char *)idr + idr->name_len.l 202 208 + sizeof(struct iso_directory_record) 203 209 - sizeof(idr->name)); 204 210 if (rr_ptr.i & 1) … … 331 337 memcpy(NAME_BUF, name, name_len); 332 338 name = NAME_BUF; 333 339 } 334 rr_ptr.ptr = RRCONT_BUF + ce_ptr->u.ce.offset.l;340 rr_ptr.ptr = (char *) RRCONT_BUF + ce_ptr->u.ce.offset.l; 335 341 rr_len = ce_ptr->u.ce.size.l; 336 if (!iso9660_devread(ce_ptr->u.ce.extent.l, 0, ISO_SECTOR_SIZE, RRCONT_BUF))342 if (!iso9660_devread(ce_ptr->u.ce.extent.l, 0, ISO_SECTOR_SIZE, (char *) RRCONT_BUF)) 337 343 { 338 344 errnum = 0; /* this is not fatal. */ 339 345 break; … … 344 350 345 351 filemax = MAXINT; 346 352 if (name_len >= pathlen 347 && !memcmp( name, dirname, pathlen))353 && !memcmp((char *) name, dirname, pathlen)) 348 354 { 349 355 if (dirname[pathlen] == '/' || !print_possibilities) 350 356 { … … 381 387 print_possibilities = -print_possibilities; 382 388 memcpy(NAME_BUF, name, name_len); 383 389 NAME_BUF[name_len] = '\0'; 384 print_a_completion ( NAME_BUF);390 print_a_completion ((char *) NAME_BUF); 385 391 #endif 386 392 } 387 393 } -
stage2/fsys_reiserfs.c
diff -Naur grub-0.97.orig/stage2/fsys_reiserfs.c grub-0.97/stage2/fsys_reiserfs.c
old new 365 365 #define JOURNAL_START ((__u32 *) (INFO + 1)) 366 366 #define JOURNAL_END ((__u32 *) (FSYS_BUF + FSYS_BUFLEN)) 367 367 368 #define log2(n) ffz(~(n)) 368 369 370 /* include/asm-i386/bitops.h */ 371 /* 372 * ffz = Find First Zero in word. Undefined if no zero exists, 373 * so code should check against ~0UL first.. 374 */ 369 375 static __inline__ unsigned long 370 log2(unsigned long word)376 ffz (unsigned long word) 371 377 { 372 378 __asm__ ("bsfl %1,%0" 373 :"=r" (word)374 : "r" (word));379 : "=r" (word) 380 : "r" (~word)); 375 381 return word; 376 382 } 377 383 -
stage2/fsys_vstafs.c
diff -Naur grub-0.97.orig/stage2/fsys_vstafs.c grub-0.97/stage2/fsys_vstafs.c
old new 186 186 int 187 187 vstafs_read (char *addr, int len) 188 188 { 189 struct alloc * a;189 struct alloc *b; 190 190 int size, ret = 0, offset, curr_len = 0; 191 int curr_ext ;191 int curr_exten; 192 192 char extent; 193 193 int ext_size; 194 194 char *curr_pos; 195 195 196 196 get_file_info (f_sector); 197 197 size = FILE_INFO->len-VSTAFS_START_DATA; 198 a= FILE_INFO->blocks;198 b = FILE_INFO->blocks; 199 199 200 200 if (filepos > 0) 201 201 { 202 if (filepos < a[0].a_len * 512 - VSTAFS_START_DATA)202 if (filepos < b[0].a_len * 512 - VSTAFS_START_DATA) 203 203 { 204 204 offset = filepos + VSTAFS_START_DATA; 205 205 extent = 0; 206 curr_len = a[0].a_len * 512 - offset - filepos;206 curr_len = b[0].a_len * 512 - offset - filepos; 207 207 } 208 208 else 209 209 { 210 ext_size = a[0].a_len * 512 - VSTAFS_START_DATA;210 ext_size = b[0].a_len * 512 - VSTAFS_START_DATA; 211 211 offset = filepos - ext_size; 212 212 extent = 1; 213 213 do 214 214 { 215 215 curr_len -= ext_size; 216 216 offset -= ext_size; 217 ext_size = a[extent+1].a_len * 512;217 ext_size = b[extent+1].a_len * 512; 218 218 } 219 219 while (extent < FILE_INFO->extents && offset>ext_size); 220 220 } … … 223 223 { 224 224 offset = VSTAFS_START_DATA; 225 225 extent = 0; 226 curr_len = a[0].a_len * 512 - offset;226 curr_len = b[0].a_len * 512 - offset; 227 227 } 228 228 229 229 curr_pos = addr; 230 230 if (curr_len > len) 231 231 curr_len = len; 232 232 233 for (curr_ext =extent;234 curr_ext < FILE_INFO->extents;235 curr_len = a[curr_ext].a_len * 512, curr_pos += curr_len, curr_ext++)233 for (curr_exten = extent; 234 curr_exten < FILE_INFO->extents; 235 curr_len = b[curr_exten].a_len * 512, curr_pos += curr_len, curr_exten++) 236 236 { 237 237 ret += curr_len; 238 238 size -= curr_len; … … 242 242 curr_len += size; 243 243 } 244 244 245 devread ( a[curr_ext].a_start,offset, curr_len, curr_pos);245 devread (b[curr_exten].a_start, offset, curr_len, curr_pos); 246 246 offset = 0; 247 247 } 248 248 -
stage2/fsys_xfs.c
diff -Naur grub-0.97.orig/stage2/fsys_xfs.c grub-0.97/stage2/fsys_xfs.c
old new 97 97 return ino & XFS_INO_MASK(XFS_INO_OFFSET_BITS); 98 98 } 99 99 100 static inline __ const__xfs_uint16_t100 static inline __attribute__((const)) xfs_uint16_t 101 101 le16 (xfs_uint16_t x) 102 102 { 103 103 __asm__("xchgb %b0,%h0" \ … … 106 106 return x; 107 107 } 108 108 109 static inline __ const__xfs_uint32_t109 static inline __attribute__((const)) xfs_uint32_t 110 110 le32 (xfs_uint32_t x) 111 111 { 112 112 #if 0 … … 122 122 return x; 123 123 } 124 124 125 static inline __ const__xfs_uint64_t125 static inline __attribute__((const)) xfs_uint64_t 126 126 le64 (xfs_uint64_t x) 127 127 { 128 128 xfs_uint32_t h = x >> 32; … … 368 368 default: 369 369 namelen = sfe->namelen; 370 370 *ino = sf_ino ((char *)sfe, namelen); 371 name = sfe->name;371 name = (char *) sfe->name; 372 372 sfe = (xfs_dir2_sf_entry_t *) 373 373 ((char *)sfe + namelen + 11 - xfs.i8param); 374 374 } -
stage2/gunzip.c
diff -Naur grub-0.97.orig/stage2/gunzip.c grub-0.97/stage2/gunzip.c
old new 277 277 * is a compressed file, and simply mark it as such. 278 278 */ 279 279 if (no_decompression 280 || grub_read ( buf, 10) != 10280 || grub_read ((char *) buf, 10) != 10 281 281 || ((*((unsigned short *) buf) != GZIP_HDR_LE) 282 282 && (*((unsigned short *) buf) != OLD_GZIP_HDR_LE))) 283 283 { … … 293 293 if (buf[2] != DEFLATED 294 294 || (buf[3] & UNSUPP_FLAGS) 295 295 || ((buf[3] & EXTRA_FIELD) 296 && (grub_read ( buf, 2) != 2296 && (grub_read ((char *) buf, 2) != 2 297 297 || bad_field (*((unsigned short *) buf)))) 298 298 || ((buf[3] & ORIG_NAME) && bad_field (-1)) 299 299 || ((buf[3] & COMMENT) && bad_field (-1))) … … 308 308 309 309 filepos = filemax - 8; 310 310 311 if (grub_read ( buf, 8) != 8)311 if (grub_read ((char *) buf, 8) != 8) 312 312 { 313 313 if (! errnum) 314 314 errnum = ERR_BAD_GZIP_HEADER; … … 485 485 486 486 #define INBUFSIZ 0x2000 487 487 488 static u chinbuf[INBUFSIZ];489 static int bufloc;488 static unsigned char inbuf[INBUFSIZ]; 489 static int bufloc; 490 490 491 491 static int 492 492 get_byte (void) … … 494 494 if (filepos == gzip_data_offset || bufloc == INBUFSIZ) 495 495 { 496 496 bufloc = 0; 497 grub_read ( inbuf, INBUFSIZ);497 grub_read ((char *) inbuf, INBUFSIZ); 498 498 } 499 499 500 500 return inbuf[bufloc++]; … … 925 925 unsigned m; /* mask for bit lengths table */ 926 926 unsigned n; /* number of lengths to get */ 927 927 unsigned nb; /* number of bit length codes */ 928 unsigned n l; /* number of literal/length codes */928 unsigned nc; /* number of literal/length codes */ 929 929 unsigned nd; /* number of distance codes */ 930 930 unsigned ll[286 + 30]; /* literal/length and distance code lengths */ 931 931 register ulg b; /* bit buffer */ … … 937 937 938 938 /* read in table lengths */ 939 939 NEEDBITS (5); 940 n l= 257 + ((unsigned) b & 0x1f); /* number of literal/length codes */940 nc = 257 + ((unsigned) b & 0x1f); /* number of literal/length codes */ 941 941 DUMPBITS (5); 942 942 NEEDBITS (5); 943 943 nd = 1 + ((unsigned) b & 0x1f); /* number of distance codes */ … … 945 945 NEEDBITS (4); 946 946 nb = 4 + ((unsigned) b & 0xf); /* number of bit length codes */ 947 947 DUMPBITS (4); 948 if (n l> 286 || nd > 30)948 if (nc > 286 || nd > 30) 949 949 { 950 950 errnum = ERR_BAD_GZIP_DATA; 951 951 return; … … 970 970 } 971 971 972 972 /* read in literal and distance code lengths */ 973 n = n l+ nd;973 n = nc + nd; 974 974 m = mask_bits[bl]; 975 975 i = l = 0; 976 976 while ((unsigned) i < n) … … 1034 1034 1035 1035 /* build the decoding tables for literal/length and distance codes */ 1036 1036 bl = lbits; 1037 if ((i = huft_build (ll, n l, 257, cplens, cplext, &tl, &bl)) != 0)1037 if ((i = huft_build (ll, nc, 257, cplens, cplext, &tl, &bl)) != 0) 1038 1038 { 1039 1039 #if 0 1040 1040 if (i == 1) … … 1045 1045 return; 1046 1046 } 1047 1047 bd = dbits; 1048 if ((i = huft_build (ll + n l, nd, 0, cpdist, cpdext, &td, &bd)) != 0)1048 if ((i = huft_build (ll + nc, nd, 0, cpdist, cpdext, &td, &bd)) != 0) 1049 1049 { 1050 1050 #if 0 1051 1051 if (i == 1) -
stage2/md5.c
diff -Naur grub-0.97.orig/stage2/md5.c grub-0.97/stage2/md5.c
old new 166 166 inputlen -= 64 - buflen; 167 167 while (inputlen >= 64) 168 168 { 169 md5_transform ( input);169 md5_transform ((unsigned char *) input); 170 170 input += 64; 171 171 inputlen -= 64; 172 172 } … … 211 211 char *p; 212 212 int saltlen; 213 213 int i, n; 214 unsignedchar alt_result[16];214 char alt_result[16]; 215 215 unsigned char *digest; 216 216 217 217 if (check) -
stage2/start_eltorito.S
diff -Naur grub-0.97.orig/stage2/start_eltorito.S grub-0.97/stage2/start_eltorito.S
old new 40 40 #define ABS(x) (x-_start+BOOTSEC_LOCATION) 41 41 42 42 #ifdef STAGE1_5 43 # define STAGE_ADDR 0x2 00043 # define STAGE_ADDR 0x2200 44 44 #else 45 # define STAGE_ADDR 0x8 00045 # define STAGE_ADDR 0x8200 46 46 #endif /* STAGE1_5 */ 47 47 48 48 /* Print message string */ … … 71 71 . = _start + 8 /* Pad to file offset 8 */ 72 72 73 73 /* This table gets filled in by mkisofs using the 74 -boot-info-table option */ 75 bi_pvd: .long 0xDEADBEEF /* LBA of primary volume descript */ 76 bi_file: .long 0xDEADBEEF /* LBA of boot file */ 77 bi_length: .long 0xDEADBEEF /* Length of boot file */ 78 bi_csum: .long 0xDEADBEEF /* Checksum of boot file */ 79 bi_reserved: .space (10*4) /* Reserved */ 74 -boot-info-table option If not, the values in this 75 table are default values that we can use to get us 76 what we need, at least under a certain set of assumptions. */ 77 bi_pvd: .long 16 /* LBA of primary volume descript */ 78 bi_file: .long 0 /* LBA of boot file */ 79 bi_length: .long 0xDEADBEEF /* Length of boot file */ 80 bi_csum: .long 0xDEADBEEF /* Checksum of boot file */ 81 bi_reserved: .space (10*4) /* Reserved */ 80 82 81 83 real_start: 82 84 xor %ax, %ax … … 92 94 /* save drive reference first thing! */ 93 95 mov %dl, ABS(BootDrive) 94 96 95 /* print a notification message on the screen */ 96 MSG(notification_string) 97 /* check if machine support IBM/MS int 13h extensions */ 98 mov $0x41, %ah 99 mov $0x55AA, %bx 100 int $0x13 101 jnc load_image 102 103 /* bios doesn't support int 13h extensions, print error messages */ 104 MSG(int13_error_string1) 105 MSG(notification_done) 106 MSG(int13_error_string2) 107 MSG(notification_done) 108 MSG(int13_error_string3) 109 MSG(notification_done) 110 /* even when bios says that it doesn't support int 13h 111 extensions, do not stop here and try to load image anyway, 112 because some bioses says that there isn't support for 113 extended functions but have the needed extended read function 114 (int 13h, function AH=42h) */ 97 115 98 116 load_image: 117 /* print a notification message on the screen */ 118 MSG(notification_string) 99 119 /* Set up boot file sector, size, load address */ 100 120 mov ABS(bi_length), %eax 101 121 add $(ISO_SECTOR_SIZE-1), %eax … … 105 125 mov %bx, %es 106 126 xor %bx, %bx 107 127 mov ABS(bi_file), %eax 128 inc %eax /* do not reload the first sector (this code) */ 129 dec %bp /* this way we have more room for code in stage1 */ 108 130 call getlinsec 109 131 mov %ds, %ax 110 132 mov %ax, %es … … 115 137 mov $ABS(firstlist - BOOTSEC_LISTSIZE), %si 116 138 mov (%si), %ebp 117 139 mov ABS(BootDrive), %dl /* this makes sure %dl is our "boot" drive */ 118 ljmp $0, $(STAGE_ADDR +SECTOR_SIZE)/* jump to main() in asm.S */140 ljmp $0, $(STAGE_ADDR) /* jump to main() in asm.S */ 119 141 120 142 /* go here when you need to stop the machine hard after an error condition */ 121 143 stop: jmp stop … … 171 193 */ 172 194 xint13: 173 195 movb $6, ABS(RetryCount) 174 pushal175 196 .try: 197 pushal 176 198 int $0x13 177 199 jc 1f 178 add $(8*4), %sp/* Clean up stack */200 popal /* Clean up stack */ 179 201 ret 180 202 1: 181 203 mov %ah, %dl /* Save error code */ … … 276 298 277 299 read_error_string: .string "Read error 0x" 278 300 301 int13_error_string1: .string "Support for IBM/MS INT 13h extensions not found" 302 int13_error_string2: .string "GRUB cannot be loaded if int 13h/function AH=42h isn't present" 303 int13_error_string3: .string "Trying to load stage 2 anyway..." 304 279 305 /* 280 306 * EBIOS disk address packet 281 307 */ … … 306 332 .word 0 307 333 .word 0 308 334 309 . = _start + SECTOR_SIZE - BOOTSEC_LISTSIZE 335 /* size of the code we can place between main body and fixed top location */ 336 . = _start + 1536 - BOOTSEC_LISTSIZE 310 337 311 338 /* fill the first data listing with the default */ 312 339 blocklist_default_start:/* this is the sector start parameter, in logical … … 321 348 #endif 322 349 blocklist_default_seg: /* this is the segment of the starting address 323 350 to load the data into */ 324 .word (STAGE_ADDR + SECTOR_SIZE) >> 4351 .word (STAGE_ADDR) >> 4 325 352 326 353 firstlist: /* this label has to be after the list data!!! */ 354 355 /* this is a workaround to allow more code to be added in stage1, 356 it allows more code to be added for this stage, but for this 357 we can't reload the first sector. So we have to align the code 358 to ISO_SECTOR_SIZE. */ 359 . = _start + ISO_SECTOR_SIZE -
util/grub-install.in
diff -Naur grub-0.97.orig/util/grub-install.in grub-0.97/util/grub-install.in
old new 336 336 # Create a safe temporary file. 337 337 test -n "$mklog" && log_file=`$mklog` 338 338 339 # Before all invocations of the grub shell, call sync to make sure 340 # the raw device is in sync with any bufferring in filesystems. 341 sync 342 339 343 $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file 340 344 quit 341 345 EOF … … 450 454 # Create a safe temporary file. 451 455 test -n "$mklog" && log_file=`$mklog` 452 456 457 # Before all invocations of the grub shell, call sync to make sure 458 # the raw device is in sync with any bufferring in filesystems. 459 sync 460 453 461 # Now perform the installation. 454 462 $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file 455 463 root $root_drive
Note:
See TracBrowser
for help on using the repository browser.