]> 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>
Fri, 10 Feb 2017 11:54:23 +0000 (12:54 +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 c6d57eacc7099475e984a935332fb3b5d3fb04c3..eedaa39d9dbc252b3ac557cd45c54054f80979aa 100644 (file)
@@ -1683,6 +1683,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);
@@ -1702,7 +1704,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;
                }
 
@@ -1731,7 +1734,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);
@@ -1739,8 +1742,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 77ca35dc57d0b90b1d939b9112d31519c7586e3e..2e206999295283b6e0954e9f31f560252a4bd2c1 100644 (file)
@@ -692,6 +692,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."));