fixed more binutils issues (newer gcc/libc)
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / sys / sysnecv850 / access.c
blob8e08b3a7f0a2eb9aaf5643f242e63e816f299e77
1 /* This is file ACCESS.C */
2 /*
3 * Copyright (C) 1993 DJ Delorie
4 * All rights reserved.
6 * Redistribution and use in source and binary forms is permitted
7 * provided that the above copyright notice and following paragraph are
8 * duplicated in all such forms.
10 * This file is distributed WITHOUT ANY WARRANTY; without even the implied
11 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 #include <fcntl.h>
15 #include <sys/stat.h>
16 #include <unistd.h>
18 int access(const char *fn, int flags)
20 struct stat s;
21 if (stat(fn, &s))
22 return -1;
23 if (s.st_mode & S_IFDIR)
24 return 0;
25 if (flags & W_OK)
27 if (s.st_mode & S_IWRITE)
28 return 0;
29 return -1;
31 return 0;