]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: remove flags from fdisk_ask API
authorKarel Zak <kzak@redhat.com>
Fri, 21 Nov 2014 14:31:55 +0000 (15:31 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 21 Nov 2014 14:31:55 +0000 (15:31 +0100)
We don't use it for anything usable, lets kill this over-engineering.

Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fdisk-menu.c
disk-utils/fdisk.c
libfdisk/src/ask.c
libfdisk/src/bsd.c
libfdisk/src/dos.c
libfdisk/src/fdiskP.h
libfdisk/src/gpt.c
libfdisk/src/libfdisk.h
libfdisk/src/sgi.c
libfdisk/src/sun.c

index 8afdf69085a1b6753efead2ec20f9e374913ceee..f920ad01c5845dda251fc1f229d125d2ffa028f2 100644 (file)
@@ -661,8 +661,7 @@ static int gpt_menu_cb(struct fdisk_context **cxt0,
                                return -ENOMEM;
                        *cxt0 = cxt = mbr;
                        fdisk_enable_details(cxt, 1);   /* keep us in expert mode */
-                       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                                       _("Entering protective/hybrid MBR disklabel."));
+                       fdisk_info(cxt, _("Entering protective/hybrid MBR disklabel."));
                        return 0;
                }
 
@@ -756,8 +755,7 @@ static int dos_menu_cb(struct fdisk_context **cxt0,
                                fdisk_unref_context(bsd);
                        else {
                                *cxt0 = cxt = bsd;
-                               fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                                               _("Entering nested BSD disklabel."));
+                               fdisk_info(cxt, _("Entering nested BSD disklabel."));
                        }
                        break;
                }
index 7d6951df9217b40f94ef36fd5aee2623bc977dc5..8a66caeed6c3fc1f041aac87609a6c0e65016d26 100644 (file)
@@ -514,7 +514,7 @@ void change_partition_type(struct fdisk_context *cxt)
        } while (!t);
 
        if (fdisk_set_partition_type(cxt, i, t) == 0)
-               fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
+               fdisk_info(cxt,
                        _("Changed type of partition '%s' to '%s'."),
                        old, t ? fdisk_parttype_get_name(t) : _("Unknown"));
        else
index 0fc48954fea3121bfbfaf26ec8369a63eca88f3e..d312a2fcccad75396dc443c73c02ad5abee80c55 100644 (file)
@@ -80,24 +80,50 @@ void fdisk_unref_ask(struct fdisk_ask *ask)
        }
 }
 
+/**
+ * fdisk_ask_get_query:
+ * @ask: ask instance
+ *
+ * Returns: pointer to dialog string.
+ */
 const char *fdisk_ask_get_query(struct fdisk_ask *ask)
 {
        assert(ask);
        return ask->query;
 }
 
+/**
+ * fdisk_ask_set_query:
+ * @ask: ask instance
+ * @str: new query string
+ *
+ * Returns: 0 on success, <0 on error
+ */
 int fdisk_ask_set_query(struct fdisk_ask *ask, const char *str)
 {
        assert(ask);
        return !strdup_to_struct_member(ask, query, str) ? -ENOMEM : 0;
 }
 
+/**
+ * fdisk_ask_get_type:
+ * @ask: ask instance
+ *
+ * Returns: FDISK_ASKTYPE_*
+ */
 int fdisk_ask_get_type(struct fdisk_ask *ask)
 {
        assert(ask);
        return ask->type;
 }
 
+/**
+ * fdisk_ask_set_type:
+ * @ask: ask instance
+ * @type: new ask type
+ *
+ * Returns: 0 on success, <0 on error
+ */
 int fdisk_ask_set_type(struct fdisk_ask *ask, int type)
 {
        assert(ask);
@@ -105,19 +131,6 @@ int fdisk_ask_set_type(struct fdisk_ask *ask, int type)
        return 0;
 }
 
