sch (01/19/83)
This is an attempt to clarify the confusion over how 4.2BSD and System 3,5 handle open with three args. The "usual" open call with two args: open(filename,oflag) works like it always did. The key is the oflag value. In Unix versions 6 and 7 (4.1BSD), the oflag can be 0 (Read only), 1 (Write only) and 2 (Read/Write). In the newer systems this is extended to include other bits which can be or'ed into the oflag. Some of these new oflags require a third arg which is the mode of the file (if it is to be created). Some of the new oflags in System 3 are: Definition Value Meaning ---------- ----- ------- O_NDELAY 00004 Non blocking Open O_APPEND 00010 Writes guaranteed to append to end O_CREAT 00400 Create if does not exist (uses third arg) O_TRUNC 01000 Truncate file if exists O_EXCL 02000 "Exclusive open" O_EXCL is the confusing one, it does not mean exclusive use, but rather is same as the existing creat(2): if the file exists, the open will fail. Personnally, I think the ideas presented are useful (like append), but the mechanism of open() and fcntl() is awkward and somewhat confusing. It introduces too many flags and modes making things hard to explain, and difficult to use.