43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
/*
|
|
* Ramdisk.hpp
|
|
* USTAR tar-based ramdisk filesystem backed by Limine modules
|
|
* Copyright (c) 2025 Daniel Hammer
|
|
*/
|
|
|
|
#pragma once
|
|
#include <cstdint>
|
|
#include <cstddef>
|
|
|
|
namespace Fs::Ramdisk {
|
|
|
|
static constexpr int MaxFiles = 512;
|
|
static constexpr int MaxNameLen = 100;
|
|
|
|
struct FileEntry {
|
|
char name[MaxNameLen];
|
|
uint8_t* data;
|
|
uint64_t size;
|
|
uint64_t capacity;
|
|
bool isDirectory;
|
|
bool heapAllocated;
|
|
};
|
|
|
|
void Initialize(void* moduleData, uint64_t moduleSize);
|
|
|
|
int Open(const char* path);
|
|
int Read(int handle, uint8_t* buffer, uint64_t offset, uint64_t size);
|
|
int Write(int handle, const uint8_t* buffer, uint64_t offset, uint64_t size);
|
|
int Create(const char* path);
|
|
uint64_t GetSize(int handle);
|
|
void Close(int handle);
|
|
|
|
int ReadDir(const char* path, const char** outNames, int maxEntries);
|
|
int ReadDirAt(const char* path, const char** outNames, int maxEntries, int startIndex);
|
|
int Delete(const char* path);
|
|
int Mkdir(const char* path);
|
|
int Rename(const char* oldPath, const char* newPath);
|
|
const char* GetLabel();
|
|
int GetFileCount();
|
|
|
|
}
|