]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sfdisk: --quiet fixes
authorKarel Zak <kzak@redhat.com>
Fri, 10 Feb 2017 11:54:23 +0000 (12:54 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 21 Feb 2017 12:46:00 +0000 (13:46 +0100)
Addresses: https://github.com/karelzak/util-linux/issues/412
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/sfdisk.c
libfdisk/src/alignment.c

index 10307ad14f200b94ca78b1c9e66b49d2ecb9c164..5e0e0de29da271f529376f1b3b0ea2745aaa26d0 100644 (file)
@@ -1678,6 +1678,8 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
                }
 
                refresh_prompt_buffer(sf, devname, next_partno, created);
+
+
                if (sf->prompt && (sf->interactive || !sf->quiet)) {
 #ifndef HAVE_LIBREADLINE
                        fputs(sf->prompt, stdout);
@@ -1697,7 +1699,8 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
                        continue;
                } else if (rc == 1) {
                        rc = SFDISK_DONE_EOF;
-                       fputs(_("Done.\n"), stdout);
+                       if (!sf->quiet)
+                               fputs(_("Done.\n"), stdout);
                        break;
                }
 
@@ -1726,7 +1729,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
                                rc = rc == 0 ? SFDISK_DONE_ASK : SFDISK_DONE_ABORT;
                                break;
                        } else if (!rc) {               /* add partition */
-                               if (!sf->interactive &&
+                               if (!sf->interactive && !sf->quiet &&
                                    (!sf->prompt || startswith(sf->prompt, SFDISK_PROMPT))) {
                                        refresh_prompt_buffer(sf, devname, next_partno, created);
                                        fputs(sf->prompt, stdout);
@@ -1734,8 +1737,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
                                rc = fdisk_add_partition(sf->cxt, pa, &cur_partno);
                                if (rc) {
                                        errno = -rc;
-                                       fdisk_warn(sf->cxt, _("Failed to add partition"));
-
+                                       fdisk_warn(sf->cxt, _("Failed to add #%d partition"), next_partno + 1);
                                }
                        }
 
index f4446c145a5fd8330bfcfc7ee438bdb77d5f86ec..f229e81f70b815149d15e56e9a9ba057ef2974cd 100644 (file)
@@ -666,6 +666,7 @@ int fdisk_reread_partition_table(struct fdisk_context *cxt)
 
        i = fstat(cxt->dev_fd, &statbuf);
        if (i == 0 && S_ISBLK(statbuf.st_mode)) {
+               DBG(CXT, ul_debugobj(cxt, "calling re-read ioctl"));
                sync();
 #ifdef BLKRRPART
                fdisk_info(cxt, _("Calling ioctl() to re-read partition table."));