| 1 | |
| 2 | |
| 3 | * fs/partitions/sgi.c
|
| 4 | *
|
| 5 | * Code extracted from drivers/block/genhd.c
|
| 6 |
|
| 7 |
|
| 8 | #include "check.h"
|
| 9 |
|
| 10 | #define SGI_LABEL_MAGIC 0x0be5a941
|
| 11 |
|
| 12 | enum {
|
| 13 | LINUX_RAID_PARTITION = 0xfd,
|
| 14 | };
|
| 15 |
|
| 16 | struct sgi_disklabel {
|
| 17 | __be32 magic_mushroom;
|
| 18 | __be16 root_part_num;
|
| 19 | __be16 swap_part_num;
|
| 20 | s8 boot_file[16];
|
| 21 | u8 _unused0[48];
|
| 22 | struct sgi_volume {
|
| 23 | s8 name[8];
|
| 24 | __be32 block_num;
|
| 25 | __be32 num_bytes;
|
| 26 | } volume[15];
|
| 27 | struct sgi_partition {
|
| 28 | __be32 num_blocks;
|
| 29 | __be32 first_block;
|
| 30 | __be32 type;
|
| 31 | } partitions[16];
|
| 32 | __be32 csum;
|
| 33 | __be32 _unused1;
|
| 34 | };
|
| 35 |
|
| 36 | int sgi_partition(struct parsed_partitions *state)
|
| 37 | {
|
| 38 | int i, csum;
|
| 39 | __be32 magic;
|
| 40 | int slot = 1;
|
| 41 | unsigned int start, blocks;
|
| 42 | __be32 *ui, cs;
|
| 43 | Sector sect;
|
| 44 | struct sgi_disklabel *label;
|
| 45 | struct sgi_partition *p;
|
| 46 |
|
| 47 | label = read_part_sector(state, 0, §);
|
| 48 | if (!label)
|
| 49 | return -1;
|
| 50 | p = &label->partitions[0];
|
| 51 | magic = label->magic_mushroom;
|
| 52 | if(be32_to_cpu(magic) != SGI_LABEL_MAGIC) {
|
| 53 | put_dev_sector(sect);
|
| 54 | return 0;
|
| 55 | }
|
| 56 | ui = ((__be32 *) (label + 1)) - 1;
|
| 57 | for(csum = 0; ui >= ((__be32 *) label);) {
|
| 58 | cs = *ui--;
|
| 59 | csum += be32_to_cpu(cs);
|
| 60 | }
|
| 61 | if(csum) {
|
| 62 | printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n",
|
| 63 | state->disk->disk_name);
|
| 64 | put_dev_sector(sect);
|
| 65 | return 0;
|
| 66 | }
|
| 67 | |
| 68 | * have 15 minor's. Luckily there are always a few zero length
|
| 69 | * partitions which we don't care about so we never overflow the
|
| 70 | * current_minor.
|
| 71 |
|
| 72 | for(i = 0; i < 16; i++, p++) {
|
| 73 | blocks = be32_to_cpu(p->num_blocks);
|
| 74 | start = be32_to_cpu(p->first_block);
|
| 75 | if (blocks) {
|
| 76 | put_partition(state, slot, start, blocks);
|
| 77 | if (be32_to_cpu(p->type) == LINUX_RAID_PARTITION)
|
| 78 | state->parts[slot].flags = ADDPART_FLAG_RAID;
|
| 79 | }
|
| 80 | slot++;
|
| 81 | }
|
| 82 | seq_buf_puts(&state->pp_buf, "\n");
|
| 83 | put_dev_sector(sect);
|
| 84 | return 1;
|
| 85 | }
|