* Use futimens that is POSIX-compliant and compatible with uclibc instead of futimes.

* Borrowed eventfd_read and eventfd_write from bionic for uclibc compatibility (uclibc headers are broken unfortunately). Bionic and
FreeRDP are both under the Apache 2.0 license.
This commit is contained in:
Rene Rheaume 2014-08-06 22:06:01 -04:00
parent 362c992f33
commit 5f9c36da5d
5 changed files with 42 additions and 3 deletions

View File

@ -433,7 +433,11 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
int status; int status;
char* fullpath; char* fullpath;
struct STAT st; struct STAT st;
#if defined(ANDROID)
struct timeval tv[2]; struct timeval tv[2];
#else
struct timespec tv[2];
#endif
UINT64 LastWriteTime; UINT64 LastWriteTime;
UINT32 FileAttributes; UINT32 FileAttributes;
UINT32 FileNameLength; UINT32 FileNameLength;
@ -454,15 +458,17 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
return FALSE; return FALSE;
tv[0].tv_sec = st.st_atime; tv[0].tv_sec = st.st_atime;
tv[0].tv_usec = 0;
tv[1].tv_sec = (LastWriteTime > 0 ? FILE_TIME_RDP_TO_SYSTEM(LastWriteTime) : st.st_mtime); tv[1].tv_sec = (LastWriteTime > 0 ? FILE_TIME_RDP_TO_SYSTEM(LastWriteTime) : st.st_mtime);
tv[1].tv_usec = 0;
#ifndef WIN32 #ifndef WIN32
/* TODO on win32 */ /* TODO on win32 */
#ifdef ANDROID #ifdef ANDROID
tv[0].tv_usec = 0;
tv[1].tv_usec = 0;
utimes(file->fullpath, tv); utimes(file->fullpath, tv);
#else #else
futimes(file->fd, tv); tv[0].tv_nsec = 0;
tv[1].tv_nsec = 0;
futimens(file->fd, tv);
#endif #endif
if (FileAttributes > 0) if (FileAttributes > 0)

View File

@ -1495,5 +1495,16 @@ BOOL CommCloseHandle(HANDLE handle)
return TRUE; return TRUE;
} }
#ifdef __UCLIBC__
int eventfd_read(int fd, eventfd_t* value)
{
return (read(fd, value, sizeof(*value)) == sizeof(*value)) ? 0 : -1;
}
int eventfd_write(int fd, eventfd_t value)
{
return (write(fd, &value, sizeof(value)) == sizeof(value)) ? 0 : -1;
}
#endif
#endif /* __linux__ */ #endif /* __linux__ */

View File

@ -92,6 +92,11 @@ void CommLog_Print(int wlog_level, char *fmt, ...);
BOOL CommIsHandled(HANDLE handle); BOOL CommIsHandled(HANDLE handle);
BOOL CommCloseHandle(HANDLE handle); BOOL CommCloseHandle(HANDLE handle);
#ifdef __UCLIBC__
int eventfd_read(int fd, eventfd_t* value);
int eventfd_write(int fd, eventfd_t value);
#endif
#endif /* __linux__ */ #endif /* __linux__ */
#endif /* WINPR_COMM_PRIVATE_H */ #endif /* WINPR_COMM_PRIVATE_H */

View File

@ -30,6 +30,9 @@
#include <unistd.h> #include <unistd.h>
#include "comm_serial_sys.h" #include "comm_serial_sys.h"
#ifdef __UCLIBC__
#include "comm.h"
#endif
#include <winpr/crt.h> #include <winpr/crt.h>
#include <winpr/wlog.h> #include <winpr/wlog.h>

View File

@ -121,6 +121,20 @@ HANDLE OpenEventA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName)
return NULL; return NULL;
} }
#ifdef HAVE_EVENTFD_H
#if defined(__UCLIBC__)
static int eventfd_read(int fd, eventfd_t* value)
{
return (read(fd, value, sizeof(*value)) == sizeof(*value)) ? 0 : -1;
}
static int eventfd_write(int fd, eventfd_t value)
{
return (write(fd, &value, sizeof(value)) == sizeof(value)) ? 0 : -1;
}
#endif
#endif
BOOL SetEvent(HANDLE hEvent) BOOL SetEvent(HANDLE hEvent)
{ {
ULONG Type; ULONG Type;