From 0e280aab008d3b1dda0fd3e441291430fe188dbc Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 11 Jul 2012 23:37:12 +0800 Subject: [PATCH] Kernel/VFS - Error catching in MkNod/O_CREAT --- KernelLand/Kernel/include/vfs_ext.h | 2 ++ KernelLand/Kernel/vfs/dir.c | 2 +- KernelLand/Kernel/vfs/open.c | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/KernelLand/Kernel/include/vfs_ext.h b/KernelLand/Kernel/include/vfs_ext.h index b4d5e2ad..df68c4c5 100644 --- a/KernelLand/Kernel/include/vfs_ext.h +++ b/KernelLand/Kernel/include/vfs_ext.h @@ -29,6 +29,8 @@ typedef Uint32 tMount; #define VFS_OPENFLAG_NOLINK 0x40 //! Create the file if it doesn't exist #define VFS_OPENFLAG_CREATE 0x80 +//! Treat as a directory +#define VFS_OPENFLAG_DIRECTORY 0x100 //! Open as a user #define VFS_OPENFLAG_USER 0x8000 /** diff --git a/KernelLand/Kernel/vfs/dir.c b/KernelLand/Kernel/vfs/dir.c index d4c15309..e2b124dc 100644 --- a/KernelLand/Kernel/vfs/dir.c +++ b/KernelLand/Kernel/vfs/dir.c @@ -97,7 +97,7 @@ int VFS_MkNod(const char *Path, Uint Flags) _CloseNode(parent); // Error Check - if(ret == 0) { + if(ret != 0) { LEAVE('i', -1); return -1; } diff --git a/KernelLand/Kernel/vfs/open.c b/KernelLand/Kernel/vfs/open.c index 2865f781..d55b7546 100644 --- a/KernelLand/Kernel/vfs/open.c +++ b/KernelLand/Kernel/vfs/open.c @@ -485,7 +485,10 @@ int VFS_OpenEx(const char *Path, Uint Flags, Uint Mode) { // TODO: Translate `Mode` into ACL and node flags // Get parent, create node - VFS_MkNod(absPath, 0); + if( VFS_MkNod(absPath, 0) ) { + free(absPath); + return -1; + } node = VFS_ParsePath(absPath, NULL, &mnt); } -- 2.20.1