deleting a bad directory
scw at UCLA-LOCUS.ARPA
scw at UCLA-LOCUS.ARPA
Fri May 11 06:29:00 AEST 1984
From: Steve Woods <cepu!scw at UCLA-LOCUS.ARPA>
>I took over this host in March and have been trying to get rid of a bad
>directory which was created in November. The directory cat/file string
>is '/u17/lost+found/#005628'. I position myself at the directory
>'lost+found' and then enter "rm -rf *562*" just encase there are any
>unprintable characters. The response is 'rmdir: Cannot remove "#005628".
>No such file or directory.' Do you have any suggestions on how to clean
>this out. Thanks:
>Herb Overstreet (DCA-EUR Administrator)
Try the following:
(1) od -c . >foo.c
(2) edit foo.c, find the line with the correct entry
conviently (under v7 anyway) each directory in the directory
takes exactly one line in the od -c output. delete all other lines:
delete the first 3 fields (offset and the inode number),
delete spaces between characters (there are 3 between valid letters,
and 1 between letters that are < ' ' or > 0176 and not in the standard
[\f, \r, \b, \n, \0] set of escapable and 2 between escapable characters.
much like below:
{typical od -c of a V7 directory}
offset |inode #| file name--------------------------------------------
0000000 002 \0 . \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000020 002 \0 . . \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000040 253 \0 u u r u n \0 \0 \0 \0 \0 \0 \0 \0 \0
.
.
.
0001020 377 004 # 0 0 5 6 2 8 177 \0 \0 \0 \0 \0 \0
.
.
.
Turn the line of interest into a quoted string.
"#005628\177\0\0\0\0\0\0"
Then build a c program around the string:
#include <stdio.h>
char *oldname="#005628\177\0\0\0\0\0\0";
main()
{
if(link(oldname,"foobar") != -1)unlink(oldname);
else printf("link failed\n");
}
(3) Compile and execute foo.c (cc foo.c;a.out;)
(4) the old garbage name has been replaced with foobar. The file may then
delt with as desired.
NOTES: if the old file is a directory you must be the SUPERUSER to link to it.
You MUST have Write permission on the target directory (to create the
link and to unlink the old file).
--------------------------------------------------------------------------------
<cepu!scw at ucla-locus>
More information about the Comp.unix.wizards
mailing list