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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc2/] [newlib/] [libc/] [sys/] [mmixware/] [access.c] - Diff between revs 207 and 520

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 520
/* access for MMIXware.
/* access for MMIXware.
 
 
   Copyright (C) 2001, 2007 Hans-Peter Nilsson
   Copyright (C) 2001, 2007 Hans-Peter Nilsson
 
 
   Permission to use, copy, modify, and distribute this software is
   Permission to use, copy, modify, and distribute this software is
   freely granted, provided that the above copyright notice, this notice
   freely granted, provided that the above copyright notice, this notice
   and the following disclaimer are preserved with no changes.
   and the following disclaimer are preserved with no changes.
 
 
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   PURPOSE.  */
   PURPOSE.  */
 
 
#include <fcntl.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <unistd.h>
#include <unistd.h>
#include "sys/syscall.h"
#include "sys/syscall.h"
#include <errno.h>
#include <errno.h>
 
 
int
int
access (const char *fn, int flags)
access (const char *fn, int flags)
{
{
  /* Ugh.  We don't have stat (), so we can't copy the other
  /* Ugh.  We don't have stat (), so we can't copy the other
     implementations.  Opening a directory as a file usually works, so
     implementations.  Opening a directory as a file usually works, so
     let's try and open it and use the openability, regardless of what
     let's try and open it and use the openability, regardless of what
     kind of test or file it is.  */
     kind of test or file it is.  */
  int fd;
  int fd;
 
 
  /* We'll just assume that if we can open the file for reading, then it's
  /* We'll just assume that if we can open the file for reading, then it's
     Z-able, no matter what Z was.  */
     Z-able, no matter what Z was.  */
  fd = _open (fn, O_RDONLY);
  fd = _open (fn, O_RDONLY);
  if (fd >= 0)
  if (fd >= 0)
    {
    {
      /* Yes, this was readable.  As in other simulator access functions,
      /* Yes, this was readable.  As in other simulator access functions,
         we always return success in this case (though the others check
         we always return success in this case (though the others check
         for directory access).  */
         for directory access).  */
      return _close (fd);
      return _close (fd);
    }
    }
 
 
  errno = EACCES;
  errno = EACCES;
  return -1;
  return -1;
}
}
 
 

powered by: WebSVN 2.1.0

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