~ilya-yanok/ubuntu/precise/grub2/fix-for-948716

« back to all changes in this revision

Viewing changes to partmap/apple.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Millan
  • Date: 2009-07-25 19:00:53 UTC
  • mfrom: (1.6.3 upstream)
  • mto: (17.4.13 sid)
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: james.westby@ubuntu.com-20090725190053-uv3lm6ya3zxs77ep
ImportĀ upstreamĀ versionĀ 1.96+20090725

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
  /* The magic number to identify the partition map, it should have
31
31
     the value `0x4552'.  */
32
32
  grub_uint16_t magic;
33
 
  grub_uint16_t blocksize;
34
33
};
35
34
 
36
35
struct grub_apple_part
106
105
  struct grub_apple_header aheader;
107
106
  struct grub_apple_part apart;
108
107
  struct grub_disk raw;
109
 
  int partno = 0, partnum = 0;
110
 
  unsigned pos;
 
108
  int partno = 0;
 
109
  unsigned pos = GRUB_DISK_SECTOR_SIZE;
111
110
 
112
111
  /* Enforce raw disk access.  */
113
112
  raw = *disk;
127
126
      goto fail;
128
127
    }
129
128
 
130
 
  pos = grub_be_to_cpu16 (aheader.blocksize);
131
 
 
132
 
  do
 
129
  for (;;)
133
130
    {
134
131
      if (grub_disk_read (&raw, pos / GRUB_DISK_SECTOR_SIZE,
135
132
                          pos % GRUB_DISK_SECTOR_SIZE,
145
142
          break;
146
143
        }
147
144
 
148
 
      if (partnum == 0)
149
 
        partnum = grub_be_to_cpu32 (apart.partmap_size);
150
 
 
151
 
      part.start = ((grub_disk_addr_t) grub_be_to_cpu32 (apart.first_phys_block)
152
 
                    * grub_be_to_cpu16 (aheader.blocksize))
153
 
        / GRUB_DISK_SECTOR_SIZE;
154
 
      part.len = ((grub_disk_addr_t) grub_be_to_cpu32 (apart.blockcnt)
155
 
                  * grub_be_to_cpu16 (aheader.blocksize))
156
 
        / GRUB_DISK_SECTOR_SIZE;
 
145
      part.start = grub_be_to_cpu32 (apart.first_phys_block);
 
146
      part.len = grub_be_to_cpu32 (apart.blockcnt);
157
147
      part.offset = pos;
158
148
      part.index = partno;
159
149
 
166
156
      if (hook (disk, &part))
167
157
        return grub_errno;
168
158
 
169
 
      pos += grub_be_to_cpu16 (aheader.blocksize);
 
159
      if (grub_be_to_cpu32 (apart.first_phys_block)
 
160
          == GRUB_DISK_SECTOR_SIZE * 2)
 
161
        return 0;
 
162
 
 
163
      pos += sizeof (struct grub_apple_part);
170
164
      partno++;
171
165
    }
172
 
  while (partno < partnum);
173
166
 
174
 
  if (partno != 0)
 
167
  if (pos != GRUB_DISK_SECTOR_SIZE)
175
168
    return 0;
176
169
 
177
170
 fail:
241
234
/* Partition map type.  */
242
235
static struct grub_partition_map grub_apple_partition_map =
243
236
  {
244
 
    .name = "part_apple",
 
237
    .name = "apple_partition_map",
245
238
    .iterate = apple_partition_map_iterate,
246
239
    .probe = apple_partition_map_probe,
247
240
    .get_name = apple_partition_map_get_name