Home » Questions » Computers [ Ask a new question ]

Is there a POSIX pathname that can't name a file?

Is there a POSIX pathname that can't name a file?

Are there any legal paths in POSIX that cannot be associated with a file, regular or irregular? That is, for which test -e "$LEGITIMATEPOSIXPATHNAME" cannot succeed?

Asked by: Guest | Views: 219
Total answers/comments: 2
Guest [Entry]

"Since the final question is whether there are special places that couldn't normally have a file, like in the /dev directory stipulated in POSIX, then the andswer is YES.

The complete list of pre-determined files and directories is given in chapter 10, POSIX Directory Structure and Devices, of the IEEE Open Group Base Specifications Issue 6:

The following directories shall exist
on conforming systems and conforming
applications shall make use of them
only as described. Strictly conforming
applications shall not assume the
ability to create files in any of
these directories, unless specified
below.

/
The root directory. /dev
Contains /dev/console, /dev/null, and /dev/tty, described below.

The following directory shall exist on
conforming systems and shall be used
as described:

/tmp
A directory made available for applications that need a place to
create temporary files. Applications
shall be allowed to create files in
this directory, but shall not assume
that such files are preserved between
invocations of the application.

The following files shall exist on
conforming systems and shall be both
readable and writable:

/dev/null
An infinite data source and data sink. Data written to /dev/null shall
be discarded. Reads from /dev/null
shall always return end-of-file
(EOF). /dev/tty
In each process, a synonym for the controlling terminal associated with
the process group of that process, if
any. It is useful for programs or
shell procedures that wish to be sure
of writing messages to or reading data
from the terminal no matter how output
has been redirected. It can also be
used for applications that demand the
name of a file for output, when typed
output is desired and it is tiresome
to find out what terminal is currently
in use.

The following file shall exist on
conforming systems and need not be
readable or writable:

/dev/console
The /dev/console file is a generic name given to the system console (see
System Console). It is usually linked
to an implementation-defined special
file. It shall provide an interface to
the system console conforming to the
requirements of the Base Definitions
volume of IEEE Std 1003.1-2001,
Chapter 11, General Terminal
Interface."
Guest [Entry]

"/dev/null/impossible cannot exist. This is because /dev/null must be a file, and so cannot be a directory.

Same for /dev/tty/impossible and /dev/console/impossible"