Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site kovacs.UUCP Path: utzoo!linus!decvax!decwrl!greipa!pesnta!hplabs!sdcrdcf!randvax!kovacs!day From: day@kovacs.UUCP (Dave Yost) Newsgroups: net.unix-wizards Subject: Maybe there should be a new flag to open(2) Message-ID: <265@kovacs.UUCP> Date: Sun, 13-Oct-85 23:04:06 EDT Article-I.D.: kovacs.265 Posted: Sun Oct 13 23:04:06 1985 Date-Received: Thu, 17-Oct-85 20:54:33 EDT Organization: Robt Abel & Assoc, Hollywood Lines: 29 Say a program wants to open a file and read it. Say this `file' is really a directory. The program reads it, finds the file contains what it considers garbage, and tells the hapless user that the file doesn't make sense. A more useful error message would tell the user that the object was a directory, not a file. Now what is a program to do? Always do an fstat on a file and see what it is whenever it finds nonsense? Ha! What if: If the O_FILE_TYPE flag to open(2) is set, the next argument is a bitmask of the allowed file types that the file may be. If it is not one of these types, the open will fail. The bits in the bitmask are numbered starting with the least significant as 0, each bit corresponding to a value in the S_IFMT field of the st_mode word (taken as if it were declared as a bit field). Programs could easily be upgraded to insist on files when they want files, opendir(3) could insist that what it is opening is a directory, etc. --dave yost