commit 74a816df60f30b1f2f8fa0daee211a9ea3f44446 Author: Marcin Krol <h...@tld-linux.org> Date: Wed Aug 21 21:11:03 2019 +0200
- more FC patches, fixes build on recent systems ...arted-labels-link-with-libiconv-if-needed.patch | 51 +++ 0081-Add-support-for-NVDIMM-devices.patch | 84 +++++ ...x-Include-sys-sysmacros.h-for-major-macro.patch | 25 ++ 0083-Fix-make-check.patch | 63 ++++ 0084-tests-fix-t6100-mdraid-partitions.patch | 26 ++ ...-disk_set-to-not-crash-when-no-flags-are-.patch | 77 +++++ ...w-negative-start-value-when-FS-TYPE-is-no.patch | 122 +++++++ 0087-Fix-resizepart-iec-unit-end-sector.patch | 32 ++ ...d-Remove-unused-traces-of-dynamic-loading.patch | 238 +++++++++++++ 0089-Lift-512-byte-restriction-on-fat-resize.patch | 52 +++ 0090-Fix-atari-label-false-positives.patch | 41 +++ ...header-move-and-msdos-overlap-to-work-wit.patch | 87 +++++ ...-header-move-and-msdos-overlap-to-python3.patch | 33 ++ ...-libparted-Fix-ending-CHS-address-in-PMBR.patch | 29 ++ 0094-Fix-the-length-of-several-strncpy-calls.patch | 76 +++++ 0095-parted.c-Always-free-peek_word.patch | 35 ++ 0096-parted.c-Make-sure-dev_name-is-freed.patch | 45 +++ ...d-partitions-Use-v0.90-metadata-for-the-t.patch | 29 ++ ...ix-potential-command-line-buffer-overflow.patch | 46 +++ ...dd-support-for-MBR-id-GPT-GUID-and-detect.patch | 379 +++++++++++++++++++++ ...-udf-to-t1700-probe-fs-and-to-the-manpage.patch | 41 +++ ...t_name-Resolve-conflicting-attributes-con.patch | 34 ++ ...rnings-from-GCC-7-s-Wimplicit-fallthrough.patch | 97 ++++++ 0103-Read-NVMe-model-names-from-sysfs.patch | 59 ++++ ...crash-due-to-improper-partition-number-in.patch | 94 +++++ ...rted-fix-wrong-error-label-jump-in-mkpart.patch | 66 ++++ ...isk-information-when-commands-fail-in-int.patch | 86 +++++ ...ve-PED_ASSERT-from-ped_partition_set_name.patch | 32 ++ ...rt-for-Windows-recovery-partition-WINRE-o.patch | 167 +++++++++ 0109-t6000-dm-Stop-using-private-lvm-root.patch | 40 +++ ...gv-in-case-2nd-nilfs2-superblock-magic-ac.patch | 53 +++ ...for-sigsegv-when-false-nilfs2-superblock-.patch | 132 +++++++ parted.spec | 65 ++++ 33 files changed, 2536 insertions(+) --- diff --git a/parted.spec b/parted.spec index 344020c..5cbac78 100644 --- a/parted.spec +++ b/parted.spec @@ -103,6 +103,38 @@ Patch76: 0076-Increase-timeout-for-rmmod-scsi_debug-and-make-it-a-.patch Patch77: 0077-tests-t1701-rescue-fs-wait-for-the-device-to-appear.patch Patch78: 0078-lib%{name}-Fix-udev-cookie-leak-in-_dm_resize_partiti.patch Patch79: 0079-atari.c-Drop-xlocale.h-1476934.patch +Patch80: 0080-libparted-labels-link-with-libiconv-if-needed.patch +Patch81: 0081-Add-support-for-NVDIMM-devices.patch +Patch82: 0082-linux-Include-sys-sysmacros.h-for-major-macro.patch +Patch83: 0083-Fix-make-check.patch +Patch84: 0084-tests-fix-t6100-mdraid-partitions.patch +Patch85: 0085-Fix-set-and-disk_set-to-not-crash-when-no-flags-are-.patch +Patch86: 0086-mkpart-Allow-negative-start-value-when-FS-TYPE-is-no.patch +Patch87: 0087-Fix-resizepart-iec-unit-end-sector.patch +Patch88: 0088-build-Remove-unused-traces-of-dynamic-loading.patch +Patch89: 0089-Lift-512-byte-restriction-on-fat-resize.patch +Patch90: 0090-Fix-atari-label-false-positives.patch +Patch91: 0091-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch +Patch92: 0092-Switch-gpt-header-move-and-msdos-overlap-to-python3.patch +Patch93: 0093-libparted-Fix-ending-CHS-address-in-PMBR.patch +Patch94: 0094-Fix-the-length-of-several-strncpy-calls.patch +Patch95: 0095-parted.c-Always-free-peek_word.patch +Patch96: 0096-parted.c-Make-sure-dev_name-is-freed.patch +Patch97: 0097-t6100-mdraid-partitions-Use-v0.90-metadata-for-the-t.patch +Patch98: 0098-Fix-potential-command-line-buffer-overflow.patch +Patch99: 0099-libparted-Add-support-for-MBR-id-GPT-GUID-and-detect.patch +Patch100: 0100-Add-udf-to-t1700-probe-fs-and-to-the-manpage.patch +Patch101: 0101-ped_unit_get_name-Resolve-conflicting-attributes-con.patch +Patch102: 0102-Fix-warnings-from-GCC-7-s-Wimplicit-fallthrough.patch +Patch103: 0103-Read-NVMe-model-names-from-sysfs.patch +Patch104: 0104-parted-fix-crash-due-to-improper-partition-number-in.patch +Patch105: 0105-parted-fix-wrong-error-label-jump-in-mkpart.patch +Patch106: 0106-clean-the-disk-information-when-commands-fail-in-int.patch +Patch107: 0107-parted-Remove-PED_ASSERT-from-ped_partition_set_name.patch +Patch108: 0108-Added-support-for-Windows-recovery-partition-WINRE-o.patch +Patch109: 0109-t6000-dm-Stop-using-private-lvm-root.patch +Patch110: 0110-Avoid-sigsegv-in-case-2nd-nilfs2-superblock-magic-ac.patch +Patch111: 0111-Tests-case-for-sigsegv-when-false-nilfs2-superblock-.patch Patch1001: %{name}-no_wrap.patch Patch1002: %{name}-BIG_FAT_WARNING.patch @@ -309,6 +341,38 @@ Biblioteka statyczna libparted. %patch77 -p1 %patch78 -p1 %patch79 -p1 +%patch80 -p1 +%patch81 -p1 +%patch82 -p1 +%patch83 -p1 +%patch84 -p1 +%patch85 -p1 +%patch86 -p1 +%patch87 -p1 +%patch88 -p1 +%patch89 -p1 +%patch90 -p1 +%patch91 -p1 +%patch92 -p1 +%patch93 -p1 +%patch94 -p1 +%patch95 -p1 +%patch96 -p1 +%patch97 -p1 +%patch98 -p1 +%patch99 -p1 +%patch100 -p1 +%patch101 -p1 +%patch102 -p1 +%patch103 -p1 +%patch104 -p1 +%patch105 -p1 +%patch106 -p1 +%patch107 -p1 +%patch108 -p1 +%patch109 -p1 +%patch110 -p1 +%patch111 -p1 %patch1001 -p1 %patch1002 -p1 @@ -399,6 +463,7 @@ rm -rf $RPM_BUILD_ROOT %endif %{_includedir}/parted %{_pkgconfigdir}/libparted.pc +%{_pkgconfigdir}/libparted-fs-resize.pc %{_aclocaldir}/parted.m4 %files static diff --git a/0080-libparted-labels-link-with-libiconv-if-needed.patch b/0080-libparted-labels-link-with-libiconv-if-needed.patch new file mode 100644 index 0000000..b6e2cd8 --- /dev/null +++ b/0080-libparted-labels-link-with-libiconv-if-needed.patch @@ -0,0 +1,51 @@ +From 8bec8bcc639cfc7ed0ca7cd3a5321513aa4348fd Mon Sep 17 00:00:00 2001 +From: "Arnout Vandecappelle (Essensium/Mind)" <arn...@mind.be> +Date: Sun, 5 Nov 2017 23:33:37 +0100 +Subject: [PATCH 80/81] libparted/labels: link with libiconv if needed + +gpt.c uses iconv so it should link with it. Otherwise, on platforms +where libiconv is a separate library, we get a link failure of parted: + + CCLD parted + ../libparted/.libs/libparted.so: undefined reference to `libiconv' + ../libparted/.libs/libparted.so: undefined reference to `libiconv_open' + ../libparted/.libs/libparted.so: undefined reference to `libiconv_close' + +Since iconv functionality is needed unconditionally (not only when +gettext is enabled), AM_ICONV needs to be added to configure.ac. + +(cherry picked from commit 571293e3f9ee45f37867578899c6a8a9cd35afd4) +--- + configure.ac | 2 ++ + libparted/labels/Makefile.am | 2 +- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 3d57157..5251dfb 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -288,6 +288,8 @@ fi + AC_PROG_LIBTOOL + LT_INIT + ++AM_ICONV ++ + AM_GNU_GETTEXT_VERSION([0.18]) + AM_GNU_GETTEXT([external]) + if test "$USE_INCLUDED_LIBINTL" = "yes"; then +diff --git a/libparted/labels/Makefile.am b/libparted/labels/Makefile.am +index 3327c8c..db612d1 100644 +--- a/libparted/labels/Makefile.am ++++ b/libparted/labels/Makefile.am +@@ -36,7 +36,7 @@ liblabels_la_SOURCES = \ + rdb.c \ + sun.c + +-liblabels_la_LIBADD = $(OS_LIBS) $(INTLLIBS) ++liblabels_la_LIBADD = $(OS_LIBS) $(INTLLIBS) $(LIBICONV) + + AM_CPPFLAGS = $(partedincludedir) $(INTLINCS) + +-- +2.13.6 + diff --git a/0081-Add-support-for-NVDIMM-devices.patch b/0081-Add-support-for-NVDIMM-devices.patch new file mode 100644 index 0000000..a4b879d --- /dev/null +++ b/0081-Add-support-for-NVDIMM-devices.patch @@ -0,0 +1,84 @@ +From b5bbee5db418e85c8fd26bf07142e71302914738 Mon Sep 17 00:00:00 2001 +From: Sebastian Parschauer <sparscha...@suse.de> +Date: Tue, 24 Oct 2017 10:22:21 +0200 +Subject: [PATCH] Add support for NVDIMM devices + +Recognize NVDIMM devices, so that "parted -s /dev/pmem7 p" now +prints "Model: NVDIMM Device (pmem)" instead of +"Model: Unknown (unknown)". + +In order for a device to be recognized as NVDIMM, it has to +have a 'blkext' major number. But since this major can be +used also by other device types, we also check that the device +path contains 'pmem' as a substring. + +* NEWS: Mention the change +* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_PMEM +* libparted/arch/linux.c(_device_probe_type): Recognize NVDIMM devices. +* libparted/arch/linux.c(linux_new): Handle NVDIMM devices. +* parted/parted.c(do_print): Add "pmem" to list of transports. + +Signed-off-by: Sebastian Parschauer <sparscha...@suse.de> +(cherry picked from commit 71885c5f493f3a5d950adbb3e8d17eff7e023053) +--- + include/parted/device.in.h | 3 ++- + libparted/arch/linux.c | 7 +++++++ + parted/parted.c | 3 ++- + 3 files changed, 11 insertions(+), 2 deletions(-) + +diff --git a/include/parted/device.in.h b/include/parted/device.in.h +index 1b6e7b8..d3af6bb 100644 +--- a/include/parted/device.in.h ++++ b/include/parted/device.in.h +@@ -51,7 +51,8 @@ typedef enum { + PED_DEVICE_MD = 17, + PED_DEVICE_LOOP = 18, + PED_DEVICE_NVME = 19, +- PED_DEVICE_RAM = 20 ++ PED_DEVICE_RAM = 20, ++ PED_DEVICE_PMEM = 21 + } PedDeviceType; + + typedef struct _PedDevice PedDevice; +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index b76000e..1c26b8c 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -704,6 +704,8 @@ _device_probe_type (PedDevice* dev) + dev->type = PED_DEVICE_NVME; + } else if (dev_major == RAM_MAJOR) { + dev->type = PED_DEVICE_RAM; ++ } else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "pmem")) { ++ dev->type = PED_DEVICE_PMEM; + } else { + dev->type = PED_DEVICE_UNKNOWN; + } +@@ -1487,6 +1489,11 @@ linux_new (const char* path) + goto error_free_arch_specific; + break; + ++ case PED_DEVICE_PMEM: ++ if (!init_generic (dev, _("NVDIMM Device"))) ++ goto error_free_arch_specific; ++ break; ++ + case PED_DEVICE_ATARAID: + if (!init_generic (dev, _("ATARAID Controller"))) + goto error_free_arch_specific; +diff --git a/parted/parted.c b/parted/parted.c +index d2e1f24..b49e1df 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -986,7 +986,8 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp) + "cpqarray", "file", "ataraid", "i2o", + "ubd", "dasd", "viodasd", "sx8", "dm", + "xvd", "sd/mmc", "virtblk", "aoe", +- "md", "loopback", "nvme", "brd"}; ++ "md", "loopback", "nvme", "brd", ++ "pmem"}; + + char* start = ped_unit_format (dev, 0); + PedUnit default_unit = ped_unit_get_default (); +-- +2.13.6 + diff --git a/0082-linux-Include-sys-sysmacros.h-for-major-macro.patch b/0082-linux-Include-sys-sysmacros.h-for-major-macro.patch new file mode 100644 index 0000000..ee09cb5 --- /dev/null +++ b/0082-linux-Include-sys-sysmacros.h-for-major-macro.patch @@ -0,0 +1,25 @@ +From ba5e0451b51c983e40afd123b6e0d3eddb55e610 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" <rjo...@redhat.com> +Date: Sat, 24 Mar 2018 17:37:02 +0000 +Subject: [PATCH 82/92] linux: Include <sys/sysmacros.h> for major() macro. + +Since glibc 2.27 this header is required. +--- + libparted/arch/linux.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 31b98ab..7e86b51 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -41,6 +41,7 @@ + #include <sys/utsname.h> /* for uname() */ + #include <scsi/scsi.h> + #include <assert.h> ++#include <sys/sysmacros.h> + #ifdef ENABLE_DEVICE_MAPPER + #include <libdevmapper.h> + #endif +-- +2.17.1 + diff --git a/0083-Fix-make-check.patch b/0083-Fix-make-check.patch new file mode 100644 index 0000000..191bbdc --- /dev/null +++ b/0083-Fix-make-check.patch @@ -0,0 +1,63 @@ +From d91acc645ad1204ded41cfecad337bf9c48952f6 Mon Sep 17 00:00:00 2001 +From: Phillip Susi <ps...@ubuntu.com> +Date: Fri, 4 May 2018 10:12:05 -0400 +Subject: [PATCH 83/92] Fix make check + +Make check failed due to some warnings treated as errors. One was +caused by a warning that a function could have the noreturn attribute. +It seems that this had previously been disabled but gcc has changed +the flag from -Wmissing-noreturn to -Wsuggest-attribute=noreturn. The +recently added volser.c test also caused a few warnings when not +compiled on s390x because most of the functions were no used, so #if +those out as well. +--- + configure.ac | 2 +- + libparted/tests/volser.c | 5 ++++- + 2 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 738c697..056478f 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -226,7 +226,7 @@ if test "$gl_gcc_warnings" = yes; then + nw="$nw -Wpacked" + nw="$nw -Wmissing-prototypes" + nw="$nw -Wmissing-declarations" +- nw="$nw -Wmissing-noreturn" ++ nw="$nw -Wsuggest-attribute=noreturn" + # things I might fix soon: + nw="$nw -Wfloat-equal" # sort.c, seq.c + nw="$nw -Wmissing-format-attribute" # copy.c +diff --git a/libparted/tests/volser.c b/libparted/tests/volser.c +index 9063821..c6efa5f 100644 +--- a/libparted/tests/volser.c ++++ b/libparted/tests/volser.c +@@ -14,6 +14,8 @@ + #include "common.h" + #include "progname.h" + ++#if defined __s390__ || defined __s390x__ ++ + /* set dasd first */ + static char vol_devno[7] = {0}; + static char *tmp_disk; +@@ -75,7 +77,6 @@ END_TEST + + START_TEST (test_check_volser) + { +- char vol[7] = {0}; + char vol_long[] = "abcdefg"; + char vol_short[] = "ab_c "; + char vol_null[] = " "; +@@ -135,6 +136,8 @@ START_TEST (test_reuse_vtoc) + } + END_TEST + ++#endif ++ + int main (int argc, char **argv) + { + +-- +2.17.1 + diff --git a/0084-tests-fix-t6100-mdraid-partitions.patch b/0084-tests-fix-t6100-mdraid-partitions.patch new file mode 100644 index 0000000..55701c6 --- /dev/null +++ b/0084-tests-fix-t6100-mdraid-partitions.patch @@ -0,0 +1,26 @@ +From ddb9cce8a2ec87cdd9853bdca25c852c7aee8bdf Mon Sep 17 00:00:00 2001 +From: Phillip Susi <ps...@ubuntu.com> +Date: Fri, 4 May 2018 10:35:42 -0400 +Subject: [PATCH 84/92] tests: fix t6100-mdraid-partitions + +The test was failing because it didn't wait for the md device +to appear after creating it. +--- + tests/t6100-mdraid-partitions.sh | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh +index dbb1686..b37cddf 100755 +--- a/tests/t6100-mdraid-partitions.sh ++++ b/tests/t6100-mdraid-partitions.sh +@@ -47,6 +47,7 @@ cleanup_fn_() { + + # create mdraid on top of both partitions + mdadm -C $md_dev --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2" ++wait_for_dev_to_appear_ ${md_dev} || { fail=1; cat /proc/partitions; } + + # create gpt and two partitions on the raid device + parted -s $md_dev mklabel gpt \ +-- +2.17.1 + diff --git a/0085-Fix-set-and-disk_set-to-not-crash-when-no-flags-are-.patch b/0085-Fix-set-and-disk_set-to-not-crash-when-no-flags-are-.patch new file mode 100644 index 0000000..49a9017 --- /dev/null +++ b/0085-Fix-set-and-disk_set-to-not-crash-when-no-flags-are-.patch @@ -0,0 +1,77 @@ +From 9e196cc2902255c328a90584e44666b79e4344c3 Mon Sep 17 00:00:00 2001 +From: Phillip Susi <ps...@ubuntu.com> +Date: Thu, 10 May 2018 12:31:36 -0400 +Subject: [PATCH 85/92] Fix set and disk_set to not crash when no flags are + supported + +Loop labels and file images support no flags. set and disk_set +would prompt for a flag and accept any string since the list of +flags was empty, then fail to look up an actual flag value, then +throw an exception with a null string for the name of the flag, +which would bug. +--- + parted/ui.c | 18 ++++++++++++++++-- + tests/t3310-flags.sh | 13 +++++++++++++ + 3 files changed, 31 insertions(+), 2 deletions(-) + +diff --git a/parted/ui.c b/parted/ui.c +index 752860b..4f42b7c 100644 +--- a/parted/ui.c ++++ b/parted/ui.c +@@ -1132,7 +1132,14 @@ command_line_get_disk_flag (const char* + opts = str_list_append_unique (opts, _(walk_name)); + } + } +- ++ if (opts == NULL) ++ { ++ ped_exception_throw (PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_OK, ++ _("No flags supported")); ++ ++ return 0; ++ } + flag_name = command_line_get_word (prompt, NULL, opts, 1); + str_list_destroy (opts); + +@@ -1161,7 +1168,14 @@ command_line_get_part_flag (const char* + opts = str_list_append_unique (opts, _(walk_name)); + } + } +- ++ if (opts == NULL) ++ { ++ ped_exception_throw (PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_OK, ++ _("No flags supported")); ++ ++ return 0; ++ } + flag_name = command_line_get_word (prompt, NULL, opts, 1); + str_list_destroy (opts); + +diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh +index 2da72d0..0997748 100644 +--- a/tests/t3310-flags.sh ++++ b/tests/t3310-flags.sh +@@ -114,4 +114,17 @@ for table_type in aix amiga atari bsd dvh gpt mac msdos pc98 sun loop; do + done + done + ++# loop filesystems support no flags. Make sure this doesn't crash ++ ++if [ $ss == 512 ]; then ++ # only test on 512 byte ss since mke2fs assumes this on a file ++ truncate -s 5m img || framework_failure ++ mke2fs img || framework_failure ++ echo Error: No flags supported > out.exp ++ parted -s img set 1 foo on > out 2>&1 ++ compare out.exp out || fail=1 ++ parted -s img disk_set foo on > out 2>&1 ++ compare out.exp out || fail=1 ++fi ++ + Exit $fail +-- +2.17.1 + diff --git a/0086-mkpart-Allow-negative-start-value-when-FS-TYPE-is-no.patch b/0086-mkpart-Allow-negative-start-value-when-FS-TYPE-is-no.patch new file mode 100644 index 0000000..a42a080 --- /dev/null +++ b/0086-mkpart-Allow-negative-start-value-when-FS-TYPE-is-no.patch @@ -0,0 +1,122 @@ +From f3b4015e216a3733082e71ff930526f3e8bf0c26 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= <m...@nh2.me> +Date: Fri, 11 May 2018 21:09:05 +0200 +Subject: [PATCH 86/92] mkpart: Allow negative start value when FS-TYPE is not + given +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The manual had long documented that negative values are +allowed for both start and end values, but until now negative +start values were rejected if FS-TYPE was not given. + +Example: + + # parted --script -a optimal /dev/loop0 -- mklabel gpt mkpart primary ext4 -5MiB 100% + (succeeds) + + # parted --script -a optimal /dev/loop0 -- mklabel gpt mkpart primary -5MiB 100% + parted: invalid token: -5MiB + Error: Expecting a file system type. + +This commit fixes the latter error. +The issue was an insufficient lookahead in command line parsing, +looking only for digits when skipping over FS-TYPE. +The fix is including the minus '-' in the lookahead. + +Originally reported as Debian bug #880035: + + "parted: fails to use negative start value for 'mkpart' command without specyfying FS-TYPE" + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=880035 + +Signed-off-by: Niklas Hambüchen <m...@nh2.me> +--- + parted/parted.c | 2 +- + tests/Makefile.am | 1 + + tests/t0213-mkpart-start-negative.sh | 48 ++++++++++++++++++++++++++++ + 4 files changed, 52 insertions(+), 1 deletion(-) + create mode 100755 tests/t0213-mkpart-start-negative.sh + +diff --git a/parted/parted.c b/parted/parted.c +index b5e3b97..88f32b9 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -682,7 +682,7 @@ do_mkpart (PedDevice** dev, PedDisk** diskp) + + peek_word = command_line_peek_word (); + if (part_type == PED_PARTITION_EXTENDED +- || (peek_word && isdigit (peek_word[0]))) { ++ || (peek_word && (isdigit (peek_word[0]) || peek_word[0] == '-'))) { + fs_type = NULL; + } else { + if (!command_line_get_fs_type (_("File system type?"), +diff --git a/tests/Makefile.am b/tests/Makefile.am +index a840304..3851983 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -25,6 +25,7 @@ TESTS = \ + t0210-gpt-resized-partition-entry-array.sh \ + t0211-gpt-rewrite-header.sh \ + t0212-gpt-many-partitions.sh \ ++ t0213-mkpart-start-negative.sh \ + t0220-gpt-msftres.sh \ + t0250-gpt.sh \ + t0251-gpt-unicode.sh \ +diff --git a/tests/t0213-mkpart-start-negative.sh b/tests/t0213-mkpart-start-negative.sh +new file mode 100755 +index 0000000..182ef0c +--- /dev/null ++++ b/tests/t0213-mkpart-start-negative.sh +@@ -0,0 +1,48 @@ ++#!/bin/sh ++# Make sure parted mkpart ends the partition one sector before the specified ++# value if end is specified with IEC units. ++ ++# Copyright (C) 2011-2018 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see <http://www.gnu.org/licenses/>. ++ ++. "${srcdir=.}/init.sh"; path_prepend_ ../parted ++ ++require_512_byte_sector_size_ ++n_mbs=8 ++dev=dev-file ++ ++dd if=/dev/null of=$dev bs=1M seek=$n_mbs || fail=1 ++# start negative, end positive ++parted --align=none -s $dev -- mklabel gpt mkpart p1 -7MiB 2MiB > err 2>&1 || fail=1 ++compare /dev/null err || fail=1 # expect no output ++ ++# start negative, end negative ++parted --align=none -s $dev -- mkpart p2 -6MiB -5MiB > err 2>&1 || fail=1 ++compare /dev/null err || fail=1 # expect no output ++ ++# check boundaries of the partitions ++parted -m -s $dev u s p > out || fail=1 ++ ++# prepare expected output ++cat <<EOF > exp || framework_failure ++1:2048s:4095s:2048s::p1:; ++2:4096s:6143s:2048s::p2:; ++EOF ++ ++# compare expected and actual outputs ++sed -e "1,2d" out > k; mv k out ++compare exp out || fail=1 ++ ++Exit $fail +-- +2.17.1 + diff --git a/0087-Fix-resizepart-iec-unit-end-sector.patch b/0087-Fix-resizepart-iec-unit-end-sector.patch new file mode 100644 index 0000000..04fc662 --- /dev/null +++ b/0087-Fix-resizepart-iec-unit-end-sector.patch @@ -0,0 +1,32 @@ +From 247e3fc6cd8bca79b7c0362886ae9b5b06ba6f8c Mon Sep 17 00:00:00 2001 +From: Phillip Susi <ps...@ubuntu.com> +Date: Thu, 12 May 2016 21:38:51 -0400 +Subject: [PATCH 87/92] Fix resizepart iec unit end sector + +Fix resizepart to adjust the end to be -1 sector when using iec +power of 2 units so that the next partition can start immediately +following the new end, just like mkpart does. +--- + parted/parted.c | 5 ++++- + 2 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/parted/parted.c b/parted/parted.c +index 88f32b9..267c346 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -1567,8 +1567,11 @@ do_resizepart (PedDevice** dev, PedDisk** diskp) + + start = part->geom.start; + end = oldend = part->geom.end; +- if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, NULL)) ++ char *end_input; ++ if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input)) + goto error; ++ _adjust_end_if_iec(&start, &end, range_end, end_input); ++ free(end_input); + /* Do not move start of the partition */ + constraint = constraint_from_start_end_fixed_start (*dev, start, range_end); + if (!ped_disk_set_partition_geom (disk, part, constraint, +-- +2.17.1 + diff --git a/0088-build-Remove-unused-traces-of-dynamic-loading.patch b/0088-build-Remove-unused-traces-of-dynamic-loading.patch new file mode 100644 index 0000000..3629bd8 --- /dev/null +++ b/0088-build-Remove-unused-traces-of-dynamic-loading.patch @@ -0,0 +1,238 @@ +From b49388018931cab220b9dd50f3a2bd51401e48af Mon Sep 17 00:00:00 2001 +From: Colin Watson <cjwat...@ubuntu.com> +Date: Mon, 21 Sep 2015 12:10:02 +0100 +Subject: [PATCH 88/92] build: Remove unused traces of dynamic loading + +Now that file system operations have been removed from libparted, +libreiserfs is no longer used. Remove references to it, along with the +dynamic loading build infrastructure which was only used for +libreiserfs. + +Signed-off-by: Colin Watson <cjwat...@ubuntu.com> +--- + README | 9 ++---- + configure.ac | 49 -------------------------------- + doc/parted.texi | 15 ---------- + libparted/Makefile.am | 1 - + libparted/fs/reiserfs/reiserfs.c | 16 +---------- + libparted/tests/Makefile.am | 1 - + libparted/tests/t2100-zerolen.sh | 3 -- + parted.spec.in | 3 +- + 8 files changed, 4 insertions(+), 93 deletions(-) + +diff --git a/README b/README +index 3d1fee9..de91d4c 100644 +--- a/README ++++ b/README +@@ -56,10 +56,5 @@ dangerous bugs before they would have done damage, so we think it's worth + it. Also, it means we get more bug reports ;) + + +-(2) When doing dependencies, remember that libreiserfs is a *soft* dependency, +-so I guess that means Debian-look-alikes should do a "suggests", but +-not a "requires". +- +- +-(3) When space is important, we suggest --without-readline, --disable-shared, +-and possibly --disable-nls and --disable-dynamic-loading. ++(2) When space is important, we suggest --without-readline, --disable-shared, ++and possibly --disable-nls. +diff --git a/configure.ac b/configure.ac +index 056478f..8413e06 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -103,20 +103,6 @@ if test "$enable_discover_only" = yes; then + fi + + PARTED_LIBS="" +-AC_ARG_ENABLE([dynamic-loading], +-[ --enable-dynamic-loading support dynamic fs libraries [default=yes]], , +- if test "$enable_discover_only" = yes; then +- enable_dynamic_loading=no +- else +- enable_dynamic_loading=yes +- fi +-) +-if test "$enable_discover_only" = yes \ +- && test "$enable_dynamic_loading" = yes; then +- AC_MSG_ERROR( +-[You can't use --enable-dynamic-loading and --disable-discover-only together] +- ) +-fi + + AC_ARG_ENABLE([debug], + [ --enable-debug compile in assertions [default=yes]], , +@@ -303,23 +289,6 @@ Or install gettext. GNU gettext is available from + ]) + fi + +-dnl Check for libdl, if we are doing dynamic loading +-DL_LIBS="" +-AC_SUBST([DYNAMIC_LOADING]) +-DYNAMIC_LOADING=no +-if test "$enable_dynamic_loading" = yes; then +- AC_CHECK_LIB([dl], [dlopen], +- DL_LIBS="-ldl" +- PARTED_LIBS="$PARTED_LIBS -ldl" +- DYNAMIC_LOADING=yes +- AC_DEFINE([DYNAMIC_LOADING], [1], [Lazy linking to fs libs]), +- AC_MSG_ERROR( +- [-ldl not found! Try using --disable-dynamic-loading] +- ) +- ) +-fi +-AC_SUBST([DL_LIBS]) +- + dnl Check for libuuid + UUID_LIBS="" + AC_CHECK_LIB([uuid], [uuid_generate], [UUID_LIBS="-luuid"], +@@ -357,24 +326,6 @@ if test "$enable_selinux" = yes; then + fi + AC_SUBST([SELINUX_LIBS]) + +-dnl Check for libreiserfs +-REISER_LIBS="" +-if test "$enable_dynamic_loading" = no && test "$enable_discover_only" = no; then +- OLD_LIBS="$LIBS" +- AC_CHECK_LIB([dal], [dal_equals], +- LIBS="-ldal" +- AC_CHECK_LIB([reiserfs], [reiserfs_fs_probe], +- REISER_LIBS="-ldal -lreiserfs" +- AC_DEFINE([HAVE_LIBREISERFS], [1], [Have libreiserfs]) +- ) +- AC_CHECK_LIB([reiserfs], [reiserfs_fs_check], +- AC_DEFINE([HAVE_REISERFS_FS_CHECK], [1], [Have reiserfs_fs_check()]) +- ) +- ) +- LIBS="$OLD_LIBS" +-fi +-AC_SUBST([REISER_LIBS]) +- + dnl Check for termcap + if test "$with_readline" = yes; then + OLD_LIBS="$LIBS" +diff --git a/doc/parted.texi b/doc/parted.texi +index ac23ef6..c08cdc7 100644 +--- a/doc/parted.texi ++++ b/doc/parted.texi +@@ -178,13 +178,6 @@ internationalisation support is desired. + + @uref{ftp://ftp.gnu.org/gnu/gettext} + +-@item libreiserfs, if you want reiserfs support: +- +- @uref{http://reiserfs.osdn.org.ua} +- +-Note that parted will automatically detect libreiserfs at runtime, and enable +-reiserfs support. libreiserfs is new, and hasn't been widely tested yet. +- + @end itemize + + @node Supported Platforms +@@ -242,14 +235,6 @@ etc., where few libraries are available. + @item --disable-debug + don't include assertions + +-@item --disable-dynamic-loading +-disables dynamic loading of some libraries (only libreiserfs for now, +-although we hope to expand this). Dynamic loading is useful because it +-allows you to reuse libparted shared libraries even when you don't know +-if some libraries will be available. It has a small overhead (mainly +-linking with libdl), so it may be useful to disable it on bootdisks if +-you don't need the flexibility. +- + @item --disable-nls + turns off native language support. This is useful for use with old + versions of glibc, or a trimmed down version of glibc suitable for +diff --git a/libparted/Makefile.am b/libparted/Makefile.am +index cb58648..e4a8049 100644 +--- a/libparted/Makefile.am ++++ b/libparted/Makefile.am +@@ -54,7 +54,6 @@ libparted_la_LIBADD = \ + labels/liblabels.la \ + $(top_builddir)/lib/libgnulib.la \ + $(OS_LIBS) \ +- $(DL_LIBS) \ + $(DM_LIBS) \ + $(SELINUX_LIBS) \ + $(LIB_BLKID) \ +diff --git a/libparted/fs/reiserfs/reiserfs.c b/libparted/fs/reiserfs/reiserfs.c +index 2efcdf3..ef809cd 100644 +--- a/libparted/fs/reiserfs/reiserfs.c ++++ b/libparted/fs/reiserfs/reiserfs.c +@@ -1,5 +1,5 @@ + /* +- reiserfs.c -- libparted / libreiserfs glue ++ reiserfs.c -- ReiserFS detection + Copyright (C) 2001-2002, 2007, 2009-2014 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify +@@ -14,17 +14,6 @@ + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +- +- This is all rather complicated. There are a few combinations: +- * shared libraries full support +- * dynamic libraries present full support (via dlopen) +- * dynamic libraries absent (full support disabled) (via dlopen) +- * discover only +- +- We'd love to hear comments... +- +- So far, we've opted for maximum flexibility for the user. Is it +- all worth it? + */ + + #include <config.h> +@@ -49,9 +38,6 @@ + static PedSector reiserfs_super_offset[] = { 128, 16, -1 }; + static PedFileSystemType* reiserfs_type; + +-#define FPTR +-#define FCLASS extern +- + static PedGeometry *reiserfs_probe(PedGeometry *geom) + { + int i; +diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am +index 9689fb3..7954e91 100644 +--- a/libparted/tests/Makefile.am ++++ b/libparted/tests/Makefile.am +@@ -35,5 +35,4 @@ $(TEST_LOGS): prereq + TESTS_ENVIRONMENT = \ + top_srcdir='$(top_srcdir)' \ + abs_top_srcdir='$(abs_top_srcdir)' \ +- DYNAMIC_LOADING=$(DYNAMIC_LOADING) \ + ENABLE_DEVICE_MAPPER=$(ENABLE_DEVICE_MAPPER) +diff --git a/libparted/tests/t2100-zerolen.sh b/libparted/tests/t2100-zerolen.sh +index ecd579c..e0e521e 100755 +--- a/libparted/tests/t2100-zerolen.sh ++++ b/libparted/tests/t2100-zerolen.sh +@@ -28,9 +28,6 @@ init_root_dir_ + test "$(uname -s)" = Linux \ + || skip_ "not on Linux" + +-test "x$DYNAMIC_LOADING" = xyes \ +- || skip_ "no dynamic loading support" +- + test "x$ENABLE_DEVICE_MAPPER" = xyes \ + || skip_ "no device-mapper support" + +diff --git a/parted.spec.in b/parted.spec.in +index cd5a99a..bdbe218 100644 +--- a/parted.spec.in ++++ b/parted.spec.in +@@ -60,8 +60,7 @@ Parted library, you need to install this package. + %endif + --enable-part-static \ + --enable-pc98=no \ +- --enable-Werror=no \ +- --disable-dynamic-loading ++ --enable-Werror=no + %{__make} %{?_smp_mflags} + + %install +-- +2.17.1 + diff --git a/0089-Lift-512-byte-restriction-on-fat-resize.patch b/0089-Lift-512-byte-restriction-on-fat-resize.patch new file mode 100644 index 0000000..391a9db --- /dev/null +++ b/0089-Lift-512-byte-restriction-on-fat-resize.patch @@ -0,0 +1,52 @@ +From 4347ddb8e2dd01674c759e94eaaf5872915a2e48 Mon Sep 17 00:00:00 2001 +From: Phillip Susi <ps...@ubuntu.com> +Date: Fri, 4 May 2018 10:57:56 -0400 +Subject: [PATCH 89/92] Lift 512 byte restriction on fat resize + +As Colin Watson pointed out way back in 2014, when I removed the +512 byte sector size restriction from the fs recognition code, +I missed the same from the fat resize code. +--- + NEWS | 2 ++ + libparted/fs/r/fat/bootsector.c | 12 ------------ + 2 files changed, 2 insertions(+), 12 deletions(-) + +diff --git a/NEWS b/NEWS +index 83352a6..552e319 100644 +--- a/NEWS ++++ b/NEWS +@@ -45,6 +45,8 @@ GNU parted NEWS -*- outline -*- + + ** New Features + ++ libparted-fs-resize: Work on non 512 byte sectors. ++ + Add resizepart command to resize a partition. This works even on + mounted partitions. + +diff --git a/libparted/fs/r/fat/bootsector.c b/libparted/fs/r/fat/bootsector.c +index 99d788d..3e34e13 100644 +--- a/libparted/fs/r/fat/bootsector.c ++++ b/libparted/fs/r/fat/bootsector.c +@@ -125,18 +125,6 @@ fat_boot_sector_analyse (FatBootSector* bs, PedFileSystem* fs) + + PED_ASSERT (bs != NULL); + +- if (PED_LE16_TO_CPU (bs->sector_size) != 512) { +- if (ped_exception_throw ( +- PED_EXCEPTION_BUG, +- PED_EXCEPTION_IGNORE_CANCEL, +- _("This file system has a logical sector size of %d. " +- "GNU Parted is known not to work properly with sector " +- "sizes other than 512 bytes."), +- (int) PED_LE16_TO_CPU (bs->sector_size)) +- != PED_EXCEPTION_IGNORE) +- return 0; +- } +- + fs_info->logical_sector_size = PED_LE16_TO_CPU (bs->sector_size) / 512; + + fs_info->sectors_per_track = PED_LE16_TO_CPU (bs->secs_track); +-- +2.17.1 + diff --git a/0090-Fix-atari-label-false-positives.patch b/0090-Fix-atari-label-false-positives.patch new file mode 100644 index 0000000..054300b --- /dev/null +++ b/0090-Fix-atari-label-false-positives.patch @@ -0,0 +1,41 @@ +From 395f8aabfecb28820006d37ec37e9ffe1d2eb1e3 Mon Sep 17 00:00:00 2001 +From: Phillip Susi <ps...@ubuntu.com> +Date: Fri, 11 May 2018 11:01:01 -0400 +Subject: [PATCH 90/92] Fix atari label false positives + +The atari label gets false positives easily, so probe it after +all other labels have said no. +--- + libparted/libparted.c | 4 ++-- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/libparted/libparted.c b/libparted/libparted.c +index d855d0e..3bd071d 100644 +--- a/libparted/libparted.c ++++ b/libparted/libparted.c +@@ -80,12 +80,13 @@ extern void ped_disk_atari_init (); + static void + init_disk_types () + { ++ /* Note that probing is done in the reverse order of init */ + ped_disk_loop_init (); /* must be last in the probe list */ + + #if defined __s390__ || defined __s390x__ + ped_disk_dasd_init(); + #endif +- ++ ped_disk_atari_init (); /* easy false positives, so probe others first */ + ped_disk_sun_init (); + #ifdef ENABLE_PC98 + ped_disk_pc98_init (); +@@ -97,7 +98,6 @@ init_disk_types () + ped_disk_bsd_init (); + ped_disk_amiga_init (); + ped_disk_aix_init (); +- ped_disk_atari_init (); + } + + extern void ped_file_system_amiga_init (void); +-- +2.17.1 + diff --git a/0091-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch b/0091-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch new file mode 100644 index 0000000..c41e16e --- /dev/null +++ b/0091-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch @@ -0,0 +1,87 @@ +From 073c24b5d2361857b8ce8b5dcd81a3e26fc05b96 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" <b...@redhat.com> +Date: Wed, 27 Jun 2018 13:45:09 -0700 +Subject: [PATCH 91/92] Modify gpt-header-move and msdos-overlap to work with + py2 or py3 + +Distributions are starting to remove python2 and only use python3. +Modify these test scripts so that they will work with either python 2.7 +or python 3.X +--- + tests/gpt-header-move | 15 ++++++++------- + tests/msdos-overlap | 5 ++--- + 2 files changed, 10 insertions(+), 10 deletions(-) + +diff --git a/tests/gpt-header-move b/tests/gpt-header-move +index 05cdc65..3dda5cb 100755 +--- a/tests/gpt-header-move ++++ b/tests/gpt-header-move +@@ -3,20 +3,21 @@ + # open img file, subtract 33 from altlba address, and move the last 33 sectors + # back by 33 sectors + +-from struct import * ++from struct import unpack_from, pack_into + from zipfile import crc32 + import array + import sys ++ + file = open(sys.argv[1],'rb+') + file.seek(512) + gptheader = file.read(512) +-altlba = unpack_from('<q', gptheader,offset=32)[0] +-gptheader = array.array('c',gptheader) ++altlba = unpack_from('<q', gptheader, offset=32)[0] ++gptheader = array.array('B', gptheader) + pack_into('<Q', gptheader, 32, altlba-33) + #zero header crc + pack_into('<L', gptheader, 16, 0) + #compute new crc +-newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF) ++newcrc = ((crc32(gptheader[:92])) & 0xFFFFFFFF) + pack_into('<L', gptheader, 16, newcrc) + file.seek(512) + file.write(gptheader) +@@ -25,7 +26,7 @@ gptheader = file.read(512) + file.seek(512*(altlba-32)) + backup = file.read(512*32) + altlba -= 33 +-gptheader = array.array('c',gptheader) ++gptheader = array.array('B',gptheader) + #update mylba + pack_into('<Q', gptheader, 24, altlba) + #update table lba +@@ -33,9 +34,9 @@ pack_into('<Q', gptheader, 72, altlba-32) + #zero header crc + pack_into('<L', gptheader, 16, 0) + #compute new crc +-newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF) ++newcrc = ((crc32(gptheader[:92])) & 0xFFFFFFFF) + pack_into('<L', gptheader, 16, newcrc) + file.seek(512*(altlba-32)) + file.write(backup) + file.write(gptheader) +-file.write("\0" * (512 * 33)) ++file.write(b"\0" * (512 * 33)) +diff --git a/tests/msdos-overlap b/tests/msdos-overlap +index 5bddfb0..d6ae8d6 100755 +--- a/tests/msdos-overlap ++++ b/tests/msdos-overlap +@@ -14,12 +14,11 @@ BAD_ENTRY = (0x72, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + OFFSET = 0x1b8 + + if len(sys.argv) < 2: +- print "%s: <image or device>" ++ print("%s: <image or device>" % sys.argv[0]) + sys.exit(1) + +-data = "".join(chr(c) for c in BAD_ENTRY) + with open(sys.argv[1], "rb+") as f: + f.seek(OFFSET, 0) +- f.write(data) ++ f.write(bytes(bytearray(BAD_ENTRY))) + + sys.exit(0) +-- +2.17.1 + diff --git a/0092-Switch-gpt-header-move-and-msdos-overlap-to-python3.patch b/0092-Switch-gpt-header-move-and-msdos-overlap-to-python3.patch new file mode 100644 index 0000000..1c7dff3 --- /dev/null +++ b/0092-Switch-gpt-header-move-and-msdos-overlap-to-python3.patch @@ -0,0 +1,33 @@ +From 38badae4d6b858da713b383b9bc7bdad6294ca1b Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" <b...@redhat.com> +Date: Wed, 27 Jun 2018 13:47:33 -0700 +Subject: [PATCH 92/92] Switch gpt-header-move and msdos-overlap to python3 + +--- + tests/gpt-header-move | 2 +- + tests/msdos-overlap | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tests/gpt-header-move b/tests/gpt-header-move +index 3dda5cb..18f58d0 100755 +--- a/tests/gpt-header-move ++++ b/tests/gpt-header-move +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + + # open img file, subtract 33 from altlba address, and move the last 33 sectors + # back by 33 sectors +diff --git a/tests/msdos-overlap b/tests/msdos-overlap +index d6ae8d6..b2b03e6 100755 +--- a/tests/msdos-overlap ++++ b/tests/msdos-overlap +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + """ + Write an overlapping partition to a msdos disk + +-- +2.17.1 + diff --git a/0093-libparted-Fix-ending-CHS-address-in-PMBR.patch b/0093-libparted-Fix-ending-CHS-address-in-PMBR.patch new file mode 100644 index 0000000..3768872 --- /dev/null +++ b/0093-libparted-Fix-ending-CHS-address-in-PMBR.patch @@ -0,0 +1,29 @@ +From 93684aeb12cf96e5bfefa405940c3010f60161b1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ulrich=20M=C3=BCller?= <u...@gentoo.org> +Date: Sat, 14 Jul 2018 09:09:31 +0200 +Subject: [PATCH] libparted: Fix ending CHS address in PMBR. + +According to the UEFI specification version 2.7, Section 5.2.3, +Table 16, the ending CHS address in the protective MBR should be set +to 0xFFFFFF. This also agrees with the behaviour of fdisk from +util-linux-2.32. +--- + libparted/labels/gpt.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c +index 4f922b2..6f92a34 100644 +--- a/libparted/labels/gpt.c ++++ b/libparted/labels/gpt.c +@@ -1144,7 +1144,7 @@ _write_pmbr (PedDevice *dev, bool pmbr_boot) + pmbr->Signature = PED_CPU_TO_LE16 (MSDOS_MBR_SIGNATURE); + pmbr->PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI; + pmbr->PartitionRecord[0].StartSector = 2; +- pmbr->PartitionRecord[0].EndHead = 0xFE; ++ pmbr->PartitionRecord[0].EndHead = 0xFF; + pmbr->PartitionRecord[0].EndSector = 0xFF; + pmbr->PartitionRecord[0].EndTrack = 0xFF; + pmbr->PartitionRecord[0].StartingLBA = PED_CPU_TO_LE32 (1); +-- +2.17.2 + diff --git a/0094-Fix-the-length-of-several-strncpy-calls.patch b/0094-Fix-the-length-of-several-strncpy-calls.patch new file mode 100644 index 0000000..a7b03e6 --- /dev/null +++ b/0094-Fix-the-length-of-several-strncpy-calls.patch @@ -0,0 +1,76 @@ +From 60906f5674ca32ddfaf8c18fe2e4ebe510dbbd6f Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" <b...@redhat.com> +Date: Mon, 23 Jul 2018 14:34:30 -0700 +Subject: [PATCH 094/103] Fix the length of several strncpy calls + +These need to be 1 less than the allocated size of the buffer, strncpy +will fill shorter strings with zeros, but there needs to be room for at +least one 0x00 at the end if the string is the same length as the buffer +and has no terminating 0x00. + +Related: rhbz#1602652 +--- + libparted/arch/linux.c | 12 ++++++++---- + libparted/labels/mac.c | 9 ++++++--- + 2 files changed, 14 insertions(+), 7 deletions(-) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 7e86b51..4c778ea 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -2582,9 +2582,12 @@ _blkpg_add_partition (PedDisk* disk, const PedPartition *part) + linux_part.length = part->geom.length * disk->dev->sector_size; + } + linux_part.pno = part->num; +- strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH); +- if (vol_name) +- strncpy (linux_part.volname, vol_name, BLKPG_VOLNAMELTH); ++ strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH-1); ++ linux_part.devname[BLKPG_DEVNAMELTH-1] = '\0'; ++ if (vol_name) { ++ strncpy (linux_part.volname, vol_name, BLKPG_VOLNAMELTH-1); ++ linux_part.volname[BLKPG_VOLNAMELTH-1] = '\0'; ++ } + + free (dev_name); + +@@ -2640,7 +2643,8 @@ static int _blkpg_resize_partition (PedDisk* disk, const PedPartition *part) + else + linux_part.length = part->geom.length * disk->dev->sector_size; + linux_part.pno = part->num; +- strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH); ++ strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH-1); ++ linux_part.devname[BLKPG_DEVNAMELTH-1] = '\0'; + + free (dev_name); + +diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c +index fa4e43f..4942c82 100644 +--- a/libparted/labels/mac.c ++++ b/libparted/labels/mac.c +@@ -930,8 +930,10 @@ _generate_raw_part (PedDisk* disk, PedPartition* part, + = PED_CPU_TO_BE32 (mac_disk_data->last_part_entry_num); + part_map_entry->start_block = PED_CPU_TO_BE32 (part->geom.start); + part_map_entry->block_count = PED_CPU_TO_BE32 (part->geom.length); +- strncpy (part_map_entry->name, mac_part_data->volume_name, 32); +- strncpy (part_map_entry->type, mac_part_data->system_name, 32); ++ strncpy (part_map_entry->name, mac_part_data->volume_name, 31); ++ part_map_entry->name[31] = '\0'; ++ strncpy (part_map_entry->type, mac_part_data->system_name, 31); ++ part_map_entry->type[31] = '\0'; + + if (mac_part_data->is_driver) { + if (mac_part_data->has_driver) +@@ -954,7 +956,8 @@ _generate_raw_part (PedDisk* disk, PedPartition* part, + part_map_entry->boot_cksum = + PED_CPU_TO_BE32 (mac_part_data->boot_checksum); + +- strncpy (part_map_entry->processor, mac_part_data->processor_name, 16); ++ strncpy (part_map_entry->processor, mac_part_data->processor_name, 15); ++ part_map_entry->processor[15] = '\0'; + + if (!_pad_raw_part (disk, part->num, part_map)) + goto error; +-- +2.17.2 + diff --git a/0095-parted.c-Always-free-peek_word.patch b/0095-parted.c-Always-free-peek_word.patch new file mode 100644 index 0000000..d5dbad7 --- /dev/null +++ b/0095-parted.c-Always-free-peek_word.patch @@ -0,0 +1,35 @@ +From b260c3354d5e9318321c2fc482724870fd9b2740 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" <b...@redhat.com> +Date: Mon, 23 Jul 2018 15:12:38 -0700 +Subject: [PATCH 095/103] parted.c: Always free peek_word + +If command_line_get_fs_type failed it would never free it, so put a free +in both branches of the if. + +Related: rhbz#1602652 +--- + parted/parted.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/parted/parted.c b/parted/parted.c +index 267c346..0dc38c3 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -684,12 +684,13 @@ do_mkpart (PedDevice** dev, PedDisk** diskp) + if (part_type == PED_PARTITION_EXTENDED + || (peek_word && (isdigit (peek_word[0]) || peek_word[0] == '-'))) { + fs_type = NULL; ++ free (peek_word); + } else { ++ free (peek_word); + if (!command_line_get_fs_type (_("File system type?"), + &fs_type)) + goto error; + } +- free (peek_word); + + if (!command_line_get_sector (_("Start?"), *dev, &start, &range_start, NULL)) + goto error; +-- +2.17.2 + diff --git a/0096-parted.c-Make-sure-dev_name-is-freed.patch b/0096-parted.c-Make-sure-dev_name-is-freed.patch new file mode 100644 index 0000000..9040d26 --- /dev/null +++ b/0096-parted.c-Make-sure-dev_name-is-freed.patch @@ -0,0 +1,45 @@ +From c624fe22349912ca8bd1a288d5ccc65b6e346420 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" <b...@redhat.com> +Date: Mon, 23 Jul 2018 15:18:37 -0700 +Subject: [PATCH 096/103] parted.c: Make sure dev_name is freed + +If there was a problem with ped_device_get or ped_device_open it would not be freed. + +Related: rhbz#1602652 +--- + parted/parted.c | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +diff --git a/parted/parted.c b/parted/parted.c +index 0dc38c3..35432c6 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -1101,6 +1101,7 @@ do_print (PedDevice** dev, PedDisk** diskp) + if (has_devices_arg) { + char* dev_name; + PedDevice* current_dev = NULL; ++ int status = 0; + + ped_device_probe_all(); + +@@ -1116,14 +1117,11 @@ do_print (PedDevice** dev, PedDisk** diskp) + ped_device_free_all (); + + *dev = ped_device_get (dev_name); +- if (!*dev) +- return 0; +- if (!ped_device_open (*dev)) +- return 0; +- ++ if (*dev && ped_device_open (*dev)) ++ status = 1; + free (dev_name); + +- return 1; ++ return status; + } + + else if (has_list_arg) +-- +2.17.2 + diff --git a/0097-t6100-mdraid-partitions-Use-v0.90-metadata-for-the-t.patch b/0097-t6100-mdraid-partitions-Use-v0.90-metadata-for-the-t.patch new file mode 100644 index 0000000..4b1dddc --- /dev/null +++ b/0097-t6100-mdraid-partitions-Use-v0.90-metadata-for-the-t.patch @@ -0,0 +1,29 @@ +From f0cfa9581f6bd9a1b0d7f0389d3460bcd4ccfde8 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" <b...@redhat.com> +Date: Mon, 23 Jul 2018 16:07:40 -0700 +Subject: [PATCH 097/103] t6100-mdraid-partitions: Use v0.90 metadata for the + test + +Newer metadata types use more disk space, causing the test to fail. +--- + tests/t6100-mdraid-partitions.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh +index b37cddf..42905fa 100755 +--- a/tests/t6100-mdraid-partitions.sh ++++ b/tests/t6100-mdraid-partitions.sh +@@ -45,8 +45,8 @@ cleanup_fn_() { + mdadm -S $md_dev || warn_ "Failed to stop MD array, $md_dev" + } + +-# create mdraid on top of both partitions +-mdadm -C $md_dev --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2" ++# create mdraid on top of both partitions with v0.90 metadata ++mdadm -C $md_dev -e0 --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2" + wait_for_dev_to_appear_ ${md_dev} || { fail=1; cat /proc/partitions; } + + # create gpt and two partitions on the raid device +-- +2.17.2 + diff --git a/0098-Fix-potential-command-line-buffer-overflow.patch b/0098-Fix-potential-command-line-buffer-overflow.patch new file mode 100644 index 0000000..f038895 --- /dev/null +++ b/0098-Fix-potential-command-line-buffer-overflow.patch @@ -0,0 +1,46 @@ +From a52926f6d3cd2520419c60d4f81a410d33d6d970 Mon Sep 17 00:00:00 2001 +From: Simon Xu <xu.si...@oracle.com> +Date: Mon, 20 Aug 2018 20:31:26 +0800 +Subject: [PATCH 098/103] Fix potential command line buffer overflow + +parted terminates with 'stack smashing detected' when fed with a long command +line argument, and segfaults when the argument is long enough: + +root # /sbin/parted /dev/sda $(perl -e 'print "a"x265') +*** stack smashing detected ***: /sbin/parted terminated +... +Aborted + +root # /sbin/parted /dev/sda $(perl -e 'print "a"x328') +*** stack smashing detected ***: /sbin/parted terminated +... +Command History: +Segmentation fault + +parted should be able to detect it and exit with error and usage messages. +This also makes command line buffer overflow exploit more possible. Fix it by +adding length check in the condition of the for loop where command line +arguments are copied. + +Signed-off-by: Simon Xu <xu.si...@oracle.com> +Signed-off-by: Brian C. Lane <b...@redhat.com> +--- + parted/ui.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/parted/ui.c b/parted/ui.c +index 4f42b7c..d421768 100644 +--- a/parted/ui.c ++++ b/parted/ui.c +@@ -728,7 +728,7 @@ command_line_push_line (const char* line, int multi_word) + line++; + + i = 0; +- for (; *line; line++) { ++ for (; *line && i < sizeof (this_word) - 1; line++) { + if (*line == ' ' && !quoted) { + if (multi_word) + break; +-- +2.17.2 + diff --git a/0099-libparted-Add-support-for-MBR-id-GPT-GUID-and-detect.patch b/0099-libparted-Add-support-for-MBR-id-GPT-GUID-and-detect.patch new file mode 100644 index 0000000..bc7acb2 --- /dev/null +++ b/0099-libparted-Add-support-for-MBR-id-GPT-GUID-and-detect.patch @@ -0,0 +1,379 @@ +From 8740cfcff3ea839dd6dc8650dec0a466e9870625 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.ro...@gmail.com> +Date: Tue, 28 Aug 2018 21:20:01 +0200 +Subject: [PATCH 099/103] libparted: Add support for MBR id, GPT GUID and + detection of UDF filesystem + +This is needed for libparted based applications (like Gparted) to correctly +choose MBR id and GPT GUID for UDF filesystem. MBR id for UDF is 0x07 and +GPT GUID is Microsoft Basic Data, see why: https://serverfault.com/a/829172 + +Without registering a new libparted fs code it is not possible to assign +MBR id or GPT GUID. + +Detection of UDF filesystem is done by checking presence of UDF VSD (NSR02 +or NSR03 identifier) and UDF AVDP at expected locations (blocks 256, -257, +-1, 512). + +Signed-off-by: Brian C. Lane <b...@redhat.com> +--- + NEWS | 2 + + libparted/fs/Makefile.am | 1 + + libparted/fs/udf/udf.c | 175 ++++++++++++++++++++++++++ + libparted/labels/dos.c | 3 + + libparted/labels/gpt.c | 1 + + libparted/libparted.c | 4 + + scripts/data/abi/baseline_symbols.txt | 2 + + tests/Makefile.am | 1 + + tests/t2410-dos-udf-partition-type.sh | 38 ++++++ + 9 files changed, 227 insertions(+) + create mode 100644 libparted/fs/udf/udf.c + create mode 100644 tests/t2410-dos-udf-partition-type.sh + +diff --git a/NEWS b/NEWS +index ee6efb6..45ea91c 100644 +--- a/NEWS ++++ b/NEWS +@@ -47,6 +47,8 @@ GNU parted NEWS -*- outline -*- + + ** New Features + ++ Add support for MBR id, GPT GUID and detection of UDF filesystem. ++ + libparted-fs-resize: Work on non 512 byte sectors. + + Add resizepart command to resize a partition. This works even on +diff --git a/libparted/fs/Makefile.am b/libparted/fs/Makefile.am +index d3cc8bc..cab32c7 100644 +--- a/libparted/fs/Makefile.am ++++ b/libparted/fs/Makefile.am +@@ -44,6 +44,7 @@ libfs_la_SOURCES = \ + ntfs/ntfs.c \ + reiserfs/reiserfs.c \ + reiserfs/reiserfs.h \ ++ udf/udf.c \ + ufs/ufs.c \ + xfs/platform_defs.h \ + xfs/xfs.c \ +diff --git a/libparted/fs/udf/udf.c b/libparted/fs/udf/udf.c +new file mode 100644 +index 0000000..00209e1 +--- /dev/null ++++ b/libparted/fs/udf/udf.c +@@ -0,0 +1,175 @@ ++/* ++ libparted - a library for manipulating disk partitions ++ Copyright (C) 2018 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see <http://www.gnu.org/licenses/>. ++*/ ++ ++#include <config.h> ++ ++#include <parted/parted.h> ++ ++/* Read bytes using ped_geometry_read() function */ ++static int read_bytes (const PedGeometry* geom, void* buffer, PedSector offset, PedSector count) ++{ ++ char* sector_buffer; ++ PedSector sector_offset, sector_count, buffer_offset; ++ ++ sector_offset = offset / geom->dev->sector_size; ++ sector_count = (offset + count + geom->dev->sector_size - 1) / geom->dev->sector_size - sector_offset; ++ buffer_offset = offset - sector_offset * geom->dev->sector_size; ++ ++ sector_buffer = alloca (sector_count * geom->dev->sector_size); ++ ++ if (!ped_geometry_read (geom, sector_buffer, sector_offset, sector_count)) ++ return 0; ++ ++ memcpy (buffer, sector_buffer + buffer_offset, count); ++ return 1; ++} ++ ++/* Scan VSR and check for UDF VSD */ ++static int check_vrs (const PedGeometry* geom, unsigned int vsdsize) ++{ ++ PedSector block; ++ PedSector offset; ++ unsigned char ident[5]; ++ ++ /* Check only first 64 blocks, but theoretically standard does not define upper limit */ ++ for (block = 0; block < 64; block++) { ++ /* VRS starts at fixed offset 32kB, it is independent of block size or vsd size */ ++ offset = 32768 + block * vsdsize; ++ ++ /* Read VSD identifier, it is at offset 1 */ ++ if (!read_bytes (geom, ident, offset + 1, 5)) ++ return 0; ++ ++ /* Check for UDF identifier */ ++ if (memcmp (ident, "NSR02", 5) == 0 || ++ memcmp (ident, "NSR03", 5) == 0) ++ return 1; ++ ++ /* Unknown VSD identifier means end of VRS */ ++ if (memcmp (ident, "BEA01", 5) != 0 && ++ memcmp (ident, "TEA01", 5) != 0 && ++ memcmp (ident, "BOOT2", 5) != 0 && ++ memcmp (ident, "CD001", 5) != 0 && ++ memcmp (ident, "CDW02", 5) != 0) ++ break; ++ } ++ ++ return 0; ++} ++ ++/* Check for UDF AVDP */ ++static int check_anchor (const PedGeometry* geom, unsigned int blocksize, int rel_block) ++{ ++ PedSector block; ++ unsigned char tag[16]; ++ ++ /* Negative block means relative to the end of device */ ++ if (rel_block < 0) { ++ block = geom->length * geom->dev->sector_size / blocksize; ++ if (block <= (PedSector)(-rel_block)) ++ return 0; ++ block -= (PedSector)(-rel_block); ++ if (block < 257) ++ return 0; ++ } else { ++ block = rel_block; ++ } ++ ++ if (!read_bytes (geom, tag, block * blocksize, 16)) ++ return 0; ++ ++ /* Check for AVDP type (0x0002) */ ++ if (((unsigned short)tag[0] | ((unsigned short)tag[1] << 8)) != 0x0002) ++ return 0; ++ ++ /* Check that location stored in AVDP matches */ ++ if (((unsigned long)tag[12] | ((unsigned long)tag[13] << 8) | ((unsigned long)tag[14] << 16) | ((unsigned long)tag[15] << 24)) != block) ++ return 0; ++ ++ return 1; ++} ++ ++/* Detect presence of UDF AVDP */ ++static int detect_anchor(const PedGeometry* geom, unsigned int blocksize) ++{ ++ /* All possible AVDP locations in preferred order */ ++ static int anchors[] = { 256, -257, -1, 512 }; ++ size_t i; ++ ++ for (i = 0; i < sizeof (anchors)/sizeof (*anchors); i++) { ++ if (check_anchor (geom, blocksize, anchors[i])) ++ return 1; ++ } ++ ++ return 0; ++} ++ ++/* Detect UDF filesystem, it must have VRS and AVDP */ ++static int detect_udf (const PedGeometry* geom) ++{ ++ unsigned int blocksize; ++ ++ /* VSD size is min(2048, UDF block size), check for block sizes <= 2048 */ ++ if (check_vrs (geom, 2048)) { ++ for (blocksize = 512; blocksize <= 2048; blocksize *= 2) { ++ if (detect_anchor (geom, blocksize)) ++ return 1; ++ } ++ } ++ ++ /* Check for block sizes larger then 2048, maximal theoretical block size is 32kB */ ++ for (blocksize = 4096; blocksize <= 32768; blocksize *= 2) { ++ if (!check_vrs (geom, blocksize)) ++ continue; ++ if (detect_anchor (geom, blocksize)) ++ return 1; ++ } ++ ++ return 0; ++} ++ ++PedGeometry* ++udf_probe (PedGeometry* geom) ++{ ++ if (!detect_udf (geom)) ++ return NULL; ++ ++ return ped_geometry_duplicate (geom); ++} ++ ++static PedFileSystemOps udf_ops = { ++ probe: udf_probe, ++}; ++ ++static PedFileSystemType udf_type = { ++ next: NULL, ++ ops: &udf_ops, ++ name: "udf", ++}; ++ ++void ++ped_file_system_udf_init () ++{ ++ ped_file_system_type_register (&udf_type); ++} ++ ++void ++ped_file_system_udf_done () ++{ ++ ped_file_system_type_unregister (&udf_type); ++} +diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c +index fa53020..b2b8de9 100644 +--- a/libparted/labels/dos.c ++++ b/libparted/labels/dos.c +@@ -65,6 +65,7 @@ static const char MBR_BOOT_CODE[] = { + #define PARTITION_FAT16 0x06 + #define PARTITION_NTFS 0x07 + #define PARTITION_HPFS 0x07 ++#define PARTITION_UDF 0x07 + #define PARTITION_FAT32 0x0b + #define PARTITION_FAT32_LBA 0x0c + #define PARTITION_FAT16_LBA 0x0e +@@ -1498,6 +1499,8 @@ msdos_partition_set_system (PedPartition* part, + } else if (!strcmp (fs_type->name, "hfs") + || !strcmp (fs_type->name, "hfs+")) + dos_data->system = PARTITION_HFS; ++ else if (!strcmp (fs_type->name, "udf")) ++ dos_data->system = PARTITION_UDF; + else if (!strcmp (fs_type->name, "sun-ufs")) + dos_data->system = PARTITION_SUN_UFS; + else if (is_linux_swap (fs_type->name)) +diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c +index 6f92a34..860f415 100644 +--- a/libparted/labels/gpt.c ++++ b/libparted/labels/gpt.c +@@ -1513,6 +1513,7 @@ gpt_partition_set_system (PedPartition *part, + if (fs_type) + { + if (strncmp (fs_type->name, "fat", 3) == 0 ++ || strcmp (fs_type->name, "udf") == 0 + || strcmp (fs_type->name, "ntfs") == 0) + { + gpt_part_data->type = PARTITION_BASIC_DATA_GUID; +diff --git a/libparted/libparted.c b/libparted/libparted.c +index 3bd071d..e517875 100644 +--- a/libparted/libparted.c ++++ b/libparted/libparted.c +@@ -112,6 +112,7 @@ extern void ped_file_system_fat_init (void); + extern void ped_file_system_ext2_init (void); + extern void ped_file_system_nilfs2_init (void); + extern void ped_file_system_btrfs_init (void); ++extern void ped_file_system_udf_init (void); + + static void + init_file_system_types () +@@ -128,6 +129,7 @@ init_file_system_types () + ped_file_system_ext2_init (); + ped_file_system_nilfs2_init (); + ped_file_system_btrfs_init (); ++ ped_file_system_udf_init (); + } + + extern void ped_disk_aix_done (); +@@ -193,6 +195,7 @@ extern void ped_file_system_ufs_done (void); + extern void ped_file_system_xfs_done (void); + extern void ped_file_system_amiga_done (void); + extern void ped_file_system_btrfs_done (void); ++extern void ped_file_system_udf_done (void); + + static void + done_file_system_types () +@@ -209,6 +212,7 @@ done_file_system_types () + ped_file_system_xfs_done (); + ped_file_system_amiga_done (); + ped_file_system_btrfs_done (); ++ ped_file_system_udf_done (); + } + + static void _done() __attribute__ ((destructor)); +diff --git a/scripts/data/abi/baseline_symbols.txt b/scripts/data/abi/baseline_symbols.txt +index 9162f1a..69abd82 100644 +--- a/scripts/data/abi/baseline_symbols.txt ++++ b/scripts/data/abi/baseline_symbols.txt +@@ -340,6 +340,8 @@ FUNC:ped_file_system_type_get + FUNC:ped_file_system_type_get_next + FUNC:ped_file_system_type_register + FUNC:ped_file_system_type_unregister ++FUNC:ped_file_system_udf_init ++FUNC:ped_file_system_udf_done + FUNC:ped_file_system_ufs_done + FUNC:ped_file_system_ufs_init + FUNC:ped_file_system_xfs_done +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 3851983..3fa75a9 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -51,6 +51,7 @@ TESTS = \ + t2310-dos-extended-2-sector-min-offset.sh \ + t2320-dos-extended-noclobber.sh \ + t2400-dos-hfs-partition-type.sh \ ++ t2410-dos-udf-partition-type.sh \ + t2500-probe-corrupt-hfs.sh \ + t3000-resize-fs.sh \ + t3200-resize-partition.sh \ +diff --git a/tests/t2410-dos-udf-partition-type.sh b/tests/t2410-dos-udf-partition-type.sh +new file mode 100644 +index 0000000..7cc8a02 +--- /dev/null ++++ b/tests/t2410-dos-udf-partition-type.sh +@@ -0,0 +1,38 @@ ++#!/bin/sh ++# Ensure that an UDF partition in a dos table gets the right ID ++ ++# Copyright (C) 2018 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see <http://www.gnu.org/licenses/>. ++ ++. "${srcdir=.}/init.sh"; path_prepend_ ../parted ++ ++dev=loop-file ++ss=$sector_size_ ++n_sectors=8000 ++ ++dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || framework_failure ++ ++# create a GPT partition table ++parted -s $dev mklabel msdos \ ++ mkpart pri udf 2048s 4095s > out 2>&1 || fail=1 ++# expect no output ++compare /dev/null out || fail=1 ++ ++# Extract the "type" byte of the first partition. ++od -An -j450 -tx1 -N1 $dev > out || fail=1 ++printf ' 07\n' > exp || fail=1 ++compare exp out || fail=1 ++ ++Exit $fail +-- +2.17.2 + diff --git a/0100-Add-udf-to-t1700-probe-fs-and-to-the-manpage.patch b/0100-Add-udf-to-t1700-probe-fs-and-to-the-manpage.patch new file mode 100644 index 0000000..773e78a --- /dev/null +++ b/0100-Add-udf-to-t1700-probe-fs-and-to-the-manpage.patch @@ -0,0 +1,41 @@ +From 749b42f25534bec8625e74a6c1c61c3ad6cc8b17 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" <b...@redhat.com> +Date: Tue, 16 Oct 2018 13:37:09 -0700 +Subject: [PATCH 100/103] Add udf to t1700-probe-fs and to the manpage + +If mkfs.udf is installed this will test to make sure that the filesystem +is detected. +--- + doc/C/parted.8 | 2 +- + tests/t1700-probe-fs.sh | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/doc/C/parted.8 b/doc/C/parted.8 +index eb7cd98..fecdc29 100644 +--- a/doc/C/parted.8 ++++ b/doc/C/parted.8 +@@ -78,7 +78,7 @@ Create a new partition. \fIpart-type\fP may be specified only with msdos and + dvh partition tables, it should be one of "primary", "logical", or "extended". + \fIname\fP is required for GPT partition tables and \fIfs-type\fP is optional. + \fIfs-type\fP can be one of "btrfs", "ext2", "ext3", "ext4", "fat16", "fat32", +-"hfs", "hfs+", "linux-swap", "ntfs", "reiserfs", or "xfs". ++"hfs", "hfs+", "linux-swap", "ntfs", "reiserfs", "udf", or "xfs". + .TP + .B name \fIpartition\fP \fIname\fP + Set the name of \fIpartition\fP to \fIname\fP. This option works only on Mac, +diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh +index b13cec0..853d6bc 100755 +--- a/tests/t1700-probe-fs.sh ++++ b/tests/t1700-probe-fs.sh +@@ -23,7 +23,7 @@ dev=loop-file + ss=$sector_size_ + n_sectors=$((512*1024)) + +-for type in ext2 ext3 ext4 btrfs xfs nilfs2 ntfs vfat hfsplus; do ++for type in ext2 ext3 ext4 btrfs xfs nilfs2 ntfs vfat hfsplus udf; do + + ( mkfs.$type 2>&1 | grep -i '^usage' ) > /dev/null \ + || { warn_ "$ME: no $type support"; continue; } +-- +2.17.2 + diff --git a/0101-ped_unit_get_name-Resolve-conflicting-attributes-con.patch b/0101-ped_unit_get_name-Resolve-conflicting-attributes-con.patch new file mode 100644 index 0000000..519f33f --- /dev/null +++ b/0101-ped_unit_get_name-Resolve-conflicting-attributes-con.patch @@ -0,0 +1,34 @@ +From 3262e2fe9ec93ad2c24e1b117bf87fb6f4b6ffec Mon Sep 17 00:00:00 2001 +From: dann frazier <dann.fraz...@canonical.com> +Date: Fri, 31 Aug 2018 09:28:27 -0600 +Subject: [PATCH 101/103] ped_unit_get_name: Resolve conflicting attributes + 'const' and 'pure' + +The const and pure attributes conflict: + + error: ignoring attribute 'const' because it conflicts with attribute 'pure' [-Werror=attributes] + +pure functions may access global memory, const functions may not. +ped_unit_get_name() accesses non-local variable unit_names, so drop const. + +Signed-off-by: Brian C. Lane <b...@redhat.com> +--- + include/parted/unit.in.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/parted/unit.in.h b/include/parted/unit.in.h +index 9d6e06a..315660d 100644 +--- a/include/parted/unit.in.h ++++ b/include/parted/unit.in.h +@@ -66,7 +66,7 @@ typedef enum { + + extern long long ped_unit_get_size (const PedDevice* dev, PedUnit unit); + extern const char *ped_unit_get_name (PedUnit unit) +- _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_CONST; ++ _GL_ATTRIBUTE_PURE; + extern PedUnit ped_unit_get_by_name (const char* unit_name) _GL_ATTRIBUTE_PURE; + + extern void ped_unit_set_default (PedUnit unit); +-- +2.17.2 + diff --git a/0102-Fix-warnings-from-GCC-7-s-Wimplicit-fallthrough.patch b/0102-Fix-warnings-from-GCC-7-s-Wimplicit-fallthrough.patch new file mode 100644 index 0000000..68a964a --- /dev/null +++ b/0102-Fix-warnings-from-GCC-7-s-Wimplicit-fallthrough.patch @@ -0,0 +1,97 @@ +From 25a19f80a97b4b04d1ada3fdfe45671121886b6d Mon Sep 17 00:00:00 2001 +From: dann frazier <dann.fraz...@canonical.com> +Date: Fri, 31 Aug 2018 09:28:28 -0600 +Subject: [PATCH 102/103] Fix warnings from GCC 7's -Wimplicit-fallthrough + +All of these locations appear to have intentional fallthroughs. Add +comments that GCC will detect to mute warnings w/ -Wimplicit-fallthrough. + +Signed-off-by: Brian C. Lane <b...@redhat.com> +--- + libparted/arch/linux.c | 8 ++++++++ + libparted/labels/rdb.c | 1 + + 2 files changed, 9 insertions(+) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 4c778ea..02d7a52 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -961,6 +961,7 @@ init_ide (PedDevice* dev) + + case PED_EXCEPTION_UNHANDLED: + ped_exception_catch (); ++ /* FALLTHROUGH */ + case PED_EXCEPTION_IGNORE: + dev->model = strdup(_("Generic IDE")); + break; +@@ -998,6 +999,7 @@ init_ide (PedDevice* dev) + + case PED_EXCEPTION_UNHANDLED: + ped_exception_catch (); ++ /* FALLTHROUGH */ + case PED_EXCEPTION_IGNORE: + break; + default: +@@ -1347,6 +1349,7 @@ init_generic (PedDevice* dev, const char* model_name) + + case PED_EXCEPTION_UNHANDLED: + ped_exception_catch (); ++ /* FALLTHROUGH */ + case PED_EXCEPTION_IGNORE: + break; + default: +@@ -1890,6 +1893,7 @@ linux_read (const PedDevice* dev, void* buffer, PedSector start, + + case PED_EXCEPTION_UNHANDLED: + ped_exception_catch (); ++ /* FALLTHROUGH */ + case PED_EXCEPTION_CANCEL: + return 0; + default: +@@ -1933,6 +1937,7 @@ linux_read (const PedDevice* dev, void* buffer, PedSector start, + + case PED_EXCEPTION_UNHANDLED: + ped_exception_catch (); ++ /* FALLTHROUGH */ + case PED_EXCEPTION_CANCEL: + free(diobuf); + return 0; +@@ -2032,6 +2037,7 @@ linux_write (PedDevice* dev, const void* buffer, PedSector start, + + case PED_EXCEPTION_UNHANDLED: + ped_exception_catch (); ++ /* FALLTHROUGH */ + case PED_EXCEPTION_CANCEL: + return 0; + default: +@@ -2075,6 +2081,7 @@ linux_write (PedDevice* dev, const void* buffer, PedSector start, + + case PED_EXCEPTION_UNHANDLED: + ped_exception_catch (); ++ /* FALLTHROUGH */ + case PED_EXCEPTION_CANCEL: + free(diobuf_start); + return 0; +@@ -2146,6 +2153,7 @@ _do_fsync (PedDevice* dev) + + case PED_EXCEPTION_UNHANDLED: + ped_exception_catch (); ++ /* FALLTHROUGH */ + case PED_EXCEPTION_CANCEL: + return 0; + default: +diff --git a/libparted/labels/rdb.c b/libparted/labels/rdb.c +index 34b59aa..48e8d7a 100644 +--- a/libparted/labels/rdb.c ++++ b/libparted/labels/rdb.c +@@ -175,6 +175,7 @@ _amiga_read_block (const PedDevice *dev, struct AmigaBlock *blk, + _amiga_calculate_checksum(AMIGA(blk)); + if (!ped_device_write ((PedDevice*)dev, blk, block, 1)) + return NULL; ++ /* FALLTHROUGH */ + case PED_EXCEPTION_IGNORE : + case PED_EXCEPTION_UNHANDLED : + default : +-- +2.17.2 + diff --git a/0103-Read-NVMe-model-names-from-sysfs.patch b/0103-Read-NVMe-model-names-from-sysfs.patch new file mode 100644 index 0000000..09af6de --- /dev/null +++ b/0103-Read-NVMe-model-names-from-sysfs.patch @@ -0,0 +1,59 @@ +From 279bd5540a59e3bdc4e3702ff062f87fd842c0e9 Mon Sep 17 00:00:00 2001 +From: dann frazier <dann.fraz...@canonical.com> +Date: Fri, 7 Sep 2018 13:31:15 -0600 +Subject: [PATCH 103/103] Read NVMe model names from sysfs + +parted currently shows the same generic model name for all NVMe devices: + + # parted /dev/nvme0n1 -s print | grep Model + Model: NVMe Device (nvme) + +If the model information is available in sysfs, display that instead: + + # parted /dev/nvme0n1 -s print | grep Model + Model: THNSN5512GPU7 NVMe TOSHIBA 512GB (nvme) + +Signed-off-by: Brian C. Lane <b...@redhat.com> +--- + libparted/arch/linux.c | 18 +++++++++++++++++- + 1 file changed, 17 insertions(+), 1 deletion(-) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 02d7a52..7d83dfb 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -1405,6 +1405,22 @@ init_sdmmc (PedDevice* dev) + return init_generic(dev, id); + } + ++static int ++init_nvme (PedDevice* dev) ++{ ++ int ret; ++ char *model = read_device_sysfs_file (dev, "model"); ++ ++ if (!model) ++ ret = init_generic (dev, _("NVMe Device")); ++ else { ++ ret = init_generic (dev, model); ++ free (model); ++ } ++ ++ return ret; ++} ++ + static PedDevice* + linux_new (const char* path) + { +@@ -1489,7 +1505,7 @@ linux_new (const char* path) + break; + + case PED_DEVICE_NVME: +- if (!init_generic (dev, _("NVMe Device"))) ++ if (!init_nvme (dev)) + goto error_free_arch_specific; + break; + +-- +2.17.2 + diff --git a/0104-parted-fix-crash-due-to-improper-partition-number-in.patch b/0104-parted-fix-crash-due-to-improper-partition-number-in.patch new file mode 100644 index 0000000..adcf939 --- /dev/null +++ b/0104-parted-fix-crash-due-to-improper-partition-number-in.patch @@ -0,0 +1,94 @@ +From 149f009c3b4ab6bac8059b48142a1c3f698c8e53 Mon Sep 17 00:00:00 2001 +From: Wang Dong <dongd...@linux.vnet.ibm.com> +Date: Fri, 23 Dec 2016 06:53:36 +0100 +Subject: [PATCH 104/106] parted: fix crash due to improper partition number + input + +When the user makes a new partition, if parted fails to add the +partition to disk, it jumps to wrong error label. In this +situation, this new partition actually is not a node in disk +data structure. But in the wrong error label, it pretends this +is a node and removes it as a list node, leading to other +partition in this disk deleted. This might lead to a memory leak. +Because if there are other partitions, it just removes them from +list without releasing the resource. And this also leads to different +disk information between memory and device. This is confusing. + +But when the new partition is added to disk successfully and if +any operations followed fail, this partition should be removed from +disk and destroyed. + +Signed-off-by: Wang Dong <dongd...@linux.vnet.ibm.com> +Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com> +--- + parted/ui.c | 26 ++++++++++++++++++++++---- + 1 file changed, 22 insertions(+), 4 deletions(-) + +diff --git a/parted/ui.c b/parted/ui.c +index 505b8ac..5d76c20 100644 +--- a/parted/ui.c ++++ b/parted/ui.c +@@ -29,6 +29,8 @@ + #include <unistd.h> + #include <setjmp.h> + #include <assert.h> ++#include <limits.h> ++#include <errno.h> + + #include "command.h" + #include "strlist.h" +@@ -909,16 +911,30 @@ command_line_get_integer (const char* prompt, int* value) + { + char def_str [10]; + char* input; +- int valid; ++ long ret; + + snprintf (def_str, 10, "%d", *value); + input = command_line_get_word (prompt, *value ? def_str : NULL, + NULL, 1); + if (!input) + return 0; +- valid = sscanf (input, "%d", value); ++ ++ errno = 0; ++ ret = strtol (input, (char**) NULL, 10); ++ if (errno) ++ goto error; ++ ++ if ((ret > INT_MAX) || (ret < INT_MIN)) ++ goto error; ++ else ++ *value = (int) ret; ++ + free (input); +- return valid; ++ return 1; ++ ++error: ++ free (input); ++ return 0; + } + + int +@@ -1029,6 +1045,7 @@ command_line_get_partition (const char* prompt, PedDisk* disk, + PedPartition** value) + { + PedPartition* part; ++ int ret; + + /* Flawed logic, doesn't seem to work?! + check = ped_disk_next_partition (disk, part); +@@ -1045,7 +1062,8 @@ command_line_get_partition (const char* prompt, PedDisk* disk, + */ + int num = (*value) ? (*value)->num : 0; + +- if (!command_line_get_integer (prompt, &num)) { ++ ret = command_line_get_integer (prompt, &num); ++ if ((!ret) || (num < 0)) { + ped_exception_throw (PED_EXCEPTION_ERROR, + PED_EXCEPTION_CANCEL, + _("Expecting a partition number.")); +-- +2.20.1 + diff --git a/0105-parted-fix-wrong-error-label-jump-in-mkpart.patch b/0105-parted-fix-wrong-error-label-jump-in-mkpart.patch new file mode 100644 index 0000000..e79bb53 --- /dev/null +++ b/0105-parted-fix-wrong-error-label-jump-in-mkpart.patch @@ -0,0 +1,66 @@ +From af150f6764a08eae4b4cf448c392259c067a1523 Mon Sep 17 00:00:00 2001 +From: Wang Dong <dongd...@linux.vnet.ibm.com> +Date: Fri, 23 Dec 2016 06:53:37 +0100 +Subject: [PATCH 105/106] parted: fix wrong error label jump in mkpart + +When the user makes a new partition, if parted fails to add the +partition to disk, it jumps to wrong error label. In this +situation, this new partition actually is not a node in disk +data structure. But in the wrong error label, it pretends this +is a node and removes it as a list node, leading to other +partition in this disk deleted. This might lead to a memory leak. +Because if there are other partitions, it just removes them from +list without releasing the resource. And this also leads to different +disk information between memory and device. This is confusing. + +But when the new partition is added to disk successfully and if +any operations followed fail, this partition should be removed from +disk and destroyed. + +Signed-off-by: Wang Dong <dongd...@linux.vnet.ibm.com> +Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com> +--- + parted/parted.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/parted/parted.c b/parted/parted.c +index a72a4eb..4bb7911 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -742,7 +742,7 @@ do_mkpart (PedDevice** dev, PedDisk** diskp) + ped_constraint_destroy (constraint_any); + + if (!added_ok) +- goto error_remove_part; ++ goto error_destroy_simple_constraints; + + if (!ped_geometry_test_sector_inside(range_start, part->geom.start) || + !ped_geometry_test_sector_inside(range_end, part->geom.end)) { +@@ -817,12 +817,12 @@ do_mkpart (PedDevice** dev, PedDisk** diskp) + free (part_name); /* avoid double-free upon failure */ + part_name = NULL; + if (!ped_partition_set_system (part, fs_type)) +- goto error; ++ goto error_remove_part; + if (ped_partition_is_flag_available (part, PED_PARTITION_LBA)) + ped_partition_set_flag (part, PED_PARTITION_LBA, 1); + + if (!ped_disk_commit (disk)) +- goto error; ++ goto error_remove_part; + + /* clean up */ + if (range_start != NULL) +@@ -845,7 +845,8 @@ error_remove_part: + error_destroy_simple_constraints: + ped_partition_destroy (part); + error: +- free (part_name); ++ if (part_name) ++ free (part_name); + if (range_start != NULL) + ped_geometry_destroy (range_start); + if (range_end != NULL) +-- +2.20.1 + diff --git a/0106-clean-the-disk-information-when-commands-fail-in-int.patch b/0106-clean-the-disk-information-when-commands-fail-in-int.patch new file mode 100644 index 0000000..e08827f --- /dev/null +++ b/0106-clean-the-disk-information-when-commands-fail-in-int.patch @@ -0,0 +1,86 @@ +From 5a61f15b7003cba73e6517ac22204bafd9a3cb8e Mon Sep 17 00:00:00 2001 +From: Wang Dong <dongd...@linux.vnet.ibm.com> +Date: Fri, 23 Dec 2016 06:53:38 +0100 +Subject: [PATCH 106/106] clean the disk information when commands fail in + interactive mode. + +parted always reads disk information to memory before any +operations. The disk that user operates is actually +a copy of real one in memory. When the information in memory +is changed, it will commit the memory to device to update the +disk information. + +Once the disk information is read, parted will never re-read it +again unless another device is loaded or the device is re-read. +Above work has been done in commit 7eac058 (parted: don't reload +partition table on every command) + +Each command of parted always commits the memory when it succeeds. +Then the disk information on device and in memory are the same. +But when it fails, they might be different. User will be confused +by this, and sometimes get undesired result with the contaminated +memory. This memory should be cleaned if some command fails. +Then the command followed will re-read the disk. + +Signed-off-by: Wang Dong <dongd...@linux.vnet.ibm.com> +Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com> +--- + parted/parted.c | 14 ++++++++++---- + parted/ui.c | 8 +++++++- + 2 files changed, 17 insertions(+), 5 deletions(-) + +diff --git a/parted/parted.c b/parted/parted.c +index 4bb7911..59ad59e 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -1390,8 +1390,12 @@ _rescue_add_partition (PedPartition* part) + default: break; + } + +- ped_partition_set_system (part, fs_type); +- ped_disk_commit (part->disk); ++ if (!ped_partition_set_system (part, fs_type)) ++ return 0; ++ ++ if (!ped_disk_commit (part->disk)) ++ return 0; ++ + return 1; + } + +@@ -1601,8 +1605,10 @@ do_rm (PedDevice** dev, PedDisk** diskp) + if (!_partition_warn_busy (part)) + goto error; + +- ped_disk_delete_partition (*diskp, part); +- ped_disk_commit (*diskp); ++ if (!ped_disk_delete_partition (*diskp, part)) ++ goto error; ++ if (!ped_disk_commit (*diskp)) ++ goto error; + + if ((*dev)->type != PED_DEVICE_FILE) + disk_is_modified = 1; +diff --git a/parted/ui.c b/parted/ui.c +index 5d76c20..af0539c 100644 +--- a/parted/ui.c ++++ b/parted/ui.c +@@ -1612,8 +1612,14 @@ interactive_mode (PedDevice** dev, PedDisk** disk, Command* cmd_list[]) + cmd = command_get (commands, word); + free (word); + if (cmd) { +- if (!command_run (cmd, dev, disk)) ++ if (!command_run (cmd, dev, disk)) { + command_line_flush (); ++ ++ if (*disk) { ++ ped_disk_destroy (*disk); ++ *disk = 0; ++ } ++ } + } else + print_commands_help (); + } +-- +2.20.1 + diff --git a/0107-parted-Remove-PED_ASSERT-from-ped_partition_set_name.patch b/0107-parted-Remove-PED_ASSERT-from-ped_partition_set_name.patch new file mode 100644 index 0000000..3391ec5 --- /dev/null +++ b/0107-parted-Remove-PED_ASSERT-from-ped_partition_set_name.patch @@ -0,0 +1,32 @@ +From 0601c8ea6de92017ee8c6293db102029e309b166 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" <b...@redhat.com> +Date: Thu, 31 Jan 2019 08:59:55 -0800 +Subject: [PATCH] parted: Remove PED_ASSERT from ped_partition_set_name + +Asserts should only check logic, not wrap functions with side-effects. +When compiled with --disable-debug this causes the name field of mkpart +to be ignored. +--- + parted/parted.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/parted/parted.c b/parted/parted.c +index 35432c6..c0600ea 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -814,9 +814,11 @@ do_mkpart (PedDevice** dev, PedDisk** diskp) + + /* set minor attributes */ + if (part_name) +- PED_ASSERT (ped_partition_set_name (part, part_name)); ++ if (!ped_partition_set_name (part, part_name)) ++ goto error_remove_part; + free (part_name); /* avoid double-free upon failure */ + part_name = NULL; ++ + if (!ped_partition_set_system (part, fs_type)) + goto error_remove_part; + if (ped_partition_is_flag_available (part, PED_PARTITION_LBA)) +-- +2.20.1 + diff --git a/0108-Added-support-for-Windows-recovery-partition-WINRE-o.patch b/0108-Added-support-for-Windows-recovery-partition-WINRE-o.patch new file mode 100644 index 0000000..5b8a613 --- /dev/null +++ b/0108-Added-support-for-Windows-recovery-partition-WINRE-o.patch @@ -0,0 +1,167 @@ +From 5a02a03e72dc116d5bcab04b8f2185ee2772b967 Mon Sep 17 00:00:00 2001 +From: Hans-Joachim Baader <baa...@gmx.net> +Date: Mon, 14 Jan 2019 16:01:07 +0100 +Subject: [PATCH] Added support for Windows recovery partition (WINRE) on MBR + +Windows 10 uses a recovery partition which is sometimes marked with +partition type 0x27 on MBR systems. It wasn't possible to handle such +a partition with parted. Therefore the partition type PARTITION_MSFT_RECOVERY +is now used properly also on MBR when the flag msftres is set. + +Signed-off-by: Brian C. Lane <b...@redhat.com> +--- + doc/C/parted.8 | 2 +- + doc/parted.texi | 4 ++-- + libparted/labels/dos.c | 40 ++++++++++++++++++++++++++++++++++++++-- + 3 files changed, 41 insertions(+), 5 deletions(-) + +diff --git a/doc/C/parted.8 b/doc/C/parted.8 +index fecdc29..15932c2 100644 +--- a/doc/C/parted.8 ++++ b/doc/C/parted.8 +@@ -112,7 +112,7 @@ or an LVM logical volume if necessary. + .B set \fIpartition\fP \fIflag\fP \fIstate\fP + Change the state of the \fIflag\fP on \fIpartition\fP to \fIstate\fP. + Supported flags are: "boot", "root", "swap", "hidden", "raid", "lvm", "lba", +-"legacy_boot", "irst", "esp" and "palo". ++"legacy_boot", "irst", "msftres", "esp" and "palo". + \fIstate\fP should be either "on" or "off". + .TP + .B unit \fIunit\fP +diff --git a/doc/parted.texi b/doc/parted.texi +index 6f8c378..e124222 100644 +--- a/doc/parted.texi ++++ b/doc/parted.texi +@@ -861,8 +861,8 @@ flag can only be removed within parted by replacing it with a competing + flag, such as boot or msftres. + + @item msftres +-(GPT) - This flag identifies a "Microsoft Reserved" partition, which is +-used by Windows on GPT disks. Note that this flag should not normally be ++(MS-DOS,GPT) - This flag identifies a "Microsoft Reserved" partition, which ++is used by Windows. Note that this flag should not normally be + set on Windows filesystem partitions (those that contain NTFS or FAT + filesystems). + +diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c +index b2b8de9..d736b9e 100644 +--- a/libparted/labels/dos.c ++++ b/libparted/labels/dos.c +@@ -156,6 +156,7 @@ typedef struct { + unsigned char system; + int boot; + int hidden; ++ int msftres; + int raid; + int lvm; + int lba; +@@ -949,8 +950,8 @@ raw_part_parse (const PedDisk* disk, const DosRawPartition* raw_part, + dos_data->system = raw_part->type; + dos_data->boot = raw_part->boot_ind != 0; + dos_data->diag = raw_part->type == PARTITION_COMPAQ_DIAG || +- raw_part->type == PARTITION_MSFT_RECOVERY || + raw_part->type == PARTITION_DELL_DIAG; ++ dos_data->msftres = raw_part->type == PARTITION_MSFT_RECOVERY; + dos_data->hidden = raw_part_is_hidden (raw_part); + dos_data->raid = raw_part->type == PARTITION_LINUX_RAID; + dos_data->lvm = raw_part->type == PARTITION_LINUX_LVM_OLD +@@ -1345,6 +1346,7 @@ msdos_partition_new (const PedDisk* disk, PedPartitionType part_type, + dos_data->orig = NULL; + dos_data->system = PARTITION_LINUX; + dos_data->hidden = 0; ++ dos_data->msftres = 0; + dos_data->boot = 0; + dos_data->diag = 0; + dos_data->raid = 0; +@@ -1384,6 +1386,7 @@ msdos_partition_duplicate (const PedPartition* part) + new_dos_data->boot = old_dos_data->boot; + new_dos_data->diag = old_dos_data->diag; + new_dos_data->hidden = old_dos_data->hidden; ++ new_dos_data->msftres = old_dos_data->msftres; + new_dos_data->raid = old_dos_data->raid; + new_dos_data->lvm = old_dos_data->lvm; + new_dos_data->lba = old_dos_data->lba; +@@ -1433,6 +1436,11 @@ msdos_partition_set_system (PedPartition* part, + && strcmp (fs_type->name, "ntfs") != 0) + dos_data->hidden = 0; + ++ if (dos_data->msftres ++ && fs_type ++ && strcmp (fs_type->name, "ntfs") != 0) ++ dos_data->msftres = 0; ++ + if (part->type & PED_PARTITION_EXTENDED) { + dos_data->diag = 0; + dos_data->raid = 0; +@@ -1452,11 +1460,14 @@ msdos_partition_set_system (PedPartition* part, + /* Don't change the system if it already is a diag type, + otherwise use Compaq as almost all vendors use that. */ + if (dos_data->system != PARTITION_COMPAQ_DIAG && +- dos_data->system != PARTITION_MSFT_RECOVERY && + dos_data->system != PARTITION_DELL_DIAG) + dos_data->system = PARTITION_COMPAQ_DIAG; + return 1; + } ++ if (dos_data->msftres) { ++ dos_data->system = PARTITION_MSFT_RECOVERY; ++ return 1; ++ } + if (dos_data->lvm) { + dos_data->system = PARTITION_LINUX_LVM; + return 1; +@@ -1516,6 +1527,7 @@ clear_flags (DosPartitionData *dos_data) + { + dos_data->diag = 0; + dos_data->hidden = 0; ++ dos_data->msftres = 0; + dos_data->lvm = 0; + dos_data->palo = 0; + dos_data->prep = 0; +@@ -1552,6 +1564,18 @@ msdos_partition_set_flag (PedPartition* part, + dos_data->hidden = state; + return ped_partition_set_system (part, part->fs_type); + ++ case PED_PARTITION_MSFT_RESERVED: ++ if (part->type == PED_PARTITION_EXTENDED) { ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_CANCEL, ++ _("Extended partitions cannot be recovery partitions on " ++ "msdos disk labels.")); ++ return 0; ++ } ++ dos_data->msftres = state; ++ return ped_partition_set_system (part, part->fs_type); ++ + case PED_PARTITION_BOOT: + dos_data->boot = state; + if (!state) +@@ -1632,6 +1656,12 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag) + else + return dos_data->hidden; + ++ case PED_PARTITION_MSFT_RESERVED: ++ if (part->type == PED_PARTITION_EXTENDED) ++ return 0; ++ else ++ return dos_data->msftres; ++ + case PED_PARTITION_BOOT: + return dos_data->boot; + +@@ -1675,6 +1705,12 @@ msdos_partition_is_flag_available (const PedPartition* part, + else + return 1; + ++ case PED_PARTITION_MSFT_RESERVED: ++ if (part->type == PED_PARTITION_EXTENDED) ++ return 0; ++ else ++ return 1; ++ + case PED_PARTITION_BOOT: + case PED_PARTITION_RAID: + case PED_PARTITION_LVM: +-- +2.20.1 + diff --git a/0109-t6000-dm-Stop-using-private-lvm-root.patch b/0109-t6000-dm-Stop-using-private-lvm-root.patch new file mode 100644 index 0000000..82a8f5a --- /dev/null +++ b/0109-t6000-dm-Stop-using-private-lvm-root.patch @@ -0,0 +1,40 @@ +From 23458a9d41c18f5f28766462b9b86165ad0752d0 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" <b...@redhat.com> +Date: Fri, 11 Jan 2019 12:13:46 -0800 +Subject: [PATCH] t6000-dm: Stop using private lvm root + +On Fedora 30 it has stopped working, and really isn't necessary as long +as our device names are unique. + +Related: rhbz#1653912 +--- + tests/t6000-dm.sh | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/tests/t6000-dm.sh b/tests/t6000-dm.sh +index 5b29660..c260b96 100755 +--- a/tests/t6000-dm.sh ++++ b/tests/t6000-dm.sh +@@ -19,10 +19,6 @@ + . "${srcdir=.}/init.sh"; path_prepend_ ../parted + + require_root_ +-lvm_init_root_dir_ +- +-test "x$ENABLE_DEVICE_MAPPER" = xyes \ +- || skip_ "no device-mapper support" + + # Device maps names - should be random to not conflict with existing ones on + # the system +@@ -71,7 +67,7 @@ for type in linear ; do + + # setup: create a mapping + echo "$dmsetup_cmd" | dmsetup create "$type_kwd" || fail=1 +- dev="$DM_DEV_DIR/mapper/$type_kwd" ++ dev="/dev/mapper/$type_kwd" + + # Create msdos partition table + parted -s $dev mklabel msdos > out 2>&1 || fail=1 +-- +2.20.1 + diff --git a/0110-Avoid-sigsegv-in-case-2nd-nilfs2-superblock-magic-ac.patch b/0110-Avoid-sigsegv-in-case-2nd-nilfs2-superblock-magic-ac.patch new file mode 100644 index 0000000..c1a51ee --- /dev/null +++ b/0110-Avoid-sigsegv-in-case-2nd-nilfs2-superblock-magic-ac.patch @@ -0,0 +1,53 @@ +From b951c46fab0efe29adc43d7fff7ed4201adcde7d Mon Sep 17 00:00:00 2001 +From: Michael Small <sma...@sdf.org> +Date: Fri, 8 Feb 2019 17:01:43 -0500 +Subject: [PATCH 110/111] Avoid sigsegv in case 2nd nilfs2 superblock magic + accidently found. + +1. is_valid_nilfs_sb: make sure the subtraction bytes - sumoff - 4 +won't give a negative number. That as the len argument to +__efi_crc32() would give a very large number for the latter's for +loop limit, since len is unsigned long. + +2. nilfs2_probe: Read and allocate enough sectors to hold a +struct nilfs2_super_block. is_valid_nilfs_sb() will be passing +up to 1024 bytes to __efi_crc32(). If only one 512 byte sector +had been allocated with alloca and read from disk that would cause +reads off the the end of the stack even if bytes were more than +sumoff - 4. +--- + libparted/fs/nilfs2/nilfs2.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/libparted/fs/nilfs2/nilfs2.c b/libparted/fs/nilfs2/nilfs2.c +index b42a464..52f757c 100644 +--- a/libparted/fs/nilfs2/nilfs2.c ++++ b/libparted/fs/nilfs2/nilfs2.c +@@ -89,7 +89,7 @@ is_valid_nilfs_sb(struct nilfs2_super_block *sb) + return 0; + + bytes = PED_LE16_TO_CPU(sb->s_bytes); +- if (bytes > 1024) ++ if (bytes > 1024 || bytes < sumoff - 4) + return 0; + + crc = __efi_crc32(sb, sumoff, PED_LE32_TO_CPU(sb->s_crc_seed)); +@@ -113,11 +113,13 @@ nilfs2_probe (PedGeometry* geom) + const int sectors = (4096 + geom->dev->sector_size - 1) / + geom->dev->sector_size; + char *buf = alloca (sectors * geom->dev->sector_size); +- void *buff2 = alloca (geom->dev->sector_size); ++ const int sectors2 = (1024 + geom->dev->sector_size -1 ) / ++ geom->dev->sector_size; ++ void *buff2 = alloca (sectors2 * geom->dev->sector_size); + + if (ped_geometry_read(geom, buf, 0, sectors)) + sb = (struct nilfs2_super_block *)(buf+1024); +- if (ped_geometry_read(geom, buff2, sb2off, 1)) ++ if (ped_geometry_read(geom, buff2, sb2off, sectors2)) + sb2 = buff2; + + if ((!sb || !is_valid_nilfs_sb(sb)) && +-- +2.20.1 + diff --git a/0111-Tests-case-for-sigsegv-when-false-nilfs2-superblock-.patch b/0111-Tests-case-for-sigsegv-when-false-nilfs2-superblock-.patch new file mode 100644 index 0000000..ab78aef --- /dev/null +++ b/0111-Tests-case-for-sigsegv-when-false-nilfs2-superblock-.patch @@ -0,0 +1,132 @@ +From 4135de60aaad363644a67c6f52b7ea977a16a7b9 Mon Sep 17 00:00:00 2001 +From: Michael Small <sma...@sdf.org> +Date: Wed, 13 Feb 2019 16:05:21 -0500 +Subject: [PATCH 111/111] Tests case for sigsegv when false nilfs2 superblock + detected. + +--- + tests/Makefile.am | 2 ++ + tests/t4301-nilfs2-badsb2.sh | 43 +++++++++++++++++++++++++++++ + tests/t4302-nilfs2-lessbadsb2.sh | 47 ++++++++++++++++++++++++++++++++ + 3 files changed, 92 insertions(+) + create mode 100755 tests/t4301-nilfs2-badsb2.sh + create mode 100755 tests/t4302-nilfs2-lessbadsb2.sh + +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 3fa75a9..0d7c022 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -66,6 +66,8 @@ TESTS = \ + t4100-msdos-starting-sector.sh \ + t4200-partprobe.sh \ + t4300-nilfs2-tiny.sh \ ++ t4301-nilfs2-badsb2.sh \ ++ t4302-nilfs2-lessbadsb2.sh \ + t5000-tags.sh \ + t6000-dm.sh \ + t6001-psep.sh \ +diff --git a/tests/t4301-nilfs2-badsb2.sh b/tests/t4301-nilfs2-badsb2.sh +new file mode 100755 +index 0000000..cef8a9a +--- /dev/null ++++ b/tests/t4301-nilfs2-badsb2.sh +@@ -0,0 +1,43 @@ ++#!/bin/sh ++# Trigger a nilfs2-related bug. ++ ++# Copyright (C) 2011-2014 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see <http://www.gnu.org/licenses/>. ++ ++. "${srcdir=.}/init.sh"; path_prepend_ ../parted ++ss=$sector_size_ ++len=32 ++dev=dev-file ++ ++dd if=/dev/zero of=$dev bs=512 count=$(($len+$ss/512)) || framework_failure_ ++ ++end=$(($len * 512 / $ss)) ++parted -s $dev mklabel msdos mkpart primary 1s ${end}s || framework_failure_ ++ ++# Write a secondary superblock with the nilfs magic number and a nilfs ++# superblock length (s_bytes) field of only 10 bytes. ++# struct nilfs2_super_block starts with these four fields... ++# uint32_t s_rev_level; ++# uint16_t s_minor_rev_level; ++# uint16_t s_magic; ++# uint16_t s_bytes; ++sb2_offset=$(( 24 / ($ss / 512) + 1)) ++perl -e "print pack 'LSSS.', 0, 0, 0x3434, 10, $ss" | ++ dd of=$dev bs=$ss seek=$sb2_offset count=1 conv=notrunc ++ ++# This used to give parted a sigsegv. ++parted -s $dev print || fail=1 ++ ++Exit $fail +diff --git a/tests/t4302-nilfs2-lessbadsb2.sh b/tests/t4302-nilfs2-lessbadsb2.sh +new file mode 100755 +index 0000000..a46dccf +--- /dev/null ++++ b/tests/t4302-nilfs2-lessbadsb2.sh +@@ -0,0 +1,47 @@ ++#!/bin/sh ++# Trigger a nilfs2-related bug. ++ ++# Copyright (C) 2011-2014 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see <http://www.gnu.org/licenses/>. ++ ++# This test is like t4301-nilfsbadsb2 except with an s_bytes field of ++# 1024 instead of 10. This exercises a less obvious bug. ++ ++. "${srcdir=.}/init.sh"; path_prepend_ ../parted ++ss=$sector_size_ ++len=32 ++dev=dev-file ++ ++dd if=/dev/zero of=$dev bs=512 count=$(($len+$ss/512)) || framework_failure_ ++ ++end=$(($len * 512 / $ss)) ++parted -s $dev mklabel msdos mkpart primary 1s ${end}s || framework_failure_ ++ ++# Write a secondary superblock with the nilfs magic number and a nilfs ++# superblock length (s_bytes) field of only 10 bytes. ++# struct nilfs2_super_block starts with these four fields... ++# uint32_t s_rev_level; ++# uint16_t s_minor_rev_level; ++# uint16_t s_magic; ++# uint16_t s_bytes; ++sb2_offset=$(( 24 / ($ss / 512) + 1)) ++perl -e "print pack 'LSSS.', 0, 0, 0x3434, 1024, $ss" | ++ dd of=$dev bs=$ss seek=$sb2_offset count=1 conv=notrunc ++ ++# This used to read past the part of the stack allocated by alloca, but ++# may or may not cause a segmentation fault as a result. ++parted -s $dev print || fail=1 ++ ++Exit $fail +-- +2.20.1 + ================================================================ ---- gitweb: http://git.pld-linux.org/gitweb.cgi/packages/parted.git/commitdiff/74a816df60f30b1f2f8fa0daee211a9ea3f44446 _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit