]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
partx: don't report ENXIO as error on -d
authorKarel Zak <kzak@redhat.com>
Wed, 21 Aug 2019 08:51:18 +0000 (10:51 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 21 Aug 2019 08:51:18 +0000 (10:51 +0200)
The errno ENXIO should be ignored, unfortunately the current code uses
variable 'rc' for ioctl return code as well as for final del_parts()
return value. So, failed ioctl (which should be ignored) affects all
del_parts() status.

  # modprobe scsi_debug dev_size_mb=100
  # partx  -d --nr 1-1024 /dev/sdc; echo $?
  1

The device dos not contains any partitions, so 0 return code is
expected in this case.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/partx.c

index 949278eb79854bb00588268115efde477903ca4a..e1f6b8f9e40f7f3ffc3acede03dcc4055e545328 100644 (file)
@@ -328,8 +328,7 @@ static int del_parts(int fd, const char *device, dev_t devno,
        }
 
        for (i = lower; i <= upper; i++) {
-               rc = partx_del_partition(fd, i);
-               if (rc == 0) {
+               if (partx_del_partition(fd, i) == 0) {
                        if (verbose)
                                printf(_("%s: partition #%d removed\n"), device, i);
                        continue;