diff options
-rw-r--r-- | disk-utils/fdisk-menu.c | 6 | ||||
-rw-r--r-- | disk-utils/fdisk.c | 2 | ||||
-rw-r--r-- | libfdisk/src/ask.c | 65 | ||||
-rw-r--r-- | libfdisk/src/bsd.c | 12 | ||||
-rw-r--r-- | libfdisk/src/dos.c | 9 | ||||
-rw-r--r-- | libfdisk/src/fdiskP.h | 1 | ||||
-rw-r--r-- | libfdisk/src/gpt.c | 20 | ||||
-rw-r--r-- | libfdisk/src/libfdisk.h | 9 | ||||
-rw-r--r-- | libfdisk/src/sgi.c | 6 | ||||
-rw-r--r-- | libfdisk/src/sun.c | 3 |
10 files changed, 51 insertions, 82 deletions
diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c index 8afdf6908..f920ad01c 100644 --- a/disk-utils/fdisk-menu.c +++ b/disk-utils/fdisk-menu.c @@ -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; } diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 7d6951df9..8a66caeed 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -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 diff --git a/libfdisk/src/ask.c b/libfdisk/src/ask.c index 0fc48954f..d312a2fcc 100644 --- a/libfdisk/src/ask.c +++ b/libfdisk/src/ask.c @@ -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); diff --git a/libfdisk/src/bsd.c b/libfdisk/src/bsd.c index 16281e2f6..28b37babd 100644 --- a/libfdisk/src/bsd.c +++ b/libfdisk/src/bsd.c @@ -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; } diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index edf5cc2e0..30b37e672 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -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); diff --git a/libfdisk/src/fdiskP.h b/libfdisk/src/fdiskP.h index 3deb64078..62c352e2f 100644 --- a/libfdisk/src/fdiskP.h +++ b/libfdisk/src/fdiskP.h @@ -293,7 +293,6 @@ struct ask_menuitem { struct fdisk_ask { int type; /* FDISK_ASKTYPE_* */ char *query; - unsigned int flags; int refcount; diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index 12756997a..06f3bef89 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -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; } diff --git a/libfdisk/src/libfdisk.h b/libfdisk/src/libfdisk.h index 3ca1f7aea..151a215f8 100644 --- a/libfdisk/src/libfdisk.h +++ b/libfdisk/src/libfdisk.h @@ -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))); diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c index c99deb3c7..436ec1f6d 100644 --- a/libfdisk/src/sgi.c +++ b/libfdisk/src/sgi.c @@ -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; } diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c index 82dd2c326..2ef28031d 100644 --- a/libfdisk/src/sun.c +++ b/libfdisk/src/sun.c @@ -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; } |