home *** CD-ROM | disk | FTP | other *** search
- Submitted-by: brnstnd@KRAMDEN.ACF.NYU.EDU (Dan Bernstein)
-
- Let me quickly mention an alternative to super-open(): namely, pdopen(),
- which is called as (e.g.) pdopen("openin","foo",O_RDONLY) and returns a
- file descriptor for reading from foo. Internally pdopen() executes
- execlp("openin","openin","foo","pdopenr",(char *) 0). openin opens foo
- for reading as fd 0 and then runs pdopenr, which gives a descriptor back
- to the original process through fd passing. One feature of pdopen() is
- that users can customize it easily: right now I can call
-
- pdopen("ftpread","wuarchive.wustl.edu:usenet/alt.sources/articles/4655",0)
-
- and get a descriptor which reads from that file on wuarchive. Utilities
- can use the syntax <&openin:foo. Voila: Uniform access to network files
- and local files. No system changes required---the code for everything I
- mentioned above already works on BSD, and I suppose that if I spend a
- little more time on it, I could have pdopenr shuttle data through pipes
- so that it doesn't need fd passing.
-
- Why am I bringing up this invention on comp.std.unix? Because I'm trying
- to make clear that it's just an *invention*, just like a version of
- open() with the same features would be. There are many possible
- solutions to the problem of accessing network files. super-open() would
- have the advantage of working with programs which used open(). pdopen()
- has the advantage of letting the user customize it easily. Neither is
- appropriate for standardization, because no industry consensus exists.
-
- Peter writes:
- > I think Dan has a couple of basic problems in his argument here: first,
- > looking at extensions to the file system as extensions to "open"; and
- > second, missing the huge amount of code that comprises the "normal" UNIX
- > environment that depends on a uniform name space.
-
- I would like to correct three parts of Peter's summaries of my position.
- First of all, Peter keeps bringing up syscalls other than open() which
- manipulate filenames and which cannot be written in terms of file
- descriptors. For example, creat(), link(), chmod(), and unlink() are
- nonsensical without the concept of a filesystem. Peter then claims that
- if there are mechanisms other than open() for creating file descriptors,
- then the functions of creat(), link(), chmod(), and unlink() must all be
- duplicated for those other mechanisms. But this is clearly nonsense: v7
- had pipes, and didn't implement chmod() for pipes, and nobody has yet
- complained at this omission. BSD had TCP/IP sockets, and didn't
- implement chmod() for sockets, and nobody's complained about that
- either. The protection mechanisms for the filesystem make sense for the
- filesystem and *not* for network connections. So there is *no* need for
- a version of chmod() (or any other filesystem-specific syscall) which
- applies to network connections. BSD has a different, and much more
- appropriate, protection mechanism for sockets; I'm glad that CSRG took
- the time to work out good semantics for bind() rather than blindly
- applying chmod() to some bastard network-filesystem creation.
-
- Second, Peter says that I'm arguing against any form of uniform
- namespace. Not at all. What I'm arguing against is the ``expectation''
- of many POSIX members that POSIX will ``standardize'' an open() which
- does something which has not won the market. If open() had worked for
- network connections from the beginning, I wouldn't be complaining about
- this issue in comp.std.unix.
-
- Finally, Peter states
-
- > Another problem with Dan's suggestions is that they reduce the name space
- > available for normal files: a name space that's already hurt by the UNIX
- > option syntax. If you start defining "3" to mean file descriptor 3,
-
- but what I meant by this was that file descriptor numbers be used
- *instead* of filenames, with the shell responsible for making this
- transparent to the user. A utility which has already been mis-designed
- to use filenames can stick to /dev/fd/3, which as I said before is a
- rather good kludge to make such utilities behave.
-
- ---Dan
-
-
- Volume-Number: Volume 26, Number 79
-
-