3 * InitRD Driver Version 1
8 #define DUMP_ON_MOUNT 1
11 extern tVFS_Node gInitRD_RootNode;
14 int InitRD_Install(char **Arguments);
15 tVFS_Node *InitRD_InitDevice(char *Device, char **Arguments);
16 void InitRD_Unmount(tVFS_Node *Node);
17 Uint64 InitRD_ReadFile(tVFS_Node *Node, Uint64 Offset, Uint64 Size, void *Buffer);
18 char *InitRD_ReadDir(tVFS_Node *Node, int ID);
19 tVFS_Node *InitRD_FindDir(tVFS_Node *Node, char *Name);
20 void InitRD_DumpDir(tVFS_Node *Node, int Indent);
23 MODULE_DEFINE(0, 0x0A, FS_InitRD, InitRD_Install, NULL);
24 tVFS_Driver gInitRD_FSInfo = {
25 "initrd", 0, InitRD_InitDevice, InitRD_Unmount, NULL
29 * \brief Register initrd with the kernel
31 int InitRD_Install(char **Arguments)
33 VFS_AddDriver( &gInitRD_FSInfo );
39 * \brief Mount the InitRD
41 tVFS_Node *InitRD_InitDevice(char *Device, char **Arguments)
44 InitRD_DumpDir( &gInitRD_RootNode, 0 );
46 return &gInitRD_RootNode;
50 * \brief Unmount the InitRD
52 void InitRD_Unmount(tVFS_Node *Node)
57 * \brief Read from a file
59 Uint64 InitRD_ReadFile(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
61 if(Offset > Node->Size)
63 if(Offset + Length > Node->Size)
64 Length = Node->Size - Offset;
66 memcpy(Buffer, Node->ImplPtr+Offset, Length);
72 * \brief Read from a directory
74 char *InitRD_ReadDir(tVFS_Node *Node, int ID)
76 tInitRD_File *dir = Node->ImplPtr;
81 return strdup(dir[ID].Name);
85 * \brief Find an element in a directory
87 tVFS_Node *InitRD_FindDir(tVFS_Node *Node, char *Name)
90 tInitRD_File *dir = Node->ImplPtr;
92 //Log("InirRD_FindDir: Name = '%s'", Name);
94 for( i = 0; i < Node->Size; i++ )
96 if(strcmp(Name, dir[i].Name) == 0)
103 void InitRD_DumpDir(tVFS_Node *Node, int Indent)
106 char indent[Indent+1];
107 tInitRD_File *dir = Node->ImplPtr;
109 for( i = 0; i < Indent; i++ ) indent[i] = ' ';
112 for( i = 0; i < Node->Size; i++ )
114 //Log("%s- %p %s", indent, dir[i].Node, dir[i].Name);
115 if(dir[i].Node->Flags & VFS_FFLAG_DIRECTORY)
116 InitRD_DumpDir(dir[i].Node, Indent+1);