[net.unix] access

ado@elsie.UUCP (Arthur David Olson) (01/03/86)

Housekeeping at the New Year brought this to my attention--the result of a
    ls -lu /usr/spool/uucppublic/.hushlogin
command on our 4.1bsd VAX 11/750:
    -rw-r--r-- 1 uucp          0 Mar  6  1984 /usr/spool/uucppublic/.hushlogin

"What?" I asked myself, knowing that "/bin/login" must deal with the above file
several hundred times a day.  As indeed it does, thusly (as usual, the trade
secret status of the code involved precludes a clearer posting):
	...
	char	qlog[]  =	".hushlogin";
	...
	quietlog = FALSE;
	if (access(qlog, 0) == 0)
		quietlog = TRUE;
	...

Now granted, doing an "stat" call on a file ought not change the access time
of the file (so that doing a "ls" of a directory doesn't make it look as if
you've peeked at every file in the directory).  However...shouldn't an "access"
call on a file change the "last access" time for the file?  Does it do so on
systems other than 4.1bsd?
--
UNIX is an AT&T Bell Laboratories trademark.
--
	UUCP: ..decvax!seismo!elsie!ado    ARPA: elsie!ado@seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks

avolio@decuac.UUCP (Frederick M. Avolio) (01/03/86)

In article <6002@elsie.UUCP>, ado@elsie.UUCP (Arthur David Olson) writes:
>     ls -lu /usr/spool/uucppublic/.hushlogin
>     -rw-r--r-- 1 uucp          0 Mar  6  1984 /usr/spool/uucppublic/.hushlogin
> Now granted, doing an "stat" call on a file ought not change the access
> time of the file ...  However...shouldn't an "access" change the "last
> access" time for the file?

Access(2) is used to "determine the accessibility of a file" (from the
Ultrix-32 manual).  So, like stat(2) et al. it does not open the file, but
reads the inode information and, in the case of access(2), lets the user
know if the file is accessible in the mode requested.  It does not
try to access the file.
-- 
Fred @ DEC Ultrix Applications Center    {decvax,seismo,cbosgd}!decuac!avolio

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (01/03/86)

> However...shouldn't an "access"
> call on a file change the "last access" time for the file?

I don't see why it should; you're not accessing the file contents.

ken@rochester.UUCP (Ipse dixit) (01/03/86)

Access(2) merely checks the path from / for accessibility and the file
for appropriate permissions (= stat).

st_atime is the time the file was last read or modified (from the man
page).

	Ken
-- 
UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken@rochester.arpa
USnail:	Dept. of Comp. Sci., U. of Rochester, NY 14627. Voice: Ken!