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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [sys/] [mmixware/] [access.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
/* access for MMIXware.
2
 
3
   Copyright (C) 2001 Hans-Peter Nilsson
4
 
5
   Permission to use, copy, modify, and distribute this software is
6
   freely granted, provided that the above copyright notice, this notice
7
   and the following disclaimer are preserved with no changes.
8
 
9
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
10
   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
12
   PURPOSE.  */
13
 
14
#include <fcntl.h>
15
#include <sys/stat.h>
16
#include <unistd.h>
17
#include "sys/syscall.h"
18
#include <errno.h>
19
 
20
int
21
access (const char *fn, int flags)
22
{
23
  /* Ugh.  We don't have stat (), so we can't copy the other
24
     implementations.  Opening a directory as a file usually works, so
25
     let's try and open it and use the openability, regardless of what
26
     kind of test or file it is.  */
27
  long ret;
28
 
29
  /* We'll just assume that if we can open the file for reading, then it's
30
     Z-able, no matter what Z was.  */
31
  ret = TRAP3f (SYS_Fopen, TMPFNO, fn, BinaryRead);
32
  if (ret == 0)
33
    {
34
      /* Yes, this was readable.  As in other simulator access functions,
35
         we always return success in this case (though the others check
36
         for directory access).  */
37
      TRAP1f (SYS_Fclose, TMPFNO);
38
      return 0;
39
    }
40
 
41
  errno = EACCES;
42
  return -1;
43
}

powered by: WebSVN 2.1.0

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