Modules/InitRD - Added new files, and re-added debug
[tpg/acess2.git] / Modules / Filesystems / InitRD / main.c
index cc54f27..9a78389 100644 (file)
@@ -5,16 +5,19 @@
 #include "initrd.h"
 #include <modules.h>
 
+#define DUMP_ON_MOUNT  1
+
 // === IMPORTS ==
 extern tVFS_Node       gInitRD_RootNode;
 
 // === PROTOTYPES ===
  int   InitRD_Install(char **Arguments);
-tVFS_Node      *InitRD_InitDevice(char *Device, char **Arguments);
+tVFS_Node      *InitRD_InitDevice(const char *Device, const char **Arguments);
 void   InitRD_Unmount(tVFS_Node *Node);
 Uint64 InitRD_ReadFile(tVFS_Node *Node, Uint64 Offset, Uint64 Size, void *Buffer);
 char   *InitRD_ReadDir(tVFS_Node *Node, int ID);
-tVFS_Node      *InitRD_FindDir(tVFS_Node *Node, char *Name);
+tVFS_Node      *InitRD_FindDir(tVFS_Node *Node, const char *Name);
+void   InitRD_DumpDir(tVFS_Node *Node, int Indent);
 
 // === GLOBALS ===
 MODULE_DEFINE(0, 0x0A, FS_InitRD, InitRD_Install, NULL);
@@ -27,15 +30,21 @@ tVFS_Driver gInitRD_FSInfo = {
  */
 int InitRD_Install(char **Arguments)
 {
+       Log_Notice("InitRD", "Installed");
        VFS_AddDriver( &gInitRD_FSInfo );
+       
        return MODULE_ERR_OK;
 }
 
 /**
  * \brief Mount the InitRD
  */
-tVFS_Node *InitRD_InitDevice(char *Device, char **Arguments)
+tVFS_Node *InitRD_InitDevice(const char *Device, const char **Arguments)
 {
+       #if DUMP_ON_MOUNT
+       InitRD_DumpDir( &gInitRD_RootNode, 0 );
+       #endif
+       Log_Notice("InitRD", "Mounted");
        return &gInitRD_RootNode;
 }
 
@@ -77,12 +86,12 @@ char *InitRD_ReadDir(tVFS_Node *Node, int ID)
 /**
  * \brief Find an element in a directory
  */
-tVFS_Node *InitRD_FindDir(tVFS_Node *Node, char *Name)
+tVFS_Node *InitRD_FindDir(tVFS_Node *Node, const char *Name)
 {
         int    i;
        tInitRD_File    *dir = Node->ImplPtr;
        
-       Log("InirRD_FindDir: Name = '%s'", Name);
+       LOG("Name = '%s'", Name);
        
        for( i = 0; i < Node->Size; i++ )
        {
@@ -92,3 +101,20 @@ tVFS_Node *InitRD_FindDir(tVFS_Node *Node, char *Name)
        
        return NULL;
 }
+
+void InitRD_DumpDir(tVFS_Node *Node, int Indent)
+{
+        int    i;
+       char    indent[Indent+1];
+       tInitRD_File    *dir = Node->ImplPtr;
+       
+       for( i = 0; i < Indent; i++ )   indent[i] = ' ';
+       indent[i] = '\0';
+       
+       for( i = 0; i < Node->Size; i++ )
+       {
+               Log_Debug("InitRD", "%s- %p %s", indent, dir[i].Node, dir[i].Name);
+               if(dir[i].Node->Flags & VFS_FFLAG_DIRECTORY)
+                       InitRD_DumpDir(dir[i].Node, Indent+1);
+       }
+}

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