From: Karel Zak Date: Fri, 22 Aug 2014 08:25:35 +0000 (+0200) Subject: libfdisk: remove debug dump function, cleanup API X-Git-Tag: v2.26-rc1~492 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=385810d22a31fe968fcf76e1b608ac3031ddd4fa;p=thirdparty%2Futil-linux.git libfdisk: remove debug dump function, cleanup API 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 --- diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index cd70dc99b1..4f9d69454d 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -535,7 +535,7 @@ void list_disk_geometry(struct fdisk_context *cxt) 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)); diff --git a/libfdisk/src/libfdisk.h b/libfdisk/src/libfdisk.h index 7bb6dd8fc2..303b927b84 100644 --- a/libfdisk/src/libfdisk.h +++ b/libfdisk/src/libfdisk.h @@ -72,8 +72,8 @@ extern void fdisk_init_debug(int mask); /* context.h */ -#define PLURAL 0 -#define SINGULAR 1 +#define FDISK_PLURAL 0 +#define FDISK_SINGULAR 1 struct fdisk_context *fdisk_new_context(void); @@ -264,8 +264,6 @@ extern int fdisk_partition_partno_follow_default(struct fdisk_partition *pa, int 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 */ @@ -273,7 +271,6 @@ extern struct fdisk_table *fdisk_new_table(void); 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); diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c index 48e91cf293..d3a7b27fa5 100644 --- a/libfdisk/src/partition.c +++ b/libfdisk/src/partition.c @@ -80,30 +80,6 @@ void fdisk_unref_partition(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 diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c index bf23017782..10e5b56728 100644 --- a/libfdisk/src/sgi.c +++ b/libfdisk/src/sgi.c @@ -821,7 +821,7 @@ static int sgi_add_partition(struct fdisk_context *cxt, 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; @@ -860,8 +860,8 @@ static int sgi_add_partition(struct fdisk_context *cxt, } 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) diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c index 9a00c65dab..7148e4f680 100644 --- a/libfdisk/src/sun.c +++ b/libfdisk/src/sun.c @@ -526,7 +526,7 @@ static int sun_add_partition( 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) @@ -621,8 +621,8 @@ static int sun_add_partition( 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); @@ -669,8 +669,8 @@ static int sun_add_partition( _("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) diff --git a/libfdisk/src/table.c b/libfdisk/src/table.c index eb09838956..28540b9e03 100644 --- a/libfdisk/src/table.c +++ b/libfdisk/src/table.c @@ -291,27 +291,6 @@ int fdisk_get_partitions(struct fdisk_context *cxt, struct fdisk_table **tb) 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) @@ -524,7 +503,6 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb) } } - DBG(LABEL, fdisk_dump_table(*tb, stderr)); done: fdisk_unref_table(parts); return rc; @@ -552,3 +530,4 @@ int fdisk_table_wrong_order(struct fdisk_table *tb) } return 0; } +