Xref: utzoo comp.unix.questions:6586 comp.unix.wizards:7812 comp.lang.c:9391 Newsgroups: comp.unix.questions,comp.unix.wizards,comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Writing to A NON-Existing File in "C" Message-ID: <1988Apr16.224643.15804@utzoo.uucp> Keywords: C program, NON-EXISTING File, flushed results Organization: U of Toronto Zoology References: <9654@jplgodo.UUCP> <10285@steinmetz.steinmetz.ge.com>, <147@obie.UUCP> Date: Sat, 16 Apr 88 22:46:43 GMT > I'd do it slightly different. Unless you need speed, try using > access(2) to determine if the file is available to you... --------------------------> NO!!! <----------------------- You should never use access(2) except when a setuid program wants to determine whether a file would be accessible in the absence of setuid privileges. For determining accessibility in normal circumstances, use stat(2) and look at the mode bits. (There was an eaccess() function posted to one of the sources groups a few years ago that would do this for you.) If your program happens to be run under setuid conditions, and it is using access(2) for ordinary availability checking, it will get the wrong answers. -- "Noalias must go. This is | Henry Spencer @ U of Toronto Zoology non-negotiable." --DMR | {ihnp4,decvax,uunet!mnetor}!utzoo!henry