]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: remove debug dump function, cleanup API
authorKarel Zak <kzak@redhat.com>
Fri, 22 Aug 2014 08:25:35 +0000 (10:25 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 22 Aug 2014 08:25:35 +0000 (10:25 +0200)
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>
disk-utils/fdisk.c
libfdisk/src/libfdisk.h
libfdisk/src/partition.c
libfdisk/src/sgi.c
libfdisk/src/sun.c
libfdisk/src/table.c

index cd70dc99b12f070e65796c8e4dac77dc07932a84..4f9d69454de8ee8eeaf986fd07e950485504fff9 100644 (file)
@@ -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));
index 7bb6dd8fc268eb74c367bc7b4fb581714fbef227..303b927b84de734330f3cda2a7fbae2f56b4a717 100644 (file)
@@ -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);
index 48e91cf29329e7d3822b2f8fd8d49520153105f2..d3a7b27fa545d1883f9c4492d2211c6af5b1e440 100644 (file)
@@ -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
index bf23017782bef7a4ae653f0d44bac1447b9a0e5a..10e5b5672810c0bb7bdb647f21252b535a179f09 100644 (file)
@@ -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)
index 9a00c65dab9407dad80eba79e9602ae004c54a7c..7148e4f68090c6bef52b67a89206fe25839a44fb 100644 (file)
@@ -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)
index eb09838956e1a0ce1cff7f8d5f99e75476a7c604..28540b9e032aa9caaf7186f690e451587bcb76b0 100644 (file)
@@ -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;
 }
+