From: John Hodge Date: Sun, 11 Mar 2012 06:43:18 +0000 (+0800) Subject: AcessNative - Possible fix to ioctl() bugs X-Git-Tag: rel0.15~731 X-Git-Url: https://git.ucc.asn.au/?p=tpg%2Facess2.git;a=commitdiff_plain;h=43c4f4db78b98e0427a04dc4b281359580591915 AcessNative - Possible fix to ioctl() bugs --- 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));