diff --git a/0012-tests-Make-sure-the-extended-partition-length-is-2-1.patch b/0012-tests-Make-sure-the-extended-partition-length-is-cor.patch similarity index 75% rename from 0012-tests-Make-sure-the-extended-partition-length-is-2-1.patch rename to 0012-tests-Make-sure-the-extended-partition-length-is-cor.patch index c5da04b..39b105a 100644 --- a/0012-tests-Make-sure-the-extended-partition-length-is-2-1.patch +++ b/0012-tests-Make-sure-the-extended-partition-length-is-cor.patch @@ -1,15 +1,18 @@ -From 8b23531d1432c7ca0918c2a1c5a7f00ca881968c Mon Sep 17 00:00:00 2001 +From 822439e4eaa4bb758d9058022154973cd690eca7 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 5 Jun 2015 13:46:29 -0700 -Subject: [PATCH 12/13] tests: Make sure the extended partition length is 2 +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. +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 | 41 +++++++++++++++++++++++++++++++++++ - 2 files changed, 42 insertions(+) + 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 @@ -26,10 +29,10 @@ index ce8391d..001b9de 100644 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..1a4638a +index 0000000..6f3dfff --- /dev/null +++ b/tests/t2320-dos-extended-noclobber.sh -@@ -0,0 +1,41 @@ +@@ -0,0 +1,48 @@ +#!/bin/sh +# Ensure that the extended partition reports the correct length +# after adding another partition. @@ -65,12 +68,19 @@ index 0000000..1a4638a +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 2 sectors ++# 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) -+[ $ext_len -eq 2 ] || fail=1 ++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.0 +2.4.3 diff --git a/0015-UI-Avoid-memory-leaks.patch b/0015-UI-Avoid-memory-leaks.patch new file mode 100644 index 0000000..91dfda8 --- /dev/null +++ b/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/0016-libparted-Fix-memory-leaks.patch b/0016-libparted-Fix-memory-leaks.patch new file mode 100644 index 0000000..23cc36a --- /dev/null +++ b/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/0017-libparted-Fix-possible-memory-leaks.patch b/0017-libparted-Fix-possible-memory-leaks.patch new file mode 100644 index 0000000..525dbd2 --- /dev/null +++ b/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/0018-libparted-Stop-converting-.-in-sys-path-to.patch b/0018-libparted-Stop-converting-.-in-sys-path-to.patch new file mode 100644 index 0000000..a22738d --- /dev/null +++ b/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/0019-libparted-Use-read-only-when-probing-devices-on-linu.patch b/0019-libparted-Use-read-only-when-probing-devices-on-linu.patch new file mode 100644 index 0000000..4b16f26 --- /dev/null +++ b/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/0020-tests-Use-wait_for_dev_to_-functions.patch b/0020-tests-Use-wait_for_dev_to_-functions.patch new file mode 100644 index 0000000..1856761 --- /dev/null +++ b/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/parted.spec b/parted.spec index d33a4f7..e6f2a6e 100644 --- a/parted.spec +++ b/parted.spec @@ -4,7 +4,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.2 -Release: 10%{?dist} +Release: 11%{?dist} License: GPLv3+ Group: Applications/System URL: http://www.gnu.org/software/parted @@ -25,9 +25,16 @@ 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-2-1.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 + Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: e2fsprogs-devel @@ -170,6 +177,15 @@ fi %changelog +* 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)