AcessNative - Changes to allow _compiling_ on windows.
[tpg/acess2.git] / KernelLand / Kernel / syscalls.c
index 5580187..bfd68bf 100644 (file)
@@ -102,7 +102,7 @@ void SyscallHandler(tSyscallRegs *Regs)
        
        // -- Get the physical address of a page
        case SYS_GETPHYS:
-               ret = MM_GetPhysAddr(Regs->Arg1);
+               ret = MM_GetPhysAddr( (void*)Regs->Arg1 );
                break;
        
        // -- Map an address
@@ -135,13 +135,10 @@ void SyscallHandler(tSyscallRegs *Regs)
        // -- Check for messages
        case SYS_GETMSG:
                CHECK_NUM_NULLOK( (Uint*)Regs->Arg1, sizeof(Uint) );
-               // NOTE: Can't do range checking as we don't know the size
-               // - Should be done by Proc_GetMessage
-               if( Regs->Arg2 && Regs->Arg2 != -1 && !MM_IsUser(Regs->Arg2) ) {
-                       err = -EINVAL;  ret = -1;       break;
-               }
+               if( Regs->Arg3 != -1 )
+                       CHECK_NUM_NULLOK((void*)Regs->Arg3, Regs->Arg2);
                // *Source, *Data
-               ret = Proc_GetMessage((Uint*)Regs->Arg1, (void*)Regs->Arg2);
+               ret = Proc_GetMessage((Uint*)Regs->Arg1, Regs->Arg2, (void*)Regs->Arg3);
                break;
        
        // -- Get the current timestamp
@@ -275,21 +272,35 @@ void SyscallHandler(tSyscallRegs *Regs)
                        ret = -1;
                        break;
                }
-               // Sanity check the paths
-               if(!Syscall_ValidString((char*)Regs->Arg1)
-               || !Syscall_ValidString((char*)Regs->Arg2)
-               || !Syscall_ValidString((char*)Regs->Arg3)
-               || !Syscall_ValidString((char*)Regs->Arg4) ) {
-                       err = -EINVAL;
-                       ret = -1;
-                       break;
+               
+               if( !Regs->Arg1 )
+               {
+                       if( !Syscall_ValidString((char*)Regs->Arg2) ) {
+                               err = -EINVAL;
+                               ret = -1;
+                               break;
+                       }
+                       
+                       ret = VFS_Unmount((char*)Regs->Arg2);
+               }
+               else
+               {
+                       // Sanity check the paths
+                       if(!Syscall_ValidString((char*)Regs->Arg1)
+                       || !Syscall_ValidString((char*)Regs->Arg2)
+                       || (Regs->Arg3 && !Syscall_ValidString((char*)Regs->Arg3))
+                       || !Syscall_ValidString((char*)Regs->Arg4) ) {
+                               err = -EINVAL;
+                               ret = -1;
+                               break;
+                       }
+                       ret = VFS_Mount(
+                               (char*)Regs->Arg1,      // Device
+                               (char*)Regs->Arg2,      // Mount point
+                               (char*)Regs->Arg3,      // Filesystem
+                               (char*)Regs->Arg4       // Options
+                               );
                }
-               ret = VFS_Mount(
-                       (char*)Regs->Arg1,      // Device
-                       (char*)Regs->Arg2,      // Mount point
-                       (char*)Regs->Arg3,      // Filesystem
-                       (char*)Regs->Arg4       // Options
-                       );
                break;
                
        // Wait on a set of handles

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