diff options
Diffstat (limited to 'fs/partitions/msdos.c')
| -rw-r--r-- | fs/partitions/msdos.c | 87 |
1 files changed, 38 insertions, 49 deletions
diff --git a/fs/partitions/msdos.c b/fs/partitions/msdos.c index 90be97f1f5a8..15bfb7b1e044 100644 --- a/fs/partitions/msdos.c +++ b/fs/partitions/msdos.c | |||
| @@ -64,7 +64,7 @@ msdos_magic_present(unsigned char *p) | |||
| 64 | #define AIX_LABEL_MAGIC2 0xC2 | 64 | #define AIX_LABEL_MAGIC2 0xC2 |
| 65 | #define AIX_LABEL_MAGIC3 0xD4 | 65 | #define AIX_LABEL_MAGIC3 0xD4 |
| 66 | #define AIX_LABEL_MAGIC4 0xC1 | 66 | #define AIX_LABEL_MAGIC4 0xC1 |
| 67 | static int aix_magic_present(unsigned char *p, struct block_device *bdev) | 67 | static int aix_magic_present(struct parsed_partitions *state, unsigned char *p) |
| 68 | { | 68 | { |
| 69 | struct partition *pt = (struct partition *) (p + 0x1be); | 69 | struct partition *pt = (struct partition *) (p + 0x1be); |
| 70 | Sector sect; | 70 | Sector sect; |
| @@ -85,7 +85,7 @@ static int aix_magic_present(unsigned char *p, struct block_device *bdev) | |||
| 85 | is_extended_partition(pt)) | 85 | is_extended_partition(pt)) |
| 86 | return 0; | 86 | return 0; |
| 87 | } | 87 | } |
| 88 | d = read_dev_sector(bdev, 7, §); | 88 | d = read_part_sector(state, 7, §); |
| 89 | if (d) { | 89 | if (d) { |
| 90 | if (d[0] == '_' && d[1] == 'L' && d[2] == 'V' && d[3] == 'M') | 90 | if (d[0] == '_' && d[1] == 'L' && d[2] == 'V' && d[3] == 'M') |
| 91 | ret = 1; | 91 | ret = 1; |
| @@ -105,15 +105,14 @@ static int aix_magic_present(unsigned char *p, struct block_device *bdev) | |||
| 105 | * only for the actual data partitions. | 105 | * only for the actual data partitions. |
| 106 | */ | 106 | */ |
| 107 | 107 | ||
| 108 | static void | 108 | static void parse_extended(struct parsed_partitions *state, |
| 109 | parse_extended(struct parsed_partitions *state, struct block_device *bdev, | 109 | sector_t first_sector, sector_t first_size) |
| 110 | sector_t first_sector, sector_t first_size) | ||
| 111 | { | 110 | { |
| 112 | struct partition *p; | 111 | struct partition *p; |
| 113 | Sector sect; | 112 | Sector sect; |
| 114 | unsigned char *data; | 113 | unsigned char *data; |
| 115 | sector_t this_sector, this_size; | 114 | sector_t this_sector, this_size; |
| 116 | sector_t sector_size = bdev_logical_block_size(bdev) / 512; | 115 | sector_t sector_size = bdev_logical_block_size(state->bdev) / 512; |
| 117 | int loopct = 0; /* number of links followed | 116 | int loopct = 0; /* number of links followed |
| 118 | without finding a data partition */ | 117 | without finding a data partition */ |
| 119 | int i; | 118 | int i; |
| @@ -126,7 +125,7 @@ parse_extended(struct parsed_partitions *state, struct block_device *bdev, | |||
| 126 | return; | 125 | return; |
| 127 | if (state->next == state->limit) | 126 | if (state->next == state->limit) |
| 128 | return; | 127 | return; |
| 129 | data = read_dev_sector(bdev, this_sector, §); | 128 | data = read_part_sector(state, this_sector, §); |
| 130 | if (!data) | 129 | if (!data) |
| 131 | return; | 130 | return; |
| 132 | 131 | ||
| @@ -198,9 +197,8 @@ done: | |||
| 198 | /* james@bpgc.com: Solaris has a nasty indicator: 0x82 which also | 197 | /* james@bpgc.com: Solaris has a nasty indicator: 0x82 which also |
| 199 | indicates linux swap. Be careful before believing this is Solaris. */ | 198 | indicates linux swap. Be careful before believing this is Solaris. */ |
| 200 | 199 | ||
| 201 | static void | 200 | static void parse_solaris_x86(struct parsed_partitions *state, |
| 202 | parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev, | 201 | sector_t offset, sector_t size, int origin) |
| 203 | sector_t offset, sector_t size, int origin) | ||
| 204 | { | 202 | { |
| 205 | #ifdef CONFIG_SOLARIS_X86_PARTITION | 203 | #ifdef CONFIG_SOLARIS_X86_PARTITION |
| 206 | Sector sect; | 204 | Sector sect; |
| @@ -208,7 +206,7 @@ parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev, | |||
| 208 | int i; | 206 | int i; |
| 209 | short max_nparts; | 207 | short max_nparts; |
| 210 | 208 | ||
| 211 | v = (struct solaris_x86_vtoc *)read_dev_sector(bdev, offset+1, §); | 209 | v = read_part_sector(state, offset + 1, §); |
| 212 | if (!v) | 210 | if (!v) |
| 213 | return; | 211 | return; |
| 214 | if (le32_to_cpu(v->v_sanity) != SOLARIS_X86_VTOC_SANE) { | 212 | if (le32_to_cpu(v->v_sanity) != SOLARIS_X86_VTOC_SANE) { |
| @@ -245,16 +243,15 @@ parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev, | |||
| 245 | * Create devices for BSD partitions listed in a disklabel, under a | 243 | * Create devices for BSD partitions listed in a disklabel, under a |
| 246 | * dos-like partition. See parse_extended() for more information. | 244 | * dos-like partition. See parse_extended() for more information. |
| 247 | */ | 245 | */ |
| 248 | static void | 246 | static void parse_bsd(struct parsed_partitions *state, |
| 249 | parse_bsd(struct parsed_partitions *state, struct block_device *bdev, | 247 | sector_t offset, sector_t size, int origin, char *flavour, |
| 250 | sector_t offset, sector_t size, int origin, char *flavour, | 248 | int max_partitions) |
| 251 | int max_partitions) | ||
| 252 | { | 249 | { |
| 253 | Sector sect; | 250 | Sector sect; |
| 254 | struct bsd_disklabel *l; | 251 | struct bsd_disklabel *l; |
| 255 | struct bsd_partition *p; | 252 | struct bsd_partition *p; |
| 256 | 253 | ||
| 257 | l = (struct bsd_disklabel *)read_dev_sector(bdev, offset+1, §); | 254 | l = read_part_sector(state, offset + 1, §); |
| 258 | if (!l) | 255 | if (!l) |
| 259 | return; | 256 | return; |
| 260 | if (le32_to_cpu(l->d_magic) != BSD_DISKMAGIC) { | 257 | if (le32_to_cpu(l->d_magic) != BSD_DISKMAGIC) { |
| @@ -291,33 +288,28 @@ parse_bsd(struct parsed_partitions *state, struct block_device *bdev, | |||
| 291 | } | 288 | } |
| 292 | #endif | 289 | #endif |
| 293 | 290 | ||
| 294 | static void | 291 | static void parse_freebsd(struct parsed_partitions *state, |
| 295 | parse_freebsd(struct parsed_partitions *state, struct block_device *bdev, | 292 | sector_t offset, sector_t size, int origin) |
| 296 | sector_t offset, sector_t size, int origin) | ||
| 297 | { | 293 | { |
| 298 | #ifdef CONFIG_BSD_DISKLABEL | 294 | #ifdef CONFIG_BSD_DISKLABEL |
| 299 | parse_bsd(state, bdev, offset, size, origin, | 295 | parse_bsd(state, offset, size, origin, "bsd", BSD_MAXPARTITIONS); |
| 300 | "bsd", BSD_MAXPARTITIONS); | ||
| 301 | #endif | 296 | #endif |
| 302 | } | 297 | } |
| 303 | 298 | ||
| 304 | static void | 299 | static void parse_netbsd(struct parsed_partitions *state, |
| 305 | parse_netbsd(struct parsed_partitions *state, struct block_device *bdev, | 300 | sector_t offset, sector_t size, int origin) |
| 306 | sector_t offset, sector_t size, int origin) | ||
| 307 | { | 301 | { |
| 308 | #ifdef CONFIG_BSD_DISKLABEL | 302 | #ifdef CONFIG_BSD_DISKLABEL |
| 309 | parse_bsd(state, bdev, offset, size, origin, | 303 | parse_bsd(state, offset, size, origin, "netbsd", BSD_MAXPARTITIONS); |
| 310 | "netbsd", BSD_MAXPARTITIONS); | ||
| 311 | #endif | 304 | #endif |
| 312 | } | 305 | } |
| 313 | 306 | ||
| 314 | static void | 307 | static void parse_openbsd(struct parsed_partitions *state, |
| 315 | parse_openbsd(struct parsed_partitions *state, struct block_device *bdev, | 308 | sector_t offset, sector_t size, int origin) |
| 316 | sector_t offset, sector_t size, int origin) | ||
| 317 | { | 309 | { |
| 318 | #ifdef CONFIG_BSD_DISKLABEL | 310 | #ifdef CONFIG_BSD_DISKLABEL |
| 319 | parse_bsd(state, bdev, offset, size, origin, | 311 | parse_bsd(state, offset, size, origin, "openbsd", |
| 320 | "openbsd", OPENBSD_MAXPARTITIONS); | 312 | OPENBSD_MAXPARTITIONS); |
| 321 | #endif | 313 | #endif |
| 322 | } | 314 | } |
| 323 | 315 | ||
| @@ -325,16 +317,15 @@ parse_openbsd(struct parsed_partitions *state, struct block_device *bdev, | |||
| 325 | * Create devices for Unixware partitions listed in a disklabel, under a | 317 | * Create devices for Unixware partitions listed in a disklabel, under a |
| 326 | * dos-like partition. See parse_extended() for more information. | 318 | * dos-like partition. See parse_extended() for more information. |
| 327 | */ | 319 | */ |
| 328 | static void | 320 | static void parse_unixware(struct parsed_partitions *state, |
| 329 | parse_unixware(struct parsed_partitions *state, struct block_device *bdev, | 321 | sector_t offset, sector_t size, int origin) |
| 330 | sector_t offset, sector_t size, int origin) | ||
| 331 | { | 322 | { |
| 332 | #ifdef CONFIG_UNIXWARE_DISKLABEL | 323 | #ifdef CONFIG_UNIXWARE_DISKLABEL |
| 333 | Sector sect; | 324 | Sector sect; |
| 334 | struct unixware_disklabel *l; | 325 | struct unixware_disklabel *l; |
| 335 | struct unixware_slice *p; | 326 | struct unixware_slice *p; |
| 336 | 327 | ||
| 337 | l = (struct unixware_disklabel *)read_dev_sector(bdev, offset+29, §); | 328 | l = read_part_sector(state, offset + 29, §); |
| 338 | if (!l) | 329 | if (!l) |
| 339 | return; | 330 | return; |
| 340 | if (le32_to_cpu(l->d_magic) != UNIXWARE_DISKMAGIC || | 331 | if (le32_to_cpu(l->d_magic) != UNIXWARE_DISKMAGIC || |
| @@ -365,9 +356,8 @@ parse_unixware(struct parsed_partitions *state, struct block_device *bdev, | |||
| 365 | * Anand Krishnamurthy <anandk@wiproge.med.ge.com> | 356 | * Anand Krishnamurthy <anandk@wiproge.med.ge.com> |
| 366 | * Rajeev V. Pillai <rajeevvp@yahoo.com> | 357 | * Rajeev V. Pillai <rajeevvp@yahoo.com> |
| 367 | */ | 358 | */ |
| 368 | static void | 359 | static void parse_minix(struct parsed_partitions *state, |
| 369 | parse_minix(struct parsed_partitions *state, struct block_device *bdev, | 360 | sector_t offset, sector_t size, int origin) |
| 370 | sector_t offset, sector_t size, int origin) | ||
| 371 | { | 361 | { |
| 372 | #ifdef CONFIG_MINIX_SUBPARTITION | 362 | #ifdef CONFIG_MINIX_SUBPARTITION |
| 373 | Sector sect; | 363 | Sector sect; |
| @@ -375,7 +365,7 @@ parse_minix(struct parsed_partitions *state, struct block_device *bdev, | |||
| 375 | struct partition *p; | 365 | struct partition *p; |
| 376 | int i; | 366 | int i; |
| 377 | 367 | ||
| 378 | data = read_dev_sector(bdev, offset, §); | 368 | data = read_part_sector(state, offset, §); |
| 379 | if (!data) | 369 | if (!data) |
| 380 | return; | 370 | return; |
| 381 | 371 | ||
| @@ -404,8 +394,7 @@ parse_minix(struct parsed_partitions *state, struct block_device *bdev, | |||
| 404 | 394 | ||
| 405 | static struct { | 395 | static struct { |
| 406 | unsigned char id; | 396 | unsigned char id; |
| 407 | void (*parse)(struct parsed_partitions *, struct block_device *, | 397 | void (*parse)(struct parsed_partitions *, sector_t, sector_t, int); |
| 408 | sector_t, sector_t, int); | ||
| 409 | } subtypes[] = { | 398 | } subtypes[] = { |
| 410 | {FREEBSD_PARTITION, parse_freebsd}, | 399 | {FREEBSD_PARTITION, parse_freebsd}, |
| 411 | {NETBSD_PARTITION, parse_netbsd}, | 400 | {NETBSD_PARTITION, parse_netbsd}, |
| @@ -417,16 +406,16 @@ static struct { | |||
| 417 | {0, NULL}, | 406 | {0, NULL}, |
| 418 | }; | 407 | }; |
| 419 | 408 | ||
| 420 | int msdos_partition(struct parsed_partitions *state, struct block_device *bdev) | 409 | int msdos_partition(struct parsed_partitions *state) |
| 421 | { | 410 | { |
| 422 | sector_t sector_size = bdev_logical_block_size(bdev) / 512; | 411 | sector_t sector_size = bdev_logical_block_size(state->bdev) / 512; |
| 423 | Sector sect; | 412 | Sector sect; |
| 424 | unsigned char *data; | 413 | unsigned char *data; |
| 425 | struct partition *p; | 414 | struct partition *p; |
| 426 | struct fat_boot_sector *fb; | 415 | struct fat_boot_sector *fb; |
| 427 | int slot; | 416 | int slot; |
| 428 | 417 | ||
| 429 | data = read_dev_sector(bdev, 0, §); | 418 | data = read_part_sector(state, 0, §); |
| 430 | if (!data) | 419 | if (!data) |
| 431 | return -1; | 420 | return -1; |
| 432 | if (!msdos_magic_present(data + 510)) { | 421 | if (!msdos_magic_present(data + 510)) { |
| @@ -434,7 +423,7 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
| 434 | return 0; | 423 | return 0; |
| 435 | } | 424 | } |
| 436 | 425 | ||
| 437 | if (aix_magic_present(data, bdev)) { | 426 | if (aix_magic_present(state, data)) { |
| 438 | put_dev_sector(sect); | 427 | put_dev_sector(sect); |
| 439 | printk( " [AIX]"); | 428 | printk( " [AIX]"); |
| 440 | return 0; | 429 | return 0; |
| @@ -503,13 +492,13 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
| 503 | put_partition(state, slot, start, n); | 492 | put_partition(state, slot, start, n); |
| 504 | 493 | ||
| 505 | printk(" <"); | 494 | printk(" <"); |
| 506 | parse_extended(state, bdev, start, size); | 495 | parse_extended(state, start, size); |
| 507 | printk(" >"); | 496 | printk(" >"); |
| 508 | continue; | 497 | continue; |
| 509 | } | 498 | } |
| 510 | put_partition(state, slot, start, size); | 499 | put_partition(state, slot, start, size); |
| 511 | if (SYS_IND(p) == LINUX_RAID_PARTITION) | 500 | if (SYS_IND(p) == LINUX_RAID_PARTITION) |
| 512 | state->parts[slot].flags = 1; | 501 | state->parts[slot].flags = ADDPART_FLAG_RAID; |
| 513 | if (SYS_IND(p) == DM6_PARTITION) | 502 | if (SYS_IND(p) == DM6_PARTITION) |
| 514 | printk("[DM]"); | 503 | printk("[DM]"); |
| 515 | if (SYS_IND(p) == EZD_PARTITION) | 504 | if (SYS_IND(p) == EZD_PARTITION) |
| @@ -532,8 +521,8 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
| 532 | 521 | ||
| 533 | if (!subtypes[n].parse) | 522 | if (!subtypes[n].parse) |
| 534 | continue; | 523 | continue; |
| 535 | subtypes[n].parse(state, bdev, start_sect(p)*sector_size, | 524 | subtypes[n].parse(state, start_sect(p) * sector_size, |
| 536 | nr_sects(p)*sector_size, slot); | 525 | nr_sects(p) * sector_size, slot); |
| 537 | } | 526 | } |
| 538 | put_dev_sector(sect); | 527 | put_dev_sector(sect); |
| 539 | return 1; | 528 | return 1; |
