FYI, I spent some time looking at the resize bug for which Matt provided a
test case a couple weeks ago. Along the way, I found that the ext2
FS-*creation* code is not up to snuff. For example, creating an EXT2
partition of certain unfortunate sizes fails unnecessarily. For example,
here's a demonstration using one of the smallest sizes:
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.
Not too keen on the state of parted's bit-rotting FS code
in the first place, now I'm looking at e2fsprogs with an eye
to replacing all ext2-related code right away. e2fsprogs is
obviously well maintained, with an extensive test suite and
an existing library/API, so it looks like it'd be a fine
replacement for what's in parted.
Is anyone already working on this?
---------------------------
FYI, here's a patch I expect to commit today, just to
record this EXT2 mkfs failure:
>From f0cbb9129a2a9af6d282963f2d072719273915e9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[EMAIL PROTECTED]>
Date: Mon, 11 Jun 2007 14:34:39 +0200
Subject: [PATCH] Add a test to record the current EXT2 mkpartfs failure for
some sizes.
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 <[EMAIL PROTECTED]>
---
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
_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel