Add a way to initialize VFS globals.

This is needed since the kernel loader doesn't even zero out bss,
much less call any static constructors.
This commit is contained in:
Andreas Kling 2018-10-19 11:20:49 +02:00
parent 97e0d75bcb
commit 2d1d01661b
Notes: sideshowbarker 2024-07-19 18:46:13 +09:00
4 changed files with 16 additions and 2 deletions

View file

@ -2,16 +2,22 @@
#include <AK/HashMap.h>
#include "FileSystem.h"
static dword s_lastFileSystemID = 0;
static dword s_lastFileSystemID;
static HashMap<dword, FileSystem*>* map;
static HashMap<dword, FileSystem*>& fileSystems()
{
static HashMap<dword, FileSystem*>* map;
if (!map)
map = new HashMap<dword, FileSystem*>();
return *map;
}
void FileSystem::initializeGlobals()
{
s_lastFileSystemID = 0;
map = 0;
}
FileSystem::FileSystem()
: m_id(++s_lastFileSystemID)
{

View file

@ -18,6 +18,7 @@ static const dword mepoch = 476763780;
class FileSystem : public Retainable<FileSystem> {
public:
static void initializeGlobals();
virtual ~FileSystem();
dword id() const { return m_id; }

View file

@ -7,6 +7,11 @@
//#define VFS_DEBUG
void VirtualFileSystem::initializeGlobals()
{
FileSystem::initializeGlobals();
}
static dword encodedDevice(unsigned major, unsigned minor)
{
return (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);

View file

@ -14,6 +14,8 @@ class FileSystem;
class VirtualFileSystem {
public:
static void initializeGlobals();
struct Node {
InodeIdentifier inode;