Re: Ext2fs getting hosed by fsck

Theodore Y. Ts'o (tytso@MIT.EDU)
Sun, 10 Aug 1997 18:47:56 -0400


Date: Sun, 10 Aug 1997 21:17:52 +0200
From: "Stephen R. van den Berg" <srb@cuci.nl>

Sometimes, when I check a filesystem after a rather untimely crash,
(Linux v2.0.30pre2-something and e2fsck v1.10), I get the following
entries in lost+found (see below).

Naturally (?), the kernel does not allow me to unlink these
contraptions:

unlink("#45135") = -1 EPERM (Operation not permitted)

These files are character devices that have the immutable bit set.
Unfortunately, due to a lack of a chflags() system call (working on it),
you can't clear the immutable bit easily.

The workaround for now to to fire up debugfs, and use the clri command
to forcibly clear out the inodes.

There are a couple of fixes here. One is to make e2fsck a bit more
strict about what's considered a valid character and block device. If
the other block fields in the inodes are non-zero, it's probably from a
garbaged inode table, and it should clear the inode. I'll be adding
this into the next version of e2fsck.

The other fix is to allow chattr to set and clear the immutable flag on
a character and block device. This is currently being done using an
ioctl, which doesn't work on block and character devices, because the
ext2 ioctl code never gets control. The right apporach is to create a
new system call that can be used to set and clear filesystem attributes
--- MSDOS system and and dump flags, ext2 dump, immtutable and
append-only flags, etc. BSD has such a system call already, so we
should just copy that design.

Both of these are on my queue of things to do, but unfortunately I've
been rather swamped lately....

- Ted