source: patches/grub-0.97-disk_geometry-1.patch@ 2eb2779

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 2eb2779 was 94053a6, checked in by Jim Gifford <clfs@…>, 19 years ago

Added: grub-0.97-disk_geometry-1.patch

  • Property mode set to 100644
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  
    34853485echo "$as_me:$LINENO: result: $size_flag" >&5
    34863486echo "${ECHO_T}$size_flag" >&6
    34873487    if test "x$size_flag" = xyes; then
    3488       STAGE2_CFLAGS="-Os"
     3488      STAGE2_CFLAGS="-Os -fno-strict-aliasing"
    34893489    else
    3490       STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
     3490      STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops"
    34913491    fi
    34923492    # OpenBSD has a GCC extension for protecting applications from
    34933493    # 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  
    9393      CFLAGS=$saved_CFLAGS
    9494    ])
    9595    if test "x$size_flag" = xyes; then
    96       STAGE2_CFLAGS="-Os"
     96      STAGE2_CFLAGS="-Os -fno-strict-aliasing"
    9797    else
    98       STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
     98      STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops"
    9999    fi
    100100    # OpenBSD has a GCC extension for protecting applications from
    101101    # 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  
    131131#include <shared.h>
    132132#include <device.h>
    133133
     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 */
     141static 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
     152struct 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
     166typedef 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
     182static void
     183get_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
     220static 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
     240static 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
    134280/* Get the geometry of a drive DRIVE.  */
    135281void
    136282get_drive_geometry (struct geometry *geom, char **map, int drive)
     
    151297#if defined(__linux__)
    152298  /* Linux */
    153299  {
    154     struct hd_geometry hdg;
    155300    unsigned long nr;
    156    
    157     if (ioctl (fd, HDIO_GETGEO, &hdg))
    158       goto fail;
    159301
    160302    if (ioctl (fd, BLKGETSIZE, &nr))
    161303      goto fail;
    162304   
    163305    /* Got the geometry, so save it. */
    164     geom->cylinders = hdg.cylinders;
    165     geom->heads = hdg.heads;
    166     geom->sectors = hdg.sectors;
    167306    geom->total_sectors = nr;
    168    
     307    get_linux_geometry(fd, geom);
     308    if (!geom->heads && !geom->cylinders && !geom->sectors)
     309        goto fail;
    169310    goto success;
    170311  }
    171312
     
    844985{
    845986  char dev[PATH_MAX];   /* XXX */
    846987  int fd;
     988  off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
    847989 
    848990  if ((partition & 0x00FF00) != 0x00FF00)
    849991    {
     
    8701012      errnum = ERR_NO_PART;
    8711013      return 0;
    8721014    }
    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);
    8831015
    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 #else
    892   {
    893     off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
    8941016
    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    }
    9021022 
    9031023  if (write (fd, buf, size * SECTOR_SIZE) != (size * SECTOR_SIZE))
    9041024    {
  • stage2/Makefile.am

    diff -Naur grub-0.97.orig/stage2/Makefile.am grub-0.97/stage2/Makefile.am
    old new  
    2424        -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
    2525        -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
    2626        -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
    2829
    2930# Stage 2 and Stage 1.5's.
    3031pkglibdir = $(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  
    5555  pu;
    5656  /* presuming that MULTIBOOT_SEARCH is large enough to encompass an
    5757     executable header */
    58   unsigned char buffer[MULTIBOOT_SEARCH];
     58  char buffer[MULTIBOOT_SEARCH];
    5959
    6060  /* sets the header pointer to point to the beginning of the
    6161     buffer by default */
     
    9898  /* ELF loading supported if multiboot, FreeBSD and NetBSD.  */
    9999  if ((type == KERNEL_TYPE_MULTIBOOT
    100100       || pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD
    101        || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
     101       || grub_strcmp ((char *) pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
    102102       || suggested_type == KERNEL_TYPE_NETBSD)
    103103      && len > sizeof (Elf32_Ehdr)
    104104      && BOOTABLE_I386_ELF ((*((Elf32_Ehdr *) buffer))))
     
    824824    moveto = (mbi.mem_upper + 0x400) << 10;
    825825 
    826826  moveto = (moveto - len) & 0xfffff000;
     827#if 0
    827828  max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203
    828829              ? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS);
     830#else
     831  max_addr = LINUX_INITRD_MAX_ADDRESS;
     832#endif
    829833  if (moveto + len >= max_addr)
    830834    moveto = (max_addr - len) & 0xfffff000;
    831835 
  • stage2/disk_io.c

    diff -Naur grub-0.97.orig/stage2/disk_io.c grub-0.97/stage2/disk_io.c
    old new  
    127127int filepos;
    128128int filemax;
    129129
    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 */
     137static __inline__ unsigned long
     138ffz (unsigned long word)
    132139{
    133   asm volatile ("bsfl %1,%0"
    134                 : "=r" (word)
    135                 : "r" (word));
     140  __asm__ ("bsfl %1,%0"
     141:          "=r" (word)
     142:          "r" (~word));
    136143  return word;
    137144}
    138145
  • stage2/freebsd.h

    diff -Naur grub-0.97.orig/stage2/freebsd.h grub-0.97/stage2/freebsd.h
    old new  
    7878struct bootinfo
    7979  {
    8080    unsigned int bi_version;
    81     unsigned char *bi_kernelname;
     81    char *bi_kernelname;
    8282    struct nfs_diskless *bi_nfs_diskless;
    8383    /* End of fields that are always present. */
    8484#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  
    5454
    5555#define FAT_CACHE_SIZE 2048
    5656
     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 */
    5764static __inline__ unsigned long
    58 log2 (unsigned long word)
     65ffz (unsigned long word)
    5966{
    6067  __asm__ ("bsfl %1,%0"
    61            : "=r" (word)
    62            : "r" (word));
     68:          "=r" (word)
     69:          "r" (~word));
    6370  return word;
    6471}
    6572
  • stage2/fsys_iso9660.c

    diff -Naur grub-0.97.orig/stage2/fsys_iso9660.c grub-0.97/stage2/fsys_iso9660.c
    old new  
    5555#define RRCONT_BUF      ((unsigned char *)(FSYS_BUF + 6144))
    5656#define NAME_BUF        ((unsigned char *)(FSYS_BUF + 8192))
    5757
     58#define log2(n) ffz(~(n))
    5859
    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 */
     65static __inline__ unsigned long
     66ffz (unsigned long word)
    6167{
    62   asm volatile ("bsfl %1,%0"
    63                 :          "=r" (word)
    64                 :          "r" (word));
     68  __asm__ ("bsfl %1,%0"
     69:          "=r" (word)
     70:          "r" (~word));
    6571  return word;
    6672}
    6773
     
    120126        break;
    121127      /* check ISO_VD_PRIMARY and ISO_STANDARD_ID */
    122128      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)))
    124130        {
    125131          ISO_SUPER->vol_sector = sector;
    126132          INODE->file_start = 0;
     
    175181          for (; idr->length.l > 0;
    176182               idr = (struct iso_directory_record *)((char *)idr + idr->length.l) )
    177183            {
    178               const char *name = idr->name;
     184              const u_int8_t *name = idr->name;
    179185              unsigned int name_len = idr->name_len.l;
    180186
    181187              file_type = (idr->flags.l & 2) ? ISO_DIRECTORY : ISO_REGULAR;
     
    198204              rr_len = (idr->length.l - idr->name_len.l
    199205                        - sizeof(struct iso_directory_record)
    200206                        + sizeof(idr->name));
    201               rr_ptr.ptr = ((unsigned char *)idr + idr->name_len.l
     207              rr_ptr.ptr = ((char *)idr + idr->name_len.l
    202208                            + sizeof(struct iso_directory_record)
    203209                            - sizeof(idr->name));
    204210              if (rr_ptr.i & 1)
     
    331337                          memcpy(NAME_BUF, name, name_len);
    332338                          name = NAME_BUF;
    333339                        }
    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;
    335341                      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))
    337343                        {
    338344                          errnum = 0;   /* this is not fatal. */
    339345                          break;
     
    344350
    345351              filemax = MAXINT;
    346352              if (name_len >= pathlen
    347                   && !memcmp(name, dirname, pathlen))
     353                  && !memcmp((char *) name, dirname, pathlen))
    348354                {
    349355                  if (dirname[pathlen] == '/' || !print_possibilities)
    350356                    {
     
    381387                        print_possibilities = -print_possibilities;
    382388                      memcpy(NAME_BUF, name, name_len);
    383389                      NAME_BUF[name_len] = '\0';
    384                       print_a_completion (NAME_BUF);
     390                      print_a_completion ((char *) NAME_BUF);
    385391#endif
    386392                    }
    387393                }
  • stage2/fsys_reiserfs.c

    diff -Naur grub-0.97.orig/stage2/fsys_reiserfs.c grub-0.97/stage2/fsys_reiserfs.c
    old new  
    365365#define JOURNAL_START    ((__u32 *) (INFO + 1))
    366366#define JOURNAL_END      ((__u32 *) (FSYS_BUF + FSYS_BUFLEN))
    367367
     368#define log2(n) ffz(~(n))
    368369
     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 */
    369375static __inline__ unsigned long
    370 log2 (unsigned long word)
     376ffz (unsigned long word)
    371377{
    372378  __asm__ ("bsfl %1,%0"
    373            : "=r" (word)
    374            : "r" (word));
     379:          "=r" (word)
     380:          "r" (~word));
    375381  return word;
    376382}
    377383
  • stage2/fsys_vstafs.c

    diff -Naur grub-0.97.orig/stage2/fsys_vstafs.c grub-0.97/stage2/fsys_vstafs.c
    old new  
    186186int
    187187vstafs_read (char *addr, int len)
    188188{
    189   struct alloc *a;
     189  struct alloc *b;
    190190  int size, ret = 0, offset, curr_len = 0;
    191   int curr_ext;
     191  int curr_exten;
    192192  char extent;
    193193  int ext_size;
    194194  char *curr_pos;
    195195 
    196196  get_file_info (f_sector);
    197197  size = FILE_INFO->len-VSTAFS_START_DATA;
    198   a = FILE_INFO->blocks;
     198  b = FILE_INFO->blocks;
    199199 
    200200  if (filepos > 0)
    201201    {
    202       if (filepos < a[0].a_len * 512 - VSTAFS_START_DATA)
     202      if (filepos < b[0].a_len * 512 - VSTAFS_START_DATA)
    203203        {
    204204          offset = filepos + VSTAFS_START_DATA;
    205205          extent = 0;
    206           curr_len = a[0].a_len * 512 - offset - filepos;
     206          curr_len = b[0].a_len * 512 - offset - filepos;
    207207        }
    208208      else
    209209        {
    210           ext_size = a[0].a_len * 512 - VSTAFS_START_DATA;
     210          ext_size = b[0].a_len * 512 - VSTAFS_START_DATA;
    211211          offset = filepos - ext_size;
    212212          extent = 1;
    213213          do
    214214            {
    215215              curr_len -= ext_size;
    216216              offset -= ext_size;
    217               ext_size = a[extent+1].a_len * 512;
     217              ext_size = b[extent+1].a_len * 512;
    218218            }
    219219          while (extent < FILE_INFO->extents && offset>ext_size);
    220220        }
     
    223223    {
    224224      offset = VSTAFS_START_DATA;
    225225      extent = 0;
    226       curr_len = a[0].a_len * 512 - offset;
     226      curr_len = b[0].a_len * 512 - offset;
    227227    }
    228228 
    229229  curr_pos = addr;
    230230  if (curr_len > len)
    231231    curr_len = len;
    232232 
    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++)
    236236    {
    237237      ret += curr_len;
    238238      size -= curr_len;
     
    242242          curr_len += size;
    243243        }
    244244     
    245       devread (a[curr_ext].a_start,offset, curr_len, curr_pos);
     245      devread (b[curr_exten].a_start, offset, curr_len, curr_pos);
    246246      offset = 0;
    247247    }
    248248 
  • stage2/fsys_xfs.c

    diff -Naur grub-0.97.orig/stage2/fsys_xfs.c grub-0.97/stage2/fsys_xfs.c
    old new  
    9797        return ino & XFS_INO_MASK(XFS_INO_OFFSET_BITS);
    9898}
    9999
    100 static inline __const__ xfs_uint16_t
     100static inline __attribute__((const)) xfs_uint16_t
    101101le16 (xfs_uint16_t x)
    102102{
    103103        __asm__("xchgb %b0,%h0" \
     
    106106                return x;
    107107}
    108108
    109 static inline __const__ xfs_uint32_t
     109static inline __attribute__((const)) xfs_uint32_t
    110110le32 (xfs_uint32_t x)
    111111{
    112112#if 0
     
    122122        return x;
    123123}
    124124
    125 static inline __const__ xfs_uint64_t
     125static inline __attribute__((const)) xfs_uint64_t
    126126le64 (xfs_uint64_t x)
    127127{
    128128        xfs_uint32_t h = x >> 32;
     
    368368                default:
    369369                        namelen = sfe->namelen;
    370370                        *ino = sf_ino ((char *)sfe, namelen);
    371                         name = sfe->name;
     371                        name = (char *) sfe->name;
    372372                        sfe = (xfs_dir2_sf_entry_t *)
    373373                                  ((char *)sfe + namelen + 11 - xfs.i8param);
    374374                }
  • stage2/gunzip.c

    diff -Naur grub-0.97.orig/stage2/gunzip.c grub-0.97/stage2/gunzip.c
    old new  
    277277   *  is a compressed file, and simply mark it as such.
    278278   */
    279279  if (no_decompression
    280       || grub_read (buf, 10) != 10
     280      || grub_read ((char *) buf, 10) != 10
    281281      || ((*((unsigned short *) buf) != GZIP_HDR_LE)
    282282          && (*((unsigned short *) buf) != OLD_GZIP_HDR_LE)))
    283283    {
     
    293293  if (buf[2] != DEFLATED
    294294      || (buf[3] & UNSUPP_FLAGS)
    295295      || ((buf[3] & EXTRA_FIELD)
    296           && (grub_read (buf, 2) != 2
     296          && (grub_read ((char *) buf, 2) != 2
    297297              || bad_field (*((unsigned short *) buf))))
    298298      || ((buf[3] & ORIG_NAME) && bad_field (-1))
    299299      || ((buf[3] & COMMENT) && bad_field (-1)))
     
    308308 
    309309  filepos = filemax - 8;
    310310 
    311   if (grub_read (buf, 8) != 8)
     311  if (grub_read ((char *) buf, 8) != 8)
    312312    {
    313313      if (! errnum)
    314314        errnum = ERR_BAD_GZIP_HEADER;
     
    485485
    486486#define INBUFSIZ  0x2000
    487487
    488 static uch inbuf[INBUFSIZ];
    489 static int bufloc;
     488static unsigned char inbuf[INBUFSIZ];
     489static int  bufloc;
    490490
    491491static int
    492492get_byte (void)
     
    494494  if (filepos == gzip_data_offset || bufloc == INBUFSIZ)
    495495    {
    496496      bufloc = 0;
    497       grub_read (inbuf, INBUFSIZ);
     497      grub_read ((char *) inbuf, INBUFSIZ);
    498498    }
    499499
    500500  return inbuf[bufloc++];
     
    925925  unsigned m;                   /* mask for bit lengths table */
    926926  unsigned n;                   /* number of lengths to get */
    927927  unsigned nb;                  /* number of bit length codes */
    928   unsigned nl;                  /* number of literal/length codes */
     928  unsigned nc;                  /* number of literal/length codes */
    929929  unsigned nd;                  /* number of distance codes */
    930930  unsigned ll[286 + 30];        /* literal/length and distance code lengths */
    931931  register ulg b;               /* bit buffer */
     
    937937
    938938  /* read in table lengths */
    939939  NEEDBITS (5);
    940   nl = 257 + ((unsigned) b & 0x1f);     /* number of literal/length codes */
     940  nc = 257 + ((unsigned) b & 0x1f);     /* number of literal/length codes */
    941941  DUMPBITS (5);
    942942  NEEDBITS (5);
    943943  nd = 1 + ((unsigned) b & 0x1f);       /* number of distance codes */
     
    945945  NEEDBITS (4);
    946946  nb = 4 + ((unsigned) b & 0xf);        /* number of bit length codes */
    947947  DUMPBITS (4);
    948   if (nl > 286 || nd > 30)
     948  if (nc > 286 || nd > 30)
    949949    {
    950950      errnum = ERR_BAD_GZIP_DATA;
    951951      return;
     
    970970    }
    971971
    972972  /* read in literal and distance code lengths */
    973   n = nl + nd;
     973  n = nc + nd;
    974974  m = mask_bits[bl];
    975975  i = l = 0;
    976976  while ((unsigned) i < n)
     
    10341034
    10351035  /* build the decoding tables for literal/length and distance codes */
    10361036  bl = lbits;
    1037   if ((i = huft_build (ll, nl, 257, cplens, cplext, &tl, &bl)) != 0)
     1037  if ((i = huft_build (ll, nc, 257, cplens, cplext, &tl, &bl)) != 0)
    10381038    {
    10391039#if 0
    10401040      if (i == 1)
     
    10451045      return;
    10461046    }
    10471047  bd = dbits;
    1048   if ((i = huft_build (ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0)
     1048  if ((i = huft_build (ll + nc, nd, 0, cpdist, cpdext, &td, &bd)) != 0)
    10491049    {
    10501050#if 0
    10511051      if (i == 1)
  • stage2/md5.c

    diff -Naur grub-0.97.orig/stage2/md5.c grub-0.97/stage2/md5.c
    old new  
    166166  inputlen -= 64 - buflen;
    167167  while (inputlen >= 64)
    168168    {
    169       md5_transform (input);
     169      md5_transform ((unsigned char *) input);
    170170      input += 64;
    171171      inputlen -= 64;
    172172    }
     
    211211  char *p;
    212212  int saltlen;
    213213  int i, n;
    214   unsigned char alt_result[16];
     214  char alt_result[16];
    215215  unsigned char *digest;
    216216
    217217  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  
    4040#define ABS(x)                  (x-_start+BOOTSEC_LOCATION)
    4141
    4242#ifdef STAGE1_5
    43 # define STAGE_ADDR             0x2000
     43# define STAGE_ADDR             0x2200
    4444#else
    45 # define STAGE_ADDR             0x8000
     45# define STAGE_ADDR             0x8200
    4646#endif /* STAGE1_5 */
    4747
    4848        /* Print message string */
     
    7171        . = _start + 8                      /* Pad to file offset 8 */
    7272
    7373                /* 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. */
     77bi_pvd:         .long 16                /* LBA of primary volume descript */
     78bi_file:        .long 0                 /* LBA of boot file */
     79bi_length:      .long 0xDEADBEEF        /* Length of boot file */
     80bi_csum:        .long 0xDEADBEEF        /* Checksum of boot file */
     81bi_reserved:    .space (10*4)           /* Reserved */
    8082
    8183real_start:
    8284        xor     %ax, %ax
     
    9294        /* save drive reference first thing! */
    9395        mov     %dl, ABS(BootDrive)
    9496
    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) */
    97115
    98116load_image:
     117        /* print a notification message on the screen */
     118        MSG(notification_string)
    99119        /* Set up boot file sector, size, load address */
    100120        mov     ABS(bi_length), %eax
    101121        add     $(ISO_SECTOR_SIZE-1), %eax
     
    105125        mov     %bx, %es
    106126        xor     %bx, %bx
    107127        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 */
    108130        call    getlinsec
    109131        mov     %ds, %ax
    110132        mov     %ax, %es
     
    115137        mov     $ABS(firstlist - BOOTSEC_LISTSIZE), %si
    116138        mov     (%si), %ebp
    117139        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 */
    119141
    120142/* go here when you need to stop the machine hard after an error condition */
    121143stop:   jmp     stop
     
    171193 */
    172194xint13:
    173195        movb    $6, ABS(RetryCount)
    174         pushal
    175196.try:
     197        pushal
    176198        int     $0x13
    177199        jc      1f
    178         add     $(8*4), %sp                 /* Clean up stack */
     200        popal                               /* Clean up stack */
    179201        ret
    1802021:
    181203        mov     %ah, %dl                    /* Save error code */
     
    276298
    277299read_error_string:      .string "Read error 0x"
    278300
     301int13_error_string1:    .string "Support for IBM/MS INT 13h extensions not found"
     302int13_error_string2:    .string "GRUB cannot be loaded if int 13h/function AH=42h isn't present"
     303int13_error_string3:    .string "Trying to load stage 2 anyway..."
     304
    279305/*
    280306 * EBIOS disk address packet
    281307 */
     
    306332        .word 0
    307333        .word 0
    308334
    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
    310337
    311338        /* fill the first data listing with the default */
    312339blocklist_default_start:/* this is the sector start parameter, in logical
     
    321348#endif
    322349blocklist_default_seg:  /* this is the segment of the starting address
    323350                           to load the data into */
    324         .word (STAGE_ADDR + SECTOR_SIZE) >> 4
     351        .word (STAGE_ADDR) >> 4
    325352
    326353firstlist:      /* 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  
    336336    # Create a safe temporary file.
    337337    test -n "$mklog" && log_file=`$mklog`
    338338
     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 
    339343    $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
    340344quit
    341345EOF
     
    450454# Create a safe temporary file.
    451455test -n "$mklog" && log_file=`$mklog`
    452456
     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.
     459sync
     460
    453461# Now perform the installation.
    454462$grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
    455463root $root_drive
Note: See TracBrowser for help on using the repository browser.