summaryrefslogtreecommitdiffstats
path: root/fdisks/fdisk.c
diff options
context:
space:
mode:
authorKarel Zak2013-06-12 17:28:26 +0200
committerKarel Zak2013-09-16 16:47:01 +0200
commit3f0ac58755c385f5fd31ca4b4bd13e9ad60ad7a0 (patch)
tree9ac37ca8b81ef211d88dc0fb4774874bc091cce3 /fdisks/fdisk.c
parentfdisk: move get_nr_sects() fdisk.h (diff)
downloadkernel-qcow2-util-linux-3f0ac58755c385f5fd31ca4b4bd13e9ad60ad7a0.tar.gz
kernel-qcow2-util-linux-3f0ac58755c385f5fd31ca4b4bd13e9ad60ad7a0.tar.xz
kernel-qcow2-util-linux-3f0ac58755c385f5fd31ca4b4bd13e9ad60ad7a0.zip
fdisk: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdisk.c')
-rw-r--r--fdisks/fdisk.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c
index 0087c235e..b160aa0a2 100644
--- a/fdisks/fdisk.c
+++ b/fdisks/fdisk.c
@@ -1,14 +1,14 @@
-/* fdisk.c -- Partition table manipulator for Linux.
- *
+/*
* Copyright (C) 1992 A. V. Le Blanc (LeBlanc@mcc.ac.uk)
* Copyright (C) 2012 Davidlohr Bueso <dave@gnu.org>
*
+ * Copyright (C) 2007-2013 Karel Zak <kzak@redhat.com>
+ *
* This program is free software. You can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation: either version 1 or
* (at your option) any later version.
*/
-
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -22,6 +22,7 @@
#include <time.h>
#include <limits.h>
+#include "c.h"
#include "xalloc.h"
#include "nls.h"
#include "rpmatch.h"
@@ -40,15 +41,38 @@
#include "fdiskbsdlabel.h"
#ifdef HAVE_LINUX_COMPILER_H
-#include <linux/compiler.h>
+# include <linux/compiler.h>
#endif
#ifdef HAVE_LINUX_BLKPG_H
-#include <linux/blkpg.h>
+# include <linux/blkpg.h>
#endif
-
int nowarn = 0; /* no warnings for fdisk -l/-s */
+static void __attribute__ ((__noreturn__)) usage(FILE *out)
+{
+ fputs(USAGE_HEADER, out);
+
+ fprintf(out,
+ _(" %1$s [options] <disk> change partition table\n"
+ " %1$s [options] -l <disk> list partition table(s)\n"
+ " %1$s -s <partition> give partition size(s) in blocks\n"),
+ program_invocation_short_name);
+
+ fputs(USAGE_OPTIONS, out);
+ fputs(_(" -b <size> sector size (512, 1024, 2048 or 4096)\n"), out);
+ fputs(_(" -c[=<mode>] compatible mode: 'dos' or 'nondos' (default)\n"), out);
+ fputs(_(" -h print this help text\n"), out);
+ fputs(_(" -u[=<unit>] display units: 'cylinders' or 'sectors' (default)\n"), out);
+ fputs(_(" -v print program version\n"), out);
+ fputs(_(" -C <number> specify the number of cylinders\n"), out);
+ fputs(_(" -H <number> specify the number of heads\n"), out);
+ fputs(_(" -S <number> specify the number of sectors per track\n"), out);
+
+ fprintf(out, USAGE_MAN_TAIL("fdisk(8)"));
+ exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+}
+
void toggle_units(struct fdisk_context *cxt)
{
fdisk_context_set_unit(cxt,
@@ -60,26 +84,6 @@ void toggle_units(struct fdisk_context *cxt)
fdisk_info(cxt, _("Changing display/entry units to sectors."));
}
-
-static void __attribute__ ((__noreturn__)) usage(FILE *out)
-{
- fprintf(out, _("Usage:\n"
- " %1$s [options] <disk> change partition table\n"
- " %1$s [options] -l <disk> list partition table(s)\n"
- " %1$s -s <partition> give partition size(s) in blocks\n"
- "\nOptions:\n"
- " -b <size> sector size (512, 1024, 2048 or 4096)\n"
- " -c[=<mode>] compatible mode: 'dos' or 'nondos' (default)\n"
- " -h print this help text\n"
- " -u[=<unit>] display units: 'cylinders' or 'sectors' (default)\n"
- " -v print program version\n"
- " -C <number> specify the number of cylinders\n"
- " -H <number> specify the number of heads\n"
- " -S <number> specify the number of sectors per track\n"
- "\n"), program_invocation_short_name);
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
struct partition *
get_part_table(int i) {
return ptes[i].part_table;