le16_to_cpu(l->d_npartitions) - BSD_MAXPARTITIONS));
for (i = 0, p = l->d_partitions; i < nparts; i++, p++) {
+ blkid_partition par;
uint32_t start, size;
/* TODO: in fdisk-mode returns all non-zero (p_size) partitions */
continue;
}
- if (!blkid_partlist_add_partition(ls, tab, p->p_fstype, start, size))
+ par = blkid_partlist_add_partition(ls, tab, start, size);
+ if (!par)
goto err;
+
+ blkid_partition_set_type(par, p->p_fstype);
}
return 0;
/* Parse data partition */
for (p = p0, i = 0; i < 4; i++, p++) {
uint32_t abs_start;
+ blkid_partition par;
/* the start is relative to the parental ext.partition */
start = dos_partition_start(p) * ssf;
if (abs_start + size > ex_start + ex_size)
continue;
}
- if (!blkid_partlist_add_partition(ls, tab, p->sys_type,
- abs_start, size))
+
+ par = blkid_partlist_add_partition(ls, tab, abs_start, size);
+ if (!par)
goto err;
+ blkid_partition_set_type(par, p->sys_type);
ct_nodata = 0;
}
/* The first nested ext.partition should be a link to the next
/* Parse primary partitions */
for (p = p0, i = 0; i < 4; i++, p++) {
+ blkid_partition par;
+
start = dos_partition_start(p) * ssf;
size = dos_partition_size(p) * ssf;
if (!size)
continue;
- if (!blkid_partlist_add_partition(ls, tab, p->sys_type,
- start, size))
+
+ par = blkid_partlist_add_partition(ls, tab, start, size);
+ if (!par)
goto err;
+
+ blkid_partition_set_type(par, p->sys_type);
}
/* Linux uses partition numbers greater than 4
continue;
}
- par = blkid_partlist_add_partition(ls, tab, 0,
- start * ssf, size * ssf);
+ par = blkid_partlist_add_partition(ls, tab,
+ start * ssf, size * ssf);
if (!par)
goto err;
start = be32_to_cpu(p->start_block) * ssf;
size = be32_to_cpu(p->block_count) * ssf;
- par = blkid_partlist_add_partition(ls, tab, 0, start, size);
+ par = blkid_partlist_add_partition(ls, tab, start, size);
if (!par)
goto err;
for (i = 0; i < MINIX_MAXPARTITIONS; i++, p++) {
uint32_t start, size;
+ blkid_partition par;
if (p->sys_type != BLKID_MINIX_PARTITION)
continue;
continue;
}
- if (!blkid_partlist_add_partition(ls, tab,
- p->sys_type, start, size))
+ par = blkid_partlist_add_partition(ls, tab, start, size);
+ if (!par)
goto err;
+
+ blkid_partition_set_type(par, p->sys_type);
}
return 0;
}
blkid_partition blkid_partlist_add_partition(blkid_partlist ls,
- blkid_parttable tab, int type,
+ blkid_parttable tab,
blkid_loff_t start, blkid_loff_t size)
{
blkid_partition par = new_partition(ls, tab);
if (!par)
return NULL;
- par->type = type;
par->start = start;
par->size = size;
DBG(DEBUG_LOWPROBE,
- printf("parts: add partition (%p type=0x%x, "
- "start=%llu, size=%llu, table=%p)\n",
- par, par->type,
- (unsigned long long) par->start,
- (unsigned long long) par->size,
- tab));
+ printf("parts: add partition (%p start=%llu, size=%llu, table=%p)\n",
+ par, (unsigned long long) par->start,
+ (unsigned long long) par->size, tab));
return par;
}
return NULL;
}
+int blkid_partition_set_type(blkid_partition par, int type)
+{
+ if (!par)
+ return -1;
+ par->type = type;
+ return 0;
+}
+
/**
* blkid_parttable_get_type:
* @tab: partition table
const char *type, blkid_loff_t offset);
extern blkid_partition blkid_partlist_add_partition(blkid_partlist ls,
- blkid_parttable tab, int type,
+ blkid_parttable tab,
blkid_loff_t start, blkid_loff_t size);
extern int blkid_partlist_set_partno(blkid_partlist ls, int partno);
extern int blkid_partition_set_uuid(blkid_partition par,
const unsigned char *uuid);
+extern int blkid_partition_set_type(blkid_partition par, int type);
+
extern int blkid_partition_set_type_string(blkid_partition par,
const unsigned char *type, size_t len);
uint32_t size = be32_to_cpu(p->num_blocks);
uint32_t start = be32_to_cpu(p->first_block);
uint32_t type = be32_to_cpu(p->type);
+ blkid_partition par;
if (size == 0 || type == SGI_TYPE_VOLULME ||
type == SGI_TYPE_VOLHDR)
continue;
- if (!blkid_partlist_add_partition(ls, tab, type, start, size))
+ par = blkid_partlist_add_partition(ls, tab, start, size);
+ if (!par)
goto err;
+
+ blkid_partition_set_type(par, type);
}
return 0;
uint32_t start = le32_to_cpu(p->s_start);
uint32_t size = le32_to_cpu(p->s_size);
+ blkid_partition par;
if (size == 0 || le16_to_cpu(p->s_tag) == SOLARIS_TAG_WHOLEDISK)
continue;
continue;
}
- if (!blkid_partlist_add_partition(ls, tab,
- le16_to_cpu(p->s_tag), start, size))
+ par = blkid_partlist_add_partition(ls, tab, start, size);
+ if (!par)
goto err;
+
+ blkid_partition_set_type(par, le16_to_cpu(p->s_tag));
}
return 0;
blkid_loff_t start;
blkid_loff_t size;
uint16_t type = infos ? be16_to_cpu(infos[i].id) : 0;
+ blkid_partition par;
start = be32_to_cpu(p->start_cylinder) * spc;
size = be32_to_cpu(p->num_sectors);
if (type == SUN_TAG_WHOLEDISK || !size)
continue;
- if (!blkid_partlist_add_partition(ls, tab, type, start, size))
+ par = blkid_partlist_add_partition(ls, tab, start, size);
+ if (!par)
goto err;
+
+ blkid_partition_set_type(par, type);
}
return 0;
uint32_t start, size;
uint16_t tag, flg;
+ blkid_partition par;
tag = le16_to_cpu(p->s_label);
flg = le16_to_cpu(p->s_flags);
continue;
}
- if (!blkid_partlist_add_partition(ls, tab, tag, start, size))
+ par = blkid_partlist_add_partition(ls, tab, start, size);
+ if (!par)
goto err;
+
+ blkid_partition_set_type(par, tag);
}
return 0;