Blame view
block/partitions/sgi.c
2.22 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
/* * fs/partitions/sgi.c * * Code extracted from drivers/block/genhd.c */ #include "check.h" #include "sgi.h" struct sgi_disklabel { __be32 magic_mushroom; /* Big fat spliff... */ __be16 root_part_num; /* Root partition number */ __be16 swap_part_num; /* Swap partition number */ s8 boot_file[16]; /* Name of boot file for ARCS */ u8 _unused0[48]; /* Device parameter useless crapola.. */ struct sgi_volume { s8 name[8]; /* Name of volume */ __be32 block_num; /* Logical block number */ __be32 num_bytes; /* How big, in bytes */ } volume[15]; struct sgi_partition { __be32 num_blocks; /* Size in logical blocks */ __be32 first_block; /* First logical block */ __be32 type; /* Type of this partition */ } partitions[16]; __be32 csum; /* Disk label checksum */ __be32 _unused1; /* Padding */ }; |
1493bf217 block: use struct... |
29 |
int sgi_partition(struct parsed_partitions *state) |
1da177e4c Linux-2.6.12-rc2 |
30 31 32 33 34 35 36 37 38 39 |
{ int i, csum; __be32 magic; int slot = 1; unsigned int start, blocks; __be32 *ui, cs; Sector sect; struct sgi_disklabel *label; struct sgi_partition *p; char b[BDEVNAME_SIZE]; |
1493bf217 block: use struct... |
40 |
label = read_part_sector(state, 0, §); |
1da177e4c Linux-2.6.12-rc2 |
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
if (!label) return -1; p = &label->partitions[0]; magic = label->magic_mushroom; if(be32_to_cpu(magic) != SGI_LABEL_MAGIC) { /*printk("Dev %s SGI disklabel: bad magic %08x ", bdevname(bdev, b), be32_to_cpu(magic));*/ put_dev_sector(sect); return 0; } ui = ((__be32 *) (label + 1)) - 1; for(csum = 0; ui >= ((__be32 *) label);) { cs = *ui--; csum += be32_to_cpu(cs); } if(csum) { printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted ", |
1493bf217 block: use struct... |
60 |
bdevname(state->bdev, b)); |
1da177e4c Linux-2.6.12-rc2 |
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
put_dev_sector(sect); return 0; } /* All SGI disk labels have 16 partitions, disks under Linux only * have 15 minor's. Luckily there are always a few zero length * partitions which we don't care about so we never overflow the * current_minor. */ for(i = 0; i < 16; i++, p++) { blocks = be32_to_cpu(p->num_blocks); start = be32_to_cpu(p->first_block); if (blocks) { put_partition(state, slot, start, blocks); if (be32_to_cpu(p->type) == LINUX_RAID_PARTITION) |
d18d7682c [PARTITION]: Add ... |
75 |
state->parts[slot].flags = ADDPART_FLAG_RAID; |
1da177e4c Linux-2.6.12-rc2 |
76 77 78 |
} slot++; } |
9c867fbe0 partitions: fix s... |
79 80 |
strlcat(state->pp_buf, " ", PAGE_SIZE); |
1da177e4c Linux-2.6.12-rc2 |
81 82 83 |
put_dev_sector(sect); return 1; } |