[parted-devel] [PATCH included] EXT2 FS code in parted

Jim Meyering jim at meyering.net
Mon Jun 11 12:48:24 UTC 2007


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:



More information about the parted-devel mailing list