]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cfdisk: add --zero command line option
authorKarel Zak <kzak@redhat.com>
Fri, 20 Jun 2014 10:17:53 +0000 (12:17 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 20 Jun 2014 10:17:53 +0000 (12:17 +0200)
The option has been supported by previous versions, we can easily
support it too.

Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/cfdisk.8
disk-utils/cfdisk.c

index 0579818f8b4640a17e3fad6c5e1caed4cc880539..c5fe2b42d1f5475ccc2a03010905ce1cd0dcff59 100644 (file)
@@ -58,6 +58,10 @@ Colorize output, enabled by default.  The optional argument \fIwhen\fP can be
 it defaults to \fBauto\fR.
 .IP "\fB-V, \-\-version"
 Display version information and exit.
+.IP "\fB-z, \-\-zero"
+Start with in-memory zeroed partition table. This option does not zero the
+partition table on the disk; rather, it simply starts the program without
+reading the existing partition table.
 
 .SH COMMANDS
 .B cfdisk
index d350dc842f2b807b50e62620d59f1fe270111f8d..0e4638f102404416b02bea18b92e8504bc354b04 100644 (file)
@@ -148,7 +148,8 @@ struct cfdisk {
        size_t  lines_idx;      /* current line <0..N>, exclude header */
        size_t  page_sz;
 
-       unsigned int    wrong_order :1;         /* PT not in right order */
+       unsigned int    wrong_order :1,         /* PT not in right order */
+                       zero_start :1;          /* ignore existing partition table */
 };
 
 /* Initialize output columns -- we follow libcfdisk columns (usually specific
@@ -1834,7 +1835,7 @@ static int ui_run(struct cfdisk *cf)
 
        DBG(FRONTEND, ul_debug("ui: start COLS=%d, LINES=%d", COLS, LINES));
 
-       if (!fdisk_dev_has_disklabel(cf->cxt)) {
+       if (!fdisk_dev_has_disklabel(cf->cxt) || cf->zero_start) {
                rc = ui_create_label(cf);
                if (rc < 0)
                        ui_errx(EXIT_FAILURE,
@@ -1931,6 +1932,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out)
 
        fputs(USAGE_OPTIONS, out);
        fputs(_(" -L --color[=<when>]     colorize output (auto, always or never)\n"), out);
+       fputs(_(" -z --zero               start with zeroed partition table\n"), out);
 
        fputs(USAGE_SEPARATOR, out);
        fputs(USAGE_HELP, out);
@@ -1950,6 +1952,7 @@ int main(int argc, char *argv[])
                { "color",   optional_argument, NULL, 'L' },
                { "help",    no_argument,       NULL, 'h' },
                { "version", no_argument,       NULL, 'V' },
+               { "zero",    no_argument,       NULL, 'z' },
                { NULL, 0, 0, 0 },
        };
 
@@ -1958,7 +1961,7 @@ int main(int argc, char *argv[])
        textdomain(PACKAGE);
        atexit(close_stdout);
 
-       while((c = getopt_long(argc, argv, "L::hV", longopts, NULL)) != -1) {
+       while((c = getopt_long(argc, argv, "L::hVz", longopts, NULL)) != -1) {
                switch(c) {
                case 'h':
                        usage(stdout);
@@ -1973,6 +1976,9 @@ int main(int argc, char *argv[])
                        printf(_("%s from %s\n"), program_invocation_short_name,
                                                  PACKAGE_STRING);
                        return EXIT_SUCCESS;
+               case 'z':
+                       cf->zero_start = 1;
+                       break;
                }
        }