From: John Hodge Date: Sat, 12 Nov 2011 04:47:11 +0000 (+0800) Subject: Kernel/vfs - Debugging changes (and some limits to FS_Root) X-Git-Tag: rel0.14~110 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=e41e7f0029020a6ab27cfea37e10b5096ca10a3b;p=tpg%2Facess2.git Kernel/vfs - Debugging changes (and some limits to FS_Root) --- diff --git a/Kernel/vfs/dir.c b/Kernel/vfs/dir.c index 8cc3fa84..3d4018f9 100644 --- a/Kernel/vfs/dir.c +++ b/Kernel/vfs/dir.c @@ -15,6 +15,7 @@ extern tVFS_Mount *gRootMount; int VFS_MkDir(const char *Path); #endif int VFS_MkNod(const char *Path, Uint Flags); +// int VFS_Symlink(const char *Name, const char *Link); // === CODE === /** @@ -115,19 +116,23 @@ int VFS_Symlink(const char *Name, const char *Link) { char *realLink; int fp; - tVFS_Node *destNode; char *_link; - //ENTER("sName sLink", Name, Link); + ENTER("sName sLink", Name, Link); // Get absolue path name _link = VFS_GetAbsPath( Link ); if(!_link) { Log_Warning("VFS", "Path '%s' is badly formed", Link); + LEAVE('i', -1); return -1; } + + LOG("_link = '%s'", _link); - destNode = VFS_ParsePath( _link, &realLink, NULL ); + #if 1 + { + tVFS_Node *destNode = VFS_ParsePath( _link, &realLink, NULL ); #if 0 // Get true path and node free(_link); @@ -144,10 +149,16 @@ int VFS_Symlink(const char *Name, const char *Link) // Derefence the destination if(destNode->Close) destNode->Close(destNode); - + } + #else + realLink = _link; + #endif + LOG("realLink = '%s'", realLink); + // Make node if( VFS_MkNod(Name, VFS_FFLAG_SYMLINK) != 0 ) { Log_Warning("VFS", "Unable to create link node '%s'", Name); + LEAVE('i', -2); return -2; // Make link node } @@ -158,6 +169,7 @@ int VFS_Symlink(const char *Name, const char *Link) free(realLink); + LEAVE('i', 1); return 1; } diff --git a/Kernel/vfs/fs/root.c b/Kernel/vfs/fs/root.c index 12417f28..a12d1542 100644 --- a/Kernel/vfs/fs/root.c +++ b/Kernel/vfs/fs/root.c @@ -9,6 +9,7 @@ // === CONSTANTS === #define MAX_FILES 64 +#define MAX_FILE_SIZE 1024 // === PROTOTYPES === tVFS_Node *Root_InitDevice(const char *Device, const char **Options); @@ -171,15 +172,21 @@ char *Root_ReadDir(tVFS_Node *Node, int Pos) Uint64 Root_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) { tRamFS_File *file = Node->ImplPtr; + ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer); - if(Offset > Node->Size) return 0; - if(Length > Node->Size) return 0; + if(Offset > Node->Size) { + LEAVE('i', 0); + return 0; + } + if(Length > Node->Size) Length = Node->Size; if(Offset+Length > Node->Size) Length = Node->Size - Offset; memcpy(Buffer, file->Data.Bytes+Offset, Length); - + LOG("Buffer = '%.*s'", (int)Length, Buffer); + + LEAVE('i', Length); return Length; } @@ -190,6 +197,20 @@ Uint64 Root_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) { tRamFS_File *file = Node->ImplPtr; + + ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer); + + if(Offset > Node->Size) { + LEAVE('i', -1); + return -1; + } + + if(Offset + Length > MAX_FILE_SIZE) + { + Length = MAX_FILE_SIZE - Offset; + } + + LOG("Buffer = '%.*s'", (int)Length, Buffer); // Check if buffer needs to be expanded if(Offset + Length > Node->Size) @@ -197,15 +218,18 @@ Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) void *tmp = realloc( file->Data.Bytes, Offset + Length ); if(tmp == NULL) { Warning("Root_Write - Increasing buffer size failed"); + LEAVE('i', -1); return -1; } file->Data.Bytes = tmp; Node->Size = Offset + Length; - //LOG("Expanded buffer to %i bytes", Node->Size); + LOG("Expanded buffer to %i bytes", (int)Node->Size); } memcpy(file->Data.Bytes+Offset, Buffer, Length); + LOG("File - '%.*s'", Node->Size, file->Data.Bytes); + LEAVE('i', Length); return Length; } diff --git a/Kernel/vfs/open.c b/Kernel/vfs/open.c index 340c9b26..a886c451 100644 --- a/Kernel/vfs/open.c +++ b/Kernel/vfs/open.c @@ -346,6 +346,7 @@ restart_parse: } curNode->Read( curNode, 0, curNode->Size, path_buffer ); path_buffer[ curNode->Size ] = '\0'; + LOG("path_buffer = '%s'", path_buffer); strcat(path_buffer, Path + ofs+nextSlash); Path = path_buffer; @@ -354,6 +355,7 @@ restart_parse: } // EVIL: Goto :) + LOG("Symlink -> '%s', restart", Path); goto restart_parse; } @@ -452,7 +454,7 @@ int VFS_int_CreateHandle( tVFS_Node *Node, tVFS_Mount *Mount, int Mode ) { int i; - ENTER("pNode pMount iMode", Node, Mount, Mode); + ENTER("pNode pMount xMode", Node, Mount, Mode); i = 0; i |= (Mode & VFS_OPENFLAG_EXEC) ? VFS_PERM_EXECUTE : 0;