-unsigned int fdisk_ask_get_flags(struct fdisk_ask *ask)
-{
-       assert(ask);
-       return ask->flags;
-}
-
-int fdisk_ask_set_flags(struct fdisk_ask *ask, unsigned int flags)
-{
-       assert(ask);
-       ask->flags = flags;
-       return 0;
-}
-
 int fdisk_do_ask(struct fdisk_context *cxt, struct fdisk_ask *ask)
 {
        int rc;
@@ -711,7 +724,7 @@ int fdisk_ask_print_set_mesg(struct fdisk_ask *ask, const char *mesg)
 }
 
 static int do_vprint(struct fdisk_context *cxt, int errnum, int type,
-                unsigned int flags, const char *fmt, va_list va)
+                    const char *fmt, va_list va)
 {
        struct fdisk_ask *ask;
        int rc;
@@ -729,7 +742,6 @@ static int do_vprint(struct fdisk_context *cxt, int errnum, int type,
        }
 
        fdisk_ask_set_type(ask, type);
-       fdisk_ask_set_flags(ask, flags);
        fdisk_ask_print_set_mesg(ask, mesg);
        if (errnum >= 0)
                fdisk_ask_print_set_errno(ask, errnum);
@@ -747,24 +759,9 @@ int fdisk_info(struct fdisk_context *cxt, const char *fmt, ...)
 
        assert(cxt);
        va_start(ap, fmt);
-       rc = do_vprint(cxt, -1, FDISK_ASKTYPE_INFO, 0, fmt, ap);
-       va_end(ap);
-       return rc;
-}
-
-/* "smart" version, allows to set flags for the message */
-int fdisk_sinfo(struct fdisk_context *cxt,
-               unsigned int flags, const char *fmt, ...)
-{
-       int rc;
-       va_list ap;
-
-       assert(cxt);
-       va_start(ap, fmt);
-       rc = do_vprint(cxt, -1, FDISK_ASKTYPE_INFO, flags, fmt, ap);
+       rc = do_vprint(cxt, -1, FDISK_ASKTYPE_INFO, fmt, ap);
        va_end(ap);
        return rc;
-
 }
 
 int fdisk_warn(struct fdisk_context *cxt, const char *fmt, ...)
@@ -774,7 +771,7 @@ int fdisk_warn(struct fdisk_context *cxt, const char *fmt, ...)
 
        assert(cxt);
        va_start(ap, fmt);
-       rc = do_vprint(cxt, errno, FDISK_ASKTYPE_WARN, 0, fmt, ap);
+       rc = do_vprint(cxt, errno, FDISK_ASKTYPE_WARN, fmt, ap);
        va_end(ap);
        return rc;
 }
@@ -786,7 +783,7 @@ int fdisk_warnx(struct fdisk_context *cxt, const char *fmt, ...)
 
        assert(cxt);
        va_start(ap, fmt);
-       rc = do_vprint(cxt, -1, FDISK_ASKTYPE_WARNX, 0, fmt, ap);
+       rc = do_vprint(cxt, -1, FDISK_ASKTYPE_WARNX, fmt, ap);
        va_end(ap);
        return rc;
 }
@@ -800,7 +797,7 @@ int fdisk_info_new_partition(
        char *str = size_to_human_string(SIZE_SUFFIX_3LETTER | SIZE_SUFFIX_SPACE,
                                     (uint64_t)(stop - start + 1) * cxt->sector_size);
 
-       rc = fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
+       rc = fdisk_info(cxt,
                        _("Created a new partition %d of type '%s' and of size %s."),
                        num, t ? t->name : _("Unknown"), str);
        free(str);
index 16281e2f6e30a71703bbfcd1a9699b118f9c4502..28b37babd34b1810f935312b81c4b21b233aefc4 100644 (file)
@@ -574,8 +574,7 @@ static int bsd_get_bootstrap(struct fdisk_context *cxt,
                return -errno;
        }
 
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("The bootstrap file %s successfully loaded."), path);
+       fdisk_info(cxt, _("The bootstrap file %s successfully loaded."), path);
        close (fd);
        return 0;
 }
@@ -646,8 +645,7 @@ int fdisk_bsd_write_bootstrap(struct fdisk_context *cxt)
                goto done;
        }
 
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("Bootstrap installed on %s."), cxt->dev_path);
+       fdisk_info(cxt, _("Bootstrap installed on %s."), cxt->dev_path);
        sync_disks(cxt);
 
        rc = 0;
@@ -818,8 +816,7 @@ static int bsd_write_disklabel(struct fdisk_context *cxt)
        }
        sync_disks(cxt);
 
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("Disklabel written to %s."), cxt->dev_path);
+       fdisk_info(cxt, _("Disklabel written to %s."), cxt->dev_path);
        return 0;
 }
 
