libfdisk: remove fdisk_colon()
It was unnecessary overkill to have colorized "foo:" prefix in fdisk output. Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
0b6fbc2599
commit
412791a995
|
@ -299,48 +299,18 @@ static int ask_offset(struct fdisk_context *cxt,
|
|||
|
||||
static unsigned int info_count;
|
||||
|
||||
static void fputs_info(struct fdisk_ask *ask, FILE *out, char *buf, size_t bufsz)
|
||||
static void fputs_info(struct fdisk_ask *ask, FILE *out)
|
||||
{
|
||||
const char *msg;
|
||||
unsigned int flags;
|
||||
|
||||
assert(ask);
|
||||
|
||||
msg = fdisk_ask_print_get_mesg(ask);
|
||||
flags = fdisk_ask_get_flags(ask);
|
||||
|
||||
if (!msg)
|
||||
return;
|
||||
if (info_count == 1)
|
||||
fputc('\n', out);
|
||||
if (flags == 0 || !colors_wanted())
|
||||
goto simple;
|
||||
|
||||
if (flags & FDISK_INFO_COLON) {
|
||||
size_t sz;
|
||||
char *sep = _(": ");
|
||||
char *p = strstr(msg, sep);
|
||||
|
||||
if (!p)
|
||||
goto simple;
|
||||
|
||||
sz = strlen(sep);
|
||||
strncpy(buf, msg, bufsz);
|
||||
buf[p - msg + sz] = '\0';
|
||||
|
||||
color_enable(UL_COLOR_BROWN);
|
||||
fputs(buf, out);
|
||||
color_disable();
|
||||
fputs(p + sz, out);
|
||||
|
||||
} else if (flags & FDISK_INFO_SUCCESS) {
|
||||
color_enable(UL_COLOR_BOLD);
|
||||
fputs(msg, out);
|
||||
color_disable();
|
||||
} else {
|
||||
simple:
|
||||
fputs(msg, out);
|
||||
}
|
||||
fputs(msg, out);
|
||||
fputc('\n', out);
|
||||
}
|
||||
|
||||
|
@ -365,7 +335,7 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,
|
|||
return ask_offset(cxt, ask, buf, sizeof(buf));
|
||||
case FDISK_ASKTYPE_INFO:
|
||||
info_count++;
|
||||
fputs_info(ask, stdout, buf, sizeof(buf));
|
||||
fputs_info(ask, stdout);
|
||||
break;
|
||||
case FDISK_ASKTYPE_WARNX:
|
||||
color_fenable(UL_COLOR_RED, stderr);
|
||||
|
@ -562,33 +532,33 @@ void list_disk_geometry(struct fdisk_context *cxt)
|
|||
char *strsz = size_to_human_string(SIZE_SUFFIX_SPACE
|
||||
| SIZE_SUFFIX_3LETTER, bytes);
|
||||
|
||||
fdisk_colon(cxt, _("Disk %s: %s, %ju bytes, %ju sectors"),
|
||||
fdisk_info(cxt, _("Disk %s: %s, %ju bytes, %ju sectors"),
|
||||
cxt->dev_path, strsz,
|
||||
bytes, (uintmax_t) cxt->total_sectors);
|
||||
free(strsz);
|
||||
|
||||
if (fdisk_require_geometry(cxt) || fdisk_context_use_cylinders(cxt))
|
||||
fdisk_colon(cxt, _("Geometry: %d heads, %llu sectors/track, %llu cylinders"),
|
||||
fdisk_info(cxt, _("Geometry: %d heads, %llu sectors/track, %llu cylinders"),
|
||||
cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders);
|
||||
|
||||
fdisk_colon(cxt, _("Units: %s of %d * %ld = %ld bytes"),
|
||||
fdisk_info(cxt, _("Units: %s of %d * %ld = %ld bytes"),
|
||||
fdisk_context_get_unit(cxt, PLURAL),
|
||||
fdisk_context_get_units_per_sector(cxt),
|
||||
cxt->sector_size,
|
||||
fdisk_context_get_units_per_sector(cxt) * cxt->sector_size);
|
||||
|
||||
fdisk_colon(cxt, _("Sector size (logical/physical): %lu bytes / %lu bytes"),
|
||||
fdisk_info(cxt, _("Sector size (logical/physical): %lu bytes / %lu bytes"),
|
||||
cxt->sector_size, cxt->phy_sector_size);
|
||||
fdisk_colon(cxt, _("I/O size (minimum/optimal): %lu bytes / %lu bytes"),
|
||||
fdisk_info(cxt, _("I/O size (minimum/optimal): %lu bytes / %lu bytes"),
|
||||
cxt->min_io_size, cxt->io_size);
|
||||
if (cxt->alignment_offset)
|
||||
fdisk_colon(cxt, _("Alignment offset: %lu bytes"),
|
||||
fdisk_info(cxt, _("Alignment offset: %lu bytes"),
|
||||
cxt->alignment_offset);
|
||||
if (fdisk_dev_has_disklabel(cxt))
|
||||
fdisk_colon(cxt, _("Disklabel type: %s"), cxt->label->name);
|
||||
fdisk_info(cxt, _("Disklabel type: %s"), cxt->label->name);
|
||||
|
||||
if (fdisk_get_disklabel_id(cxt, &id) == 0 && id)
|
||||
fdisk_colon(cxt, _("Disk identifier: %s"), id);
|
||||
fdisk_info(cxt, _("Disk identifier: %s"), id);
|
||||
}
|
||||
|
||||
void list_disklabel(struct fdisk_context *cxt)
|
||||
|
@ -655,7 +625,7 @@ static void dump_buffer(off_t base, unsigned char *buf, size_t sz, int all)
|
|||
static void dump_blkdev(struct fdisk_context *cxt, const char *name,
|
||||
off_t offset, size_t size, int all)
|
||||
{
|
||||
fdisk_colon(cxt, _("\n%s: offset = %ju, size = %zu bytes."),
|
||||
fdisk_info(cxt, _("\n%s: offset = %ju, size = %zu bytes."),
|
||||
name, offset, size);
|
||||
|
||||
if (lseek(cxt->dev_fd, offset, SEEK_SET) == (off_t) -1)
|
||||
|
|
|
@ -713,19 +713,6 @@ int fdisk_sinfo(struct fdisk_context *cxt,
|
|||
|
||||
}
|
||||
|
||||
int fdisk_colon(struct fdisk_context *cxt, const char *fmt, ...)
|
||||
{
|
||||
int rc;
|
||||
va_list ap;
|
||||
|
||||
assert(cxt);
|
||||
va_start(ap, fmt);
|
||||
rc = do_vprint(cxt, -1, FDISK_ASKTYPE_INFO, FDISK_INFO_COLON, fmt, ap);
|
||||
va_end(ap);
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
int fdisk_warn(struct fdisk_context *cxt, const char *fmt, ...)
|
||||
{
|
||||
int rc;
|
||||
|
|
|
@ -366,37 +366,37 @@ static int bsd_list_disklabel(struct fdisk_context *cxt)
|
|||
assert(fdisk_is_disklabel(cxt, BSD));
|
||||
|
||||
if (fdisk_context_display_details(cxt)) {
|
||||
fdisk_colon(cxt, "# %s:", cxt->dev_path);
|
||||
fdisk_info(cxt, "# %s:", cxt->dev_path);
|
||||
|
||||
if ((unsigned) d->d_type < BSD_DKMAXTYPES)
|
||||
fdisk_colon(cxt, _("type: %s"), bsd_dktypenames[d->d_type]);
|
||||
fdisk_info(cxt, _("type: %s"), bsd_dktypenames[d->d_type]);
|
||||
else
|
||||
fdisk_colon(cxt, _("type: %d"), d->d_type);
|
||||
fdisk_info(cxt, _("type: %d"), d->d_type);
|
||||
|
||||
fdisk_colon(cxt, _("disk: %.*s"), (int) sizeof(d->d_typename), d->d_typename);
|
||||
fdisk_colon(cxt, _("label: %.*s"), (int) sizeof(d->d_packname), d->d_packname);
|
||||
fdisk_info(cxt, _("disk: %.*s"), (int) sizeof(d->d_typename), d->d_typename);
|
||||
fdisk_info(cxt, _("label: %.*s"), (int) sizeof(d->d_packname), d->d_packname);
|
||||
|
||||
fdisk_colon(cxt, _("flags: %s"),
|
||||
fdisk_info(cxt, _("flags: %s"),
|
||||
d->d_flags & BSD_D_REMOVABLE ? _(" removable") :
|
||||
d->d_flags & BSD_D_ECC ? _(" ecc") :
|
||||
d->d_flags & BSD_D_BADSECT ? _(" badsect") : "");
|
||||
|
||||
/* On various machines the fields of *lp are short/int/long */
|
||||
/* In order to avoid problems, we cast them all to long. */
|
||||
fdisk_colon(cxt, _("bytes/sector: %ld"), (long) d->d_secsize);
|
||||
fdisk_colon(cxt, _("sectors/track: %ld"), (long) d->d_nsectors);
|
||||
fdisk_colon(cxt, _("tracks/cylinder: %ld"), (long) d->d_ntracks);
|
||||
fdisk_colon(cxt, _("sectors/cylinder: %ld"), (long) d->d_secpercyl);
|
||||
fdisk_colon(cxt, _("cylinders: %ld"), (long) d->d_ncylinders);
|
||||
fdisk_colon(cxt, _("rpm: %d"), d->d_rpm);
|
||||
fdisk_colon(cxt, _("interleave: %d"), d->d_interleave);
|
||||
fdisk_colon(cxt, _("trackskew: %d"), d->d_trackskew);
|
||||
fdisk_colon(cxt, _("cylinderskew: %d"), d->d_cylskew);
|
||||
fdisk_colon(cxt, _("headswitch: %ld (milliseconds)"), (long) d->d_headswitch);
|
||||
fdisk_colon(cxt, _("track-to-track seek: %ld (milliseconds)"), (long) d->d_trkseek);
|
||||
fdisk_info(cxt, _("bytes/sector: %ld"), (long) d->d_secsize);
|
||||
fdisk_info(cxt, _("sectors/track: %ld"), (long) d->d_nsectors);
|
||||
fdisk_info(cxt, _("tracks/cylinder: %ld"), (long) d->d_ntracks);
|
||||
fdisk_info(cxt, _("sectors/cylinder: %ld"), (long) d->d_secpercyl);
|
||||
fdisk_info(cxt, _("cylinders: %ld"), (long) d->d_ncylinders);
|
||||
fdisk_info(cxt, _("rpm: %d"), d->d_rpm);
|
||||
fdisk_info(cxt, _("interleave: %d"), d->d_interleave);
|
||||
fdisk_info(cxt, _("trackskew: %d"), d->d_trackskew);
|
||||
fdisk_info(cxt, _("cylinderskew: %d"), d->d_cylskew);
|
||||
fdisk_info(cxt, _("headswitch: %ld (milliseconds)"), (long) d->d_headswitch);
|
||||
fdisk_info(cxt, _("track-to-track seek: %ld (milliseconds)"), (long) d->d_trkseek);
|
||||
}
|
||||
|
||||
fdisk_colon(cxt, _("partitions: %d"), d->d_npartitions);
|
||||
fdisk_info(cxt, _("partitions: %d"), d->d_npartitions);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1382,11 +1382,11 @@ static int gpt_list_disklabel(struct fdisk_context *cxt)
|
|||
if (fdisk_context_display_details(cxt)) {
|
||||
struct gpt_header *h = self_label(cxt)->pheader;
|
||||
|
||||
fdisk_colon(cxt, _("First LBA: %ju"), h->first_usable_lba);
|
||||
fdisk_colon(cxt, _("Last LBA: %ju"), h->last_usable_lba);
|
||||
fdisk_colon(cxt, _("Alternative LBA: %ju"), h->alternative_lba);
|
||||
fdisk_colon(cxt, _("Partitions entries LBA: %ju"), h->partition_entry_lba);
|
||||
fdisk_colon(cxt, _("Allocated partition entries: %u"), h->npartition_entries);
|
||||
fdisk_info(cxt, _("First LBA: %ju"), h->first_usable_lba);
|
||||
fdisk_info(cxt, _("Last LBA: %ju"), h->last_usable_lba);
|
||||
fdisk_info(cxt, _("Alternative LBA: %ju"), h->alternative_lba);
|
||||
fdisk_info(cxt, _("Partitions entries LBA: %ju"), h->partition_entry_lba);
|
||||
fdisk_info(cxt, _("Allocated partition entries: %u"), h->npartition_entries);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -61,8 +61,7 @@ enum {
|
|||
|
||||
/* extra flags for info massages (see fdisk_sinfo() */
|
||||
enum {
|
||||
FDISK_INFO_COLON = 1, /* colorize "foo bar:" prefix in the message */
|
||||
FDISK_INFO_SUCCESS, /* info after successful action */
|
||||
FDISK_INFO_SUCCESS /* info after successful action */
|
||||
};
|
||||
|
||||
/* init.c */
|
||||
|
|
|
@ -253,7 +253,7 @@ static int sgi_list_table(struct fdisk_context *cxt)
|
|||
int rc = 0;
|
||||
|
||||
if (fdisk_context_display_details(cxt))
|
||||
fdisk_colon(cxt, _(
|
||||
fdisk_info(cxt, _(
|
||||
"Label geometry: %d heads, %llu sectors\n"
|
||||
" %llu cylinders, %d physical cylinders\n"
|
||||
" %d extra sects/cyl, interleave %d:1\n"),
|
||||
|
@ -261,7 +261,7 @@ static int sgi_list_table(struct fdisk_context *cxt)
|
|||
cxt->geom.cylinders, be16_to_cpu(sgiparam->pcylcount),
|
||||
(int) sgiparam->sparecyl, be16_to_cpu(sgiparam->ilfact));
|
||||
|
||||
fdisk_colon(cxt, _("Bootfile: %s"), sgilabel->boot_file);
|
||||
fdisk_info(cxt, _("Bootfile: %s"), sgilabel->boot_file);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -718,7 +718,7 @@ static int sun_list_disklabel(struct fdisk_context *cxt)
|
|||
sunlabel = self_disklabel(cxt);
|
||||
|
||||
if (fdisk_context_display_details(cxt)) {
|
||||
fdisk_colon(cxt,
|
||||
fdisk_info(cxt,
|
||||
_("Label geometry: %d rpm, %d alternate and %d physical cylinders,\n"
|
||||
" %d extra sects/cyl, interleave %d:1"),
|
||||
be16_to_cpu(sunlabel->rpm),
|
||||
|
@ -726,8 +726,8 @@ static int sun_list_disklabel(struct fdisk_context *cxt)
|
|||
be16_to_cpu(sunlabel->pcyl),
|
||||
be16_to_cpu(sunlabel->apc),
|
||||
be16_to_cpu(sunlabel->intrlv));
|
||||
fdisk_colon(cxt, _("Label ID: %s"), sunlabel->label_id);
|
||||
fdisk_colon(cxt, _("Volume ID: %s"),
|
||||
fdisk_info(cxt, _("Label ID: %s"), sunlabel->label_id);
|
||||
fdisk_info(cxt, _("Volume ID: %s"),
|
||||
*sunlabel->vtoc.volume_id ? sunlabel->vtoc.volume_id : _("<none>"));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue