AcessNative - Fixed CLIShell
[tpg/acess2.git] / AcessNative / ld-acess_src / exports.c
index 406e55f..9ee04f1 100644 (file)
@@ -5,7 +5,7 @@
  * - 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>
@@ -35,6 +35,9 @@ extern int    AllocateMemory(uintptr_t VirtAddr, size_t ByteCount);
 // === CONSTANTS ===
 #define NATIVE_FILE_MASK       0x40000000
 
+// === GLOBALS ===
+int    acess__errno;
+
 // === CODE ===
 // --- VFS Calls
 int acess_chdir(const char *Path)
@@ -68,14 +71,16 @@ int acess_reopen(int FD, const char *Path, int Flags) {
 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);
 }
 
@@ -95,8 +100,8 @@ 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);
+       // NOTE: The length here is hacky and could break
        if( data == NULL )
                len = 0;
        else
@@ -113,8 +118,8 @@ int acess_finfo(int fd, t_sysFInfo *info, int maxacls) {
                );
 }
 
-int acess_readdir(int fd, char *dest) {
-       DEBUG("readdir(%i, %p)", fd, dest);
+int acess_SysReadDir(int fd, char *dest) {
+       DEBUG("SysReadDir(%i, %p)", fd, dest);
        return _Syscall(SYS_READDIR, ">i <d", fd, 256, dest);
 }
 
@@ -181,8 +186,8 @@ int acess_clone(int flags, void *stack)
                if(ret == 0)
                {
                        _CloseSyscalls();
-                       _InitSyscalls();
                        giSyscall_ClientID = newID;
+                       _InitSyscalls();
                        return 0;
                }
                
@@ -267,7 +272,7 @@ int acess_SysGetMessage(int *SourceTID, void *Data)
        int lastlen;
 
        lastlen = _Syscall(SYS_GETMSG, "<d <d",
-               SourceTID ? sizeof(int) : 0, SourceTID,
+               SourceTID ? sizeof(uint32_t) : 0, SourceTID,
                Data ? 1024 : 0, Data
                );
        return lastlen;
@@ -285,7 +290,7 @@ void acess__SysDebug(const char *Format, ...)
        
        va_start(args, Format);
        
-       printf("[_SysDebug %i]", giSyscall_ClientID);
+       printf("[_SysDebug %i] ", giSyscall_ClientID);
        vprintf(Format, args);
        printf("\n");
        
@@ -301,7 +306,7 @@ void acess__exit(int Status)
 
 
 // === Symbol List ===
-#define DEFSYM(name)   {#name, acess_##name}
+#define DEFSYM(name)   {#name, &acess_##name}
 const tSym     caBuiltinSymbols[] = {
        DEFSYM(_exit),
        
@@ -315,7 +320,7 @@ const tSym  caBuiltinSymbols[] = {
        DEFSYM(tell),
        DEFSYM(ioctl),
        DEFSYM(finfo),
-       DEFSYM(readdir),
+       DEFSYM(SysReadDir),
        DEFSYM(select),
        DEFSYM(_SysOpenChild),
        DEFSYM(_SysGetACL),
@@ -337,7 +342,9 @@ const tSym  caBuiltinSymbols[] = {
        DEFSYM(_SysAllocate),
        DEFSYM(_SysDebug),
        DEFSYM(_SysSetFaultHandler),
-       DEFSYM(_SysWaitEvent)
+       DEFSYM(_SysWaitEvent),
+       
+       DEFSYM(_errno)
 };
 
 const int      ciNumBuiltinSymbols = sizeof(caBuiltinSymbols)/sizeof(caBuiltinSymbols[0]);

UCC git Repository :: git.ucc.asn.au