Confused file name in directory

simon at its63b.UUCP simon at its63b.UUCP
Fri Feb 27 23:36:44 AEST 1987


In article <5587 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>In article <105 at aob.UUCP> someone finds a directory entry with an
>embedded NUL, and has nothing handy to fix it.
>
>There is still another way, easier yet but more dangerous and
>thrilling.  You cannot edit a directory, but you can edit a file.
>And the only difference between the two is one byte.
>
>Write another program, `hacki'.
>Instead of zeroing the inode, toggle the S_IFDIR and S_IFREG bits.
>Run it once on the directory inode, and now it is a file.  Use your
>favourite binary editor (Emacs works, but be sure it does not make
>a backup!), fix the embedded NUL character.  Make sure the file size
>is exactly the same as before.  Then run the hacki program once
>more.
>
>Of course, if you have source, you could alter fsck to check for
>embedded NULs in filenames.

Another "entity" you can edit is a disk - using a nice powerful editor
like adb :-) So, just find the i-number for the directory, then: power-up
your adb, find the inode-entry for the directory, from which you can find the
data-block list (luckily there're hardly ever any indirect blocks in a 
directory, unless its very big), find the bad bytes, and change them to 
something sensible.

Why write new code when you do anything you need using existing utilities :-)

-- 

-----------------------------
Simon Brown                                             @@@\
Department of Computer Science                         /-/@ \
University of Edinburgh, Scotland, UK.                / /@   \@@
                                                     / /@     \-\
UUCP:  seismo!mcvax!ukc!{its63b,cstvax}!simon       / /@/-/    \ \
JANET: simon at uk.ac.ed.{its63b,cstvax}              / /@/ / /-/  \ \
ARPA:  simon@{its63b,cstvax}.ed.ac.uk             /-/@/-/ /-/    \ \
------------------------------                   ~~~~~~~~~~~~~~~~~~~~
                                             "Life's like that, you know"



More information about the Comp.unix.xenix mailing list