return "0x".str_pad( dechex(ord(fgetc($fp))), 2, "0", STR_PAD_LEFT );
}
+$inode = 0;
function ProcessFolder($prefix, $items)
{
global $gOutput, $gDependencies;
global $ACESSDIR, $ARCH;
+ global $inode;
foreach($items as $i=>$item)
{
+ $inode ++;
if(is_array($item[1]))
{
ProcessFolder("{$prefix}_{$i}", $item[1]);
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = VFS_FFLAG_DIRECTORY,
.Size = $size,
+ .Inode = {$inode},
.ImplPtr = {$prefix}_{$i}_entries,
.ReadDir = InitRD_ReadDir,
.FindDir = InitRD_FindDir
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = 0,
.Size = $size,
+ .Inode = {$inode},
.ImplPtr = {$prefix}_{$i}_data,
.Read = InitRD_ReadFile
};
};
EOF;
+$gOutput .= <<<EOF
+
+tVFS_Node * const gInitRD_FileList[] = {
+&gInitRD_RootNode
+EOF;
+
+function PutNodePointers($prefix, $items)
+{
+ global $gOutput;
+ foreach($items as $i=>$item)
+ {
+ $gOutput .= ",&{$prefix}_{$i}";
+ if(is_array($item[1]))
+ {
+ PutNodePointers("{$prefix}_{$i}", $item[1]);
+ }
+ }
+}
+
+PutNodePointers("gInitRD_Files", $lStack[0][1]);
+
+$gOutput .= <<<EOF
+};
+const int giInitRD_NumFiles = sizeof(gInitRD_FileList)/sizeof(gInitRD_FileList[0]);
+
+EOF;
+
+
$fp = fopen($gOutputFile, "w");
fputs($fp, $gOutput);
fclose($fp);
// === IMPORTS ==
extern tVFS_Node gInitRD_RootNode;
+extern const int giInitRD_NumFiles;
+extern tVFS_Node * const gInitRD_FileList[];
// === PROTOTYPES ===
int InitRD_Install(char **Arguments);
tVFS_Node *InitRD_InitDevice(const char *Device, const char **Arguments);
void InitRD_Unmount(tVFS_Node *Node);
+tVFS_Node *InitRD_GetNodeFromINode(tVFS_Node *Root, Uint64 Inode);
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, const char *Name);
// === GLOBALS ===
MODULE_DEFINE(0, 0x0A, FS_InitRD, InitRD_Install, NULL);
tVFS_Driver gInitRD_FSInfo = {
- "initrd", 0, InitRD_InitDevice, InitRD_Unmount, NULL
+ "initrd", 0, InitRD_InitDevice, InitRD_Unmount, InitRD_GetNodeFromINode
};
/**
{
}
+/**
+ */
+tVFS_Node *InitRD_GetNodeFromINode(tVFS_Node *Root, Uint64 Inode)
+{
+ if( Inode >= giInitRD_NumFiles ) return NULL;
+ return gInitRD_FileList[Inode];
+}
+
/**
* \brief Read from a file
*/