ext2 and unlink(2)

Herbert Xu (herbert@gondor.apana.org.au)
Mon, 29 Sep 1997 10:01:06 +1000 (EST)


The following was observed with kernel 2.0.30 and e2fsprogs 1.10. Brian later
tried to do 'chattr -i' on those files but it failed as described in the 2nd
forwarded message. Brian still has these files around if anyone needs him to
do any testing.

And please cc to 13330-forwarded@bugs.debian.org and bcwhite@verisim.com when
replying. Thanks.

----- Forwarded message from Brian White -----

Message-ID: <34298977.71AB894F@verisim.com>
Date: Wed, 24 Sep 1997 17:43:19 -0400
From: Brian White <bcwhite@verisim.com>
To: Debian Bugs <submit@bugs.debian.org>
Subject: rm won't remove some files

Package: fileutils
Version: 3.16-4

I have a few files on my disk were created by filesystems problems that I
am completely unable to get rid of.

Here is what I tried to do first:

dragon:/tmp/wcsmbs# ls -l
total 3982528256
c--xrw-r-- 1 14464 35136 141, 0 Jun 17 1902 wcpcpy.o
b--sr-srwt 1 14951 14964 101, 100 Apr 10 2030 wcscat.d
br-xrws-w- 1 29791 29791 105, 116 Aug 19 2022 wcscat.o
br-sr-xr-T 1 29791 24420 116, 101 May 10 05:05 wcschr.d
br-xrw--w- 1 25710 13619 53, 51 May 5 2024 wcscmp.o
c--Srws--- 1 15160 59 49, 114 May 7 1999 wcsdup.d
dragon:/tmp/wcsmbs# rm -f *
rm: wcpcpy.o: Operation not permitted
rm: wcscat.d: Operation not permitted
rm: wcscat.o: Operation not permitted
rm: wcschr.d: Operation not permitted
rm: wcscmp.o: Operation not permitted
rm: wcsdup.d: Operation not permitted

I guess I can understand this since the inodes are garbage even though
e2fsck gives the disk a clean bill of health. So, I tried the following:

dragon:/tmp/wcsmbs# cd ..
dragon:/tmp# id
uid=0(root) gid=0(root) groups=0(root)
dragon:/tmp# ls -ld wcsmbs
drwxr-xr-x 2 root root 3072 Sep 24 17:13 wcsmbs/
dragon:/tmp# rm -d wcsmbs
rm: wcsmbs: Operation not permitted
dragon:/tmp# rm -df wcsmbs
rm: wcsmbs: Operation not permitted

According to the 'rm' man page:

-d, --directory
Remove directories with `unlink' instead of
`rmdir', and don't require a directory to be empty
before trying to unlink it. Only works for the
super-user. Because unlinking a directory causes
any files in the deleted directory to become unref­
erenced, it is wise to fsck the filesystem after
doing this.

I don't see any reason why this should fail, thus the bug report. Since
it appears I'm stuck with these files until this gets fixed, please don't
hesitate to ask if I can give any more info.

Brian
( bcwhite@verisim.com )

----- End of forwarded message from Brian White -----

----- Forwarded message from Brian White -----

Message-ID: <342C0EA2.15526426@verisim.com>
Date: Fri, 26 Sep 1997 15:36:02 -0400
From: Brian White <bcwhite@verisim.com>
To: Galen Hazelwood <galenh@micron.net>
CC: Herbert Xu <herbert@gondor.apana.org.au>, 13330@bugs.debian.org
Subject: Re: Bug#13330: rm won't remove some files

> > Seems like they are immutable files. Try chattr.
>
> Okay, I officially feel like an idiot now. *WHACK* Thank you. Why didn't
> I think of that?

No luck...

dragon:/var/tmp/badfiles/wcsmbs# ll
total 3982528256
c--xrw-r-- 1 14464 35136 141, 0 Jun 17 1902 wcpcpy.o
b--sr-srwt 1 14951 14964 101, 100 Apr 10 2030 wcscat.d
br-xrws-w- 1 29791 29791 105, 116 Aug 19 2022 wcscat.o
br-sr-xr-T 1 29791 24420 116, 101 May 10 05:05 wcschr.d
br-xrw--w- 1 25710 13619 53, 51 May 5 2024 wcscmp.o
c--Srws--- 1 15160 59 49, 114 May 7 1999 wcsdup.d
dragon:/var/tmp/badfiles/wcsmbs# chattr -i *
chattr 1.10, 24-Apr-97 for EXT2 FS 0.5b, 95/08/09
chattr: No such device while reading flags on wcpcpy.o
chattr: No such device while reading flags on wcscat.d
chattr: No such device while reading flags on wcscat.o
chattr: No such device while reading flags on wcschr.d
chattr: No such device while reading flags on wcscmp.o
chattr: No such device while reading flags on wcsdup.d

Even if it had worked, though, it doesn't fix the problem of rm not being
able to unlink a dir.

Brian
( bcwhite@verisim.com )

-------------------------------------------------------------------------------
Generated by Signify v1.02. For this and more, visit http://www.verisim.com/

----- End of forwarded message from Brian White -----

-- 
Debian GNU/Linux 1.3 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://greathan.apana.org.au/~herbert/
PGP Key: http://greathan.apana.org.au/~herbert/pubkey.txt