How do you delete files that are seemingly missing inodes?

I have some files that appear to have no inode numbers. To complicate the matter, the filenames have UTF8 (I think) characters.

I am trying to delete them. In fact, and this might make things easier, I'm trying to delete their parent directory.

I don't know what to try next, please help.

Thanks,
Ryan

Ok here are the symptoms:
1) rm appears to have no effect. so does unlink. so does rmdir on the parent directory.

$ ls
Andre?? 3000 Feat. Kelis  Les Mise??rables  ???????????? ???  ??????????????????  ???????????????
$ rm -rf Andr�\ 3000\ Feat.\ Kelis
$ ls
Andre?? 3000 Feat. Kelis  Les Mise??rables  ???????????? ???  ??????????????????  ???????????????

2) More pushy rm options lead to more mystery:

$ rm -d Andr�\ 3000\ Feat.\ Kelis 
rm: cannot remove `Andre\314\201 3000 Feat. Kelis': No such file or directory

3) Really can't find them?! Bc they think they're there:

$ find . -print
.
find: ./: No such file or directory
find: ./Andr� 3000 Feat. Kelis: No such file or directory
find: ./: No such file or directory
find: ./ : No such file or directory
find: ./Les Mis�rables: No such file or directory

4) How come they have no inodes?

$ ls -ial
total 40
5783555 drwxr-xr-x 10 farl farl 36864 Feb  1 21:53 .
5783553 drwxr-xr-x  3 farl  121  4096 May 21  2008 ..
      ? ?---------  ? ?    ?        ?            ? Andre?? 3000 Feat. Kelis
      ? ?---------  ? ?    ?        ?            ? Les Mise??rables
      ? ?---------  ? ?    ?        ?            ? ???????????? ???
      ? ?---------  ? ?    ?        ?            ? ??????????????????
      ? ?---------  ? ?    ?        ?            ? ???????????????
$ ls -Qi
0 "Andre\314\201 3000 Feat. Kelis"
0 "Les Mise\314\201rables"
0 "\344\275\220\346\235\221\346\262\263\345\206\205 \345\256\210"
0 "\345\256\207\345\244\232\347\224\260\343\203\222\343\202\253\343\203\253"
0 "\346\227\251\347\250\262\347\224\260\345\244\247\345\255\246"

5) fsck says everything is ok

$ sudo fsck.ext3 /dev/sdb2
e2fsck 1.40-WIP (14-Nov-2006)
/dev/sdb2: clean, 60692/59834368 files, 74016803/119652120 blocks 
$ sudo fsck.ext3 -vf /dev/sdb2              
e2fsck 1.40-WIP (14-Nov-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

   60693 inodes used (0.10%)
    5639 non-contiguous inodes (9.3%)
         # of inodes with ind/dind/tind blocks: 32097/910/0
74016804 blocks used (61.86%)
       0 bad blocks
      16 large files

   59067 regular files
    1556 directories
       0 character device files
       0 block device files
       0 fifos
    6044 links
      60 symbolic links (0 fast symbolic links)
       0 sockets
--------
   66727 files

Probably you already tried it :

find . -exec /bin/rm -f {}

Yeah, same results as trying to manually rm them.

$ ls
Andre?? 3000 Feat. Kelis  Les Mise??rables  ???????????? ???  ??????????????????  ???????????????
$ find . -print -exec /bin/rm -f {} \;
.
/bin/rm: cannot remove `.' or `..'
find: ./????????????: No such file or directory
find: ./Andr? 3000 Feat. Kelis: No such file or directory
find: ./??????????: No such file or directory
find: ./???????? ??: No such file or directory
find: ./Les Mis?rables: No such file or directory
$ ls
Andre?? 3000 Feat. Kelis  Les Mise??rables  ???????????? ???  ??????????????????  ??????????????? 

I hope there is an easy answer. So far, the only thing I can think of is a bit drastic: somehow forcibly orphan the files/directory or remove their references from the directory structure and let fsck handle the aftermath---although I have no clue how to do that.

Look carefully at your man page for fsck. There should be a option like -f to force it to do a full check. Unmount the file system, rerun fsck with the force option, and see if that fixes it.

If this doesn't work, tell us the name of your OS so we don't have to guess. Solutions to stuff like this are very OS specific. It seems to be linux, but what release of which distro?

$ uname -ar
Linux maclir 2.6.18-5-ixp4xx #1 Thu Aug 30 16:47:13 UTC 2007 armv5tel GNU/Linux

This is a Linksys NSLU2 running Debian 4.0. Files in question are on an ext3 partition on an external USB drive and is not the root partition.

Perderabo: fsck -f output is in original post.

I hope you have a backup of that disk.

If your fsck is accepting directory entries like that, I must suspect a bug. So my first approach would be find a better version of fsck. Are your patches up to date? If you can find a patched version of fsck, try that.

The safest way out is a fair amount of work... Do a mkfs and reload all of the files.

There is, perhaps, a way to do what you want. I have never done it on Linux, but I have done it on HP-UX. So I am locating the similiar linux commands and guessing that they might work. Caution, I have never tried anything like this in linux.

You need to destroy that directory. A directory is actually a file and it has datablocks allocated to it. Each directory entry is a pair of items: a name and an inode number. Your directory has entries pointing to invalid inode numbers. To destroy that directory, use "ls -id /path/to/directory" to get the inode of that directory. Then destroy that inode and rerun fsck. The clri command is what I used on HP-UX and on linux, it is not a separate command, it is part of debugfs. So it goes something like:

1 find inode number of directory
2 umount /dev/sdb2
3 debugfs -w /dev/sdb2
4 at the debug prompt, clri 1234
5 at the debugfs prompt, quit
6 fsck -f /dev/sdb2

But I'm not gonna try that on my system... you first... :slight_smile: