Help! There's a slash '/' in my filename.

Donald L. Nash D.Nash at utexas.edu
Sat Feb 2 11:31:59 AEST 1991


In article <11714 at helios.TAMU.EDU> you write:
>  shouldn't something like:  rm "slash/file"
>  work OK?

This won't work.  The / is not interpreted by the shell, but by the
kernel routine namei(), which translates file names into inode numbers. 
The interpretation of the / character is wired into namei()'s brain. 
Any solution which involves using the unlink() system call to remove the
file will fail because namei() will gag on that /.  I've never had to
deal with this problem before, but I seem to remember hearing a
solution.  Please wizards, don't flame me if I'm wrong, I'm only a
wizard in training.  Just politely point out my mistake and we'll all be
happy.  Anyway, if you "ls -i" in the directory containing this bogon
file, you'll get the inode number for it.  You can then use the clri
command to zap this inode.  This will leave all the links which pointed
to this inode hanging loose, including the bogon link.  It will also
leave all the blocks associated with the file "missing," i.e. they won't
be on the free list and the won't be allocated to files.  After you run
clri, unmount the filesystem and run fsck on it to repair the damage. 
This should get rid of all the hanging links and place the lost blocks
on the free list.  BTW, you'd better do this in single-user mode so no
one will have open files on the filesystem when you try to dismount it,
otherwise you won't be able to dismount it.  Be sure to read the man
pages for clri and fsck before you do any of this.

				Donald L. Nash

				The University of Texas System
				Office of Telecommunication Services

Internet:  D.Nash at utexas.edu
THEnet:    THENIC::DON
BITNET:    DON at THENIC
PSI Mail:  311051200131::DON



More information about the Comp.unix.wizards mailing list