Kernel - Fixed a bug in VFS_ParsePath that cause symlinks to break
authorJohn Hodge <[email protected]>
Wed, 27 Jul 2011 09:47:17 +0000 (17:47 +0800)
committerJohn Hodge <[email protected]>
Wed, 27 Jul 2011 09:47:17 +0000 (17:47 +0800)
Kernel/lib.c
Kernel/vfs/handle.c
Kernel/vfs/io.c
Kernel/vfs/open.c

index 0b5ccfe..acf36aa 100644 (file)
@@ -495,6 +495,7 @@ char *strncpy(char *__str1, const char *__str2, size_t max)
 char *strcat(char *__dest, const char *__src)
 {
        while(*__dest++);
+       __dest--;
        while(*__src)
                *__dest++ = *__src++;
        *__dest = '\0';
index ecf3f5c..55c841e 100644 (file)
@@ -19,7 +19,7 @@ tVFS_Handle   *VFS_GetHandle(int FD);
  int   VFS_AllocHandle(int FD, tVFS_Node *Node, int Mode);
 
 // === GLOBALS ===
-tVFS_Handle    *gaUserHandles = (void*)MM_PPD_VFS;
+tVFS_Handle    *gaUserHandles = (void*)MM_PPD_HANDLES;
 tVFS_Handle    *gaKernelHandles = (void*)MM_KERNEL_VFS;
 
 // === CODE ===
index 7260df7..212a7c2 100644 (file)
@@ -144,6 +144,8 @@ int VFS_Seek(int FD, Sint64 Offset, int Whence)
        
        // Set relative to end of file
        if(Whence < 0) {
+               if( h->Node->Size == -1 )       return -1;
+
                h->Position = h->Node->Size - Offset;
                return 0;
        }
index 02c9266..70d3c24 100644 (file)
@@ -203,7 +203,7 @@ restart_parse:
        
        // Check if there is anything mounted
        if(!gVFS_Mounts) {
-               Warning("WTF! There's nothing mounted?");
+               Log_Error("VFS", "VFS_ParsePath - No filesystems mounted");
                return NULL;
        }
        
@@ -318,7 +318,7 @@ restart_parse:
                                *TruePath = NULL;
                        }
                        if(!curNode->Read) {
-                               Warning("VFS_ParsePath - Read of node %p is NULL (%s)",
+                               Log_Warning("VFS", "VFS_ParsePath - Read of symlink node %p'%s' is NULL",
                                        curNode, Path);
                                if(curNode->Close)      curNode->Close(curNode);
                                // No need to free *TruePath, it should already be NULL
@@ -345,12 +345,12 @@ restart_parse:
                                }
                                curNode->Read( curNode, 0, curNode->Size, path_buffer );
                                path_buffer[ curNode->Size ] = '\0';
-                               strcat(path_buffer, &Path[ofs+nextSlash]);
+                               strcat(path_buffer, Path + ofs+nextSlash);
                                
                                Path = path_buffer;
+//                             Log_Debug("VFS", "VFS_ParsePath: Symlink translated to '%s'", Path);
                                iNestedLinks ++;
                        }
-                       
 
                        // EVIL: Goto :)
                        goto restart_parse;
@@ -359,7 +359,7 @@ restart_parse:
                // Handle Non-Directories
                if( !(curNode->Flags & VFS_FFLAG_DIRECTORY) )
                {
-                       Warning("VFS_ParsePath - File in directory context");
+                       Log_Warning("VFS", "VFS_ParsePath - Path segment is not a directory");
                        if(TruePath)    free(*TruePath);
                        LEAVE('n');
                        return NULL;
@@ -372,7 +372,7 @@ restart_parse:
                tmp = realloc( *TruePath, retLength + strlen(pathEle) + 1 + 1 );
                // Check if allocation succeeded
                if(!tmp) {
-                       Warning("VFS_ParsePath -  Unable to reallocate true path buffer");
+                       Log_Warning("VFS", "VFS_ParsePath - Unable to reallocate true path buffer");
                        free(*TruePath);
                        *TruePath = NULL;
                        if(curNode->Close)      curNode->Close(curNode);
@@ -396,7 +396,7 @@ restart_parse:
                        free(*TruePath);
                        *TruePath = NULL;
                }
-               Log("FindDir fail on '%s'", Path);
+               Log_Warning("VFS", "VFS_ParsePath - FindDir doesn't exist for element of '%s'", Path);
                LEAVE('n');
                return NULL;
        }

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