2002-03-12 Richard Earnshaw <rearnsha@arm.com>
* libc/sys/arm/access.c: New file. * libc/sys/arm/Makefile.am (lib_a_SOURCES): Add access.c. * libc/sys/arm/Makefile.in: Regenerate. * libc/sys/arm/syscalls.c (_stat): New function.
This commit is contained in:
parent
cb4589f49d
commit
d2a246ad72
|
@ -1,3 +1,10 @@
|
|||
2002-03-12 Richard Earnshaw <rearnsha@arm.com>
|
||||
|
||||
* libc/sys/arm/access.c: New file.
|
||||
* libc/sys/arm/Makefile.am (lib_a_SOURCES): Add access.c.
|
||||
* libc/sys/arm/Makefile.in: Regenerate.
|
||||
* libc/sys/arm/syscalls.c (_stat): New function.
|
||||
|
||||
2002-03-11 Michael Meissner <meissner@redhat.com>
|
||||
|
||||
* libc/machine/mips/Makefile.am (lib_a_SOURCES): Add Mips specific
|
||||
|
|
|
@ -6,7 +6,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
|||
|
||||
noinst_LIBRARIES = lib.a
|
||||
|
||||
lib_a_SOURCES = syscalls.c libcfunc.c trap.S setjmp.S
|
||||
lib_a_SOURCES = access.c syscalls.c libcfunc.c trap.S setjmp.S
|
||||
|
||||
all: crt0.o
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
|||
|
||||
noinst_LIBRARIES = lib.a
|
||||
|
||||
lib_a_SOURCES = syscalls.c libcfunc.c trap.S setjmp.S
|
||||
lib_a_SOURCES = access.c syscalls.c libcfunc.c trap.S setjmp.S
|
||||
|
||||
ACLOCAL_AMFLAGS = -I ../../..
|
||||
CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
|
||||
|
@ -98,7 +98,7 @@ DEFS = @DEFS@ -I. -I$(srcdir)
|
|||
CPPFLAGS = @CPPFLAGS@
|
||||
LIBS = @LIBS@
|
||||
lib_a_LIBADD =
|
||||
lib_a_OBJECTS = syscalls.o libcfunc.o trap.o setjmp.o
|
||||
lib_a_OBJECTS = access.o syscalls.o libcfunc.o trap.o setjmp.o
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/* This is file ACCESS.C */
|
||||
/*
|
||||
* Copyright (C) 1993 DJ Delorie
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms is permitted
|
||||
* provided that the above copyright notice and following paragraph are
|
||||
* duplicated in all such forms.
|
||||
*
|
||||
* This file is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int access(const char *fn, int flags)
|
||||
{
|
||||
struct stat s;
|
||||
if (stat(fn, &s))
|
||||
return -1;
|
||||
if (s.st_mode & S_IFDIR)
|
||||
return 0;
|
||||
if (flags & W_OK)
|
||||
{
|
||||
if (s.st_mode & S_IWRITE)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ int _gettimeofday _PARAMS ((struct timeval *, struct timezone *));
|
|||
void _raise _PARAMS ((void));
|
||||
int _unlink _PARAMS ((void));
|
||||
int _link _PARAMS ((void));
|
||||
int _stat _PARAMS ((const char *, struct stat *));
|
||||
int _fstat _PARAMS ((int, struct stat *));
|
||||
caddr_t _sbrk _PARAMS ((int));
|
||||
int _getpid _PARAMS ((int));
|
||||
|
@ -515,6 +516,22 @@ _fstat (int file, struct stat * st)
|
|||
file = file;
|
||||
}
|
||||
|
||||
int _stat (const char *fname, struct stat *st)
|
||||
{
|
||||
int file;
|
||||
|
||||
/* The best we can do is try to open the file readonly. If it exists,
|
||||
then we can guess a few things about it. */
|
||||
if ((file = _open (fname, O_RDONLY)) < 0)
|
||||
return -1;
|
||||
|
||||
memset (st, 0, sizeof (* st));
|
||||
st->st_mode = S_IFREG | S_IREAD;
|
||||
st->st_blksize = 1024;
|
||||
_swiclose (file); /* Not interested in the error. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_link (void)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue