mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Update ustar functions
This commit is contained in:
parent
fedccbfd79
commit
3d93f9d919
@ -76,15 +76,29 @@ namespace VirtualFileSystem
|
||||
.Seek = USTAR_Seek,
|
||||
};
|
||||
|
||||
USTAR::USTAR(uintptr_t Address, Virtual *vfs_ctx)
|
||||
bool USTAR::TestArchive(uintptr_t Address)
|
||||
{
|
||||
trace("Initializing USTAR with address %#llx", Address);
|
||||
if (!Memory::Virtual().Check((void *)Address))
|
||||
{
|
||||
error("Address %#lx is not mapped!", Address);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memcmp(((FileHeader *)(uintptr_t)Address)->signature, "ustar", 5) != 0)
|
||||
{
|
||||
error("ustar signature invalid!");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void USTAR::ReadArchive(uintptr_t Address, Virtual *vfs_ctx)
|
||||
{
|
||||
trace("Initializing USTAR with address %#llx", Address);
|
||||
|
||||
if (!this->TestArchive(Address))
|
||||
return; /* Check whether the archive is deflated */
|
||||
|
||||
debug("USTAR signature valid! Name:%s Signature:%s Mode:%c Size:%lu",
|
||||
((FileHeader *)Address)->name,
|
||||
((FileHeader *)Address)->signature,
|
||||
@ -168,5 +182,7 @@ namespace VirtualFileSystem
|
||||
}
|
||||
}
|
||||
|
||||
USTAR::~USTAR() { warn("Destroyed"); }
|
||||
USTAR::USTAR() {}
|
||||
|
||||
USTAR::~USTAR() {}
|
||||
}
|
||||
|
@ -412,7 +412,11 @@ EXTERNC NIF void Main()
|
||||
debug("Found initrd at %p", bInfo.Modules[i].Address);
|
||||
static char initrd = 0;
|
||||
if (!initrd++)
|
||||
new VirtualFileSystem::USTAR((uintptr_t)bInfo.Modules[i].Address, vfs);
|
||||
{
|
||||
uintptr_t initrdAddress = (uintptr_t)bInfo.Modules[i].Address;
|
||||
VirtualFileSystem::USTAR *ustar = new VirtualFileSystem::USTAR;
|
||||
ustar->ReadArchive(initrdAddress, vfs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,9 @@ namespace VirtualFileSystem
|
||||
}
|
||||
|
||||
public:
|
||||
USTAR(uintptr_t Address, Virtual *vfs_ctx);
|
||||
bool TestArchive(uintptr_t Address);
|
||||
void ReadArchive(uintptr_t Address, Virtual *vfs_ctx);
|
||||
USTAR();
|
||||
~USTAR();
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user