4.104.114.84.95
Line | |
---|
1 | /* |
---|
2 | * access() - POSIX 1003.1b 5.6.3 - File Accessibility |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-1999. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.OARcorp.com/rtems/license.html. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #include <unistd.h> |
---|
15 | #include <fcntl.h> |
---|
16 | #include <sys/stat.h> |
---|
17 | |
---|
18 | int access( |
---|
19 | const char *path, |
---|
20 | int amode |
---|
21 | ) |
---|
22 | { |
---|
23 | struct stat statbuf; |
---|
24 | |
---|
25 | if ( stat(path, &statbuf) ) |
---|
26 | return -1; |
---|
27 | |
---|
28 | if ( amode & R_OK ) { |
---|
29 | if (!( statbuf.st_mode & S_IREAD )) |
---|
30 | return -1; |
---|
31 | } |
---|
32 | |
---|
33 | if ( amode & W_OK ) { |
---|
34 | if ( !( statbuf.st_mode & S_IWRITE ) ) |
---|
35 | return -1; |
---|
36 | } |
---|
37 | |
---|
38 | if ( amode & X_OK ) { |
---|
39 | if ( !( statbuf.st_mode & S_IEXEC ) ) |
---|
40 | return -1; |
---|
41 | } |
---|
42 | |
---|
43 | return 0; |
---|
44 | } |
---|
45 | |
---|
Note: See
TracBrowser
for help on using the repository browser.