[parted-devel] [PATCH 2/6] libparted: remove extraneous blkpg add partition ped exception

Jim Meyering jim at meyering.net
Fri Oct 19 13:58:47 UTC 2012


Phillip Susi wrote:
> _blkpg_add_partition was throwing an exception if it failed to add the new
> partition, in addition to _disk_sync_part_table throwing one, and then
> bailing out.  Instead of bailing out, just log the error for reporting
> later and continue.
> ---
>  libparted/arch/linux.c                          |   21 +++------------------
>  tests/t2310-dos-extended-2-sector-min-offset.sh |    3 +--
>  2 files changed, 4 insertions(+), 20 deletions(-)
>
> diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
> index 496e1c5..f0eb4aa 100644
> --- a/libparted/arch/linux.c
> +++ b/libparted/arch/linux.c
> @@ -2411,18 +2411,7 @@ _blkpg_add_partition (PedDisk* disk, const PedPartition *part)
>
>          if (!_blkpg_part_command (disk->dev, &linux_part,
>                                    BLKPG_ADD_PARTITION)) {
> -                return ped_exception_throw (
> -                        PED_EXCEPTION_ERROR,
> -                        PED_EXCEPTION_IGNORE_CANCEL,
> -                        _("Error informing the kernel about modifications to "
> -                          "partition %s -- %s.  This means Linux won't know "
> -                          "about any changes you made to %s until you reboot "
> -                          "-- so you shouldn't mount it or use it in any way "
> -                          "before rebooting."),
> -                        linux_part.devname,
> -                        strerror (errno),
> -                        linux_part.devname)
> -                                == PED_EXCEPTION_IGNORE;
> +                return 0;
>          }
>
>          return 1;
> @@ -2792,12 +2781,8 @@ _disk_sync_part_table (PedDisk* disk)
>
>                          /* add the (possibly modified or new) partition */
>                          if (!add_partition (disk, part)) {
> -                                ped_exception_throw (
> -                                        PED_EXCEPTION_ERROR,
> -                                        PED_EXCEPTION_RETRY_CANCEL,
> -                                        _("Failed to add partition %d (%s)"),
> -                                        i, strerror (errno));
> -                                goto cleanup;
> +                                ok[i - 1] = 0;
> +                                errnums[i - 1] = errno;
>                          }
>                  }
>          }
> diff --git a/tests/t2310-dos-extended-2-sector-min-offset.sh b/tests/t2310-dos-extended-2-sector-min-offset.sh
> index 89453ae..a09ef53 100644
> --- a/tests/t2310-dos-extended-2-sector-min-offset.sh
> +++ b/tests/t2310-dos-extended-2-sector-min-offset.sh
> @@ -39,8 +39,7 @@ $scsi_dev:2048s:scsi:512:512:msdos:Linux scsi_debug:;
>  EOF
>
>  cat <<EOF > err.exp || framework_failure
> -Error: Error informing the kernel about modifications to partition $p5 -- Device or resource busy.  This means Linux won't know about any changes you made to $p5 until you reboot -- so you shouldn't mount it or use it in any way before rebooting.
> -Error: Failed to add partition 5 (Device or resource busy)
> +Error: Partition(s) 5 on /dev/sde have been written, but we hav...

Thanks.  Applied, but amended to use $scsi_dev in place of that
hard-coded "/dev/sde".

    -Error: Partition(s) 5 on /dev/sde have been ...
    +Error: Partition(s) 5 on $scsi_dev have been ...

I'm waiting for your ACK before I push the preceding patch:

    libparted: refactor device-mapper partition sync code



More information about the parted-devel mailing list