File util-linux-fdisk-l-error.patch of Package util-linux.12160

Partial rewrite.
From 8fdd483c5331671b3ab31a1a240aeb1e2c2840c6 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 13 Dec 2016 12:11:18 +0100
Subject: [PATCH] fdisk: don't be silent when list non-existing device

Addresses: https://github.com/karelzak/util-linux/issues/376
Signed-off-by: Karel Zak <kzak@redhat.com>
---
 disk-utils/fdisk.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Index: util-linux-2.28/disk-utils/fdisk.c
===================================================================
--- util-linux-2.28.orig/disk-utils/fdisk.c
+++ util-linux-2.28/disk-utils/fdisk.c
@@ -928,8 +928,12 @@ int main(int argc, char **argv)
 
 		if (argc > optind) {
 			int k;
-			for (k = optind; k < argc; k++)
-				print_device_pt(cxt, argv[k], 1, 0);
+
+			for (rc = 0, k = optind; k < argc; k++) {
+				rc += print_device_pt(cxt, argv[k], 1, 0);
+				if (rc)
+					err(EXIT_FAILURE, _("cannot open %s"), argv[optind]);
+			}
 		} else
 			print_all_devices_pt(cxt, 0);
 		break;
openSUSE Build Service is sponsored by