Ghost file

Guy Harris guy at auspex.UUCP
Sun Nov 27 15:09:41 AEST 1988


>Who assumes "\0" is a synonym for "." ? The kernel, open(2),... ?

In SunOS (and systems that have adopted the SunOS VFS code), the routine
"lookuppn".  In 4.3BSD, the routine "namei".  Both are in the kernel (as
is "open()", which when calls ends up causing either "lookuppn" or
"namei" to be called).

>The file I created was shown by ls -l as "-rw-r----    ?",

That doesn't look like "".  That looks like a file with some
non-printable character.  "ls" in all UNIX implementations I know of
treats file names as character strings, which means it treats '\0' as an
end-of-string character, not a non-printable character; there's some
real character there, not just a '\0'.

>but file(1) said it was a directory. It was in my home directory,
>and cd "" kept me there.

Since "" is a synonym for "." in SunOS, 'cd ""' and 'cd .' do the same
thing, namely keep you in the current directory.  Similarly, 'file ""'
will, just like 'file .', tell you it's a directory. 

It sounds like ELM "defaulted" to an uninitialized string which, in this
particular case, contained a non-printable character followed by a '\0'
(assuming that the "ls -l" in question did, in fact, show only one '?';
there could, presumably, have been blanks before and/or after it).  You
then assumed it actually created a file with a null name, and tried
various operations on "".

"rm -i *" probably succeeded, and gave the impression that it removed a
file with a null name, because it actually tried removing a file with a
name like "\001", and when it printed "\001" your terminal did nothing
with the "\001".  In other words, "rm"s message was something like

	rm: remove (\001)?

which appeared as

	rm: remove ?



More information about the Comp.unix.wizards mailing list