Don't ask me how, but it's booting again
[tpg/acess2.git] / Kernel / vfs / open.c
index 118380f..bd43a5f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * AcessMicro VFS
+ * Acess2 VFS
  * - Open, Close and ChDir
  */
 #define DEBUG  0
@@ -167,7 +167,7 @@ char *VFS_GetAbsPath(const char *Path)
 }
 
 /**
- * \fn char *VFS_ParsePath(char *Path, char **TruePath)
+ * \fn char *VFS_ParsePath(const char *Path, char **TruePath)
  * \brief Parses a path, resolving sysmlinks and applying permissions
  */
 tVFS_Node *VFS_ParsePath(const char *Path, char **TruePath)
@@ -237,12 +237,6 @@ tVFS_Node *VFS_ParsePath(const char *Path, char **TruePath)
                longestMount = mnt;
        }
        
-       // Sanity Check
-       /*if(!longestMount) {
-               Log("VFS_ParsePath - ERROR: No Root Node\n");
-               return NULL;
-       }*/
-       
        // Save to shorter variable
        mnt = longestMount;
        
@@ -294,11 +288,14 @@ tVFS_Node *VFS_ParsePath(const char *Path, char **TruePath)
                        LEAVE('n');
                        return NULL;
                }
-               LOG("FindDir(%p, '%s')", curNode, pathEle);
+               LOG("FindDir{=%p}(%p, '%s')", curNode->FindDir, curNode, pathEle);
                // Get Child Node
                tmpNode = curNode->FindDir(curNode, pathEle);
                LOG("tmpNode = %p", tmpNode);
-               if(curNode->Close)      curNode->Close(curNode);
+               if(curNode->Close) {
+                       //LOG2("curNode->Close = %p", curNode->Close);
+                       curNode->Close(curNode);
+               }
                curNode = tmpNode;
                
                // Error Check
@@ -391,12 +388,23 @@ tVFS_Node *VFS_ParsePath(const char *Path, char **TruePath)
                (*TruePath)[retLength] = '/';
                strcpy(*TruePath+retLength+1, pathEle);
                
-               LOG("*TruePath = '%s'\n", *TruePath);
+               LOG("*TruePath = '%s'", *TruePath);
                
                // - Extend Path
                retLength += nextSlash + 1;
        }
        
+       if( !curNode->FindDir ) {
+               if(curNode->Close)      curNode->Close(curNode);
+               if(TruePath) {
+                       free(*TruePath);
+                       *TruePath = NULL;
+               }
+               Log("FindDir fail on '%s'", Path);
+               LEAVE('n');
+               return NULL;
+       }
+       
        // Get last node
        LOG("VFS_ParsePath: FindDir(%p, '%s')", curNode, &Path[ofs]);
        tmpNode = curNode->FindDir(curNode, &Path[ofs]);

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