]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sfdisk: don't be silent when list non-existing device
authorKarel Zak <kzak@redhat.com>
Tue, 29 Nov 2016 14:58:18 +0000 (15:58 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 29 Nov 2016 15:01:46 +0000 (16:01 +0100)
Addresses: https://github.com/karelzak/util-linux/issues/376
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/sfdisk.c

index 52f2a6d9262bcc2388579fc57ed4eec0c93e85f4..0f69d65756ce0ae8c8b11357f1c9f1317a933be6 100644 (file)
@@ -560,6 +560,7 @@ static int write_changes(struct sfdisk *sf)
  */
 static int command_list_partitions(struct sfdisk *sf, int argc, char **argv)
 {
+       int fail = 0;
        fdisk_enable_listonly(sf->cxt, 1);
 
        if (argc) {
@@ -568,13 +569,14 @@ static int command_list_partitions(struct sfdisk *sf, int argc, char **argv)
                for (i = 0; i < argc; i++) {
                        if (ct)
                                fputs("\n\n", stdout);
-                       if (print_device_pt(sf->cxt, argv[i], 0, sf->verify) == 0)
-                               ct++;
+                       if (print_device_pt(sf->cxt, argv[i], 1, sf->verify) != 0)
+                               fail++;
+                       ct++;
                }
        } else
                print_all_devices_pt(sf->cxt, sf->verify);
 
-       return 0;
+       return fail;
 }
 
 /*
@@ -582,6 +584,7 @@ static int command_list_partitions(struct sfdisk *sf, int argc, char **argv)
  */
 static int command_list_freespace(struct sfdisk *sf, int argc, char **argv)
 {
+       int fail = 0;
        fdisk_enable_listonly(sf->cxt, 1);
 
        if (argc) {
@@ -590,13 +593,14 @@ static int command_list_freespace(struct sfdisk *sf, int argc, char **argv)
                for (i = 0; i < argc; i++) {
                        if (ct)
                                fputs("\n\n", stdout);
-                       if (print_device_freespace(sf->cxt, argv[i], 0) == 0)
-                               ct++;
+                       if (print_device_freespace(sf->cxt, argv[i], 1) != 0)
+                               fail++;
+                       ct++;
                }
        } else
                print_all_devices_freespace(sf->cxt);
 
-       return 0;
+       return fail;
 }
 
 /*