Skip to content

Commit

Permalink
* Use futimens that is POSIX-compliant and compatible with uclibc ins…
Browse files Browse the repository at this point in the history
…tead 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.
  • Loading branch information
repzilon committed Aug 7, 2014
1 parent 362c992 commit 5f9c36d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
12 changes: 9 additions & 3 deletions channels/drive/client/drive_file.c
Expand Up @@ -433,7 +433,11 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
int status;
char* fullpath;
struct STAT st;
#if defined(ANDROID)
struct timeval tv[2];
#else
struct timespec tv[2];
#endif
UINT64 LastWriteTime;
UINT32 FileAttributes;
UINT32 FileNameLength;
Expand All @@ -454,15 +458,17 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
return FALSE;

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_usec = 0;
#ifndef WIN32
/* TODO on win32 */
#ifdef ANDROID
tv[0].tv_usec = 0;
tv[1].tv_usec = 0;
utimes(file->fullpath, tv);
#else
futimes(file->fd, tv);
tv[0].tv_nsec = 0;
tv[1].tv_nsec = 0;
futimens(file->fd, tv);
#endif

if (FileAttributes > 0)
Expand Down
11 changes: 11 additions & 0 deletions winpr/libwinpr/comm/comm.c
Expand Up @@ -1495,5 +1495,16 @@ BOOL CommCloseHandle(HANDLE handle)
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__ */
5 changes: 5 additions & 0 deletions winpr/libwinpr/comm/comm.h
Expand Up @@ -92,6 +92,11 @@ void CommLog_Print(int wlog_level, char *fmt, ...);
BOOL CommIsHandled(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 /* WINPR_COMM_PRIVATE_H */
3 changes: 3 additions & 0 deletions winpr/libwinpr/comm/comm_serial_sys.c
Expand Up @@ -30,6 +30,9 @@
#include <unistd.h>

#include "comm_serial_sys.h"
#ifdef __UCLIBC__
#include "comm.h"
#endif

#include <winpr/crt.h>
#include <winpr/wlog.h>
Expand Down
14 changes: 14 additions & 0 deletions winpr/libwinpr/synch/event.c
Expand Up @@ -121,6 +121,20 @@ HANDLE OpenEventA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName)
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)
{
ULONG Type;
Expand Down

0 comments on commit 5f9c36d

Please sign in to comment.