From 43c4f4db78b98e0427a04dc4b281359580591915 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 11 Mar 2012 14:43:18 +0800 Subject: [PATCH 1/1] AcessNative - Possible fix to ioctl() bugs --- AcessNative/acesskernel_src/threads.c | 4 ++-- AcessNative/ld-acess_src/exports.c | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/AcessNative/acesskernel_src/threads.c b/AcessNative/acesskernel_src/threads.c index a2a58981..71fa2941 100644 --- a/AcessNative/acesskernel_src/threads.c +++ b/AcessNative/acesskernel_src/threads.c @@ -50,7 +50,7 @@ typedef struct sProcess int MaxFD; } tProcess; -typedef struct sThread +struct sThread { struct sThread *GlobalNext; struct sThread *Next; @@ -82,7 +82,7 @@ typedef struct sThread Uint32 Events, WaitMask; SDL_sem *EventSem; -} tThread; +}; // === PROTOTYPES === int Threads_Wake(tThread *Thread); diff --git a/AcessNative/ld-acess_src/exports.c b/AcessNative/ld-acess_src/exports.c index 0c87bda6..c236b526 100644 --- a/AcessNative/ld-acess_src/exports.c +++ b/AcessNative/ld-acess_src/exports.c @@ -12,6 +12,7 @@ #include #define DEBUG(v...) Debug(v) +#define PAGE_SIZE 4096 typedef struct sFILE FILE; @@ -93,9 +94,14 @@ uint64_t acess_tell(int FD) { } int acess_ioctl(int fd, int id, void *data) { + int len; // NOTE: 1024 byte size is a hack DEBUG("ioctl(%i, %i, %p)", fd, id, data); - return _Syscall(SYS_IOCTL, ">i >i ?d", fd, id, 1024, data); + if( data == NULL ) + len = 0; + else + len = PAGE_SIZE - ((uintptr_t)data % PAGE_SIZE); + return _Syscall(SYS_IOCTL, ">i >i ?d", fd, id, len, data); } int acess_finfo(int fd, t_sysFInfo *info, int maxacls) { // DEBUG("offsetof(size, t_sysFInfo) = %i", offsetof(t_sysFInfo, size)); -- 2.20.1