From 383e0a7b0f5f23bea1b9712abc1060798d20bb3a Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 3 Jul 2013 19:32:07 +0800 Subject: [PATCH] Kernel/syscalls - Implimenting _SysMkDir --- KernelLand/Kernel/syscalls.c | 22 ++++++++++++------- KernelLand/Kernel/vfs/dir.c | 8 ++++--- .../ld-acess.so_src/arch/syscalls.s.h | 2 ++ .../ld-acess.so_src/include_exp/acess/sys.h | 1 + 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/KernelLand/Kernel/syscalls.c b/KernelLand/Kernel/syscalls.c index 34a35c5f..7a960114 100644 --- a/KernelLand/Kernel/syscalls.c +++ b/KernelLand/Kernel/syscalls.c @@ -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: diff --git a/KernelLand/Kernel/vfs/dir.c b/KernelLand/Kernel/vfs/dir.c index 24175397..add48b0c 100644 --- a/KernelLand/Kernel/vfs/dir.c +++ b/KernelLand/Kernel/vfs/dir.c @@ -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; diff --git a/Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h b/Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h index 8ed66842..98dfbcc3 100644 --- a/Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h +++ b/Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h @@ -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* diff --git a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h index bcd3d1fa..87decebd 100644 --- a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h +++ b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h @@ -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 --- -- 2.20.1