]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
partx: don't print error when partition already doesn't exist
authorPhillip Susi <psusi@cfl.rr.com>
Mon, 5 Dec 2011 20:02:51 +0000 (15:02 -0500)
committerKarel Zak <kzak@redhat.com>
Thu, 8 Dec 2011 12:41:39 +0000 (13:41 +0100)
If you run partx -d to delete partitions, and there are gaps
in the sequence ( partition 2 exists, but 1 doesn't ), then it
would complain that it had errors trying to remove the partitions
that already don't exist. Changed to ignore the error when
errno == ENXIO.

Signed-off-by: Phillip Susi <psusi@cfl.rr.com>
partx/partx.c

index d2fde3f4e65b74493f52720acea4f304571ead3e..7c4235bb0e31e738cecb99ff8dee69efd15bb93e 100644 (file)
@@ -302,10 +302,15 @@ static int del_parts(int fd, const char *device, dev_t devno,
        }
 
        for (i = lower; i <= upper; i++) {
-               if (partx_del_partition(fd, i) == 0) {
+               rc = partx_del_partition(fd, i);
+               if (rc == 0) {
                        if (verbose)
                                printf(_("%s: partition #%d removed\n"), device, i);
                        continue;
+               } else if (errno == ENXIO) {
+                       if (verbose)
+                               printf(_("%s: partition #%d already doesn't exist\n"), device, i);
+                       continue;
                }
                rc = -1;
                if (verbose)