[net.unix-wizards] Maybe there should be a new flag to open

day@kovacs.UUCP (Dave Yost) (10/14/85)

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

guy@sun.uucp (Guy Harris) (10/17/85)

> 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.

Easily?  Do tell.  There are tons of programs out there that use "open".
Care to go change them all?

They could just as easily be changed to do an "fstat" and check the file
type.  Alternatively, you could add a library routine to do the checking.
There is certainly no need to add more features to the raw system call.

	Guy Harris

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (10/19/85)

More importantly, the kernel cannot reasonably perform
all the validity checking on files that applications
might require, so each such application needs to do this
anyway.

If I found out that some system utility program refused
to work on ptys or other non-ordinary files for no good
reason other than attempting to "protect" the naive user,
I would be quite upset and would probably rip out the
silly restriction.

boyd@basser.oz (Boyd Roberts) (10/19/85)

It really must be head-through-the-terminal time.  Features, you want
features!  I want coherence, clean design and clarity of implementation.
I just can't believe the attitude of "I need this dubious feature because
I couldn't code up a solution without it".

But, anyway, if you want this crap, why not write it in user-mode.  That's
why we use C.  That's why we have functions.  You can poison your own domain,
but leave the rest of the place free from such pestilence.

When I see news items containing such puerile and infantile suggestions,
my first reaction is to put an axe through my terminal, find another one,
``su'' and ``rm -fr /usr/spool/news''.

I guess you could say I feel strongly about this.


Boyd Roberts		...!seismo!munnari!basser.oz!boyd