@@ -889,8 +886,7 @@ int fdisk_bsd_link_partition(struct fdisk_context *cxt)
        cxt->label->nparts_cur = d->d_npartitions;
        fdisk_label_set_changed(cxt->label, 1);
 
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("BSD partition '%c' linked to DOS partition %zu."),
+       fdisk_info(cxt, _("BSD partition '%c' linked to DOS partition %zu."),
                        'a' + (int) i, k + 1);
        return 0;
 }
index edf5cc2e093cf843a7100ace95ae070e1ac04d68..30b37e67242d849e51ff778dbd55c513f135efe5 100644 (file)
@@ -655,8 +655,7 @@ static int dos_create_disklabel(struct fdisk_context *cxt)
        /* Put MBR signature */
        mbr_set_magic(cxt->firstsector);
 
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       ("Created a new DOS disklabel with disk "
+       fdisk_info(cxt, _("Created a new DOS disklabel with disk "
                         "identifier 0x%08x."), id);
        return 0;
 }
@@ -693,8 +692,7 @@ static int dos_set_disklabel_id(struct fdisk_context *cxt)
        l->non_pt_changed = 1;
        fdisk_label_set_changed(cxt->label, 1);
 
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("Disk identifier changed from 0x%08x to 0x%08x."),
+       fdisk_info(cxt, _("Disk identifier changed from 0x%08x to 0x%08x."),
                        old, id);
        return 0;
 }
@@ -2207,8 +2205,7 @@ static int dos_toggle_partition_flag(
 
                p->boot_ind = (p->boot_ind ? 0 : ACTIVE_FLAG);
                partition_set_changed(cxt, i, 1);
-               fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       p->boot_ind ?
+               fdisk_info(cxt, p->boot_ind ?
                        _("The bootable flag on partition %zu is enabled now.") :
                        _("The bootable flag on partition %zu is disabled now."),
                        i + 1);
index 3deb64078e03e0857f1ff2e99a8c83481c4fcfb2..62c352e2f4b0402dacf7ea91aee274f42758ec02 100644 (file)
@@ -293,7 +293,6 @@ struct ask_menuitem {
 struct fdisk_ask {
        int             type;           /* FDISK_ASKTYPE_* */
        char            *query;
-       unsigned int    flags;
 
        int             refcount;
 
index 12756997a96b8b7ada402ebad29e088abb58efb4..06f3bef89cdb4ae6e3571ed5448eb7e4a6c7cbaa 100644 (file)
@@ -1524,8 +1524,7 @@ static int gpt_set_partition(struct fdisk_context *cxt, size_t n,
                if (rc)
                        return rc;
                guid_to_string(&e->partition_guid, new_u);
-               fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("Partition UUID changed from %s to %s."),
+               fdisk_info(cxt, _("Partition UUID changed from %s to %s."),
                        old_u, new_u);
        }
 
@@ -1533,8 +1532,7 @@ static int gpt_set_partition(struct fdisk_context *cxt, size_t n,
                char *old = encode_to_utf8((unsigned char *)e->name, sizeof(e->name));
                gpt_entry_set_name(e, pa->name);
 
-               fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("Partition name changed from '%s' to '%.*s'."),
+               fdisk_info(cxt, _("Partition name changed from '%s' to '%.*s'."),
                        old, (int) GPT_PART_NAME_LEN, pa->name);
                free(old);
        }
@@ -2215,8 +2213,7 @@ static int gpt_create_disklabel(struct fdisk_context *cxt)
 
        guid_to_string(&gpt->pheader->disk_guid, str);
        fdisk_label_set_changed(cxt->label, 1);
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("Created a new GPT disklabel (GUID: %s)."), str);
+       fdisk_info(cxt, _("Created a new GPT disklabel (GUID: %s)."), str);
 done:
        return rc;
 }
@@ -2274,8 +2271,7 @@ static int gpt_set_disklabel_id(struct fdisk_context *cxt)
 
        gpt_get_disklabel_id(cxt, &new);
 
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("Disk identifier changed from %s to %s."), old, new);
+       fdisk_info(cxt, _("Disk identifier changed from %s to %s."), old, new);
 
        free(old);
        free(new);
