{
struct dos_partition *p;
struct pte *pe;
- sector_t start, size;
assert(cxt);
assert(pa);
if (pa->type && !pa->type->code)
fdisk_warnx(cxt, _("Type 0 means free space to many systems. "
"Having partitions of type 0 is probably unwise."));
- pe = self_pte(cxt, n);
+
p = self_partition(cxt, n);
- start = pa->start ? pa->start : get_abs_partition_start(pe);
- size = pa->size ? pa->size : dos_partition_get_size(p);
+ if (pa->start || pa->size) {
+ sector_t start, size;
+
+ pe = self_pte(cxt, n);
+
+ start = pa->start ? pa->start : get_abs_partition_start(pe);
+ size = pa->size ? pa->size : dos_partition_get_size(p);
- set_partition(cxt, n, 0, start, start + size - 1,
+ set_partition(cxt, n, 0, start, start + size - 1,
pa->type ? pa->type->code : p->sys_ind,
pa->boot);
+ } else {
+ if (pa->type)
+ p->sys_ind = pa->type->code;
+ if (pa->boot != FDISK_EMPTY_BOOTFLAG)
+ p->boot_ind = pa->boot == 1 ? ACTIVE_FLAG : 0;
+ }
+
partition_set_changed(cxt, n, 1);
return 0;
}
char *start_addr; /* start C/H/S in string */
char *end_addr; /* end C/H/S in string */
+ int boot; /* MBR only: 1 = yes, 0 = no, -1 undefined */
+
unsigned int partno_follow_default : 1, /* use default partno */
start_follow_default : 1, /* use default start */
end_follow_default : 1, /* use default end */
freespace : 1, /* this is free space */
container : 1, /* container partition (e.g. extended partition) */
wholedisk : 1, /* special system partition */
- boot : 1, /* bootable (MBR only) */
used : 1; /* partition already used */
};
#define FDISK_EMPTY_PARTNO ((size_t) -1)
#define FDISK_EMPTY_PARTITION { .partno = FDISK_EMPTY_PARTNO }
+#define FDISK_EMPTY_BOOTFLAG (-1)
struct fdisk_table {
struct list_head parts; /* partitions */
INIT_LIST_HEAD(&pa->parts);
pa->partno = FDISK_EMPTY_PARTNO;
pa->parent_partno = FDISK_EMPTY_PARTNO;
+ pa->boot = FDISK_EMPTY_BOOTFLAG;
DBG(PART, ul_debugobj(pa, "alloc"));
return pa;
}
memset(pa, 0, sizeof(*pa));
pa->partno = FDISK_EMPTY_PARTNO;
pa->parent_partno = FDISK_EMPTY_PARTNO;
+ pa->boot = FDISK_EMPTY_BOOTFLAG;
pa->refcount = ref;
INIT_LIST_HEAD(&pa->parts);
}
int fdisk_partition_is_bootable(struct fdisk_partition *pa)
{
- return pa && pa->boot;
+ return pa && pa->boot == 1;
}
int fdisk_partition_is_freespace(struct fdisk_partition *pa)