The fdisk_dump_* prefix will be used for sfdisk-like functionality.
The patch also add FDISK_ prefix to fdisk_get_unit() options.
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk_get_geom_cylinders(cxt));
fdisk_info(cxt, _("Units: %s of %d * %ld = %ld bytes"),
- fdisk_get_unit(cxt, PLURAL),
+ fdisk_get_unit(cxt, FDISK_PLURAL),
fdisk_get_units_per_sector(cxt),
fdisk_get_sector_size(cxt),
fdisk_get_units_per_sector(cxt) * fdisk_get_sector_size(cxt));
/* context.h */
-#define PLURAL 0
-#define SINGULAR 1
+#define FDISK_PLURAL 0
+#define FDISK_SINGULAR 1
struct fdisk_context *fdisk_new_context(void);
extern int fdisk_partition_start_follow_default(struct fdisk_partition *pa, int enable);
extern int fdisk_partition_end_follow_default(struct fdisk_partition *pa, int enable);
-extern int fdisk_dump_partition(struct fdisk_partition *pa, FILE *f);
-
extern int fdisk_reorder_partitions(struct fdisk_context *cxt);
/* table.c */
extern int fdisk_reset_table(struct fdisk_table *tb);
extern void fdisk_ref_table(struct fdisk_table *tb);
extern void fdisk_unref_table(struct fdisk_table *tb);
-extern int fdisk_dump_table(struct fdisk_table *b, FILE *f);
extern int fdisk_table_get_nents(struct fdisk_table *tb);
extern int fdisk_table_is_empty(struct fdisk_table *tb);
extern int fdisk_table_add_partition(struct fdisk_table *tb, struct fdisk_partition *pa);
}
}
-int fdisk_dump_partition(struct fdisk_partition *pa, FILE *f)
-{
- assert(pa);
- assert(f);
-
- if (pa->partno == FDISK_EMPTY_PARTNO)
- fputs("# ", f);
- else
- fprintf(f, "#%zu ", pa->partno);
-
- fprintf(f, "[%p] start=%ju, end=%ju, size=%ju",
- pa, pa->start, pa->end, pa->size);
- if (pa->parent_partno != FDISK_EMPTY_PARTNO)
- fprintf(f, ", parent=%zu", pa->parent_partno);
- if (fdisk_partition_is_freespace(pa))
- fputs(" freespace", f);
- if (fdisk_partition_is_container(pa))
- fputs(" container", f);
- if (fdisk_partition_is_nested(pa))
- fputs(" nested", f);
- fputc('\n', f);
- return 0;
-}
-
/**
* fdisk_partition_set_start:
* @pa: partition
return -ERANGE;
} else {
snprintf(mesg, sizeof(mesg), _("First %s"),
- fdisk_get_unit(cxt, SINGULAR));
+ fdisk_get_unit(cxt, FDISK_SINGULAR));
ask = fdisk_new_ask();
if (!ask)
return -ENOMEM;
} else {
snprintf(mesg, sizeof(mesg),
_("Last %s or +%s or +size{K,M,G,T,P}"),
- fdisk_get_unit(cxt, SINGULAR),
- fdisk_get_unit(cxt, PLURAL));
+ fdisk_get_unit(cxt, FDISK_SINGULAR),
+ fdisk_get_unit(cxt, FDISK_PLURAL));
ask = fdisk_new_ask();
if (!ask)
struct fdisk_ask *ask;
snprintf(mesg, sizeof(mesg), _("First %s"),
- fdisk_get_unit(cxt, SINGULAR));
+ fdisk_get_unit(cxt, FDISK_SINGULAR));
for (;;) {
ask = fdisk_new_ask();
if (!ask)
snprintf(mesg, sizeof(mesg),
_("Last %s or +%s or +size{K,M,G,T,P}"),
- fdisk_get_unit(cxt, SINGULAR),
- fdisk_get_unit(cxt, PLURAL));
+ fdisk_get_unit(cxt, FDISK_SINGULAR),
+ fdisk_get_unit(cxt, FDISK_PLURAL));
fdisk_ask_set_query(ask, mesg);
fdisk_ask_set_type(ask, FDISK_ASKTYPE_OFFSET);
_("You haven't covered the whole disk with the 3rd partition, but your value\n"
"%lu %s covers some other partition. Your entry has been changed\n"
"to %lu %s"),
- (unsigned long) fdisk_scround(cxt, last), fdisk_get_unit(cxt, SINGULAR),
- (unsigned long) fdisk_scround(cxt, stop), fdisk_get_unit(cxt, SINGULAR));
+ (unsigned long) fdisk_scround(cxt, last), fdisk_get_unit(cxt, FDISK_SINGULAR),
+ (unsigned long) fdisk_scround(cxt, stop), fdisk_get_unit(cxt, FDISK_SINGULAR));
last = stop;
}
} else if (!whole_disk && last > stop)
return 0;
}
-int fdisk_dump_table(struct fdisk_table *tb, FILE *f)
-{
- struct fdisk_partition *pa;
- struct fdisk_iter itr;
- int i = 0;
-
- assert(tb);
- assert(f);
-
- fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
-
- fprintf(f, "--table--%p\n", tb);
- while (fdisk_table_next_partition(tb, &itr, &pa) == 0) {
- fprintf(f, "%d: ", i++);
- fdisk_dump_partition(pa, f);
- }
- fputs("-----\n", f);
- return 0;
-}
-
-
typedef int (*fdisk_partcmp_t)(struct fdisk_partition *, struct fdisk_partition *);
static int cmp_parts_wrapper(struct list_head *a, struct list_head *b, void *data)
}
}
- DBG(LABEL, fdisk_dump_table(*tb, stderr));
done:
fdisk_unref_table(parts);
return rc;
}
return 0;
}
+