0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "check.h"
0011 #include <linux/compiler.h>
0012
0013 #define KARMA_LABEL_MAGIC 0xAB56
0014
0015 int karma_partition(struct parsed_partitions *state)
0016 {
0017 int i;
0018 int slot = 1;
0019 Sector sect;
0020 unsigned char *data;
0021 struct disklabel {
0022 u8 d_reserved[270];
0023 struct d_partition {
0024 __le32 p_res;
0025 u8 p_fstype;
0026 u8 p_res2[3];
0027 __le32 p_offset;
0028 __le32 p_size;
0029 } d_partitions[2];
0030 u8 d_blank[208];
0031 __le16 d_magic;
0032 } __packed *label;
0033 struct d_partition *p;
0034
0035 data = read_part_sector(state, 0, §);
0036 if (!data)
0037 return -1;
0038
0039 label = (struct disklabel *)data;
0040 if (le16_to_cpu(label->d_magic) != KARMA_LABEL_MAGIC) {
0041 put_dev_sector(sect);
0042 return 0;
0043 }
0044
0045 p = label->d_partitions;
0046 for (i = 0 ; i < 2; i++, p++) {
0047 if (slot == state->limit)
0048 break;
0049
0050 if (p->p_fstype == 0x4d && le32_to_cpu(p->p_size)) {
0051 put_partition(state, slot, le32_to_cpu(p->p_offset),
0052 le32_to_cpu(p->p_size));
0053 }
0054 slot++;
0055 }
0056 strlcat(state->pp_buf, "\n", PAGE_SIZE);
0057 put_dev_sector(sect);
0058 return 1;
0059 }
0060