7 is_extended(int type) {
8 return (type == 5 || type == 0xf || type == 0x85);
12 read_extended_partition(int fd, struct partition *ep,
13 struct slice *sp, int ns)
16 unsigned long start, here;
22 here = start = le32_to_cpu(ep->start_sect);
29 bp = (unsigned char *)getblock(fd, here);
33 if (bp[510] != 0x55 || bp[511] != 0xaa)
36 p = (struct partition *) (bp + 0x1be);
38 for (i=0; i<2; i++, p++) {
39 if (p->nr_sects == 0 || is_extended(p->sys_type))
42 sp[n].start = here + le32_to_cpu(p->start_sect);
43 sp[n].size = le32_to_cpu(p->nr_sects);
47 "dos_extd_partition: too many slices\n");
54 for (i=0; i<2; i++, p++) {
55 if(p->nr_sects != 0 && is_extended(p->sys_type)) {
56 here = start + le32_to_cpu(p->start_sect);
67 return (type == 0xEE);
71 read_dos_pt(int fd, struct slice all, struct slice *sp, int ns) {
73 unsigned long offset = all.start;
77 bp = (unsigned char *)getblock(fd, offset);
81 if (bp[510] != 0x55 || bp[511] != 0xaa)
84 p = (struct partition *) (bp + 0x1be);
86 if (is_gpt(p->sys_type)) {
91 p = (struct partition *) (bp + 0x1be);
93 /* always add, even if zero length */
95 sp[n].start = le32_to_cpu(p->start_sect);
96 sp[n].size = le32_to_cpu(p->nr_sects);
100 "dos_partition: too many slices\n");
105 p = (struct partition *) (bp + 0x1be);
106 for (i=0; i<4; i++) {
107 if (is_extended(p->sys_type))
108 n += read_extended_partition(fd, p, sp+n, ns-n);