Print this page
grub patch

Split Close
Expand all
Collapse all
          --- old/grub/grub-core/partmap/sunpc.c
          +++ new/grub/grub-core/partmap/sunpc.c
↓ open down ↓ 66 lines elided ↑ open up ↑
  67   67  }
  68   68  
  69   69  static grub_err_t
  70   70  sun_pc_partition_map_iterate (grub_disk_t disk,
  71   71                                int (*hook) (grub_disk_t disk,
  72   72                                             const grub_partition_t partition))
  73   73  {
  74   74    grub_partition_t p;
  75   75    union
  76   76    {
  77      -    struct grub_sun_pc_block sun;
       77 +    struct grub_sun_pc_block sunb;
  78   78      grub_uint16_t raw[0];
  79   79    } block;
  80   80    int partnum;
  81   81    grub_err_t err;
  82   82  
  83   83    p = (grub_partition_t) grub_zalloc (sizeof (struct grub_partition));
  84   84    if (! p)
  85   85      return grub_errno;
  86   86  
  87   87    p->partmap = &grub_sun_pc_partition_map;
  88   88    err = grub_disk_read (disk, 1, 0, sizeof (struct grub_sun_pc_block), &block);
  89   89    if (err)
  90   90      {
  91   91        grub_free (p);
  92   92        return err;
  93   93      }
  94   94    
  95      -  if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.sun.magic))
       95 +  if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.sunb.magic))
  96   96      {
  97   97        grub_free (p);
  98   98        return grub_error (GRUB_ERR_BAD_PART_TABLE, 
  99   99                           "not a sun_pc partition table");
 100  100      }
 101  101  
 102  102    if (! grub_sun_is_valid (block.raw))
 103  103      {
 104  104        grub_free (p);
 105  105        return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
 106  106      }
 107  107  
 108  108    /* Maybe another error value would be better, because partition
 109  109       table _is_ recognized but invalid.  */
 110  110    for (partnum = 0; partnum < GRUB_PARTMAP_SUN_PC_MAX_PARTS; partnum++)
 111  111      {
 112  112        struct grub_sun_pc_partition_descriptor *desc;
 113  113  
 114      -      if (block.sun.partitions[partnum].id == 0
 115      -          || block.sun.partitions[partnum].id
      114 +      if (block.sunb.partitions[partnum].id == 0
      115 +          || block.sunb.partitions[partnum].id
 116  116            == GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID)
 117  117          continue;
 118  118  
 119      -      desc = &block.sun.partitions[partnum];
      119 +      desc = &block.sunb.partitions[partnum];
 120  120        p->start = grub_le_to_cpu32 (desc->start_sector);
 121  121        p->len = grub_le_to_cpu32 (desc->num_sectors);
 122  122        p->number = partnum;
 123  123        if (p->len)
 124  124          {
 125  125            if (hook (disk, p))
 126  126              partnum = GRUB_PARTMAP_SUN_PC_MAX_PARTS;
 127  127          }
 128  128      }
 129  129  
↓ open down ↓ 22 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX