[PATCH] Add a test to record the current EXT2 mkpartfs failure for some sizes.

Jim Meyering jim at meyering.net
Mon Jun 11 12:34:39 UTC 2007


Run this:

    dev=F
    dd if=/dev/null of=$dev bs=1 seek=20M
    ./parted -s $dev mklabel gpt
    ./parted -s $dev mkpartfs primary ext2 0 16796160B

It fails with this diagnostic:

    Error: Attempt to write sectors 32772-32773 outside of partition on /t/F.

But if you choose a size that's one byte smaller, it works:

    ./parted -s $dev mkpartfs primary ext2 0 16796159B

The difference is in how ext2_mkfs_write_meta computes
the number of block groups.  In the former case, it computes
numgroups = 3.  In the latter, numgroups = 2.
The trouble with the first case is that there isn't enough
space for 3 full block groups in a file system of that size.
Hence the eventual attempt to write beyond the initially-
established end-of-file-system mark.

Signed-off-by: Jim Meyering <jim at meyering.net>
---
 tests/t2000-mkfs.sh |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/tests/t2000-mkfs.sh b/tests/t2000-mkfs.sh
index e1a01fc..11951ea 100755
--- a/tests/t2000-mkfs.sh
+++ b/tests/t2000-mkfs.sh
@@ -106,4 +106,23 @@ test_expect_success \
        echo "Error: Expecting a file system type."; } > exp &&
      $compare out exp'

+#############################################################
+# Demonstrate 3-block-group failure for 16+MB EXT2 file system.
+# This test fails with at least parted-1.8.8.
+
+dev=loop-file
+
+test_expect_success \
+    "setup: create and label a device" \
+    'dd if=/dev/null of=$dev bs=1 seek=20M 2>/dev/null &&
+     parted -s $dev mklabel gpt'
+
+# FIXME: this test currently fails with the diagnostic "Error: Attempt
+# to write sectors 32772-32773 outside of partition on .../loop-file."
+# Eventually, when this bug is fixed, change to "test_expect_success"
+# and ensure that the output file is empty.
+test_expect_failure \
+    'try to create a file system with the offending size' \
+    'parted -s $dev mkpartfs primary ext2 0 16796160B >out 2>&1'
+
 test_done



More information about the parted-devel mailing list