mescc: Mes C Library: Fix access stub.

* lib/stub/access.c (access): Use _open3 to give more meaningful
behaviour.  Fixes hanging of mes.
This commit is contained in:
Jan Nieuwenhuizen 2019-03-16 16:36:00 +01:00
parent 7c6da0c213
commit f5bf3f4cf6
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -20,6 +20,8 @@
#include <mes/lib.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
int
access (char const *file_name, int how)
@ -29,5 +31,15 @@ access (char const *file_name, int how)
eputs ("access stub\n");
stub = 1;
errno = 0;
return 0;
if (how == R_OK || how == F_OK)
{
int filedes = _open3 (file_name, O_RDONLY, 0);
if (filedes >= 2)
return 0;
}
else if (how == W_OK)
return 0;
else if (how == X_OK)
return 0;
return -1;
}