From 42ecfc7b6b625245eb53e70fa36d657973f11c74 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 15 Apr 2014 14:42:18 -0700
Subject: [PATCH] - 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

---
 ...e-for-xfs-in-t1700-and-a-larger-file.patch | 52 ++++++++++++
 0095-tests-t1700-change-count-to-seek.patch   | 37 +++++++++
 ...100-xfs-filesystem-larger-and-sparse.patch | 44 ++++++++++
 ...parted-Fix-part-dupe-with-empty-name.patch | 33 ++++++++
 0098-tests-check-name-when-duplicating.patch  | 82 +++++++++++++++++++
 ...tfs-vfat-hfsplus-to-t1700-probe-test.patch | 55 +++++++++++++
 parted.spec                                   | 15 +++-
 7 files changed, 317 insertions(+), 1 deletion(-)
 create mode 100644 0094-tests-Use-force-for-xfs-in-t1700-and-a-larger-file.patch
 create mode 100644 0095-tests-t1700-change-count-to-seek.patch
 create mode 100644 0096-tests-Make-t4100-xfs-filesystem-larger-and-sparse.patch
 create mode 100644 0097-libparted-Fix-part-dupe-with-empty-name.patch
 create mode 100644 0098-tests-check-name-when-duplicating.patch
 create mode 100644 0099-tests-Add-ntfs-vfat-hfsplus-to-t1700-probe-test.patch

