Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!bellcore!faline!scherzo!allegra!mit-eddie!husc6!seismo!mcvax!ukc!its63b!simon From: simon@its63b.UUCP Newsgroups: comp.unix.questions,comp.unix.wizards,comp.unix.xenix Subject: Re: Confused file name in directory Message-ID: <285@its63b.ed.ac.uk> Date: Fri, 27-Feb-87 08:36:44 EST Article-I.D.: its63b.285 Posted: Fri Feb 27 08:36:44 1987 Date-Received: Sat, 7-Mar-87 00:15:43 EST References: <105@aob.UUCP> <563@aw.sei.cmu.edu.sei.cmu.edu> <5587@mimsy.UUCP> Reply-To: simon@its63b.ed.ac.uk (ECSC68 S Brown CS) Organization: I.T. School, Univ. of Edinburgh, U.K. Lines: 40 Xref: utgpu comp.unix.questions:1269 comp.unix.wizards:1220 comp.unix.xenix:144 In article <5587@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >In article <105@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@uk.ac.ed.{its63b,cstvax} / /@/ / /-/ \ \ ARPA: simon@{its63b,cstvax}.ed.ac.uk /-/@/-/ /-/ \ \ ------------------------------ ~~~~~~~~~~~~~~~~~~~~ "Life's like that, you know"