diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7967dd1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +SOURCES/parted-3.2.tar.xz +SOURCES/pubkey.jim.meyering +SOURCES/pubkey.phillip.susi diff --git a/.parted.metadata b/.parted.metadata new file mode 100644 index 0000000..1e731b7 --- /dev/null +++ b/.parted.metadata @@ -0,0 +1,3 @@ +78db6ca8dd6082c5367c8446bf6f7ae044091959 SOURCES/parted-3.2.tar.xz +4bd7444e752e7cfcb922051483a8a3c0f2c0bcb4 SOURCES/pubkey.jim.meyering +0ef8ad4c6cc02bbacd5c9de79187c116c3efb10a SOURCES/pubkey.phillip.susi diff --git a/SOURCES/0001-tests-Try-several-UTF8-locales.patch b/SOURCES/0001-tests-Try-several-UTF8-locales.patch new file mode 100644 index 0000000..e19cce2 --- /dev/null +++ b/SOURCES/0001-tests-Try-several-UTF8-locales.patch @@ -0,0 +1,45 @@ +From e73c27f435017e22a68383255f15ebaa562dd414 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 13 Aug 2014 13:40:28 -0700 +Subject: [PATCH] tests: Try several UTF8 locales + +Not all distributions (Fedora) have C.UTF-8 so try several (en_US, de_DE, +fr_FR, es_ES). This may still fail if none exist. + +* tests/t0251-gpt-unicode.sh: Test for en_US de_DE fr_FR es_ES +--- + tests/t0251-gpt-unicode.sh | 18 +++++++++++++++++- + 1 file changed, 17 insertions(+), 1 deletion(-) + +diff --git a/tests/t0251-gpt-unicode.sh b/tests/t0251-gpt-unicode.sh +index c845950..537aaa1 100755 +--- a/tests/t0251-gpt-unicode.sh ++++ b/tests/t0251-gpt-unicode.sh +@@ -22,7 +22,23 @@ dev=loop-file + # create zeroed device + truncate -s 10m $dev || fail=1 + +-export LC_ALL=C.UTF-8 ++found_locale=no ++for locale in en_US de_DE fr_FR es_ES ++do ++ LC_ALL="$locale.utf8" ++ ++ # In a UTF-8 locale, the string below prints as 4 characters. ++ if [ `printf 'foo\341\264\244' | wc -m` -eq 4 ]; then ++ found_locale=yes ++ break ++ fi ++done ++ ++if [ "$found_locale" != "yes" ]; then ++ echo "no valid UTF-8 locale found; skipping" >&2 ++ exit 77 ++fi ++ + # create gpt label with named partition + part_name=$(printf 'foo\341\264\244') + parted -s $dev mklabel gpt mkpart primary ext2 1MiB 2MiB name 1 $part_name > empty 2>&1 || fail=1 +-- +1.9.3 + diff --git a/SOURCES/0002-maint-post-release-administrivia.patch b/SOURCES/0002-maint-post-release-administrivia.patch new file mode 100644 index 0000000..8d2a23a --- /dev/null +++ b/SOURCES/0002-maint-post-release-administrivia.patch @@ -0,0 +1,50 @@ +From f1cdf08806caf7d71779a5fe67af797c8e3ab09e Mon Sep 17 00:00:00 2001 +From: Phillip Susi +Date: Mon, 28 Jul 2014 23:19:51 -0400 +Subject: [PATCH 2/6] maint: post-release administrivia + +* NEWS: Add header line for next release. +* .prev-version: Record previous version. +* cfg.mk (old_NEWS_hash): Auto-update. +--- + .prev-version | 2 +- + NEWS | 3 +++ + cfg.mk | 2 +- + 3 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/.prev-version b/.prev-version +index 8c50098..a3ec5a4 100644 +--- a/.prev-version ++++ b/.prev-version +@@ -1 +1 @@ +-3.1 ++3.2 +diff --git a/NEWS b/NEWS +index 49c8129..297b0a5 100644 +--- a/NEWS ++++ b/NEWS +@@ -1,5 +1,8 @@ + GNU parted NEWS -*- outline -*- + ++* Noteworthy changes in release ?.? (????-??-??) [?] ++ ++ + * Noteworthy changes in release 3.2 (2014-07-28) [stable] + + ** New Features +diff --git a/cfg.mk b/cfg.mk +index ade72d7..62a02b6 100644 +--- a/cfg.mk ++++ b/cfg.mk +@@ -43,7 +43,7 @@ local-checks-to-skip = \ + # Now that we have better (check.mk) tests, make this the default. + export VERBOSE = yes + +-old_NEWS_hash = bd453bcf049e292a9677c094d24a29dd ++old_NEWS_hash = 85f2e93c40425e202491675d97e40166 + + include $(srcdir)/dist-check.mk + +-- +1.9.3 + diff --git a/SOURCES/0003-libparted-also-link-to-UUID_LIBS.patch b/SOURCES/0003-libparted-also-link-to-UUID_LIBS.patch new file mode 100644 index 0000000..eb9ab33 --- /dev/null +++ b/SOURCES/0003-libparted-also-link-to-UUID_LIBS.patch @@ -0,0 +1,26 @@ +From 507d8e8d4c60fa6175d327c4f2dac307dc11ccd6 Mon Sep 17 00:00:00 2001 +From: Heiko Becker +Date: Fri, 19 Sep 2014 16:51:34 +0200 +Subject: [PATCH 3/6] libparted: also link to UUID_LIBS + +* libparted/Makefile.am (libparted_la_LIBADD): Add UUID_LIBS. +This fixes building parted with the gold linker. +--- + libparted/Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libparted/Makefile.am b/libparted/Makefile.am +index edc5f2e..cb58648 100644 +--- a/libparted/Makefile.am ++++ b/libparted/Makefile.am +@@ -58,6 +58,7 @@ libparted_la_LIBADD = \ + $(DM_LIBS) \ + $(SELINUX_LIBS) \ + $(LIB_BLKID) \ ++ $(UUID_LIBS) \ + $(INTLLIBS) + + EXTRA_DIST = mbr.s +-- +1.9.3 + diff --git a/SOURCES/0004-lib-fs-resize-Prevent-crash-resizing-FAT16-file-syst.patch b/SOURCES/0004-lib-fs-resize-Prevent-crash-resizing-FAT16-file-syst.patch new file mode 100644 index 0000000..4f56b35 --- /dev/null +++ b/SOURCES/0004-lib-fs-resize-Prevent-crash-resizing-FAT16-file-syst.patch @@ -0,0 +1,69 @@ +From 1e9e770f4bc7f3d80e09ecd1df58575fad064163 Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sun, 28 Sep 2014 16:15:48 +0100 +Subject: [PATCH 4/6] lib-fs-resize: Prevent crash resizing FAT16 file systems + +Resizing FAT16 file system crashes in libparted/fs/r/fat/resize.c +create_resize_context() because it was dereferencing NULL pointer +fs_info->info_sector to copy the info_sector. + +Only FAT32 file systems have info_sector populated by fat_open() -> +fat_info_sector_read(). FAT12 and FAT16 file systems don't have an +info_sector so pointer fs_info->info_sector remains assigned NULL from +fat_alloc(). When resizing a FAT file system create_resize_context() +was always dereferencing fs_info->info_sector to memory copy the +info_sector, hence it crashed for FAT12 and FAT16. + +Make create_resize_context() only copy the info_sector for FAT32 file +systems. + +Reported by Christian Hesse in +https://bugzilla.gnome.org/show_bug.cgi?id=735669 +--- + NEWS | 4 ++++ + libparted/fs/r/fat/resize.c | 12 +++++++++--- + 2 files changed, 13 insertions(+), 3 deletions(-) + +diff --git a/NEWS b/NEWS +index 297b0a5..da7db50 100644 +--- a/NEWS ++++ b/NEWS +@@ -2,6 +2,10 @@ GNU parted NEWS -*- outline -*- + + * Noteworthy changes in release ?.? (????-??-??) [?] + ++** Bug Fixes ++ ++ libparted-fs-resize: Prevent crash resizing FAT16 file systems. ++ + + * Noteworthy changes in release 3.2 (2014-07-28) [stable] + +diff --git a/libparted/fs/r/fat/resize.c b/libparted/fs/r/fat/resize.c +index 919acf0..bfe60a0 100644 +--- a/libparted/fs/r/fat/resize.c ++++ b/libparted/fs/r/fat/resize.c +@@ -668,11 +668,17 @@ create_resize_context (PedFileSystem* fs, const PedGeometry* new_geom) + + /* preserve boot code, etc. */ + new_fs_info->boot_sector = ped_malloc (new_geom->dev->sector_size); +- new_fs_info->info_sector = ped_malloc (new_geom->dev->sector_size); + memcpy (new_fs_info->boot_sector, fs_info->boot_sector, + new_geom->dev->sector_size); +- memcpy (new_fs_info->info_sector, fs_info->info_sector, +- new_geom->dev->sector_size); ++ new_fs_info->info_sector = NULL; ++ if (fs_info->fat_type == FAT_TYPE_FAT32) ++ { ++ PED_ASSERT (fs_info->info_sector != NULL); ++ new_fs_info->info_sector = ++ ped_malloc (new_geom->dev->sector_size); ++ memcpy (new_fs_info->info_sector, fs_info->info_sector, ++ new_geom->dev->sector_size); ++ } + + new_fs_info->logical_sector_size = fs_info->logical_sector_size; + new_fs_info->sector_count = new_geom->length; +-- +1.9.3 + diff --git a/SOURCES/0005-tests-t3000-resize-fs.sh-Add-FAT16-resizing-test.patch b/SOURCES/0005-tests-t3000-resize-fs.sh-Add-FAT16-resizing-test.patch new file mode 100644 index 0000000..fccf55f --- /dev/null +++ b/SOURCES/0005-tests-t3000-resize-fs.sh-Add-FAT16-resizing-test.patch @@ -0,0 +1,54 @@ +From d704c4919e7e95c3a2e28f48bb8eeacaf17a7cc8 Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sun, 28 Sep 2014 16:15:49 +0100 +Subject: [PATCH 5/6] tests: t3000-resize-fs.sh: Add FAT16 resizing test + +Add FAT16 resizing test so that we don't regress again. +--- + tests/t3000-resize-fs.sh | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh +index 8cab476..9084eb4 100755 +--- a/tests/t3000-resize-fs.sh ++++ b/tests/t3000-resize-fs.sh +@@ -46,7 +46,7 @@ device_sectors_required=$(echo $default_end | sed 's/s$//') + # Ensure that $dev is large enough for this test + test $device_sectors_required -le $dev_n_sectors || fail=1 + +-for fs_type in hfs+ fat32; do ++for fs_type in hfs+ fat32 fat16; do + + # create an empty $fs_type partition, cylinder aligned, size > 256 MB + parted -a min -s $dev mkpart p1 $start $default_end > out 2>&1 || fail=1 +@@ -59,6 +59,7 @@ for fs_type in hfs+ fat32; do + wait_for_dev_to_appear_ ${dev}1 + + case $fs_type in ++ fat16) mkfs_cmd='mkfs.vfat -F 16'; fsck='fsck.vfat -v';; + fat32) mkfs_cmd='mkfs.vfat -F 32'; fsck='fsck.vfat -v';; + hfs*) mkfs_cmd='mkfs.hfs'; fsck=fsck.hfs;; + *) error "internal error: unhandled fs type: $fs_type";; +@@ -70,8 +71,17 @@ for fs_type in hfs+ fat32; do + # NOTE: shrinking is the only type of resizing that works. + # resize that file system to be one cylinder (8MiB) smaller + fs-resize ${dev}1 0 $new_end > out 2>&1 || fail=1 +- # expect no output +- compare /dev/null out || fail=1 ++ ++ # check for expected output ++ case $fs_type in ++ fat16) cat << EOF > exp || framework_failure ++Information: Would you like to use FAT32? If you leave your file system as FAT16, then you will have no problems. If you convert to FAT32, and MS Windows is installed on this partition, then you must re-install the MS Windows boot loader. If you want to do this, you should consult the Parted manual (or your distribution's manual). Also, converting to FAT32 will make the file system unreadable by MS DOS, MS Windows 95a, and MS Windows NT. ++EOF ++ ;; ++ fat32) cat /dev/null > exp || framework_failure;; # expect no output ++ hfs*) cat /dev/null > exp || framework_failure;; # expect no output ++ esac ++ compare exp out || fail=1 + + # This is known to segfault with fsck.hfs from + # Fedora 16's hfsplus-tools-332.14-12.fc15.x86_64. +-- +1.9.3 + diff --git a/SOURCES/0006-tests-t3000-resize-fs.sh-Add-requirement-on-mkfs.vfa.patch b/SOURCES/0006-tests-t3000-resize-fs.sh-Add-requirement-on-mkfs.vfa.patch new file mode 100644 index 0000000..f803fbe --- /dev/null +++ b/SOURCES/0006-tests-t3000-resize-fs.sh-Add-requirement-on-mkfs.vfa.patch @@ -0,0 +1,68 @@ +From ac74b830ce518c2228b8ae3fba3f1ece82b49f81 Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sun, 28 Sep 2014 16:15:50 +0100 +Subject: [PATCH 6/6] tests: t3000-resize-fs.sh: Add requirement on mkfs.vfat + +Add test skipping requirement on mkfs.vfat for the FAT32 and FAT16 file +system resizing tests. This matches existing test skipping requirement +on mkfs.hfs for the hfs+ file system. + +* tests/t3000-resize-fs.sh: Also correct skip_test_ to skip_. +* tests/t-lib-helpers.sh: Also update message for requirement of hfs. +--- + tests/t-lib-helpers.sh | 8 +++++++- + tests/t3000-resize-fs.sh | 5 +++-- + 2 files changed, 10 insertions(+), 3 deletions(-) + +diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh +index 4e83a05..c8684bb 100644 +--- a/tests/t-lib-helpers.sh ++++ b/tests/t-lib-helpers.sh +@@ -20,7 +20,13 @@ require_acl_() + require_hfs_() + { + mkfs.hfs 2>&1 | grep '^usage:' \ +- || skip_ "This test requires HFS support." ++ || skip_ "mkfs.hfs: command not found" ++} ++ ++require_fat_() ++{ ++ mkfs.vfat 2>&1 | grep '^Usage:' \ ++ || skip_ "mkfs.vfat: command not found" + } + + # Skip this test if we're not in SELinux "enforcing" mode. +diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh +index 9084eb4..a79a307 100755 +--- a/tests/t3000-resize-fs.sh ++++ b/tests/t3000-resize-fs.sh +@@ -18,7 +18,7 @@ + + . "${srcdir=.}/init.sh"; path_prepend_ ../parted . + require_hfs_ +- ++require_fat_ + require_root_ + require_scsi_debug_module_ + require_512_byte_sector_size_ +@@ -31,7 +31,7 @@ default_end=546147s + + # create memory-backed device + scsi_debug_setup_ dev_size_mb=550 > dev-name || +- skip_test_ 'failed to create scsi_debug device' ++ skip_ 'failed to create scsi_debug device' + dev=$(cat dev-name) + + fail=0 +@@ -47,6 +47,7 @@ device_sectors_required=$(echo $default_end | sed 's/s$//') + test $device_sectors_required -le $dev_n_sectors || fail=1 + + for fs_type in hfs+ fat32 fat16; do ++ echo "fs_type=$fs_type" + + # create an empty $fs_type partition, cylinder aligned, size > 256 MB + parted -a min -s $dev mkpart p1 $start $default_end > out 2>&1 || fail=1 +-- +1.9.3 + diff --git a/SOURCES/0007-tests-Change-minimum-size-to-256MiB.patch b/SOURCES/0007-tests-Change-minimum-size-to-256MiB.patch new file mode 100644 index 0000000..a5be3fa --- /dev/null +++ b/SOURCES/0007-tests-Change-minimum-size-to-256MiB.patch @@ -0,0 +1,27 @@ +From 17630fc4d523d9c03af87a6e735599e88a032e2a Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 7 Nov 2014 11:15:55 -0800 +Subject: [PATCH] tests: Change minimum size to 256MiB + +btrfs on ppc64 wants 136MiB so expand the minimum temp filesystem size +for the t1700-probe-fs test. +--- + tests/t1700-probe-fs.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh +index 574d6fe..94ed9ae 100755 +--- a/tests/t1700-probe-fs.sh ++++ b/tests/t1700-probe-fs.sh +@@ -21,7 +21,7 @@ require_512_byte_sector_size_ + + dev=loop-file + ss=$sector_size_ +-n_sectors=$((257*1024)) ++n_sectors=$((512*1024)) + + for type in ext2 ext3 ext4 btrfs xfs nilfs2 ntfs vfat hfsplus; do + +-- +1.9.3 + diff --git a/SOURCES/0008-parted-don-t-crash-in-disk_set-when-disk-label-not-f.patch b/SOURCES/0008-parted-don-t-crash-in-disk_set-when-disk-label-not-f.patch new file mode 100644 index 0000000..c6aae75 --- /dev/null +++ b/SOURCES/0008-parted-don-t-crash-in-disk_set-when-disk-label-not-f.patch @@ -0,0 +1,43 @@ +From 624a8b14af7d358782ecc12627c84da72c28aeff Mon Sep 17 00:00:00 2001 +From: Phillip Susi +Date: Tue, 13 Jan 2015 11:05:48 -0500 +Subject: [PATCH 08/11] parted: don't crash in disk_set when disk label not + found + +Due to a typeo in commit 7eac058 "parted: don't reload partition +table on every command", the disk_set command would crash if +a disk label was not found. +--- + NEWS | 2 ++ + parted/parted.c | 2 +- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/NEWS b/NEWS +index da7db50..10c9a6e 100644 +--- a/NEWS ++++ b/NEWS +@@ -4,6 +4,8 @@ GNU parted NEWS -*- outline -*- + + ** Bug Fixes + ++ Don't crash in the disk_set command when a disk label is not found ++ + libparted-fs-resize: Prevent crash resizing FAT16 file systems. + + +diff --git a/parted/parted.c b/parted/parted.c +index f27a035..2678554 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -1684,7 +1684,7 @@ do_disk_set (PedDevice** dev, PedDisk** diskp) + + if (!*diskp) + *diskp = ped_disk_new (*dev); +- if (!diskp) ++ if (!*diskp) + goto error; + + if (!command_line_get_disk_flag (_("Flag to Invert?"), *diskp, &flag)) +-- +2.1.0 + diff --git a/SOURCES/0009-tests-Add-a-test-for-device-mapper-partition-sizes.patch b/SOURCES/0009-tests-Add-a-test-for-device-mapper-partition-sizes.patch new file mode 100644 index 0000000..894ffa1 --- /dev/null +++ b/SOURCES/0009-tests-Add-a-test-for-device-mapper-partition-sizes.patch @@ -0,0 +1,103 @@ +From 8ab27474806687a2af7efb008b80b33615e6eb1d Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 4 Feb 2015 16:31:00 -0800 +Subject: [PATCH 09/11] tests: Add a test for device-mapper partition sizes + +device-mapper uses 512b sector units, not device specific sector sizes. +This test ensures that the correct partition size is created, no matter +what the device's sector size is. +--- + tests/Makefile.am | 1 + + tests/t6006-dm-512b-sectors.sh | 68 ++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 69 insertions(+) + create mode 100644 tests/t6006-dm-512b-sectors.sh + +diff --git a/tests/Makefile.am b/tests/Makefile.am +index b726366..ce8391d 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -69,6 +69,7 @@ TESTS = \ + t6003-dm-hide.sh \ + t6004-dm-many-partitions.sh \ + t6005-dm-uuid.sh \ ++ t6006-dm-512b-sectors.sh \ + t6100-mdraid-partitions.sh \ + t7000-scripting.sh \ + t8000-loop.sh \ +diff --git a/tests/t6006-dm-512b-sectors.sh b/tests/t6006-dm-512b-sectors.sh +new file mode 100644 +index 0000000..31abba9 +--- /dev/null ++++ b/tests/t6006-dm-512b-sectors.sh +@@ -0,0 +1,68 @@ ++#!/bin/sh ++# device-mapper sector sizes are 512b, make sure partitions are the correct ++# size when using larger sector sizes and a linear dm table. ++ ++# Copyright (C) 2015 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 . ++ ++. "${srcdir=.}/init.sh"; path_prepend_ ../parted ++ ++require_root_ ++require_scsi_debug_module_ ++ ++grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null || ++ skip_ 'this system lacks a new-enough libblkid' ++ ++(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed" ++ ++# Device maps names - should be random to not conflict with existing ones on ++# the system ++linear_=plinear-$$test ++ ++cleanup_fn_() { ++ i=0 ++ udevadm settle ++ while [ $i -lt 10 ] ; do ++ [ -e "/dev/mapper/${linear_}1" ] && dmsetup remove ${linear_}1 ++ sleep .2 ++ [ -e "/dev/mapper/$linear_" ] && dmsetup remove $linear_ ++ sleep .2 ++ [ -e "/dev/mapper/${linear_}1" -o -e "/dev/mapper/$linear_" ] || i=10 ++ i=$((i + 1)) ++ done ++ udevadm settle ++} ++ ++# Create a 500M device ++ss=$sector_size_ ++scsi_debug_setup_ sector_size=$ss dev_size_mb=500 > dev-name || ++ skip_ 'failed to create scsi_debug device' ++scsi_dev=$(cat dev-name) ++ ++# Size of device, in 512b units ++scsi_dev_size=$(blockdev --getsz $scsi_dev) || framework_failure ++ ++dmsetup create $linear_ --table "0 $scsi_dev_size linear $scsi_dev 0" || framework_failure ++dev="/dev/mapper/$linear_" ++ ++# Create msdos partition table with a partition from 1MiB to 100MiB ++parted -s $dev mklabel msdos mkpart primary ext2 1MiB 101MiB > out 2>&1 || fail=1 ++compare /dev/null out || fail=1 ++ ++# The size of the partition should be 100MiB, or 204800 512b sectors ++p1_size=$(blockdev --getsz ${dev}1) || framework_failure ++[ $p1_size == 204800 ] || fail=1 ++ ++Exit $fail +-- +2.1.0 + diff --git a/SOURCES/0010-libparted-device-mapper-uses-512b-sectors.patch b/SOURCES/0010-libparted-device-mapper-uses-512b-sectors.patch new file mode 100644 index 0000000..3f91c28 --- /dev/null +++ b/SOURCES/0010-libparted-device-mapper-uses-512b-sectors.patch @@ -0,0 +1,93 @@ +From f98f791e19669b900345dad7d96ea4df974e4596 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 4 Feb 2015 16:46:07 -0800 +Subject: [PATCH 10/11] libparted: device mapper uses 512b sectors + +device mapper doesn't use the device's sector size when creating a +table. It always uses 512b units. This causes partitions to be created +8x smaller than expected on devices with 4906b sectors. +--- + NEWS | 4 ++++ + libparted/arch/linux.c | 21 +++++++++++++++++---- + 2 files changed, 21 insertions(+), 4 deletions(-) + +diff --git a/NEWS b/NEWS +index 10c9a6e..96135ed 100644 +--- a/NEWS ++++ b/NEWS +@@ -4,6 +4,10 @@ GNU parted NEWS -*- outline -*- + + ** Bug Fixes + ++ Use 512b sector size when communicating with device-mapper. Fixes ++ problems with partitions being created too small on dm devices ++ with sector sizes > 5121b ++ + Don't crash in the disk_set command when a disk label is not found + + libparted-fs-resize: Prevent crash resizing FAT16 file systems. +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 0f18904..90ab21d 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -2763,6 +2763,12 @@ _dm_get_partition_start_and_length(PedPartition const *part, + if (sscanf (params, "%d:%d %Ld", &major, &minor, start) != 3) + goto err; + rc = 1; ++ ++ /* device-mapper uses 512b units, make sure we return length and start in terms of the device's ++ * sector size. ++ */ ++ *start /= (part->disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT); ++ *length /= (part->disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT); + err: + free (path); + dm_task_destroy(task); +@@ -2810,8 +2816,10 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part) + /* Caution: dm_task_destroy frees dev_name. */ + dm_task_destroy (task); + task = NULL; ++ /* device-mapper uses 512b units, not the device's sector size */ + if ( ! (params = zasprintf ("%d:%d %lld", arch_specific->major, +- arch_specific->minor, part->geom.start))) ++ arch_specific->minor, ++ part->geom.start * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT)))) + goto err; + + task = dm_task_create (DM_DEVICE_CREATE); +@@ -2821,7 +2829,8 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part) + dm_task_set_name (task, vol_name); + if (vol_uuid) + dm_task_set_uuid (task, vol_uuid); +- dm_task_add_target (task, 0, part->geom.length, ++ /* device-mapper uses 512b units, not the device's sector size */ ++ dm_task_add_target (task, 0, part->geom.length * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT), + "linear", params); + if (!dm_task_set_cookie (task, &cookie, 0)) + goto err; +@@ -2878,8 +2887,11 @@ _dm_resize_partition (PedDisk* disk, const PedPartition* part) + /* Caution: dm_task_destroy frees dev_name. */ + dm_task_destroy (task); + task = NULL; ++ ++ /* device-mapper uses 512b units, not the device's sector size */ + if ( ! (params = zasprintf ("%d:%d %lld", arch_specific->major, +- arch_specific->minor, part->geom.start))) ++ arch_specific->minor, ++ part->geom.start * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT)))) + goto err; + + task = dm_task_create (DM_DEVICE_RELOAD); +@@ -2887,7 +2899,8 @@ _dm_resize_partition (PedDisk* disk, const PedPartition* part) + goto err; + + dm_task_set_name (task, vol_name); +- dm_task_add_target (task, 0, part->geom.length, ++ /* device-mapper uses 512b units, not the device's sector size */ ++ dm_task_add_target (task, 0, part->geom.length * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT), + "linear", params); + if (!dm_task_set_cookie (task, &cookie, 0)) + goto err; +-- +2.1.0 + diff --git a/SOURCES/0011-Update-manpage-NAME-so-whatis-will-work.patch b/SOURCES/0011-Update-manpage-NAME-so-whatis-will-work.patch new file mode 100644 index 0000000..a4130bc --- /dev/null +++ b/SOURCES/0011-Update-manpage-NAME-so-whatis-will-work.patch @@ -0,0 +1,24 @@ +From 098bf9ca4c1ea7955ad683694c64f0201760de60 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 1 Aug 2014 14:48:13 -0700 +Subject: [PATCH 11/11] Update manpage NAME so whatis will work + +--- + doc/C/parted.8 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/doc/C/parted.8 b/doc/C/parted.8 +index 689011c..5304375 100644 +--- a/doc/C/parted.8 ++++ b/doc/C/parted.8 +@@ -1,6 +1,6 @@ + .TH PARTED 8 "2007 March 29" parted "GNU Parted Manual" + .SH NAME +-GNU Parted \- a partition manipulation program ++parted \- a partition manipulation program + .SH SYNOPSIS + .B parted + [options] [device [command [options...]...]] +-- +2.1.0 + diff --git a/SOURCES/0012-tests-Make-sure-the-extended-partition-length-is-cor.patch b/SOURCES/0012-tests-Make-sure-the-extended-partition-length-is-cor.patch new file mode 100644 index 0000000..39b105a --- /dev/null +++ b/SOURCES/0012-tests-Make-sure-the-extended-partition-length-is-cor.patch @@ -0,0 +1,86 @@ +From 822439e4eaa4bb758d9058022154973cd690eca7 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 5 Jun 2015 13:46:29 -0700 +Subject: [PATCH] tests: Make sure the extended partition length is correct + (#1135493) + +parted tells the kernel the wrong length when reporting a resize of an +extended partition. Make sure the length is 2 for 512b sectors and 1 +sector for larger. + +(cherry picked from commit 31b5bfa4cd0b2e2944af22466e7b7d88ad94c4c9) +--- + tests/Makefile.am | 1 + + tests/t2320-dos-extended-noclobber.sh | 48 +++++++++++++++++++++++++++++++++++ + 2 files changed, 49 insertions(+) + create mode 100644 tests/t2320-dos-extended-noclobber.sh + +diff --git a/tests/Makefile.am b/tests/Makefile.am +index ce8391d..001b9de 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -47,6 +47,7 @@ TESTS = \ + t2201-pc98-label-recog.sh \ + t2300-dos-label-extended-bootcode.sh \ + t2310-dos-extended-2-sector-min-offset.sh \ ++ t2320-dos-extended-noclobber.sh \ + t2400-dos-hfs-partition-type.sh \ + t2500-probe-corrupt-hfs.sh \ + t3000-resize-fs.sh \ +diff --git a/tests/t2320-dos-extended-noclobber.sh b/tests/t2320-dos-extended-noclobber.sh +new file mode 100644 +index 0000000..6f3dfff +--- /dev/null ++++ b/tests/t2320-dos-extended-noclobber.sh +@@ -0,0 +1,48 @@ ++#!/bin/sh ++# Ensure that the extended partition reports the correct length ++# after adding another partition. ++ ++# Copyright (C) 2015 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 . ++ ++. "${srcdir=.}/init.sh"; path_prepend_ ../parted ++ ++require_root_ ++require_scsi_debug_module_ ++ ++# create memory-backed device ++ss=$sector_size_ ++scsi_debug_setup_ sector_size=$ss dev_size_mb=10 > dev-name || ++ skip_ 'failed to create scsi_debug device' ++scsi_dev=$(cat dev-name) ++ ++# Create a DOS label with an extended partition and a primary partition ++parted -s $scsi_dev mklabel msdos || fail=1 ++parted -s $scsi_dev mkpart extended 1 5 > out 2>&1 || fail=1 ++parted -s $scsi_dev mkpart primary 5 10 > out 2>&1 || fail=1 ++ ++# Make sure the size of the extended partition is correct. ++# 2 sectors for 512b and 1 sector for larger. /sys/.../size is in ++# 512b blocks so convert accordingly. ++dev=${scsi_dev#/dev/} ++ext_len=$(cat /sys/block/$dev/${dev}1/size) ++if [ $ss -eq 512 ]; then ++ expected_len=2 ++else ++ expected_len=$((ss / 512)) ++fi ++[ $ext_len -eq $expected_len ] || fail=1 ++ ++Exit $fail +-- +2.4.3 + diff --git a/SOURCES/0013-libparted-BLKPG_RESIZE_PARTITION-uses-bytes-not-sect.patch b/SOURCES/0013-libparted-BLKPG_RESIZE_PARTITION-uses-bytes-not-sect.patch new file mode 100644 index 0000000..4a1b90f --- /dev/null +++ b/SOURCES/0013-libparted-BLKPG_RESIZE_PARTITION-uses-bytes-not-sect.patch @@ -0,0 +1,33 @@ +From 1174a9cca1610611ad5d8cf9f3611e9d4c984fb0 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 5 Jun 2015 14:40:00 -0700 +Subject: [PATCH 13/13] libparted: BLKPG_RESIZE_PARTITION uses bytes, not + sectors (#1135493) + +This results in the extended partition vanishing after adding another +partition. + +Resolves: rhbz#1135493 +--- + libparted/arch/linux.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 90ab21d..e73fe1c 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -2547,7 +2547,10 @@ static int _blkpg_resize_partition (PedDisk* disk, const PedPartition *part) + if (walk->geom.start == part->geom.start+1) + linux_part.length = 1; + } +- } else linux_part.length = 1; ++ } else { ++ linux_part.length = 1; ++ } ++ linux_part.length *= disk->dev->sector_size; + } + else + linux_part.length = part->geom.length * disk->dev->sector_size; +-- +2.4.0 + diff --git a/SOURCES/0014-parted-Fix-crash-with-name-command-and-no-disklabel-.patch b/SOURCES/0014-parted-Fix-crash-with-name-command-and-no-disklabel-.patch new file mode 100644 index 0000000..7cb8c0b --- /dev/null +++ b/SOURCES/0014-parted-Fix-crash-with-name-command-and-no-disklabel-.patch @@ -0,0 +1,29 @@ +From f5c628dd51c7d77ff939554425159ab6e8aef1c0 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 13 Jul 2015 16:43:11 -0700 +Subject: [PATCH] parted: Fix crash with name command and no disklabel + (#1226067) + +A typo (the last I think) from commit 7eac058 wasn't properly checking +the result of ped_disk_new so it could crash if there was no disklabel +on the device. +--- + parted/parted.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/parted/parted.c b/parted/parted.c +index 2678554..a9426c4 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -860,7 +860,7 @@ do_name (PedDevice** dev, PedDisk** diskp) + + if (!*diskp) + *diskp = ped_disk_new (*dev); +- if (!diskp) ++ if (!*diskp) + goto error; + + if (!command_line_get_partition (_("Partition number?"), *diskp, &part)) +-- +2.4.3 + diff --git a/SOURCES/0015-UI-Avoid-memory-leaks.patch b/SOURCES/0015-UI-Avoid-memory-leaks.patch new file mode 100644 index 0000000..91dfda8 --- /dev/null +++ b/SOURCES/0015-UI-Avoid-memory-leaks.patch @@ -0,0 +1,44 @@ +From 059c9548534bef5b0312ac7089eb60e8596469be Mon Sep 17 00:00:00 2001 +From: Amarnath Valluri +Date: Fri, 31 Jul 2015 12:12:44 +0300 +Subject: [PATCH 15/18] UI: Avoid memory leaks. + +* parted/ui.c(command_line_get_sector): Don't leak input string. +* parted/ui.c(command_line_prompt_words): Don't leak _def string in + opt script mode. + +Signed-off-by: Amarnath Valluri +Signed-off-by: Brian C. Lane +(cherry picked from commit 50dc0862a94a3e6e77d4cfb2af21de117fbb4819) +--- + parted/ui.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/parted/ui.c b/parted/ui.c +index 7365e7d..505b8ac 100644 +--- a/parted/ui.c ++++ b/parted/ui.c +@@ -829,8 +829,11 @@ command_line_prompt_words (const char* prompt, const char* def, + } + + if (opt_script_mode) { +- if (_def) ++ if (_def) { + command_line_push_line (_def, 0); ++ if (_def_needs_free) ++ free (_def); ++ } + return; + } + +@@ -938,6 +941,7 @@ command_line_get_sector (const char* prompt, PedDevice* dev, PedSector* value, + if (range) { + *range = ped_geometry_new (dev, *value, 1); + free (def_str); ++ free (input); + return *range != NULL; + } + +-- +2.4.3 + diff --git a/SOURCES/0016-libparted-Fix-memory-leaks.patch b/SOURCES/0016-libparted-Fix-memory-leaks.patch new file mode 100644 index 0000000..23cc36a --- /dev/null +++ b/SOURCES/0016-libparted-Fix-memory-leaks.patch @@ -0,0 +1,61 @@ +From bb1014e4e66c6a113f208d2ede8e484f7b702a9d Mon Sep 17 00:00:00 2001 +From: Amarnath Valluri +Date: Mon, 3 Aug 2015 11:46:33 +0300 +Subject: [PATCH 16/18] libparted: Fix memory leaks + +* libparted/fs/r/hfs/hfs.c(hfsplus_resize): Don't leak embedded_geom + when volume resizing failed. +* libparted/fs/fat/fat.c(fat_create): Don't leake fs in-case of + fat_write_clustor failuer. +* libparted/arch/linux.c(_kernel_get_partition_start_and_length): Don't leak + dev_fd file descriptor. + +Signed-off-by: Amarnath Valluri +Signed-off-by: Brian C. Lane +(cherry picked from commit b70ecd7a7ef1f69b0afd5c239681decbf369f5d9) +--- + libparted/arch/linux.c | 1 + + libparted/fs/r/fat/fat.c | 2 +- + libparted/fs/r/hfs/hfs.c | 1 + + 3 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 1d4cf17..d33c02d 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -2655,6 +2655,7 @@ _kernel_get_partition_start_and_length(PedPartition const *part, + int dev_fd = open (dev_name, O_RDONLY); + if (dev_fd != -1 && ioctl (dev_fd, HDIO_GETGEO, &geom)) { + *start = geom.start; ++ close (dev_fd); + ok = true; + } else { + if (dev_fd != -1) +diff --git a/libparted/fs/r/fat/fat.c b/libparted/fs/r/fat/fat.c +index 5aa72d8..4ecf5c5 100644 +--- a/libparted/fs/r/fat/fat.c ++++ b/libparted/fs/r/fat/fat.c +@@ -305,7 +305,7 @@ fat_create (PedGeometry* geom, FatType fat_type, PedTimer* timer) + memset (fs_info->buffer, 0, fs_info->cluster_size); + if (!fat_write_cluster (fs, fs_info->buffer, + fs_info->root_cluster)) +- return 0; ++ goto error_free_buffers; + } + + fs_info->serial_number = generate_random_uint32 (); +diff --git a/libparted/fs/r/hfs/hfs.c b/libparted/fs/r/hfs/hfs.c +index a1c37cc..7109a45 100644 +--- a/libparted/fs/r/hfs/hfs.c ++++ b/libparted/fs/r/hfs/hfs.c +@@ -985,6 +985,7 @@ hfsplus_resize (PedFileSystem* fs, PedGeometry* geom, PedTimer* timer) + /* Resize the HFS+ volume */ + if (!hfsplus_volume_resize (fs, embedded_geom, timer_plus)) { + if (timer_plus != timer) ped_timer_destroy_nested (timer_plus); ++ if (priv_data->wrapper) ped_geometry_destroy (embedded_geom); + ped_exception_throw ( + PED_EXCEPTION_ERROR, + PED_EXCEPTION_CANCEL, +-- +2.4.3 + diff --git a/SOURCES/0017-libparted-Fix-possible-memory-leaks.patch b/SOURCES/0017-libparted-Fix-possible-memory-leaks.patch new file mode 100644 index 0000000..525dbd2 --- /dev/null +++ b/SOURCES/0017-libparted-Fix-possible-memory-leaks.patch @@ -0,0 +1,62 @@ +From c01a30a6821b243cb0f497b73bb5a7b7465b6aca Mon Sep 17 00:00:00 2001 +From: Amarnath Valluri +Date: Tue, 4 Aug 2015 13:04:45 +0300 +Subject: [PATCH 17/18] libparted: Fix possible memory leaks + +* libparted/fs/r/fat/resize.c(fat_convert_directory): Possible leak + of sub_old_dir_trav or sub_new_dir_trav in error case. +* libparted/fs/r/fat/resize.c(fat_construct_converted_tree ): Possible + leak of new_trav_info or old_trav_info in error case. + +Signed-off-by: Amarnath Valluri +Signed-off-by: Brian C. Lane +(cherry picked from commit 4886bad13dd011ff56e1c46ff29e8067778c16fd) +--- + libparted/fs/r/fat/resize.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/libparted/fs/r/fat/resize.c b/libparted/fs/r/fat/resize.c +index 919acf0..b512576 100644 +--- a/libparted/fs/r/fat/resize.c ++++ b/libparted/fs/r/fat/resize.c +@@ -177,10 +177,13 @@ fat_convert_directory (FatOpContext* ctx, FatTraverseInfo* old_trav, + && old_dir_entry->name [0] != '.') { + sub_old_dir_trav + = fat_traverse_directory (old_trav, old_dir_entry); ++ if (!sub_old_dir_trav) return 0; + sub_new_dir_trav + = fat_traverse_directory (new_trav, new_dir_entry); +- if (!sub_old_dir_trav || !sub_new_dir_trav) ++ if (!sub_new_dir_trav) { ++ fat_traverse_complete (sub_old_dir_trav); + return 0; ++ } + + if (!fat_convert_directory (ctx, sub_old_dir_trav, + sub_new_dir_trav)) +@@ -315,17 +318,21 @@ fat_construct_converted_tree (FatOpContext* ctx) + if (new_fs_info->fat_type == FAT_TYPE_FAT32) { + new_trav_info = fat_traverse_begin (ctx->new_fs, + new_fs_info->root_cluster, "\\"); ++ if (!new_trav_info) return 0; + old_trav_info = fat_traverse_begin (ctx->old_fs, FAT_ROOT, + "\\"); + } else { + fat_clear_root_dir (ctx->new_fs); + new_trav_info = fat_traverse_begin (ctx->new_fs, FAT_ROOT, + "\\"); ++ if (!new_trav_info) return 0; + old_trav_info = fat_traverse_begin (ctx->old_fs, + old_fs_info->root_cluster, "\\"); + } +- if (!new_trav_info || !old_trav_info) ++ if (!old_trav_info) { ++ fat_traverse_complete (new_trav_info); + return 0; ++ } + if (!fat_convert_directory (ctx, old_trav_info, new_trav_info)) + return 0; + return 1; +-- +2.4.3 + diff --git a/SOURCES/0018-libparted-Stop-converting-.-in-sys-path-to.patch b/SOURCES/0018-libparted-Stop-converting-.-in-sys-path-to.patch new file mode 100644 index 0000000..a22738d --- /dev/null +++ b/SOURCES/0018-libparted-Stop-converting-.-in-sys-path-to.patch @@ -0,0 +1,37 @@ +From 6dc72201ff5b41c171863e6b8eb069b8f8c479cf Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 7 Aug 2015 13:59:58 -0700 +Subject: [PATCH 18/18] libparted: Stop converting . in sys path to / + +In _probe_sys_block it claimed that ! and . are replaced by / in sys +paths, but according to the kernel code only ! is replaced (for cciss +devices). + +This is now causing problems with libnvdimm devices, the details are +here: + +https://git.kernel.org/cgit/linux/kernel/git/djbw/nvdimm.git/tree/Documentation/nvdimm/nvdimm.txt?h=libnvdimm-for-next +(cherry picked from commit 579bd6878b07d8387451d36106ccf86d26818b77) +--- + libparted/arch/linux.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index d33c02d..20a7235 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -2235,9 +2235,9 @@ _probe_sys_block () + + strcpy (dev_name, "/dev/"); + strcat (dev_name, dirent->d_name); +- /* in /sys/block, '/'s are replaced with '!' or '.' */ ++ /* in /sys/block, '/'s are replaced with '!' */ + for (ptr = dev_name; *ptr != '\0'; ptr++) { +- if (*ptr == '!' || *ptr == '.') ++ if (*ptr == '!') + *ptr = '/'; + } + _ped_device_probe (dev_name); +-- +2.4.3 + diff --git a/SOURCES/0019-libparted-Use-read-only-when-probing-devices-on-linu.patch b/SOURCES/0019-libparted-Use-read-only-when-probing-devices-on-linu.patch new file mode 100644 index 0000000..4b16f26 --- /dev/null +++ b/SOURCES/0019-libparted-Use-read-only-when-probing-devices-on-linu.patch @@ -0,0 +1,220 @@ +From d66b197b227e1fbd4a72f002cb8b8a7ee9461062 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Thu, 6 Aug 2015 07:17:14 -0700 +Subject: [PATCH 19/20] libparted: Use read only when probing devices on linux + (#1245144) + +When a device is opened for RW closing it can trigger other actions, +like udev scanning it for partition changes. Use read only for the +init_* methods and RW for actual changes to the device. + +This adds _device_open which takes mode flags as an argument and turns +linux_open into a wrapper for it with RW_MODE. + +_device_open_ro is added to open the device with RD_MODE and increment +the open_counter. This is used in the init_* functions. + +_device_close is a wrapper around linux_close that decrements the +open_counter and is used in the init_* functions. + +All of these changes are self-contained with no external API changes. +The only visible change in behavior is that when a new PedDevice is +created the device is opened in RO_MODE instead of RW_MODE. + +Resolves: rhbz#1245144 +(cherry picked from commit 0e169215efcdb33d588ddc2267467593bbf717c9) +--- + libparted/arch/linux.c | 62 +++++++++++++++++++++++++++++++++++--------------- + 1 file changed, 44 insertions(+), 18 deletions(-) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index b68130b..3934a5b 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -291,7 +291,9 @@ struct blkdev_ioctl_param { + static char* _device_get_part_path (PedDevice const *dev, int num); + static int _partition_is_mounted_by_path (const char* path); + static unsigned int _device_get_partition_range(PedDevice const* dev); +- ++static int _device_open (PedDevice* dev, int flags); ++static int _device_open_ro (PedDevice* dev); ++static int _device_close (PedDevice* dev); + + static int + _read_fd (int fd, char **buf) +@@ -910,7 +912,7 @@ init_ide (PedDevice* dev) + if (!_device_stat (dev, &dev_stat)) + goto error; + +- if (!ped_device_open (dev)) ++ if (!_device_open_ro (dev)) + goto error; + + if (ioctl (arch_specific->fd, HDIO_GET_IDENTITY, &hdi)) { +@@ -979,11 +981,11 @@ init_ide (PedDevice* dev) + if (!_device_probe_geometry (dev)) + goto error_close_dev; + +- ped_device_close (dev); ++ _device_close (dev); + return 1; + + error_close_dev: +- ped_device_close (dev); ++ _device_close (dev); + error: + return 0; + } +@@ -1116,7 +1118,7 @@ init_scsi (PedDevice* dev) + char* vendor; + char* product; + +- if (!ped_device_open (dev)) ++ if (!_device_open_ro (dev)) + goto error; + + if (ioctl (arch_specific->fd, SCSI_IOCTL_GET_IDLUN, &idlun) < 0) { +@@ -1130,7 +1132,7 @@ init_scsi (PedDevice* dev) + goto error_close_dev; + if (!_device_probe_geometry (dev)) + goto error_close_dev; +- ped_device_close (dev); ++ _device_close (dev); + return 1; + } + +@@ -1152,11 +1154,11 @@ init_scsi (PedDevice* dev) + if (!_device_probe_geometry (dev)) + goto error_close_dev; + +- ped_device_close (dev); ++ _device_close (dev); + return 1; + + error_close_dev: +- ped_device_close (dev); ++ _device_close (dev); + error: + return 0; + } +@@ -1168,7 +1170,7 @@ init_file (PedDevice* dev) + + if (!_device_stat (dev, &dev_stat)) + goto error; +- if (!ped_device_open (dev)) ++ if (!_device_open_ro (dev)) + goto error; + + dev->sector_size = PED_SECTOR_SIZE_DEFAULT; +@@ -1195,7 +1197,7 @@ init_file (PedDevice* dev) + goto error_close_dev; + } + +- ped_device_close (dev); ++ _device_close (dev); + + dev->bios_geom.cylinders = dev->length / 4 / 32; + dev->bios_geom.heads = 4; +@@ -1206,7 +1208,7 @@ init_file (PedDevice* dev) + return 1; + + error_close_dev: +- ped_device_close (dev); ++ _device_close (dev); + error: + return 0; + } +@@ -1222,7 +1224,7 @@ init_dasd (PedDevice* dev, const char* model_name) + if (!_device_stat (dev, &dev_stat)) + goto error; + +- if (!ped_device_open (dev)) ++ if (!_device_open_ro (dev)) + goto error; + + LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); +@@ -1262,11 +1264,11 @@ init_dasd (PedDevice* dev, const char* model_name) + + dev->model = strdup (model_name); + +- ped_device_close (dev); ++ _device_close (dev); + return 1; + + error_close_dev: +- ped_device_close (dev); ++ _device_close (dev); + error: + return 0; + } +@@ -1281,7 +1283,7 @@ init_generic (PedDevice* dev, const char* model_name) + if (!_device_stat (dev, &dev_stat)) + goto error; + +- if (!ped_device_open (dev)) ++ if (!_device_open_ro (dev)) + goto error; + + ped_exception_fetch_all (); +@@ -1329,11 +1331,11 @@ init_generic (PedDevice* dev, const char* model_name) + + dev->model = strdup (model_name); + +- ped_device_close (dev); ++ _device_close (dev); + return 1; + + error_close_dev: +- ped_device_close (dev); ++ _device_close (dev); + error: + return 0; + } +@@ -1620,12 +1622,27 @@ retry: + } + + static int ++_device_open_ro (PedDevice* dev) ++{ ++ int rc = _device_open (dev, RD_MODE); ++ if (rc) ++ dev->open_count++; ++ return rc; ++} ++ ++static int + linux_open (PedDevice* dev) + { ++ return _device_open (dev, RW_MODE); ++} ++ ++static int ++_device_open (PedDevice* dev, int flags) ++{ + LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); + + retry: +- arch_specific->fd = open (dev->path, RW_MODE); ++ arch_specific->fd = open (dev->path, flags); + + if (arch_specific->fd == -1) { + char* rw_error_msg = strerror (errno); +@@ -1694,6 +1711,15 @@ linux_refresh_close (PedDevice* dev) + return 1; + } + ++static int ++_device_close (PedDevice* dev) ++{ ++ int rc = linux_close (dev); ++ if (dev->open_count > 0) ++ dev->open_count--; ++ return rc; ++} ++ + #if SIZEOF_OFF_T < 8 + + static _syscall5(int,_llseek, +-- +2.4.3 + diff --git a/SOURCES/0020-tests-Use-wait_for_dev_to_-functions.patch b/SOURCES/0020-tests-Use-wait_for_dev_to_-functions.patch new file mode 100644 index 0000000..1856761 --- /dev/null +++ b/SOURCES/0020-tests-Use-wait_for_dev_to_-functions.patch @@ -0,0 +1,209 @@ +From f72968f996372d923dbeded302395d8f08445b31 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 7 Aug 2015 11:43:17 -0700 +Subject: [PATCH 20/20] tests: Use wait_for_dev_to_ functions + +Recent changes to udev have made some long-standing problems appear more +frequently. udev executes various actions when changes are made to +devices. Sometimes this can result in device nodes not appearing +immediately. Other times it can result in EBUSY being returned. This +patch only addresses devices that are slow to appear/disappear. + +It is best to use the wait_for_dev_to_appear_ and +wait_for_dev_to_disappear_ functions than to test for existance. These +will loop and wait for up to 2 seconds for it to appear. + +This also changes t9041 to fail if mkfs doesn't work since using skip +here may hide cases when the device node doesn't appear. + +(cherry picked from commit 1dc13965e1108ab513662450e0171c3ea3af3bd1) +--- + tests/t1100-busy-label.sh | 10 ++-------- + tests/t1102-loop-label.sh | 25 +++++-------------------- + tests/t2320-dos-extended-noclobber.sh | 1 + + tests/t6001-psep.sh | 4 ++-- + tests/t6004-dm-many-partitions.sh | 6 ++---- + tests/t6006-dm-512b-sectors.sh | 1 + + tests/t6100-mdraid-partitions.sh | 5 +++-- + tests/t9041-undetected-in-use-16th-partition.sh | 2 +- + 8 files changed, 17 insertions(+), 37 deletions(-) + +diff --git a/tests/t1100-busy-label.sh b/tests/t1100-busy-label.sh +index 4e256d3..70e8ede 100755 +--- a/tests/t1100-busy-label.sh ++++ b/tests/t1100-busy-label.sh +@@ -27,22 +27,16 @@ dev=$(cat dev-name) + + parted -s "$dev" mklabel msdos mkpart primary fat32 1 40 > out 2>&1 || fail=1 + compare /dev/null out || fail=1 +-mkfs.vfat ${dev}1 || skip_ "mkfs.vfat failed" ++wait_for_dev_to_appear_ ${dev}1 || fail=1 ++mkfs.vfat ${dev}1 || fail=1 + + mount_point="`pwd`/mnt" + + # Be sure to unmount upon interrupt, failure, etc. + cleanup_fn_() { umount "${dev}1" > /dev/null 2>&1; } + +-# There's a race condition here: on udev-based systems, the partition#1 +-# device, ${dev}1 (i.e., /dev/sdd1) is not created immediately, and +-# without some delay, this mount command would fail. Using a flash card +-# as $dev, the loop below typically iterates 7-20 times. +- + # create mount point dir. and mount the just-created partition on it + mkdir $mount_point || fail=1 +-i=0; while :; do test -e "${dev}1" && break; test $i = 90 && break; +- i=$(expr $i + 1); done; + mount "${dev}1" $mount_point || fail=1 + + # now that a partition is mounted, mklabel attempt must fail +diff --git a/tests/t1102-loop-label.sh b/tests/t1102-loop-label.sh +index 9752002..68b9af4 100644 +--- a/tests/t1102-loop-label.sh ++++ b/tests/t1102-loop-label.sh +@@ -44,15 +44,9 @@ mv out o2 && sed -e "s,$dev,DEVICE,;s/ *$//" o2 > out + + compare exp out || fail=1 + parted -s $dev rm 1 || fail=1 +-if [ -e ${dev}1 ]; then +- echo "Partition should not exist on loop device" +- fail=1 +-fi ++wait_for_dev_to_disappear_ ${dev}1 2 || fail=1 + partprobe $dev || fail=1 +-if [ -e ${dev}1 ]; then +- echo "Partition should not exist on loop device" +- fail=1 +-fi ++wait_for_dev_to_disappear_ ${dev}1 2 || fail=1 + + mount_point="`pwd`/mnt" + +@@ -80,24 +74,15 @@ umount "$mount_point" + + # make sure partprobe cleans up stale partition devices + parted -s $dev mklabel msdos mkpart primary ext2 0% 100% || fail=1 +-if [ ! -e ${dev}1 ]; then +- echo "Partition doesn't exist on loop device" +- fail=1 +-fi ++wait_for_dev_to_appear_ ${dev}1 || fail=1 + + mke2fs -F $dev + partprobe $dev || fail=1 +-if [ -e ${dev}1 ]; then +- echo "Partition should not exist on loop device" +- fail=1 +-fi ++wait_for_dev_to_disappear_ ${dev}1 2 || fail=1 + + # make sure new loop label removes old partitions > 1 + parted -s $dev mklabel msdos mkpart primary ext2 0% 50% mkpart primary ext2 50% 100% || fail=1 + parted -s $dev mklabel loop || fail=1 +-if [ -e ${dev}2 ]; then +- echo "Partition 2 not removed" +- fail=1 +-fi ++wait_for_dev_to_disappear_ ${dev}2 2 || fail=1 + + Exit $fail +diff --git a/tests/t2320-dos-extended-noclobber.sh b/tests/t2320-dos-extended-noclobber.sh +index 6f3dfff..bbc4f26 100644 +--- a/tests/t2320-dos-extended-noclobber.sh ++++ b/tests/t2320-dos-extended-noclobber.sh +@@ -32,6 +32,7 @@ scsi_dev=$(cat dev-name) + parted -s $scsi_dev mklabel msdos || fail=1 + parted -s $scsi_dev mkpart extended 1 5 > out 2>&1 || fail=1 + parted -s $scsi_dev mkpart primary 5 10 > out 2>&1 || fail=1 ++wait_for_dev_to_appear_ ${scsi_dev}1 || fail=1 + + # Make sure the size of the extended partition is correct. + # 2 sectors for 512b and 1 sector for larger. /sys/.../size is in +diff --git a/tests/t6001-psep.sh b/tests/t6001-psep.sh +index f15090a..4c758e8 100644 +--- a/tests/t6001-psep.sh ++++ b/tests/t6001-psep.sh +@@ -54,7 +54,7 @@ parted -s $dev mklabel msdos mkpart primary fat32 1m 5m > out 2>&1 || fail=1 + compare /dev/null out || fail=1 + + #make sure device name is correct +-test -e ${dev}p1 || fail=1 ++wait_for_dev_to_appear_ ${dev}p1 || fail=1 + + #repeat on name not ending in a digit + # setup: create a mapping +@@ -66,7 +66,7 @@ parted -s $dev mklabel msdos mkpart primary fat32 1m 5m > out 2>&1 || fail=1 + compare /dev/null out || fail=1 + + #make sure device name is correct +-test -e ${dev}1 || fail=1 ++wait_for_dev_to_appear_ ${dev}1 || fail=1 + + if [ -n "$fail" ]; then + ls /dev/mapper +diff --git a/tests/t6004-dm-many-partitions.sh b/tests/t6004-dm-many-partitions.sh +index 8d291ef..7ebc48a 100755 +--- a/tests/t6004-dm-many-partitions.sh ++++ b/tests/t6004-dm-many-partitions.sh +@@ -49,10 +49,8 @@ parted -m -a min -s /dev/mapper/$dm_name mklabel gpt $cmd > /dev/null 2>&1 || fa + + # Make sure all the partitions appeared under /dev/mapper/ + for ((i=1; i<=$n_partitions; i+=1)); do +- if [ ! -e "/dev/mapper/${dm_name}p$i" ]; then +- fail=1 +- break +- fi ++ wait_for_dev_to_appear_ "/dev/mapper/${dm_name}p$i" || { fail=1; break; } ++ + # remove the partitions as we go, otherwise cleanup won't work. + dmsetup remove /dev/mapper/${dm_name}p$i + done +diff --git a/tests/t6006-dm-512b-sectors.sh b/tests/t6006-dm-512b-sectors.sh +index 31abba9..c3045af 100644 +--- a/tests/t6006-dm-512b-sectors.sh ++++ b/tests/t6006-dm-512b-sectors.sh +@@ -60,6 +60,7 @@ dev="/dev/mapper/$linear_" + # Create msdos partition table with a partition from 1MiB to 100MiB + parted -s $dev mklabel msdos mkpart primary ext2 1MiB 101MiB > out 2>&1 || fail=1 + compare /dev/null out || fail=1 ++wait_for_dev_to_appear_ ${dev}1 || fail=1 + + # The size of the partition should be 100MiB, or 204800 512b sectors + p1_size=$(blockdev --getsz ${dev}1) || framework_failure +diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh +index 6f08442..dbc5986 100755 +--- a/tests/t6100-mdraid-partitions.sh ++++ b/tests/t6100-mdraid-partitions.sh +@@ -54,13 +54,14 @@ parted -s $md_dev mklabel gpt \ + compare /dev/null out || fail=1 + + # Verify that kernel has been informed about the second device. +-grep "${md_name}p2" /proc/partitions || { fail=1; cat /proc/partitions; } ++wait_for_dev_to_appear_ ${md_dev}p2 || { fail=1; cat /proc/partitions; } + + # Remove partitions from the raid device. + parted -s $md_dev rm 2 rm 1 > out 2>&1 || fail=1 + compare /dev/null out || fail=1 + + # Verify that kernel has been informed about those removals. +-grep "${md_name}p[12]" /proc/partitions && { fail=1; cat /proc/partitions; } ++wait_for_dev_to_disappear_ ${md_dev}p1 2 || { fail=1; cat /proc/partitions; } ++wait_for_dev_to_disappear_ ${md_dev}p2 2 || { fail=1; cat /proc/partitions; } + + Exit $fail +diff --git a/tests/t9041-undetected-in-use-16th-partition.sh b/tests/t9041-undetected-in-use-16th-partition.sh +index edaae1b..673e508 100644 +--- a/tests/t9041-undetected-in-use-16th-partition.sh ++++ b/tests/t9041-undetected-in-use-16th-partition.sh +@@ -72,7 +72,7 @@ wait_for_dev_to_appear_ ${scsi_dev}16 || fail_ ${scsi_dev}16 did not appear + + partitions="${scsi_dev}14 ${scsi_dev}15 ${scsi_dev}16" + for i in $partitions; do +- mkfs.ext3 $i || skip_ mkfs.ext3 $i failed ++ mkfs.ext3 $i || fail=1 + done + + # be sure to unmount upon interrupt, failure, etc. +-- +2.4.3 + diff --git a/SOURCES/0021-fdasd-geometry-handling-updated-from-upstream-s390-t.patch b/SOURCES/0021-fdasd-geometry-handling-updated-from-upstream-s390-t.patch new file mode 100644 index 0000000..f13ef02 --- /dev/null +++ b/SOURCES/0021-fdasd-geometry-handling-updated-from-upstream-s390-t.patch @@ -0,0 +1,281 @@ +From 4d480d980a9b69b432b8d60df3c4397ba8cdc965 Mon Sep 17 00:00:00 2001 +From: Viktor Mihajlovski +Date: Thu, 17 Sep 2015 15:33:28 +0200 +Subject: [PATCH 21/22] fdasd: geometry handling updated from upstream + s390-tools + +Remove the necessity for DASD-specific ioctls for partition handling. +This allows to correctly handle DASD-backed virtio block devices. + +Note that this is necessary because virtio is just the transport. +A DASD, even if provided via virtio, still has it's unique +characteristics, which means that only traditional DASD partition +table formats can be used (no MBR, GPT, or similar). + +Use bzero for initialization to make sure all struct members are +properly cleared. Also changed partition list handling code to be +more similar to upstream s390-tools fdasd. + +Further, enhanced error handling capabilities by providing a +return code by fdasd_get_geometry. + +Code is largely backported from s390-tools project. + +Signed-off-by: Viktor Mihajlovski +Acked-by: Stefan Haberland +Signed-off-by: Hendrik Brueckner +Signed-off-by: Brian C. Lane +--- + include/parted/fdasd.in.h | 4 +- + libparted/labels/fdasd.c | 166 ++++++++++++++++++++++++++++++++-------------- + 2 files changed, 119 insertions(+), 51 deletions(-) + +diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h +index 6f6a7e0..4e351c4 100644 +--- a/include/parted/fdasd.in.h ++++ b/include/parted/fdasd.in.h +@@ -190,6 +190,8 @@ typedef struct format_data_t { + #define BLKRRPART _IO(0x12,95) + /* get block device sector size */ + #define BLKSSZGET _IO(0x12,104) ++/* device size in bytes (u64 *arg)*/ ++#define BLKGETSIZE64 _IOR(0x12,114,size_t) + /* get device geometry */ + #define HDIO_GETGEO 0x0301 + +@@ -285,7 +287,7 @@ enum fdasd_failure { + + void fdasd_cleanup (fdasd_anchor_t *anchor); + void fdasd_initialize_anchor (fdasd_anchor_t * anc); +-void fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int fd); ++int fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int fd); + void fdasd_check_api_version (fdasd_anchor_t *anc, int fd); + int fdasd_check_volume (fdasd_anchor_t *anc, int fd); + int fdasd_write_labels (fdasd_anchor_t *anc, int fd); +diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c +index 1f87937..7e6a77a 100644 +--- a/libparted/labels/fdasd.c ++++ b/libparted/labels/fdasd.c +@@ -210,27 +210,7 @@ fdasd_initialize_anchor (fdasd_anchor_t * anc) + partition_info_t *p = NULL; + partition_info_t *q = NULL; + +- anc->devno = 0; +- anc->dev_type = 0; +- anc->used_partitions = 0; +- +- anc->silent = 0; +- anc->verbose = 0; +- anc->big_disk = 0; +- anc->volid_specified = 0; +- anc->config_specified = 0; +- anc->auto_partition = 0; +- anc->devname_specified = 0; +- anc->print_table = 0; +- +- anc->option_reuse = 0; +- anc->option_recreate = 0; +- +- anc->vlabel_changed = 0; +- anc->vtoc_changed = 0; +- anc->blksize = 0; +- anc->fspace_trk = 0; +- anc->label_pos = 0; ++ bzero(anc, sizeof(fdasd_anchor_t)); + + for (i=0; iused = 0x00; +- p->len_trk = 0; +- p->start_trk = 0; +- p->fspace_trk = 0; +- p->type = 0; ++ bzero(p, sizeof(partition_info_t)); + + /* add p to double pointered list */ + if (i == 1) { +- anc->first = p; +- p->prev = NULL; ++ anc->first = p; + } else if (i == USABLE_PARTITIONS) { +- anc->last = p; +- p->next = NULL; ++ anc->last = p; + p->prev = q; + q->next = p; + } else { +- p->prev = q; +- q->next = p; ++ p->prev = q; ++ q->next = p; + } + + p->f1 = malloc(sizeof(format1_label_t)); +@@ -947,15 +921,77 @@ fdasd_check_api_version (fdasd_anchor_t *anc, int f) + } + + /* ++ * The following two functions match those in the DASD ECKD device driver. ++ * They are used to compute how many records of a given size can be stored ++ * in one track. ++ */ ++static unsigned int ceil_quot(unsigned int d1, unsigned int d2) ++{ ++ return (d1 + (d2 - 1)) / d2; ++} ++ ++/* kl: key length, dl: data length */ ++static unsigned int recs_per_track(unsigned short dev_type, unsigned int kl, ++ unsigned int dl) ++{ ++ unsigned int dn, kn; ++ ++ switch (dev_type) { ++ case DASD_3380_TYPE: ++ if (kl) ++ return 1499 / (15 + 7 + ceil_quot(kl + 12, 32) + ++ ceil_quot(dl + 12, 32)); ++ else ++ return 1499 / (15 + ceil_quot(dl + 12, 32)); ++ case DASD_3390_TYPE: ++ dn = ceil_quot(dl + 6, 232) + 1; ++ if (kl) { ++ kn = ceil_quot(kl + 6, 232) + 1; ++ return 1729 / (10 + 9 + ceil_quot(kl + 6 * kn, 34) + ++ 9 + ceil_quot(dl + 6 * dn, 34)); ++ } else ++ return 1729 / (10 + 9 + ceil_quot(dl + 6 * dn, 34)); ++ case DASD_9345_TYPE: ++ dn = ceil_quot(dl + 6, 232) + 1; ++ if (kl) { ++ kn = ceil_quot(kl + 6, 232) + 1; ++ return 1420 / (18 + 7 + ceil_quot(kl + 6 * kn, 34) + ++ ceil_quot(dl + 6 * dn, 34)); ++ } else ++ return 1420 / (18 + 7 + ceil_quot(dl + 6 * dn, 34)); ++ } ++ return 0; ++} ++ ++/* ++ * Verify that number of tracks (heads) per cylinder and number of ++ * sectors per track match the expected values for a given device type ++ * and block size. ++ * Returns 1 for a valid match and 0 otherwise. ++ */ ++static int fdasd_verify_geometry(unsigned short dev_type, int blksize, ++ struct fdasd_hd_geometry *geometry) ++{ ++ unsigned int expected_sectors; ++ if (geometry->heads != 15) ++ return 0; ++ expected_sectors = recs_per_track(dev_type, 0, blksize); ++ if (geometry->sectors == expected_sectors) ++ return 1; ++ return 0; ++} ++ ++/* + * reads dasd geometry data + */ +-void ++int + fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f) + { + PDEBUG + int blksize = 0; + dasd_information_t dasd_info; + struct dasd_eckd_characteristics *characteristics; ++ unsigned long long size_in_bytes; + + /* We can't get geometry from a regular file, + so simulate something usable, for the sake of testing. */ +@@ -979,6 +1015,12 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f) + anc->geo.heads; + anc->is_file = 1; + } else { ++ if (ioctl(f, BLKGETSIZE64, &size_in_bytes) != 0) { ++ fdasd_error(anc, unable_to_ioctl, ++ _("Could not retrieve disk size.")); ++ goto error; ++ } ++ + if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0) + fdasd_error(anc, unable_to_ioctl, + _("Could not retrieve disk geometry information.")); +@@ -988,27 +1030,51 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f) + _("Could not retrieve blocksize information.")); + + /* get disk type */ +- if (ioctl(f, BIODASDINFO, &dasd_info) != 0) +- fdasd_error(anc, unable_to_ioctl, +- _("Could not retrieve disk information.")); +- +- characteristics = (struct dasd_eckd_characteristics *) +- &dasd_info.characteristics; +- if (characteristics->no_cyl == LV_COMPAT_CYL && +- characteristics->long_no_cyl) +- anc->hw_cylinders = characteristics->long_no_cyl; +- else +- anc->hw_cylinders = characteristics->no_cyl; ++ if (ioctl(f, BIODASDINFO, &dasd_info) != 0) { ++ /* verify that the geometry matches a 3390 DASD */ ++ if (!fdasd_verify_geometry(DASD_3390_TYPE, blksize, ++ &anc->geo)) { ++ fdasd_error(anc, wrong_disk_type, ++ _("Disk geometry does not match a " \ ++ "DASD device of type 3390.")); ++ goto error; ++ } ++ anc->dev_type = DASD_3390_TYPE; ++ anc->hw_cylinders = ++ size_in_bytes / (blksize * anc->geo.heads * anc->geo.sectors); ++ /* The VOL1 label on a CDL formatted ECKD DASD is in block 2 ++ * It will be verified later, if this position actually holds a ++ * valid label record. ++ */ ++ anc->label_pos = 2 * blksize; ++ /* A devno 0 is actually a valid devno, which could exist ++ * in the system. Since we use this number only to create ++ * a default volume serial, there is no serious conflict. ++ */ ++ anc->devno = 0; ++ } else { ++ characteristics = (struct dasd_eckd_characteristics *) ++ &dasd_info.characteristics; ++ if (characteristics->no_cyl == LV_COMPAT_CYL && ++ characteristics->long_no_cyl) ++ anc->hw_cylinders = characteristics->long_no_cyl; ++ else ++ anc->hw_cylinders = characteristics->no_cyl; ++ anc->dev_type = dasd_info.dev_type; ++ anc->label_pos = dasd_info.label_block * blksize; ++ anc->devno = dasd_info.devno; ++ anc->label_block = dasd_info.label_block; ++ anc->FBA_layout = dasd_info.FBA_layout; ++ } + + anc->is_file = 0; + } + +- anc->dev_type = dasd_info.dev_type; +- anc->blksize = blksize; +- anc->label_pos = dasd_info.label_block * blksize; +- anc->devno = dasd_info.devno; +- anc->label_block = dasd_info.label_block; +- anc->FBA_layout = dasd_info.FBA_layout; ++ anc->blksize = blksize; ++ return 1; ++ ++ error: ++ return 0; + } + + /* +-- +2.4.3 + diff --git a/SOURCES/0022-dasd-enhance-device-probing.patch b/SOURCES/0022-dasd-enhance-device-probing.patch new file mode 100644 index 0000000..e823fb3 --- /dev/null +++ b/SOURCES/0022-dasd-enhance-device-probing.patch @@ -0,0 +1,238 @@ +From 834713b5aee1edc004f863231dd489ee3a79f536 Mon Sep 17 00:00:00 2001 +From: Viktor Mihajlovski +Date: Thu, 17 Sep 2015 15:33:29 +0200 +Subject: [PATCH 22/22] dasd: enhance device probing + +Probe for all device/transport types as every block device +could be a DASD on s390. + +Since the calculation of the minimum and optimum alignment +is different between DASDs and common fixed block disks +we need a means other than dev->type == PED_DEVICE_DASD. +For that purpose a static function _ped_device_like_dasd() +offering a DASD detection heuristic has been added to +arch/linux.c. + +By always providing arch-specific alignment functions the +need for DASD-specific code could be removed from device.c. + +Observe fdasd_get_geometry return code for proper error +handling. + +Remove the obsolete API check as we no longer require the +DASD-specific IOCTLs. + +Signed-off-by: Viktor Mihajlovski +Acked-by: Stefan Haberland +Signed-off-by: Hendrik Brueckner +Signed-off-by: Brian C. Lane +--- + libparted/arch/linux.c | 85 ++++++++++++++++++++++++++++++++++++++++--------- + libparted/device.c | 14 +++----- + libparted/labels/dasd.c | 18 +++++------ + 3 files changed, 82 insertions(+), 35 deletions(-) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index adc368d..9344ceb 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -785,9 +785,13 @@ _device_set_sector_size (PedDevice* dev) + #endif + + #if defined __s390__ || defined __s390x__ ++ /* The real_sector_size is currently needed for DASD layouts, ++ * so we set it unconditionally. In the long run it should ++ * be considered to use the dev->phys_sector_size in label/dasd.c. ++ */ ++ arch_specific->real_sector_size = dev->sector_size; + /* Return PED_SECTOR_SIZE_DEFAULT for DASDs. */ + if (dev->type == PED_DEVICE_DASD) { +- arch_specific->real_sector_size = dev->sector_size; + dev->sector_size = PED_SECTOR_SIZE_DEFAULT; + } + #endif +@@ -3167,19 +3171,72 @@ linux_disk_commit (PedDisk* disk) + { + if (disk->dev->type != PED_DEVICE_FILE) { + +- /* We now require BLKPG support. If this assertion fails, +- please write to the mailing list describing your system. +- Assuming it's never triggered, ... +- FIXME: remove this assertion in 2012. */ +- assert (_have_blkpg ()); ++ /* We now require BLKPG support. If this assertion fails, ++ please write to the mailing list describing your system. ++ Assuming it's never triggered, ... ++ FIXME: remove this assertion in 2012. */ ++ assert (_have_blkpg ()); + +- if (!_disk_sync_part_table (disk)) +- return 0; ++ if (!_disk_sync_part_table (disk)) ++ return 0; + } + + return 1; + } + ++#if defined __s390__ || defined __s390x__ ++/** ++ * Check whether this device could be a DASD ++ * ++ * The device probing yields PED_DEVICE_DASD for native DASD transport ++ * If the block device uses a different transport (e.g. virtio) ++ * a simplified heuristic (assuming a model 3390 with 4K sectors) ++ * is applied (only) on s390x systems for this check. ++ * ++ * \return 1 if the geometry indicates this could be a DASD ++ * and 0 otherwise ++ */ ++static int ++_ped_device_like_dasd(const PedDevice *dev) ++{ ++ return (dev->type == PED_DEVICE_DASD) ++ || (dev->hw_geom.heads == 15 ++ && dev->hw_geom.sectors == 12 ++ && (dev->hw_geom.cylinders ++ * dev->hw_geom.heads ++ * dev->hw_geom.sectors ++ * dev->phys_sector_size ++ == dev->length * dev->sector_size)); ++} ++ ++ ++ ++static PedAlignment* ++s390_get_minimum_alignment(const PedDevice *dev) ++{ ++#if USE_BLKID ++ return linux_get_minimum_alignment(dev); ++#else ++ return ped_alignment_new(0, ++ dev->phys_sector_size ++ / dev->sector_size); ++#endif ++} ++ ++static PedAlignment* ++s390_get_optimum_alignment(const PedDevice *dev) ++{ ++ /* DASD needs to use minimum alignment */ ++ if (_ped_device_like_dasd(dev)) ++ return s390_get_minimum_alignment(dev); ++#if USE_BLKID ++ return linux_get_optimum_alignment(dev); ++#else ++ return NULL; ++#endif ++} ++#endif ++ + #if USE_BLKID + static PedAlignment* + linux_get_minimum_alignment(const PedDevice *dev) +@@ -3220,15 +3277,10 @@ linux_get_optimum_alignment(const PedDevice *dev) + && PED_DEFAULT_ALIGNMENT % optimal_io == 0) + || (!optimal_io && minimum_io + && PED_DEFAULT_ALIGNMENT % minimum_io == 0) +- ) { +- /* DASD needs to use minimum alignment */ +- if (dev->type == PED_DEVICE_DASD) +- return linux_get_minimum_alignment(dev); +- ++ ) + return ped_alignment_new( + blkid_topology_get_alignment_offset(tp) / dev->sector_size, + PED_DEFAULT_ALIGNMENT / dev->sector_size); +- } + + /* If optimal_io_size is 0 and we don't meet the other criteria + for using the device.c default, return the minimum alignment. */ +@@ -3255,7 +3307,10 @@ static PedDeviceArchOps linux_dev_ops = { + sync: linux_sync, + sync_fast: linux_sync_fast, + probe_all: linux_probe_all, +-#if USE_BLKID ++#if defined __s390__ || defined __s390x__ ++ get_minimum_alignment: s390_get_minimum_alignment, ++ get_optimum_alignment: s390_get_optimum_alignment, ++#elif USE_BLKID + get_minimum_alignment: linux_get_minimum_alignment, + get_optimum_alignment: linux_get_optimum_alignment, + #endif +diff --git a/libparted/device.c b/libparted/device.c +index cdcc117..36fecd2 100644 +--- a/libparted/device.c ++++ b/libparted/device.c +@@ -550,16 +550,10 @@ ped_device_get_optimum_alignment(const PedDevice *dev) + /* If the arch specific code could not give as an alignment + return a default value based on the type of device. */ + if (align == NULL) { +- switch (dev->type) { +- case PED_DEVICE_DASD: +- align = ped_device_get_minimum_alignment(dev); +- break; +- default: +- /* Align to a grain of 1MiB (like vista / win7) */ +- align = ped_alignment_new(0, +- (PED_DEFAULT_ALIGNMENT +- / dev->sector_size)); +- } ++ /* Align to a grain of 1MiB (like vista / win7) */ ++ align = ped_alignment_new(0, ++ (PED_DEFAULT_ALIGNMENT ++ / dev->sector_size)); + } + + return align; +diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c +index fa9414f..bb32d66 100644 +--- a/libparted/labels/dasd.c ++++ b/libparted/labels/dasd.c +@@ -214,19 +214,13 @@ dasd_probe (const PedDevice *dev) + + PED_ASSERT(dev != NULL); + +- if (!(dev->type == PED_DEVICE_DASD +- || dev->type == PED_DEVICE_VIODASD +- || dev->type == PED_DEVICE_FILE)) +- return 0; +- + arch_specific = LINUX_SPECIFIC(dev); + + /* add partition test here */ + fdasd_initialize_anchor(&anchor); + +- fdasd_get_geometry(dev, &anchor, arch_specific->fd); +- +- fdasd_check_api_version(&anchor, arch_specific->fd); ++ if (fdasd_get_geometry(dev, &anchor, arch_specific->fd) == 0) ++ goto error_cleanup; + + /* Labels are required on CDL formatted DASDs. */ + if (fdasd_check_volume(&anchor, arch_specific->fd) && +@@ -276,7 +270,9 @@ dasd_read (PedDisk* disk) + + fdasd_initialize_anchor(&anchor); + +- fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd); ++ if (fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd) == 0) ++ goto error_close_dev; ++ + disk_specific->label_block = anchor.label_block; + + if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE) +@@ -630,7 +626,9 @@ dasd_write (const PedDisk* disk) + + /* initialize the anchor */ + fdasd_initialize_anchor(&anchor); +- fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd); ++ if (fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd) == 0) ++ goto error; ++ + fdasd_check_volume(&anchor, arch_specific->fd); + memcpy(anchor.vlabel, &disk_specific->vlabel, sizeof(volume_label_t)); + anchor.vlabel_changed++; +-- +2.4.3 + diff --git a/SOURCES/0023-parted-fix-build-error-on-s390.patch b/SOURCES/0023-parted-fix-build-error-on-s390.patch new file mode 100644 index 0000000..4b60f19 --- /dev/null +++ b/SOURCES/0023-parted-fix-build-error-on-s390.patch @@ -0,0 +1,143 @@ +From 388bab890a4e09b09d2428c0e773ed083295f91b Mon Sep 17 00:00:00 2001 +From: Colin Watson +Date: Thu, 29 Oct 2015 21:12:01 +0100 +Subject: [PATCH] parted: fix build error on s390 + +The preceding dasd probing patches have introduced a compile error +when building with blkid support. Fixed by reordering function +definitions. + +Signed-off-by: Colin Watson +Signed-off-by: Viktor Mihajlovski +Signed-off-by: Brian C. Lane +--- + libparted/arch/linux.c | 106 ++++++++++++++++++++++++------------------------- + 1 file changed, 53 insertions(+), 53 deletions(-) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 9344ceb..1198f52 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -3184,59 +3184,6 @@ linux_disk_commit (PedDisk* disk) + return 1; + } + +-#if defined __s390__ || defined __s390x__ +-/** +- * Check whether this device could be a DASD +- * +- * The device probing yields PED_DEVICE_DASD for native DASD transport +- * If the block device uses a different transport (e.g. virtio) +- * a simplified heuristic (assuming a model 3390 with 4K sectors) +- * is applied (only) on s390x systems for this check. +- * +- * \return 1 if the geometry indicates this could be a DASD +- * and 0 otherwise +- */ +-static int +-_ped_device_like_dasd(const PedDevice *dev) +-{ +- return (dev->type == PED_DEVICE_DASD) +- || (dev->hw_geom.heads == 15 +- && dev->hw_geom.sectors == 12 +- && (dev->hw_geom.cylinders +- * dev->hw_geom.heads +- * dev->hw_geom.sectors +- * dev->phys_sector_size +- == dev->length * dev->sector_size)); +-} +- +- +- +-static PedAlignment* +-s390_get_minimum_alignment(const PedDevice *dev) +-{ +-#if USE_BLKID +- return linux_get_minimum_alignment(dev); +-#else +- return ped_alignment_new(0, +- dev->phys_sector_size +- / dev->sector_size); +-#endif +-} +- +-static PedAlignment* +-s390_get_optimum_alignment(const PedDevice *dev) +-{ +- /* DASD needs to use minimum alignment */ +- if (_ped_device_like_dasd(dev)) +- return s390_get_minimum_alignment(dev); +-#if USE_BLKID +- return linux_get_optimum_alignment(dev); +-#else +- return NULL; +-#endif +-} +-#endif +- + #if USE_BLKID + static PedAlignment* + linux_get_minimum_alignment(const PedDevice *dev) +@@ -3293,6 +3240,59 @@ linux_get_optimum_alignment(const PedDevice *dev) + } + #endif + ++#if defined __s390__ || defined __s390x__ ++/** ++ * Check whether this device could be a DASD ++ * ++ * The device probing yields PED_DEVICE_DASD for native DASD transport ++ * If the block device uses a different transport (e.g. virtio) ++ * a simplified heuristic (assuming a model 3390 with 4K sectors) ++ * is applied (only) on s390x systems for this check. ++ * ++ * \return 1 if the geometry indicates this could be a DASD ++ * and 0 otherwise ++ */ ++static int ++_ped_device_like_dasd(const PedDevice *dev) ++{ ++ return (dev->type == PED_DEVICE_DASD) ++ || (dev->hw_geom.heads == 15 ++ && dev->hw_geom.sectors == 12 ++ && (dev->hw_geom.cylinders ++ * dev->hw_geom.heads ++ * dev->hw_geom.sectors ++ * dev->phys_sector_size ++ == dev->length * dev->sector_size)); ++} ++ ++ ++ ++static PedAlignment* ++s390_get_minimum_alignment(const PedDevice *dev) ++{ ++#if USE_BLKID ++ return linux_get_minimum_alignment(dev); ++#else ++ return ped_alignment_new(0, ++ dev->phys_sector_size ++ / dev->sector_size); ++#endif ++} ++ ++static PedAlignment* ++s390_get_optimum_alignment(const PedDevice *dev) ++{ ++ /* DASD needs to use minimum alignment */ ++ if (_ped_device_like_dasd(dev)) ++ return s390_get_minimum_alignment(dev); ++#if USE_BLKID ++ return linux_get_optimum_alignment(dev); ++#else ++ return NULL; ++#endif ++} ++#endif ++ + static PedDeviceArchOps linux_dev_ops = { + _new: linux_new, + destroy: linux_destroy, +-- +2.4.3 + diff --git a/SOURCES/0024-fdasd.c-Safeguard-against-geometry-misprobing.patch b/SOURCES/0024-fdasd.c-Safeguard-against-geometry-misprobing.patch new file mode 100644 index 0000000..8683e25 --- /dev/null +++ b/SOURCES/0024-fdasd.c-Safeguard-against-geometry-misprobing.patch @@ -0,0 +1,48 @@ +From 953f340c3e24c296e9e73f4a0b45ff6563359592 Mon Sep 17 00:00:00 2001 +From: Viktor Mihajlovski +Date: Fri, 5 Feb 2016 14:47:11 +0100 +Subject: [PATCH] fdasd.c: Safeguard against geometry misprobing + +Fixes an issue with parted print being run against a logical +volume realised by extents on a physical volume residing on +a DASD. +We must make sure that geometry, device blocksize and DASD +attributes are present before we start format verifications +If any of it is missing this is not a DASD. + +Signed-off-by: Viktor Mihajlovski +Signed-off-by: Brian C. Lane +--- + libparted/labels/fdasd.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c +index 7e6a77a..968b332 100644 +--- a/libparted/labels/fdasd.c ++++ b/libparted/labels/fdasd.c +@@ -1021,13 +1021,20 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f) + goto error; + } + +- if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0) ++ if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0 || ++ anc->geo.heads == 0 || ++ anc->geo.sectors == 0 || ++ anc->geo.cylinders == 0 ) { + fdasd_error(anc, unable_to_ioctl, + _("Could not retrieve disk geometry information.")); ++ goto error; ++ } + +- if (ioctl(f, BLKSSZGET, &blksize) != 0) ++ if (ioctl(f, BLKSSZGET, &blksize) != 0) { + fdasd_error(anc, unable_to_ioctl, + _("Could not retrieve blocksize information.")); ++ goto error; ++ } + + /* get disk type */ + if (ioctl(f, BIODASDINFO, &dasd_info) != 0) { +-- +2.5.0 + diff --git a/SOURCES/0025-Add-libparted-fs-resize.pc.patch b/SOURCES/0025-Add-libparted-fs-resize.pc.patch new file mode 100644 index 0000000..4d904c6 --- /dev/null +++ b/SOURCES/0025-Add-libparted-fs-resize.pc.patch @@ -0,0 +1,67 @@ +From 151dd81cd1e86c1329488a892fa5df38aae132f5 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 29 Feb 2016 11:34:31 -0800 +Subject: [PATCH 25/28] Add libparted-fs-resize.pc + +Add a pkgconfig file for the filesystem resize library. + +(cherry picked from commit 56ede67e254132eba72b0c3e74b7b3677c22782d) +--- + Makefile.am | 3 ++- + configure.ac | 1 + + libparted-fs-resize.pc.in | 10 ++++++++++ + 3 files changed, 13 insertions(+), 1 deletion(-) + create mode 100644 libparted-fs-resize.pc.in + +diff --git a/Makefile.am b/Makefile.am +index 686b61c..c426b8c 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -6,6 +6,7 @@ EXTRA_DIST = \ + .prev-version \ + BUGS \ + libparted.pc.in \ ++ libparted-fs-resize.pc.in \ + parted.spec.in \ + parted.spec \ + scripts/data/abi/baseline_symbols.txt \ +@@ -18,7 +19,7 @@ EXTRA_DIST = \ + aclocaldir=$(datadir)/aclocal + + pcdir = $(libdir)/pkgconfig +-pc_DATA = libparted.pc ++pc_DATA = libparted.pc libparted-fs-resize.pc + + # This is best not done via configure.ac, because automake's + # make distcheck target does not like auto-generated files +diff --git a/configure.ac b/configure.ac +index 436d0e2..3d57157 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -613,6 +613,7 @@ libparted/labels/Makefile + libparted/fs/Makefile + libparted/tests/Makefile + libparted.pc ++libparted-fs-resize.pc + parted/Makefile + partprobe/Makefile + doc/Makefile +diff --git a/libparted-fs-resize.pc.in b/libparted-fs-resize.pc.in +new file mode 100644 +index 0000000..ed9b3d6 +--- /dev/null ++++ b/libparted-fs-resize.pc.in +@@ -0,0 +1,10 @@ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++libdir=@libdir@ ++includedir=@includedir@ ++ ++Name: libparted-fs-resize ++Description: The GNU Parted filesystem resize shared library ++Version: @VERSION@ ++Libs: -L${libdir} -lparted-fs-resize ++Cflags: -I${includedir} +-- +2.5.0 + diff --git a/SOURCES/0026-tests-Add-udevadm-settle-to-wait_for_-loop-1260664.patch b/SOURCES/0026-tests-Add-udevadm-settle-to-wait_for_-loop-1260664.patch new file mode 100644 index 0000000..8a49b15 --- /dev/null +++ b/SOURCES/0026-tests-Add-udevadm-settle-to-wait_for_-loop-1260664.patch @@ -0,0 +1,119 @@ +From 889e484922d3d5df300718ca229e12e5601e774a Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Tue, 1 Mar 2016 10:38:26 -0800 +Subject: [PATCH 26/28] tests: Add udevadm settle to wait_for_ loop (#1260664) + +Sometimes the device will vanish after the wait_for_dev_to_appear exits. +Add udevadm settle in an attempt to make sure the udev system is done +flapping around and the device will stay in place. + +Related: rhbz#1260664 +--- + tests/t-lib-helpers.sh | 2 ++ + tests/t-local.sh | 2 ++ + tests/t6001-psep.sh | 2 ++ + tests/t6004-dm-many-partitions.sh | 1 + + tests/t6005-dm-uuid.sh | 2 ++ + tests/t6100-mdraid-partitions.sh | 1 + + 6 files changed, 10 insertions(+) + +diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh +index 4e83a05..298f1fc 100644 +--- a/tests/t-lib-helpers.sh ++++ b/tests/t-lib-helpers.sh +@@ -371,6 +371,7 @@ wait_for_dev_to_appear_() + local i=0 + local incr=1 + while :; do ++ udevadm settle + ls "$file" > /dev/null 2>&1 && return 0 + sleep .1 2>/dev/null || { sleep 1; incr=10; } + i=$(expr $i + $incr); test $i = 20 && break +@@ -386,6 +387,7 @@ wait_for_dev_to_disappear_() + local i=0 + local incr=1 + while :; do ++ udevadm settle + ls "$file" > /dev/null 2>&1 || return 0 + sleep .1 2>/dev/null || { sleep 1; incr=10; } + i=$(expr $i + $incr); test $i -ge $(expr $n_sec \* 10) && break +diff --git a/tests/t-local.sh b/tests/t-local.sh +index b40a5a0..a7d5226 100644 +--- a/tests/t-local.sh ++++ b/tests/t-local.sh +@@ -47,6 +47,7 @@ wait_for_dev_to_appear_() + local i=0 + local incr=1 + while :; do ++ udevadm settle + ls "$file" > /dev/null 2>&1 && return 0 + sleep .1 2>/dev/null || { sleep 1; incr=10; } + i=$(expr $i + $incr); test $i = 20 && break +@@ -110,6 +111,7 @@ scsi_debug_setup_() + local i=0 + local new_dev + while :; do ++ udevadm settle + new_dev=$(new_sdX_) && break + sleep .1 2>/dev/null || { sleep 1; incr=10; } + i=$(expr $i + $incr); test $i = 20 && break +diff --git a/tests/t6001-psep.sh b/tests/t6001-psep.sh +index 4c758e8..2985cf5 100644 +--- a/tests/t6001-psep.sh ++++ b/tests/t6001-psep.sh +@@ -19,6 +19,8 @@ + . "${srcdir=.}/init.sh"; path_prepend_ ../parted + + require_root_ ++require_udevadm_settle_ ++ + (dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed" + + # Device maps names - should be random to not conflict with existing ones on +diff --git a/tests/t6004-dm-many-partitions.sh b/tests/t6004-dm-many-partitions.sh +index 7ebc48a..01d7fc0 100755 +--- a/tests/t6004-dm-many-partitions.sh ++++ b/tests/t6004-dm-many-partitions.sh +@@ -20,6 +20,7 @@ + . "${srcdir=.}/init.sh"; path_prepend_ ../parted + + require_root_ ++require_udevadm_settle_ + (dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed" + + ss=$sector_size_ +diff --git a/tests/t6005-dm-uuid.sh b/tests/t6005-dm-uuid.sh +index ce1251a..a48ae72 100755 +--- a/tests/t6005-dm-uuid.sh ++++ b/tests/t6005-dm-uuid.sh +@@ -20,6 +20,7 @@ + . "${srcdir=.}/init.sh"; path_prepend_ ../parted + + require_root_ ++require_udevadm_settle_ + (dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed" + + ss=$sector_size_ +@@ -46,6 +47,7 @@ for ((i=1; i<=$n_partitions; i+=1)); do + cmd="$cmd mkpart p$i ${s}s ${s}s" + done + parted -m -a min -s /dev/mapper/$dm_name mklabel gpt $cmd > /dev/null 2>&1 || fail=1 ++wait_for_dev_to_appear_ /dev/mapper/${dm_name}p${n_partitions} || fail=1 + + # Make sure all the partitions have UUIDs + for ((i=1; i<=$n_partitions; i+=1)); do +diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh +index dbc5986..dbb1686 100755 +--- a/tests/t6100-mdraid-partitions.sh ++++ b/tests/t6100-mdraid-partitions.sh +@@ -38,6 +38,7 @@ parted -s "$scsi_dev" mklabel gpt \ + mkpart p1 ext2 1M 4M \ + mkpart p2 ext2 5M 8M > out 2>&1 || fail=1 + compare /dev/null out || fail=1 ++wait_for_dev_to_appear_ ${scsi_dev}2 || { fail=1; cat /proc/partitions; } + + cleanup_fn_() { + # stop mdraid array +-- +2.5.0 + diff --git a/SOURCES/0027-tests-Add-wait-to-t9042-1257415.patch b/SOURCES/0027-tests-Add-wait-to-t9042-1257415.patch new file mode 100644 index 0000000..ebf1415 --- /dev/null +++ b/SOURCES/0027-tests-Add-wait-to-t9042-1257415.patch @@ -0,0 +1,31 @@ +From 91c2993edc47f590f1d3199976c970768fd6964c Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Tue, 1 Mar 2016 13:51:54 -0800 +Subject: [PATCH 27/28] tests: Add wait to t9042 (#1257415) + +Also make the new disklabel and first partition all in one step to +prevent udev problems. + +Resolves: rhbz#1257415 +--- + tests/t9042-dos-partition-limit.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tests/t9042-dos-partition-limit.sh b/tests/t9042-dos-partition-limit.sh +index b01828c..1a69384 100644 +--- a/tests/t9042-dos-partition-limit.sh ++++ b/tests/t9042-dos-partition-limit.sh +@@ -44,8 +44,8 @@ printf '%s\n' "BYT;" \ + "1:$((start-2))s:$((n-1))s:$((n-start+2))s:::lba;" \ + > exp || fail=1 + +-parted -s $scsi_dev mklabel msdos || fail=1 +-parted -s -a min $scsi_dev mkpart extended $((start-2))s 100% || fail=1 ++parted -s -a min $scsi_dev mklabel msdos mkpart extended $((start-2))s 100% || fail=1 ++wait_for_dev_to_appear_ ${scsi_dev}1 || fail=1 + + i=1 + while :; do +-- +2.5.0 + diff --git a/SOURCES/0028-tests-Fix-t1700-failing-on-a-host-with-a-4k-xfs-file.patch b/SOURCES/0028-tests-Fix-t1700-failing-on-a-host-with-a-4k-xfs-file.patch new file mode 100644 index 0000000..aa5bf07 --- /dev/null +++ b/SOURCES/0028-tests-Fix-t1700-failing-on-a-host-with-a-4k-xfs-file.patch @@ -0,0 +1,56 @@ +From 1fc0439a5bd27697fb5daa911f776de4a69e0ca3 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 29 Feb 2016 14:31:35 -0800 +Subject: [PATCH 28/28] tests: Fix t1700 failing on a host with a 4k xfs + filesystem (#1260664) + +The problem is that mkfs.xfs won't work if the file it is trying to +create is on a filesystem with a sector size larger than the passed +-ssize value. So a host with 4k disks (eg. s390) and the xfs filesystem +will fail with the error message: + illegal sector size 512; hw sector is 4096 + +Failures setting up the environment for the test aren't parted bugs. +This stops treating mkfs and dd errors as test failures, skipping the fs +and logging a warning. + +Related: rhbz#1260664 +--- + tests/t1700-probe-fs.sh | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh +index 94ed9ae..b13cec0 100755 +--- a/tests/t1700-probe-fs.sh ++++ b/tests/t1700-probe-fs.sh +@@ -39,13 +39,13 @@ for type in ext2 ext3 ext4 btrfs xfs nilfs2 ntfs vfat hfsplus; do + hfsplus) fsname=hfs+;; + esac + +- # create an $type file system ++ # create an $type file system, creation failures are not parted bugs, ++ # skip the filesystem instead of failing the test. + if [ "$type" = "xfs" ]; then +- # Work around a problem with s390 +- mkfs.xfs -ssize=$ss -dfile,name=$dev,size=${n_sectors}s || fail=1 ++ mkfs.xfs -ssize=$ss -dfile,name=$dev,size=${n_sectors}s || { warn_ "$ME: mkfs.$type failed, skipping"; continue; } + else +- dd if=/dev/null of=$dev bs=$ss seek=$n_sectors >/dev/null || fail=1 +- mkfs.$type $force $dev || { warn_ $ME: mkfs.$type failed; fail=1; continue; } ++ dd if=/dev/null of=$dev bs=$ss seek=$n_sectors >/dev/null || { warn_ "$ME: dd failed, skipping $type"; continue; } ++ mkfs.$type $force $dev || { warn_ "$ME: mkfs.$type failed skipping"; continue; } + fi + + # probe the $type file system +@@ -57,7 +57,7 @@ done + # Some features should indicate ext4 by themselves. + for feature in uninit_bg flex_bg; do + # create an ext3 file system +- dd if=/dev/null of=$dev bs=1024 seek=4096 >/dev/null || fail=1 ++ dd if=/dev/null of=$dev bs=1024 seek=4096 >/dev/null || skip_ "dd failed" + mkfs.ext3 -F $dev >/dev/null || skip_ "mkfs.ext3 failed" + + # set the feature +-- +2.5.0 + diff --git a/SOURCES/0029-lib-fs-resize-Prevent-crash-resizing-FAT-with-very-d.patch b/SOURCES/0029-lib-fs-resize-Prevent-crash-resizing-FAT-with-very-d.patch new file mode 100644 index 0000000..3624c8a --- /dev/null +++ b/SOURCES/0029-lib-fs-resize-Prevent-crash-resizing-FAT-with-very-d.patch @@ -0,0 +1,33 @@ +From 9a95ca5da96846f3edea48ab18c6365001805e70 Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sun, 28 Feb 2016 15:36:10 +0000 +Subject: [PATCH 29/30] lib-fs-resize: Prevent crash resizing FAT with very + deep directories + +Resizing a FAT file system crashes in libparted/fs/r/fat/count.c +flag_traverse_dir() if the length of any path name in the file system +overflows the 512 byte file_name local buffer. Increase buffer to 4096, +PATH_MAX on Linux. + +Reported in +https://bugzilla.gnome.org/show_bug.cgi?id=762448 +--- + libparted/fs/r/fat/count.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libparted/fs/r/fat/count.c b/libparted/fs/r/fat/count.c +index 7949e47..a5837c0 100644 +--- a/libparted/fs/r/fat/count.c ++++ b/libparted/fs/r/fat/count.c +@@ -219,7 +219,7 @@ flag_traverse_dir (FatTraverseInfo* trav_info) { + PedFileSystem* fs = trav_info->fs; + FatDirEntry* this_entry; + FatTraverseInfo* subdir_trav_info; +- char file_name [512]; ++ char file_name [4096]; + char* file_name_start; + FatCluster first_cluster; + PedSector size; +-- +2.5.0 + diff --git a/SOURCES/0030-tests-t3000-resize-fs.sh-Add-very-deep-directory.patch b/SOURCES/0030-tests-t3000-resize-fs.sh-Add-very-deep-directory.patch new file mode 100644 index 0000000..a16e10e --- /dev/null +++ b/SOURCES/0030-tests-t3000-resize-fs.sh-Add-very-deep-directory.patch @@ -0,0 +1,49 @@ +From 599ce25c802fc1154ed619fde4249bb381430407 Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sun, 28 Feb 2016 15:36:11 +0000 +Subject: [PATCH 30/30] tests: t3000-resize-fs.sh: Add very deep directory + +Create 500 deep directory tree, with longest name of 4000 characters, to +the file system being resized to test the fix to prevent crash when +resizing a FAT file system with such a long path. +--- + tests/t3000-resize-fs.sh | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh +index a79a307..608871c 100755 +--- a/tests/t3000-resize-fs.sh ++++ b/tests/t3000-resize-fs.sh +@@ -46,6 +46,13 @@ device_sectors_required=$(echo $default_end | sed 's/s$//') + # Ensure that $dev is large enough for this test + test $device_sectors_required -le $dev_n_sectors || fail=1 + ++# create mount point dir ++mount_point="`pwd`/mnt" ++mkdir "$mount_point" || fail=1 ++ ++# be sure to unmount upon interrupt, failure, etc. ++cleanup_fn_() { umount "${dev}1" > /dev/null 2>&1; } ++ + for fs_type in hfs+ fat32 fat16; do + echo "fs_type=$fs_type" + +@@ -69,6 +76,15 @@ for fs_type in hfs+ fat32 fat16; do + # create the file system + $mkfs_cmd ${dev}1 || fail=1 + ++ # create 500 deep directory tree with longest name 4000 characters ++ # to catch core dump in libparted/fs/r/fat/count.c flag_traverse_dir() ++ # overflowing 512 byte file_name local buffer. ++ mount "${dev}1" "$mount_point" || fail=1 ++ cat /dev/null > exp ++ ( cd "$mount_point"; for d in `seq 500`; do mkdir TESTDIR; cd TESTDIR; done ) > out ++ compare exp out || fail=1 # Ensure no errors creating directory tree ++ umount "${dev}1" || fail=1 ++ + # NOTE: shrinking is the only type of resizing that works. + # resize that file system to be one cylinder (8MiB) smaller + fs-resize ${dev}1 0 $new_end > out 2>&1 || fail=1 +-- +2.5.0 + diff --git a/SOURCES/0031-Use-BLKSSZGET-to-get-device-sector-size-in-_device_p.patch b/SOURCES/0031-Use-BLKSSZGET-to-get-device-sector-size-in-_device_p.patch new file mode 100644 index 0000000..b458a2d --- /dev/null +++ b/SOURCES/0031-Use-BLKSSZGET-to-get-device-sector-size-in-_device_p.patch @@ -0,0 +1,101 @@ +From 61dd3d4c5eb782eb43caa95342e63727db3f8281 Mon Sep 17 00:00:00 2001 +From: David Cantrell +Date: Thu, 17 Mar 2016 09:24:55 -0400 +Subject: [PATCH] Use BLKSSZGET to get device sector size in + _device_probe_geometry() + +Seen on certain newer devices (such as >32G SDHC memory cards), the +HDIO_GETGEO ioctl does not return useful information. The libparted +code records hardware and bios reported geometry information, but all of +that is largely unusable these days. The information is used in the +PedConstraint code for aligning partitions. The sector count is most +useful. Rather than only trying HDIO_GETGIO, first initialize the +bios_geom fields to 0 and then use BLKSSZGET to capture the sector size. +If that fails, try HDIO_GETGEO. And if that fails, raise a warning and +fall back on the library's default sector size macro. + +This problem showed up on Raspberry Pi devices where users were +attempting to grow a partition to fill the SDHC card. Using the +optimal_aligned_constraint returned invalid geometry information +(98703359 instead of 124735488 sectors). The issue was reported here: + + https://github.com/fedberry/fedberry/issues/8 + +And to the pyparted project: + + https://github.com/rhinstaller/pyparted/issues/25 + +I've applied this patch locally to parted, rebuilt, and reinstalled it +and it is working correctly for the problem SDHC cards. + +Signed-off-by: Brian C. Lane +--- + libparted/arch/linux.c | 40 +++++++++++++++++++++++++--------------- + 1 file changed, 25 insertions(+), 15 deletions(-) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 1198f52..326b956 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -852,6 +852,7 @@ _device_probe_geometry (PedDevice* dev) + LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); + struct stat dev_stat; + struct hd_geometry geometry; ++ int sector_size = 0; + + if (!_device_stat (dev, &dev_stat)) + return 0; +@@ -863,26 +864,35 @@ _device_probe_geometry (PedDevice* dev) + if (!dev->length) + return 0; + +- /* The GETGEO ioctl is no longer useful (as of linux 2.6.x). We could +- * still use it in 2.4.x, but this is contentious. Perhaps we should +- * move to EDD. */ +- dev->bios_geom.sectors = 63; +- dev->bios_geom.heads = 255; +- dev->bios_geom.cylinders +- = dev->length / (63 * 255); ++ /* initialize the bios_geom values to something */ ++ dev->bios_geom.sectors = 0; ++ dev->bios_geom.heads = 0; ++ dev->bios_geom.cylinders = 0; + +- /* FIXME: what should we put here? (TODO: discuss on linux-kernel) */ +- if (!ioctl (arch_specific->fd, HDIO_GETGEO, &geometry) ++ if (!ioctl (arch_specific->fd, BLKSSZGET, §or_size)) { ++ /* get the sector count first */ ++ dev->bios_geom.sectors = 1 + (sector_size / PED_SECTOR_SIZE_DEFAULT); ++ dev->bios_geom.heads = 255; ++ } else if (!ioctl (arch_specific->fd, HDIO_GETGEO, &geometry) + && geometry.sectors && geometry.heads) { +- dev->hw_geom.sectors = geometry.sectors; +- dev->hw_geom.heads = geometry.heads; +- dev->hw_geom.cylinders +- = dev->length / (dev->hw_geom.heads +- * dev->hw_geom.sectors); ++ /* if BLKSSZGET failed, try the deprecated HDIO_GETGEO */ ++ dev->bios_geom.sectors = geometry.sectors; ++ dev->bios_geom.heads = geometry.heads; + } else { +- dev->hw_geom = dev->bios_geom; ++ ped_exception_throw ( ++ PED_EXCEPTION_WARNING, ++ PED_EXCEPTION_OK, ++ _("Could not determine sector size for %s: %s.\n" ++ "Using the default sector size (%lld)."), ++ dev->path, strerror (errno), PED_SECTOR_SIZE_DEFAULT); ++ dev->bios_geom.sectors = 2; ++ dev->bios_geom.heads = 255; + } + ++ dev->bios_geom.cylinders ++ = dev->length / (dev->bios_geom.heads ++ * dev->bios_geom.sectors); ++ dev->hw_geom = dev->bios_geom; + return 1; + } + +-- +2.5.0 + diff --git a/SOURCES/0032-parted-fix-the-rescue-command.patch b/SOURCES/0032-parted-fix-the-rescue-command.patch new file mode 100644 index 0000000..72a9de2 --- /dev/null +++ b/SOURCES/0032-parted-fix-the-rescue-command.patch @@ -0,0 +1,106 @@ +From 0b996d3ebe95fdb6704f2c1d1a82574e07e86798 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Tue, 12 Apr 2016 16:13:44 -0700 +Subject: [PATCH 32/36] parted: fix the rescue command + +The rescue command often failed to locate a filesystem due to it +leaving cylinder alignment on, which snapped the allowed bounds +of the filesystem down to the next lower cylinder boundary, +causing the detected filesystem to be rejected due to not fitting. + +(cherry picked from commit e09c30fb53179319ba1543813b5b4024e923b795) +--- + parted/parted.c | 4 ++++ + tests/Makefile.am | 1 + + tests/t1701-rescue-fs.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 57 insertions(+) + create mode 100644 tests/t1701-rescue-fs.sh + +diff --git a/parted/parted.c b/parted/parted.c +index f8c81ca..18b778c 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -1472,6 +1472,10 @@ do_rescue (PedDevice** dev, PedDisk** diskp) + disk = ped_disk_new (*dev); + if (!disk) + goto error; ++ if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT)) ++ if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT, ++ 0)) ++ goto error; + + if (!command_line_get_sector (_("Start?"), *dev, &start, NULL, NULL)) + goto error_destroy_disk; +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 001b9de..6a06dce 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -43,6 +43,7 @@ TESTS = \ + t1102-loop-label.sh \ + t1104-remove-and-add-partition.sh \ + t1700-probe-fs.sh \ ++ t1701-rescue-fs.sh \ + t2200-dos-label-recog.sh \ + t2201-pc98-label-recog.sh \ + t2300-dos-label-extended-bootcode.sh \ +diff --git a/tests/t1701-rescue-fs.sh b/tests/t1701-rescue-fs.sh +new file mode 100644 +index 0000000..9b726cf +--- /dev/null ++++ b/tests/t1701-rescue-fs.sh +@@ -0,0 +1,52 @@ ++#!/bin/sh ++# rescue ext4 file system ++ ++# Copyright (C) 2008-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 . ++ ++. "${srcdir=.}/init.sh"; path_prepend_ ../parted ++require_512_byte_sector_size_ ++require_root_ ++require_scsi_debug_module_ ++ ++# create memory-backed device ++scsi_debug_setup_ sector_size=$sector_size_ dev_size_mb=32 > dev-name || ++ skip_ 'failed to create scsi_debug device' ++scsi_dev=$(cat dev-name) ++ ++( mkfs.ext4 2>&1 | grep -i '^usage' ) > /dev/null \ ++ || { warn_ "$ME: no ext4 support"; Exit $fail; } ++ ++parted -s $scsi_dev mklabel msdos mkpart primary ext2 1m 100% ++mkfs.ext4 ${scsi_dev}1 || { warn_ $ME: mkfs.ext4 failed; fail=1; Exit $fail; } ++ ++# remove the partition ++parted -s $scsi_dev rm 1 || fail=1 ++ ++# rescue the partition ++echo yes | parted ---pretend-input-tty $scsi_dev rescue 1m 100% > out 2>&1 ++cat > exp < 33.6MB. Do you want to add it to the partition table? ++Yes/No/Cancel? yes ++Information: You may need to update /etc/fstab. ++EOF ++# Transform the actual output, to avoid spurious differences when ++# $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity. ++# normalize the actual output ++mv out o2 && sed -e "s, * ,,g;s, $,," \ ++ -e "s,^.*/lt-parted: ,parted: ," o2 > out ++echo '' >> exp ++compare out exp || fail=1 ++Exit $fail +-- +2.5.5 + diff --git a/SOURCES/0033-Use-disk-geometry-as-basis-for-ext2-sector-sizes.patch b/SOURCES/0033-Use-disk-geometry-as-basis-for-ext2-sector-sizes.patch new file mode 100644 index 0000000..9cb7915 --- /dev/null +++ b/SOURCES/0033-Use-disk-geometry-as-basis-for-ext2-sector-sizes.patch @@ -0,0 +1,30 @@ +From ac501e86dd95baa6f426cdd1395f2fe2a9c4e92a Mon Sep 17 00:00:00 2001 +From: Steven Lang +Date: Thu, 8 Jan 2015 17:22:02 -0800 +Subject: [PATCH 33/36] Use disk geometry as basis for ext2 sector sizes. + +When creating the geom for probed ext2 based filesystems, the +size was being reported in 512 byte sectors, regardless of what +the actual sector size of the device is. + +(cherry picked from commit d15a596a4436a08b9ad9db35729740b6314d536b) +--- + libparted/fs/ext2/interface.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libparted/fs/ext2/interface.c b/libparted/fs/ext2/interface.c +index 890a47b..a90c592 100644 +--- a/libparted/fs/ext2/interface.c ++++ b/libparted/fs/ext2/interface.c +@@ -41,7 +41,7 @@ _ext2_generic_probe (PedGeometry* geom, int expect_ext_ver) + struct ext2_super_block *sb = (struct ext2_super_block *)(sb_v + 1024); + + if (EXT2_SUPER_MAGIC(*sb) == EXT2_SUPER_MAGIC_CONST) { +- PedSector block_size = 1 << (EXT2_SUPER_LOG_BLOCK_SIZE(*sb) + 1); ++ PedSector block_size = (EXT2_MIN_BLOCK_SIZE << (EXT2_SUPER_LOG_BLOCK_SIZE(*sb))) / geom->dev->sector_size; + PedSector block_count = EXT2_SUPER_BLOCKS_COUNT(*sb); + PedSector group_blocks = EXT2_SUPER_BLOCKS_PER_GROUP(*sb); + PedSector group_nr = EXT2_SUPER_BLOCK_GROUP_NR(*sb); +-- +2.5.5 + diff --git a/SOURCES/0034-docs-Add-list-of-filesystems-for-fs-type-1311596.patch b/SOURCES/0034-docs-Add-list-of-filesystems-for-fs-type-1311596.patch new file mode 100644 index 0000000..963ef9a --- /dev/null +++ b/SOURCES/0034-docs-Add-list-of-filesystems-for-fs-type-1311596.patch @@ -0,0 +1,29 @@ +From d1d40cda51078a5dd8843d8c54e7e112fa028518 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 29 Feb 2016 16:47:18 -0800 +Subject: [PATCH 34/36] docs: Add list of filesystems for fs-type (#1311596) + +Add the most common filesystem types to the parted manpage. + +Resolves: rhbz#1311596 +(cherry picked from commit c9f50a36aee0a4c373b5e1bd3069aeb18fac055d) +--- + doc/C/parted.8 | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/doc/C/parted.8 b/doc/C/parted.8 +index 5304375..a45f42f 100644 +--- a/doc/C/parted.8 ++++ b/doc/C/parted.8 +@@ -76,6 +76,8 @@ should be one of "aix", "amiga", "bsd", "dvh", "gpt", "loop", "mac", "msdos", + .B mkpart \fIpart-type\fP \fI[fs-type]\fP \fIstart\fP \fIend\fP + Make a \fIpart-type\fP partition for filesystem \fIfs-type\fP (if specified), + beginning at \fIstart\fP and ending at \fIend\fP (by default in megabytes). ++\fIfs-type\fP can be one of "btrfs", "ext2", "ext3", "ext4", "fat16", "fat32", ++"hfs", "hfs+", "linux-swap", "ntfs", "reiserfs", or "xfs". + \fIpart-type\fP should be one of "primary", "logical", or "extended". + .TP + .B name \fIpartition\fP \fIname\fP +-- +2.5.5 + diff --git a/SOURCES/0035-parted-Display-details-of-partition-alignment-failur.patch b/SOURCES/0035-parted-Display-details-of-partition-alignment-failur.patch new file mode 100644 index 0000000..ee44397 --- /dev/null +++ b/SOURCES/0035-parted-Display-details-of-partition-alignment-failur.patch @@ -0,0 +1,145 @@ +From a7d850a3b39b160dcc23e12491cb2cc7c056cd01 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 28 Oct 2015 11:57:22 -0700 +Subject: [PATCH 35/36] parted: Display details of partition alignment failure + (#726856) + +When alignment for a new partition fails it isn't always obvious why it +failed. This adds printing the reason for the failure, in the form of: + +start % grain != offset + +This modifies align-check in interactive mode to print the alignment the +error details if it isn't aligned. Script mode behavior is unchanged. + +Also cleanup pointer usage and handle asprintf failure by using a constant +string in the error report - "unknown (malloc failure)". + +(cherry picked from commit 1726dbb4cd2dc4b19fe8d3c4b94e172fc0bd2c7c) +--- + parted/parted.c | 64 +++++++++++++++++++++++++++++++++++++++++++++------------ + 1 file changed, 51 insertions(+), 13 deletions(-) + +diff --git a/parted/parted.c b/parted/parted.c +index 18b778c..06f9971 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -183,7 +183,8 @@ static TimerContext timer_context; + static int _print_list (); + static void _done (PedDevice* dev, PedDisk *diskp); + static bool partition_align_check (PedDisk const *disk, +- PedPartition const *part, enum AlignmentType a_type); ++ PedPartition const *part, enum AlignmentType a_type, ++ char **align_err); + + static void + _timer_handler (PedTimer* timer, void* context) +@@ -783,21 +784,27 @@ do_mkpart (PedDevice** dev, PedDisk** diskp) + } + } + ++ char *align_err = NULL; + if ((alignment == ALIGNMENT_OPTIMAL && +- !partition_align_check(disk, part, PA_OPTIMUM)) || ++ !partition_align_check(disk, part, PA_OPTIMUM, &align_err)) || + (alignment == ALIGNMENT_MINIMAL && +- !partition_align_check(disk, part, PA_MINIMUM))) { ++ !partition_align_check(disk, part, PA_MINIMUM, &align_err))) { + if (ped_exception_throw( + PED_EXCEPTION_WARNING, + (opt_script_mode + ? PED_EXCEPTION_OK + : PED_EXCEPTION_IGNORE_CANCEL), + _("The resulting partition is not properly " +- "aligned for best performance.")) == ++ "aligned for best performance: %s"), ++ align_err ? align_err : _("unknown (malloc failed)")) == + PED_EXCEPTION_CANCEL) { ++ if (align_err) ++ free(align_err); + /* undo partition addition */ + goto error_remove_part; + } ++ if (align_err) ++ free(align_err); + } + } else { + ped_exception_leave_all(); +@@ -1629,10 +1636,18 @@ do_select (PedDevice** dev, PedDisk** diskp) + offset and alignment requirements. Also return true if there is + insufficient kernel support to determine DISK's alignment requirements. + Otherwise, return false. A_TYPE selects whether to check for minimal +- or optimal alignment requirements. */ ++ or optimal alignment requirements. ++ ++ If align_err is not NULL a string describing why the check failed ++ will be allocated and returned. It is up to the caller to free this. ++ Pass NULL if no error description is needed. ++ ++ If allocating the error string fails *align_err will be set to NULL, the ++ caller should always check for this. ++*/ + static bool + partition_align_check (PedDisk const *disk, PedPartition const *part, +- enum AlignmentType a_type) ++ enum AlignmentType a_type, char **align_err) + { + PED_ASSERT (part->disk == disk); + PedDevice const *dev = disk->dev; +@@ -1641,10 +1656,20 @@ partition_align_check (PedDisk const *disk, PedPartition const *part, + ? ped_device_get_minimum_alignment (dev) + : ped_device_get_optimum_alignment (dev)); + if (pa == NULL) +- return true; ++ return true; + + PED_ASSERT (pa->grain_size != 0); + bool ok = (part->geom.start % pa->grain_size == pa->offset); ++ ++ /* If it isn't aligned and the caller wants an explanation, ++ show them the math. */ ++ if (!ok && align_err) { ++ if (asprintf(align_err, ++ "%llds %% %llds != %llds", ++ part->geom.start, pa->grain_size, pa->offset) < 0) { ++ *align_err = NULL; ++ } ++ } + free (pa); + return ok; + } +@@ -1665,12 +1690,25 @@ do_align_check (PedDevice **dev, PedDisk** diskp) + if (!command_line_get_partition (_("Partition number?"), *diskp, &part)) + goto error; + +- bool aligned = partition_align_check (*diskp, part, align_type); +- if (!opt_script_mode) +- printf(aligned ? _("%d aligned\n") : _("%d not aligned\n"), part->num); +- +- if (opt_script_mode) +- return aligned ? 1 : 0; ++ char *align_err = NULL; ++ bool aligned = partition_align_check (*diskp, part, align_type, &align_err); ++ ++ /* Don't print the error in script mode */ ++ if (opt_script_mode) { ++ if (align_err) ++ free(align_err); ++ return aligned ? 1 : 0; ++ } ++ ++ if (aligned) ++ printf(_("%d aligned\n"), part->num); ++ else ++ printf(_("%d not aligned: %s\n"), ++ part->num, ++ align_err ? align_err : _("unknown (malloc failed)")); ++ ++ if (align_err) ++ free(align_err); + + /* Always return 1 in interactive mode, to be consistent + with the other modes. */ +-- +2.5.5 + diff --git a/SOURCES/0036-libparted-Remove-fdasd-geometry-code-from-alloc_meta.patch b/SOURCES/0036-libparted-Remove-fdasd-geometry-code-from-alloc_meta.patch new file mode 100644 index 0000000..8f47ace --- /dev/null +++ b/SOURCES/0036-libparted-Remove-fdasd-geometry-code-from-alloc_meta.patch @@ -0,0 +1,49 @@ +From 02178bf3980410abdd57c9f1045ff27bc4f11d7e Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 11 Apr 2016 15:10:51 -0700 +Subject: [PATCH 36/36] libparted: Remove fdasd geometry code from + alloc_metadata (#1244833) + +commit db20944f changed how the trailing_metadata_end is calculated in +dasd_alloc_metadata, removing the need for setting up the anchor struct. +But dasd_alloc_metadata can be called in various contexts, and the +arch_specific->fd may or may not be valid during these calls. This can +result in unpredictable crashes when it uses a stale fd and tries to run +the file image code in fdasd_get_geometry instead of the device code. + +The solution is to just drop the unneeded code, and to remember that +arch_specific->fd should only be used when ped_device_open has first +been called. + +Resolves: rhbz#1244833 +(cherry picked from commit 9da2f460bebf9a8281fdd52536d3676b0914b8fd) +--- + libparted/labels/dasd.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c +index bb32d66..f79a867 100644 +--- a/libparted/labels/dasd.c ++++ b/libparted/labels/dasd.c +@@ -948,7 +948,6 @@ dasd_alloc_metadata (PedDisk* disk) + PedPartition* part = NULL; /* initialize solely to placate gcc */ + PedPartition* new_part2; + PedSector trailing_meta_start, trailing_meta_end; +- struct fdasd_anchor anchor; + + PED_ASSERT (disk != NULL); + PED_ASSERT (disk->dev != NULL); +@@ -998,10 +997,7 @@ dasd_alloc_metadata (PedDisk* disk) + backed up, then restored to a larger size disk, etc. + */ + trailing_meta_start = part->geom.end + 1; +- fdasd_initialize_anchor(&anchor); +- fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd); + trailing_meta_end = (long long) disk->dev->length - 1; +- fdasd_cleanup(&anchor); + if (trailing_meta_end >= trailing_meta_start) { + new_part2 = ped_partition_new (disk,PED_PARTITION_METADATA, + NULL, trailing_meta_start, trailing_meta_end); +-- +2.5.5 + diff --git a/SOURCES/0037-libparted-Fix-probing-AIX-disks-on-other-arches.patch b/SOURCES/0037-libparted-Fix-probing-AIX-disks-on-other-arches.patch new file mode 100644 index 0000000..394d60b --- /dev/null +++ b/SOURCES/0037-libparted-Fix-probing-AIX-disks-on-other-arches.patch @@ -0,0 +1,56 @@ +From 85cec179048914d165e3a11b1d8d8c759725d236 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 6 May 2016 14:39:09 -0700 +Subject: [PATCH 37/38] libparted: Fix probing AIX disks on other arches + +Not a likely scenario, but make sure the magic check works everywhere. + +(cherry picked from commit 24cd71c0a7c4b2abdfff04be5a088a44ab5df2fe) +--- + libparted/labels/aix.c | 18 +++--------------- + 1 file changed, 3 insertions(+), 15 deletions(-) + +diff --git a/libparted/labels/aix.c b/libparted/labels/aix.c +index 0fa6fe7..a831d95 100644 +--- a/libparted/labels/aix.c ++++ b/libparted/labels/aix.c +@@ -34,23 +34,11 @@ + # define _(String) (String) + #endif /* ENABLE_NLS */ + +-#define AIX_LABEL_MAGIC 0xc9c2d4c1 ++#define AIX_LABEL_MAGIC (0xc9c2d4c1UL) + #define MAX_TOTAL_PART 16 + + static PedDiskType aix_disk_type; + +-static inline int +-aix_label_magic_get (const char *label) +-{ +- return *(unsigned int *)label; +-} +- +-static inline void +-aix_label_magic_set (char *label, int magic_val) +-{ +- *(unsigned int *)label = magic_val; +-} +- + static int + aix_probe (const PedDevice *dev) + { +@@ -59,9 +47,9 @@ aix_probe (const PedDevice *dev) + void *label; + if (!ptt_read_sector (dev, 0, &label)) + return 0; +- unsigned int magic = aix_label_magic_get (label); ++ bool found = PED_BE32_TO_CPU(*(uint32_t *)label) == AIX_LABEL_MAGIC; + free (label); +- return magic == AIX_LABEL_MAGIC; ++ return found; + } + + static PedDisk* +-- +2.5.5 + diff --git a/SOURCES/0038-partprobe-Open-the-device-once-for-probing.patch b/SOURCES/0038-partprobe-Open-the-device-once-for-probing.patch new file mode 100644 index 0000000..4cd4231 --- /dev/null +++ b/SOURCES/0038-partprobe-Open-the-device-once-for-probing.patch @@ -0,0 +1,43 @@ +From f3cbda4bf581b407586f24c980cf2e5a9cb2b4b2 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 25 May 2016 09:00:04 -0700 +Subject: [PATCH 38/38] partprobe: Open the device once for probing + +Previously there were 3 open/close pairs for the device, which may +result in triggering extra udev actions. Instead, open it once at the +start of process_dev and close it at the end. +--- + partprobe/partprobe.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/partprobe/partprobe.c b/partprobe/partprobe.c +index 34997fe..8f2190b 100644 +--- a/partprobe/partprobe.c ++++ b/partprobe/partprobe.c +@@ -105,6 +105,9 @@ process_dev (PedDevice* dev) + PedDiskType* disk_type; + PedDisk* disk; + ++ if (!ped_device_open (dev)) ++ return 0; ++ + disk_type = ped_disk_probe (dev); + if (!disk_type) { + /* Partition table not found, so create dummy, +@@ -128,11 +131,13 @@ process_dev (PedDevice* dev) + if (opt_summary) + summary (disk); + ped_disk_destroy (disk); ++ ped_device_close (dev); + return 1; + + error_destroy_disk: + ped_disk_destroy (disk); + error: ++ ped_device_close (dev); + return 0; + } + +-- +2.5.5 + diff --git a/SOURCES/0039-Cleanup-mkpart-manpage-entry-1183077.patch b/SOURCES/0039-Cleanup-mkpart-manpage-entry-1183077.patch new file mode 100644 index 0000000..e3798eb --- /dev/null +++ b/SOURCES/0039-Cleanup-mkpart-manpage-entry-1183077.patch @@ -0,0 +1,48 @@ +From a5a64f34ca3d64c4da04ed6e870d4c8e469c6098 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Thu, 5 Nov 2015 15:03:54 -0800 +Subject: [PATCH 39/40] Cleanup mkpart manpage entry (#1183077) + +(cherry picked from commit fa6cd8448f68e6661fb86a8331b44198edd02c9d) +--- + doc/C/parted.8 | 8 ++++---- + doc/parted.texi | 2 +- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/doc/C/parted.8 b/doc/C/parted.8 +index a45f42f..41baa1a 100644 +--- a/doc/C/parted.8 ++++ b/doc/C/parted.8 +@@ -73,12 +73,12 @@ Create a new disklabel (partition table) of \fIlabel-type\fP. \fIlabel-type\fP + should be one of "aix", "amiga", "bsd", "dvh", "gpt", "loop", "mac", "msdos", + "pc98", or "sun". + .TP +-.B mkpart \fIpart-type\fP \fI[fs-type]\fP \fIstart\fP \fIend\fP +-Make a \fIpart-type\fP partition for filesystem \fIfs-type\fP (if specified), +-beginning at \fIstart\fP and ending at \fIend\fP (by default in megabytes). ++.B mkpart [\fIpart-type\fP \fIname\fP \fIfs-type\fP] \fIstart\fP \fIend\fP ++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". +-\fIpart-type\fP should be one of "primary", "logical", or "extended". + .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/doc/parted.texi b/doc/parted.texi +index 07aa702..c727fb2 100644 +--- a/doc/parted.texi ++++ b/doc/parted.texi +@@ -550,7 +550,7 @@ PCs. + @cindex mkpart, command description + @cindex command description, mkpart + +-@deffn Command mkpart [@var{part-type} @var{fs-type} @var{name}] @var{start} @var{end} ++@deffn Command mkpart [@var{part-type} @var{name} @var{fs-type}] @var{start} @var{end} + + Creates a new partition, @emph{without} creating a new file system on + that partition. This is useful for creating partitions for file systems +-- +2.5.5 + diff --git a/SOURCES/0040-doc-Add-information-about-quoting.patch b/SOURCES/0040-doc-Add-information-about-quoting.patch new file mode 100644 index 0000000..a5ff968 --- /dev/null +++ b/SOURCES/0040-doc-Add-information-about-quoting.patch @@ -0,0 +1,49 @@ +From fd311a9367ec342b7d1fa5265f4d2167a29de30d Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 6 Nov 2015 08:56:45 -0800 +Subject: [PATCH 40/40] doc: Add information about quoting + +Some shells (bash) will strip off the " so it needs to be +wrapped in '' to prevent it. eg. + +parted -s ./disk.img mkpart '"EFI System Partition"' 1M 500M + +(cherry picked from commit 8d5e7329a6984614ac9951f376bc77ea7f822ca3) +--- + doc/C/parted.8 | 4 +++- + doc/parted.texi | 4 +++- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/doc/C/parted.8 b/doc/C/parted.8 +index 41baa1a..eb7cd98 100644 +--- a/doc/C/parted.8 ++++ b/doc/C/parted.8 +@@ -82,7 +82,9 @@ dvh partition tables, it should be one of "primary", "logical", or "extended". + .TP + .B name \fIpartition\fP \fIname\fP + Set the name of \fIpartition\fP to \fIname\fP. This option works only on Mac, +-PC98, and GPT disklabels. The name can be placed in quotes, if necessary. ++PC98, and GPT disklabels. The name can be placed in double quotes, if necessary. ++And depending on the shell may need to also be wrapped in single quotes so that ++the shell doesn't strip off the double quotes. + .TP + .B print + Display the partition table. +diff --git a/doc/parted.texi b/doc/parted.texi +index c727fb2..1b9c084 100644 +--- a/doc/parted.texi ++++ b/doc/parted.texi +@@ -628,7 +628,9 @@ $ @kbd{mkfs.vfat /dev/sdX2} + @deffn Command name @var{number} @var{name} + + Sets the name for the partition @var{number} (GPT, Mac, MIPS and PC98 only). +-The name can be placed in quotes. ++The name can be placed in quotes. And depending on the shell may need to also ++be wrapped in single quotes so that the shell doesn't strip off the double ++quotes. + + Example: + +-- +2.5.5 + diff --git a/SOURCES/0041-libparted-dasd-correct-the-offset-where-the-first-pa.patch b/SOURCES/0041-libparted-dasd-correct-the-offset-where-the-first-pa.patch new file mode 100644 index 0000000..c56f7f6 --- /dev/null +++ b/SOURCES/0041-libparted-dasd-correct-the-offset-where-the-first-pa.patch @@ -0,0 +1,54 @@ +From 40270928ff4ac2a87825f47e53c680ffb18b5bc4 Mon Sep 17 00:00:00 2001 +From: Wang Dong +Date: Tue, 14 Jun 2016 12:19:40 +0200 +Subject: [PATCH 41/53] libparted/dasd: correct the offset where the first + partition begins + +The start point of first partition must start at least from the third +track of DASD, due to the existence of metadata in the first two track. +The previous constraint just sets all the device to be partitioned. +So when the start point of the first partition start before the third +track, (For example if it starts from.0) parted will exit abruptly. +And this kind of job must be done with constraint explicitly. + +Then the constraint is modified to exclude the first two tracks and +to make the first partition start from the third track by default. + +Signed-off-by: Wang Dong +Reviewed-by: Viktor Mihajlovski +Signed-off-by: Hendrik Brueckner +Signed-off-by: Brian C. Lane +(cherry picked from commit 4126d0292c75cf7d50a2f4e9d485a52b5beafccc) +--- + libparted/labels/dasd.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c +index f79a867..4e68512 100644 +--- a/libparted/labels/dasd.c ++++ b/libparted/labels/dasd.c +@@ -829,6 +829,7 @@ _primary_constraint (PedDisk* disk) + PedSector sector_size; + LinuxSpecific* arch_specific; + DasdDiskSpecific* disk_specific; ++ PedSector start; + + PDEBUG; + +@@ -842,7 +843,12 @@ _primary_constraint (PedDisk* disk) + if (!ped_alignment_init (&end_align, -1, + disk->dev->hw_geom.sectors * sector_size)) + return NULL; +- if (!ped_geometry_init (&max_geom, disk->dev, 0, disk->dev->length)) ++ ++ start = (FIRST_USABLE_TRK * (long long) disk->dev->hw_geom.sectors ++ * (long long) arch_specific->real_sector_size ++ / (long long) disk->dev->sector_size); ++ ++ if (!ped_geometry_init (&max_geom, disk->dev, start, disk->dev->length)) + return NULL; + + return ped_constraint_new(&start_align, &end_align, &max_geom, +-- +2.7.4 + diff --git a/SOURCES/0042-Add-support-for-NVMe-devices.patch b/SOURCES/0042-Add-support-for-NVMe-devices.patch new file mode 100644 index 0000000..0abce18 --- /dev/null +++ b/SOURCES/0042-Add-support-for-NVMe-devices.patch @@ -0,0 +1,105 @@ +From 797d7b90c677e49552fbe7c526ce849b964e1ffe Mon Sep 17 00:00:00 2001 +From: Petr Uzel +Date: Tue, 14 Jun 2016 13:17:00 +0200 +Subject: [PATCH 42/53] Add support for NVMe devices + +Recognize NVMe Devices, so "parted -s /dev/nvme0n1" now prints +"NVMe Device (nvme)" instead of "Model: Unknown (unknown)". + +In order for a device to be recognized as NVMe, it has to +have a 'blkext' major number. But since this major can be +used also by other device types, we also check the device +path contains 'nvme' as a substring. + +* NEWS: Mention the change +* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_NVME +* libparted/arch/linux.c(BLKEXT_MAJOR): New define. +* libparted/arch/linux.c(_is_blkext_major): New function. +* libparted/arch/linux.c(_device_probe_type): Recognize NVMe devices. +* libparted/arch/linux.c(linux_new): Handle NVMe devices. +* parted/parted.c(do_print): Add "nvme" to list of transports. + +Signed-off-by: Brian C. Lane +(cherry picked from commit e4ae4330f3e33201aeeed3b7ca88e15d98d03e13) +--- + include/parted/device.in.h | 3 ++- + libparted/arch/linux.c | 14 ++++++++++++++ + parted/parted.c | 2 +- + 3 files changed, 17 insertions(+), 2 deletions(-) + +diff --git a/include/parted/device.in.h b/include/parted/device.in.h +index 82d4104..d38db44 100644 +--- a/include/parted/device.in.h ++++ b/include/parted/device.in.h +@@ -49,7 +49,8 @@ typedef enum { + PED_DEVICE_VIRTBLK = 15, + PED_DEVICE_AOE = 16, + PED_DEVICE_MD = 17, +- PED_DEVICE_LOOP = 18 ++ PED_DEVICE_LOOP = 18, ++ PED_DEVICE_NVME = 19 + } PedDeviceType; + + typedef struct _PedDevice PedDevice; +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index eb01deb..b7ba5de 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -278,6 +278,7 @@ struct blkdev_ioctl_param { + #define SDMMC_MAJOR 179 + #define LOOP_MAJOR 7 + #define MD_MAJOR 9 ++#define BLKEXT_MAJOR 259 + + #define SCSI_BLK_MAJOR(M) ( \ + (M) == SCSI_DISK0_MAJOR \ +@@ -441,6 +442,12 @@ _is_virtblk_major (int major) + return _major_type_in_devices (major, "virtblk"); + } + ++static int ++_is_blkext_major (int major) ++{ ++ return _major_type_in_devices (major, "blkext"); ++} ++ + #ifdef ENABLE_DEVICE_MAPPER + static int + _dm_task_run_wait (struct dm_task *task, uint32_t cookie) +@@ -692,6 +699,8 @@ _device_probe_type (PedDevice* dev) + dev->type = PED_DEVICE_LOOP; + } else if (dev_major == MD_MAJOR) { + dev->type = PED_DEVICE_MD; ++ } else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "nvme")) { ++ dev->type = PED_DEVICE_NVME; + } else { + dev->type = PED_DEVICE_UNKNOWN; + } +@@ -1465,6 +1474,11 @@ linux_new (const char* path) + goto error_free_arch_specific; + break; + ++ case PED_DEVICE_NVME: ++ if (!init_generic (dev, _("NVMe 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 06f9971..bd848c3 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -979,7 +979,7 @@ _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"}; ++ "md", "loopback", "nvme"}; + + char* start = ped_unit_format (dev, 0); + PedUnit default_unit = ped_unit_get_default (); +-- +2.7.4 + diff --git a/SOURCES/0043-docs-Improve-partition-description-in-parted.texi.patch b/SOURCES/0043-docs-Improve-partition-description-in-parted.texi.patch new file mode 100644 index 0000000..30052d5 --- /dev/null +++ b/SOURCES/0043-docs-Improve-partition-description-in-parted.texi.patch @@ -0,0 +1,61 @@ +From 22a2fd360f5f0f8e7e522712a6187b1c6ac74ba7 Mon Sep 17 00:00:00 2001 +From: Gareth Randall +Date: Fri, 30 Sep 2016 10:07:42 -0700 +Subject: [PATCH 43/53] docs: Improve partition description in parted.texi + +(cherry picked from commit e27ac8ff6706f67817f68246311899bd920b9c88) +--- + doc/parted.texi | 36 +++++++++++++++++++++++++++++++----- + 1 file changed, 31 insertions(+), 5 deletions(-) + +diff --git a/doc/parted.texi b/doc/parted.texi +index 1b9c084..414179d 100644 +--- a/doc/parted.texi ++++ b/doc/parted.texi +@@ -291,12 +291,38 @@ or you want to modify a root or boot partition, use GParted Live: + @section Introduction to Partitioning + @cindex partitioning overview + +-Unfortunately, partitioning your disk is rather complicated. This is +-because there are interactions between many different systems that need +-to be taken into consideration. ++Partitioning is the process of dividing a storage device into local ++sections, called partitions, which help organize multiple filesystems ++and their associated operating systems. ++ ++A storage device presents itself as a sequence of bytes, numbered ++starting from zero and increasing until the maximum capacity of the ++device is reached. Bytes are normally read and written a sector at a ++time, rather than individually. Each sector contains a fixed number ++of bytes, with the number determined by the device. ++ ++@example +++------------------------------------------------------------+ ++| storage device with no partitions | +++------------------------------------------------------------+ ++0 start end ++@end example ++ ++In order to store multiple filesystems, a storage device can be divided ++up in to multiple partitions. Each partition can be thought of as an ++area which contains a real filesystem inside of it. To show where these ++partitions are on the device a small table is written at the start, ++shown as PT in the diagram below. This table is called a partition ++table, or disklabel, and also stores the type of each partition and ++some flags. ++ ++@example +++--+---------------+----------------+------------------------+ ++|PT| Partition 1 | Partition 2 | Partition 3 | +++--+---------------+----------------+------------------------+ ++0 start end ++@end example + +-This manual used to introduce the reader to these systems and their +-working. This content has moved to the GNU Storage Guide. + + @node Running Parted + @section Using GNU Parted +-- +2.7.4 + diff --git a/SOURCES/0044-libparted-only-IEC-units-are-treated-as-exact.patch b/SOURCES/0044-libparted-only-IEC-units-are-treated-as-exact.patch new file mode 100644 index 0000000..cdf1084 --- /dev/null +++ b/SOURCES/0044-libparted-only-IEC-units-are-treated-as-exact.patch @@ -0,0 +1,82 @@ +From e4bf9b823452c0b98b394b8abcc67f887b6991b3 Mon Sep 17 00:00:00 2001 +From: Petr Uzel +Date: Thu, 21 Jul 2016 16:46:46 +0200 +Subject: [PATCH 44/53] libparted: only IEC units are treated as exact + +If the user specifies start/end of the partition as a unit, +whose size happens to be power of two, we treat that as +exact address with exact placement. + +Recently, commit 01900e056ec25083 added an exception for +percent units. + +This logic however can fail also for cylinders, e.g. on DASD FBA disks, +which report CHS=(*, 128, 16) geometry, hence once cylinder is 1 MiB. +With cylinders as units, exact placement is not what the user wants. + +Instead of adding cylinders to the blacklist, let's instead +whitelist units which should trigger exact placement. + +* libparted/unit.c (is_power_of_2): Remove now unused function. +(ped_unit_parse_custom): Specify which units trigger exact placement. +* NEWS (Bug Fixes): Mention this. + +(cherry picked from commit f4f38082fc4dbf0c28ccc7613c672fe279d3032e) +--- + libparted/unit.c | 33 +++++++++++++++++---------------- + 1 file changed, 17 insertions(+), 16 deletions(-) + +diff --git a/libparted/unit.c b/libparted/unit.c +index dddb5db..e47e868 100644 +--- a/libparted/unit.c ++++ b/libparted/unit.c +@@ -481,12 +481,6 @@ parse_unit_suffix (const char* suffix, PedUnit suggested_unit) + return suggested_unit; + } + +-static bool +-is_power_of_2 (long long n) +-{ +- return (n & (n - 1)) == 0; +-} +- + /** + * If \p str contains a valid description of a location on \p dev, then + * \p *sector is modified to describe the location and a geometry is created +@@ -540,16 +534,23 @@ ped_unit_parse_custom (const char* str, const PedDevice* dev, PedUnit unit, + } + + unit_size = ped_unit_get_size (dev, unit); +- radius = (ped_div_round_up (unit_size, dev->sector_size) / 2) - 1; +- if (radius < 0) +- radius = 0; +- /* If the user specifies units in a power of 2, e.g., 4MiB, as in +- parted -s -- $dev mklabel gpt mkpart P-NAME 4MiB -34s +- do not use 4MiB as the range. Rather, presume that they +- are specifying precisely the starting or ending number, +- and treat "4MiB" just as we would treat "4194304B". */ +- if (is_power_of_2 (unit_size) && unit != PED_UNIT_PERCENT) +- radius = 0; ++ switch (unit) { ++ /* If the user specifies the address using IEC units e.g., 4MiB, as in ++ parted -s -- $dev mklabel gpt mkpart P-NAME 4MiB -34s ++ do not use size of the unit as the range. Rather, presume that they ++ are specifying precisely the starting or ending number, ++ and treat "4MiB" just as we would treat "4194304B". */ ++ case PED_UNIT_KIBIBYTE: ++ case PED_UNIT_MEBIBYTE: ++ case PED_UNIT_GIBIBYTE: ++ case PED_UNIT_TEBIBYTE: ++ radius = 0; ++ break; ++ default: ++ radius = (ped_div_round_up (unit_size, dev->sector_size) / 2) - 1; ++ if (radius < 0) ++ radius = 0; ++ } + + *sector = num * unit_size / dev->sector_size; + /* negative numbers count from the end */ +-- +2.7.4 + diff --git a/SOURCES/0045-tests-t3310-flags.sh-Query-libparted-for-all-flags-t.patch b/SOURCES/0045-tests-t3310-flags.sh-Query-libparted-for-all-flags-t.patch new file mode 100644 index 0000000..9fa912c --- /dev/null +++ b/SOURCES/0045-tests-t3310-flags.sh-Query-libparted-for-all-flags-t.patch @@ -0,0 +1,188 @@ +From 450dbead63306b242e8159c85641698bddf6d19e Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sat, 1 Oct 2016 16:40:16 +0100 +Subject: [PATCH 45/53] tests: t3310-flags.sh: Query libparted for all flags to + be tested + +Replace scanning the documentation for an incomplete list of flags with +querying libparted for the complete list of supported flags via the +added helper print-flags. + +Correct $ME -> $ME_ in the warning messages. Improve the warning +messages by including the table type and flag name not correctly set or +cleared. + +Plus minor changes: +(1) use slightly longer variable name primary_or_name; +(2) use longer test partition name PTNNAME; and +(3) stop shortening parted unit command to u. + +Signed-off-by: Brian C. Lane +--- + tests/Makefile.am | 3 ++- + tests/print-flags.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + tests/t3310-flags.sh | 32 ++++++++++++++++-------------- + 3 files changed, 75 insertions(+), 16 deletions(-) + create mode 100644 tests/print-flags.c + +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 6a06dce..a840304 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -92,7 +92,8 @@ EXTRA_DIST = \ + init.cfg init.sh t-lib-helpers.sh gpt-header-munge \ + gpt-header-move msdos-overlap + +-check_PROGRAMS = print-align print-max dup-clobber duplicate fs-resize ++check_PROGRAMS = print-align print-flags print-max dup-clobber duplicate \ ++ fs-resize + fs_resize_LDADD = \ + $(top_builddir)/libparted/fs/libparted-fs-resize.la \ + $(top_builddir)/libparted/libparted.la +diff --git a/tests/print-flags.c b/tests/print-flags.c +new file mode 100644 +index 0000000..3176ca6 +--- /dev/null ++++ b/tests/print-flags.c +@@ -0,0 +1,56 @@ ++/* Print the available flags for a particular partition. */ ++ ++#include ++#include ++#include ++#include ++#include "progname.h" ++ ++int ++main (int argc, char **argv) ++{ ++ PedDevice *dev; ++ PedDisk *disk; ++ PedPartition *part; ++ ++ set_program_name (argv[0]); ++ ++ if (argc != 2 ) { ++ fprintf (stderr, "Usage: %s \n", argv[0]); ++ return EXIT_FAILURE; ++ } ++ ++ dev = ped_device_get(argv[1]); ++ if (!dev) { ++ fprintf (stderr, "Error: failed to create device %s\n", ++ argv[1]); ++ return EXIT_FAILURE; ++ } ++ if (!ped_device_open (dev)) { ++ fprintf (stderr, "Error: failed to open device %s\n", argv[1]); ++ return EXIT_FAILURE; ++ } ++ disk = ped_disk_new (dev); ++ if (!disk) { ++ fprintf (stderr, ++ "Error: failed to read partition table from device %s\n", ++ argv[1]); ++ return EXIT_FAILURE; ++ } ++ ++ part = ped_disk_get_partition (disk, 1); ++ if (!part) { ++ fprintf (stderr, ++ "Error: failed to get partition 1 from device %s\n", ++ argv[1]); ++ return EXIT_FAILURE; ++ } ++ ++ for (PedPartitionFlag flag = PED_PARTITION_FIRST_FLAG; ++ flag <= PED_PARTITION_LAST_FLAG; flag++) ++ { ++ if (ped_partition_is_flag_available (part, flag)) ++ puts (ped_partition_flag_get_name (flag)); ++ } ++ return EXIT_SUCCESS; ++} +diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh +index cb3024a..85a673a 100644 +--- a/tests/t3310-flags.sh ++++ b/tests/t3310-flags.sh +@@ -1,5 +1,5 @@ + #!/bin/sh +-# Exercise the exclusive, single-bit flags. ++# Exercise partition flags. + + # Copyright (C) 2010-2014 Free Software Foundation, Inc. + +@@ -16,35 +16,37 @@ + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + +-. "${srcdir=.}/init.sh"; path_prepend_ ../parted ++. "${srcdir=.}/init.sh"; path_prepend_ ../parted . + ss=$sector_size_ + dev=dev-file + + extract_flags() + { +- perl -nle '/^1:2048s:4095s:2048s::(?:P1)?:(.+);$/ and print $1' "$@" ++ perl -nle '/^1:2048s:4095s:2048s::(?:PTNNAME)?:(.+);$/ and print $1' "$@" + } + + for table_type in msdos gpt; do + +- # Extract flag names of type $table_type from the texinfo documentation. + case $table_type in +- msdos) search_term=MS-DOS; pri_or_name=pri;; +- gpt) search_term=GPT; pri_or_name=P1;; ++ gpt) primary_or_name='PTNNAME' ++ ;; ++ msdos) primary_or_name='primary' ++ ;; + esac +- flags=$(sed -n '/^@node set/,/^@node/p' \ +- "$abs_top_srcdir/doc/parted.texi" \ +- | perl -00 -ne \ +- '/^\@item (\w+).*'"$search_term"'/s and print lc($1), "\n"') + + n_sectors=5000 + dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1 + + parted -s $dev mklabel $table_type \ +- mkpart $pri_or_name ext2 $((1*2048))s $((2*2048-1))s \ ++ mkpart $primary_or_name ext2 $((1*2048))s $((2*2048-1))s \ + > out 2> err || fail=1 + compare /dev/null out || fail=1 + ++ # Query libparted for the available flags for this test partition. ++ flags=`print-flags $dev` \ ++ || { warn_ "$ME_: $table_type: failed to get available flags"; ++ fail=1; continue; } ++ + for mode in on_only on_and_off ; do + for flag in $flags; do + +@@ -53,18 +55,18 @@ for table_type in msdos gpt; do + case $flag in boot|lba|hidden) continue;; esac + + # Turn on each flag, one at a time. +- parted -m -s $dev set 1 $flag on u s print > raw 2> err || fail=1 ++ parted -m -s $dev set 1 $flag on unit s print > raw 2> err || fail=1 + extract_flags raw > out + grep -F "$flag" out \ +- || { warn_ "$ME: flag not turned on: $(cat out)"; fail=1; } ++ || { warn_ "$ME_: $table_type: flag '$flag' not turned on: $(cat out)"; fail=1; } + compare /dev/null err || fail=1 + + if test $mode = on_and_off; then + # Turn it off +- parted -m -s $dev set 1 $flag off u s print > raw 2> err || fail=1 ++ parted -m -s $dev set 1 $flag off unit s print > raw 2> err || fail=1 + extract_flags raw > out + grep -F "$flag" out \ +- && { warn_ "$ME: flag not turned off: $(cat out)"; fail=1; } ++ && { warn_ "$ME_: $table_type: flag '$flag' not turned off: $(cat out)"; fail=1; } + compare /dev/null err || fail=1 + fi + done +-- +2.7.4 + diff --git a/SOURCES/0046-tests-t3310-flags.sh-Stop-excluding-certain-flags-fr.patch b/SOURCES/0046-tests-t3310-flags.sh-Stop-excluding-certain-flags-fr.patch new file mode 100644 index 0000000..e5be802 --- /dev/null +++ b/SOURCES/0046-tests-t3310-flags.sh-Stop-excluding-certain-flags-fr.patch @@ -0,0 +1,47 @@ +From cfcfadac1d61093f900d1903f580818d244479ad Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sat, 1 Oct 2016 16:40:17 +0100 +Subject: [PATCH 46/53] tests: t3310-flags.sh: Stop excluding certain flags + from being tested + +Also grep for whole words, grep -w, to avoid flag 'boot' being matched +as a substring of flag 'legacy_boot'. + +Signed-off-by: Brian C. Lane +--- + tests/t3310-flags.sh | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh +index 85a673a..5cbf2da 100644 +--- a/tests/t3310-flags.sh ++++ b/tests/t3310-flags.sh +@@ -49,15 +49,10 @@ for table_type in msdos gpt; do + + for mode in on_only on_and_off ; do + for flag in $flags; do +- +- # Exclude the supplemental flags. +- # These are not boolean, like the others. +- case $flag in boot|lba|hidden) continue;; esac +- + # Turn on each flag, one at a time. + parted -m -s $dev set 1 $flag on unit s print > raw 2> err || fail=1 + extract_flags raw > out +- grep -F "$flag" out \ ++ grep -w "$flag" out \ + || { warn_ "$ME_: $table_type: flag '$flag' not turned on: $(cat out)"; fail=1; } + compare /dev/null err || fail=1 + +@@ -65,7 +60,7 @@ for table_type in msdos gpt; do + # Turn it off + parted -m -s $dev set 1 $flag off unit s print > raw 2> err || fail=1 + extract_flags raw > out +- grep -F "$flag" out \ ++ grep -w "$flag" out \ + && { warn_ "$ME_: $table_type: flag '$flag' not turned off: $(cat out)"; fail=1; } + compare /dev/null err || fail=1 + fi +-- +2.7.4 + diff --git a/SOURCES/0047-tests-t3310-flags.sh-Add-test-for-bsd-table-flags.patch b/SOURCES/0047-tests-t3310-flags.sh-Add-test-for-bsd-table-flags.patch new file mode 100644 index 0000000..df52fe2 --- /dev/null +++ b/SOURCES/0047-tests-t3310-flags.sh-Add-test-for-bsd-table-flags.patch @@ -0,0 +1,30 @@ +From d7bcb49f1313da7deae0ca41ab402980fb3094a4 Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sat, 1 Oct 2016 16:40:18 +0100 +Subject: [PATCH 47/53] tests: t3310-flags.sh: Add test for bsd table flags + +Signed-off-by: Brian C. Lane +--- + tests/t3310-flags.sh | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh +index 5cbf2da..3f80213 100644 +--- a/tests/t3310-flags.sh ++++ b/tests/t3310-flags.sh +@@ -25,9 +25,11 @@ extract_flags() + perl -nle '/^1:2048s:4095s:2048s::(?:PTNNAME)?:(.+);$/ and print $1' "$@" + } + +-for table_type in msdos gpt; do ++for table_type in bsd gpt msdos; do + + case $table_type in ++ bsd) primary_or_name='' ++ ;; + gpt) primary_or_name='PTNNAME' + ;; + msdos) primary_or_name='primary' +-- +2.7.4 + diff --git a/SOURCES/0048-libparted-Fix-to-report-success-when-setting-lvm-fla.patch b/SOURCES/0048-libparted-Fix-to-report-success-when-setting-lvm-fla.patch new file mode 100644 index 0000000..f66d772 --- /dev/null +++ b/SOURCES/0048-libparted-Fix-to-report-success-when-setting-lvm-fla.patch @@ -0,0 +1,33 @@ +From fa15f7d65ad76872f9019f34dd2a1db0f678b0f9 Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sat, 1 Oct 2016 16:40:19 +0100 +Subject: [PATCH 48/53] libparted: Fix to report success when setting lvm flag + on bsd table + +bsd_partition_set_flag() was falling through in the lvm flag case and +returning failure. Fix this by adding missing return 1 (success) like +for the other flags. + +Found as a result of this bug reported by Timo Riikonen: +https://bugzilla.gnome.org/show_bug.cgi?id=769831 + +Signed-off-by: Brian C. Lane +--- + libparted/labels/bsd.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libparted/labels/bsd.c b/libparted/labels/bsd.c +index a8525a4..23daea8 100644 +--- a/libparted/labels/bsd.c ++++ b/libparted/labels/bsd.c +@@ -488,6 +488,7 @@ bsd_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state) + bsd_data->raid = 0; + } + bsd_data->lvm = state; ++ return 1; + default: + ; + } +-- +2.7.4 + diff --git a/SOURCES/0049-libparted-Remove-commented-local-variable-from-bsd_p.patch b/SOURCES/0049-libparted-Remove-commented-local-variable-from-bsd_p.patch new file mode 100644 index 0000000..da4e9bd --- /dev/null +++ b/SOURCES/0049-libparted-Remove-commented-local-variable-from-bsd_p.patch @@ -0,0 +1,26 @@ +From fe6d1478172071779135001e494afffb993a9068 Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sat, 1 Oct 2016 16:40:20 +0100 +Subject: [PATCH 49/53] libparted: Remove commented local variable from + bsd_partition_set_flag() + +Signed-off-by: Brian C. Lane +--- + libparted/labels/bsd.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/libparted/labels/bsd.c b/libparted/labels/bsd.c +index 23daea8..f253a32 100644 +--- a/libparted/labels/bsd.c ++++ b/libparted/labels/bsd.c +@@ -464,7 +464,6 @@ bsd_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type) + static int + bsd_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state) + { +-// PedPartition* walk; // since -Werror, this unused variable would break build + BSDPartitionData* bsd_data; + + PED_ASSERT (part != NULL); +-- +2.7.4 + diff --git a/SOURCES/0050-tests-t3310-flags.sh-Add-test-for-mac-table-flags.patch b/SOURCES/0050-tests-t3310-flags.sh-Add-test-for-mac-table-flags.patch new file mode 100644 index 0000000..c57e935 --- /dev/null +++ b/SOURCES/0050-tests-t3310-flags.sh-Add-test-for-mac-table-flags.patch @@ -0,0 +1,126 @@ +From 81b397bbc9eb270ef0b3ed52d40c3a76ecd9ac80 Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sat, 1 Oct 2016 16:40:21 +0100 +Subject: [PATCH 50/53] tests: t3310-flags.sh: Add test for mac table flags + +MAC partition table reserves partition 1 for the partition map +partition, so the created test partition will be number 2. Adapt +accordingly. + +Setting flags 'root' and 'swap' also sets the partition name to 'root' +and 'swap' respectively, so no longer match the partition name in +extract_flags(). + +Don't test lvm and raid flags as they fail to be cleared with a single +set off command. See FIXME comment in the test for more details. + +Signed-off-by: Brian C. Lane +--- + tests/print-flags.c | 12 +++++++----- + tests/t3310-flags.sh | 27 ++++++++++++++++++++++----- + 2 files changed, 29 insertions(+), 10 deletions(-) + +diff --git a/tests/print-flags.c b/tests/print-flags.c +index 3176ca6..db088e8 100644 +--- a/tests/print-flags.c ++++ b/tests/print-flags.c +@@ -12,11 +12,12 @@ main (int argc, char **argv) + PedDevice *dev; + PedDisk *disk; + PedPartition *part; ++ int partnum; + + set_program_name (argv[0]); + +- if (argc != 2 ) { +- fprintf (stderr, "Usage: %s \n", argv[0]); ++ if (argc != 3 ) { ++ fprintf (stderr, "Usage: %s \n", argv[0]); + return EXIT_FAILURE; + } + +@@ -38,11 +39,12 @@ main (int argc, char **argv) + return EXIT_FAILURE; + } + +- part = ped_disk_get_partition (disk, 1); ++ partnum = atoi (argv[2]); ++ part = ped_disk_get_partition (disk, partnum); + if (!part) { + fprintf (stderr, +- "Error: failed to get partition 1 from device %s\n", +- argv[1]); ++ "Error: failed to get partition %d from device %s\n", ++ partnum, argv[1]); + return EXIT_FAILURE; + } + +diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh +index 3f80213..672160d 100644 +--- a/tests/t3310-flags.sh ++++ b/tests/t3310-flags.sh +@@ -22,16 +22,22 @@ dev=dev-file + + extract_flags() + { +- perl -nle '/^1:2048s:4095s:2048s::(?:PTNNAME)?:(.+);$/ and print $1' "$@" ++ perl -nle '/^[^:]*:2048s:4095s:2048s::[^:]*:(.+);$/ and print $1' "$@" + } + +-for table_type in bsd gpt msdos; do ++for table_type in bsd gpt mac msdos; do ++ ptn_num=1 + + case $table_type in + bsd) primary_or_name='' + ;; + gpt) primary_or_name='PTNNAME' + ;; ++ mac) primary_or_name='PTNNAME' ++ # MAC table has the partition map partition as the first ++ # partition so the created test partition will be number 2. ++ ptn_num=2 ++ ;; + msdos) primary_or_name='primary' + ;; + esac +@@ -45,14 +51,25 @@ for table_type in bsd gpt msdos; do + compare /dev/null out || fail=1 + + # Query libparted for the available flags for this test partition. +- flags=`print-flags $dev` \ ++ flags=`print-flags $dev $ptn_num` \ + || { warn_ "$ME_: $table_type: failed to get available flags"; + fail=1; continue; } ++ case $table_type in ++ mac) # FIXME: Setting root or swap flags also sets the partition ++ # name to root or swap respectively. Probably intended ++ # behaviour. Setting lvm or raid flags after root or swap ++ # takes two goes to clear the lvm or raid flag. Is this ++ # intended? For now don't test lvm or raid flags as this ++ # test only tries to clear the flags once which causes this ++ # test to fail. ++ flags=`echo "$flags" | egrep -v 'lvm|raid'` ++ ;; ++ esac + + for mode in on_only on_and_off ; do + for flag in $flags; do + # Turn on each flag, one at a time. +- parted -m -s $dev set 1 $flag on unit s print > raw 2> err || fail=1 ++ parted -m -s $dev set $ptn_num $flag on unit s print > raw 2> err || fail=1 + extract_flags raw > out + grep -w "$flag" out \ + || { warn_ "$ME_: $table_type: flag '$flag' not turned on: $(cat out)"; fail=1; } +@@ -60,7 +77,7 @@ for table_type in bsd gpt msdos; do + + if test $mode = on_and_off; then + # Turn it off +- parted -m -s $dev set 1 $flag off unit s print > raw 2> err || fail=1 ++ parted -m -s $dev set $ptn_num $flag off unit s print > raw 2> err || fail=1 + extract_flags raw > out + grep -w "$flag" out \ + && { warn_ "$ME_: $table_type: flag '$flag' not turned off: $(cat out)"; fail=1; } +-- +2.7.4 + diff --git a/SOURCES/0051-tests-t3310-flags.sh-Add-test-for-dvh-table-flags.patch b/SOURCES/0051-tests-t3310-flags.sh-Add-test-for-dvh-table-flags.patch new file mode 100644 index 0000000..a92a5a2 --- /dev/null +++ b/SOURCES/0051-tests-t3310-flags.sh-Add-test-for-dvh-table-flags.patch @@ -0,0 +1,69 @@ +From 797dbba3bb86178e17ccac46d3619936f75df1d4 Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sat, 1 Oct 2016 16:40:22 +0100 +Subject: [PATCH 51/53] tests: t3310-flags.sh: Add test for dvh table flags + +DVH table reserves the first 4 MiB for the volume header information so +move the created test partition to immediately after that. + +Exclude testing the boot flag as that can only be set on logical +partitions and this test script only uses primary partitions so far. + +Signed-off-by: Brian C. Lane +--- + tests/t3310-flags.sh | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh +index 672160d..e449589 100644 +--- a/tests/t3310-flags.sh ++++ b/tests/t3310-flags.sh +@@ -22,15 +22,17 @@ dev=dev-file + + extract_flags() + { +- perl -nle '/^[^:]*:2048s:4095s:2048s::[^:]*:(.+);$/ and print $1' "$@" ++ perl -nle '/^[^:]*:4096s:6143s:2048s::[^:]*:(.+);$/ and print $1' "$@" + } + +-for table_type in bsd gpt mac msdos; do ++for table_type in bsd dvh gpt mac msdos; do + ptn_num=1 + + case $table_type in + bsd) primary_or_name='' + ;; ++ dvh) primary_or_name='primary' ++ ;; + gpt) primary_or_name='PTNNAME' + ;; + mac) primary_or_name='PTNNAME' +@@ -42,11 +44,11 @@ for table_type in bsd gpt mac msdos; do + ;; + esac + +- n_sectors=5000 ++ n_sectors=8192 + dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1 + + parted -s $dev mklabel $table_type \ +- mkpart $primary_or_name ext2 $((1*2048))s $((2*2048-1))s \ ++ mkpart $primary_or_name ext2 $((4*1024))s $((6*1024-1))s \ + > out 2> err || fail=1 + compare /dev/null out || fail=1 + +@@ -55,6 +57,11 @@ for table_type in bsd gpt mac msdos; do + || { warn_ "$ME_: $table_type: failed to get available flags"; + fail=1; continue; } + case $table_type in ++ dvh) # FIXME: Exclude boot flag as that can only be set on logical ++ # partitions in the DVH disk label and this test only uses ++ # primary partitions. ++ flags=`echo "$flags" | egrep -v 'boot'` ++ ;; + mac) # FIXME: Setting root or swap flags also sets the partition + # name to root or swap respectively. Probably intended + # behaviour. Setting lvm or raid flags after root or swap +-- +2.7.4 + diff --git a/SOURCES/0052-tests-t3310-flags.sh-Add-tests-for-remaining-table-t.patch b/SOURCES/0052-tests-t3310-flags.sh-Add-tests-for-remaining-table-t.patch new file mode 100644 index 0000000..a2b5051 --- /dev/null +++ b/SOURCES/0052-tests-t3310-flags.sh-Add-tests-for-remaining-table-t.patch @@ -0,0 +1,55 @@ +From 1bd5c463377b0e54dc3bed840906a8df37bf6f7e Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +Date: Sat, 1 Oct 2016 16:40:23 +0100 +Subject: [PATCH 52/53] tests: t3310-flags.sh: Add tests for remaining table + types + +Add test of flags for remaining table types: aix, amiga, pc98, sun and +loop. Note that support of writing AIX tables is not yet implemented in +parted and LOOP tables don't support partitions nor flags. + +Signed-off-by: Brian C. Lane +--- + tests/t3310-flags.sh | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh +index e449589..e97c3b9 100644 +--- a/tests/t3310-flags.sh ++++ b/tests/t3310-flags.sh +@@ -25,10 +25,16 @@ extract_flags() + perl -nle '/^[^:]*:4096s:6143s:2048s::[^:]*:(.+);$/ and print $1' "$@" + } + +-for table_type in bsd dvh gpt mac msdos; do ++for table_type in aix amiga bsd dvh gpt mac msdos pc98 sun loop; do + ptn_num=1 + + case $table_type in ++ aix) # Support for writing AIX disk labels and adding partitions ++ # is not yet implemented. ++ continue ++ ;; ++ amiga) primary_or_name='PTNNAME' ++ ;; + bsd) primary_or_name='' + ;; + dvh) primary_or_name='primary' +@@ -42,6 +48,14 @@ for table_type in bsd dvh gpt mac msdos; do + ;; + msdos) primary_or_name='primary' + ;; ++ pc98) primary_or_name='PTNNAME' ++ ;; ++ sun) primary_or_name='' ++ ;; ++ loop) # LOOP table doesn't support creation of a partition nor any ++ # flags. ++ continue ++ ;; + esac + + n_sectors=8192 +-- +2.7.4 + diff --git a/SOURCES/0053-tests-Set-optimal-blocks-to-64-for-scsi_debug-device.patch b/SOURCES/0053-tests-Set-optimal-blocks-to-64-for-scsi_debug-device.patch new file mode 100644 index 0000000..eeee176 --- /dev/null +++ b/SOURCES/0053-tests-Set-optimal-blocks-to-64-for-scsi_debug-device.patch @@ -0,0 +1,31 @@ +From a5f1b41b0a10fc1dc64f17b677ddf14e15f8d40e Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Tue, 23 Aug 2016 08:55:18 -0700 +Subject: [PATCH 53/53] tests: Set optimal blocks to 64 for scsi_debug devices + +The Linux kernel 4.5 changed the optimal blocks count from 64 to 1024 +This causes tests using scsi_debug devices to fail because of alignment +issues. Set the opt_blks to 64 so that we have consistent behavior +across kernels. + +(cherry picked from commit bd2664285e4014d2d4c80cee3e87609272e1fca9) +--- + tests/t-local.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/t-local.sh b/tests/t-local.sh +index a7d5226..13073d2 100644 +--- a/tests/t-local.sh ++++ b/tests/t-local.sh +@@ -98,7 +98,7 @@ scsi_debug_setup_() + # It is not trivial to determine the name of the device we're creating. + # Record the names of all /sys/block/sd* devices *before* probing: + touch stamp +- modprobe scsi_debug "$@" || { rm -f stamp; return 1; } ++ modprobe scsi_debug opt_blks=64 "$@" || { rm -f stamp; return 1; } + scsi_debug_modprobe_succeeded_=1 + test "$VERBOSE" = yes \ + && echo $ME_ modprobe scsi_debug succeeded 1>&2 +-- +2.7.4 + diff --git a/SOURCES/0054-tests-t3310-flags.sh-skip-pc98-when-sector-size-512.patch b/SOURCES/0054-tests-t3310-flags.sh-skip-pc98-when-sector-size-512.patch new file mode 100644 index 0000000..5b993e3 --- /dev/null +++ b/SOURCES/0054-tests-t3310-flags.sh-skip-pc98-when-sector-size-512.patch @@ -0,0 +1,25 @@ +From a6ba22e539ae5836326703cf4e6d549f6628b861 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Tue, 4 Oct 2016 16:11:25 -0700 +Subject: [PATCH] tests: t3310-flags.sh skip pc98 when sector size != 512 + +--- + tests/t3310-flags.sh | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh +index e97c3b9..10ac50d 100644 +--- a/tests/t3310-flags.sh ++++ b/tests/t3310-flags.sh +@@ -49,6 +49,8 @@ for table_type in aix amiga bsd dvh gpt mac msdos pc98 sun loop; do + msdos) primary_or_name='primary' + ;; + pc98) primary_or_name='PTNNAME' ++ # pc98 only supports 512b sectors ++ [ $ss -ne 512 ] && continue + ;; + sun) primary_or_name='' + ;; +-- +2.7.4 + diff --git a/SOURCES/0055-tests-Stop-timing-t9040-1172675.patch b/SOURCES/0055-tests-Stop-timing-t9040-1172675.patch new file mode 100644 index 0000000..6d35543 --- /dev/null +++ b/SOURCES/0055-tests-Stop-timing-t9040-1172675.patch @@ -0,0 +1,46 @@ +From 582d7cddcda260684d2bca7265294dc651bcb091 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 29 Feb 2016 16:54:05 -0800 +Subject: [PATCH 55/75] tests: Stop timing t9040 (#1172675) + +parted doesn't have any control over how long this takes, there is no +reason to consider this a parted bug if it takes longer than expected. + +Resolves: rhbz#1172675 +(cherry picked from commit fdd2e12b504c1d8a7829055cf8195d4aae4cd708) +--- + tests/t9040-many-partitions.sh | 10 ---------- + 1 file changed, 10 deletions(-) + +diff --git a/tests/t9040-many-partitions.sh b/tests/t9040-many-partitions.sh +index a3af5e7..4f58658 100644 +--- a/tests/t9040-many-partitions.sh ++++ b/tests/t9040-many-partitions.sh +@@ -53,9 +53,7 @@ while :; do + done + + # Time the actual command: +-t0=$(date +%s.%N) + parted -m -a min -s $scsi_dev mklabel gpt $cmd u s p > out 2>&1 || fail=1 +-t_final=$(date +%s.%N) + + i=1 + while :; do +@@ -64,14 +62,6 @@ while :; do + printf "$i:${s}s:${e}s:${partition_sectors}s::p$i:;\n" >> exp + test $i = $n_partitions && break; i=$((i+1)) + done +- +-# Fail the test if it takes too long. +-# On Fedora 16, this takes about 10 seconds for me. +-# With Fedora-12-era kernels, it typically took more than 150 seconds. +-$AWK "BEGIN {d = $t_final - $t0; n = $n_partitions; st = 60 < d;"\ +-' printf "created %d partitions in %.2f seconds\n", n, d; exit st }' /dev/null \ +- || fail=1 +- + compare exp out || fail=1 + + Exit $fail +-- +2.9.3 + diff --git a/SOURCES/0056-libparted-Fix-starting-CHS-in-protective-MBR.patch b/SOURCES/0056-libparted-Fix-starting-CHS-in-protective-MBR.patch new file mode 100644 index 0000000..20fa7f6 --- /dev/null +++ b/SOURCES/0056-libparted-Fix-starting-CHS-in-protective-MBR.patch @@ -0,0 +1,33 @@ +From ef6a998695636d81d7d24ad8ae7405b03bf75c2f Mon Sep 17 00:00:00 2001 +From: Petr Uzel +Date: Thu, 10 Mar 2016 14:18:52 +0100 +Subject: [PATCH 56/75] libparted: Fix starting CHS in protective MBR + +The CHS address for protective partition start in protective MBR +should be 0/0/2, according to UEFI spec (v2.6, section 5.2.1). + +* libparted/labels/gpt.c (_write_pmbr): Fix starting CHS address + +Reported by Steffen Winterfeldt in https://bugzilla.suse.com/969165 + +Signed-off-by: Petr Uzel +--- + 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 d69377a..6027eb3 100644 +--- a/libparted/labels/gpt.c ++++ b/libparted/labels/gpt.c +@@ -1139,7 +1139,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 = 1; ++ pmbr->PartitionRecord[0].StartSector = 2; + pmbr->PartitionRecord[0].EndHead = 0xFE; + pmbr->PartitionRecord[0].EndSector = 0xFF; + pmbr->PartitionRecord[0].EndTrack = 0xFF; +-- +2.9.3 + diff --git a/SOURCES/0057-libparted-Don-t-warn-if-no-HDIO_GET_IDENTITY-ioctl.patch b/SOURCES/0057-libparted-Don-t-warn-if-no-HDIO_GET_IDENTITY-ioctl.patch new file mode 100644 index 0000000..09540a1 --- /dev/null +++ b/SOURCES/0057-libparted-Don-t-warn-if-no-HDIO_GET_IDENTITY-ioctl.patch @@ -0,0 +1,44 @@ +From a6612fb6dd3746cfc9138ebc84210945a8fffa10 Mon Sep 17 00:00:00 2001 +From: Sebastian Parschauer +Date: Tue, 4 Oct 2016 11:37:30 +0200 +Subject: [PATCH 57/75] libparted: Don't warn if no HDIO_GET_IDENTITY ioctl + +Fully virtualized Xen VMs (HVM) use Linux IDE devices which don't +support the HDIO_GET_IDENTITY ioctl. EINVAL is returned, a warning +is printed and the device model is set to "Generic IDE" in that +case. The problem is seeing the warning all the time. So drop it +for this case. + +Signed-off-by: Brian C. Lane +--- + libparted/arch/linux.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index b7ba5de..2058697 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -931,6 +931,7 @@ init_ide (PedDevice* dev) + PedExceptionOption ex_status; + char hdi_buf[41]; + int sector_multiplier = 0; ++ int r; + + if (!_device_stat (dev, &dev_stat)) + goto error; +@@ -938,7 +939,11 @@ init_ide (PedDevice* dev) + if (!_device_open_ro (dev)) + goto error; + +- if (ioctl (arch_specific->fd, HDIO_GET_IDENTITY, &hdi)) { ++ r = ioctl (arch_specific->fd, HDIO_GET_IDENTITY, &hdi); ++ if (r && errno == EINVAL) { ++ /* silently ignore unsupported ioctl */ ++ dev->model = strdup(_("Generic IDE")); ++ } else if (r) { + ex_status = ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_IGNORE_CANCEL, +-- +2.9.3 + diff --git a/SOURCES/0058-libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch b/SOURCES/0058-libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch new file mode 100644 index 0000000..b906b83 --- /dev/null +++ b/SOURCES/0058-libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch @@ -0,0 +1,272 @@ +From ebb6eef20792a17388da30f1c312ede4b03140fd Mon Sep 17 00:00:00 2001 +From: Wang Dong +Date: Wed, 26 Oct 2016 04:22:46 +0200 +Subject: [PATCH 58/75] libparted/dasd: unify vtoc handling for cdl/ldl + +Merge volume label cdl and ldl. It is convenient to manipulate +the same structure. Also remove unused arguments in the functions. + +Signed-off-by: Wang Dong +Signed-off-by: Hendrik Brueckner +Signed-off-by: Brian C. Lane +--- + include/parted/vtoc.in.h | 34 +++++++++++++++++++--------------- + libparted/labels/dasd.c | 8 +++----- + libparted/labels/vtoc.c | 38 +++++++++++++++++--------------------- + 3 files changed, 39 insertions(+), 41 deletions(-) + +diff --git a/include/parted/vtoc.in.h b/include/parted/vtoc.in.h +index 499c2d3..b9da23a 100644 +--- a/include/parted/vtoc.in.h ++++ b/include/parted/vtoc.in.h +@@ -62,7 +62,6 @@ typedef struct cchh cchh_t; + typedef struct labeldate labeldate_t; + typedef struct volume_label volume_label_t; + typedef struct cms_volume_label cms_volume_label_t; +-typedef struct ldl_volume_label ldl_volume_label_t; + typedef struct extent extent_t; + typedef struct dev_const dev_const_t; + typedef struct format1_label format1_label_t; +@@ -94,6 +93,19 @@ struct __attribute__ ((packed)) labeldate { + u_int16_t day; + }; + ++/* ++ * The following structure is a merger of the cdl and ldl volume label. ++ * On an ldl disk there is no key information, so when reading an ++ * ldl label from disk, the data should be copied at the address of vollbl. ++ * On the other side, the field ldl_version is reserved in a cdl record ++ * and the field formatted_blocks exists only for ldl labels. So when ++ * reading a cdl label from disk, the formatted_blocks field will contain ++ * arbitrary data. ++ * This layout may be a bit awkward, but the advantage of having the ++ * same label type for both disk layout types is bigger than the effort ++ * for taking a bit of extra care at the fringes. ++ */ ++ + struct __attribute__ ((packed)) volume_label { + char volkey[4]; /* volume key = volume label */ + char vollbl[4]; /* volume label ("VOL1" in EBCDIC) */ +@@ -107,15 +119,8 @@ struct __attribute__ ((packed)) volume_label { + char labperci[4]; /* no of labels per CI (FBA), blanks for CKD */ + char res2[4]; /* reserved */ + char lvtoc[14]; /* owner code for LVTOC */ +- char res3[29]; /* reserved */ +- char fudge[4]; /* filler to match length of ldl label */ +-}; +- +-struct __attribute__ ((packed)) ldl_volume_label { +- char vollbl[4]; /* Label identifier ("LNX1" in EBCDIC) */ +- char volid[6]; /* Volume identifier */ +- char res3[69]; /* Reserved field */ +- char ldl_version[1]; /* Version number, valid for ldl format */ ++ char res3[28]; /* reserved */ ++ char ldl_version; /* version number, valid for ldl format */ + u_int64_t formatted_blocks; /* valid when ldl_version >= "2" (in + EBCDIC) */ + }; +@@ -335,11 +340,10 @@ void vtoc_write_label (int fd, unsigned long position, + format7_label_t const *f7, + format9_label_t const *f9); + +-void vtoc_init_format1_label (char *volid, unsigned int blksize, ++void vtoc_init_format1_label (unsigned int blksize, + extent_t *part_extent, format1_label_t *f1); + + void vtoc_init_format4_label (format4_label_t *f4lbl, +- unsigned int usable_partitions, + unsigned int compat_cylinders, + unsigned int real_cylinders, + unsigned int tracks, +@@ -352,11 +356,11 @@ void vtoc_update_format4_label (format4_label_t *f4, cchhb_t *highest_f1, + + void vtoc_init_format5_label (format5_label_t *f5); + +-void vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl, ++void vtoc_update_format5_label_add (format5_label_t *f5, int verbose, + int trk, u_int16_t a, u_int16_t b, + u_int8_t c); + +-void vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl, ++void vtoc_update_format5_label_del (format5_label_t *f5, int verbose, + int trk, u_int16_t a, u_int16_t b, + u_int8_t c); + +@@ -368,7 +372,7 @@ void vtoc_update_format7_label_add (format7_label_t *f7, int verbose, + void vtoc_update_format7_label_del (format7_label_t *f7, int verbose, + u_int32_t a, u_int32_t b); + +-void vtoc_init_format8_label (char *volid, unsigned int blksize, ++void vtoc_init_format8_label (unsigned int blksize, + extent_t *part_extent, format1_label_t *f1); + + void vtoc_update_format8_label (cchhb_t *associated_f9, format1_label_t *f8); +diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c +index 4e68512..7594e96 100644 +--- a/libparted/labels/dasd.c ++++ b/libparted/labels/dasd.c +@@ -330,13 +330,12 @@ dasd_read (PedDisk* disk) + DasdPartitionData* dasd_data; + + union vollabel { +- volume_label_t unused; +- ldl_volume_label_t ldl; ++ volume_label_t ldl; + cms_volume_label_t cms; + }; + union vollabel *cms_ptr1 = (union vollabel *) anchor.vlabel; + cms_volume_label_t *cms_ptr = &cms_ptr1->cms; +- ldl_volume_label_t *ldl_ptr = &cms_ptr1->ldl; ++ volume_label_t *ldl_ptr = &cms_ptr1->ldl; + int partition_start_block; + + disk_specific->format_type = 1; +@@ -360,8 +359,7 @@ dasd_read (PedDisk* disk) + * (long long) cms_ptr->disk_offset; + + if (is_ldl) +- if (strncmp(ldl_ptr->ldl_version, +- vtoc_ebcdic_enc("2", str, 1), 1) >= 0) ++ if (ldl_ptr->ldl_version >= 0xf2) + end = (long long) arch_specific->real_sector_size + / (long long) disk->dev->sector_size + * (long long) ldl_ptr->formatted_blocks - 1; +diff --git a/libparted/labels/vtoc.c b/libparted/labels/vtoc.c +index fdfa94f..d47b791 100644 +--- a/libparted/labels/vtoc.c ++++ b/libparted/labels/vtoc.c +@@ -150,7 +150,7 @@ enum failure { + unable_to_read + }; + +-static char buffer[89]; ++static char buffer[93]; + + static void + vtoc_error (enum failure why, char const *s1, char const *s2) +@@ -329,7 +329,7 @@ void + vtoc_volume_label_init (volume_label_t *vlabel) + { + PDEBUG +- sprintf(buffer, "%88s", " "); ++ sprintf(buffer, "%92s", " "); + vtoc_ebcdic_enc(buffer, buffer, sizeof *vlabel); + memcpy(vlabel, buffer, sizeof *vlabel); + } +@@ -348,8 +348,8 @@ vtoc_read_volume_label (int f, unsigned long vlabel_start, + typedef union vollabel vollabel_t; + + union __attribute__((packed)) vollabel { ++ /* cdl and ldl have the same data struct */ + volume_label_t cdl; +- ldl_volume_label_t ldl; + cms_volume_label_t cms; + }; + +@@ -373,9 +373,7 @@ vtoc_read_volume_label (int f, unsigned long vlabel_start, + } + + rc = read(f, vlabel, sizeof(volume_label_t)); +- if (rc != sizeof(volume_label_t) && +- /* For CDL we ask to read 88 bytes, but only get 84 */ +- rc != sizeof(volume_label_t) - 4) { ++ if (rc != sizeof(volume_label_t)) { + vtoc_error(unable_to_read, "vtoc_read_volume_label", + _("Could not read volume label.")); + return 1; +@@ -427,10 +425,8 @@ vtoc_write_volume_label (int f, unsigned long vlabel_start, + vtoc_error(unable_to_seek, "vtoc_write_volume_label", + _("Could not write volume label.")); + +- rc = write(f, vlabel, sizeof(volume_label_t) - 4); +- /* Subtract 4 to leave off the "fudge" variable when writing. +- We only write CDL volume labels, never LDL or CMS. */ +- if (rc != sizeof(volume_label_t) - 4) ++ rc = write(f, vlabel, sizeof(volume_label_t)); ++ if (rc != sizeof(volume_label_t)) + vtoc_error(unable_to_write, "vtoc_write_volume_label", + _("Could not write volume label.")); + +@@ -632,7 +628,7 @@ vtoc_write_label (int f, unsigned long position, + * initializes a format4 label + */ + void +-vtoc_init_format4_label (format4_label_t *f4, unsigned int usable_partitions, ++vtoc_init_format4_label (format4_label_t *f4, + unsigned int compat_cylinders, + unsigned int real_cylinders, unsigned int tracks, + unsigned int blocks, unsigned int blksize, +@@ -740,7 +736,7 @@ vtoc_init_format7_label (format7_label_t *f7) + * format1 or format 8 label, all but the field DS1FMTID + */ + void +-vtoc_init_format_1_8_label (char *volid, unsigned int blksize, ++vtoc_init_format_1_8_label (unsigned int blksize, + extent_t *part_extent, format1_label_t *f1) + { + PDEBUG +@@ -794,18 +790,18 @@ vtoc_init_format_1_8_label (char *volid, unsigned int blksize, + } + + void +-vtoc_init_format1_label (char *volid, unsigned int blksize, ++vtoc_init_format1_label (unsigned int blksize, + extent_t *part_extent, format1_label_t *f1) + { +- vtoc_init_format_1_8_label(volid, blksize, part_extent, f1); ++ vtoc_init_format_1_8_label(blksize, part_extent, f1); + f1->DS1FMTID = 0xf1; + } + + void +-vtoc_init_format8_label (char *volid, unsigned int blksize, ++vtoc_init_format8_label (unsigned int blksize, + extent_t *part_extent, format1_label_t *f8) + { +- vtoc_init_format_1_8_label(volid, blksize, part_extent, f8); ++ vtoc_init_format_1_8_label(blksize, part_extent, f8); + f8->DS1FMTID = 0xf8; + } + +@@ -886,7 +882,7 @@ vtoc_reorganize_FMT5_extents (format5_label_t *f5) + * add a free space extent description to the VTOC FMT5 DSCB + */ + void +-vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl, ++vtoc_update_format5_label_add (format5_label_t *f5, int verbose, + int trk, u_int16_t a, u_int16_t b, u_int8_t c) + { + PDEBUG +@@ -974,7 +970,7 @@ vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl, + * remove a free space extent description from the VTOC FMT5 DSCB + */ + void +-vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl, ++vtoc_update_format5_label_del (format5_label_t *f5, int verbose, + int trk, u_int16_t a, u_int16_t b, u_int8_t c) + { + PDEBUG +@@ -1054,7 +1050,7 @@ vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl, + ext->ft = (a - ext->t) % trk; + + vtoc_update_format5_label_add(f5, verbose, +- cyl, trk, x, y, z); ++ trk, x, y, z); + + if (verbose) + puts ("FMT5 del extent: 2 pieces"); +@@ -1322,9 +1318,9 @@ vtoc_set_freespace(format4_label_t *f4, format5_label_t *f5, + z = (u_int8_t) ((stop - start + 1) % trk); + + if (ch == '+') +- vtoc_update_format5_label_add(f5, verbose, cyl, trk, x, y, z); ++ vtoc_update_format5_label_add(f5, verbose, trk, x, y, z); + else if (ch == '-') +- vtoc_update_format5_label_del(f5, verbose, cyl, trk, x, y, z); ++ vtoc_update_format5_label_del(f5, verbose, trk, x, y, z); + else + puts ("BUG: syntax error in vtoc_set_freespace call"); + +-- +2.9.3 + diff --git a/SOURCES/0059-libparted-dasd-update-and-improve-fdasd-functions.patch b/SOURCES/0059-libparted-dasd-update-and-improve-fdasd-functions.patch new file mode 100644 index 0000000..c9edd37 --- /dev/null +++ b/SOURCES/0059-libparted-dasd-update-and-improve-fdasd-functions.patch @@ -0,0 +1,208 @@ +From 1666d22aa8a044d57797d2f4c7f5448d5ef9606c Mon Sep 17 00:00:00 2001 +From: Wang Dong +Date: Wed, 26 Oct 2016 04:22:47 +0200 +Subject: [PATCH 59/75] libparted/dasd: update and improve fdasd functions + +Update the fdasd_anchor_t data structure and the fdasd_cleanup() +function. Also correct vtoc_changed and vlabel_changed accounting +because they are important to rewrite vtoc to save the changes. + +Wang Dong +Hendrik Brueckner + +Signed-off-by: Brian C. Lane +--- + include/parted/fdasd.in.h | 14 +++++------- + libparted/labels/fdasd.c | 56 ++++++++++++++++++++++++----------------------- + 2 files changed, 35 insertions(+), 35 deletions(-) + +diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h +index 4e351c4..09a35a0 100644 +--- a/include/parted/fdasd.in.h ++++ b/include/parted/fdasd.in.h +@@ -186,6 +186,7 @@ typedef struct format_data_t { + /***************************************************************************** + * SECTION: Further IOCTL Definitions (see fs.h) * + *****************************************************************************/ ++#define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */ + /* re-read partition table */ + #define BLKRRPART _IO(0x12,95) + /* get block device sector size */ +@@ -198,15 +199,14 @@ typedef struct format_data_t { + /***************************************************************************** + * SECTION: FDASD internal types * + *****************************************************************************/ ++#define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1) ++#define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1) + + #define DASD_MIN_API_VERSION 0 + + #define DEFAULT_FDASD_CONF "/etc/fdasd.conf" /* default config file */ + +-#define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1) +-#define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1) +- +-#define FDASD_VERSION "1.05" ++#define FDASD_VERSION "1.32.0" + #define DEVICE "device" + #define DISC "disc" + #define PART "part" +@@ -233,9 +233,6 @@ typedef struct config_data { + typedef struct fdasd_anchor { + int vlabel_changed; + int vtoc_changed; +- int devname_specified; +- int volid_specified; +- int config_specified; + int auto_partition; + int print_table; + int big_disk; +@@ -282,7 +279,8 @@ enum fdasd_failure { + vlabel_corrupted, + dsname_corrupted, + malloc_failed, +- device_verification_failed ++ device_verification_failed, ++ volser_not_found + }; + + void fdasd_cleanup (fdasd_anchor_t *anchor); +diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c +index 968b332..e5df5cf 100644 +--- a/libparted/labels/fdasd.c ++++ b/libparted/labels/fdasd.c +@@ -106,28 +106,26 @@ fdasd_cleanup (fdasd_anchor_t *anchor) + { + PDEBUG + int i; +- partition_info_t *p, *q; ++ partition_info_t *part_info, *next; + + if (anchor == NULL) + return; + +- free(anchor->f4); +- free(anchor->f5); +- free(anchor->f7); +- free(anchor->f9); +- free(anchor->vlabel); +- +- p = anchor->first; +- if (p == NULL) +- return; +- +- for (i=1; i <= USABLE_PARTITIONS; i++) { +- if (p == NULL) +- return; +- q = p->next; +- free(p->f1); +- free(p); +- p = q; ++ if (anchor->f4 != NULL) ++ free(anchor->f4); ++ if (anchor->f5 != NULL) ++ free(anchor->f5); ++ if (anchor->f7 != NULL) ++ free(anchor->f7); ++ if (anchor->vlabel != NULL) ++ free(anchor->vlabel); ++ ++ part_info = anchor->first; ++ for (i = 1; i <= USABLE_PARTITIONS && part_info != NULL; i++) { ++ next = part_info->next; ++ free(part_info->f1); ++ free(part_info); ++ part_info = next; + } + } + +@@ -190,6 +188,9 @@ fdasd_error (fdasd_anchor_t *anc, enum fdasd_failure why, char const *str) + _("Device verification failed"), + _("The specified device is not a valid DASD device")); + break; ++ case volser_not_found: ++ sprintf(error, "fdasd: %s -- %s\n", _("VOLSER not found on device"), str); ++ break; + default: + sprintf(error, "fdasd: %s: %s\n", _("Fatal error"), str); + } +@@ -287,7 +288,7 @@ fdasd_write_vtoc_labels (fdasd_anchor_t * anc, int fd) + PDEBUG + partition_info_t *p; + unsigned long b, maxblk; +- char dsno[6], s1[7], s2[45], *c1, *c2, *ch; ++ char dsno[6], s1[VOLSER_LENGTH + 1], s2[45], *c1, *c2, *ch; + int i = 0, k = 0; + cchhb_t f9addr; + format1_label_t emptyf1; +@@ -519,7 +520,6 @@ fdasd_recreate_vtoc (fdasd_anchor_t *anc) + int i; + + vtoc_init_format4_label(anc->f4, +- USABLE_PARTITIONS, + anc->geo.cylinders, + anc->formatted_cylinders, + anc->geo.heads, +@@ -767,7 +767,7 @@ fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc) + anc->formatted_cylinders = anc->hw_cylinders; + anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads + - FIRST_USABLE_TRK; +- vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS, ++ vtoc_init_format4_label(anc->f4, + anc->geo.cylinders, anc->formatted_cylinders, + anc->geo.heads, anc->geo.sectors, + anc->blksize, anc->dev_type); +@@ -781,6 +781,8 @@ fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc) + anc->formatted_cylinders, anc->geo.heads); + + vtoc_set_cchhb(&anc->vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01); ++ anc->vtoc_changed++; ++ anc->vlabel_changed++; + } + + /* +@@ -792,7 +794,7 @@ fdasd_process_invalid_vtoc(fdasd_anchor_t *anc) + anc->formatted_cylinders = anc->hw_cylinders; + anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads + - FIRST_USABLE_TRK; +- vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS, ++ vtoc_init_format4_label(anc->f4, + anc->geo.cylinders, anc->formatted_cylinders, + anc->geo.heads, anc->geo.sectors, + anc->blksize, anc->dev_type); +@@ -803,6 +805,8 @@ fdasd_process_invalid_vtoc(fdasd_anchor_t *anc) + FIRST_USABLE_TRK, + anc->formatted_cylinders * anc->geo.heads - 1, + anc->formatted_cylinders, anc->geo.heads); ++ ++ anc->vtoc_changed++; + } + + +@@ -875,7 +879,7 @@ fdasd_check_volume (fdasd_anchor_t *anc, int fd) + + fdasd_init_volume_label(anc, fd); + +- vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS, ++ vtoc_init_format4_label(anc->f4, + anc->geo.cylinders, anc->formatted_cylinders, + anc->geo.heads, anc->geo.sectors, + anc->blksize, anc->dev_type); +@@ -1286,12 +1290,10 @@ fdasd_add_partition (fdasd_anchor_t *anc, unsigned int start, + return 0; + + if (anc->formatted_cylinders > LV_COMPAT_CYL) { +- vtoc_init_format8_label(anc->vlabel->volid, anc->blksize, &ext, +- p->f1); ++ vtoc_init_format8_label(anc->blksize, &ext, p->f1); + } else { + PDEBUG; +- vtoc_init_format1_label(anc->vlabel->volid, anc->blksize, &ext, +- p->f1); ++ vtoc_init_format1_label(anc->blksize, &ext, p->f1); + } + + PDEBUG; +-- +2.9.3 + diff --git a/SOURCES/0060-libparted-dasd-add-new-fdasd-functions.patch b/SOURCES/0060-libparted-dasd-add-new-fdasd-functions.patch new file mode 100644 index 0000000..3daadaf --- /dev/null +++ b/SOURCES/0060-libparted-dasd-add-new-fdasd-functions.patch @@ -0,0 +1,171 @@ +From 3267b55ff764840cf267fd1e02fa467e4d87d388 Mon Sep 17 00:00:00 2001 +From: Wang Dong +Date: Wed, 26 Oct 2016 04:22:48 +0200 +Subject: [PATCH 60/75] libparted/dasd: add new fdasd functions + +Introduce a set of new functions from the fdasd utility of the s390-tools +to keep the code base in parted and s390-tools in sync. + +These new functions are: + fdasd_check_volser(): validate the volser input + fdasd_get_volser(): get volume serial (volser) + fdasd_change_volser(): change volser with string + fdasd_reuse_vtoc(): re-create vtoc labels based on the existing vtoc + +Signed-off-by: Wang Dong +Signed-off-by: Hendrik Brueckner +Signed-off-by: Brian C. Lane +--- + include/parted/fdasd.in.h | 4 ++ + libparted/labels/fdasd.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 127 insertions(+) + +diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h +index 09a35a0..9e5d7d1 100644 +--- a/include/parted/fdasd.in.h ++++ b/include/parted/fdasd.in.h +@@ -293,5 +293,9 @@ void fdasd_recreate_vtoc(fdasd_anchor_t *anc); + partition_info_t * fdasd_add_partition (fdasd_anchor_t *anc, + unsigned int start, unsigned int stop); + int fdasd_prepare_labels (fdasd_anchor_t *anc, int fd) ; ++void fdasd_check_volser(char *volser, int devno); ++int fdasd_get_volser(fdasd_anchor_t *anc, char *volser, int fd); ++void fdasd_change_volser(fdasd_anchor_t *anc, char *str); ++void fdasd_reuse_vtoc(fdasd_anchor_t *anc); + + #endif /* FDASD_H */ +diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c +index e5df5cf..713ed6b 100644 +--- a/libparted/labels/fdasd.c ++++ b/libparted/labels/fdasd.c +@@ -1320,4 +1320,127 @@ fdasd_add_partition (fdasd_anchor_t *anc, unsigned int start, + return p; + } + ++/* ++ * Check for valid volume serial characters (max. 6) - remove invalid. ++ * If volser is empty, fill with default volser. ++ */ ++void fdasd_check_volser (char *volser, int devno) ++{ ++ int from, to; ++ ++ for (from = 0, to = 0; volser[from] && from < VOLSER_LENGTH; from++) { ++ ++ if ((volser[from] >= 0x23 && ++ volser[from] <= 0x25) || ++ (volser[from] >= 0x30 && ++ volser[from] <= 0x39) || ++ (volser[from] >= 0x40 && ++ volser[from] <= 0x5a) || ++ (volser[from] >= 0x61 && ++ volser[from] <= 0x7a)) ++ volser[to++] = toupper(volser[from]); ++ } ++ ++ volser[to] = 0x00; ++ ++ if (volser[0] == 0x00) ++ sprintf(volser, "0X%04x", devno); ++} ++ ++/* ++ * get volser from vtoc ++ */ ++int fdasd_get_volser (fdasd_anchor_t *anc, char *volser, int fd) ++{ ++ volume_label_t vlabel; ++ ++ vtoc_read_volume_label(fd, anc->label_pos, &vlabel); ++ vtoc_volume_label_get_volser(&vlabel, volser); ++ return 0; ++} ++ ++/* Changes the volume serial (menu option) ++ * ++ */ ++void fdasd_change_volser (fdasd_anchor_t *anc, char *str) ++{ ++ fdasd_check_volser(str, anc->devno); ++ vtoc_volume_label_set_volser(anc->vlabel, str); ++ ++ vtoc_set_cchhb(&anc->vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01); ++ anc->vlabel_changed++; ++ anc->vtoc_changed++; ++} ++ ++/* ++ * re-create all VTOC labels, but use the partition information ++ * from existing VTOC ++ */ ++void fdasd_reuse_vtoc (fdasd_anchor_t *anc) ++{ ++ partition_info_t *part_info = anc->first; ++ struct fdasd_hd_geometry geo = anc->geo; ++ format1_label_t f1; ++ format4_label_t f4; ++ format5_label_t f5; ++ format7_label_t f7; ++ ++ vtoc_init_format4_label(&f4, geo.cylinders, anc->formatted_cylinders, ++ geo.heads, geo.sectors, ++ anc->blksize, anc->dev_type); ++ ++ /* reuse some FMT4 values */ ++ f4.DS4HPCHR = anc->f4->DS4HPCHR; ++ f4.DS4DSREC = anc->f4->DS4DSREC; ++ ++ /* re-initialize both free-space labels */ ++ vtoc_init_format5_label(&f5); ++ vtoc_init_format7_label(&f7); ++ ++ if (anc->fspace_trk > 0) ++ vtoc_set_freespace(&f4, &f5, &f7, '+', anc->verbose, ++ FIRST_USABLE_TRK, ++ FIRST_USABLE_TRK + anc->fspace_trk - 1, ++ anc->formatted_cylinders, geo.heads); ++ ++ while (part_info != NULL) { ++ if (part_info->used != 0x01) { ++ part_info = part_info->next; ++ continue; ++ } ++ ++ if (anc->formatted_cylinders > LV_COMPAT_CYL) ++ vtoc_init_format8_label(anc->blksize, ++ &part_info->f1->DS1EXT1, &f1); ++ else ++ vtoc_init_format1_label(anc->blksize, ++ &part_info->f1->DS1EXT1, &f1); ++ ++ ++ strncpy(f1.DS1DSNAM, part_info->f1->DS1DSNAM, 44); ++ strncpy((char *)f1.DS1DSSN, (char *)part_info->f1->DS1DSSN, 6); ++ f1.DS1CREDT = part_info->f1->DS1CREDT; ++ ++ memcpy(part_info->f1, &f1, sizeof(format1_label_t)); ++ ++ if (part_info->fspace_trk > 0) ++ vtoc_set_freespace(&f4, &f5, &f7, '+', anc->verbose, ++ part_info->end_trk + 1, ++ part_info->end_trk + ++ part_info->fspace_trk, ++ anc->formatted_cylinders, geo.heads); ++ ++ part_info = part_info->next; ++ } ++ ++ /* over-write old labels with new ones */ ++ memcpy(anc->f4, &f4, sizeof(format4_label_t)); ++ memcpy(anc->f5, &f5, sizeof(format5_label_t)); ++ memcpy(anc->f7, &f7, sizeof(format7_label_t)); ++ ++ anc->vtoc_changed++; ++ ++ return; ++} ++ + /* vim:set tabstop=4 shiftwidth=4 softtabstop=4: */ +-- +2.9.3 + diff --git a/SOURCES/0061-libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch b/SOURCES/0061-libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch new file mode 100644 index 0000000..4b59261 --- /dev/null +++ b/SOURCES/0061-libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch @@ -0,0 +1,43 @@ +From 6872c0d2fd2038b366cc8086588a272465d6a553 Mon Sep 17 00:00:00 2001 +From: Wang Dong +Date: Wed, 26 Oct 2016 04:22:49 +0200 +Subject: [PATCH 61/75] libparted/dasd: add test cases for the new fdasd + functions + +The test case uses a temporary file in libparted/tests under +Check framwork. It can be issued by "make check" in the test dir. + +Signed-off-by: Wang Dong +Signed-off-by: Hendrik Brueckner +Signed-off-by: Brian C. Lane +--- + libparted/tests/Makefile.am | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am +index c7c10a9..9689fb3 100644 +--- a/libparted/tests/Makefile.am ++++ b/libparted/tests/Makefile.am +@@ -3,9 +3,9 @@ + # + # This file may be modified and/or distributed without restriction. + +-TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh ++TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh t4000-volser.sh + EXTRA_DIST = $(TESTS) +-check_PROGRAMS = label disk zerolen symlink ++check_PROGRAMS = label disk zerolen symlink volser + AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) + + LDADD = \ +@@ -23,6 +23,7 @@ label_SOURCES = common.h common.c label.c + disk_SOURCES = common.h common.c disk.c + zerolen_SOURCES = common.h common.c zerolen.c + symlink_SOURCES = common.h common.c symlink.c ++volser_SOURCES = common.h common.c volser.c + + # Arrange to symlink to tests/init.sh. + CLEANFILES = init.sh +-- +2.9.3 + diff --git a/SOURCES/0062-libparted-set-swap-flag-on-GPT-partitions.patch b/SOURCES/0062-libparted-set-swap-flag-on-GPT-partitions.patch new file mode 100644 index 0000000..8b99780 --- /dev/null +++ b/SOURCES/0062-libparted-set-swap-flag-on-GPT-partitions.patch @@ -0,0 +1,202 @@ +From f209b71efc693b97b7c812678e811698ffd2bc79 Mon Sep 17 00:00:00 2001 +From: Arvin Schnell +Date: Thu, 22 Dec 2016 14:36:43 -0800 +Subject: [PATCH 62/75] libparted: set swap flag on GPT partitions + +The filesystem type is still detected as befor, but now setting the +'swap' flag will set the partition GUID to PARTITION_SWAP_GUID. + +Signed-off-by: Brian C. Lane +--- + libparted/labels/gpt.c | 42 +++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 39 insertions(+), 3 deletions(-) + +diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c +index 6027eb3..4f922b2 100644 +--- a/libparted/labels/gpt.c ++++ b/libparted/labels/gpt.c +@@ -290,6 +290,7 @@ typedef struct _GPTPartitionData + efi_char16_t name[37]; + char *translated_name; + int lvm; ++ int swap; + int raid; + int boot; + int bios_grub; +@@ -818,7 +819,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte) + gpt_part_data->name[i] = 0; + gpt_part_data->translated_name = 0; + +- gpt_part_data->lvm = gpt_part_data->raid ++ gpt_part_data->lvm = gpt_part_data->swap ++ = gpt_part_data->raid + = gpt_part_data->boot = gpt_part_data->hp_service + = gpt_part_data->hidden = gpt_part_data->msftres + = gpt_part_data->msftdata +@@ -841,6 +843,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte) + gpt_part_data->raid = 1; + else if (!guid_cmp (gpt_part_data->type, PARTITION_LVM_GUID)) + gpt_part_data->lvm = 1; ++ else if (!guid_cmp (gpt_part_data->type, PARTITION_SWAP_GUID)) ++ gpt_part_data->swap = 1; + else if (!guid_cmp (gpt_part_data->type, PARTITION_HPSERVICE_GUID)) + gpt_part_data->hp_service = 1; + else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID)) +@@ -1361,6 +1365,7 @@ gpt_partition_new (const PedDisk *disk, + + gpt_part_data->type = PARTITION_LINUX_DATA_GUID; + gpt_part_data->lvm = 0; ++ gpt_part_data->swap = 0; + gpt_part_data->raid = 0; + gpt_part_data->boot = 0; + gpt_part_data->bios_grub = 0; +@@ -1449,6 +1454,11 @@ gpt_partition_set_system (PedPartition *part, + gpt_part_data->type = PARTITION_LVM_GUID; + return 1; + } ++ if (gpt_part_data->swap) ++ { ++ gpt_part_data->type = PARTITION_SWAP_GUID; ++ return 1; ++ } + if (gpt_part_data->raid) + { + gpt_part_data->type = PARTITION_RAID_GUID; +@@ -1636,6 +1646,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + if (state) + gpt_part_data->raid + = gpt_part_data->lvm ++ = gpt_part_data->swap + = gpt_part_data->bios_grub + = gpt_part_data->hp_service + = gpt_part_data->msftres +@@ -1650,6 +1661,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + if (state) + gpt_part_data->raid + = gpt_part_data->lvm ++ = gpt_part_data->swap + = gpt_part_data->boot + = gpt_part_data->hp_service + = gpt_part_data->msftres +@@ -1664,6 +1676,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + if (state) + gpt_part_data->boot + = gpt_part_data->lvm ++ = gpt_part_data->swap + = gpt_part_data->bios_grub + = gpt_part_data->hp_service + = gpt_part_data->msftres +@@ -1677,6 +1690,22 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + gpt_part_data->lvm = state; + if (state) + gpt_part_data->boot ++ = gpt_part_data->swap ++ = gpt_part_data->raid ++ = gpt_part_data->bios_grub ++ = gpt_part_data->hp_service ++ = gpt_part_data->msftres ++ = gpt_part_data->msftdata ++ = gpt_part_data->msftrecv ++ = gpt_part_data->prep ++ = gpt_part_data->irst ++ = gpt_part_data->atvrecv = 0; ++ return gpt_partition_set_system (part, part->fs_type); ++ case PED_PARTITION_SWAP: ++ gpt_part_data->swap = state; ++ if (state) ++ gpt_part_data->boot ++ = gpt_part_data->lvm + = gpt_part_data->raid + = gpt_part_data->bios_grub + = gpt_part_data->hp_service +@@ -1693,6 +1722,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + gpt_part_data->boot + = gpt_part_data->raid + = gpt_part_data->lvm ++ = gpt_part_data->swap + = gpt_part_data->bios_grub + = gpt_part_data->msftres + = gpt_part_data->msftdata +@@ -1707,6 +1737,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + gpt_part_data->boot + = gpt_part_data->raid + = gpt_part_data->lvm ++ = gpt_part_data->swap + = gpt_part_data->bios_grub + = gpt_part_data->hp_service + = gpt_part_data->msftdata +@@ -1721,6 +1752,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + gpt_part_data->boot + = gpt_part_data->raid + = gpt_part_data->lvm ++ = gpt_part_data->swap + = gpt_part_data->bios_grub + = gpt_part_data->hp_service + = gpt_part_data->msftres +@@ -1739,6 +1771,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + gpt_part_data->boot + = gpt_part_data->raid + = gpt_part_data->lvm ++ = gpt_part_data->swap + = gpt_part_data->bios_grub + = gpt_part_data->hp_service + = gpt_part_data->msftdata +@@ -1753,6 +1786,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + gpt_part_data->boot + = gpt_part_data->raid + = gpt_part_data->lvm ++ = gpt_part_data->swap + = gpt_part_data->bios_grub + = gpt_part_data->hp_service + = gpt_part_data->msftres +@@ -1766,6 +1800,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + gpt_part_data->boot + = gpt_part_data->raid + = gpt_part_data->lvm ++ = gpt_part_data->swap + = gpt_part_data->bios_grub + = gpt_part_data->hp_service + = gpt_part_data->msftres +@@ -1779,6 +1814,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + gpt_part_data->boot + = gpt_part_data->raid + = gpt_part_data->lvm ++ = gpt_part_data->swap + = gpt_part_data->bios_grub + = gpt_part_data->hp_service + = gpt_part_data->msftres +@@ -1793,7 +1829,6 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + case PED_PARTITION_LEGACY_BOOT: + gpt_part_data->legacy_boot = state; + return 1; +- case PED_PARTITION_SWAP: + case PED_PARTITION_ROOT: + case PED_PARTITION_LBA: + default: +@@ -1839,6 +1874,7 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag) + case PED_PARTITION_IRST: + return gpt_part_data->irst; + case PED_PARTITION_SWAP: ++ return gpt_part_data->swap; + case PED_PARTITION_LBA: + case PED_PARTITION_ROOT: + default: +@@ -1855,6 +1891,7 @@ gpt_partition_is_flag_available (const PedPartition *part, + { + case PED_PARTITION_RAID: + case PED_PARTITION_LVM: ++ case PED_PARTITION_SWAP: + case PED_PARTITION_BOOT: + case PED_PARTITION_BIOS_GRUB: + case PED_PARTITION_HPSERVICE: +@@ -1868,7 +1905,6 @@ gpt_partition_is_flag_available (const PedPartition *part, + case PED_PARTITION_IRST: + case PED_PARTITION_ESP: + return 1; +- case PED_PARTITION_SWAP: + case PED_PARTITION_ROOT: + case PED_PARTITION_LBA: + default: +-- +2.9.3 + diff --git a/SOURCES/0063-tests-Update-t0220-and-t0280-for-the-swap-flag.patch b/SOURCES/0063-tests-Update-t0220-and-t0280-for-the-swap-flag.patch new file mode 100644 index 0000000..faed432 --- /dev/null +++ b/SOURCES/0063-tests-Update-t0220-and-t0280-for-the-swap-flag.patch @@ -0,0 +1,43 @@ +From 3228fcc714347701f48034288b5fa98c6bb0a50d Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Thu, 22 Dec 2016 16:59:27 -0800 +Subject: [PATCH 63/75] tests: Update t0220 and t0280 for the swap flag. + +--- + tests/t0220-gpt-msftres.sh | 6 +++++- + tests/t0280-gpt-corrupt.sh | 2 +- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/tests/t0220-gpt-msftres.sh b/tests/t0220-gpt-msftres.sh +index 79518ae..6721a47 100755 +--- a/tests/t0220-gpt-msftres.sh ++++ b/tests/t0220-gpt-msftres.sh +@@ -56,7 +56,11 @@ printf "BYT;\n$dev:${n_sectors}s:file:$ss:$ss:gpt::;\n" > exp + i=1 + for type in $fs_types; do + end=$(expr $start + $part_size - 1) +- case $type in fat*|NTFS) flag=msftdata;; *) flag=;; esac ++ case $type in ++ fat*|NTFS) flag=msftdata;; ++ linux-swap) flag=swap;; ++ *) flag=;; ++ esac + echo "$i:${start}s:${end}s:${part_size}s::$type:$flag;" >> exp || fail=1 + parted -s $dev mkpart p-name $type ${start}s ${end}s > err 2>&1 || fail=1 + compare /dev/null err || fail=1 +diff --git a/tests/t0280-gpt-corrupt.sh b/tests/t0280-gpt-corrupt.sh +index a7c8d82..1b4d86b 100755 +--- a/tests/t0280-gpt-corrupt.sh ++++ b/tests/t0280-gpt-corrupt.sh +@@ -89,7 +89,7 @@ compare exp err || fail=1 + parted -m -s $dev u s print > out 2>&1 || fail=1 + + # check for expected output +-printf "BYT;\nfile\n1:2048s:4095s:2048s::foo:;\n" > exp || fail=1 ++printf "BYT;\nfile\n1:2048s:4095s:2048s::foo:swap;\n" > exp || fail=1 + sed "s/.*gpt::;/file/" out > k && mv k out || fail=1 + compare exp out || fail=1 + +-- +2.9.3 + diff --git a/SOURCES/0064-libparted-tests-Move-get_sector_size-to-common.c.patch b/SOURCES/0064-libparted-tests-Move-get_sector_size-to-common.c.patch new file mode 100644 index 0000000..f142760 --- /dev/null +++ b/SOURCES/0064-libparted-tests-Move-get_sector_size-to-common.c.patch @@ -0,0 +1,94 @@ +From 105746f40724d94499a04a0d7036380aaa41c1f5 Mon Sep 17 00:00:00 2001 +From: John Paul Adrian Glaubitz +Date: Sun, 4 Dec 2016 17:12:45 +0100 +Subject: [PATCH 64/75] libparted:tests: Move get_sector_size() to common.c + +Moving get_sector_size() from disk.c to common.c allows +us to use it in _implemented_disk_label() to test for +512-byte sectors. This change is required to be able to +enable this test for atari partition tables for which +support is added in a follow-up patch. + +Signed-off-by: John Paul Adrian Glaubitz +Signed-off-by: Brian C. Lane +--- + libparted/tests/common.c | 14 ++++++++++++++ + libparted/tests/common.h | 5 +++++ + libparted/tests/disk.c | 15 --------------- + 3 files changed, 19 insertions(+), 15 deletions(-) + +diff --git a/libparted/tests/common.c b/libparted/tests/common.c +index a0be997..9115686 100644 +--- a/libparted/tests/common.c ++++ b/libparted/tests/common.c +@@ -7,9 +7,23 @@ + #include + + #include "common.h" ++#include "xstrtol.h" + + #define STREQ(a, b) (strcmp (a, b) == 0) + ++size_t get_sector_size (void) ++{ ++ char *p = getenv ("PARTED_SECTOR_SIZE"); ++ size_t ss = 512; ++ unsigned long val; ++ if (p ++ && xstrtoul (p, NULL, 10, &val, NULL) == LONGINT_OK ++ && val % 512 == 0) ++ ss = val; ++ ++ return ss; ++} ++ + PedExceptionOption + _test_exception_handler (PedException* e) + { +diff --git a/libparted/tests/common.h b/libparted/tests/common.h +index 1b1c801..5d7485e 100644 +--- a/libparted/tests/common.h ++++ b/libparted/tests/common.h +@@ -1,5 +1,10 @@ + #include + ++/* Determine sector size from environment ++ * ++ */ ++size_t get_sector_size (void); ++ + /* Create an empty disk image + * + * filename: file (with full path) where to write the disk image +diff --git a/libparted/tests/disk.c b/libparted/tests/disk.c +index 48561b9..62d20c1 100644 +--- a/libparted/tests/disk.c ++++ b/libparted/tests/disk.c +@@ -7,24 +7,9 @@ + + #include "common.h" + #include "progname.h" +-#include "xstrtol.h" + + static char* temporary_disk; + +-static +-size_t get_sector_size (void) +-{ +- char *p = getenv ("PARTED_SECTOR_SIZE"); +- size_t ss = 512; +- unsigned long val; +- if (p +- && xstrtoul (p, NULL, 10, &val, NULL) == LONGINT_OK +- && val % 512 == 0) +- ss = val; +- +- return ss; +-} +- + static void + create_disk (void) + { +-- +2.9.3 + diff --git a/SOURCES/0065-libparted-Add-support-for-atari-partition-tables.patch b/SOURCES/0065-libparted-Add-support-for-atari-partition-tables.patch new file mode 100644 index 0000000..b1dc8e0 --- /dev/null +++ b/SOURCES/0065-libparted-Add-support-for-atari-partition-tables.patch @@ -0,0 +1,2135 @@ +From 5750e235a3cb27dc94aae0ca0e7d946c9319cc9d Mon Sep 17 00:00:00 2001 +From: John Paul Adrian Glaubitz +Date: Sun, 4 Dec 2016 17:12:46 +0100 +Subject: [PATCH 65/75] libparted: Add support for atari partition tables + +Signed-off-by: John Paul Adrian Glaubitz +Signed-off-by: Brian C. Lane +--- + libparted/labels/Makefile.am | 1 + + libparted/labels/atari.c | 1969 +++++++++++++++++++++++++++++++++++++++ + libparted/labels/pt-limit.gperf | 1 + + libparted/libparted.c | 4 + + libparted/tests/common.c | 3 + + po/POTFILES.in | 1 + + tests/t3310-flags.sh | 6 +- + tests/t9021-maxima.sh | 5 +- + 8 files changed, 1988 insertions(+), 2 deletions(-) + create mode 100644 libparted/labels/atari.c + +diff --git a/libparted/labels/Makefile.am b/libparted/labels/Makefile.am +index c996f81..3327c8c 100644 +--- a/libparted/labels/Makefile.am ++++ b/libparted/labels/Makefile.am +@@ -19,6 +19,7 @@ noinst_LTLIBRARIES = liblabels.la + liblabels_la_SOURCES = \ + $(S390_SRCS) \ + aix.c \ ++ atari.c \ + bsd.c \ + dos.c \ + dvh.c \ +diff --git a/libparted/labels/atari.c b/libparted/labels/atari.c +new file mode 100644 +index 0000000..36e68b9 +--- /dev/null ++++ b/libparted/labels/atari.c +@@ -0,0 +1,1969 @@ ++/* -*- Mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- ++ ++ libparted - a library for manipulating disk partitions ++ atari.c - libparted module to manipulate Atari partition tables. ++ Copyright (C) 2000-2001, 2004, 2007-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 . ++ ++ Contributor: Guillaume Knispel ++ John Paul Adrian Glaubitz ++*/ ++ ++/* ++ Documentation : ++ README file of atari-fdisk ++ atari-fdisk source code ++ Linux atari partitions parser source code ++ ( fs/partitions/atari.[ch] ) ++*/ ++ ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "pt-tools.h" ++ ++#if ENABLE_NLS ++# include ++# define _(String) dgettext (PACKAGE, String) ++#else ++# define _(String) (String) ++#endif /* ENABLE_NLS */ ++ ++ ++/********************** Atari data and structure stuff **********************/ ++ ++#define BOOTABLE_CKSUM 0x1234 ++#define NONBOOT_CKSUM 0x4321 ++ ++#define GEM_MAX ((32*1024*1024)/PED_SECTOR_SIZE_DEFAULT) ++ ++#define PART_FLAG_USED 0x01 ++#define PART_FLAG_BOOT_GEM 0x80 /* GEMDOS */ ++#define PART_FLAG_BOOT_ASV 0x40 /* Atari System V */ ++#define PART_FLAG_BOOT_BSD 0x20 /* Net(?)BSD */ ++#define PART_FLAG_BOOT_LNX 0x10 /* Linux */ ++#define PART_FLAG_BOOT_UNK 0x08 /* unknown / other */ ++ ++#define N_AHDI 4 ++#define N_ICD 8 ++ ++#define MAXIMUM_PARTS 64 ++ ++/* what we put instead of id, start and size in empty */ ++/* partition tables, to be able to detect it */ ++#define SIGNATURE_EMPTY_TABLE "PARTEDATARI" ++#define SIGNATURE_EMPTY_SIZE 11 ++ ++/* to be compared to the last two bytes of 1st sector (Big Endian) */ ++static const uint16_t atr_forbidden_sign[] = { ++ 0x55AA, ++ 0 ++}; ++ ++static const char *atr_known_icd_pid[] = { ++ "BGM", "GEM", "LNX", "SWP", "RAW", NULL ++}; ++ ++/* static const char *atr_known_pid[] = { */ ++/* "BGM", "GEM", "LNX", "MAC", "MIX", "MNX", "RAW", "SWP", "UNX", */ ++/* "F32", "SV4", NULL */ ++/* }; */ ++ ++struct _AtariPartID2BootFlag { ++ const char pid[4]; ++ uint8_t flag; ++}; ++typedef struct _AtariPartID2BootFlag AtariPartID2BootFlag; ++ ++static AtariPartID2BootFlag atr_pid2bf[] = { ++ { "GEM", PART_FLAG_BOOT_GEM }, ++ { "BGM", PART_FLAG_BOOT_GEM }, ++ { "UNX", PART_FLAG_BOOT_ASV }, ++ { "LNX", PART_FLAG_BOOT_LNX }, ++ { "", PART_FLAG_BOOT_UNK }, ++}; ++ ++struct _AtariFS2PartId { ++ const char* fs; ++ const char pid[4]; ++ PedSector max_sectors; ++}; ++typedef struct _AtariFS2PartId AtariFS2PartId; ++ ++static AtariFS2PartId atr_fs2pid[] = { ++/* Other ID are available : MIX MNX <= minix ++ UNX <= Atari SysV Unix ++ SV4 <= Univ System 4 */ ++ { "ext2", "LNX", INT32_MAX }, ++ { "ext3", "LNX", INT32_MAX }, ++ { "fat16", "GEM", GEM_MAX }, /* small partitions */ ++ { "fat16", "BGM", INT32_MAX }, /* big partitions */ ++ { "fat32", "F32", INT32_MAX }, ++ { "hfs", "MAC", INT32_MAX }, ++ { "hfs+", "MAC", INT32_MAX }, ++ { "hfsx", "MAC", INT32_MAX }, ++ { "jfs", "LNX", INT32_MAX }, ++ { "linux-swap", "SWP", INT32_MAX }, ++ { "reiserfs", "LNX", INT32_MAX }, ++ { "hp-ufs", "LNX", INT32_MAX }, ++ { "sun-ufs", "LNX", INT32_MAX }, ++ { "xfs", "LNX", INT32_MAX }, ++ { "ntfs", "RAW", INT32_MAX }, ++ { "", "RAW", INT32_MAX }, /* default entry */ ++ { NULL, "" , 0 } /* end of list */ ++}; ++ ++struct __attribute__ ((packed)) _AtariRawPartition { ++ uint8_t flag; /* bit 0: active; bit 7: bootable */ ++ uint8_t id[3]; /* "GEM", "BGM", "XGM", ... */ ++ uint32_t start; /* start of partition */ ++ uint32_t size; /* length of partition */ ++}; ++typedef struct _AtariRawPartition AtariRawPartition; ++ ++struct __attribute__ ((packed)) _AtariRawTable { ++ uint8_t boot_code[0x156]; /* room for boot code */ ++ AtariRawPartition icd_part[N_ICD]; /* info for ICD-partitions 5..12 */ ++ uint8_t unused[0xc]; ++ uint32_t hd_size; /* size of disk in blocks */ ++ AtariRawPartition part[N_AHDI]; /* the four primary partitions */ ++ uint32_t bsl_start; /* start of bad sector list */ ++ uint32_t bsl_count; /* length of bad sector list */ ++ uint16_t checksum; /* checksum for bootable disks */ ++}; ++typedef struct _AtariRawTable AtariRawTable; ++ ++typedef enum { ++ FMT_AHDI = 0, /* AHDI v1 compatible, no ICD and no XGM */ ++ FMT_XGM = 1, /* AHDI v3 with XGM / this disable ICD */ ++ FMT_ICD = 2 /* ICD detected / requested because more than 4 prim */ ++ /* no XGM allowed */ ++} AtrFmt; ++ ++struct _AtariDisk { ++ AtrFmt format; ++ int has_been_read; /* actually means has been read or written... */ ++ uint32_t bsl_start; /* first sector of the Bad Sectors List */ ++ uint32_t bsl_count; /* number of sectors of the BSL */ ++ uint8_t HDX_comp; /* if set to one, atari_write will initialize */ ++ /* the bsl area */ ++}; ++typedef struct _AtariDisk AtariDisk; ++ ++struct _AtariPart { ++ char part_id[4]; /* ASCIIZ */ ++ char icd_id[4]; /* Linux only parse a limited set of ID */ ++ /* in ICD (why???), so everything else */ ++ /* is translated to RAW. */ ++ uint8_t flag; /* without bit 0 (entry used) */ ++}; ++typedef struct _AtariPart AtariPart; ++ ++/* set by initialisation code to C locale */ ++static locale_t atr_c_locale; ++ ++static PedDiskType atari_disk_type; ++ ++ ++ ++/******************************** Atari Code ********************************/ ++ ++#define ATARI_DISK(disk) ((AtariDisk*)((disk)->disk_specific)) ++#define ATARI_PART(part) ((AtariPart*)((part)->disk_specific)) ++ ++#define atr_pid_eq(a,b) (!memcmp( (a), (b), 3 )) ++ ++#define atr_pid_assign(a, b) (memcpy ( (a), (b), 3 )) ++ ++#define atr_part_used(part) (((part)->flag) & PART_FLAG_USED) ++ ++static int ++atr_start_size_correct (uint32_t start, uint32_t size, uint32_t hd_size) ++{ ++ uint32_t end = start + size; ++ ++ return end >= start ++ && 0 < start && start <= hd_size ++ && 0 < size && size <= hd_size ++ && 0 < end && end <= hd_size; ++} ++ ++static int ++atr_part_correct (AtariRawPartition* part, uint32_t hd_size) ++{ ++ uint32_t start, size; ++ ++ start = PED_BE32_TO_CPU (part->start); ++ size = PED_BE32_TO_CPU (part->size); ++ ++ return isalnum_l(part->id[0], atr_c_locale) ++ && isalnum_l(part->id[1], atr_c_locale) ++ && isalnum_l(part->id[2], atr_c_locale) ++ && atr_start_size_correct (start, size, hd_size); ++} ++ ++static int _GL_ATTRIBUTE_PURE ++atr_pid_known (const char* pid, const char** pid_list) ++{ ++ for (; *pid_list; pid_list++) { ++ if (atr_pid_eq(pid, *pid_list)) ++ return 1; ++ } ++ ++ return 0; ++} ++ ++/* Recognize Parted signature in an AHDI entry, used to ++ * identify empty Atari partition tables */ ++static int ++atr_is_signature_entry (AtariRawPartition* part) ++{ ++ return part->flag == 0 ++ && !memcmp (part->id, SIGNATURE_EMPTY_TABLE, ++ SIGNATURE_EMPTY_SIZE ); ++} ++ ++/* Set Parted signature in an AHDI entry */ ++static void ++atr_put_signature_entry (AtariRawPartition* part) ++{ ++ part->flag = 0; ++ memcpy (part->id, SIGNATURE_EMPTY_TABLE, SIGNATURE_EMPTY_SIZE); ++} ++ ++#define atr_part_known(part, pid_list) (atr_pid_known ((part)->id, pid_list)) ++ ++#define atr_part_valid(part, sz) (atr_part_used(part)\ ++ && atr_part_correct((part), (sz))) ++#define atr_part_trash(part, sz) (atr_part_used(part)\ ++ && !atr_part_correct((part), (sz))) ++ ++/* Check if this device can be used with an Atari label */ ++static int ++atr_can_use_dev (const PedDevice *dev) ++{ ++ /* i really don't know how atari behave with non 512 bytes */ ++ /* sectors... */ ++ if (dev->sector_size != PED_SECTOR_SIZE_DEFAULT) { ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_CANCEL, ++ _("Can't use Atari partition tables on disks with a " ++ "sector size not equal to %d bytes."), ++ (int)PED_SECTOR_SIZE_DEFAULT ); ++ return 0; ++ } ++ ++ /* the format isn't well defined enough to support > 0x7FFFFFFF */ ++ /* sectors */ ++ if (dev->length > INT32_MAX) { ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_CANCEL, ++ _("Can't use Atari partition tables on disks with more " ++ "than %d sectors."), ++ INT32_MAX ); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++/* ++ * The Atari disk label doesn't have any magic id ++ * so we must completely parse the layout to be sure ++ * we are really dealing with it. ++ */ ++static int ++atari_probe (const PedDevice *dev) ++{ ++ AtariRawTable table; ++ uint32_t rs_hd_size, parts, exts; ++ int valid_count, xgm_part, xgm_num, i; ++ int num_sign, total_count = 0; ++ ++ PED_ASSERT (dev != NULL); ++ ++ /* Device Spec ok for Atari label? */ ++ if (!atr_can_use_dev (dev)) ++ return 0; ++ ++ /* read the root sector */ ++ if (!ped_device_read (dev, &table, 0, 1)) ++ return 0; ++ ++ /* number of sectors stored in the root sector > device length ? */ ++ /* => just reject the Atari disk label */ ++ rs_hd_size = PED_BE32_TO_CPU (table.hd_size); ++ if (rs_hd_size > dev->length ++ || rs_hd_size < 2) ++ return 0; ++ ++ /* check the BSL fields */ ++ if ((table.bsl_start || table.bsl_count) ++ && !atr_start_size_correct (PED_BE32_TO_CPU (table.bsl_start), ++ PED_BE32_TO_CPU (table.bsl_count), ++ rs_hd_size ) ) ++ return 0; ++ ++ /* scan the main AHDI fields */ ++ num_sign = 0; xgm_num = 0; ++ valid_count = 0; xgm_part = 0; ++ for (i = 0; i < N_AHDI; i++) { ++ if (atr_part_valid (&table.part[i], rs_hd_size)) { ++ valid_count++; ++ total_count++; ++ if (atr_pid_eq(table.part[i].id, "XGM")) { ++ xgm_part++; ++ xgm_num = i; ++ } ++ } else if (atr_part_trash (&table.part[i], rs_hd_size)) { ++ return 0; ++ } ++ if (atr_is_signature_entry (&table.part[i])) ++ num_sign++; ++ } ++ ++ /* no way to reliably detect empty Atari disk labels if ++ * they aren't using parted signature in 4 prim fields ++ * && reject multi XGM labels because Parted can't handle ++ * multiple extended partitions ++ * && reject if xgm partition in slot 0 because not allowed */ ++ if ((!valid_count && num_sign != N_AHDI) ++ || xgm_part > 1 ++ || (xgm_part == 1 && xgm_num == 0) ) ++ return 0; ++ ++ /* check coherency of each logical partitions and ARS */ ++ if (xgm_part) { /* ! WARNING ! reuses "table" */ ++ /* we must allow empty ext partition even if they're */ ++ /* not valid because parted write the layout to the HD */ ++ /* at each operation, and we can't create ext and log */ ++ /* at the same time */ ++ int empty_ars_allowed = 1; ++ ++ parts = exts = PED_BE32_TO_CPU (table.part[xgm_num].start); ++ while (1) { ++ if (!ped_device_read (dev, &table, parts, 1)) ++ return 0; ++ ++ for (i = 0; i < N_AHDI-1; ++i) { ++ if (atr_part_used (&table.part[i])) ++ break; ++ } ++ ++ /* we allow the ext part to be empty (see above) */ ++ if (i == N_AHDI-1 && empty_ars_allowed) ++ break; ++ ++ /* data partition must be in slot 0, 1 or 2 */ ++ if (i == N_AHDI-1 ++ || !atr_part_correct (&table.part[i], rs_hd_size ++ - parts ) ++ || atr_pid_eq (table.part[i].id, "XGM")) ++ return 0; ++ ++ /* If there is at least one logical partition */ ++ /* then next ARS should not be empty */ ++ empty_ars_allowed = 0; ++ ++ total_count++; ++ if (total_count > MAXIMUM_PARTS) { ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_CANCEL, ++ _("Too many Atari partitions detected. " ++ " Maybe there is a loop in the XGM " ++ "linked list. Aborting.") ); ++ return 0; ++ } ++ ++ /* end of logical partitions? */ ++ if (!atr_part_used (&table.part[i+1])) ++ break; ++ ++ /* is this really the descriptor of the next ARS? */ ++ if (!atr_part_correct (&table.part[i+1], rs_hd_size ++ - exts ) ++ || !atr_pid_eq (table.part[i+1].id, "XGM")) ++ return 0; ++ ++ parts = exts + PED_BE32_TO_CPU (table.part[i+1].start); ++ } ++ } /* no XGM so try ICD */ ++ else if (atr_part_valid (&table.icd_part[0], rs_hd_size) ++ && atr_part_known (&table.icd_part[0], atr_known_icd_pid)) { ++ for (i = 1; i < N_ICD; i++) { ++ if (atr_part_trash (&table.icd_part[i], rs_hd_size)) ++ return 0; ++ } ++ } ++ ++ return 1; ++} ++ ++static void ++atr_disk_reset (AtariDisk* atr_disk) ++{ ++ /* Empty partition table => only AHDI needed right now */ ++ atr_disk->format = FMT_AHDI; ++ /* The disk is not in sync with the actual content of the label */ ++ atr_disk->has_been_read = 0; ++ /* Create an empty BSL for HDX compatibility */ ++ atr_disk->bsl_start = 1; ++ atr_disk->bsl_count = 1; ++ atr_disk->HDX_comp = 1; ++} ++ ++/* ++ * Must set up the PedDisk and the associated AtariDisk as if ++ * the user is doing mklabel, since in this case atari_alloc ++ * is called alone whereas when reading an existing partition ++ * table atari_read is called after atari_alloc and can overwrite ++ * the settings. ++ */ ++static PedDisk* ++atari_alloc (const PedDevice* dev) ++{ ++ PedDisk* disk; ++ AtariDisk* atr_disk; ++ ++ PED_ASSERT (dev != NULL); ++ ++ if (!atr_can_use_dev (dev) ++ || !(disk = _ped_disk_alloc (dev, &atari_disk_type))) ++ return NULL; ++ ++ if (!(disk->disk_specific = atr_disk = ped_malloc (sizeof (AtariDisk)))) ++ goto error_free_disk; ++ ++ atr_disk_reset (atr_disk); ++ ++ return disk; ++ ++error_free_disk: ++ free (disk); ++ return NULL; ++} ++ ++static PedDisk* ++atari_duplicate (const PedDisk* disk) ++{ ++ PedDisk* new_disk; ++ AtariDisk* old_atr_dsk; ++ AtariDisk* new_atr_dsk; ++ ++ PED_ASSERT (disk != NULL); ++ PED_ASSERT (disk->dev != NULL); ++ PED_ASSERT (disk->disk_specific != NULL); ++ ++ old_atr_dsk = ATARI_DISK (disk); ++ if (!(new_disk = ped_disk_new_fresh (disk->dev, &atari_disk_type))) ++ return NULL; ++ new_atr_dsk = ATARI_DISK (new_disk); ++ ++ memcpy (new_atr_dsk, old_atr_dsk, sizeof(*old_atr_dsk)); ++ ++ return new_disk; ++} ++ ++static void ++atari_free (PedDisk* disk) ++{ ++ AtariDisk* atr_disk; ++ PED_ASSERT (disk != NULL); ++ PED_ASSERT (disk->disk_specific != NULL); ++ atr_disk = ATARI_DISK (disk); ++ ++ _ped_disk_free (disk); ++ free (atr_disk); ++} ++ ++/* Warning : ID not ASCIIZ but 3 chars long */ ++static void ++atr_part_sysraw (PedPartition* part, const char* id, uint8_t flag) ++{ ++ AtariPart* atr_part = ATARI_PART (part); ++ ++ atr_part->flag = flag & ~PART_FLAG_USED; ++ ++ atr_pid_assign (atr_part->part_id, id); ++ atr_part->part_id[3] = 0; ++ ++ if (atr_pid_known (id, atr_known_icd_pid)) { ++ atr_pid_assign (atr_part->icd_id, id); ++ atr_part->icd_id[3] = 0; ++ } else { ++ atr_pid_assign (atr_part->icd_id, "RAW"); ++ atr_part->icd_id[3] = 0; ++ } ++} ++ ++static int ++atr_parse_add_rawpart (PedDisk* disk, PedPartitionType type, PedSector st_off, ++ int num, const AtariRawPartition* rawpart ) ++{ ++ PedSector start, end; ++ PedPartition* part; ++ PedConstraint* const_exact; ++ int added; ++ ++ start = st_off + PED_BE32_TO_CPU (rawpart->start); ++ end = start + PED_BE32_TO_CPU (rawpart->size) - 1; ++ ++ part = ped_partition_new (disk, type, NULL, start, end); ++ if (!part) ++ return 0; ++ ++ /*part->num = num;*/ /* Enumeration will take care of that */ ++ part->num = -1; /* Indeed we can't enumerate here ++ * because the enumerate function uses ++ * -1 do detect new partition being ++ * inserted and update the atrdisk->format */ ++ if (type != PED_PARTITION_EXTENDED) ++ part->fs_type = ped_file_system_probe (&part->geom); ++ else ++ part->fs_type = NULL; ++ atr_part_sysraw (part, rawpart->id, rawpart->flag); ++ ++ const_exact = ped_constraint_exact (&part->geom); ++ added = ped_disk_add_partition (disk, part, const_exact); ++ ped_constraint_destroy (const_exact); ++ if (!added) { ++ ped_partition_destroy (part); ++ return 0; ++ } ++ ++ PED_ASSERT (part->num == num); ++ return 1; ++} ++ ++/* ++ * Read the chained list of logical partitions. ++ * exts points to the first Auxiliary Root Sector, at the start ++ * of the extended partition. ++ * In each ARS one partition entry describes to the logical partition ++ * (start relative to the ARS position) and the next entry with ID "XGM" ++ * points to the next ARS (start relative to exts). ++ */ ++static int ++atr_read_logicals (PedDisk* disk, PedSector exts, int* pnum) ++{ ++ AtariRawTable table; ++ PedSector parts = exts; ++ int i, empty_ars_allowed = 1; ++ ++ while (1) { ++ if (!ped_device_read (disk->dev, &table, parts, 1)) ++ return 0; ++ ++ for (i = 0; i < N_AHDI-1; ++i) ++ if (atr_part_used (&table.part[i])) ++ break; ++ ++ if (i == N_AHDI-1 && empty_ars_allowed) ++ break; ++ ++ /* data partition must be in slot 0, 1 or 2 */ ++ if (i == N_AHDI-1 ++ || atr_pid_eq (table.part[i].id, "XGM")) { ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_CANCEL, ++ _("No data partition found in the ARS at " ++ "sector %lli."), parts ); ++ return 0; ++ } ++ ++ empty_ars_allowed = 0; ++ ++ if (!atr_parse_add_rawpart (disk, PED_PARTITION_LOGICAL, ++ parts, *pnum, &table.part[i] ) ) ++ return 0; ++ ++ (*pnum)++; ++ ++ /* end of logical partitions? */ ++ if (!atr_part_used (&table.part[i+1])) ++ break; ++ ++ if (!atr_pid_eq (table.part[i+1].id, "XGM")) { ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_CANCEL, ++ _("The entry of the next logical ARS is not of " ++ "type XGM in ARS at sector %lli."), parts ); ++ return 0; ++ } ++ ++ parts = exts + PED_BE32_TO_CPU (table.part[i+1].start); ++ } ++ ++ return 1; ++} ++ ++static int ++atari_read (PedDisk* disk) ++{ ++ AtariRawTable table; ++ AtariDisk* atr_disk; ++ uint32_t rs_hd_size; ++ int i, pnum, xgm, pcount; ++ ++ PED_ASSERT (disk != NULL); ++ PED_ASSERT (disk->dev != NULL); ++ PED_ASSERT (disk->disk_specific != NULL); ++ atr_disk = ATARI_DISK (disk); ++ ++ ped_disk_delete_all (disk); ++ atr_disk_reset (atr_disk); ++ ++ if (!atari_probe (disk->dev)) { ++ if (ped_exception_throw ( ++ PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_IGNORE_CANCEL, ++ _("There doesn't seem to be an Atari partition table " ++ "on this disk (%s), or it is corrupted."), ++ disk->dev->path ) ++ != PED_EXCEPTION_IGNORE) ++ return 0; ++ } ++ ++ if (!ped_device_read (disk->dev, (void*) &table, 0, 1)) ++ goto error; ++ ++ /* We are sure that the layout looks coherent so we ++ don't need to check too much */ ++ ++ rs_hd_size = PED_BE32_TO_CPU (table.hd_size); ++ atr_disk->bsl_start = PED_BE32_TO_CPU (table.bsl_start); ++ atr_disk->bsl_count = PED_BE32_TO_CPU (table.bsl_count); ++ atr_disk->HDX_comp = 0; ++ ++ /* AHDI primary partitions */ ++ pnum = 1; xgm = 0; pcount = 0; ++ for (i = 0; i < N_AHDI; i++) { ++ if (!atr_part_used (&table.part[i])) ++ continue; ++ ++ pcount++; ++ ++ if (atr_pid_eq (table.part[i].id, "XGM")) { ++ ++ atr_disk->format = FMT_XGM; ++ xgm = 1; ++ if (!atr_parse_add_rawpart(disk, PED_PARTITION_EXTENDED, ++ 0, 0, &table.part[i] ) ++ || !atr_read_logicals ( ++ disk, ++ PED_BE32_TO_CPU (table.part[i].start), ++ &pnum ) ) ++ goto error; ++ ++ } else { ++ ++ if (!atr_parse_add_rawpart (disk, PED_PARTITION_NORMAL, ++ 0, pnum, &table.part[i] ) ) ++ goto error; ++ pnum++; ++ } ++ } ++ ++ /* If no XGM partition has been found, the AHDI table is not empty, */ ++ /* the first entry is valid and its ID ok for ICD, then we parse the */ ++ /* ICD table. */ ++ if (!xgm && pcount != 0 ++ && atr_part_valid (&table.icd_part[0], rs_hd_size) ++ && atr_part_known (&table.icd_part[0], atr_known_icd_pid)) ++ for (i = 0; i < N_ICD; i++) { ++ ++ if (!atr_part_known (&table.icd_part[i], atr_known_icd_pid) ++ || !atr_part_used (&table.icd_part[i])) ++ continue; ++ atr_disk->format = FMT_ICD; ++ ++ if (!atr_parse_add_rawpart (disk, PED_PARTITION_NORMAL, ++ 0, pnum, &table.icd_part[i] ) ) ++ goto error; ++ pnum++; ++ } ++ ++ atr_disk->has_been_read = 1; ++ return 1; ++ ++error: ++ ped_disk_delete_all (disk); ++ atr_disk_reset (atr_disk); ++ return 0; ++} ++ ++/* Returns the number of the first logical partition or -1 if not found */ ++static int ++atr_find_first_log (const PedDisk* disk) ++{ ++ PedPartition* part; ++ int first_log, last; ++ ++ last = ped_disk_get_last_partition_num (disk); ++ ++ for (first_log = 1; first_log <= last; first_log++) { ++ if ((part = ped_disk_get_partition (disk, first_log)) ++ && (part->type & PED_PARTITION_LOGICAL)) ++ break; ++ } ++ ++ return first_log > last ? -1 : first_log; ++} ++ ++#ifndef DISCOVER_ONLY ++static int ++atari_clobber (PedDevice* dev) ++{ ++ AtariRawTable table; ++ ++ PED_ASSERT (dev != NULL); ++ PED_ASSERT (atari_probe (dev)); ++ ++ if (!ped_device_read (dev, &table, 0, 1)) ++ return 0; ++ ++ /* clear anything but the boot code and the optional ICD table */ ++ memset (table.boot_code + offsetof (AtariRawTable, hd_size), ++ 0, ++ PED_SECTOR_SIZE_DEFAULT - offsetof (AtariRawTable, hd_size)); ++ ++ return ped_device_write (dev, &table, 0, 1); ++} ++ ++/* Computes the checksum of the root sector */ ++static uint16_t ++atr_calc_rs_sum (const AtariRawTable* table) ++{ ++ const uint16_t* word = (uint16_t*)(table); ++ const uint16_t* end = (uint16_t*)(table + 1); ++ uint16_t sum; ++ ++ for (sum = 0; word < end; word++) ++ sum += PED_BE16_TO_CPU(*word); ++ ++ return sum; ++} ++ ++/* Returns 1 if the root sector is bootable, else returns 0 */ ++static int ++atr_is_boot_table (const AtariRawTable* table) ++{ ++ return atr_calc_rs_sum (table) == BOOTABLE_CKSUM; ++} ++ ++/* ++ * Returns 1 if sign belongs to a set of `forbidden' signatures. ++ * (e.g.: 55AA which is the MSDOS siganture...) ++ * Only used for non bootable root sector since the signature of ++ * a bootable one is unique. ++ */ ++static int _GL_ATTRIBUTE_PURE ++atr_sign_is_forbidden (uint16_t sign) ++{ ++ const uint16_t* forbidden; ++ ++ for (forbidden = atr_forbidden_sign; *forbidden; forbidden++) { ++ if (sign == *forbidden) ++ return 1; ++ } ++ ++ return 0; ++} ++ ++/* Updates table->checksum so the RS will be considered bootable (or not) */ ++static void ++atr_table_set_boot (AtariRawTable* table, int boot) ++{ ++ uint16_t boot_cksum, noboot_cksum; ++ uint16_t sum; ++ ++ table->checksum = 0; ++ sum = atr_calc_rs_sum (table); ++ boot_cksum = BOOTABLE_CKSUM - sum; ++ ++ if (boot) { ++ table->checksum = PED_CPU_TO_BE16 (boot_cksum); ++ return; ++ } ++ ++ noboot_cksum = NONBOOT_CKSUM - sum; ++ ++ while (atr_sign_is_forbidden (noboot_cksum) ++ || noboot_cksum == boot_cksum) ++ noboot_cksum++; ++ ++ table->checksum = PED_CPU_TO_BE16 (noboot_cksum); ++} ++ ++/* Fill an used partition entry */ ++static void ++atr_fill_raw_entry (AtariRawPartition* rawpart, uint8_t flag, const char* id, ++ uint32_t start, uint32_t size ) ++{ ++ rawpart->flag = PART_FLAG_USED | flag; ++ atr_pid_assign (rawpart->id, id); ++ rawpart->start = PED_CPU_TO_BE32 (start); ++ rawpart->size = PED_CPU_TO_BE32 (size); ++} ++ ++static int ++atr_write_logicals (const PedDisk* disk) ++{ ++ AtariRawTable table; ++ PedPartition* log_curr; ++ PedPartition* log_next; ++ PedPartition* ext; ++ PedPartition* part; ++ PedSector exts; ++ PedSector parts; ++ AtariPart* atr_part; ++ int first_log, pnum, i; ++ ++ PED_ASSERT (disk != NULL); ++ ++ ext = ped_disk_extended_partition (disk); ++ exts = parts = ext->geom.start; ++ ++ pnum = first_log = atr_find_first_log (disk); ++ ++ while (1) { ++ if (pnum != -1) { ++ log_curr = ped_disk_get_partition (disk, pnum); ++ log_next = ped_disk_get_partition (disk, pnum + 1); ++ } else { ++ log_curr = log_next = NULL; ++ } ++ ++ if (log_curr && !(log_curr->type & PED_PARTITION_LOGICAL)) ++ log_curr = NULL; ++ if (log_next && !(log_next->type & PED_PARTITION_LOGICAL)) ++ log_next = NULL; ++ ++ PED_ASSERT (pnum == first_log || log_curr); ++ ++ part = ped_disk_get_partition_by_sector (disk, parts); ++ if (part && ped_partition_is_active (part)) { ++ if (log_curr) ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_CANCEL, ++ _("No room at sector %lli to store ARS " ++ "of logical partition %d."), ++ parts, pnum ); ++ else ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_CANCEL, ++ _("No room at sector %lli to store ARS."), ++ parts ); ++ return 0; ++ } ++ ++ if (!ped_device_read (disk->dev, &table, parts, 1)) ++ return 0; ++ ++ if (!log_curr) { ++ PED_ASSERT (!log_next); ++ ++ for (i = 0; i < N_AHDI; i++) ++ table.part[i].flag &= ~PART_FLAG_USED; ++ } else { ++ atr_part = ATARI_PART (log_curr); ++ atr_fill_raw_entry (&table.part[0], atr_part->flag, ++ atr_part->part_id, ++ log_curr->geom.start - parts, ++ log_curr->geom.length ); ++ ++ for (i = 1; i < N_AHDI; i++) ++ table.part[i].flag &= ~PART_FLAG_USED; ++ ++ if (log_next) { ++ atr_fill_raw_entry (&table.part[1], 0, "XGM", ++ log_next->geom.start - 1 - exts, ++ log_next->geom.length + 1 ); ++ } ++ } ++ ++ /* TODO: check if we can set that bootable, and when */ ++ atr_table_set_boot (&table, 0); ++ ++ if (!ped_device_write (disk->dev, &table, parts, 1)) ++ return 0; ++ ++ if (!log_next) ++ break; ++ ++ parts = log_next->geom.start - 1; ++ pnum++; ++ } ++ ++ return 1; ++} ++ ++static int _GL_ATTRIBUTE_PURE ++_disk_logical_partition_count (const PedDisk* disk) ++{ ++ PedPartition* walk; ++ ++ int count = 0; ++ ++ PED_ASSERT (disk != NULL); ++ for (walk = disk->part_list; walk; ++ walk = ped_disk_next_partition (disk, walk)) { ++ if (ped_partition_is_active (walk) ++ && (walk->type & PED_PARTITION_LOGICAL)) ++ count++; ++ } ++ ++ return count; ++} ++ ++/* Load the HD size from the table and ask to fix it if != device size. */ ++static int ++atr_load_fix_hdsize (const PedDisk* disk, uint32_t* rs_hd_size, AtariRawTable* table) ++{ ++ AtariDisk* atr_disk = ATARI_DISK (disk); ++ int result = PED_EXCEPTION_UNHANDLED; ++ ++ *rs_hd_size = PED_BE32_TO_CPU (table->hd_size); ++ if (*rs_hd_size != disk->dev->length) { ++ if (atr_disk->has_been_read) { ++ result = ped_exception_throw ( ++ PED_EXCEPTION_WARNING, ++ PED_EXCEPTION_FIX | PED_EXCEPTION_IGNORE_CANCEL, ++ _("The sector count that is stored in the " ++ "partition table does not correspond " ++ "to the size of your device. Do you " ++ "want to fix the partition table?") ); ++ if (result == PED_EXCEPTION_CANCEL) ++ return 0; ++ } ++ ++ if (result == PED_EXCEPTION_UNHANDLED) ++ result = PED_EXCEPTION_FIX; ++ ++ if (result == PED_EXCEPTION_FIX) { ++ *rs_hd_size = disk->dev->length; ++ table->hd_size = PED_CPU_TO_BE32(*rs_hd_size); ++ } ++ } ++ return 1; ++} ++ ++/* Try to init the HDX compatibility Bad Sectors List. */ ++static int ++atr_empty_init_bsl (const PedDisk* disk) ++{ ++ uint8_t zeros[PED_SECTOR_SIZE_DEFAULT]; ++ PedSector sec; ++ PedPartition* part; ++ AtariDisk* atr_disk = ATARI_DISK (disk); ++ ++ memset (zeros, 0, PED_SECTOR_SIZE_DEFAULT); ++ for (sec = atr_disk->bsl_start; ++ sec < atr_disk->bsl_start + atr_disk->bsl_count; ++ sec++ ) { ++ if (sec == atr_disk->bsl_start) ++ zeros[3] = 0xA5; ++ else ++ zeros[3] = 0; ++ part = ped_disk_get_partition_by_sector (disk, sec); ++ if (part && ped_partition_is_active (part)) { ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_CANCEL, ++ _("No room at sector %lli to store BSL."), ++ sec ); ++ return 0; ++ } ++ ped_device_write (disk->dev, zeros, sec, 1); ++ } ++ atr_disk->HDX_comp = 0; ++ return 1; ++} ++ ++static int ++atari_write (const PedDisk* disk) ++{ ++ AtariRawTable table; ++ AtariDisk* atr_disk; ++ AtariPart* atr_part; ++ PedPartition* log; ++ PedPartition* ext_part; ++ PedPartition* part = NULL; ++ uint32_t rs_hd_size; ++ int i, xgm_begin, pnum, append_ext; ++ int put_sign, boot, prim_count, last_num; ++ PED_ASSERT (disk != NULL); ++ PED_ASSERT (disk->dev != NULL); ++ atr_disk = ATARI_DISK (disk); ++ PED_ASSERT (atr_disk != NULL); ++ ++ prim_count = ped_disk_get_primary_partition_count (disk); ++ last_num = ped_disk_get_last_partition_num (disk); ++ ext_part = ped_disk_extended_partition (disk); ++ ++ /* WARNING: similar/related code in atari_enumerate */ ++ xgm_begin = ((log = ped_disk_get_partition (disk, 1)) ++ && (log->type & PED_PARTITION_LOGICAL)); ++ PED_ASSERT (atr_disk->format != FMT_ICD || ext_part == NULL); ++ PED_ASSERT (atr_disk->format != FMT_XGM || prim_count + xgm_begin <= N_AHDI); ++ PED_ASSERT (atr_disk->format != FMT_AHDI || (ext_part == NULL && prim_count + xgm_begin <= N_AHDI)); ++ ++ /* Device Spec ok for Atari label? */ ++ if (!atr_can_use_dev (disk->dev)) ++ goto error; ++ ++ if (!ped_device_read (disk->dev, (void*) &table, 0, 1)) ++ goto error; ++ ++ boot = atr_is_boot_table (&table); ++ ++ table.bsl_start = PED_CPU_TO_BE32 (atr_disk->bsl_start); ++ table.bsl_count = PED_CPU_TO_BE32 (atr_disk->bsl_count); ++ ++ /* Before anything else check the sector count and */ ++ /* fix it if necessary */ ++ if (!atr_load_fix_hdsize (disk, &rs_hd_size, &table)) ++ goto error; ++ ++ append_ext = (ext_part != NULL) ++ && (_disk_logical_partition_count (disk) == 0); ++ ++ /* Fill the AHDI table */ ++ put_sign = (prim_count == 0); ++ pnum = 1; ++ for (i = 0; i < N_AHDI; i++) { ++ if (pnum > last_num) ++ part = NULL; ++ else while (pnum <= last_num ++ && !(part = ped_disk_get_partition (disk, pnum))) ++ pnum++; ++ ++ if (put_sign) { ++ atr_put_signature_entry (&table.part[i]); ++ continue; ++ } ++ ++ if (!part && i != 0 && append_ext) { ++ part = ext_part; ++ append_ext = 0; ++ } ++ ++ if (!part || (i == 0 && xgm_begin)) { ++ table.part[i].flag &= ~PART_FLAG_USED; ++ continue; ++ } ++ ++ if (part->type & PED_PARTITION_LOGICAL) ++ part = ext_part; ++ ++ PED_ASSERT (part != NULL); ++ ++ atr_part = ATARI_PART (part); ++ atr_fill_raw_entry (&table.part[i], atr_part->flag, ++ atr_part->part_id, part->geom.start, ++ part->geom.length ); ++ ++ if (part->type & PED_PARTITION_EXTENDED) { ++ while (pnum <= last_num) { ++ part = ped_disk_get_partition (disk, pnum); ++ if (part && ++ !(part->type & PED_PARTITION_LOGICAL)) ++ break; ++ pnum++; ++ } ++ } else ++ pnum++; ++ } ++ ++ if ((ext_part != NULL || atr_disk->format == FMT_AHDI) ++ && pnum <= last_num) { ++ ped_exception_throw (PED_EXCEPTION_BUG, PED_EXCEPTION_CANCEL, ++ _("There were remaining partitions after filling " ++ "the main AHDI table.") ); ++ goto error; ++ } ++ ++ /* Leave XGM or ICD mode if uneeded */ ++ if (pnum > last_num ++ && (atr_disk->format == FMT_ICD || ext_part == NULL)) ++ atr_disk->format = FMT_AHDI; ++ ++ /* If AHDI mode, check that no ICD will be detected */ ++ /* and propose to fix */ ++ if (atr_disk->format == FMT_AHDI ++ && atr_part_valid (&table.icd_part[0], rs_hd_size) ++ && atr_part_known (&table.icd_part[0], atr_known_icd_pid)) { ++ int result = PED_EXCEPTION_UNHANDLED; ++ result = ped_exception_throw ( ++ PED_EXCEPTION_WARNING, ++ PED_EXCEPTION_YES_NO_CANCEL, ++ _("The main AHDI table has been filled with all " ++ "partitions but the ICD table is not empty " ++ "so more partitions of unknown size and position " ++ "will be detected by ICD compatible software. Do " ++ "you want to invalidate the ICD table?") ); ++ if (result == PED_EXCEPTION_YES ++ || result == PED_EXCEPTION_UNHANDLED) ++ table.icd_part[0].flag &= ~PART_FLAG_USED; ++ else if (result == PED_EXCEPTION_CANCEL) ++ goto error; ++ } ++ ++ if (put_sign) ++ goto write_to_dev; ++ ++ /* Fill the ICD table */ ++ if (atr_disk->format == FMT_ICD) ++ for (i = 0; i < N_ICD; i++) { ++ if (pnum > last_num) ++ part = NULL; ++ else while (pnum <= last_num ++ && !(part = ped_disk_get_partition (disk, pnum))) ++ pnum++; ++ ++ if (!part) { ++ table.icd_part[i].flag &= ~PART_FLAG_USED; ++ continue; ++ } ++ ++ if (part->type & PED_PARTITION_EXTENDED ++ || part->type & PED_PARTITION_LOGICAL) { ++ ped_exception_throw ( ++ PED_EXCEPTION_BUG, ++ PED_EXCEPTION_CANCEL, ++ _("ICD entries can't contain extended or " ++ "logical partitions.") ); ++ goto error; ++ } ++ ++ atr_part = ATARI_PART (part); ++ atr_fill_raw_entry (&table.icd_part[i], atr_part->flag, ++ atr_part->icd_id, part->geom.start, ++ part->geom.length ); ++ ++ pnum++; ++ } ++ ++ /* Write the chained list of logical partitions */ ++ if (atr_disk->format == FMT_XGM) { ++ if (!atr_write_logicals (disk)) ++ goto error; ++ } ++ ++write_to_dev: ++ if (pnum <= last_num) { ++ ped_exception_throw (PED_EXCEPTION_BUG, PED_EXCEPTION_CANCEL, ++ _("There were remaining partitions after filling " ++ "the tables.") ); ++ goto error; ++ } ++ ++ /* Do we need to do that in case of failure too??? */ ++ atr_table_set_boot (&table, boot); ++ ++ /* Commit the root sector... */ ++ if (!ped_device_write (disk->dev, (void*) &table, 0, 1) ++ || !ped_device_sync (disk->dev)) ++ goto error; ++ ++ /* Try to init the HDX compatibility Bad Sectors List if needed. */ ++ if (atr_disk->HDX_comp && !atr_empty_init_bsl (disk)) ++ goto error; ++ ++ atr_disk->has_been_read = 1; ++ return ped_device_sync (disk->dev); ++ ++error: ++ atr_disk->has_been_read = 0; ++ return 0; ++} ++#endif ++ ++/* If extended partition in ICD mode, generate an error and returns 1 */ ++/* else returns 0 */ ++static int ++atr_xgm_in_icd (const PedDisk* disk, PedPartitionType part_type) ++{ ++ AtariDisk* atrdisk; ++ ++ PED_ASSERT (disk != NULL); ++ ++ if (part_type & PED_PARTITION_EXTENDED) { ++ atrdisk = ATARI_DISK (disk); ++ if (atrdisk->format == FMT_ICD) { ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, ++ _("You can't use an extended XGM partition in " ++ "ICD mode (more than %d primary partitions, if " ++ "XGM is the first one it counts for two)."), ++ N_AHDI ); ++ return 1; ++ } ++ } ++ ++ return 0; ++} ++ ++static PedPartition* ++atari_partition_new (const PedDisk* disk, PedPartitionType part_type, ++ const PedFileSystemType* fs_type, ++ PedSector start, PedSector end) ++{ ++ PedPartition* part; ++ AtariPart* atrpart; ++ ++ if (atr_xgm_in_icd(disk, part_type)) ++ return 0; ++ ++ part = _ped_partition_alloc (disk, part_type, fs_type, start, end); ++ if (!part) ++ goto error; ++ if (ped_partition_is_active (part)) { ++ part->disk_specific = atrpart = ped_malloc (sizeof (AtariPart)); ++ if (!atrpart) ++ goto error_free_part; ++ memset (atrpart, 0, sizeof (AtariPart)); ++ } else { ++ part->disk_specific = NULL; ++ } ++ return part; ++ ++error_free_part: ++ _ped_partition_free (part); ++error: ++ return NULL; ++} ++ ++static PedPartition* ++atari_partition_duplicate (const PedPartition* part) ++{ ++ PedPartition* new_part; ++ ++ new_part = ped_partition_new (part->disk, part->type, ++ part->fs_type, part->geom.start, ++ part->geom.end); ++ if (!new_part) ++ return NULL; ++ new_part->num = part->num; ++ if (ped_partition_is_active (part)) ++ memcpy (new_part->disk_specific, part->disk_specific, ++ sizeof (AtariPart)); ++ ++ return new_part; ++} ++ ++static void ++atari_partition_destroy (PedPartition* part) ++{ ++ PED_ASSERT (part != NULL); ++ ++ if (ped_partition_is_active (part)) { ++ PED_ASSERT (part->disk_specific != NULL); ++ free (part->disk_specific); ++ } ++ _ped_partition_free (part); ++} ++ ++/* Note: fs_type is NULL for extended partitions */ ++static int ++atari_partition_set_system (PedPartition* part, ++ const PedFileSystemType* fs_type) ++{ ++ AtariPart* atrpart; ++ AtariFS2PartId* fs2id; ++ PED_ASSERT (part != NULL); ++ atrpart = ATARI_PART (part); ++ PED_ASSERT (atrpart != NULL); ++ ++ part->fs_type = fs_type; ++ ++ if (atr_xgm_in_icd(part->disk, part->type)) ++ return 0; ++ ++ if (part->type & PED_PARTITION_EXTENDED) { ++ strcpy (atrpart->part_id, "XGM"); ++ strcpy (atrpart->icd_id, "XGM"); ++ return 1; ++ } ++ ++ if (!fs_type) { ++ strcpy (atrpart->part_id, "RAW"); ++ strcpy (atrpart->icd_id, "RAW"); ++ return 1; ++ } ++ ++ for (fs2id = atr_fs2pid; fs2id->fs; fs2id++) { ++ if (!*fs2id->fs /* default entry */ ++ || ((!strcmp (fs_type->name, fs2id->fs) ++ && part->geom.length < fs2id->max_sectors))) { ++ ++ strcpy (atrpart->part_id, fs2id->pid); ++ if (atr_pid_known (fs2id->pid, atr_known_icd_pid)) ++ strcpy (atrpart->icd_id, fs2id->pid); ++ else ++ strcpy (atrpart->icd_id, "RAW"); ++ ++ break; ++ } ++ } ++ PED_ASSERT (fs2id->fs != NULL); ++ ++ return 1; ++} ++ ++static int ++atari_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state) ++{ ++ AtariPart* atr_part; ++ AtariPartID2BootFlag* bf; ++ ++ PED_ASSERT (part != NULL); ++ atr_part = ATARI_PART (part); ++ PED_ASSERT (atr_part != NULL); ++ ++ if (flag != PED_PARTITION_BOOT) ++ return 0; ++ ++ if (state == 0) { ++ atr_part->flag = 0; ++ } else { ++ for (bf = atr_pid2bf; *bf->pid; bf++) { ++ if (atr_pid_eq (bf->pid, atr_part->part_id)) ++ break; ++ } ++ atr_part->flag = bf->flag; ++ } ++ ++ return 1; ++} ++ ++static int _GL_ATTRIBUTE_PURE ++atari_partition_get_flag (const PedPartition* part, PedPartitionFlag flag) ++{ ++ AtariPart* atr_part; ++ ++ PED_ASSERT (part != NULL); ++ atr_part = ATARI_PART (part); ++ PED_ASSERT (atr_part != NULL); ++ ++ if (flag != PED_PARTITION_BOOT) ++ return 0; ++ ++ return (atr_part->flag != 0); ++} ++ ++static int ++atari_partition_is_flag_available (const PedPartition* part, ++ PedPartitionFlag flag) ++{ ++ if (flag == PED_PARTITION_BOOT) ++ return 1; ++ ++ return 0; ++} ++ ++/* Adapted from disk_dos */ ++static PedConstraint* ++atr_log_constraint (const PedPartition* part) ++{ ++ const PedGeometry* geom = &part->geom; ++ PedGeometry safe_space; ++ PedSector min_start; ++ PedSector max_end; ++ PedDisk* disk; ++ PedDevice* dev; ++ PedPartition* ext_part; ++ PedPartition* walk; ++ int first_log, not_first; ++ ++ PED_ASSERT (part->disk != NULL); ++ PED_ASSERT (part->disk->dev != NULL); ++ ext_part = ped_disk_extended_partition (part->disk); ++ PED_ASSERT (ext_part != NULL); ++ ++ dev = (disk = part->disk) -> dev; ++ ++ first_log = atr_find_first_log (disk); ++ if (first_log == -1) ++ first_log = part->num; ++ ++ not_first = (part->num != first_log); ++ ++ walk = ext_part->part_list; ++ ++ min_start = ext_part->geom.start + 1 + not_first; ++ max_end = ext_part->geom.end; ++ ++ while (walk != NULL ++ && ( walk->geom.start - (walk->num != first_log) ++ < geom->start - not_first ++ || walk->geom.start - (walk->num != first_log) ++ < min_start ) ) { ++ if (walk != part && ped_partition_is_active (walk)) ++ min_start = walk->geom.end + 1 + not_first; ++ walk = walk->next; ++ } ++ ++ while (walk && (walk == part || !ped_partition_is_active (walk))) ++ walk = walk->next; ++ ++ if (walk) ++ max_end = walk->geom.start - 1 - (walk->num != first_log); ++ ++ if (min_start >= max_end) ++ return NULL; ++ ++ ped_geometry_init (&safe_space, dev, min_start, ++ max_end - min_start + 1); ++ return ped_constraint_new_from_max (&safe_space); ++} ++ ++/* Adapted from disk_dos */ ++static PedGeometry* ++art_min_extended_geom (const PedPartition* ext_part) ++{ ++ PedDisk* disk = ext_part->disk; ++ PedPartition* walk; ++ PedGeometry* min_geom; ++ int first_log; ++ ++ first_log = atr_find_first_log (disk); ++ if (first_log == -1) ++ return NULL; ++ ++ walk = ped_disk_get_partition (disk, first_log); ++ PED_ASSERT (walk->type & PED_PARTITION_LOGICAL); ++ min_geom = ped_geometry_duplicate (&walk->geom); ++ if (!min_geom) ++ return NULL; ++ ped_geometry_set_start (min_geom, walk->geom.start - 1); ++ ++ for (walk = ext_part->part_list; walk; walk = walk->next) { ++ if (!ped_partition_is_active (walk) || walk->num == first_log) ++ continue; ++ if (walk->geom.start < min_geom->start) ++ ped_geometry_set_start (min_geom, walk->geom.start - 2); ++ if (walk->geom.end > min_geom->end) ++ ped_geometry_set_end (min_geom, walk->geom.end); ++ } ++ ++ return min_geom; ++} ++ ++/* Adapted from disk_dos */ ++static PedConstraint* ++atr_ext_constraint (const PedPartition* part) ++{ ++ PedGeometry start_range; ++ PedGeometry end_range; ++ PedConstraint* constraint; ++ PedDevice* dev; ++ PedDisk* disk; ++ PedGeometry* min; ++ ++ PED_ASSERT (part->disk != NULL); ++ PED_ASSERT (part->disk->dev != NULL); ++ ++ dev = (disk = part->disk) -> dev; ++ min = art_min_extended_geom (part); ++ ++ if (min) { ++ ped_geometry_init (&start_range, dev, 1, min->start); ++ ped_geometry_init (&end_range, dev, min->end, ++ dev->length - min->end); ++ ped_geometry_destroy (min); ++ } else { ++ ped_geometry_init (&start_range, dev, 1, dev->length - 1); ++ ped_geometry_init (&end_range, dev, 1, dev->length - 1); ++ } ++ ++ constraint = ped_constraint_new (ped_alignment_any, ped_alignment_any, ++ &start_range, &end_range, 1, dev->length); ++ return constraint; ++} ++ ++static PedConstraint* ++atr_prim_constraint (const PedPartition* part) ++{ ++ PedDevice* dev; ++ PedGeometry max; ++ ++ PED_ASSERT (part->disk != NULL); ++ PED_ASSERT (part->disk->dev != NULL); ++ ++ dev = part->disk->dev; ++ ++ ped_geometry_init (&max, dev, 1, dev->length - 1); ++ return ped_constraint_new_from_max (&max); ++} ++ ++/* inspiration from disk_dos */ ++static PedGeometry* ++_best_solution (PedGeometry* a, PedGeometry* b) ++{ ++ if (!a) ++ return b; ++ if (!b) ++ return a; ++ ++ if (a->length < b->length) ++ goto choose_b; ++ ++ ped_geometry_destroy (b); ++ return a; ++ ++choose_b: ++ ped_geometry_destroy (a); ++ return b; ++} ++ ++/* copied from disk_dos */ ++static PedGeometry* ++_try_constraint (const PedPartition* part, const PedConstraint* external, ++ PedConstraint* internal) ++{ ++ PedConstraint* intersection; ++ PedGeometry* solution; ++ ++ intersection = ped_constraint_intersect (external, internal); ++ ped_constraint_destroy (internal); ++ if (!intersection) ++ return NULL; ++ ++ solution = ped_constraint_solve_nearest (intersection, &part->geom); ++ ped_constraint_destroy (intersection); ++ return solution; ++} ++ ++/* ++ * internal is either the primary or extented constraint. ++ * If there's no BSL, the is the only internal constraint considered. ++ * If there's a BSL, try to fit the partition before or after (and ++ * choose the best fit, the one which results in the greatest size...) ++ */ ++static int ++atr_prim_align (PedPartition* part, const PedConstraint* constraint, ++ PedConstraint* internal) ++{ ++ PedDevice* dev; ++ AtariDisk* atr_disk; ++ PedConstraint* cut; ++ PedGeometry* solution = NULL; ++ PedGeometry max; ++ PedSector bsl_end; ++ ++ PED_ASSERT (part->disk != NULL); ++ PED_ASSERT (part->disk->dev != NULL); ++ dev = part->disk->dev; ++ atr_disk = ATARI_DISK (part->disk); ++ PED_ASSERT (atr_disk != NULL); ++ ++ /* No BSL */ ++ if (!atr_disk->bsl_start && !atr_disk->bsl_count) { ++ /* Note: _ped_partition_attempt_align will destroy internal */ ++ return _ped_partition_attempt_align(part, constraint, internal); ++ } ++ ++ /* BSL, try to fit before */ ++ if (atr_disk->bsl_start > 1) { ++ ped_geometry_init (&max, dev, 1, atr_disk->bsl_start - 1); ++ cut = ped_constraint_new_from_max (&max); ++ solution = _best_solution (solution, ++ _try_constraint (part, constraint, ++ ped_constraint_intersect (internal, cut))); ++ ped_constraint_destroy (cut); ++ } ++ ++ /* BSL, try to fit after, take the best solution */ ++ bsl_end = atr_disk->bsl_start + atr_disk->bsl_count; ++ if (bsl_end < dev->length) { ++ ped_geometry_init (&max, dev, bsl_end, dev->length - bsl_end); ++ cut = ped_constraint_new_from_max (&max); ++ solution = _best_solution (solution, ++ _try_constraint (part, constraint, ++ ped_constraint_intersect (internal, cut))); ++ ped_constraint_destroy (cut); ++ } ++ ++ ped_constraint_destroy (internal); ++ ++ if (solution) { ++ ped_geometry_set (&part->geom, solution->start, ++ solution->length); ++ ped_geometry_destroy (solution); ++ return 1; ++ } ++ ++ return 0; ++} ++ ++static int ++atari_partition_align (PedPartition* part, const PedConstraint* constraint) ++{ ++ PED_ASSERT (part != NULL); ++ ++ switch (part->type) { ++ case PED_PARTITION_LOGICAL: ++ if (_ped_partition_attempt_align (part, constraint, ++ atr_log_constraint (part) ) ) ++ return 1; ++ break; ++ case PED_PARTITION_EXTENDED: ++ if (atr_prim_align (part, constraint, ++ atr_ext_constraint (part) ) ) ++ return 1; ++ break; ++ default: ++ if (atr_prim_align (part, constraint, ++ atr_prim_constraint (part) ) ) ++ return 1; ++ break; ++ } ++ ++#ifndef DISCOVER_ONLY ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_CANCEL, ++ _("Unable to satisfy all constraints on the partition.")); ++#endif ++ return 0; ++} ++ ++/* increment numbers of any non logical partition found after the last */ ++/* logical one, to make room for a new logical partition */ ++static int ++art_room_for_logic (PedDisk* disk) ++{ ++ PedPartition* part; ++ int num, last_logic, last; ++ ++ /* too many partitions ? */ ++ last = ped_disk_get_last_partition_num (disk); ++ if (last >= MAXIMUM_PARTS) ++ return 0; ++ ++ /* find the last logical partition */ ++ last_logic = 0; ++ for (num = 1; num <= last; num++) { ++ part = ped_disk_get_partition (disk, num); ++ if (part && ped_partition_is_active (part) ++ && (part->type & PED_PARTITION_LOGICAL)) ++ last_logic = num; ++ } ++ ++ if (!last_logic) ++ return 1; ++ ++ /* increment */ ++ for (num = last; num > last_logic; num--) { ++ part = ped_disk_get_partition (disk, num); ++ if (part && ped_partition_is_active (part) ++ && !(part->type & ( PED_PARTITION_LOGICAL ++ | PED_PARTITION_EXTENDED)) ++ && part->num > 0 ) ++ part->num++; ++ } ++ ++ return 1; ++} ++ ++static int ++atari_partition_enumerate (PedPartition* part) ++{ ++ AtariDisk* atrdisk; ++ PedPartition* ext_part; ++ PedPartition* log; ++ int i, want_icd, want_xgm, num_max, xgm_begin, prim_count; ++ ++ PED_ASSERT (part != NULL); ++ PED_ASSERT (part->disk != NULL); ++ atrdisk = ATARI_DISK (part->disk); ++ PED_ASSERT (atrdisk != NULL); ++ ++ /* WARNING: some similar/related code in atari_write */ ++ /* This is quite a : this function is probably the only way */ ++ /* to know something has been / is going to be modified in the table.*/ ++ /* So we detect the current operation mode (AHDI/XGM/ICD) and report */ ++ /* errors (in which case we refuse to operate...) */ ++ ++ prim_count = ped_disk_get_primary_partition_count (part->disk); ++ ext_part = ped_disk_extended_partition (part->disk); ++ ++ /* : we can't reorder (yet) , so if we begin with */ ++ /* XGM the first slot must be empty */ ++ xgm_begin = ((log = ped_disk_get_partition (part->disk, 1)) ++ && (log->type & PED_PARTITION_LOGICAL)) ++ || ((part->num == -1) ++ && (part->type & PED_PARTITION_LOGICAL) ++ && !ped_disk_get_partition (part->disk, 1)); ++ /* */ ++ ++ PED_ASSERT (atrdisk->format != FMT_ICD || ext_part == NULL); ++ PED_ASSERT (atrdisk->format != FMT_XGM ++ || prim_count + xgm_begin <= N_AHDI); ++ PED_ASSERT (atrdisk->format != FMT_AHDI ++ || (ext_part == NULL && prim_count + xgm_begin <= N_AHDI)); ++ ++ want_icd = ( ( prim_count ++ + xgm_begin ++ + ( (part->num == -1) ++ && !(part->type & PED_PARTITION_LOGICAL) ) ) ++ > N_AHDI ); ++ want_xgm = ( (part->type & PED_PARTITION_EXTENDED) ++ || ext_part != NULL ); ++ ++ if (!want_xgm && !want_icd) ++ atrdisk->format = FMT_AHDI; ++ else if (want_xgm && !want_icd) ++ atrdisk->format = FMT_XGM; ++ else if (!want_xgm && want_icd) ++ atrdisk->format = FMT_ICD; ++ else { ++ if (atr_xgm_in_icd (part->disk, PED_PARTITION_EXTENDED)) ++ return 0; ++ else { ++ ped_exception_throw ( ++ PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, ++ _("You can't use more than %d primary partitions " ++ "(ICD mode) if you use an extended XGM " ++ "partition. If XGM is the first partition " ++ "it counts for two."), ++ N_AHDI ); ++ return 0; ++ } ++ } ++ /* End of */ ++ ++ ++ /* Ext will be numbered 0 and will stay 0... */ ++ if (part->num == 0) ++ return 1; ++ ++ if (part->num == -1) { ++ ++ /* Linux don't show the ext part itself for Atari disk labels */ ++ /* so we use number 0 (could use a big number too, but that */ ++ /* would be less cute ;) */ ++ if (part->type & PED_PARTITION_EXTENDED) { ++ part->num = 0; ++ return 1; ++ } ++ ++ switch (atrdisk->format) { ++ case FMT_AHDI: ++ case FMT_ICD: ++ num_max = N_ICD + N_AHDI; ++ break; ++ case FMT_XGM: ++ num_max = MAXIMUM_PARTS; ++ break; ++ default: ++ num_max = 0; ++ PED_ASSERT (0); ++ } ++ ++ /* make room for logical partitions */ ++ if (part->type & PED_PARTITION_LOGICAL) { ++ if (!art_room_for_logic (part->disk)) ++ goto error_alloc_failed; ++ } ++ ++ /* find an unused number */ ++ for (i = 1; i <= num_max; i++) { ++ if (!ped_disk_get_partition (part->disk, i)) { ++ part->num = i; ++ return 1; ++ } ++ } ++ ++ } else { ++ /* find an unused number before or don't re-number */ ++ for (i = 1; i < part->num; i++) { ++ if (!ped_disk_get_partition (part->disk, i)) { ++ part->num = i; ++ } ++ } ++ return 1; ++ } ++ ++ /* failed to allocate a number */ ++error_alloc_failed: ++#ifndef DISCOVER_ONLY ++ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, ++ _("Unable to allocate a partition number.")); ++#endif ++ return 0; ++} ++ ++static int ++atr_creat_add_metadata (PedDisk* disk, PedSector start, PedSector end, ++ PedPartitionType type ) ++{ ++ PedPartition* new_part; ++ PedConstraint* const_exact; ++ int added; ++ ++ type |= PED_PARTITION_METADATA; ++ new_part = ped_partition_new (disk, type, NULL, start, end); ++ if (!new_part) ++ goto error; ++ ++ const_exact = ped_constraint_exact (&new_part->geom); ++ added = ped_disk_add_partition (disk, new_part, const_exact); ++ ped_constraint_destroy (const_exact); ++ if (!added) ++ goto error_destroy_part; ++ ++ return 1; ++ ++error_destroy_part: ++ ped_partition_destroy (new_part); ++error: ++ return 0; ++} ++ ++static int ++atari_alloc_metadata (PedDisk* disk) ++{ ++ PedPartition* ext; ++ PedPartition* log; ++ AtariDisk* atr_disk; ++ int i; ++ ++ PED_ASSERT (disk != NULL); ++ PED_ASSERT (disk->dev != NULL); ++ atr_disk = ATARI_DISK (disk); ++ PED_ASSERT (atr_disk != NULL); ++ ++ /* allocate 1 sector for the disk label at the start */ ++ if (!atr_creat_add_metadata (disk, 0, 0, 0)) ++ return 0; ++ ++ /* allocate the sectors containing the BSL */ ++ if (atr_disk->bsl_start || atr_disk->bsl_count) { ++ if (!atr_creat_add_metadata (disk, atr_disk->bsl_start, ++ atr_disk->bsl_start ++ + atr_disk->bsl_count - 1, 0 ) ) ++ return 0; ++ } ++ ++ ext = ped_disk_extended_partition (disk); ++ if (ext) { ++ if (!atr_creat_add_metadata (disk, ext->geom.start, ++ ext->geom.start, ++ PED_PARTITION_LOGICAL ) ) ++ return 0; ++ ++ /* Find the first logical part */ ++ for (i = 1; i <= ped_disk_get_last_partition_num (disk); i++) ++ if ((log = ped_disk_get_partition (disk, i)) ++ && (log->type & PED_PARTITION_LOGICAL)) ++ break; ++ ++ for (log = ext->part_list; log; log = log->next) { ++ if ((log->type & ( PED_PARTITION_METADATA ++ | PED_PARTITION_FREESPACE)) ++ || log->num == i) ++ continue; ++ ++ if (!atr_creat_add_metadata (disk, log->geom.start-1, ++ log->geom.start-1, ++ PED_PARTITION_LOGICAL ) ) ++ return 0; ++ } ++ } ++ ++ return 1; ++} ++ ++static int _GL_ATTRIBUTE_PURE ++atari_get_max_primary_partition_count (const PedDisk* disk) ++{ ++ AtariDisk* atr_disk; ++ ++ PED_ASSERT (disk != NULL); ++ atr_disk = ATARI_DISK (disk); ++ PED_ASSERT (atr_disk != NULL); ++ ++ return atr_disk->format == FMT_XGM ? N_AHDI : N_AHDI + N_ICD; ++} ++ ++static bool ++atari_get_max_supported_partition_count (const PedDisk* disk, int *max_n) ++{ ++ AtariDisk* atr_disk; ++ ++ PED_ASSERT (disk != NULL); ++ atr_disk = ATARI_DISK (disk); ++ PED_ASSERT (atr_disk != NULL); ++ ++ *max_n = atr_disk->format == FMT_XGM ? N_AHDI : N_AHDI + N_ICD; ++ return true; ++} ++ ++#include "pt-common.h" ++PT_define_limit_functions(atari) ++ ++static PedDiskOps atari_disk_ops = { ++ clobber: NULL_IF_DISCOVER_ONLY (atari_clobber), ++ write: NULL_IF_DISCOVER_ONLY (atari_write), ++ ++ partition_set_name: NULL, ++ partition_get_name: NULL, ++ ++ PT_op_function_initializers (atari) ++}; ++ ++static PedDiskType atari_disk_type = { ++ next: NULL, ++ name: "atari", ++ ops: &atari_disk_ops, ++ features: PED_DISK_TYPE_EXTENDED ++}; ++ ++void ++ped_disk_atari_init () ++{ ++ PED_ASSERT (sizeof (AtariRawPartition) == 12); ++ PED_ASSERT (sizeof (AtariRawTable) == 512); ++ /* GNU Libc doesn't support NULL instead of the locale name */ ++ PED_ASSERT ((atr_c_locale = newlocale(LC_ALL_MASK, "C", NULL)) != NULL); ++ ++ ped_disk_type_register (&atari_disk_type); ++} ++ ++void ++ped_disk_atari_done () ++{ ++ ped_disk_type_unregister (&atari_disk_type); ++ freelocale(atr_c_locale); ++} +diff --git a/libparted/labels/pt-limit.gperf b/libparted/labels/pt-limit.gperf +index 3d764ae..d5a580d 100644 +--- a/libparted/labels/pt-limit.gperf ++++ b/libparted/labels/pt-limit.gperf +@@ -25,3 +25,4 @@ pc98,UINT32_MAX,UINT32_MAX + # + # FIXME: not verified. looks like these are cylinder aligned, too + amiga,UINT32_MAX,UINT32_MAX ++atari,INT32_MAX,INT32_MAX +diff --git a/libparted/libparted.c b/libparted/libparted.c +index d5cbb3a..d855d0e 100644 +--- a/libparted/libparted.c ++++ b/libparted/libparted.c +@@ -75,6 +75,7 @@ extern void ped_disk_pc98_init (); + extern void ped_disk_sun_init (); + extern void ped_disk_amiga_init (); + extern void ped_disk_dasd_init (); ++extern void ped_disk_atari_init (); + + static void + init_disk_types () +@@ -96,6 +97,7 @@ 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); +@@ -139,6 +141,7 @@ extern void ped_disk_pc98_done (); + extern void ped_disk_sun_done (); + extern void ped_disk_amiga_done (); + extern void ped_disk_dasd_done (); ++extern void ped_disk_atari_done (); + + static void + done_disk_types () +@@ -158,6 +161,7 @@ done_disk_types () + ped_disk_bsd_done (); + ped_disk_amiga_done (); + ped_disk_aix_done (); ++ ped_disk_atari_done (); + } + + static void _init() __attribute__ ((constructor)); +diff --git a/libparted/tests/common.c b/libparted/tests/common.c +index 9115686..2be0e3a 100644 +--- a/libparted/tests/common.c ++++ b/libparted/tests/common.c +@@ -83,6 +83,9 @@ _implemented_disk_label (const char *label) + /* FIXME: these have minor problems, so skip them, temporarily. */ + if (STREQ (label, "amiga")) return 0; + ++ if (STREQ (label, "atari") && get_sector_size() != 512) ++ return 0; ++ + /* Not implemented yet */ + if (STREQ (label, "aix")) return 0; + if (STREQ (label, "pc98")) return 0; +diff --git a/po/POTFILES.in b/po/POTFILES.in +index a8e5994..7a196f7 100644 +--- a/po/POTFILES.in ++++ b/po/POTFILES.in +@@ -27,6 +27,7 @@ libparted/debug.c + libparted/disk.c + libparted/exception.c + libparted/labels/aix.c ++libparted/labels/atari.c + libparted/labels/bsd.c + libparted/labels/dasd.c + libparted/labels/dos.c +diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh +index 10ac50d..2da72d0 100644 +--- a/tests/t3310-flags.sh ++++ b/tests/t3310-flags.sh +@@ -25,7 +25,7 @@ extract_flags() + perl -nle '/^[^:]*:4096s:6143s:2048s::[^:]*:(.+);$/ and print $1' "$@" + } + +-for table_type in aix amiga bsd dvh gpt mac msdos pc98 sun loop; do ++for table_type in aix amiga atari bsd dvh gpt mac msdos pc98 sun loop; do + ptn_num=1 + + case $table_type in +@@ -35,6 +35,10 @@ for table_type in aix amiga bsd dvh gpt mac msdos pc98 sun loop; do + ;; + amiga) primary_or_name='PTNNAME' + ;; ++ atari) primary_or_name='primary' ++ # atari only supports 512b sectors ++ [ $ss -ne 512 ] && continue ++ ;; + bsd) primary_or_name='' + ;; + dvh) primary_or_name='primary' +diff --git a/tests/t9021-maxima.sh b/tests/t9021-maxima.sh +index 510e6c2..5320a6e 100755 +--- a/tests/t9021-maxima.sh ++++ b/tests/t9021-maxima.sh +@@ -37,6 +37,7 @@ max_n_partitions() + mac) m=65536;; + bsd) m=8;; + amiga) m=128;; ++ atari) m=12;; + loop) m=1;; + pc98) case $ss in 512) m=16;; *) m=64;; esac;; + *) warn_ invalid partition table type: $1 1>&2; exit 1;; +@@ -45,8 +46,9 @@ max_n_partitions() + } + + # FIXME: add aix when/if it's supported again +-for t in msdos gpt dvh sun mac bsd amiga loop pc98; do ++for t in msdos gpt dvh sun mac bsd amiga atari loop pc98; do + echo $t ++ [ $t == 'atari' ] && [ $ss != 512 ] && continue + rm -f $dev + dd if=/dev/zero of=$dev bs=$ss count=1 seek=10000 || { fail=1; continue; } + parted -s $dev mklabel $t || { fail=1; continue; } +@@ -56,6 +58,7 @@ for t in msdos gpt dvh sun mac bsd amiga loop pc98; do + max_start=4294967295 + max_len=4294967295 + case $t in ++ atari) max_start=2147483647; max_len=$max_start;; + gpt|loop) max_start=18446744073709551615; max_len=$max_start;; + sun) max_start=549755813760;; # 128 * (2^32-1) + esac +-- +2.9.3 + diff --git a/SOURCES/0066-mac-copy-partition-type-and-name-correctly.patch b/SOURCES/0066-mac-copy-partition-type-and-name-correctly.patch new file mode 100644 index 0000000..2007dfa --- /dev/null +++ b/SOURCES/0066-mac-copy-partition-type-and-name-correctly.patch @@ -0,0 +1,42 @@ +From 783e08a4e5f6769f7ebd2f3e43ca4ccfab003e8b Mon Sep 17 00:00:00 2001 +From: Sergei Antonov +Date: Fri, 3 Jul 2015 00:21:23 +0200 +Subject: [PATCH 66/75] mac: copy partition type and name correctly + +Use strncpy() instead of strcpy() to copy partition name and type. +This prevents possible buffer overflow, because the source string +occupies up to 33 bytes with a terminating null. + +Static analysis tools complain about the code as it is now: + Function: _generate_raw_part + Destination buffer too small + string_overflow: You might overrun the 32 byte destination string + part_map_entry->type by writing 33 bytes from mac_part_data->system_name + (Destination buffer too small, line 933) + +Cc: Sabas Rosales, Blanca E +Signed-off-by: Sergei Antonov +Signed-off-by: Brian C. Lane +(cherry picked from commit 282e25e0384e8d1275ccacf904fdaf65f1d4a8af) +--- + libparted/labels/mac.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c +index 1034418..d8da941 100644 +--- a/libparted/labels/mac.c ++++ b/libparted/labels/mac.c +@@ -930,8 +930,8 @@ _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); +- strcpy (part_map_entry->name, mac_part_data->volume_name); +- strcpy (part_map_entry->type, mac_part_data->system_name); ++ strncpy (part_map_entry->name, mac_part_data->volume_name, 32); ++ strncpy (part_map_entry->type, mac_part_data->system_name, 32); + + if (mac_part_data->is_driver) { + mac_part_data->boot_region_length = part->geom.length; +-- +2.9.3 + diff --git a/SOURCES/0067-libparted-Fix-MacOS-boot-support.patch b/SOURCES/0067-libparted-Fix-MacOS-boot-support.patch new file mode 100644 index 0000000..69c7956 --- /dev/null +++ b/SOURCES/0067-libparted-Fix-MacOS-boot-support.patch @@ -0,0 +1,122 @@ +From 526f3ee2afbe7cd90d282915b7b580d4f356c4eb Mon Sep 17 00:00:00 2001 +From: Laurent Vivier +Date: Fri, 9 Dec 2016 15:10:53 +0100 +Subject: [PATCH 67/75] libparted: Fix MacOS boot support + +boot_region_length (or BootSize in the MacOS dialect) is the length +of the driver code in the driver partition. This length is used +to compute the checksum of the driver. + +libparted updates this value by setting the whole size of the partition +without computing the checksum of the driver using this size. + +As the checksum is wrong, the driver is broken and cannot be loaded +by the MacOS ROM, and thus the disk is not bootable anymore. + +Moreover, parted try to update the driver list and makes it disappear. + +As parted is not able to insert a driver in a partition, +the driver is generally inserted by the Apple HD Tool, +this patch removes the line updating the driver size. + +We also simplify the driver list scan and fix endianess use. + +This has been tested... and it works, now. + +I have updated a bootable disk with parted on x86_64 and +then been able to boot it (again) on a Mac LC III. + +Signed-off-by: Laurent Vivier +Signed-off-by: Brian C. Lane +--- + libparted/labels/mac.c | 41 ++++++++++++++++++++--------------------- + 1 file changed, 20 insertions(+), 21 deletions(-) + +diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c +index d8da941..fa4e43f 100644 +--- a/libparted/labels/mac.c ++++ b/libparted/labels/mac.c +@@ -411,14 +411,14 @@ _rawpart_has_driver (const MacRawPartition* raw_part, MacDiskData* mac_disk_data + { + MacDeviceDriver *driverlist; + uint16_t i; +- uint32_t driver_bs, driver_be, part_be; ++ uint32_t start_block, block_count; + ++ start_block = PED_BE32_TO_CPU(raw_part->start_block); ++ block_count = PED_BE32_TO_CPU(raw_part->block_count); + driverlist = &mac_disk_data->driverlist[0]; + for (i = 0; i < mac_disk_data->driver_count; i++) { +- driver_bs = driverlist->block; +- driver_be = driver_bs + driverlist->size; +- part_be = raw_part->start_block + raw_part->block_count; +- if (driver_bs >= raw_part->start_block && driver_be <= part_be) ++ if (start_block == PED_BE32_TO_CPU(driverlist->block) && ++ block_count == PED_BE16_TO_CPU(driverlist->size)) + return 1; + driverlist++; + } +@@ -751,11 +751,12 @@ mac_read (PedDisk* disk) + if (!ped_disk_delete_all (disk)) + goto error; + +- if (raw_disk->driver_count && raw_disk->driver_count < 62) { ++ if (PED_BE16_TO_CPU(raw_disk->driver_count) && ++ PED_BE16_TO_CPU(raw_disk->driver_count) < 62) { + memcpy(&mac_disk_data->driverlist[0], &raw_disk->driverlist[0], + sizeof(mac_disk_data->driverlist)); +- mac_disk_data->driver_count = raw_disk->driver_count; +- mac_disk_data->block_size = raw_disk->block_size; ++ mac_disk_data->driver_count = PED_BE16_TO_CPU(raw_disk->driver_count); ++ mac_disk_data->block_size = PED_BE16_TO_CPU(raw_disk->block_size); + } + + /* If _disk_analyse_block_size has increased the sector_size, +@@ -877,17 +878,16 @@ static void + _update_driver_count (MacRawPartition* part_map_entry, + MacDiskData *mac_driverdata, const MacDiskData* mac_disk_data) + { +- uint16_t i, count_orig, count_cur; +- uint32_t driver_bs, driver_be, part_be; +- +- count_cur = mac_driverdata->driver_count; +- count_orig = mac_disk_data->driver_count; +- for (i = 0; i < count_orig; i++) { +- driver_bs = mac_disk_data->driverlist[i].block; +- driver_be = driver_bs + mac_disk_data->driverlist[i].size; +- part_be = part_map_entry->start_block + part_map_entry->block_count; +- if (driver_bs >= part_map_entry->start_block +- && driver_be <= part_be) { ++ uint16_t i; ++ uint32_t start_block, block_count; ++ ++ start_block = PED_BE32_TO_CPU(part_map_entry->start_block); ++ block_count = PED_BE32_TO_CPU(part_map_entry->block_count); ++ ++ for (i = 0; i < mac_disk_data->driver_count; i++) { ++ if (start_block == PED_BE32_TO_CPU(mac_disk_data->driverlist[i].block) && ++ block_count == PED_BE16_TO_CPU(mac_disk_data->driverlist[i].size)) { ++ uint16_t count_cur = mac_driverdata->driver_count; + mac_driverdata->driverlist[count_cur].block + = mac_disk_data->driverlist[i].block; + mac_driverdata->driverlist[count_cur].size +@@ -934,7 +934,6 @@ _generate_raw_part (PedDisk* disk, PedPartition* part, + strncpy (part_map_entry->type, mac_part_data->system_name, 32); + + if (mac_part_data->is_driver) { +- mac_part_data->boot_region_length = part->geom.length; + if (mac_part_data->has_driver) + _update_driver_count(part_map_entry, mac_driverdata, + mac_disk_data); +@@ -1042,7 +1041,7 @@ write_block_zero (PedDisk* disk, MacDiskData* mac_driverdata) + raw_disk->block_size = PED_CPU_TO_BE16 (dev->sector_size); + raw_disk->block_count = PED_CPU_TO_BE32 (dev->length); + +- raw_disk->driver_count = mac_driverdata->driver_count; ++ raw_disk->driver_count = PED_CPU_TO_BE16(mac_driverdata->driver_count); + memcpy(&raw_disk->driverlist[0], &mac_driverdata->driverlist[0], + sizeof(raw_disk->driverlist)); + +-- +2.9.3 + diff --git a/SOURCES/0068-libparted-Fix-typo-in-hfs-error-message.patch b/SOURCES/0068-libparted-Fix-typo-in-hfs-error-message.patch new file mode 100644 index 0000000..cf31e66 --- /dev/null +++ b/SOURCES/0068-libparted-Fix-typo-in-hfs-error-message.patch @@ -0,0 +1,27 @@ +From c625f6769144472f3c099cdd512318cea18e2766 Mon Sep 17 00:00:00 2001 +From: Sebastian Rasmussen +Date: Thu, 19 Jan 2017 23:38:40 +0100 +Subject: [PATCH 68/75] libparted: Fix typo in hfs error message + +--- + libparted/fs/r/hfs/cache.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libparted/fs/r/hfs/cache.c b/libparted/fs/r/hfs/cache.c +index 68be366..03c2913 100644 +--- a/libparted/fs/r/hfs/cache.c ++++ b/libparted/fs/r/hfs/cache.c +@@ -210,8 +210,8 @@ hfsc_cache_move_extent(HfsCPrivateCache* cache, uint32_t old_start, + ped_exception_throw ( + PED_EXCEPTION_BUG, + PED_EXCEPTION_CANCEL, +- _("Trying to move an extent from block Ox%X to block " +- "Ox%X, but another one already exists at this " ++ _("Trying to move an extent from block 0x%X to block " ++ "0x%X, but another one already exists at this " + "position. This should not happen!"), + old_start, new_start); + return NULL; +-- +2.9.3 + diff --git a/SOURCES/0069-Fix-crash-when-localized.patch b/SOURCES/0069-Fix-crash-when-localized.patch new file mode 100644 index 0000000..e4028b3 --- /dev/null +++ b/SOURCES/0069-Fix-crash-when-localized.patch @@ -0,0 +1,28 @@ +From 1f1382ab8672b9bb679ecc7e79583fd826908f6f Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 1 May 2017 17:04:11 -0700 +Subject: [PATCH 69/75] Fix crash when localized + +The _() macro is only for translating string literals. It was +incorrectly applied to a runtime string representing the name +of a partition and this sometimes caused a gettext crash. +--- + parted/parted.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/parted/parted.c b/parted/parted.c +index bd848c3..f767bec 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -1276,7 +1276,7 @@ do_print (PedDevice** dev, PedDisk** diskp) + putchar (':'); + + if (has_name) +- printf ("%s:", _(ped_partition_get_name (part))); ++ printf ("%s:", ped_partition_get_name (part)); + else + putchar (':'); + +-- +2.9.3 + diff --git a/SOURCES/0070-Add-support-for-RAM-drives.patch b/SOURCES/0070-Add-support-for-RAM-drives.patch new file mode 100644 index 0000000..b724769 --- /dev/null +++ b/SOURCES/0070-Add-support-for-RAM-drives.patch @@ -0,0 +1,102 @@ +From eb927155680f75e570dc7375514e344a936a3fb5 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 1 May 2017 17:05:01 -0700 +Subject: [PATCH 70/75] Add support for RAM drives + +Recognize RAM drives, so "parted -s /dev/ram0 p" now prints +"RAM Drive (brd)" instead of "Model: Unknown (unknown)". + +In order for a device to be recognized as RAM drive, it has to +have major number 1. Also the BLKFLSBUF ioctl shouldn't be used +on RAM drives as it is used to zero the device. + +* NEWS: Mention the change +* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_RAM. +* libparted/arch/linux.c(RAM_MAJOR): New define. +* libparted/arch/linux.c(_device_probe_type): Recognize RAM drives. +* libparted/arch/linux.c(linux_new): Handle RAM drives. +* libparted/arch/linux.c(_flush_cache): Skip RAM drives. +* parted/parted.c(do_print): Add "brd" to list of transports. + +Signed-off-by: Sebastian Parschauer +--- + include/parted/device.in.h | 3 ++- + libparted/arch/linux.c | 12 ++++++++++-- + parted/parted.c | 2 +- + 3 files changed, 13 insertions(+), 4 deletions(-) + +diff --git a/include/parted/device.in.h b/include/parted/device.in.h +index d38db44..1b6e7b8 100644 +--- a/include/parted/device.in.h ++++ b/include/parted/device.in.h +@@ -50,7 +50,8 @@ typedef enum { + PED_DEVICE_AOE = 16, + PED_DEVICE_MD = 17, + PED_DEVICE_LOOP = 18, +- PED_DEVICE_NVME = 19 ++ PED_DEVICE_NVME = 19, ++ PED_DEVICE_RAM = 20 + } PedDeviceType; + + typedef struct _PedDevice PedDevice; +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 2058697..c2fdab0 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -279,6 +279,7 @@ struct blkdev_ioctl_param { + #define LOOP_MAJOR 7 + #define MD_MAJOR 9 + #define BLKEXT_MAJOR 259 ++#define RAM_MAJOR 1 + + #define SCSI_BLK_MAJOR(M) ( \ + (M) == SCSI_DISK0_MAJOR \ +@@ -701,6 +702,8 @@ _device_probe_type (PedDevice* dev) + dev->type = PED_DEVICE_MD; + } else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "nvme")) { + dev->type = PED_DEVICE_NVME; ++ } else if (dev_major == RAM_MAJOR) { ++ dev->type = PED_DEVICE_RAM; + } else { + dev->type = PED_DEVICE_UNKNOWN; + } +@@ -1547,6 +1550,11 @@ linux_new (const char* path) + goto error_free_arch_specific; + break; + ++ case PED_DEVICE_RAM: ++ if (!init_generic (dev, _("RAM Drive"))) ++ goto error_free_arch_specific; ++ break; ++ + default: + ped_exception_throw (PED_EXCEPTION_NO_FEATURE, + PED_EXCEPTION_CANCEL, +@@ -1619,9 +1627,9 @@ _flush_cache (PedDevice* dev) + { + LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); + int i; +- int lpn = _device_get_partition_range(dev); ++ int lpn = _device_get_partition_range(dev); + +- if (dev->read_only) ++ if (dev->read_only || dev->type == PED_DEVICE_RAM) + return; + dev->dirty = 0; + +diff --git a/parted/parted.c b/parted/parted.c +index f767bec..a7fcd3b 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -979,7 +979,7 @@ _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"}; ++ "md", "loopback", "nvme", "brd"}; + + char* start = ped_unit_format (dev, 0); + PedUnit default_unit = ped_unit_get_default (); +-- +2.9.3 + diff --git a/SOURCES/0071-parted-check-the-name-of-partition-first-when-to-nam.patch b/SOURCES/0071-parted-check-the-name-of-partition-first-when-to-nam.patch new file mode 100644 index 0000000..a1e88ac --- /dev/null +++ b/SOURCES/0071-parted-check-the-name-of-partition-first-when-to-nam.patch @@ -0,0 +1,43 @@ +From 1a891f6d352d47a6a9422083bbb38a2c4c4e901b Mon Sep 17 00:00:00 2001 +From: Wang Dong +Date: Fri, 24 Mar 2017 03:11:08 +0100 +Subject: [PATCH 71/75] parted: check the name of partition first when to name + a partition + +The previous function works well for the labels supporting naming +partition, but not for these which don't. If the disk label does not +support partition naming, two exceptions will be raised. Even after the first +error indicates it does not support name, parted yet asks user for +name in iteractive mode. + +First check if the disk label supports partition naming and if it +does, it will continue; otherwise, it will stop and raise an +exception. + +Signed-off-by: Wang Dong +Signed-off-by: Hendrik Brueckner +--- + parted/parted.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/parted/parted.c b/parted/parted.c +index a7fcd3b..d2e1f24 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -870,6 +870,13 @@ do_name (PedDevice** dev, PedDisk** diskp) + if (!*diskp) + goto error; + ++ if (!ped_disk_type_check_feature((*diskp)->type, PED_DISK_TYPE_PARTITION_NAME)) { ++ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, ++ _("%s disk labels do not support partition name."), ++ (*diskp)->type->name); ++ goto error; ++ } ++ + if (!command_line_get_partition (_("Partition number?"), *diskp, &part)) + goto error; + +-- +2.9.3 + diff --git a/SOURCES/0072-parted-ui-remove-unneccesary-information-of-command-.patch b/SOURCES/0072-parted-ui-remove-unneccesary-information-of-command-.patch new file mode 100644 index 0000000..a68a7ee --- /dev/null +++ b/SOURCES/0072-parted-ui-remove-unneccesary-information-of-command-.patch @@ -0,0 +1,42 @@ +From eb5eb44f6ef009c68cc8867e3277fa832cad7f10 Mon Sep 17 00:00:00 2001 +From: Wang Dong +Date: Fri, 24 Mar 2017 03:11:10 +0100 +Subject: [PATCH 72/75] parted/ui: remove unneccesary information of command + line + +When some command fails, the information still exists in +command_line buffer. When in command mode or interactive mode, +if an interactive exception prompts, the remained information +will be processed as option from user. This will raise some other +information or even unexpected results. So before getting option +input from user, clean the command line buffer. + +Example: When the disk label is invalid and user tries to make + new partition on the device with command like, + mkpart 0 50%. Then parted will raise an exception + telling an invalid disk label found and whether to correct it. + But at this time 0 as the input of mkpart will be + considered as the option input for the exception(yes/no). + So one more exception will raised with error information. + +Signed-off-by: Wang Dong +Signed-off-by: Hendrik Brueckner +--- + parted/ui.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/parted/ui.c b/parted/ui.c +index 505b8ac..c603ed2 100644 +--- a/parted/ui.c ++++ b/parted/ui.c +@@ -1270,6 +1270,7 @@ command_line_get_ex_opt (const char* prompt, PedExceptionOption options) + PedExceptionOption opt; + char* opt_name; + ++ command_line_flush (); + for (opt = option_get_next (options, 0); opt; + opt = option_get_next (options, opt)) { + options_strlist = str_list_append_unique (options_strlist, +-- +2.9.3 + diff --git a/SOURCES/0073-libpartd-dasd-improve-flag-processing-for-DASD-LDL.patch b/SOURCES/0073-libpartd-dasd-improve-flag-processing-for-DASD-LDL.patch new file mode 100644 index 0000000..4186463 --- /dev/null +++ b/SOURCES/0073-libpartd-dasd-improve-flag-processing-for-DASD-LDL.patch @@ -0,0 +1,47 @@ +From fb8167365502c7476d571fb279889ad2c6c2785e Mon Sep 17 00:00:00 2001 +From: Wang Dong +Date: Fri, 24 Mar 2017 03:11:12 +0100 +Subject: [PATCH 73/75] libpartd/dasd: improve flag processing for DASD-LDL + +DASD-LDL does not support flag now, so all the flags are +unavailable to it. + +Signed-off-by: Andre Wild +Signed-off-by: Wang Dong +Signed-off-by: Hendrik Brueckner +--- + libparted/labels/dasd.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c +index 7594e96..e246ecb 100644 +--- a/libparted/labels/dasd.c ++++ b/libparted/labels/dasd.c +@@ -773,10 +773,24 @@ dasd_partition_get_flag (const PedPartition* part, PedPartitionFlag flag) + } + } + ++/* ++ * The DASD-LDL does not support flags now. ++ * So just return 0. ++*/ + static int + dasd_partition_is_flag_available (const PedPartition* part, + PedPartitionFlag flag) + { ++ DasdDiskSpecific* disk_specific; ++ PED_ASSERT (part != NULL); ++ PED_ASSERT (part->disk != NULL); ++ PED_ASSERT (part->disk->disk_specific != NULL); ++ ++ disk_specific = part->disk->disk_specific; ++ ++ if (disk_specific->format_type == 1) ++ return 0; ++ + switch (flag) { + case PED_PARTITION_RAID: + return 1; +-- +2.9.3 + diff --git a/SOURCES/0074-libparted-dasd-add-an-exception-for-changing-DASD-LD.patch b/SOURCES/0074-libparted-dasd-add-an-exception-for-changing-DASD-LD.patch new file mode 100644 index 0000000..92d8c52 --- /dev/null +++ b/SOURCES/0074-libparted-dasd-add-an-exception-for-changing-DASD-LD.patch @@ -0,0 +1,38 @@ +From c6ada23e466d824efcaff699a3de2923895c2244 Mon Sep 17 00:00:00 2001 +From: Wang Dong +Date: Fri, 24 Mar 2017 11:20:09 +0100 +Subject: [PATCH 74/75] libparted/dasd: add an exception for changing DASD-LDL + partition table + +The partition table of DASD-LDL device with the dasd disk label +should not be changed according to its character in Linux. +When the user tries to modify the partition table, an exception +will be raised to inform user of this character. + +Signed-off-by: Wang Dong +Signed-off-by: Hendrik Brueckner +--- + libparted/labels/dasd.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c +index e246ecb..632ec8e 100644 +--- a/libparted/labels/dasd.c ++++ b/libparted/labels/dasd.c +@@ -619,8 +619,12 @@ dasd_write (const PedDisk* disk) + PDEBUG; + + /* If not formated in CDL, don't write anything. */ +- if (disk_specific->format_type == 1) ++ if (disk_specific->format_type == 1) { ++ ped_exception_throw (PED_EXCEPTION_ERROR, ++ PED_EXCEPTION_CANCEL, ++ _("The partition table of DASD-LDL device cannot be changed.\n")); + return 1; ++ } + + /* initialize the anchor */ + fdasd_initialize_anchor(&anchor); +-- +2.9.3 + diff --git a/SOURCES/0075-libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch b/SOURCES/0075-libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch new file mode 100644 index 0000000..f454531 --- /dev/null +++ b/SOURCES/0075-libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch @@ -0,0 +1,241 @@ +From e76ec6107f63fbf17cc6daf00a9cdb21994e54c1 Mon Sep 17 00:00:00 2001 +From: Wang Dong +Date: Thu, 20 Apr 2017 10:20:07 +0200 +Subject: [PATCH 75/75] libparted/dasd: add test cases for the new fdasd + functions + +The test case uses a temporary file in libparted/tests under +Check framwork.It can be issued by "make check" in the test dir. + +Signed-off-by: Wang Dong +Signed-off-by: Hendrik Brueckner +--- + libparted/tests/t4000-volser.sh | 20 +++++ + libparted/tests/volser.c | 188 ++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 208 insertions(+) + create mode 100755 libparted/tests/t4000-volser.sh + create mode 100644 libparted/tests/volser.c + +diff --git a/libparted/tests/t4000-volser.sh b/libparted/tests/t4000-volser.sh +new file mode 100755 +index 0000000..89688ba +--- /dev/null ++++ b/libparted/tests/t4000-volser.sh +@@ -0,0 +1,20 @@ ++#!/bin/sh ++ ++# 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 . ++ ++. "${top_srcdir=../..}/tests/init.sh"; path_prepend_ . ++ ++volser || fail=1 ++ ++Exit $fail +diff --git a/libparted/tests/volser.c b/libparted/tests/volser.c +new file mode 100644 +index 0000000..9063821 +--- /dev/null ++++ b/libparted/tests/volser.c +@@ -0,0 +1,188 @@ ++/* ++ * Author: Wang Dong ++ */ ++ ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include "../arch/linux.h" ++#include "common.h" ++#include "progname.h" ++ ++/* set dasd first */ ++static char vol_devno[7] = {0}; ++static char *tmp_disk; ++static int fd; ++ ++static PedDisk *disk; ++static struct fdasd_anchor anc; ++static fdasd_anchor_t *anchor = &anc; ++static LinuxSpecific *arch_specific; ++ ++/* set the enviroment */ ++static void set_test (void) ++{ ++ PedDevice *dev; ++ PedDiskType *type; ++ type = ped_disk_type_get ("dasd"); ++ ++ tmp_disk = _create_disk (20*1024*1024); ++ fail_if (tmp_disk == NULL, "Failed to create temporary disk"); ++ dev = ped_device_get (tmp_disk); ++ if (dev == NULL) ++ return; ++ ++ disk = _create_disk_label (dev, type); ++ if (!ped_device_open (disk->dev)) ++ return; ++ ++ fdasd_initialize_anchor (anchor); ++ arch_specific = LINUX_SPECIFIC (disk->dev); ++ fd = arch_specific->fd; ++ if (!fdasd_get_geometry (dev, anchor, fd)) ++ return; ++ ++ fdasd_check_volume (anchor, fd); ++ sprintf (vol_devno, "0X%04x", anchor->devno); ++ ck_assert (strlen (vol_devno) == VOLSER_LENGTH); ++} ++ ++static void free_test (void) ++{ ++ ped_device_close (disk->dev); ++ ped_device_destroy (disk->dev); ++ unlink (tmp_disk); ++ free (tmp_disk); ++ fdasd_cleanup (anchor); ++} ++ ++/* Test with default volser */ ++START_TEST (test_get_volser) ++{ ++ char volser[7] = {0}; ++ fdasd_change_volser (anchor, vol_devno); ++ fdasd_write_labels (anchor, fd); ++ ++ fdasd_get_volser (anchor, volser, fd); ++ ck_assert (!strcmp (volser, vol_devno)); ++} ++END_TEST ++ ++START_TEST (test_check_volser) ++{ ++ char vol[7] = {0}; ++ char vol_long[] = "abcdefg"; ++ char vol_short[] = "ab_c "; ++ char vol_null[] = " "; ++ char *vol_input = NULL; ++ ++ vol_input = vol_long; ++ fdasd_check_volser (vol_input, anchor->devno); ++ ck_assert(!strcmp (vol_input, "ABCDEF")); ++ ++ vol_input = vol_short; ++ fdasd_check_volser (vol_input, anchor->devno); ++ ck_assert (!strcmp (vol_input, "ABC")); ++ ++ vol_input = vol_null; ++ fdasd_check_volser (vol_input, anchor->devno); ++ ck_assert (!strcmp (vol_input, vol_devno)); ++} ++END_TEST ++ ++START_TEST (test_change_volser) ++{ ++ ++ char vol[] = "000000"; ++ char volser[7] = {0}; ++ ++ fdasd_change_volser (anchor, vol); ++ fdasd_write_labels (anchor, fd); ++ ++ fdasd_get_volser (anchor, volser, fd); ++ ck_assert (!strcmp (volser, vol)); ++} ++END_TEST ++ ++/* ++ * fdsad_recreate_vtoc recreate the VTOC with existing one. ++ * So the partition information should be not changed after recreating ++ * VTOC. ++*/ ++START_TEST (test_reuse_vtoc) ++{ ++ ds5ext_t before; ++ ds5ext_t after; ++ ++ memcpy (&before, &anchor->f5->DS5AVEXT, sizeof(ds5ext_t)); ++ ++ if (anchor->fspace_trk) { ++ fdasd_reuse_vtoc (anchor); ++ memcpy (&after, &anchor->f5->DS5AVEXT, sizeof(ds5ext_t)); ++ if ((before.t != after.t) && (before.fc != after.fc) && (before.ft != after.ft)) ++ ck_abort (); ++ } else { ++ fdasd_reuse_vtoc (anchor); ++ memcpy (&after, &anchor->f5->DS5AVEXT, sizeof(ds5ext_t)); ++ if ((before.t != after.t) && (before.fc != after.fc) && (before.ft != after.ft)) ++ ck_abort (); ++ } ++} ++END_TEST ++ ++int main (int argc, char **argv) ++{ ++ ++ set_program_name (argv[0]); ++ ++#if defined __s390__ || defined __s390x__ ++ ++ int number_failed = 0; ++ ++ Suite *suite = suite_create ("Volser"); ++ ++ TCase *tcase_get = tcase_create ("Get"); ++ TCase *tcase_check = tcase_create ("Check"); ++ TCase *tcase_change = tcase_create ("Change"); ++ TCase *tcase_vtoc = tcase_create ("Vtoc"); ++ ++ ped_exception_set_handler (_test_exception_handler); ++ ++ tcase_add_checked_fixture (tcase_check, set_test, free_test); ++ tcase_add_test (tcase_check, test_check_volser); ++ tcase_set_timeout (tcase_check, 0); ++ suite_add_tcase (suite, tcase_check); ++ ++ tcase_add_checked_fixture (tcase_change, set_test, free_test); ++ tcase_add_test (tcase_change, test_change_volser); ++ tcase_set_timeout (tcase_change, 0); ++ suite_add_tcase (suite, tcase_change); ++ ++ tcase_add_checked_fixture (tcase_get, set_test, free_test); ++ tcase_add_test (tcase_get, test_get_volser); ++ tcase_set_timeout (tcase_get, 0); ++ suite_add_tcase (suite, tcase_get); ++ ++ tcase_add_checked_fixture (tcase_vtoc, set_test, free_test); ++ tcase_add_test (tcase_vtoc, test_reuse_vtoc); ++ tcase_set_timeout (tcase_vtoc, 0); ++ suite_add_tcase (suite, tcase_vtoc); ++ ++ SRunner *srunner = srunner_create (suite); ++ /* When to debug, uncomment this line */ ++ /* srunner_set_fork_status (srunner, CK_NOFORK); */ ++ ++ srunner_run_all (srunner, CK_VERBOSE); ++ ++ number_failed = srunner_ntests_failed (srunner); ++ srunner_free (srunner); ++ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; ++ ++#endif ++ return 0; ++} +-- +2.9.3 + diff --git a/SOURCES/0076-Increase-timeout-for-rmmod-scsi_debug-and-make-it-a-.patch b/SOURCES/0076-Increase-timeout-for-rmmod-scsi_debug-and-make-it-a-.patch new file mode 100644 index 0000000..42c8dae --- /dev/null +++ b/SOURCES/0076-Increase-timeout-for-rmmod-scsi_debug-and-make-it-a-.patch @@ -0,0 +1,41 @@ +From 58986a509da1c6387435b27c4071944ee14613a2 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 24 Feb 2017 11:06:20 -0800 +Subject: [PATCH 76/77] Increase timeout for rmmod scsi_debug and make it a + framework failure + +On some hardware scsi_debug can take longer to remove. If this fails it +inevitably results in the next test failing since it cannot load +scsi_debug. + +Increse the timeout to 40 loops (8 seconds), and if it hits the limit +without succeeding call framework_failure_ + +(cherry picked from commit 40e55a0819862d5dbe2098803735f8c48fb30b6d) +--- + tests/t-local.sh | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/tests/t-local.sh b/tests/t-local.sh +index 13073d2..2ba7ee1 100644 +--- a/tests/t-local.sh ++++ b/tests/t-local.sh +@@ -27,13 +27,14 @@ scsi_debug_cleanup_() + # "Module scsi_debug is in use". + i=0 + udevadm settle +- while [ $i -lt 10 ] ; do ++ while [ $i -lt 40 ] ; do + rmmod scsi_debug \ + && { test "$VERBOSE" = yes && warn_ $ME_ rmmod scsi_debug...; break; } + sleep .2 || sleep 1 + i=$((i + 1)) + done + udevadm settle ++ test $i = 40 && framework_failure_ rmmod scsi_debug failed. + fi + rm -fr $scsi_debug_lock_dir_ + } +-- +2.9.3 + diff --git a/SOURCES/0077-tests-t1701-rescue-fs-wait-for-the-device-to-appear.patch b/SOURCES/0077-tests-t1701-rescue-fs-wait-for-the-device-to-appear.patch new file mode 100644 index 0000000..b19317f --- /dev/null +++ b/SOURCES/0077-tests-t1701-rescue-fs-wait-for-the-device-to-appear.patch @@ -0,0 +1,27 @@ +From 1eb7c40bcf7aeb359e9e605ebf2ae7e4a602a23c Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 24 Feb 2017 12:12:03 -0800 +Subject: [PATCH 77/77] tests/t1701-rescue-fs wait for the device to appear. + +After mkpart it needs to wait for the new partition to appear. + +(cherry picked from commit 8d149b24eb2789fdf00743ef735e0cffde598040) +--- + tests/t1701-rescue-fs.sh | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tests/t1701-rescue-fs.sh b/tests/t1701-rescue-fs.sh +index 9b726cf..bbf5eac 100644 +--- a/tests/t1701-rescue-fs.sh ++++ b/tests/t1701-rescue-fs.sh +@@ -30,6 +30,7 @@ scsi_dev=$(cat dev-name) + || { warn_ "$ME: no ext4 support"; Exit $fail; } + + parted -s $scsi_dev mklabel msdos mkpart primary ext2 1m 100% ++wait_for_dev_to_appear_ ${scsi_dev}1 || fail=1 + mkfs.ext4 ${scsi_dev}1 || { warn_ $ME: mkfs.ext4 failed; fail=1; Exit $fail; } + + # remove the partition +-- +2.9.3 + diff --git a/SOURCES/0078-libparted-Fix-udev-cookie-leak-in-_dm_resize_partiti.patch b/SOURCES/0078-libparted-Fix-udev-cookie-leak-in-_dm_resize_partiti.patch new file mode 100644 index 0000000..22424bb --- /dev/null +++ b/SOURCES/0078-libparted-Fix-udev-cookie-leak-in-_dm_resize_partiti.patch @@ -0,0 +1,69 @@ +From e7870afe3c13dcc77845d48409daa35e3e42b5fb Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Thu, 25 May 2017 09:42:23 -0700 +Subject: [PATCH] libparted: Fix udev cookie leak in _dm_resize_partition + +The function is setting udev cookies, but not using them when waiting +for the task. This results in leaked cookies, which can eventually +exhaust the available number of semaphores. + +'dmsetup udevcookies' will show a cookie remaining afterwards, and 'ipcs -s' +will show the semaphores in use. + +Also simplified the exit so that the task is always destroyed and memory +is all freed in the same path. + +Resolves: rhbz#1455564 +--- + libparted/arch/linux.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 9886d6e..1a35964 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -2943,6 +2943,7 @@ _dm_resize_partition (PedDisk* disk, const PedPartition* part) + char* vol_name = NULL; + const char* dev_name = NULL; + uint32_t cookie = 0; ++ int rc = 0; + + /* Get map name from devicemapper */ + struct dm_task *task = dm_task_create (DM_DEVICE_INFO); +@@ -2983,8 +2984,9 @@ _dm_resize_partition (PedDisk* disk, const PedPartition* part) + /* device-mapper uses 512b units, not the device's sector size */ + dm_task_add_target (task, 0, part->geom.length * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT), + "linear", params); +- if (!dm_task_set_cookie (task, &cookie, 0)) +- goto err; ++ /* NOTE: DM_DEVICE_RELOAD doesn't generate udev events, so no cookie is needed (it will freeze). ++ * DM_DEVICE_RESUME does, so get a cookie and synchronize with udev. ++ */ + if (dm_task_run (task)) { + dm_task_destroy (task); + task = dm_task_create (DM_DEVICE_RESUME); +@@ -2993,10 +2995,8 @@ _dm_resize_partition (PedDisk* disk, const PedPartition* part) + dm_task_set_name (task, vol_name); + if (!dm_task_set_cookie (task, &cookie, 0)) + goto err; +- if (dm_task_run (task)) { +- free (params); +- free (vol_name); +- return 1; ++ if (_dm_task_run_wait (task, cookie)) { ++ rc = 1; + } + } + err: +@@ -3005,7 +3005,7 @@ err: + dm_task_destroy (task); + free (params); + free (vol_name); +- return 0; ++ return rc; + } + + #endif +-- +2.9.4 + diff --git a/SOURCES/0079-atari.c-Drop-xlocale.h-1476934.patch b/SOURCES/0079-atari.c-Drop-xlocale.h-1476934.patch new file mode 100644 index 0000000..7ba2dd6 --- /dev/null +++ b/SOURCES/0079-atari.c-Drop-xlocale.h-1476934.patch @@ -0,0 +1,25 @@ +From 465fdd8d72e7f8517d67ec7b5f227f5482928ec1 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 31 Jul 2017 15:20:45 -0700 +Subject: [PATCH] atari.c: Drop xlocale.h (#1476934) + +glibc no longer includes this header. locale.h should work just fine. +--- + libparted/labels/atari.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/libparted/labels/atari.c b/libparted/labels/atari.c +index 36e68b9..ea4c87f 100644 +--- a/libparted/labels/atari.c ++++ b/libparted/labels/atari.c +@@ -37,7 +37,6 @@ + #include + #include + #include +-#include + #include + #include + #include +-- +2.9.4 + diff --git a/SOURCES/0080-libparted-labels-link-with-libiconv-if-needed.patch b/SOURCES/0080-libparted-labels-link-with-libiconv-if-needed.patch new file mode 100644 index 0000000..b6e2cd8 --- /dev/null +++ b/SOURCES/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)" +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/SOURCES/0081-Add-support-for-NVDIMM-devices.patch b/SOURCES/0081-Add-support-for-NVDIMM-devices.patch new file mode 100644 index 0000000..a4b879d --- /dev/null +++ b/SOURCES/0081-Add-support-for-NVDIMM-devices.patch @@ -0,0 +1,84 @@ +From b5bbee5db418e85c8fd26bf07142e71302914738 Mon Sep 17 00:00:00 2001 +From: Sebastian Parschauer +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 +(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/SOURCES/0082-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch b/SOURCES/0082-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch new file mode 100644 index 0000000..358ae57 --- /dev/null +++ b/SOURCES/0082-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch @@ -0,0 +1,87 @@ +From 0e70861c9f72fb2e06f9a121e6dac0e542ee1230 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 27 Jun 2018 13:45:09 -0700 +Subject: [PATCH 82/86] 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('" ++ print("%s: " % 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/SOURCES/0083-Switch-gpt-header-move-and-msdos-overlap-to-python3.patch b/SOURCES/0083-Switch-gpt-header-move-and-msdos-overlap-to-python3.patch new file mode 100644 index 0000000..8eda2ff --- /dev/null +++ b/SOURCES/0083-Switch-gpt-header-move-and-msdos-overlap-to-python3.patch @@ -0,0 +1,33 @@ +From 8a0e65d53cfd7dc83016cfebe3f001edb8de63b5 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 27 Jun 2018 13:47:33 -0700 +Subject: [PATCH 83/86] 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/SOURCES/0084-Fix-the-length-of-several-strncpy-calls.patch b/SOURCES/0084-Fix-the-length-of-several-strncpy-calls.patch new file mode 100644 index 0000000..643d335 --- /dev/null +++ b/SOURCES/0084-Fix-the-length-of-several-strncpy-calls.patch @@ -0,0 +1,76 @@ +From 531eb00aaa03f448cdb3f0c647db7f8d4544c50a Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 23 Jul 2018 14:34:30 -0700 +Subject: [PATCH 84/88] 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 1c26b8c..dd4820d 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -2571,9 +2571,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); + +@@ -2629,7 +2632,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.1 + diff --git a/SOURCES/0085-parted.c-Always-free-peek_word.patch b/SOURCES/0085-parted.c-Always-free-peek_word.patch new file mode 100644 index 0000000..18b2eda --- /dev/null +++ b/SOURCES/0085-parted.c-Always-free-peek_word.patch @@ -0,0 +1,35 @@ +From d42cea08828c72c6f289add05acd3b93d481fbee Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 23 Jul 2018 15:12:38 -0700 +Subject: [PATCH 85/86] 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 b49e1df..dae35a5 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]))) { + 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.1 + diff --git a/SOURCES/0086-parted.c-Make-sure-dev_name-is-freed.patch b/SOURCES/0086-parted.c-Make-sure-dev_name-is-freed.patch new file mode 100644 index 0000000..b104b6b --- /dev/null +++ b/SOURCES/0086-parted.c-Make-sure-dev_name-is-freed.patch @@ -0,0 +1,45 @@ +From d68bd3d8afc97c2c9fcf9aab7819c078f4a21290 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 23 Jul 2018 15:18:37 -0700 +Subject: [PATCH 86/86] 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 dae35a5..c95fbbf 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -1100,6 +1100,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(); + +@@ -1115,14 +1116,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.1 + diff --git a/SOURCES/0087-t6100-mdraid-partitions-Use-v0.90-metadata-for-the-t.patch b/SOURCES/0087-t6100-mdraid-partitions-Use-v0.90-metadata-for-the-t.patch new file mode 100644 index 0000000..bd001a5 --- /dev/null +++ b/SOURCES/0087-t6100-mdraid-partitions-Use-v0.90-metadata-for-the-t.patch @@ -0,0 +1,28 @@ +From 784d8ff89e1771a5592b38989f5253fa53536cba Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 23 Jul 2018 16:07:40 -0700 +Subject: [PATCH] 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 dbb1686..f051589 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" + + # create gpt and two partitions on the raid device + parted -s $md_dev mklabel gpt \ +-- +2.17.1 + diff --git a/SOURCES/0088-linux.c-Use-sys-sysmacros.h-for-major-minor.patch b/SOURCES/0088-linux.c-Use-sys-sysmacros.h-for-major-minor.patch new file mode 100644 index 0000000..cec3a15 --- /dev/null +++ b/SOURCES/0088-linux.c-Use-sys-sysmacros.h-for-major-minor.patch @@ -0,0 +1,28 @@ +From 027f5669d4c78b035a0c9134608d8411d9617c4b Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 13 Aug 2018 12:04:23 -0700 +Subject: [PATCH] linux.c: Use sys/sysmacros.h for major/minor + +gcc is also going to deprecate this at some point, so start using +sys/sysmacros.h directly. + +Resolves: rhbz#1615592 +--- + libparted/arch/linux.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 4ec3440..8eb54fa 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -36,6 +36,7 @@ + #include + #include + #include ++#include /* for major() and minor() */ + #include + #include + #include /* for uname() */ +-- +2.17.1 + diff --git a/SOURCES/parted-3.2.tar.xz.sig b/SOURCES/parted-3.2.tar.xz.sig new file mode 100644 index 0000000..b8ca108 --- /dev/null +++ b/SOURCES/parted-3.2.tar.xz.sig @@ -0,0 +1,11 @@ +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1 + +iQEcBAABCgAGBQJT1xMSAAoJEI5FoCIzSKrwifgH/3RPcmdiLuBG1CFhSwvFMDE4 +0+cOupMjmPvLXjjj1wVD1svj5MF5R/Hejd2GzOfZZ1OOZD/1asgBCteh3RLXvj00 +gE8vTv9MsYeO6C3IiNNy8KwAi1XMDD/75WyOxgStTZuDaspczyRxtYgHUk/vHRdf +btpkf2fuzSX4EskU5U4QetJgjmVUee0bGafC1CGLdxKTwxY2At4uf9TX+Y4us8Ym +EEqdQyeF8OV/wcGJq8aRkbZbHPVtI1id4IS8X7RxTmJtRHp13/WcYo/vkQUm1BUt +RFFeCCE65PxY33jYSYIJCSrfr1LLvzM2LCfEXNduLXUiKwz54/72j5HBkjeKYps= +=vEMW +-----END PGP SIGNATURE----- diff --git a/SPECS/parted.spec b/SPECS/parted.spec new file mode 100644 index 0000000..d8d1c9e --- /dev/null +++ b/SPECS/parted.spec @@ -0,0 +1,1493 @@ +%define _sbindir /sbin +%define _libdir /%{_lib} + +Summary: The GNU disk partition manipulation program +Name: parted +Version: 3.2 +Release: 36%{?dist} +License: GPLv3+ +Group: Applications/System +URL: http://www.gnu.org/software/parted + +Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz +Source1: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz.sig +Source2: pubkey.jim.meyering +Source3: pubkey.phillip.susi + +Patch0001: 0001-tests-Try-several-UTF8-locales.patch +Patch0002: 0002-maint-post-release-administrivia.patch +Patch0003: 0003-libparted-also-link-to-UUID_LIBS.patch +Patch0004: 0004-lib-fs-resize-Prevent-crash-resizing-FAT16-file-syst.patch +Patch0005: 0005-tests-t3000-resize-fs.sh-Add-FAT16-resizing-test.patch +Patch0006: 0006-tests-t3000-resize-fs.sh-Add-requirement-on-mkfs.vfa.patch +Patch0007: 0007-tests-Change-minimum-size-to-256MiB.patch +Patch0008: 0008-parted-don-t-crash-in-disk_set-when-disk-label-not-f.patch +Patch0009: 0009-tests-Add-a-test-for-device-mapper-partition-sizes.patch +Patch0010: 0010-libparted-device-mapper-uses-512b-sectors.patch +Patch0011: 0011-Update-manpage-NAME-so-whatis-will-work.patch +Patch0012: 0012-tests-Make-sure-the-extended-partition-length-is-cor.patch +Patch0013: 0013-libparted-BLKPG_RESIZE_PARTITION-uses-bytes-not-sect.patch +Patch0014: 0014-parted-Fix-crash-with-name-command-and-no-disklabel-.patch +Patch0015: 0015-UI-Avoid-memory-leaks.patch +Patch0016: 0016-libparted-Fix-memory-leaks.patch +Patch0017: 0017-libparted-Fix-possible-memory-leaks.patch +Patch0018: 0018-libparted-Stop-converting-.-in-sys-path-to.patch +Patch0019: 0019-libparted-Use-read-only-when-probing-devices-on-linu.patch +Patch0020: 0020-tests-Use-wait_for_dev_to_-functions.patch +Patch0021: 0021-fdasd-geometry-handling-updated-from-upstream-s390-t.patch +Patch0022: 0022-dasd-enhance-device-probing.patch +Patch0023: 0023-parted-fix-build-error-on-s390.patch +Patch0024: 0024-fdasd.c-Safeguard-against-geometry-misprobing.patch +Patch0025: 0025-Add-libparted-fs-resize.pc.patch +Patch0026: 0026-tests-Add-udevadm-settle-to-wait_for_-loop-1260664.patch +Patch0027: 0027-tests-Add-wait-to-t9042-1257415.patch +Patch0028: 0028-tests-Fix-t1700-failing-on-a-host-with-a-4k-xfs-file.patch +Patch0029: 0029-lib-fs-resize-Prevent-crash-resizing-FAT-with-very-d.patch +Patch0030: 0030-tests-t3000-resize-fs.sh-Add-very-deep-directory.patch +Patch0031: 0031-Use-BLKSSZGET-to-get-device-sector-size-in-_device_p.patch +Patch0032: 0032-parted-fix-the-rescue-command.patch +Patch0033: 0033-Use-disk-geometry-as-basis-for-ext2-sector-sizes.patch +Patch0034: 0034-docs-Add-list-of-filesystems-for-fs-type-1311596.patch +Patch0035: 0035-parted-Display-details-of-partition-alignment-failur.patch +Patch0036: 0036-libparted-Remove-fdasd-geometry-code-from-alloc_meta.patch +Patch0037: 0037-libparted-Fix-probing-AIX-disks-on-other-arches.patch +Patch0038: 0038-partprobe-Open-the-device-once-for-probing.patch +Patch0039: 0039-Cleanup-mkpart-manpage-entry-1183077.patch +Patch0040: 0040-doc-Add-information-about-quoting.patch +Patch0041: 0041-libparted-dasd-correct-the-offset-where-the-first-pa.patch +Patch0042: 0042-Add-support-for-NVMe-devices.patch +Patch0043: 0043-docs-Improve-partition-description-in-parted.texi.patch +Patch0044: 0044-libparted-only-IEC-units-are-treated-as-exact.patch +Patch0045: 0045-tests-t3310-flags.sh-Query-libparted-for-all-flags-t.patch +Patch0046: 0046-tests-t3310-flags.sh-Stop-excluding-certain-flags-fr.patch +Patch0047: 0047-tests-t3310-flags.sh-Add-test-for-bsd-table-flags.patch +Patch0048: 0048-libparted-Fix-to-report-success-when-setting-lvm-fla.patch +Patch0049: 0049-libparted-Remove-commented-local-variable-from-bsd_p.patch +Patch0050: 0050-tests-t3310-flags.sh-Add-test-for-mac-table-flags.patch +Patch0051: 0051-tests-t3310-flags.sh-Add-test-for-dvh-table-flags.patch +Patch0052: 0052-tests-t3310-flags.sh-Add-tests-for-remaining-table-t.patch +Patch0053: 0053-tests-Set-optimal-blocks-to-64-for-scsi_debug-device.patch +Patch0054: 0054-tests-t3310-flags.sh-skip-pc98-when-sector-size-512.patch +Patch0055: 0055-tests-Stop-timing-t9040-1172675.patch +Patch0056: 0056-libparted-Fix-starting-CHS-in-protective-MBR.patch +Patch0057: 0057-libparted-Don-t-warn-if-no-HDIO_GET_IDENTITY-ioctl.patch +Patch0058: 0058-libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch +Patch0059: 0059-libparted-dasd-update-and-improve-fdasd-functions.patch +Patch0060: 0060-libparted-dasd-add-new-fdasd-functions.patch +Patch0061: 0061-libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch +Patch0062: 0062-libparted-set-swap-flag-on-GPT-partitions.patch +Patch0063: 0063-tests-Update-t0220-and-t0280-for-the-swap-flag.patch +Patch0064: 0064-libparted-tests-Move-get_sector_size-to-common.c.patch +Patch0065: 0065-libparted-Add-support-for-atari-partition-tables.patch +Patch0066: 0066-mac-copy-partition-type-and-name-correctly.patch +Patch0067: 0067-libparted-Fix-MacOS-boot-support.patch +Patch0068: 0068-libparted-Fix-typo-in-hfs-error-message.patch +Patch0069: 0069-Fix-crash-when-localized.patch +Patch0070: 0070-Add-support-for-RAM-drives.patch +Patch0071: 0071-parted-check-the-name-of-partition-first-when-to-nam.patch +Patch0072: 0072-parted-ui-remove-unneccesary-information-of-command-.patch +Patch0073: 0073-libpartd-dasd-improve-flag-processing-for-DASD-LDL.patch +Patch0074: 0074-libparted-dasd-add-an-exception-for-changing-DASD-LD.patch +Patch0075: 0075-libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch +Patch0076: 0076-Increase-timeout-for-rmmod-scsi_debug-and-make-it-a-.patch +Patch0077: 0077-tests-t1701-rescue-fs-wait-for-the-device-to-appear.patch +Patch0078: 0078-libparted-Fix-udev-cookie-leak-in-_dm_resize_partiti.patch +Patch0079: 0079-atari.c-Drop-xlocale.h-1476934.patch +Patch0080: 0080-libparted-labels-link-with-libiconv-if-needed.patch +Patch0081: 0081-Add-support-for-NVDIMM-devices.patch + +# Use python3 in the buildroot +# Sent upstream 2018-06-27 +Patch0082: 0082-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch +Patch0083: 0083-Switch-gpt-header-move-and-msdos-overlap-to-python3.patch + +# Fixes for covscan issues +Patch0084: 0084-Fix-the-length-of-several-strncpy-calls.patch +Patch0085: 0085-parted.c-Always-free-peek_word.patch +Patch0086: 0086-parted.c-Make-sure-dev_name-is-freed.patch + +# Fix a test bug using newer mdraid metadata formats +Patch0087: 0087-t6100-mdraid-partitions-Use-v0.90-metadata-for-the-t.patch +Patch0088: 0088-linux.c-Use-sys-sysmacros.h-for-major-minor.patch + +Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: gcc +BuildRequires: e2fsprogs-devel +BuildRequires: readline-devel +BuildRequires: ncurses-devel +BuildRequires: gettext-devel +BuildRequires: texinfo +BuildRequires: device-mapper-devel +BuildRequires: libselinux-devel +BuildRequires: libuuid-devel +BuildRequires: libblkid-devel >= 2.17 +BuildRequires: gnupg2 +BuildRequires: git +BuildRequires: autoconf automake +BuildRequires: e2fsprogs +BuildRequires: xfsprogs +BuildRequires: dosfstools +BuildRequires: perl-Digest-CRC +BuildRequires: bc +Buildrequires: python3-devel +BuildRequires: gperf +BuildRequires: make + +Requires(post): /sbin/ldconfig +Requires(post): /sbin/install-info +Requires(preun): /sbin/install-info +Requires(postun): /sbin/ldconfig + +# bundled gnulib library exception, as per packaging guidelines +# https://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries +Provides: bundled(gnulib) + +%description +The GNU Parted program allows you to create, destroy, resize, move, +and copy hard disk partitions. Parted can be used for creating space +for new operating systems, reorganizing disk usage, and copying data +to new hard disks. + + +%package devel +Summary: Files for developing apps which will manipulate disk partitions +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: pkgconfig + +%description devel +The GNU Parted library is a set of routines for hard disk partition +manipulation. If you want to develop programs that manipulate disk +partitions and filesystems using the routines provided by the GNU +Parted library, you need to install this package. + + +%prep +%setup -q +gpg2 --import %{SOURCE2} %{SOURCE3} +gpg2 --verify %{SOURCE1} %{SOURCE0} +git init +git config user.email "parted-owner@fedoraproject.org" +git config user.name "Fedora Ninjas" +git add . +git commit -a -q -m "%{version} baseline." +[ -n "%{patches}" ] && git am %{patches} +iconv -f ISO-8859-1 -t UTF8 AUTHORS > tmp; touch -r AUTHORS tmp; mv tmp AUTHORS +git commit -a -m "run iconv" + +%build +autoreconf +autoconf +CFLAGS="$RPM_OPT_FLAGS -Wno-unused-but-set-variable"; export CFLAGS +%configure --enable-selinux --disable-static --disable-gcc-warnings +# Don't use rpath! +%{__sed} -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool +%{__sed} -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool +V=1 %{__make} %{?_smp_mflags} + + +%install +%{__rm} -rf %{buildroot} +%{__make} install DESTDIR=%{buildroot} + +# Remove components we do not ship +%{__rm} -rf %{buildroot}%{_libdir}/*.la +%{__rm} -rf %{buildroot}%{_infodir}/dir +%{__rm} -rf %{buildroot}%{_bindir}/label +%{__rm} -rf %{buildroot}%{_bindir}/disk + +%find_lang %{name} + + +%check +export LD_LIBRARY_PATH=$(pwd)/libparted/.libs:$(pwd)/libparted/fs/.libs +make check + + + +%post +/sbin/ldconfig +if [ -f %{_infodir}/parted.info.gz ]; then + /sbin/install-info %{_infodir}/parted.info.gz %{_infodir}/dir || : +fi + +%preun +if [ $1 = 0 ]; then + /sbin/install-info --delete %{_infodir}/parted.info.gz %{_infodir}/dir >/dev/null 2>&1 || : +fi + +%postun -p /sbin/ldconfig + + +%files -f %{name}.lang +%defattr(-,root,root,-) +%doc AUTHORS NEWS README THANKS +%{!?_licensedir:%global license %%doc} +%license COPYING +%{_sbindir}/parted +%{_sbindir}/partprobe +%{_mandir}/man8/parted.8.gz +%{_mandir}/man8/partprobe.8.gz +%{_libdir}/libparted.so.2 +%{_libdir}/libparted.so.2.0.1 +%{_libdir}/libparted-fs-resize.so.0 +%{_libdir}/libparted-fs-resize.so.0.0.1 +%{_infodir}/parted.info.gz + +%files devel +%defattr(-,root,root,-) +%doc TODO doc/API doc/FAT +%{_includedir}/parted +%{_libdir}/libparted.so +%{_libdir}/libparted-fs-resize.so +%{_libdir}/pkgconfig/libparted.pc +%{_libdir}/pkgconfig/libparted-fs-resize.pc + + +%changelog +* Tue Aug 14 2018 Brian C. Lane - 3.2-36 +- Fix strncpy fix, always add NULL terminator + Resolves: rhbz#1615635 + +* Mon Aug 13 2018 Brian C. Lane - 3.2-35 +- Use python3-devel in buildroot + Resolves: rhbz#1615576 +- linux.c: Use sys/sysmacros.h for major/minor + Resolves: rhbz#1615592 + +* Mon Jul 23 2018 Brian C. Lane - 3.2-34 +- Fix the length of several strncpy calls (bcl) + Related: rhbz#1602652 +- parted.c: Always free peek_word (bcl) + Related: rhbz#1602652 +- parted.c: Make sure dev_name is freed (bcl) + Related: rhbz#1602652 +- t6100-mdraid-partitions: Use v0.90 metadata for the test (bcl) +- Fix msdos-overlap to work correctly with py2 or py3 (bcl) + Related: rhbz#1595810 + +* Wed Jun 27 2018 Brian C. Lane - 3.2-33 +- Switch gpt-header-move and msdos-overlap to python3 (bcl) + Resolves: rhbz#1595810 +- Modify gpt-header-move and msdos-overlap to work with py2 or py3 (bcl) + Related: rhbz#1595810 + +* Thu Jun 07 2018 Brian C. Lane - 3.2-32 +- Switch to using gpg2 for signature check + Resolves: rhbz#1566029 + +* Mon Feb 19 2018 Brian C. Lane - 3.2-31 +- Add gcc BuildRequires for future minimal buildroot support +- Remove %%clean section + +* Thu Feb 08 2018 Fedora Release Engineering - 3.2-30 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Tue Dec 19 2017 Brian C. Lane - 3.2-29 +- Add support for NVDIMM devices (sparschauer) +- libparted/labels: link with libiconv if needed (arnout) + +* Mon Jul 31 2017 Brian C. Lane - 3.2-28 +- atari.c: Drop xlocale.h + Resloves: rhbz#1476934 + +* Thu Jul 27 2017 Fedora Release Engineering - 3.2-27 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Tue Jun 06 2017 Brian C. Lane - 3.2-26 +- libparted: Fix udev cookie leak in _dm_resize_partition (bcl) + Resolves: rhbz#1455564 + +* Mon May 01 2017 Brian C. Lane - 3.2-25 ++ Updating to upstream patches +- tests/t1701-rescue-fs wait for the device to appear. (bcl) +- Increase timeout for rmmod scsi_debug and make it a framework failure (bcl) +- libparted/dasd: add test cases for the new fdasd functions (dongdwdw) +- libparted/dasd: add an exception for changing DASD-LDL partition table + (dongdwdw) +- libpartd/dasd: improve flag processing for DASD-LDL (dongdwdw) +- parted/ui: remove unneccesary information of command line (dongdwdw) +- parted: check the name of partition first when to name a partition (dongdwdw) +- Add support for RAM drives (sparschauer) +- Fix crash when localized (psusi) +- libparted: Fix typo in hfs error message (sebras) +- libparted: Fix MacOS boot support (laurent) +- mac: copy partition type and name correctly (saproj) +- libparted: Add support for atari partition tables (glaubitz) +- libparted:tests: Move get_sector_size() to common.c (glaubitz) +- tests: Update t0220 and t0280 for the swap flag. (bcl) +- libparted: set swap flag on GPT partitions (aschnell) +- libparted/dasd: add test cases for the new fdasd functions (dongdwdw) +- libparted/dasd: add new fdasd functions (dongdwdw) +- libparted/dasd: update and improve fdasd functions (dongdwdw) +- libparted/dasd: unify vtoc handling for cdl/ldl (dongdwdw) +- libparted: Don't warn if no HDIO_GET_IDENTITY ioctl (sparschauer) +- libparted: Fix starting CHS in protective MBR (petr.uzel) +- tests: Stop timing t9040 (#1172675) (bcl) + +* Sat Feb 11 2017 Fedora Release Engineering - 3.2-24 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Thu Jan 12 2017 Igor Gnatenko - 3.2-23 +- Rebuild for readline 7.x + +* Tue Oct 04 2016 Brian C. Lane - 3.2-22 +- tests: t3310-flags.sh: skip pc98 when sector size != 512 (bcl) +- tests: Set optimal blocks to 64 for scsi_debug devices (bcl) +- tests: t3310-flags.sh: Add tests for remaining table types (mike.fleetwood) +- tests: t3310-flags.sh: Add test for dvh table flags (mike.fleetwood) +- tests: t3310-flags.sh: Add test for mac table flags (mike.fleetwood) +- libparted: Remove commented local variable from bsd_partition_set_flag() + (mike.fleetwood) +- libparted: Fix to report success when setting lvm flag on bsd table + (mike.fleetwood) +- tests: t3310-flags.sh: Add test for bsd table flags (mike.fleetwood) +- tests: t3310-flags.sh: Stop excluding certain flags from being tested + (mike.fleetwood) +- tests: t3310-flags.sh: Query libparted for all flags to be tested + (mike.fleetwood) +- libparted: only IEC units are treated as exact (petr.uzel) +- docs: Improve partition description in parted.texi (gareth.randall) +- Add support for NVMe devices (petr.uzel) +- libparted/dasd: correct the offset where the first partition begins + (dongdwdw) + +* Wed Jun 15 2016 Brian C. Lane - 3.2-21 +- Cleanup mkpart manpage entry (#1183077) +- doc: Add information about quoting + +* Thu May 26 2016 Brian C. Lane - 3.2-20 +- libparted: Fix probing AIX disks on other arches +- partprobe: Open the device once for probing + +* Tue Apr 12 2016 Brian C. Lane 3.2-19 +- libparted: Remove fdasd geometry code from alloc_metadata (#1244833) (bcl) +- parted: Display details of partition alignment failure (#726856) (bcl) +- docs: Add list of filesystems for fs-type (#1311596) (bcl) +- Use disk geometry as basis for ext2 sector sizes. (Steven.Lang) +- parted: fix the rescue command (psusi) + +* Tue Mar 29 2016 Brian C. Lane 3.2-18 +- Use BLKSSZGET to get device sector size in _device_probe_geometry() + +* Mon Mar 07 2016 Brian C. Lane 3.2-17 +- lib-fs-resize: Prevent crash resizing FAT with very deep directories +- Add libparted/fs/.libs/ to LD_LIBRARY_PATH during make check + +* Mon Feb 29 2016 Brian C. Lane 3.2-16 +- Cleanup library path usage in specfile + pkgconfig wasn't finding libparted.pc because it was under /usr/lib64/ +- Explicitly reference the library files instead of use wildcards. +- Move libparted-fs-resize.so to the -devel package where it belongs. +- Add a pkgconfig file for the filesystem resize library +- tests: Add udevadm settle to wait_for_ loop +- tests: Add wait to t9042 +- tests: Fix t1700 failing on a host with a 4k xfs file + +* Tue Feb 09 2016 Brian C. Lane 3.2-15 +- fdasd.c Safeguard against geometry misprobing.patch (#1305931) + +* Thu Feb 04 2016 Fedora Release Engineering - 3.2-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Thu Oct 29 2015 Brian C. Lane 3.2-13 +- parted: fix build error on s390 + +* Tue Oct 27 2015 Brian C. Lane 3.2-12 +- dasd: enhance device probing +- fdasd: geometry handling updated from upstream s390-tools + +* Fri Aug 07 2015 Brian C. Lane 3.2-11 +- tests: Fix patch 0012 test for extended partition length +- UI: Avoid memory leaks +- libparted: Fix memory leaks.patch +- libparted: Fix possible memory leaks.patch +- libparted: Stop converting . in-sys-path-to / +- libparted: Use read-only when probing devices on linux +- tests: Use wait_for_dev_to_ functions + +* Mon Jul 13 2015 Brian C. Lane 3.2-10 +- parted: Fix crash with name command and no disklabel (#1226067) + +* Thu Jun 18 2015 Fedora Release Engineering - 3.2-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Fri Jun 05 2015 Brian C. Lane 3.2-8 +- tests: Make sure the extended partition length is 2 (#1135493) +- libparted: BLKPG_RESIZE_PARTITION uses bytes not sectors (#1135493) + +* Tue Apr 28 2015 Brian C. Lane 3.2-7 +- Add python2 as a BuildRequires, used in some of the tests + +* Tue Apr 28 2015 Brian C. Lane 3.2-6 +- Update manpage NAME so whatis will work (bcl) +- libparted: device mapper uses 512b sectors (bcl) +- tests: Add a test for device-mapper partition sizes (bcl) +- parted: don't crash in disk_set when disk label not found (psusi) + +* Fri Nov 07 2014 Brian C. Lane 3.2-5 +- tests: Change minimum size to 256MiB for t1700-probe-fs + +* Fri Oct 31 2014 Brian C. Lane 3.2-4 +- Update to current master commit ac74b83 to fix fat16 resize (#1159083) +- tests: t3000-resize-fs.sh: Add requirement on mkfs.vfat (mike.fleetwood) +- tests: t3000-resize-fs.sh: Add FAT16 resizing test (mike.fleetwood) +- lib-fs-resize: Prevent crash resizing FAT16 file systems (mike.fleetwood) +- libparted: also link to UUID_LIBS (heirecka) + +* Sun Aug 17 2014 Fedora Release Engineering - 3.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Wed Aug 13 2014 Brian C. Lane 3.2-2 +- Use a better patch to find the UTF8 locale for t0251 + +* Wed Jul 30 2014 Brian C. Lane 3.2-1 +- Rebase on upstream stable release v3.2 +- Drop upstream patches. +- Patch t0251 to use en_US.UTF-8 if possible. Fedora doesn't have C.UTF-8 + +* Wed Jul 30 2014 Tom Callaway 3.1.90-2 +- fix license handling + +* Mon Jul 28 2014 Brian C. Lane 3.1.90-1 +- Rebase on upstream Alpha source release +- drop included patches (all but one) +- add Phillip Susi's GPG key +- make sure gcc warnings as errors remains disabled since we use git for patches + +* Mon Jul 14 2014 Brian C. Lane 3.1-29 +- Rebase on parted master commit 081ed98 +- libparted: Add support for partition resize +- parted: add resizepart command + +* Wed Jun 11 2014 Brian C. Lane 3.1-28 +- Rebase on parted master commit 1da239e2ebd2 +- libparted: Fix bug with dupe and empty name + +* Fri Jun 06 2014 Fedora Release Engineering - 3.1-27 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sat May 31 2014 Peter Robinson 3.1-26 +- Move dev docs to devel +- Drop duplicated/outdated docs + +* Tue May 27 2014 Brian C. Lane 3.1-25 +- Use mkfs.xfs to create files (#1101112) + +* Thu May 22 2014 Brian C. Lane 3.1-24 +- Add some missing patches from master and the loop label fixes +- tests: test loop labels (psusi) +- libparted: don't trash filesystem when writing loop label (psusi) +- libparted: give correct partition device name on loop labels (psusi) +- partprobe: do not skip loop labels (psusi) +- libparted: don't create partition on loop label (psusi) +- libparted: fix loop labels to not vanish (psusi) +- libparted: remove all old partitions, even if new label allows less (psusi) +- libparted: remove old partitions *first* before adding new ones (psusi) +- libparted: don't detect fat and ntfs boot sectors as dos MBR (psusi) +- Fix filesystem detection on non 512 byte sectors (psusi) +- tests: fix t2310-dos-extended-2-sector-min-offset.sh (psusi) +- libparted: remove last_usable_if_grown (psusi) + +* Fri May 16 2014 Brian C. Lane 3.1-23 +- Fix partition naming patch for big endian systems. + +* Fri May 16 2014 Brian C. Lane 3.1-22 +- Fix a problem with GPT Partition names using. They are UCS-2LE not UTF-16 + +* Fri Apr 18 2014 Brian C. Lane 3.1-21 +- Fix t1700 probe patch -- remove loop before making new fs + +* Thu Apr 17 2014 Brian C. Lane 3.1-20 +- Use force for xfs in t1700 and a larger file +- Make t4100 xfs filesystem larger and sparse +- Fix part dupe with empty name +- check name when duplicating +- Add ntfs vfat hfsplus to t1700 probe test + +* Wed Apr 09 2014 Brian C. Lane 3.1-19 +- Use little endian packing in gpt tests +- Fix integer overflows with DVH disk label + +* Tue Apr 08 2014 Brian C. Lane 3.1-18 +- Rebase on new upstream master commit cc382c3 +- Drop patches incorporated into upstream +- Still adds the various DASD patches + +* Thu Feb 27 2014 Brian C. Lane 3.1-17 +- Drop hfs_esp patch. Idea didn't work. + +* Wed Sep 11 2013 Brian C. Lane 3.1-16 +- tests: Restrict gpt header munge to little-endian systems +- Add perl Digest::CRC as a build requirement so more tests will run + +* Wed Sep 04 2013 Brian C. Lane 3.1-15 +- libparted: Flush parent device on open (#962611) + +* Wed Aug 28 2013 Brian C. Lane 3.1-14 +- Rebasing Fedora patches with upstream master since v3.1 release +- Summary of important changes from upstream: + - add support for a new Linux-specific GPT partition type code + - partprobe: remove partitions when there is no partition table + - libparted: refactor device-mapper partition sync code + - libparted: remove extraneous blkpg add partition ped exception + - libparted: don't probe every dm device in probe_all +- New Fedora changes: + - libparted: Add Intel Rapid Start Technology partition flag. + - libparted: Add UEFI System Partition flag. + - libparted: Add hfs_esp partition flag to GPT. + - libparted: Recognize btrfs filesystem + - tests: Add btrfs and xfs to the fs probe test + +* Sat Aug 03 2013 Fedora Release Engineering - 3.1-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Wed Apr 17 2013 Brian C. Lane 3.1-12 +- libparted: mklabel to support EDEV DASD (#953146) +- tests: rewrite t6001 to use /dev/mapper + +* Thu Feb 14 2013 Fedora Release Engineering - 3.1-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Wed Dec 12 2012 Brian C. Lane 3.1-10 +- libparted: mklabel to support EAV DASD (#707032) +- libparted: Avoid dasd as default disk type while probe (#707032) + +* Thu Nov 01 2012 Brian C. Lane 3.1-9 +- don't canonicalize /dev/md/ paths (#872361) + +* Tue Oct 16 2012 Brian C. Lane 3.1-8 +- change partition UUID to use partX-UUID (#858704) +- fixup losetup usage in tests +- add support for implicit FBA DASD partitions (#707027) +- add support for EAV DASD partitions (#707032) + +* Tue Sep 04 2012 Brian C. Lane 3.1-7 +- reallocate buf after _disk_analyse_block_size (#835601) + +* Fri Aug 03 2012 Brian C. Lane 3.1-6 +- Use dm_udev_wait for dm operations (#844257) (bcl) +- use largest_partnum in _dm_reread_part_table (bcl) +- set uuid on dm partitions (#832145) (bcl) + +* Fri Jul 20 2012 Fedora Release Engineering - 3.1-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Fri Jun 08 2012 Brian C. Lane 3.1-4 +- Fix crash on ppc64 with GPT (#829960) (rwmj) + +* Tue May 15 2012 Brian C. Lane 3.1-3 +- Added Provides: bundled(gnulib) (#821782) + +* Wed Mar 21 2012 Brian C. Lane 3.1-2 +- libparted: check PMBR before GPT partition table (#805272) +- tests: add a test for the new behavior + +* Tue Mar 13 2012 Brian C. Lane 3.1-1 +- Rebase to upstream parted v3.1 +- removed merged patches +- add new libparted-fs-resize library + +* Fri Feb 03 2012 Brian C. Lane - 3.0-7 +- Update patch for copying flags so that it is generic +- Copy pmbr_boot flag in gpt_duplicate + +* Thu Feb 02 2012 Brian C. Lane - 3.0-6 +- gpt: add commands to manipulate pMBR boot flag (#754850) +- parted: when printing, also print the new disk flags +- tests: update tests for new disk flags output +- tests: add test for GPT PMBR pmbr_boot flag +- doc: update parted documentation + +* Fri Jan 13 2012 Fedora Release Engineering - 3.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Oct 31 2011 Brian C. Lane - 3.0-4 +- Fix ped_disk_duplicate on GPT so that it copies the partition flags (#747947) +- Add new test to check ped_disk_duplicate on msdos, gpt, bsd disk labels +- Add e2fsprogs and dosfstools so that skipped tests will be run + +* Fri Oct 07 2011 Brian C. Lane - 3.0-3 +- Fix handling of zero-length gpt partitions (#728949) +- Fix bug in nilfs2 probe with short partitions (#728949) +- Fix bug in hfs probe code (#714758) +- Make pc98 detection depend on specific signatures (#646053) + +* Wed Jun 29 2011 Richard W.M. Jones - 3.0-2 +- (Re-)apply patch to fix Linux "3.0" problem. + +* Tue Jun 28 2011 Brian C. Lane - 3.0-1 +- Update to parted v3.0 +- Run autoreconf so that patches to .am files will work +- Add patch to Fix snap radius and don't allow values < 1 (#665496) +- Add tests for the snap radius fix. +- Drop patches included in upstream release + +* Sun Jun 5 2011 Richard W.M. Jones - 2.4-2 +- Apply patch which may fix Linux "3.0" problem. + +* Thu May 26 2011 Brian C. Lane - 2.4-1 +- Updating to latest upstream v2.4 +- Drop patches included in upstream + +* Fri Mar 11 2011 Brian C. Lane - 2.3-8 +- Add support for legacy_boot flag for GPT partitions (680562) +- Remove PED_ASSERT for dos geometry calculations (585468) + +* Wed Feb 09 2011 Brian C. Lane - 2.3-7 +- Tell GCC to stop treating unused variable warnings as errors + +* Tue Feb 08 2011 Fedora Release Engineering - 2.3-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Mon Dec 20 2010 Brian C. Lanr - 2.3-5 +- Document the align-check command + Resolves: #642476 +- Default to 1MiB partition alignment + Resolves: #618255 + +* Fri Dec 17 2010 Peter Jones - 2.3-4 +- Handle mac labels with differing physical/logical sector sizes better + +* Wed Sep 29 2010 jkeating - 2.3-3 +- Rebuilt for gcc bug 634757 + +* Fri Sep 17 2010 Brian C. Lane 2.3-2 +- Add patch to handle syncing partition changes when using blkext majors +- Resolves rhbz#634980 +- Related rhbz#629719 + +* Tue Jul 20 2010 Hans de Goede 2.3-1 +- Rebase to new upstream 2.3 release +- Drop all patches (all upstreamed) +- Recognize scsi disks with a high major as such (#611691) + +* Thu May 6 2010 Hans de Goede 2.2-5 +- Also recognize recovery partitions with id 27 / on gpt (#589451) + +* Fri Apr 23 2010 Hans de Goede 2.2-4 +- Properly check dm_task_run return value (#585158) +- Fix mkpartfs (ext2) on partitions >2TB (#585159) + +* Mon Apr 19 2010 Hans de Goede 2.2-3 +- Add a flag for detecting diagnostics / recovery partitions (#583626) + +* Tue Apr 6 2010 Hans de Goede 2.2-2 +- Parted should not canonicalize symlinks under /dev/mapper (#577824) + +* Tue Mar 30 2010 Hans de Goede 2.2-1 +- New upstream version 2.2 (#577478) +- Drop all our patches (all upstreamed) + +* Thu Feb 18 2010 Hans de Goede 2.1-5 +- Copy needs_clobber value in ped_disk_duplicate() (#561976) + +* Wed Feb 10 2010 Hans de Goede 2.1-4 +- Don't crash when reading a DASD disk with PV's on there (#563419) +- Don't overwrite the pmbr when merely printing a gpt table (#563211) + +* Sun Jan 31 2010 Hans de Goede 2.1-3 +- If a drive does not have alignment information available default + to an alignment of 1MiB (#559639) + +* Sun Jan 17 2010 Hans de Goede 2.1-2 +- Fix various memory leaks in error paths (#556012) +- Add %%check section to the specfile, invoking make check + +* Mon Jan 11 2010 Hans de Goede 2.1-1 +- New upstream release 2.1 +- Drop all our patches (all merged upstream) + +* Sun Dec 20 2009 Hans de Goede 1.9.0-25 +- Fix crash when partitioning loopback devices (#546622) +- Drop no-cylinder-align patch: + - its functionality is superseeded by the per disk flags + - its only user (pyparted) has been updated to use those + - this is not upstream so we don't want other programs to start using it + +* Fri Dec 18 2009 Hans de Goede 1.9.0-24 +- Allow partitioning of loopback devices (#546622) +- Add libparted function to query maximum partition length and start + addresses for a given disk (#533417) +- Add per disk flags functions from upstream, this is the way upstream + has implemented the disable cylinder alignment functionality +- Add --align cmdline option to specify how to align new partitions + see the parted man page for details (#361951) +- Make the default alignment for new partitions optimal (#361951) +- When cylinder alignment is disabled, allow use of the last (incomplete) + cylinder of the disk (#533328) +- Don't crash when printing partition tables in Russian (#543029) +- Make parted work correctly with new lvm (#525095) + +* Wed Nov 11 2009 Hans de Goede 1.9.0-23 +- Fix parted not building on s390 + +* Mon Nov 9 2009 Hans de Goede 1.9.0-22 +- Fix error when creating a fresh dasd disk on a dasd device + with a corrupted dasd label (#533808) + +* Fri Nov 6 2009 Hans de Goede 1.9.0-21 +- Fix a compiler warning which is causing build errors (#532425) + +* Tue Nov 3 2009 Hans de Goede 1.9.0-20 +- Fix error when creating a fresh dasd disk (#532425) +- Rewrite dasd disk duplication patches, as the old old ones conflicted + with fixing creating a fresh dasd disk + +* Fri Oct 30 2009 Hans de Goede 1.9.0-19 +- Fix a segfault introduced by -18 when operating on plain files + +* Thu Oct 29 2009 Hans de Goede 1.9.0-18 +- Add functions to query device / partition table alignments (#528030) + +* Thu Oct 8 2009 Hans de Goede 1.9.0-17 +- Only change the partition type to 82 when setting the swap flag on dos + labels, not when resetting it + +* Tue Oct 6 2009 Hans de Goede 1.9.0-16 +- Correctly handle GPT labels on big endian machines + +* Tue Oct 6 2009 Hans de Goede 1.9.0-15 +- ped_partition_is_busy() should not throw exceptions (#527035) +- msdos_partition_is_flag_available() should return 1 for swap flag (#513729) + +* Mon Aug 31 2009 Joel Granados 1.9.0-14 +- Patchs for 'commit to os' for linux. Thx to hansg. + +* Fri Aug 28 2009 Karsten Hopp 1.9.0-13 +- volkey is only 4 chars, don't overflow destination buffer with 84 chars + +* Fri Aug 21 2009 Joel Granados - 1.9.0-12 +- libuuid-devel is now valid for s390 builds. + +* Wed Aug 12 2009 Ville Skyttä - 1.9.0-11 +- Use xz compressed upstream tarball. + +* Wed Aug 12 2009 Joel Granados - 1.9.0-10 +- Make install with exclude docs work without an error message. + +* Wed Jul 29 2009 Joel Granados - 1.9.0-9 +- Add parenthesis where needed (#511907) + +* Mon Jul 27 2009 Joel Granados - 1.9.0-8 +- Add the swap flag to the dos type labels + +* Sat Jul 25 2009 Fedora Release Engineering - 1.9.0-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Thu Jul 23 2009 Joel Granados - 1.9.0-6 +- Rebuild usiing the official tar.gz at http://ftp.gnu.org/gnu/parted/parted-1.9.0.tar.gz + +* Wed Jul 22 2009 Joel Granados - 1.9.0-5.20090721git980c +- Better handle a duplicate error. + +* Tue Jul 21 2009 Joel Granados - 1.9.0-4.20090721git980c +- New snapshot. +- Add patches to make dasd duplicate disk work. + +* Sat Jul 18 2009 Lubomir Rintel - 1.9.0-3.20090610git32dc +- Fix a typo in the errno patch + +* Mon Jul 13 2009 Joel Granados - 1.9.0-2.20090610git32dc +- Correctly number the snapshot. + +* Fri Jul 10 2009 Joel Granados - 1.9.0-1 +- New version. + +* Thu Mar 26 2009 Joel Granados - 1.8.8-15 +- Begin to identify virtio devices. +- Actually change the partition type in msdos lables (dcantrell). + +* Mon Mar 23 2009 Joel Granados - 1.8.8-14 +- Correct the behavior of upated_mode functions when the ASSERT fails (thx to hansg). + +* Thu Feb 26 2009 Joel Granados - 1.8.8-13 +- Fix parted build for gcc-4.4 + +* Thu Feb 26 2009 Fedora Release Engineering - 1.8.8-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Thu Jan 22 2009 Joel Granados - 1.8.8-12 +- Avoid the calling of stat for strings that don't begin with the "/" char (#353191). + +* Sat Dec 13 2008 Tom "spot" Callaway - 1.8.8-11 +- fix typo in last patch + +* Sat Dec 13 2008 Tom "spot" Callaway - 1.8.8-10 +- enable RAID partition types on sun disklabels for sparc + +* Thu Nov 06 2008 Joel Granados - 1.8.8-9 +- Fix the build for the s390(x) archs (#470211). + +* Thu Jun 05 2008 Peter Jones - 1.8.8-8 +- Fix some of the atvrecv code (and the msftres code) so that the flags + actually stick. + +* Thu Jun 05 2008 Peter Jones - 1.8.8-7 +- Added "atvrecv" flag patch from atv-bootloader project. + +* Thu May 29 2008 Joel Granados - 1.8.8-6 +- Do a better job at recognizing the dos partition. (#246423) + +* Thu Apr 10 2008 David Cantrell - 1.8.8-5 +- Allow RAID or LVM partition types on BSD disklabels. + (jay.estabrook AT hp.com, #427114) + +* Thu Apr 10 2008 Peter Jones - 1.8.8-4 +- Don't interactively ask to fix an AlternateGPT's location when not + at the end of the disk; this is so that disk images written to a + usb-key can work reasonably. + +* Mon Feb 04 2008 David Cantrell - 1.8.8-3 +- Fixes so parted compiles with gcc-4.3 (#431397) + +* Sun Jan 13 2008 David Cantrell - 1.8.8-2 +- Move libparted libraries to /lib (#428420) + +* Wed Jan 02 2008 David Cantrell - 1.8.8-1 +- Upgraded to GNU parted-1.8.8 +- License for GNU parted is now GPLv3+ + +* Thu Dec 13 2007 David Cantrell - 1.8.6-13 +- Modify parted man page to indicate which flags are valid for which + disk labels (#242711) + +* Mon Nov 05 2007 David Cantrell - 1.8.6-12 +- Add KNOWN ISSUES section to parted(8) man page explaining that we cannot + currently do ext3 resizing inside parted (#367101) +- Update the xvd patch to include 'xvd' in the string table that parted + uses when printing device types (#366971) +- Do not install the linux.h or gnu.h headers + +* Tue Oct 30 2007 David Cantrell - 1.8.6-11 +- Do not install fdasd.h and vtoc.h header files + +* Thu Oct 04 2007 David Cantrell - 1.8.6-10 +- Do not install the testsuite tools + +* Thu Oct 04 2007 David Cantrell - 1.8.6-9 +- Always define PED_DEVICE_DM regardless of compile time options + +* Tue Aug 21 2007 David Cantrell - 1.8.6-8 +- Rebuild + +* Wed Aug 08 2007 David Cantrell - 1.8.6-7 +- Update License tag to GPLv2+ + +* Tue Aug 07 2007 David Cantrell - 1.8.6-6 +- Detect Xen virtual block devices and set model name appropriately + +* Thu Apr 19 2007 David Cantrell - 1.8.6-5 +- Spec file cleanups for merge review (#226230) + +* Fri Apr 13 2007 David Cantrell - 1.8.6-4 +- Fix primary partition cylinder alignment error for DOS disk labels (#229745) +- Do not build and package up libparted.a, only the shared library + +* Wed Apr 11 2007 David Cantrell - 1.8.6-3 +- Fix off-by-one bug in parted(8) when displaying disk label (#235901) + +* Wed Mar 21 2007 David Cantrell - 1.8.6-2 +- Do not translate partition name from disk label (#224182) + +* Tue Mar 20 2007 David Cantrell - 1.8.6-1 +- Upgrade to GNU parted-1.8.6, summary of major change(s): + a) Revert linux-swap(new) and linux-swap(old) fs types, it's + linux-swap for all swap types (#233085) + +* Tue Mar 20 2007 David Cantrell - 1.8.5-1 +- Upgrade to GNU parted-1.8.5 (added missing po files) + +* Fri Mar 16 2007 David Cantrell - 1.8.4-1 +- Upgrade to GNU parted-1.8.4, summary of major changes: + a) Update to use newest GNU developer tools + b) Use gnulib, the GNU portability library + c) HFS+ resize support + d) Windows Vista fixes + e) AIX disk label fixes + f) >512 byte logical sector read support on Linux +- Spec file cleanups per Fedora packaging guidelines + +* Thu Feb 08 2007 David Cantrell - 1.8.2-5 +- Remove period from end of summary line (package review) +- Use preferred BuildRoot (package review) +- BR device-mapper-devel + +* Tue Jan 30 2007 David Cantrell - 1.8.2-4 +- Patched parted.8 man page to show partition names apply to GPT disklabels + as well as Mac and PC98 disklabels (#221600) + +* Mon Jan 22 2007 David Cantrell - 1.8.2-3 +- Remove BR for libtermcap-devel +- Specifically preserve starting alignment of 0x800 on Windows Vista + (see http://support.microsoft.com/kb/923332 for details) +- Fix incorrect sector parameter used to initialize a new PedAlignment + +* Thu Jan 18 2007 David Cantrell - 1.8.2-2 +- Preserve starting sector for primary NTFS 3.1 partitions (Windows + Vista) when modifying the DOS disk label. NTFS 3.1 partitions do + not start on the 2nd head of the 1st cylinder at the beginning of + the drive. + +* Fri Jan 12 2007 David Cantrell - 1.8.2-1 +- Upgrade to GNU parted-1.8.2 + +* Fri Dec 15 2006 David Cantrell - 1.8.1-2 +- Fix a segfault when initializing new volumes (pjones) + +* Mon Dec 04 2006 David Cantrell - 1.8.1-1 +- Upgrade to GNU parted-1.8.1 + +* Fri Nov 17 2006 David Cantrell - 1.8.0-1 +- Upgrade to GNU parted-1.8.0 + +* Thu Nov 02 2006 David Cantrell - 1.7.1-18 +- Detect Apple_Boot partition types correctly (#204714) + +* Thu Oct 26 2006 David Cantrell - 1.7.1-17 +- For init_generic() failures on user-mode Linux block devices, goto + error_free_arch_specific instead of error_free_dev. + +* Wed Oct 04 2006 David Cantrell - 1.7.1-16 +- Don't throw PED_EXCEPTION_ERROR in ped_geometry_read() if accessing + sectors outside of partition boundary, since returning false will + shift ped_geometry_check() to the correct sectors. + +* Wed Aug 23 2006 David Cantrell - 1.7.1-15 +- Fixed gpt patch (*asked_already -> asked_already, whoops) + +* Tue Aug 22 2006 David Cantrell - 1.7.1-14 +- Improve error message returned by _parse_header() on GPT-labeled disks + so users actually have an idea of how to correct the problem +- Fix off-by-one error with LastUsableLBA and PartitionEntryLBA overlap + to prevent possible data corruption when using non-parted GPT editing + tools + +* Mon Aug 21 2006 Peter Jones - 1.7.1-13 +- Don't use the "volume name" as the device node name on dm device + partitions, it isn't really what we want at all. + +* Thu Aug 17 2006 David Cantrell - 1.7.1-12 +- Updated O_DIRECT patch to work around s390 problems +- Update LastUsableLBA on GPT-labeled disks after LUN resize (#194238) +- Fix exception when backup GPT table is not in the correction location + and parted tries to move it (#194238) + +* Tue Aug 15 2006 David Cantrell - 1.7.1-11 +- Expand error buffer to 8192 bytes in vtoc_error() +- Do not apply O_DIRECT patch on S/390 or S/390x platforms + +* Mon Aug 14 2006 David Cantrell - 1.7.1-10 +- Removed bad header file patch (#200577) + +* Wed Jul 12 2006 Jesse Keating - 1.7.1-9.1 +- rebuild + +* Wed Jul 5 2006 Peter Jones - 1.7.1-9 +- add ped_exception_get_handler() + +* Mon Jun 26 2006 Florian La Roche - 1.7.1-8 +- remove info files in preun + +* Thu Jun 22 2006 David Cantrell - 1.7.1-7 +- PED_SECTOR_SIZE -> PED_SECTOR_SIZE_DEFAULT + +* Thu Jun 22 2006 David Cantrell - 1.7.1-6 +- Roll dasd patches together +- Use O_DIRECT to prevent first partition corruption on GPT disks + +* Thu Jun 15 2006 Jeremy Katz - 1.7.1-5 +- fix segfaults with dasd devices + +* Wed Jun 7 2006 Jeremy Katz - 1.7.1-4 +- move .so symlink to -devel subpackage + +* Sun May 28 2006 David Cantrell - 1.7.1-3 +- Rebuild + +* Sun May 28 2006 David Cantrell - 1.7.1-2 +- Removed mac-swraid patch (added upstream) +- Updated device-mapper patch for parted-1.7.1 + +* Sat May 27 2006 David Cantrell - 1.7.1-1 +- Upgraded to parted-1.7.1 + +* Fri May 19 2006 David Cantrell - 1.7.0-1 +- Upgraded to parted-1.7.0 + +* Thu Apr 13 2006 David Cantrell - 1.6.25.1-1 +- Upgraded to parted-1.6.25.1 +- BuildRequires libtool + +* Tue Mar 14 2006 Jeremy Katz - 1.6.25-8 +- fix ppc swraid +- BR gettext-devel + +* Wed Feb 22 2006 Peter Jones - 1.6.25-7 +- close /proc/devices correctly + +* Fri Feb 10 2006 Jesse Keating - 1.6.25-6.1 +- bump again for double-long bug on ppc(64) + +* Tue Feb 7 2006 Peter Jones 1.6.25-6 +- Fix dm partition naming. + +* Tue Feb 7 2006 Jesse Keating 1.6.25-5.2 +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Fri Dec 9 2005 Jesse Keating +- rebuilt + +* Fri Dec 2 2005 Peter Jones 1.6.25-5 +- rebuild for new device-mapper + +* Thu Dec 1 2005 Peter Jones 1.6.25-4 +- change device-mapper code to call dm_task_update_nodes() after + tasks which change device nodes. + +* Wed Nov 16 2005 Peter Jones 1.6.25-3 +- fix /proc/devices parser bug + +* Tue Nov 15 2005 Peter Jones 1.6.25-2 +- add support for partitions on dm devices + +* Wed Nov 09 2005 Chris Lumens 1.6.25-1 +- Updated to 1.6.25. +- Update DASD, iseries, and SX8 patches. + +* Tue Aug 30 2005 Chris Lumens 1.6.24-1 +- Updated to 1.6.24. + +* Mon Jul 18 2005 Chris Lumens 1.6.23-2 +- Add buildreq for texinfo. + +* Fri Jul 08 2005 Chris Lumens 1.6.23-1 +- Updated to 1.6.23. +- Get rid of separate Mac patches that are now included in upstream. +- Update DASD and AIX patches. + +* Tue Jun 07 2005 Chris Lumens 1.6.22-3 +- Modified Apple_Free patch to take care of the case where the partitions + are unnamed, causing many errors to be printed (#159047). + +* Thu May 05 2005 Chris Lumens 1.6.22-2 +- Added upstream patch to display certain Apple_Free partitions (#154479). + +* Wed Mar 23 2005 Chris Lumens 1.6.22-1 +- Updated to 1.6.22. +- Get rid of separate gc4 patch that's now included upstream. +- Take Mac LVM patch from parted CVS. + +* Mon Mar 14 2005 Chris Lumens 1.6.21-3 +- Include patches from parted CVS for new gcc4 warnings. + +* Sun Feb 20 2005 Paul Nasrat 1.6.21-2 +- Support lvm flags on mac partitions (#121266) + +* Fri Jan 21 2005 Chris Lumens 1.6.21-1 +- Updated to 1.6.21 + +* Wed Jan 12 2005 Tim Waugh 1.6.20-2 +- Rebuilt for new readline. + +* Fri Jan 07 2005 Chris Lumens 1.6.20-1 +- Updated to 1.6.20 (#139257, #142100). +- Updated DASD and AIX patches for 1.6.20. + +* Tue Dec 14 2004 Jeremy Katz - 1.6.19-2 +- add support for Promise SX8 devices + +* Sun Nov 28 2004 Jeremy Katz - 1.6.19-1 +- update to 1.6.19 (#138419) + +* Sun Nov 21 2004 Jeremy Katz - 1.6.18-1 +- update to 1.6.18 + +* Sat Nov 20 2004 Miloslav Trmac - 1.6.16-3 +- Convert pt_BR-parted.8 to UTF-8 + +* Thu Nov 11 2004 Jeremy Katz - 1.6.16-2 +- add patch from Matt Domsch to fix consistency of GPT disk labels + with the EFI specification for disks > 2TB (#138480) +- understand the new Sun UFS partition ID +- merge the new geometry probing from CVS to see if that helps the + assertions people are seeing (#138419) + +* Mon Nov 8 2004 Jeremy Katz - 1.6.16-1 +- update to 1.6.16 +- rebuild for python 2.4 + +* Mon Oct 18 2004 Jeremy Katz - 1.6.15-5 +- add patch from Matt Domsch to add a unique signature to new DOS labels + so that we can later determine which BIOS disk is which (#106674) + +* Fri Oct 15 2004 Phil Knirsch 1.6.15-4 +- Fixed dasd patch (had some duplicate file patches in it) +- Fixed problem with parted segfaulting on SCSI discs on s390 (#133997) + +* Tue Oct 12 2004 Jeremy Katz - 1.6.15-3 +- add patch from peterm to fix printing of the size of large devices (#135468) + +* Thu Oct 07 2004 Phil Knirsch 1.6.15-2 +- Fixed geometry calculation for bios_geo in dasd_init() + +* Mon Sep 20 2004 Jeremy Katz - 1.6.15-1 +- 1.6.15 + +* Fri Sep 10 2004 Jeremy Katz - 1.6.14-1 +- update to 1.6.14 + +* Tue Aug 24 2004 Jeremy Katz - 1.6.12-2 +- fix assertion error when checking flags on non-active partition (#130692) +- buildrequires: gettext-devel + +* Mon Aug 16 2004 Jeremy Katz - 1.6.12-1 +- update to 1.6.12 with major changes to CHS handling to hopefully fix #115980 +- adjust dasd patch accordingly, drop some included patches + +* Mon Jul 19 2004 Karsten Hopp 1.6.11-4 +- update dasd patch for dos-type partitions on mainframes (scsi disks) + +* Fri Jun 25 2004 Jeremy Katz - 1.6.11-3 +- install-info (#77687) + +* Tue Jun 15 2004 Elliot Lee - 1.6.11-2 +- rebuilt + +* Tue Jun 1 2004 Jeremy Katz +- -devel requires main package (#124938) + +* Thu May 13 2004 Jeremy Katz - 1.6.11-1 +- update to 1.6.11 + +* Tue May 11 2004 Jeremy Katz - 1.6.9-4 +- add patch from Matt Domsch to not use the get/set last sector ioctls + with a 2.6 kernel (#121455) + +* Thu Apr 15 2004 David Woodhouse - 1.6.9-3 +- Fix Mac partition detection to close #112937 + +* Tue Apr 13 2004 Jeremy Katz - 1.6.9-2 +- another minor tweak for 2.6's lack of sane geometry handling + +* Mon Apr 12 2004 Jeremy Katz - 1.6.9-1 +- update to 1.6.9 +- need automake17 +- python-devel is superfluous with pyparted as a separate package +- lose the fake-libtool stuff, 1.6.9 was disted with newer auto* + +* Mon Mar 15 2004 Elliot Lee 1.6.6-2 +- Fix parted's "part-static" option to close #118183. Woohoo, a fake-libtool.sh :) + +* Fri Mar 12 2004 Jeremy Katz - 1.6.6-1 +- update to 1.6.6 +- split dasd into a patch instead of included in the tarball +- python module is now in the pyparted package (separate src.rpm) +- ExcludeArch: ppc64 (#118183) + +* Tue Mar 02 2004 Elliot Lee +- rebuilt + +* Fri Feb 13 2004 Elliot Lee +- rebuilt + +* Fri Feb 6 2004 Jeremy Katz +- add automake buildrequires (#115063) + +* Thu Jan 22 2004 Jeremy Katz 1.6.3-33 +- 2.6 removes the geometry fixups that used to be present for IDE disks. + According to Andries, just follow what's in the partition table and don't + worry about what Linux "detects" + +* Thu Nov 6 2003 Jeremy Katz 1.6.3-32 +- rebuild for python 2.3 + +* Mon Oct 27 2003 Jeremy Katz 1.6.3-31 +- add patch from Michael Schwendt for segfault + +* Wed Sep 17 2003 Jeremy Katz 1.6.3-30 +- rebuild + +* Wed Sep 17 2003 Jeremy Katz 1.6.3-29 +- and don't barf on the old (broken) 1.02 gpt rev + +* Tue Sep 16 2003 Jeremy Katz 1.6.3-28 +- rebuild + +* Tue Sep 16 2003 Jeremy Katz 1.6.3-27 +- write out the correct gpt revision (#103664) +- add buildrequires on ncurses-devel + +* Thu Sep 4 2003 Bill Nottingham 1.6.3-26 +- rebuild + +* Thu Sep 4 2003 Bill Nottingham 1.6.3-25 +- don't buildreq libunicode-devel + +* Thu Aug 07 2003 Elliot Lee 1.6.3-24 +- Fix libtool + +* Wed Jul 09 2003 Phil Knirsch 1.6.3-23 +- Fixed dasd_write and dasd_read to support lvm and raid partitions. + +* Wed Jun 18 2003 Phil Knirsch 1.6.3-22 +- Fixed a small bug in VTOC fdasd_check_volume() (#97300). + +* Wed Jun 04 2003 Elliot Lee 1.6.3-21 +- rebuilt + +* Wed Jun 4 2003 Matt Wilson 1.6.3-20 +- don't detect AIX physical volumes as msdos partition tables (#91748) +- added stubbed code for manipulating AIX PVs, enough to clobber the + signature. (#91748) + +* Wed Jun 04 2003 Phil Knirsch 1.6.3-19 +- Added LDL disk layout support for s390(x). + +* Sun May 18 2003 Matt Wilson 1.6.3-18 +- use metadata partitions to protect DASD VTOC +- stash DASD specific data in disk specific areas, not arch specific + areas. + +* Fri May 16 2003 Matt Wilson 1.6.3-18 +- recongnize iseries viodasd (#90449) + +* Thu May 08 2003 Phil Knirsch 1.6.3-17 +- Fixed problem with probing partitions on s390(x) with new partition code. + +* Mon May 05 2003 Phil Knirsch 1.6.3-16 +- Fixed partiton reread code for s390(x). + +* Fri May 02 2003 Phil Knirsch 1.6.3-15 +- Rewrote partition handling for s390(x) dasd devices. No more empty partitions. + +* Wed Mar 12 2003 Phil Knirsch 1.6.3-13 +- Finished updating vtoc and fdasd code to latest s390-utils version. + +* Thu Mar 06 2003 Phil Knirsch 1.6.3-12 +- Fixed vtoc handling on s390(x) dasd devices. + +* Thu Feb 06 2003 Karsten Hopp 1.6.3-11 +- use different define to enable DASD debugging + Otherwise we'll get a lot of dasd debug output because DEBUG is + always defined + +* Wed Jan 22 2003 Tim Powers +- rebuilt + +* Wed Jan 22 2003 Karsten Hopp 1.6.3-9 +- missed one debug message + +* Tue Jan 21 2003 Karsten Hopp 1.6.3-8 +- add patch from CVS to disable debug messages on s390 + +* Tue Jan 14 2003 Matt Wilson 1.6.3-7 +- updated to a new tarball of parted that includes a fs.probe_specific binding + +* Sun Dec 1 2002 Matt Wilson 1.6.3-6 +- hack in partition.native_type (#78118) + +* Thu Nov 7 2002 Matt Wilson +- added a patch to avoid SIGFPE when fat sector size is 0 + +* Tue Nov 5 2002 Matt Wilson +- use --disable-dynamic-loading + +* Mon Nov 4 2002 Matt Wilson +- add device.disk_new_fresh() + +* Fri Nov 1 2002 Matt Wilson +- 1.6.3 + +* Fri Oct 4 2002 Jeremy Katz 1.4.24-7 +- use make LIBTOOL=/usr/bin/libtool instead of recreating everything +- add patch from Jack Howarth to self host properly +- add patch to treat GPT structs as little-endian always and treat GUIDS + as little-endian blobs +- add patch to recognize hp service partitions + +* Wed Sep 25 2002 Jeremy Katz 1.4.24-6hammer +- libtoolize, etc for x86_64 +- hack to get the python module in the right place until python.m4 + from automake is fixed + +* Fri Jun 21 2002 Tim Powers 1.4.24-6 +- automated rebuild + +* Sun May 26 2002 Tim Powers 1.4.24-5 +- automated rebuild + +* Wed May 22 2002 Jeremy Katz 1.4.24-4 +- rebuild in new environment + +* Fri Mar 22 2002 Matt Wilson 1.4.24-3 +- fixed the probe-with-open behavior (again) + +* Fri Feb 22 2002 Matt Wilson 1.4.24-1 +- rebuild + +* Tue Feb 12 2002 Matt Wilson 1.4.24-1 +- 1.4.24 + +* Wed Jan 09 2002 Tim Powers +- automated rebuild + +* Mon Jan 7 2002 Jeremy Katz 1.4.20-4 +- build with final python 2.2 + +* Wed Dec 12 2001 Jeremy Katz 1.4.20-3 +- update from CVS and rebuild in new environment + +* Thu Oct 25 2001 Jeremy Katz 1.4.20-2 +- build both python1.5 and python2 modules + +* Fri Oct 19 2001 Matt Wilson 1.4.20-1 +- 1.4.20 final + +* Thu Oct 11 2001 Matt Wilson 1.4.20-0.1pre3 +- new dist from CVS with new autoconf and automake +- gpt is in 1.4.20, removed patch1 (gpt support) +- partstatic is in 1.4.20, removed patch2 (partstatic patch) + +* Tue Aug 28 2001 Matt Wilson 1.4.16-8 +- new dist from cvs with changes to the python binding: register + DEVICE_I20 and DEVICE_ATARAID, check to make sure that a partition + exists in the PedDisk when using it to find ped_disk_next_partition + +* Tue Aug 21 2001 Matt Wilson 1.4.16-7 +- really disable pc98 support (SF #51632) + +* Fri Aug 17 2001 Matt Wilson 1.4.16-6 +- added a patch (Patch1) to link the c library in dynamically, the + rest of the libs statically for the parted binary (MF #49358) + +* Tue Aug 7 2001 Matt Wilson +- made a new dist from CVS that includes binding for + disk.get_partition_by_sector and accessing the name of a disk type + +* Mon Aug 6 2001 Matt Wilson 1.4.16-4 +- created a new dist from CVS that fixes ext3 detection when + _probe_with_open is needed (#50292) + +* Fri Jul 20 2001 Matt Wilson +- rewrite scsi id code (#49533) + +* Fri Jul 20 2001 Matt Wilson +- added build requires (#49549) + +* Tue Jul 17 2001 Matt Wilson +- 1.4.16 +- regenerated gpt patch against 1.4.16, incorporated + parted-1.4.15-pre1-gpt-printf.patch into the same patch, removed Patch1 + +* Tue Jul 10 2001 Matt Wilson +- added a new dist tarball that contains python wrappers to get disk types + +* Tue Jul 10 2001 Tim Powers +- run ldconfig on un/install + +* Tue Jul 10 2001 Matt Wilson +- added a fix from clausen for border case when there is an extended + on the last cyl + +* Mon Jul 9 2001 Matt Wilson +- 1.4.15 + +* Thu Jul 5 2001 Matt Wilson +- added patch from Arjan to enable ataraid support + +* Wed Jul 4 2001 Matt Wilson +- imported 1.4.15-pre2 into CVS and made a new dist tarball + +* Tue Jun 26 2001 Matt Wilson +- added a new dist tarball that contains a check in python code to + make sure that a partition exists within a disk before trying to + remove it from the disk +- also changed _probe_with_open to make the first probed filesystem win + +* Tue Jun 26 2001 Bill Nottingham +- fix filesystem type reading on GPT disks + +* Tue Jun 26 2001 Matt Wilson +- added another fix for ext2/ext3 +- added Patch4 to move the crc32 function into its own namespace so + we don't colide with zlib when both are in the same executable space + +* Mon Jun 25 2001 Matt Wilson +- added a new dist tarball from CVS that includes + ext3 probing + +* Wed Jun 6 2001 Matt Wilson +- updated dist with binding for partition.geom.disk + +* Tue Jun 5 2001 Matt Wilson +- make a new dist tarball that has new python binding changes + +* Tue May 29 2001 Bill Nottingham +- add major numbers for cciss +- add libunicode-devel buildprereq + +* Sun May 27 2001 Matthew Wilson +- added type, heads, and sectors to the python binding for PedDevice + +* Fri May 4 2001 Matt Wilson +- added parted-1.4.11-gpt-pmbralign.patch from Matt Domsch + +* Wed May 2 2001 Matt Wilson +- include python binding +- enable shared library (for python binding, we want fpic code) + with --enable-shared +- build parted binary static with --enable-all-static +- don't run libtoolize on this. + +* Wed May 02 2001 Bill Nottingham +- update to 1.4.11 +- add EFI GPT patch from Matt Domsch () +- don't run autoconf, it relies on a newer non-released version + of autoconf... + +* Fri Feb 23 2001 Trond Eivind Glomsrød +- langify + +* Wed Jan 17 2001 Florian La Roche +- update to 1.4.7 + +* Thu Dec 14 2000 Bill Nottingham +- rebuild because of broken fileutils + +* Fri Nov 03 2000 Florian La Roche +- update to 1.2.12 + +* Wed Nov 01 2000 Florian La Roche +- update to 1.2.11 + +* Tue Oct 17 2000 Florian La Roche +- update to 1.2.10 + +* Sun Sep 10 2000 Florian La Roche +- update to 1.2.9 + +* Tue Aug 29 2000 Florian La Roche +- fix bug when just hitting "return" with no user input + +* Sun Aug 20 2000 Florian La Roche +- 1.2.8 +- blksize patch not needed anymore +- move changelog to the end of the spec file + +* Wed Aug 16 2000 Matt Wilson +- 1.2.7 +- patched configure script to ignore the 2.4 blkpg.h header (fixes #15835). + +* Fri Aug 4 2000 Florian La Roche +- update to 1.2.6 + +* Sat Jul 22 2000 Florian La Roche +- update to 1.2.5 +- add more docu + +* Wed Jul 12 2000 Prospector +- automatic rebuild + +* Mon Jun 12 2000 Matt Wilson +- initialization of spec file.