diff --git a/0094-tests-Use-force-for-xfs-in-t1700-and-a-larger-file.patch b/0094-tests-Use-force-for-xfs-in-t1700-and-a-larger-file.patch
new file mode 100644
index 0000000..7050678
--- /dev/null
+++ b/0094-tests-Use-force-for-xfs-in-t1700-and-a-larger-file.patch
@@ -0,0 +1,52 @@
+From abd761cc286c56e9b9d19c22bb044d2b416a4e8a Mon Sep 17 00:00:00 2001
+From: "Brian C. Lane" <bcl@redhat.com>
+Date: Mon, 14 Apr 2014 15:04:17 -0700
+Subject: [PATCH] tests: Use force for xfs in t1700 and a larger file
+
+Also use sparse files that are (with 512B blocks) 128M so that they are
+large enough for all the filesystems.
+
+* tests/t1700-probe-fs.sh: Make changes.
+---
+ tests/t1700-probe-fs.sh | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh
+index 0418e73..08ec7d9 100755
+--- a/tests/t1700-probe-fs.sh
++++ b/tests/t1700-probe-fs.sh
+@@ -21,17 +21,19 @@ require_512_byte_sector_size_
+ 
+ dev=loop-file
+ ss=$sector_size_
++n_sectors=$((257*1024))
+ 
+ for type in ext2 ext3 ext4 btrfs xfs nilfs2; do
+ 
+   ( mkfs.$type -V ) >/dev/null 2>&1 \
+       || { warn_ "$ME: no $type support"; continue; }
+ 
+-  case $type in ext*) n_sectors=8000 force=-F;;
+-      *) n_sectors=$((257*1024)) force=;; esac
++  case $type in ext*) force=-F;;
++      xfs) force=-f;;
++      *) force=;; esac
+ 
+   # create an $type file system
+-  dd if=/dev/zero of=$dev bs=$ss count=$n_sectors >/dev/null || fail=1
++  dd if=/dev/null of=$dev bs=$ss count=$n_sectors >/dev/null || fail=1
+   mkfs.$type $force $dev || { warn_ $ME: mkfs.$type failed; fail=1; continue; }
+ 
+   # probe the $type file system
+@@ -43,7 +45,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/zero of=$dev bs=1024 count=4096 >/dev/null || fail=1
++  dd if=/dev/null of=$dev bs=1024 count=4096 >/dev/null || fail=1
+   mkfs.ext3 -F $dev >/dev/null || skip_ "mkfs.ext3 failed"
+ 
+   # set the feature
+-- 
+1.9.0
+
diff --git a/0095-tests-t1700-change-count-to-seek.patch b/0095-tests-t1700-change-count-to-seek.patch
new file mode 100644
index 0000000..fa192b0
--- /dev/null
+++ b/0095-tests-t1700-change-count-to-seek.patch
@@ -0,0 +1,37 @@
+From 3819a3822af62c56c0e1f4b0ab1c6aea9ae147bb Mon Sep 17 00:00:00 2001
+From: "Brian C. Lane" <bcl@redhat.com>
+Date: Thu, 17 Apr 2014 12:12:29 -0700
+Subject: [PATCH 95/99] tests: t1700 change count to seek
+
+Fix a typo when changing to sparse images.
+
+* tests/t1700-probe-fs.sh: count should be seek.
+---
+ tests/t1700-probe-fs.sh | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh
+index 08ec7d9..bf6ad9c 100755
+--- a/tests/t1700-probe-fs.sh
++++ b/tests/t1700-probe-fs.sh
+@@ -33,7 +33,7 @@ for type in ext2 ext3 ext4 btrfs xfs nilfs2; do
+       *) force=;; esac
+ 
+   # create an $type file system
+-  dd if=/dev/null of=$dev bs=$ss count=$n_sectors >/dev/null || fail=1
++  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; }
+ 
+   # probe the $type file system
+@@ -45,7 +45,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 count=4096 >/dev/null || fail=1
++  dd if=/dev/null of=$dev bs=1024 seek=4096 >/dev/null || fail=1
+   mkfs.ext3 -F $dev >/dev/null || skip_ "mkfs.ext3 failed"
+ 
+   # set the feature
+-- 
+1.9.0
+
diff --git a/0096-tests-Make-t4100-xfs-filesystem-larger-and-sparse.patch b/0096-tests-Make-t4100-xfs-filesystem-larger-and-sparse.patch
new file mode 100644
index 0000000..6d8ed4b
--- /dev/null
+++ b/0096-tests-Make-t4100-xfs-filesystem-larger-and-sparse.patch
@@ -0,0 +1,44 @@
+From 2621c147fb65a4034fd186b07792634d26488b5f Mon Sep 17 00:00:00 2001
+From: "Brian C. Lane" <bcl@redhat.com>
+Date: Wed, 16 Apr 2014 17:58:29 -0700
+Subject: [PATCH 96/99] tests: Make t4100 xfs filesystem larger and sparse
+
+Newer versions of mkfs.xfs appear to be using more blocks for the
+journal, causing t4100-* tests to fail. Make the image larger.
+
+* tests/t4100-dvh-partition-limits.sh: Make the xfs image larger
+* tests/t4100-msdos-partition-limits.sh: Make the xfs image larger
+---
+ tests/t4100-dvh-partition-limits.sh   | 2 +-
+ tests/t4100-msdos-partition-limits.sh | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tests/t4100-dvh-partition-limits.sh b/tests/t4100-dvh-partition-limits.sh
+index a1bc69a..fb10025 100755
+--- a/tests/t4100-dvh-partition-limits.sh
++++ b/tests/t4100-dvh-partition-limits.sh
+@@ -37,7 +37,7 @@ mp=`pwd`/mount-point
+ n=4096
+ 
+ # create an XFS file system
+-dd if=/dev/zero of=$fs bs=1MB count=2 seek=20 || fail=1
++dd if=/dev/null of=$fs bs=1MB seek=50 || fail=1
+ mkfs.xfs -f -q $fs || fail=1
+ mkdir "$mp" || fail=1
+ 
+diff --git a/tests/t4100-msdos-partition-limits.sh b/tests/t4100-msdos-partition-limits.sh
+index 65bda25..af7907f 100755
+--- a/tests/t4100-msdos-partition-limits.sh
++++ b/tests/t4100-msdos-partition-limits.sh
+@@ -37,7 +37,7 @@ mp=`pwd`/mount-point
+ n=4096
+ 
+ # create an XFS file system
+-dd if=/dev/zero of=$fs bs=1MB count=2 seek=20 || fail=1
++dd if=/dev/null of=$fs bs=1MB seek=50 || fail=1
+ mkfs.xfs -f -q $fs || fail=1
+ mkdir "$mp" || fail=1
+ 
+-- 
+1.9.0
+
diff --git a/0097-libparted-Fix-part-dupe-with-empty-name.patch b/0097-libparted-Fix-part-dupe-with-empty-name.patch
new file mode 100644
index 0000000..7585b96
--- /dev/null
+++ b/0097-libparted-Fix-part-dupe-with-empty-name.patch
@@ -0,0 +1,33 @@
+From 0f121ea55d996f6149c465e7e5cf94c596a448a5 Mon Sep 17 00:00:00 2001
+From: "Brian C. Lane" <bcl@redhat.com>
+Date: Wed, 16 Apr 2014 18:18:38 -0700
+Subject: [PATCH 97/99] libparted: Fix part dupe with empty name
+
+It was setting the original translated_name to 0, not the new copy.
+
+* libparted/labels/gpt.c (gpt_partition_duplicate): fix empty name
+---
+ libparted/labels/gpt.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
+index 6eff38a..31f6d17 100644
+--- a/libparted/labels/gpt.c
++++ b/libparted/labels/gpt.c
+@@ -1414,9 +1414,11 @@ gpt_partition_duplicate (const PedPartition *part)
+     goto error_free_part;
+ 
+   *result_data = *part_data;
+-  if (part_data->translated_name)
++  if (part_data->translated_name) {
+     result_data->translated_name = xstrdup (part_data->translated_name);
+-  else part_data->translated_name = 0;
++  } else {
++    result_data->translated_name = 0;
++  }
+   return result;
+ 
+ error_free_part:
+-- 
+1.9.0
+
diff --git a/0098-tests-check-name-when-duplicating.patch b/0098-tests-check-name-when-duplicating.patch
new file mode 100644
index 0000000..5c22ecd
--- /dev/null
+++ b/0098-tests-check-name-when-duplicating.patch
@@ -0,0 +1,82 @@
+From b9fb544685bebee87311007686e6d7c93f6f2797 Mon Sep 17 00:00:00 2001
+From: "Brian C. Lane" <bcl@redhat.com>
+Date: Wed, 16 Apr 2014 16:51:18 -0700
+Subject: [PATCH 98/99] tests: check name when duplicating
+
+Create a second partition with a name when supported by the disk label.
+Check to make sure that the duplicate has copied over the name. The goal
+with this was to try to catch the bug fixed by the previous commit but I
+was unable to make it fail. But this should improve our test coverage
+anyway.
+
+* tests/duplicate.c: Add a partition name test.
+---
+ tests/duplicate.c | 33 +++++++++++++++++++++++++++++----
+ 1 file changed, 29 insertions(+), 4 deletions(-)
+
+diff --git a/tests/duplicate.c b/tests/duplicate.c
+index 129537c..a9dde84 100644
+--- a/tests/duplicate.c
++++ b/tests/duplicate.c
+@@ -50,7 +50,7 @@ main (int argc, char **argv)
+   const PedGeometry *geometry = ped_geometry_new (dev, 34, 1024);
+   assert (geometry);
+   PedPartition *part = ped_partition_new (disk, part_type, fs_type,
+-					  geometry->start, geometry->end);
++                                          geometry->start, geometry->end);
+   assert (part);
+   PedConstraint *constraint = ped_constraint_exact (geometry);
+   assert (constraint);
+@@ -65,6 +65,22 @@ main (int argc, char **argv)
+   if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
+     ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
+ 
++  /* Add a 2nd partition with a name (when supported) */
++  geometry = ped_geometry_new (dev, 1500, 500);
++  assert (geometry);
++  part = ped_partition_new (disk, part_type, fs_type,
++                            geometry->start, geometry->end);
++  assert (part);
++  constraint = ped_constraint_exact (geometry);
++  assert (constraint);
++  assert (ped_disk_add_partition (disk, part, constraint));
++  ped_constraint_destroy (constraint);
++  assert (ped_partition_set_system (part, fs_type));
++  if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
++    ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
++  if (ped_disk_type_check_feature (part->disk->type, PED_DISK_TYPE_PARTITION_NAME))
++    ped_partition_set_name(part, "foobarbaz");
++
+   assert (ped_disk_commit(disk));
+ 
+   /* Duplicate it */
+@@ -114,14 +130,23 @@ main (int argc, char **argv)
+ 
+     /* Check the flags */
+     for (PedPartitionFlag flag = PED_PARTITION_FIRST_FLAG;
+-	 flag <= PED_PARTITION_LAST_FLAG; flag++) {
++        flag <= PED_PARTITION_LAST_FLAG; flag++)
++    {
+       if (!ped_partition_is_flag_available(disk_part, flag))
+         continue;
+       fprintf (stderr, "Checking partition flag %d\n", flag);
+       fprintf (stderr, "%d ? %d\n", ped_partition_get_flag (disk_part, flag),
+-	       ped_partition_get_flag (copy_part, flag));
++               ped_partition_get_flag (copy_part, flag));
+       assert (ped_partition_get_flag (disk_part, flag)
+-	      == ped_partition_get_flag (copy_part, flag));
++              == ped_partition_get_flag (copy_part, flag));
++    }
++
++    /* Check the name, if supported */
++    if (ped_disk_type_check_feature (part->disk->type, PED_DISK_TYPE_PARTITION_NAME))
++    {
++      const char *disk_name = ped_partition_get_name(disk_part);
++      const char *copy_name = ped_partition_get_name(copy_part);
++      assert (strcmp (disk_name, copy_name) == 0);
+     }
+   }
+ 
+-- 
+1.9.0
+
diff --git a/0099-tests-Add-ntfs-vfat-hfsplus-to-t1700-probe-test.patch b/0099-tests-Add-ntfs-vfat-hfsplus-to-t1700-probe-test.patch
new file mode 100644
index 0000000..1809650
--- /dev/null
+++ b/0099-tests-Add-ntfs-vfat-hfsplus-to-t1700-probe-test.patch
@@ -0,0 +1,55 @@
+From 01d4a9431ddecb1fb4ff276aa33e6e4ac3418f1d Mon Sep 17 00:00:00 2001
+From: "Brian C. Lane" <bcl@redhat.com>
+Date: Thu, 17 Apr 2014 12:14:48 -0700
+Subject: [PATCH 99/99] tests: Add ntfs vfat hfsplus to t1700 probe test
+
+Add some new filesystems to test. Adjust how mkfs.* tests, since some of
+them don't support -V, and add fsname so that the printed filesystem
+name doesn't have to match the type.
+
+* tests/t1700-probe-fs.sh: Add new filesystems to test
+---
+ tests/t1700-probe-fs.sh | 16 +++++++++++-----
+ 1 file changed, 11 insertions(+), 5 deletions(-)
+
+diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh
+index bf6ad9c..d53cc7e 100755
+--- a/tests/t1700-probe-fs.sh
++++ b/tests/t1700-probe-fs.sh
+@@ -23,14 +23,20 @@ dev=loop-file
+ ss=$sector_size_
+ n_sectors=$((257*1024))
+ 
+-for type in ext2 ext3 ext4 btrfs xfs nilfs2; do
++for type in ext2 ext3 ext4 btrfs xfs nilfs2 ntfs vfat hfsplus; do
+ 
+-  ( mkfs.$type -V ) >/dev/null 2>&1 \
++  ( mkfs.$type 2>&1 | grep -i '^usage' ) > /dev/null \
+       || { warn_ "$ME: no $type support"; continue; }
+ 
+-  case $type in ext*) force=-F;;
++  fsname=$type
++  force=
++  case $type in
++      ext*) force=-F;;
+       xfs) force=-f;;
+-      *) force=;; esac
++      ntfs) force=-F;;
++      vfat) fsname=fat16;;
++      hfsplus) fsname=hfs+;;
++  esac
+ 
+   # create an $type file system
+   dd if=/dev/null of=$dev bs=$ss seek=$n_sectors >/dev/null || fail=1
+@@ -38,7 +44,7 @@ for type in ext2 ext3 ext4 btrfs xfs nilfs2; do
+ 
+   # probe the $type file system
+   parted -m -s $dev u s print >out 2>&1 || fail=1
+-  grep '^1:.*:'$type'::;$' out || { cat out; fail=1; }
++  grep '^1:.*:'$fsname'::;$' out || { cat out; fail=1; }
+ 
+ done
+ 
+-- 
+1.9.0
+
diff --git a/parted.spec b/parted.spec
index ce8f3d6..6ff4e55 100644
--- a/parted.spec
+++ b/parted.spec
@@ -4,7 +4,7 @@
 Summary: The GNU disk partition manipulation program
 Name:    parted
 Version: 3.1
