OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems/] [c/] [src/] [lib/] [libc/] [access.c] - Blame information for rev 1767

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 158 chris
/*
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 208 chris
 *  $Id: access.c,v 1.2 2001-09-27 12:01:15 chris Exp $
12 158 chris
 */
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
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.