struct fdisk_context *cxt;
size_t partno;
+
uint64_t start;
uint64_t end;
uint64_t size;
+
char *name;
char *uuid;
char *attrs;
struct fdisk_parttype *type;
+ /* private fields */
+ char start_post;
+ char end_post;
+ char size_post;
+ uint64_t fsize;
+ uint64_t bsize;
+ uint64_t cpg;
+
+
unsigned int nested : 1, /* logical partition */
used : 1, /* partition used */
endrel : 1; /* end is specified as relative number */
fdisk_reset_partition(pa);
pa->cxt = cxt;
+ pa->partno = partno;
rc = cxt->label->op->get_part(cxt, partno, pa);
if (rc == 0 && fdisk_partition_is_used(pa))
rc = fdisk_get_partition(cxt, i, pa);
if (rc)
- goto done;
+ continue;
if (!fdisk_partition_is_used(pa))
continue;
ln = tt_add_line(tb, NULL);
continue;
rc = fdisk_partition_to_string(pa, col->id, &data);
if (rc)
- goto done;
+ continue;
tt_line_set_data(ln, j, data);
}
}
if (!tt_is_empty(tb))
rc = fdisk_print_table(cxt, tb);
+ else
+ DBG(LABEL, dbgprint("table empty, not list"));
done:
if (org != cols)
free(cols);
switch (id) {
case FDISK_COL_DEVICE:
- p = fdisk_partname(pa->cxt->dev_path, pa->partno + 1);
+ if (pa->cxt->label->flags & FDISK_LABEL_FL_INCHARS_PARTNO)
+ rc = asprintf(&p, "%c", (int) pa->partno + 'a');
+ else
+ p = fdisk_partname(pa->cxt->dev_path, pa->partno + 1);
break;
case FDISK_COL_START:
- if (asprintf(&p, "%ju", pa->start) < 0)
- rc = -ENOMEM;
+ rc = pa->start_post ?
+ asprintf(&p, "%ju%c", pa->start, pa->start_post) :
+ asprintf(&p, "%ju", pa->start);
break;
case FDISK_COL_END:
- if (asprintf(&p, "%ju", pa->end) < 0)
- rc = -ENOMEM;
+ rc = pa->end_post ?
+ asprintf(&p, "%ju%c", pa->end, pa->end_post) :
+ asprintf(&p, "%ju", pa->end);
break;
case FDISK_COL_SIZE:
if (fdisk_context_display_details(pa->cxt)) {
- if (asprintf(&p, "%ju", pa->size))
- rc = -ENOMEM;
+ rc = pa->size_post ?
+ asprintf(&p, "%ju%c", pa->size, pa->size_post) :
+ asprintf(&p, "%ju", pa->size);
} else {
p = size_to_human_string(SIZE_SUFFIX_1LETTER, pa->size);
if (!p)
rc = -ENOMEM;
}
break;
+ case FDISK_COL_BSIZE:
+ rc = asprintf(&p, "%ju", pa->bsize);
+ break;
+ case FDISK_COL_FSIZE:
+ rc = asprintf(&p, "%ju", pa->fsize);
+ break;
+ case FDISK_COL_CPG:
+ rc = asprintf(&p, "%ju", pa->cpg);
+ break;
case FDISK_COL_TYPE:
p = pa->type && pa->type->name ? strdup(pa->type->name) : NULL;
break;
return -EINVAL;
}
+ if (rc < 0)
+ rc = -ENOMEM;
+ else if (rc > 0)
+ rc = 0;
+
if (data)
*data = p;
return rc;