19.10 access (6746)

This procedure is called by “exec” (3041), “chdir” (3552), “core” (4109), “openl” (5815, 5817), “namei” (7563, 7664, 7658) to check access permission to a file. The second parameter, “mode”, is equal to one of “IEXEC”, “IWRITE” and “IREAD”, with octal values of 0100, 0200 and 0400 respectively.

6753:

“write” permission is denied if the file is on a file system volume which has been mounted as “read only” or if the file is functioning as the text segment for an executing program;

6763:

the suer-user may not execute a file unless it is “executable” in at least one of the three “permission” groups. In any other situation he is always allowed access;

6769:

If the user is not the owner of the file, shift “m” three places to the right so that group permissions will be operative ... If the groups don’t match, shift “m” again;

6774:

Compare “m” and the access permissions.

Note that there is an anomaly here in that if a file has a “mode” of 0077, the owner cannot reference it at all, but everyone else can. This situation could be changed satisfactorily by inserting a statement

   m =|  (m |  (m >> 3)) >> 3;

after line 6752, and replacing lines 6764, 6765 by

   if (m & IEXEC && (m & ip->i_mode) == 0)