Path: utzoo!mnetor!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!mailrus!nrl-cmf!ames!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!hpcupt1!hpisod2!decot From: decot@hpisod2.HP.COM (Dave Decot) Newsgroups: comp.unix.wizards Subject: Re: Writing to A NON-Existing File in "C" Message-ID: <14020030@hpisod2.HP.COM> Date: 19 Apr 88 03:27:24 GMT References: <9654@jplgodo.UUCP> Organization: Hewlett Packard, Cupertino Lines: 23 > > I'd do it slightly different. Unless you need speed, try using > > access(2) to determine if the file is available to you, and if not > > open /dev/null for writing: > > > > [little C fragment to do the above] > > AAAAAAAAAARGH! Please do not use access(2) as a handy-dandy > "does the file exist?" function. It is designed to be used > by set-{user,group}-id programs to see if the underlying user > has permission to access the file in the requested manner. Uh...I think a file's existence is independent of your user-id. It's perfectly acceptable to use access(2) the F_OK (0) value of amode it to determine whether files exist. Such calls succeed exactly when calls to stat(2) succeed. access(2) should not be used to determine the other access permissions except in setuid programs, and even then, not for testing execute access by setuid-root programs. Dave Decot hpda!decot