@@ -2372,14 +2368,12 @@ static int gpt_toggle_partition_flag(
        gpt->ents[i].attrs = cpu_to_le64(attrs);
 
        if (flag == GPT_FLAG_GUIDSPECIFIC)
-               fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       isset(bits, bit) ?
+               fdisk_info(cxt, isset(bits, bit) ?
                        _("The GUID specific bit %d on partition %zu is enabled now.") :
                        _("The GUID specific bit %d on partition %zu is disabled now."),
                        bit, i + 1);
        else
-               fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       isset(bits, bit) ?
+               fdisk_info(cxt, isset(bits, bit) ?
                        _("The %s flag on partition %zu is enabled now.") :
                        _("The %s flag on partition %zu is disabled now."),
                        name, i + 1);
@@ -2427,7 +2421,7 @@ static int gpt_reorder(struct fdisk_context *cxt)
        gpt_recompute_crc(gpt->bheader, gpt->ents);
        fdisk_label_set_changed(cxt->label, 1);
 
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS, _("Done."));
+       fdisk_info(cxt, _("Done."));
        return 0;
 }
 
index 3ca1f7aead92fff3d5ee0b11a1c798be3f8b9bfd..151a215f8d83514dff716d8da8d0f299be8c5d5a 100644 (file)
@@ -64,11 +64,6 @@ enum {
        FDISK_ASKTYPE_MENU
 };
 
-/* extra flags for info massages (see fdisk_sinfo() */
-enum {
-       FDISK_INFO_SUCCESS      /* info after successful action */
-};
-
 /* init.c */
 extern void fdisk_init_debug(int mask);
 
@@ -461,8 +456,6 @@ extern const char *fdisk_ask_get_query(struct fdisk_ask *ask);
 extern int fdisk_ask_set_query(struct fdisk_ask *ask, const char *str);
 extern int fdisk_ask_get_type(struct fdisk_ask *ask);
 extern int fdisk_ask_set_type(struct fdisk_ask *ask, int type);
-extern int fdisk_ask_set_flags(struct fdisk_ask *ask, unsigned int flags);
-extern unsigned int fdisk_ask_get_flags(struct fdisk_ask *ask);
 
 extern int fdisk_do_ask(struct fdisk_context *cxt, struct fdisk_ask *ask);
 
@@ -506,8 +499,6 @@ extern int fdisk_info(struct fdisk_context *cxt, const char *fmt, ...)
                        __attribute__ ((__format__ (__printf__, 2, 3)));
 extern int fdisk_colon(struct fdisk_context *cxt, const char *fmt, ...)
                        __attribute__ ((__format__ (__printf__, 2, 3)));
-extern int fdisk_sinfo(struct fdisk_context *cxt, unsigned int flags, const char *fmt, ...)
-                       __attribute__ ((__format__ (__printf__, 3, 4)));
 
 extern int fdisk_warnx(struct fdisk_context *cxt, const char *fmt, ...)
                        __attribute__ ((__format__ (__printf__, 2, 3)));
index c99deb3c796d84abb5438cc854824cee0f4b28d3..436ec1f6d7a5de5347568313a1579e78f65157c3 100644 (file)
@@ -403,8 +403,7 @@ int fdisk_sgi_set_bootfile(struct fdisk_context *cxt)
 
        memcpy(sgilabel->boot_file, name, sz);
 
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("Bootfile has been changed to \"%s\"."), name);
+       fdisk_info(cxt, _("Bootfile has been changed to \"%s\"."), name);
 done:
        free(name);
        return rc;
@@ -1000,8 +999,7 @@ static int sgi_create_disklabel(struct fdisk_context *cxt)
        }
        cxt->label->nparts_cur = count_used_partitions(cxt);
 
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("Created a new SGI disklabel."));
+       fdisk_info(cxt, _("Created a new SGI disklabel."));
        return 0;
 }
 
index 82dd2c326b54dc25d7ca6cefe8eee5ab7288043b..2ef28031d58e3e9182bbc379c634c267da28519a 100644 (file)
@@ -286,8 +286,7 @@ static int sun_create_disklabel(struct fdisk_context *cxt)
        fdisk_label_set_changed(cxt->label, 1);
        cxt->label->nparts_cur = count_used_partitions(cxt);
 
-       fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-                       _("Created a new Sun disklabel."));
+       fdisk_info(cxt, _("Created a new Sun disklabel."));
        return 0;
 }