0001
0002
0003
0004
0005
0006
0007
0008 #include "check.h"
0009
0010 #define SGI_LABEL_MAGIC 0x0be5a941
0011
0012 enum {
0013 LINUX_RAID_PARTITION = 0xfd,
0014 };
0015
0016 struct sgi_disklabel {
0017 __be32 magic_mushroom;
0018 __be16 root_part_num;
0019 __be16 swap_part_num;
0020 s8 boot_file[16];
0021 u8 _unused0[48];
0022 struct sgi_volume {
0023 s8 name[8];
0024 __be32 block_num;
0025 __be32 num_bytes;
0026 } volume[15];
0027 struct sgi_partition {
0028 __be32 num_blocks;
0029 __be32 first_block;
0030 __be32 type;
0031 } partitions[16];
0032 __be32 csum;
0033 __be32 _unused1;
0034 };
0035
0036 int sgi_partition(struct parsed_partitions *state)
0037 {
0038 int i, csum;
0039 __be32 magic;
0040 int slot = 1;
0041 unsigned int start, blocks;
0042 __be32 *ui, cs;
0043 Sector sect;
0044 struct sgi_disklabel *label;
0045 struct sgi_partition *p;
0046
0047 label = read_part_sector(state, 0, §);
0048 if (!label)
0049 return -1;
0050 p = &label->partitions[0];
0051 magic = label->magic_mushroom;
0052 if(be32_to_cpu(magic) != SGI_LABEL_MAGIC) {
0053
0054
0055 put_dev_sector(sect);
0056 return 0;
0057 }
0058 ui = ((__be32 *) (label + 1)) - 1;
0059 for(csum = 0; ui >= ((__be32 *) label);) {
0060 cs = *ui--;
0061 csum += be32_to_cpu(cs);
0062 }
0063 if(csum) {
0064 printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n",
0065 state->disk->disk_name);
0066 put_dev_sector(sect);
0067 return 0;
0068 }
0069
0070
0071
0072
0073
0074 for(i = 0; i < 16; i++, p++) {
0075 blocks = be32_to_cpu(p->num_blocks);
0076 start = be32_to_cpu(p->first_block);
0077 if (blocks) {
0078 put_partition(state, slot, start, blocks);
0079 if (be32_to_cpu(p->type) == LINUX_RAID_PARTITION)
0080 state->parts[slot].flags = ADDPART_FLAG_RAID;
0081 }
0082 slot++;
0083 }
0084 strlcat(state->pp_buf, "\n", PAGE_SIZE);
0085 put_dev_sector(sect);
0086 return 1;
0087 }