Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!sdd.hp.com!ucsd!ucbvax!unisoft!greywolf From: greywolf@unisoft.UUCP (The Grey Wolf) Newsgroups: comp.lang.c Subject: Re: access() Message-ID: <3345@unisoft.UUCP> Date: 5 Feb 91 23:51:10 GMT References: <14944@smoke.brl.mil> <1991Feb1.125713.14842@dce.ie> <15051@smoke.brl.mil> Reply-To: greywolf@unisoft.UUCP (The Grey Wolf) Organization: Foo Bar and Grill Lines: 27 In article <15051@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: /* * ... one is said to have access for execution when in fact an attempt to * execute cannot succeed. * * There are other problems, but that should be enough to discourage use of * access(). It is usually simpler and more reliable to simply attempt the * desired operation and see whether it succeeds. */ Sometimes, we only want to verify that a file exists, in which case it is more tended to use access() for this. We may not do anything with it -- it may be a lock file. creat() doesn't work for this; open with O_CREAT|O_EXCL set is a more expensive call, after which we might not want to do anything with the file descriptor we get back. [ I was going to argue that an access(dirpath, X_OK) is faster than chdir(dirpath);, but my argument is kind of null since, generally, if one wishes to verify that a directory is executable (searchable/ residable), one will probably be performing a chdir() to it rather soon afterwards. ] -- thought: I ain't so damb dumn! | Your brand new kernel just dump core on you war: Invalid argument | And fsck can't find root inode 2 | Don't worry -- be happy... ...!{ucbvax,acad,uunet,amdahl,pyramid}!unisoft!greywolf