* - Exported functions
*/
#define DONT_INCLUDE_SYSCALL_NAMES 1
-#include "../../Usermode/include/acess/sys.h"
+#include "../../Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h"
#include "../syscalls.h"
#include "exports.h"
#include <stdarg.h>
#include <stddef.h>
#define DEBUG(v...) Debug(v)
+#define PAGE_SIZE 4096
typedef struct sFILE FILE;
size_t acess_read(int FD, void *Dest, size_t Bytes) {
if(FD & NATIVE_FILE_MASK)
return native_read(FD & (NATIVE_FILE_MASK-1), Dest, Bytes);
- DEBUG("read(0x%x, 0x%x, *%p)", FD, Bytes, Dest);
+// if( FD > 2 )
+ DEBUG("read(0x%x, 0x%x, *%p)", FD, Bytes, Dest);
return _Syscall(SYS_READ, ">i >i <d", FD, Bytes, Bytes, Dest);
}
size_t acess_write(int FD, const void *Src, size_t Bytes) {
if(FD & NATIVE_FILE_MASK)
return native_write(FD & (NATIVE_FILE_MASK-1), Src, Bytes);
- DEBUG("write(0x%x, 0x%x, %p\"%.*s\")", FD, Bytes, Src, Bytes, (char*)Src);
+// if( FD > 2 )
+ DEBUG("write(0x%x, 0x%x, %p\"%.*s\")", FD, Bytes, Src, Bytes, (char*)Src);
return _Syscall(SYS_WRITE, ">i >i >d", FD, Bytes, Bytes, Src);
}
}
int acess_ioctl(int fd, int id, void *data) {
- // NOTE: 1024 byte size is a hack
+ int len;
DEBUG("ioctl(%i, %i, %p)", fd, id, data);
- return _Syscall(SYS_IOCTL, ">i >i ?d", fd, id, 1024, data);
+ // NOTE: The length here is hacky and could break
+ 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));
return _Syscall(SYS_READDIR, ">i <d", fd, 256, dest);
}
-int acess_select(int nfds, fd_set *read, fd_set *write, fd_set *error, time_t *timeout)
+int acess__SysSelect(int nfds, fd_set *read, fd_set *write, fd_set *error, time_t *timeout, uint32_t events)
{
- DEBUG("select(%i, %p, %p, %p, %p)", nfds, read, write, error, timeout);
- return _Syscall(SYS_SELECT, ">i ?d ?d ?d >d", nfds,
+ DEBUG("_SysSelect(%i, %p, %p, %p, %p, 0x%x)", nfds, read, write, error, timeout, events);
+ return _Syscall(SYS_SELECT, ">i ?d ?d ?d >d >i", nfds,
read ? (nfds+7)/8 : 0, read,
write ? (nfds+7)/8 : 0, write,
error ? (nfds+7)/8 : 0, error,
- sizeof(*timeout), timeout
+ sizeof(*timeout), timeout,
+ events
);
}
+int acess_select(int nfds, fd_set *read, fd_set *write, fd_set *error, time_t *timeout)
+{
+ return acess__SysSelect(nfds, read, write, error, timeout, 0);
+}
+
+
int acess__SysOpenChild(int fd, char *name, int flags) {
return _Syscall(SYS_OPENCHILD, ">i >s >i", fd, name, flags);
}
return _Syscall(SYS_WAITTID, ">i <d", TID, sizeof(int), &ExitStatus);
}
-int acess_setuid(int ID)
-{
- return _Syscall(SYS_SETUID, ">i", ID);
-}
-
-int acess_setgid(int ID)
-{
- return _Syscall(SYS_SETGID, ">i", ID);
-}
+int acess_setuid(int ID) { return _Syscall(SYS_SETUID, ">i", ID); }
+int acess_setgid(int ID) { return _Syscall(SYS_SETGID, ">i", ID); }
+int acess_gettid(void) { return _Syscall(SYS_GETTID, ""); }
+int acess_getpid(void) { return _Syscall(SYS_GETPID, ""); }
+int acess_getuid(void) { return _Syscall(SYS_GETUID, ""); }
+int acess_getgid(void) { return _Syscall(SYS_GETGID, ""); }
int acess_SysSendMessage(int DestTID, int Length, void *Data)
{
int acess_SysGetMessage(int *SourceTID, void *Data)
{
- return _Syscall(SYS_GETMSG, "<d <d",
- SourceTID ? sizeof(int) : 0, SourceTID,
- Data ? 4096 : 0, Data
+// static __thread int lastlen = 1024;
+ int lastlen;
+
+ lastlen = _Syscall(SYS_GETMSG, "<d <d",
+ SourceTID ? sizeof(uint32_t) : 0, SourceTID,
+ Data ? 1024 : 0, Data
);
+ return lastlen;
+}
+
+int acess__SysWaitEvent(int Mask)
+{
+ return _Syscall(SYS_WAITEVENT, ">i", Mask);
}
// --- Logging
va_start(args, Format);
- printf("[_SysDebug %i]", giSyscall_ClientID);
+ printf("[_SysDebug %i] ", giSyscall_ClientID);
vprintf(Format, args);
printf("\n");
DEFSYM(_SysOpenChild),
DEFSYM(_SysGetACL),
DEFSYM(_SysMount),
+ DEFSYM(_SysSelect),
DEFSYM(clone),
DEFSYM(execve),
DEFSYM(waittid),
DEFSYM(setuid),
DEFSYM(setgid),
+ DEFSYM(gettid),
DEFSYM(SysSendMessage),
DEFSYM(SysGetMessage),
DEFSYM(_SysAllocate),
DEFSYM(_SysDebug),
- DEFSYM(_SysSetFaultHandler)
+ DEFSYM(_SysSetFaultHandler),
+ DEFSYM(_SysWaitEvent)
};
const int ciNumBuiltinSymbols = sizeof(caBuiltinSymbols)/sizeof(caBuiltinSymbols[0]);