-Release: 19%{?dist}
+Release: 20%{?dist}
 License: GPLv3+
 Group:   Applications/System
 URL:     http://www.gnu.org/software/parted
@@ -116,6 +116,12 @@ Patch0090: 0090-tests-Add-emit_superuser_warning-for-gpt-tests.patch
 Patch0091: 0091-tests-Use-msdos-overlap-to-setup-t0283.patch
 Patch0092: 0092-testing-Use-little-endian-packing-in-gpt-tests.patch
 Patch0093: 0093-libparted-fix-several-integer-overflows-with-dvh-lab.patch
+Patch0094: 0094-tests-Use-force-for-xfs-in-t1700-and-a-larger-file.patch
+Patch0095: 0095-tests-t1700-change-count-to-seek.patch
+Patch0096: 0096-tests-Make-t4100-xfs-filesystem-larger-and-sparse.patch
+Patch0097: 0097-libparted-Fix-part-dupe-with-empty-name.patch
+Patch0098: 0098-tests-check-name-when-duplicating.patch
+Patch0099: 0099-tests-Add-ntfs-vfat-hfsplus-to-t1700-probe-test.patch
 
 
 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -255,6 +261,13 @@ fi
 
 
 %changelog
+* Thu Apr 17 2014 Brian C. Lane <bcl@redhat.com> 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 <bcl@redhat.com> 3.1-19
 - Use little endian packing in gpt tests
 - Fix integer overflows with DVH disk label