Kernel/syscalls - Implimenting _SysMkDir
authorJohn Hodge <[email protected]>
Wed, 3 Jul 2013 11:32:07 +0000 (19:32 +0800)
committerJohn Hodge <[email protected]>
Wed, 3 Jul 2013 11:32:07 +0000 (19:32 +0800)
KernelLand/Kernel/syscalls.c
KernelLand/Kernel/vfs/dir.c
Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h
Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h

index 34a35c5..7a96011 100644 (file)
@@ -315,14 +315,10 @@ void SyscallHandler(tSyscallRegs *Regs)
                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;
-                       }
+                       CHECK_STR_NONULL((char*)Regs->Arg1);
+                       CHECK_STR_NONULL((char*)Regs->Arg2);
+                       CHECK_STR_NULLOK((char*)Regs->Arg3);
+                       CHECK_STR_NONULL((char*)Regs->Arg4);
                        ret = VFS_Mount(
                                (char*)Regs->Arg1,      // Device
                                (char*)Regs->Arg2,      // Mount point
@@ -355,7 +351,17 @@ void SyscallHandler(tSyscallRegs *Regs)
                        0       // User handles
                        );
                break;
+
+       
+       // Create a directory
+       case SYS_MKDIR:
+               CHECK_STR_NONULL( (char*)Regs->Arg1 );
+               ret = VFS_MkDir( (char*)Regs->Arg1 );
+               break;
        
+       case SYS_UNLINK:
+               Log_Error("Syscalls", "TODO: Impliment SYS_UNLINK");
+               // Fall
        // -- Debug
        //#if DEBUG_BUILD
        case SYS_DEBUG:
index 2417539..add48b0 100644 (file)
@@ -104,9 +104,11 @@ int VFS_MkNod(const char *Path, Uint Flags)
        return ret==NULL;
 
 _error:
-       _CloseNode(parent);
-       ASSERT(mountpt->OpenHandleCount>0);
-       mountpt->OpenHandleCount --;
+       if( parent ) {
+               _CloseNode(parent);
+               ASSERT(mountpt->OpenHandleCount>0);
+               mountpt->OpenHandleCount --;
+       }
        free(absPath);
        LEAVE('i', -1);
        return -1;
index 8ed6684..98dfbcc 100644 (file)
@@ -56,5 +56,7 @@ SYSCALL1(_SysChdir, SYS_CHDIR)        // char*
 SYSCALL3(_SysIOCtl, SYS_IOCTL) // int, int, void*
 SYSCALL4(_SysMount, SYS_MOUNT) // char*, char*, char*, char*
 SYSCALL6(_SysSelect, SYS_SELECT)       // int, fd_set*, fd_set*, fd_set*, tTime*, uint32_t
+
+SYSCALL1(_SysMkDir, SYS_MKDIR) // const char*
 SYSCALL1(_SysUnlink, SYS_UNLINK)       // const char*
 
index bcd3d1f..87deceb 100644 (file)
@@ -93,6 +93,7 @@ extern int    _SysGetACL(int fd, t_sysACL *dest);
 extern int     _SysMount(const char *Device, const char *Directory, const char *Type, const char *Options);
 extern int     _SysSelect(int nfds, fd_set *read, fd_set *write, fd_set *err, int64_t *timeout, unsigned int extraevents);
 //#define select(nfs, rdfds, wrfds, erfds, timeout)    _SysSelect(nfs, rdfds, wrfds, erfds, timeout, 0)
+extern int     _SysMkDir(const char *dirname);
 extern int     _SysUnlink(const char *pathname);
 
 // --- IPC ---

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