diff options
Diffstat (limited to 'fs/partitions')
-rw-r--r-- | fs/partitions/check.c | 40 | ||||
-rw-r--r-- | fs/partitions/efi.c | 42 | ||||
-rw-r--r-- | fs/partitions/ldm.c | 70 | ||||
-rw-r--r-- | fs/partitions/ldm.h | 5 |
4 files changed, 83 insertions, 74 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 6149e4b58c88..7d6b34e201db 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c | |||
@@ -344,18 +344,18 @@ static ssize_t whole_disk_show(struct device *dev, | |||
344 | static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, | 344 | static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, |
345 | whole_disk_show, NULL); | 345 | whole_disk_show, NULL); |
346 | 346 | ||
347 | void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, int flags) | 347 | int add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, int flags) |
348 | { | 348 | { |
349 | struct hd_struct *p; | 349 | struct hd_struct *p; |
350 | int err; | 350 | int err; |
351 | 351 | ||
352 | p = kzalloc(sizeof(*p), GFP_KERNEL); | 352 | p = kzalloc(sizeof(*p), GFP_KERNEL); |
353 | if (!p) | 353 | if (!p) |
354 | return; | 354 | return -ENOMEM; |
355 | 355 | ||
356 | if (!init_part_stats(p)) { | 356 | if (!init_part_stats(p)) { |
357 | kfree(p); | 357 | err = -ENOMEM; |
358 | return; | 358 | goto out0; |
359 | } | 359 | } |
360 | p->start_sect = start; | 360 | p->start_sect = start; |
361 | p->nr_sects = len; | 361 | p->nr_sects = len; |
@@ -378,15 +378,31 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, | |||
378 | 378 | ||
379 | /* delay uevent until 'holders' subdir is created */ | 379 | /* delay uevent until 'holders' subdir is created */ |
380 | p->dev.uevent_suppress = 1; | 380 | p->dev.uevent_suppress = 1; |
381 | device_add(&p->dev); | 381 | err = device_add(&p->dev); |
382 | if (err) | ||
383 | goto out1; | ||
382 | partition_sysfs_add_subdir(p); | 384 | partition_sysfs_add_subdir(p); |
383 | p->dev.uevent_suppress = 0; | 385 | p->dev.uevent_suppress = 0; |
384 | if (flags & ADDPART_FLAG_WHOLEDISK) | 386 | if (flags & ADDPART_FLAG_WHOLEDISK) { |
385 | err = device_create_file(&p->dev, &dev_attr_whole_disk); | 387 | err = device_create_file(&p->dev, &dev_attr_whole_disk); |
388 | if (err) | ||
389 | goto out2; | ||
390 | } | ||
386 | 391 | ||
387 | /* suppress uevent if the disk supresses it */ | 392 | /* suppress uevent if the disk supresses it */ |
388 | if (!disk->dev.uevent_suppress) | 393 | if (!disk->dev.uevent_suppress) |
389 | kobject_uevent(&p->dev.kobj, KOBJ_ADD); | 394 | kobject_uevent(&p->dev.kobj, KOBJ_ADD); |
395 | |||
396 | return 0; | ||
397 | |||
398 | out2: | ||
399 | device_del(&p->dev); | ||
400 | out1: | ||
401 | put_device(&p->dev); | ||
402 | free_part_stats(p); | ||
403 | out0: | ||
404 | kfree(p); | ||
405 | return err; | ||
390 | } | 406 | } |
391 | 407 | ||
392 | /* Not exported, helper to add_disk(). */ | 408 | /* Not exported, helper to add_disk(). */ |
@@ -401,7 +417,7 @@ void register_disk(struct gendisk *disk) | |||
401 | disk->dev.parent = disk->driverfs_dev; | 417 | disk->dev.parent = disk->driverfs_dev; |
402 | disk->dev.devt = MKDEV(disk->major, disk->first_minor); | 418 | disk->dev.devt = MKDEV(disk->major, disk->first_minor); |
403 | 419 | ||
404 | strlcpy(disk->dev.bus_id, disk->disk_name, KOBJ_NAME_LEN); | 420 | strlcpy(disk->dev.bus_id, disk->disk_name, BUS_ID_SIZE); |
405 | /* ewww... some of these buggers have / in the name... */ | 421 | /* ewww... some of these buggers have / in the name... */ |
406 | s = strchr(disk->dev.bus_id, '/'); | 422 | s = strchr(disk->dev.bus_id, '/'); |
407 | if (s) | 423 | if (s) |
@@ -483,10 +499,16 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) | |||
483 | if (!size) | 499 | if (!size) |
484 | continue; | 500 | continue; |
485 | if (from + size > get_capacity(disk)) { | 501 | if (from + size > get_capacity(disk)) { |
486 | printk(" %s: p%d exceeds device capacity\n", | 502 | printk(KERN_ERR " %s: p%d exceeds device capacity\n", |
487 | disk->disk_name, p); | 503 | disk->disk_name, p); |
504 | continue; | ||
505 | } | ||
506 | res = add_partition(disk, p, from, size, state->parts[p].flags); | ||
507 | if (res) { | ||
508 | printk(KERN_ERR " %s: p%d could not be added: %d\n", | ||
509 | disk->disk_name, p, -res); | ||
510 | continue; | ||
488 | } | 511 | } |
489 | add_partition(disk, p, from, size, state->parts[p].flags); | ||
490 | #ifdef CONFIG_BLK_DEV_MD | 512 | #ifdef CONFIG_BLK_DEV_MD |
491 | if (state->parts[p].flags & ADDPART_FLAG_RAID) | 513 | if (state->parts[p].flags & ADDPART_FLAG_RAID) |
492 | md_autodetect_dev(bdev->bd_dev+p); | 514 | md_autodetect_dev(bdev->bd_dev+p); |
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c index e7b07006bc41..038a6022152f 100644 --- a/fs/partitions/efi.c +++ b/fs/partitions/efi.c | |||
@@ -95,13 +95,6 @@ | |||
95 | #include "check.h" | 95 | #include "check.h" |
96 | #include "efi.h" | 96 | #include "efi.h" |
97 | 97 | ||
98 | #undef EFI_DEBUG | ||
99 | #ifdef EFI_DEBUG | ||
100 | #define Dprintk(x...) printk(KERN_DEBUG x) | ||
101 | #else | ||
102 | #define Dprintk(x...) | ||
103 | #endif | ||
104 | |||
105 | /* This allows a kernel command line option 'gpt' to override | 98 | /* This allows a kernel command line option 'gpt' to override |
106 | * the test for invalid PMBR. Not __initdata because reloading | 99 | * the test for invalid PMBR. Not __initdata because reloading |
107 | * the partition tables happens after init too. | 100 | * the partition tables happens after init too. |
@@ -305,10 +298,10 @@ is_gpt_valid(struct block_device *bdev, u64 lba, | |||
305 | 298 | ||
306 | /* Check the GUID Partition Table signature */ | 299 | /* Check the GUID Partition Table signature */ |
307 | if (le64_to_cpu((*gpt)->signature) != GPT_HEADER_SIGNATURE) { | 300 | if (le64_to_cpu((*gpt)->signature) != GPT_HEADER_SIGNATURE) { |
308 | Dprintk("GUID Partition Table Header signature is wrong:" | 301 | pr_debug("GUID Partition Table Header signature is wrong:" |
309 | "%lld != %lld\n", | 302 | "%lld != %lld\n", |
310 | (unsigned long long)le64_to_cpu((*gpt)->signature), | 303 | (unsigned long long)le64_to_cpu((*gpt)->signature), |
311 | (unsigned long long)GPT_HEADER_SIGNATURE); | 304 | (unsigned long long)GPT_HEADER_SIGNATURE); |
312 | goto fail; | 305 | goto fail; |
313 | } | 306 | } |
314 | 307 | ||
@@ -318,9 +311,8 @@ is_gpt_valid(struct block_device *bdev, u64 lba, | |||
318 | crc = efi_crc32((const unsigned char *) (*gpt), le32_to_cpu((*gpt)->header_size)); | 311 | crc = efi_crc32((const unsigned char *) (*gpt), le32_to_cpu((*gpt)->header_size)); |
319 | 312 | ||
320 | if (crc != origcrc) { | 313 | if (crc != origcrc) { |
321 | Dprintk | 314 | pr_debug("GUID Partition Table Header CRC is wrong: %x != %x\n", |
322 | ("GUID Partition Table Header CRC is wrong: %x != %x\n", | 315 | crc, origcrc); |
323 | crc, origcrc); | ||
324 | goto fail; | 316 | goto fail; |
325 | } | 317 | } |
326 | (*gpt)->header_crc32 = cpu_to_le32(origcrc); | 318 | (*gpt)->header_crc32 = cpu_to_le32(origcrc); |
@@ -328,9 +320,9 @@ is_gpt_valid(struct block_device *bdev, u64 lba, | |||
328 | /* Check that the my_lba entry points to the LBA that contains | 320 | /* Check that the my_lba entry points to the LBA that contains |
329 | * the GUID Partition Table */ | 321 | * the GUID Partition Table */ |
330 | if (le64_to_cpu((*gpt)->my_lba) != lba) { | 322 | if (le64_to_cpu((*gpt)->my_lba) != lba) { |
331 | Dprintk("GPT my_lba incorrect: %lld != %lld\n", | 323 | pr_debug("GPT my_lba incorrect: %lld != %lld\n", |
332 | (unsigned long long)le64_to_cpu((*gpt)->my_lba), | 324 | (unsigned long long)le64_to_cpu((*gpt)->my_lba), |
333 | (unsigned long long)lba); | 325 | (unsigned long long)lba); |
334 | goto fail; | 326 | goto fail; |
335 | } | 327 | } |
336 | 328 | ||
@@ -339,15 +331,15 @@ is_gpt_valid(struct block_device *bdev, u64 lba, | |||
339 | */ | 331 | */ |
340 | lastlba = last_lba(bdev); | 332 | lastlba = last_lba(bdev); |
341 | if (le64_to_cpu((*gpt)->first_usable_lba) > lastlba) { | 333 | if (le64_to_cpu((*gpt)->first_usable_lba) > lastlba) { |
342 | Dprintk("GPT: first_usable_lba incorrect: %lld > %lld\n", | 334 | pr_debug("GPT: first_usable_lba incorrect: %lld > %lld\n", |
343 | (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba), | 335 | (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba), |
344 | (unsigned long long)lastlba); | 336 | (unsigned long long)lastlba); |
345 | goto fail; | 337 | goto fail; |
346 | } | 338 | } |
347 | if (le64_to_cpu((*gpt)->last_usable_lba) > lastlba) { | 339 | if (le64_to_cpu((*gpt)->last_usable_lba) > lastlba) { |
348 | Dprintk("GPT: last_usable_lba incorrect: %lld > %lld\n", | 340 | pr_debug("GPT: last_usable_lba incorrect: %lld > %lld\n", |
349 | (unsigned long long)le64_to_cpu((*gpt)->last_usable_lba), | 341 | (unsigned long long)le64_to_cpu((*gpt)->last_usable_lba), |
350 | (unsigned long long)lastlba); | 342 | (unsigned long long)lastlba); |
351 | goto fail; | 343 | goto fail; |
352 | } | 344 | } |
353 | 345 | ||
@@ -360,7 +352,7 @@ is_gpt_valid(struct block_device *bdev, u64 lba, | |||
360 | le32_to_cpu((*gpt)->sizeof_partition_entry)); | 352 | le32_to_cpu((*gpt)->sizeof_partition_entry)); |
361 | 353 | ||
362 | if (crc != le32_to_cpu((*gpt)->partition_entry_array_crc32)) { | 354 | if (crc != le32_to_cpu((*gpt)->partition_entry_array_crc32)) { |
363 | Dprintk("GUID Partitition Entry Array CRC check failed.\n"); | 355 | pr_debug("GUID Partitition Entry Array CRC check failed.\n"); |
364 | goto fail_ptes; | 356 | goto fail_ptes; |
365 | } | 357 | } |
366 | 358 | ||
@@ -616,7 +608,7 @@ efi_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
616 | return 0; | 608 | return 0; |
617 | } | 609 | } |
618 | 610 | ||
619 | Dprintk("GUID Partition Table is valid! Yea!\n"); | 611 | pr_debug("GUID Partition Table is valid! Yea!\n"); |
620 | 612 | ||
621 | for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) { | 613 | for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) { |
622 | if (!is_pte_valid(&ptes[i], last_lba(bdev))) | 614 | if (!is_pte_valid(&ptes[i], last_lba(bdev))) |
diff --git a/fs/partitions/ldm.c b/fs/partitions/ldm.c index 0fdda2e8a4cc..8652fb99e962 100644 --- a/fs/partitions/ldm.c +++ b/fs/partitions/ldm.c | |||
@@ -133,17 +133,17 @@ static bool ldm_parse_privhead(const u8 *data, struct privhead *ph) | |||
133 | bool is_vista = false; | 133 | bool is_vista = false; |
134 | 134 | ||
135 | BUG_ON(!data || !ph); | 135 | BUG_ON(!data || !ph); |
136 | if (MAGIC_PRIVHEAD != BE64(data)) { | 136 | if (MAGIC_PRIVHEAD != get_unaligned_be64(data)) { |
137 | ldm_error("Cannot find PRIVHEAD structure. LDM database is" | 137 | ldm_error("Cannot find PRIVHEAD structure. LDM database is" |
138 | " corrupt. Aborting."); | 138 | " corrupt. Aborting."); |
139 | return false; | 139 | return false; |
140 | } | 140 | } |
141 | ph->ver_major = BE16(data + 0x000C); | 141 | ph->ver_major = get_unaligned_be16(data + 0x000C); |
142 | ph->ver_minor = BE16(data + 0x000E); | 142 | ph->ver_minor = get_unaligned_be16(data + 0x000E); |
143 | ph->logical_disk_start = BE64(data + 0x011B); | 143 | ph->logical_disk_start = get_unaligned_be64(data + 0x011B); |
144 | ph->logical_disk_size = BE64(data + 0x0123); | 144 | ph->logical_disk_size = get_unaligned_be64(data + 0x0123); |
145 | ph->config_start = BE64(data + 0x012B); | 145 | ph->config_start = get_unaligned_be64(data + 0x012B); |
146 | ph->config_size = BE64(data + 0x0133); | 146 | ph->config_size = get_unaligned_be64(data + 0x0133); |
147 | /* Version 2.11 is Win2k/XP and version 2.12 is Vista. */ | 147 | /* Version 2.11 is Win2k/XP and version 2.12 is Vista. */ |
148 | if (ph->ver_major == 2 && ph->ver_minor == 12) | 148 | if (ph->ver_major == 2 && ph->ver_minor == 12) |
149 | is_vista = true; | 149 | is_vista = true; |
@@ -191,14 +191,14 @@ static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc) | |||
191 | { | 191 | { |
192 | BUG_ON (!data || !toc); | 192 | BUG_ON (!data || !toc); |
193 | 193 | ||
194 | if (MAGIC_TOCBLOCK != BE64 (data)) { | 194 | if (MAGIC_TOCBLOCK != get_unaligned_be64(data)) { |
195 | ldm_crit ("Cannot find TOCBLOCK, database may be corrupt."); | 195 | ldm_crit ("Cannot find TOCBLOCK, database may be corrupt."); |
196 | return false; | 196 | return false; |
197 | } | 197 | } |
198 | strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name)); | 198 | strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name)); |
199 | toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = 0; | 199 | toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = 0; |
200 | toc->bitmap1_start = BE64 (data + 0x2E); | 200 | toc->bitmap1_start = get_unaligned_be64(data + 0x2E); |
201 | toc->bitmap1_size = BE64 (data + 0x36); | 201 | toc->bitmap1_size = get_unaligned_be64(data + 0x36); |
202 | 202 | ||
203 | if (strncmp (toc->bitmap1_name, TOC_BITMAP1, | 203 | if (strncmp (toc->bitmap1_name, TOC_BITMAP1, |
204 | sizeof (toc->bitmap1_name)) != 0) { | 204 | sizeof (toc->bitmap1_name)) != 0) { |
@@ -208,8 +208,8 @@ static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc) | |||
208 | } | 208 | } |
209 | strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name)); | 209 | strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name)); |
210 | toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = 0; | 210 | toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = 0; |
211 | toc->bitmap2_start = BE64 (data + 0x50); | 211 | toc->bitmap2_start = get_unaligned_be64(data + 0x50); |
212 | toc->bitmap2_size = BE64 (data + 0x58); | 212 | toc->bitmap2_size = get_unaligned_be64(data + 0x58); |
213 | if (strncmp (toc->bitmap2_name, TOC_BITMAP2, | 213 | if (strncmp (toc->bitmap2_name, TOC_BITMAP2, |
214 | sizeof (toc->bitmap2_name)) != 0) { | 214 | sizeof (toc->bitmap2_name)) != 0) { |
215 | ldm_crit ("TOCBLOCK's second bitmap is '%s', should be '%s'.", | 215 | ldm_crit ("TOCBLOCK's second bitmap is '%s', should be '%s'.", |
@@ -237,22 +237,22 @@ static bool ldm_parse_vmdb (const u8 *data, struct vmdb *vm) | |||
237 | { | 237 | { |
238 | BUG_ON (!data || !vm); | 238 | BUG_ON (!data || !vm); |
239 | 239 | ||
240 | if (MAGIC_VMDB != BE32 (data)) { | 240 | if (MAGIC_VMDB != get_unaligned_be32(data)) { |
241 | ldm_crit ("Cannot find the VMDB, database may be corrupt."); | 241 | ldm_crit ("Cannot find the VMDB, database may be corrupt."); |
242 | return false; | 242 | return false; |
243 | } | 243 | } |
244 | 244 | ||
245 | vm->ver_major = BE16 (data + 0x12); | 245 | vm->ver_major = get_unaligned_be16(data + 0x12); |
246 | vm->ver_minor = BE16 (data + 0x14); | 246 | vm->ver_minor = get_unaligned_be16(data + 0x14); |
247 | if ((vm->ver_major != 4) || (vm->ver_minor != 10)) { | 247 | if ((vm->ver_major != 4) || (vm->ver_minor != 10)) { |
248 | ldm_error ("Expected VMDB version %d.%d, got %d.%d. " | 248 | ldm_error ("Expected VMDB version %d.%d, got %d.%d. " |
249 | "Aborting.", 4, 10, vm->ver_major, vm->ver_minor); | 249 | "Aborting.", 4, 10, vm->ver_major, vm->ver_minor); |
250 | return false; | 250 | return false; |
251 | } | 251 | } |
252 | 252 | ||
253 | vm->vblk_size = BE32 (data + 0x08); | 253 | vm->vblk_size = get_unaligned_be32(data + 0x08); |
254 | vm->vblk_offset = BE32 (data + 0x0C); | 254 | vm->vblk_offset = get_unaligned_be32(data + 0x0C); |
255 | vm->last_vblk_seq = BE32 (data + 0x04); | 255 | vm->last_vblk_seq = get_unaligned_be32(data + 0x04); |
256 | 256 | ||
257 | ldm_debug ("Parsed VMDB successfully."); | 257 | ldm_debug ("Parsed VMDB successfully."); |
258 | return true; | 258 | return true; |
@@ -507,7 +507,7 @@ static bool ldm_validate_vmdb (struct block_device *bdev, unsigned long base, | |||
507 | goto out; /* Already logged */ | 507 | goto out; /* Already logged */ |
508 | 508 | ||
509 | /* Are there uncommitted transactions? */ | 509 | /* Are there uncommitted transactions? */ |
510 | if (BE16(data + 0x10) != 0x01) { | 510 | if (get_unaligned_be16(data + 0x10) != 0x01) { |
511 | ldm_crit ("Database is not in a consistent state. Aborting."); | 511 | ldm_crit ("Database is not in a consistent state. Aborting."); |
512 | goto out; | 512 | goto out; |
513 | } | 513 | } |
@@ -802,7 +802,7 @@ static bool ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
802 | return false; | 802 | return false; |
803 | 803 | ||
804 | len += VBLK_SIZE_CMP3; | 804 | len += VBLK_SIZE_CMP3; |
805 | if (len != BE32 (buffer + 0x14)) | 805 | if (len != get_unaligned_be32(buffer + 0x14)) |
806 | return false; | 806 | return false; |
807 | 807 | ||
808 | comp = &vb->vblk.comp; | 808 | comp = &vb->vblk.comp; |
@@ -851,7 +851,7 @@ static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
851 | return false; | 851 | return false; |
852 | 852 | ||
853 | len += VBLK_SIZE_DGR3; | 853 | len += VBLK_SIZE_DGR3; |
854 | if (len != BE32 (buffer + 0x14)) | 854 | if (len != get_unaligned_be32(buffer + 0x14)) |
855 | return false; | 855 | return false; |
856 | 856 | ||
857 | dgrp = &vb->vblk.dgrp; | 857 | dgrp = &vb->vblk.dgrp; |
@@ -895,7 +895,7 @@ static bool ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb) | |||
895 | return false; | 895 | return false; |
896 | 896 | ||
897 | len += VBLK_SIZE_DGR4; | 897 | len += VBLK_SIZE_DGR4; |
898 | if (len != BE32 (buffer + 0x14)) | 898 | if (len != get_unaligned_be32(buffer + 0x14)) |
899 | return false; | 899 | return false; |
900 | 900 | ||
901 | dgrp = &vb->vblk.dgrp; | 901 | dgrp = &vb->vblk.dgrp; |
@@ -931,7 +931,7 @@ static bool ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb) | |||
931 | return false; | 931 | return false; |
932 | 932 | ||
933 | len += VBLK_SIZE_DSK3; | 933 | len += VBLK_SIZE_DSK3; |
934 | if (len != BE32 (buffer + 0x14)) | 934 | if (len != get_unaligned_be32(buffer + 0x14)) |
935 | return false; | 935 | return false; |
936 | 936 | ||
937 | disk = &vb->vblk.disk; | 937 | disk = &vb->vblk.disk; |
@@ -968,7 +968,7 @@ static bool ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb) | |||
968 | return false; | 968 | return false; |
969 | 969 | ||
970 | len += VBLK_SIZE_DSK4; | 970 | len += VBLK_SIZE_DSK4; |
971 | if (len != BE32 (buffer + 0x14)) | 971 | if (len != get_unaligned_be32(buffer + 0x14)) |
972 | return false; | 972 | return false; |
973 | 973 | ||
974 | disk = &vb->vblk.disk; | 974 | disk = &vb->vblk.disk; |
@@ -1034,14 +1034,14 @@ static bool ldm_parse_prt3(const u8 *buffer, int buflen, struct vblk *vb) | |||
1034 | return false; | 1034 | return false; |
1035 | } | 1035 | } |
1036 | len += VBLK_SIZE_PRT3; | 1036 | len += VBLK_SIZE_PRT3; |
1037 | if (len > BE32(buffer + 0x14)) { | 1037 | if (len > get_unaligned_be32(buffer + 0x14)) { |
1038 | ldm_error("len %d > BE32(buffer + 0x14) %d", len, | 1038 | ldm_error("len %d > BE32(buffer + 0x14) %d", len, |
1039 | BE32(buffer + 0x14)); | 1039 | get_unaligned_be32(buffer + 0x14)); |
1040 | return false; | 1040 | return false; |
1041 | } | 1041 | } |
1042 | part = &vb->vblk.part; | 1042 | part = &vb->vblk.part; |
1043 | part->start = BE64(buffer + 0x24 + r_name); | 1043 | part->start = get_unaligned_be64(buffer + 0x24 + r_name); |
1044 | part->volume_offset = BE64(buffer + 0x2C + r_name); | 1044 | part->volume_offset = get_unaligned_be64(buffer + 0x2C + r_name); |
1045 | part->size = ldm_get_vnum(buffer + 0x34 + r_name); | 1045 | part->size = ldm_get_vnum(buffer + 0x34 + r_name); |
1046 | part->parent_id = ldm_get_vnum(buffer + 0x34 + r_size); | 1046 | part->parent_id = ldm_get_vnum(buffer + 0x34 + r_size); |
1047 | part->disk_id = ldm_get_vnum(buffer + 0x34 + r_parent); | 1047 | part->disk_id = ldm_get_vnum(buffer + 0x34 + r_parent); |
@@ -1139,9 +1139,9 @@ static bool ldm_parse_vol5(const u8 *buffer, int buflen, struct vblk *vb) | |||
1139 | return false; | 1139 | return false; |
1140 | } | 1140 | } |
1141 | len += VBLK_SIZE_VOL5; | 1141 | len += VBLK_SIZE_VOL5; |
1142 | if (len > BE32(buffer + 0x14)) { | 1142 | if (len > get_unaligned_be32(buffer + 0x14)) { |
1143 | ldm_error("len %d > BE32(buffer + 0x14) %d", len, | 1143 | ldm_error("len %d > BE32(buffer + 0x14) %d", len, |
1144 | BE32(buffer + 0x14)); | 1144 | get_unaligned_be32(buffer + 0x14)); |
1145 | return false; | 1145 | return false; |
1146 | } | 1146 | } |
1147 | volu = &vb->vblk.volu; | 1147 | volu = &vb->vblk.volu; |
@@ -1294,9 +1294,9 @@ static bool ldm_frag_add (const u8 *data, int size, struct list_head *frags) | |||
1294 | 1294 | ||
1295 | BUG_ON (!data || !frags); | 1295 | BUG_ON (!data || !frags); |
1296 | 1296 | ||
1297 | group = BE32 (data + 0x08); | 1297 | group = get_unaligned_be32(data + 0x08); |
1298 | rec = BE16 (data + 0x0C); | 1298 | rec = get_unaligned_be16(data + 0x0C); |
1299 | num = BE16 (data + 0x0E); | 1299 | num = get_unaligned_be16(data + 0x0E); |
1300 | if ((num < 1) || (num > 4)) { | 1300 | if ((num < 1) || (num > 4)) { |
1301 | ldm_error ("A VBLK claims to have %d parts.", num); | 1301 | ldm_error ("A VBLK claims to have %d parts.", num); |
1302 | return false; | 1302 | return false; |
@@ -1425,12 +1425,12 @@ static bool ldm_get_vblks (struct block_device *bdev, unsigned long base, | |||
1425 | } | 1425 | } |
1426 | 1426 | ||
1427 | for (v = 0; v < perbuf; v++, data+=size) { /* For each vblk */ | 1427 | for (v = 0; v < perbuf; v++, data+=size) { /* For each vblk */ |
1428 | if (MAGIC_VBLK != BE32 (data)) { | 1428 | if (MAGIC_VBLK != get_unaligned_be32(data)) { |
1429 | ldm_error ("Expected to find a VBLK."); | 1429 | ldm_error ("Expected to find a VBLK."); |
1430 | goto out; | 1430 | goto out; |
1431 | } | 1431 | } |
1432 | 1432 | ||
1433 | recs = BE16 (data + 0x0E); /* Number of records */ | 1433 | recs = get_unaligned_be16(data + 0x0E); /* Number of records */ |
1434 | if (recs == 1) { | 1434 | if (recs == 1) { |
1435 | if (!ldm_ldmdb_add (data, size, ldb)) | 1435 | if (!ldm_ldmdb_add (data, size, ldb)) |
1436 | goto out; /* Already logged */ | 1436 | goto out; /* Already logged */ |
diff --git a/fs/partitions/ldm.h b/fs/partitions/ldm.h index 80f63b5fdd9f..30e08e809c1d 100644 --- a/fs/partitions/ldm.h +++ b/fs/partitions/ldm.h | |||
@@ -98,11 +98,6 @@ struct parsed_partitions; | |||
98 | #define TOC_BITMAP1 "config" /* Names of the two defined */ | 98 | #define TOC_BITMAP1 "config" /* Names of the two defined */ |
99 | #define TOC_BITMAP2 "log" /* bitmaps in the TOCBLOCK. */ | 99 | #define TOC_BITMAP2 "log" /* bitmaps in the TOCBLOCK. */ |
100 | 100 | ||
101 | /* Most numbers we deal with are big-endian and won't be aligned. */ | ||
102 | #define BE16(x) ((u16)be16_to_cpu(get_unaligned((__be16*)(x)))) | ||
103 | #define BE32(x) ((u32)be32_to_cpu(get_unaligned((__be32*)(x)))) | ||
104 | #define BE64(x) ((u64)be64_to_cpu(get_unaligned((__be64*)(x)))) | ||
105 | |||
106 | /* Borrowed from msdos.c */ | 101 | /* Borrowed from msdos.c */ |
107 | #define SYS_IND(p) (get_unaligned(&(p)->sys_ind)) | 102 | #define SYS_IND(p) (get_unaligned(&(p)->sys_ind)) |
108 | 103 | ||