sfdisk: remove do_warn
Replace it with warnx() instead. Signed-off-by: Davidlohr Bueso <dave@gnu.org>
This commit is contained in:
parent
109dbc4f84
commit
66d28be811
|
@ -90,17 +90,6 @@ int opt_list = 0;
|
|||
char *save_sector_file = NULL;
|
||||
char *restore_sector_file = NULL;
|
||||
|
||||
static void
|
||||
do_warn(char *s, ...) {
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
fflush(stdout);
|
||||
vfprintf(stderr, s, p);
|
||||
fflush(stderr);
|
||||
va_end(p);
|
||||
}
|
||||
|
||||
static void
|
||||
my_warn(char *s, ...) {
|
||||
va_list p;
|
||||
|
@ -429,7 +418,7 @@ get_geometry(char *dev, int fd, int silent) {
|
|||
{
|
||||
g.heads = g.sectors = g.cylinders = g.start = 0;
|
||||
if (!silent)
|
||||
do_warn(_("Disk %s: cannot get geometry\n"), dev);
|
||||
warnx(_("Disk %s: cannot get geometry\n"), dev);
|
||||
}
|
||||
|
||||
R.start = g.start;
|
||||
|
@ -446,7 +435,7 @@ get_geometry(char *dev, int fd, int silent) {
|
|||
if (fstat(fd, &s) == 0 && S_ISREG(s.st_mode))
|
||||
R.total_size = (s.st_size >> 9);
|
||||
else if (!silent)
|
||||
do_warn(_("Disk %s: cannot get size\n"), dev);
|
||||
warnx(_("Disk %s: cannot get size\n"), dev);
|
||||
} else
|
||||
R.total_size = sectors;
|
||||
|
||||
|
@ -809,7 +798,7 @@ reread_disk_partition(char *dev, int fd) {
|
|||
sync();
|
||||
|
||||
if (reread_ioctl(fd) && is_blockdev(fd)) {
|
||||
do_warn(_("The command to re-read the partition table failed.\n"
|
||||
warnx(_("The command to re-read the partition table failed.\n"
|
||||
"Run partprobe(8), kpartx(8) or reboot your system now,\n"
|
||||
"before using mkfs\n"));
|
||||
return 0;
|
||||
|
@ -817,7 +806,7 @@ reread_disk_partition(char *dev, int fd) {
|
|||
|
||||
if (fsync(fd) || close(fd)) {
|
||||
perror(dev);
|
||||
do_warn(_("Error closing %s\n"), dev);
|
||||
warnx(_("Error closing %s\n"), dev);
|
||||
return 0;
|
||||
}
|
||||
printf("\n");
|
||||
|
@ -881,7 +870,7 @@ static void
|
|||
set_format(char c) {
|
||||
switch (c) {
|
||||
default:
|
||||
do_warn(_("unrecognized format - using sectors\n"));
|
||||
warnx(_("unrecognized format - using sectors\n"));
|
||||
case 'S':
|
||||
specified_format = F_SECTOR;
|
||||
break;
|
||||
|
@ -940,7 +929,7 @@ out_partition_header(char *dev, int format, struct geometry G) {
|
|||
|
||||
switch (format) {
|
||||
default:
|
||||
do_warn(_("unimplemented format - using %s\n"),
|
||||
warnx(_("unimplemented format - using %s\n"),
|
||||
G.cylindersize ? _("cylinders") : _("sectors"));
|
||||
case F_CYLINDER:
|
||||
if (G.cylindersize) {
|
||||
|
@ -1122,17 +1111,17 @@ out_partition(char *dev, int format, struct part_desc *p,
|
|||
aa = chs_to_longchs(a);
|
||||
bb = chs_to_longchs(b);
|
||||
if (a.s && !is_equal_chs(a, b))
|
||||
do_warn(_("\t\tstart: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
warnx(_("\t\tstart: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
aa.c, aa.h, aa.s, bb.c, bb.h, bb.s);
|
||||
a = (size ? ulong_to_chs(end, G) : zero_chs);
|
||||
b = p->p.end_chs;
|
||||
aa = chs_to_longchs(a);
|
||||
bb = chs_to_longchs(b);
|
||||
if (a.s && !is_equal_chs(a, b))
|
||||
do_warn(_("\t\tend: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
warnx(_("\t\tend: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
|
||||
aa.c, aa.h, aa.s, bb.c, bb.h, bb.s);
|
||||
if (G.cylinders && G.cylinders < 1024 && bb.c > G.cylinders)
|
||||
do_warn(_("partition ends on cylinder %ld, beyond the end of the disk\n"),
|
||||
warnx(_("partition ends on cylinder %ld, beyond the end of the disk\n"),
|
||||
bb.c);
|
||||
}
|
||||
}
|
||||
|
@ -1142,10 +1131,10 @@ out_partitions(char *dev, struct disk_desc *z) {
|
|||
int pno, format = 0;
|
||||
|
||||
if (z->partno == 0)
|
||||
do_warn(_("No partitions found\n"));
|
||||
warnx(_("No partitions found\n"));
|
||||
else {
|
||||
if (get_fdisk_geometry(z) && !dump) {
|
||||
do_warn(_("Warning: The partition table looks like it was made\n"
|
||||
warnx(_("Warning: The partition table looks like it was made\n"
|
||||
" for C/H/S=*/%ld/%ld (instead of %ld/%ld/%ld).\n"
|
||||
"For this listing I'll assume that geometry.\n"),
|
||||
F.heads, F.sectors, B.cylinders, B.heads, B.sectors);
|
||||
|
@ -1429,12 +1418,12 @@ extended_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z)
|
|||
/* This is BAD */
|
||||
if (DOS_extended) {
|
||||
here = start -= (start % B.cylindersize);
|
||||
do_warn(_("Warning: shifted start of the extd partition "
|
||||
"from %ld to %ld\n"
|
||||
warnx(_("Warning: shifted start of the extd partition "
|
||||
"from %lld to %lld\n"
|
||||
"(For listing purposes only. "
|
||||
"Do not change its contents.)\n"), ep->start, start);
|
||||
} else {
|
||||
do_warn(_("Warning: extended partition does not start at a "
|
||||
warnx(_("Warning: extended partition does not start at a "
|
||||
"cylinder boundary.\n"
|
||||
"DOS and Linux will interpret the contents differently.\n"));
|
||||
}
|
||||
|
@ -1452,7 +1441,7 @@ extended_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z)
|
|||
cp = s->data + 0x1be;
|
||||
|
||||
if (pno + 4 >= ARRAY_SIZE(z->partitions)) {
|
||||
do_warn(_("too many partitions - ignoring those past nr (%d)\n"),
|
||||
warnx(_("too many partitions - ignoring those past nr (%ld)\n"),
|
||||
pno - 1);
|
||||
break;
|
||||
}
|
||||
|
@ -1467,7 +1456,7 @@ extended_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z)
|
|||
if (is_extended(p.sys_type)) {
|
||||
partitions[pno].start = start + p.start_sect;
|
||||
if (next)
|
||||
do_warn(_("tree of partitions?\n"));
|
||||
warnx(_("tree of partitions?\n"));
|
||||
else
|
||||
next = partitions[pno].start; /* follow `upper' branch */
|
||||
moretodo = 1;
|
||||
|
@ -1529,8 +1518,8 @@ bsd_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z) {
|
|||
bp = bp0 = &l->d_partitions[0];
|
||||
while (bp - bp0 < BSD_MAXPARTITIONS && bp - bp0 < l->d_npartitions) {
|
||||
if (pno + 1 >= ARRAY_SIZE(z->partitions)) {
|
||||
do_warn(_("too many partitions - ignoring those "
|
||||
"past nr (%d)\n"), pno - 1);
|
||||
warnx(_("too many partitions - ignoring those "
|
||||
"past nr (%ld)\n"), pno - 1);
|
||||
break;
|
||||
}
|
||||
if (bp->p_fstype != BSD_FS_UNUSED) {
|
||||
|
@ -1575,7 +1564,7 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
|
|||
|| pt.sys_type == EZD_PARTITION
|
||||
|| pt.sys_type == DM6_AUX1PARTITION
|
||||
|| pt.sys_type == DM6_AUX3PARTITION) {
|
||||
do_warn(_("detected Disk Manager - unable to handle that\n"));
|
||||
warnx(_("detected Disk Manager - unable to handle that\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1583,7 +1572,7 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
|
|||
if (sig <= 0x1ae
|
||||
&& *(unsigned short *)(s->data + sig) == 0x55aa
|
||||
&& (1 & *(unsigned char *)(s->data + sig + 2))) {
|
||||
do_warn(_("DM6 signature found - giving up\n"));
|
||||
warnx(_("DM6 signature found - giving up\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1602,14 +1591,14 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
|
|||
for (i = 0; i < 4; i++) {
|
||||
if (is_extended(partitions[i].p.sys_type)) {
|
||||
if (!partitions[i].size) {
|
||||
do_warn(_("strange..., an extended partition of size 0?\n"));
|
||||
warnx(_("strange..., an extended partition of size 0?\n"));
|
||||
continue;
|
||||
}
|
||||
extended_partition(dev, fd, &partitions[i], z);
|
||||
}
|
||||
if (!bsd_later && is_bsd(partitions[i].p.sys_type)) {
|
||||
if (!partitions[i].size) {
|
||||
do_warn(_("strange..., a BSD partition of size 0?\n"));
|
||||
warnx(_("strange..., a BSD partition of size 0?\n"));
|
||||
continue;
|
||||
}
|
||||
bsd_partition(dev, fd, &partitions[i], z);
|
||||
|
@ -1620,7 +1609,7 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
|
|||
for (i = 0; i < 4; i++) {
|
||||
if (is_bsd(partitions[i].p.sys_type)) {
|
||||
if (!partitions[i].size) {
|
||||
do_warn(_("strange..., a BSD partition of size 0?\n"));
|
||||
warnx(_("strange..., a BSD partition of size 0?\n"));
|
||||
continue;
|
||||
}
|
||||
bsd_partition(dev, fd, &partitions[i], z);
|
||||
|
@ -1663,7 +1652,7 @@ get_partitions(char *dev, int fd, struct disk_desc *z) {
|
|||
&& !osf_partition(dev, fd, 0, z)
|
||||
&& !sun_partition(dev, fd, 0, z)
|
||||
&& !amiga_partition(dev, fd, 0, z)) {
|
||||
do_warn(_(" %s: unrecognized partition table type\n"), dev);
|
||||
warnx(_(" %s: unrecognized partition table type\n"), dev);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1675,7 +1664,7 @@ write_partitions(char *dev, int fd, struct disk_desc *z) {
|
|||
int pno = z->partno;
|
||||
|
||||
if (no_write) {
|
||||
do_warn(_("-n flag was given: Nothing changed\n"));
|
||||
warnx(_("-n flag was given: Nothing changed\n"));
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -1870,11 +1859,11 @@ get_ul(char *u, unsigned long *up, unsigned long def, int base) {
|
|||
errno = 0;
|
||||
val = strtoul(u, &nu, base);
|
||||
if (errno == ERANGE) {
|
||||
do_warn(_("number too big\n"));
|
||||
warnx(_("number too big\n"));
|
||||
return -1;
|
||||
}
|
||||
if (*nu) {
|
||||
do_warn(_("trailing junk after number\n"));
|
||||
warnx(_("trailing junk after number\n"));
|
||||
return -1;
|
||||
}
|
||||
if (sign == 1)
|
||||
|
@ -1907,11 +1896,11 @@ get_ull(char *u, unsigned long long *up, unsigned long long def, int base) {
|
|||
errno = 0;
|
||||
val = strtoull(u, &nu, base);
|
||||
if (errno == ERANGE) {
|
||||
do_warn(_("number too big\n"));
|
||||
warnx(_("number too big\n"));
|
||||
return -1;
|
||||
}
|
||||
if (*nu) {
|
||||
do_warn(_("trailing junk after number\n"));
|
||||
warnx(_("trailing junk after number\n"));
|
||||
return -1;
|
||||
}
|
||||
if (sign == 1)
|
||||
|
@ -2120,7 +2109,7 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive,
|
|||
if (fno == RD_EOF) {
|
||||
return -1;
|
||||
} else if (fno > 10 && *(fields[10]) != 0) {
|
||||
do_warn(_("too many input fields\n"));
|
||||
warnx(_("too many input fields\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2337,7 +2326,7 @@ read_partition_chain(char *dev, int interactive, struct part_desc *ep,
|
|||
while (1) {
|
||||
base = z->partno;
|
||||
if (base + 4 > ARRAY_SIZE(z->partitions)) {
|
||||
do_warn(_("too many partitions\n"));
|
||||
warnx(_("too many partitions\n"));
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < 4; i++)
|
||||
|
@ -3154,7 +3143,7 @@ do_reread(char *dev) {
|
|||
|
||||
fd = my_open(dev, 0, 0);
|
||||
if (reread_ioctl(fd)) {
|
||||
do_warn(_("This disk is currently in use.\n"));
|
||||
warnx(_("This disk is currently in use.\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -3178,7 +3167,7 @@ do_fdisk(char *dev) {
|
|||
errx(EXIT_FAILURE, _("Fatal error: cannot find %s"), dev);
|
||||
}
|
||||
if (!S_ISBLK(statbuf.st_mode)) {
|
||||
do_warn(_("Warning: %s is not a block device\n"), dev);
|
||||
warnx(_("Warning: %s is not a block device\n"), dev);
|
||||
no_reread = 1;
|
||||
}
|
||||
fd = my_open(dev, !no_write, 0);
|
||||
|
@ -3186,11 +3175,11 @@ do_fdisk(char *dev) {
|
|||
if (!no_write && !no_reread) {
|
||||
my_warn(_("Checking that no-one is using this disk right now ...\n"));
|
||||
if (reread_ioctl(fd)) {
|
||||
do_warn(_("\nThis disk is currently in use - repartitioning is probably a bad idea.\n"
|
||||
warnx(_("\nThis disk is currently in use - repartitioning is probably a bad idea.\n"
|
||||
"Umount all file systems, and swapoff all swap partitions on this disk.\n"
|
||||
"Use the --no-reread flag to suppress this check.\n"));
|
||||
if (!force) {
|
||||
do_warn(_("Use the --force flag to overrule all checks.\n"));
|
||||
warnx(_("Use the --force flag to overrule all checks.\n"));
|
||||
exit(1);
|
||||
}
|
||||
} else
|
||||
|
@ -3223,7 +3212,7 @@ do_fdisk(char *dev) {
|
|||
errx(EXIT_FAILURE, _("I don't like these partitions - nothing changed.\n"
|
||||
"(If you really want this, use the --force option.)"));
|
||||
else
|
||||
do_warn(_("I don't like this - probably you should answer No\n"));
|
||||
warnx(_("I don't like this - probably you should answer No\n"));
|
||||
}
|
||||
ask:
|
||||
if (interactive) {
|
||||
|
|
Loading…
Reference in New Issue