home *** CD-ROM | disk | FTP | other *** search
- static char sccs_id[] = "@(#) access.c 1.2 " __DATE__ " HJR";
-
- /* access.c (c) Copyright 1990 H.Rogers */
-
- #include <errno.h>
-
- #include "sys/types.h"
- #include "sys/unix.h"
- #include "sys/os.h"
-
- int
- access (char *file, register int mode)
- {
- int r[6];
- os_error *e;
- int i;
-
- file = __uname (file, 0);
-
- if (e = os_file (0x05, file, r))
- {
- __seterr (e);
- return (-1);
- }
- if (!r[0])
- {
- errno = ENOENT;
- return (-1);
- }
-
- i = ((r[5] & 0040) >> 4) | ((r[5] & 0020) >> 2) |
- ((r[5] & 0002)) | ((r[5] & 0001) << 2);
-
- if (i & 0002)
- i |= 0001;
-
- if ((i & mode) != mode)
- {
- errno = EPERM;
- return (-1);
- }
-
- return (0);
- }
-