X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Funistd.c;h=145de5192eb07e34b7893c457b926ee8508b1383;hb=ef7a4c06206976de7ef2e974267407347ddb75a4;hp=5652329e13ff78abe8ca97b54789c5ded2522e7e;hpb=0900c61969ca862b0bcc967b4413e539acf07dbb;p=mono.git diff --git a/support/unistd.c b/support/unistd.c index 5652329e13f..145de5192eb 100644 --- a/support/unistd.c +++ b/support/unistd.c @@ -7,6 +7,8 @@ * Copyright (C) 2004-2006 Jonathan Pryor */ +#include + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif /* ndef _GNU_SOURCE */ @@ -19,8 +21,8 @@ #include #include /* for swab(3) on Mac OS X */ +#include "mph.h" /* Don't remove or move after map.h! Works around issues with Android SDK unified headers */ #include "map.h" -#include "mph.h" G_BEGIN_DECLS @@ -136,16 +138,29 @@ Mono_Posix_Syscall_ttyname_r (int fd, char *buf, mph_size_t len) } #endif /* ndef HAVE_TTYNAME_R */ -gint32 -Mono_Posix_Syscall_readlink (const char *path, char *buf, mph_size_t len) +gint64 +Mono_Posix_Syscall_readlink (const char *path, unsigned char *buf, mph_size_t len) { - int r; + gint64 r; + mph_return_if_size_t_overflow (len); + r = readlink (path, (char*) buf, (size_t) len); + if (r >= 0 && r < len) + buf [r] = '\0'; + return r; +} + +#ifdef HAVE_READLINKAT +gint64 +Mono_Posix_Syscall_readlinkat (int dirfd, const char *path, unsigned char *buf, mph_size_t len) +{ + gint64 r; mph_return_if_size_t_overflow (len); - r = readlink (path, buf, (size_t) len); + r = readlinkat (dirfd, path, (char*) buf, (size_t) len); if (r >= 0 && r < len) buf [r] = '\0'; return r; } +#endif /* def HAVE_READLINKAT */ #if HAVE_GETLOGIN_R gint32 @@ -215,7 +230,7 @@ Mono_Posix_Syscall_setdomainname (const char *name, mph_size_t len) /* Android implements truncate, but doesn't declare it. * Result is a warning during compilation, so skip it. */ -#ifndef PLATFORM_ANDROID +#ifndef HOST_ANDROID gint32 Mono_Posix_Syscall_truncate (const char *path, mph_off_t length) {