Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!samsung!munnari.oz.au!metro!cluster!tmx!brahman!melb.bull.oz.au!sun0!sjg From: sjg@sun0.melb.bull.oz.au (Simon J. Gerraty) Newsgroups: comp.unix.questions Subject: unlink(inode)? or how to remove file with '/' in its name Message-ID: <1990Oct18.030832.10894@melb.bull.oz.au> Date: 18 Oct 90 03:08:32 GMT Sender: news@melb.bull.oz.au (USENET News Account) Organization: Bull HN Information Systems Australia Lines: 40 We have an interesting situation here. While investigating the practicalities of using an Appletalk-NFS gateway (Gatorbox I think but please don't quote me), one of our users created a file on one of our Sun's with a '/' in the name. Unfortunately he forgot to remove the file before returning the gateway. Having exhausted all the normal solutions for removing files with "funny" chars in their names, I was asked to have a look. Again after quickly trying the above solutions myself, I went and had a look in the manuals. It only took five minutes to write a short C programme to print inode/name pairs from a directory. ls(1) etc weren't any use at all, though echo '*' would at least show the name. Ok, I know the inode, all I have to do is get rid of it. How? While there are system/library calls to read directory entries, there appears no way of _writing_ them, not even for root? So a simple directory sanitiser is out of the question. It gets worse though as there appear to be no system/library calls available to unlink or otherwise operate on an inode. All the commands, and system/library calls appear to deal with pathnames only and naturally vomit when asked to deal with a fictitious path (since the filename has a '/' in it :-) So, have I missed something, or do I have to resort to editing the raw disk file? I would also be interested to here how NFS created the stupid file in the first place. Perhaps I can write an programme to ask NFS to remove it? By the way all of the above applies to SunOS 4.0.3 -- Simon J. Gerraty #include /* imagine something *very* witty here */