[ox] Add a new oxfs tool

This commit is contained in:
2022-01-28 01:22:37 -06:00
parent df782129bb
commit 2be5b0f6bc
5 changed files with 114 additions and 6 deletions

View File

@@ -41,9 +41,9 @@ struct OX_PACKED DirectoryEntry {
LittleEndian<InodeId_t> m_bufferSize = sizeof(DirectoryEntry);
public:
DirectoryEntry() = default;
constexpr DirectoryEntry() noexcept = default;
Error init(InodeId_t inode, const char *name, InodeId_t bufferSize) {
Error init(InodeId_t inode, const char *name, InodeId_t bufferSize) noexcept {
m_bufferSize = bufferSize;
auto d = data();
if (d.valid()) {
@@ -54,7 +54,7 @@ struct OX_PACKED DirectoryEntry {
return OxError(1);
}
ptrarith::Ptr<DirectoryEntryData, InodeId_t> data() {
ptrarith::Ptr<DirectoryEntryData, InodeId_t> data() noexcept {
oxTracef("ox::fs::DirectoryEntry::data", "{} {} {}", this->fullSize(), sizeof(*this), this->size());
return ptrarith::Ptr<DirectoryEntryData, InodeId_t>(this, this->fullSize(), sizeof(*this), this->size(), this->size());
}

View File

@@ -28,11 +28,9 @@ class FileAddress {
public:
static constexpr auto TypeName = "net.drinkingtea.ox.FileAddress";
static constexpr auto Fields = 2;
union Data {
static constexpr auto TypeName = "net.drinkingtea.ox.FileAddress.Data";
static constexpr auto Fields = 3;
char *path = nullptr;
const char *constPath;
uint64_t inode;

View File

@@ -18,6 +18,12 @@
namespace ox {
namespace detail {
static inline void fsBuffFree(char *buff) noexcept {
delete buff;
}
}
class FileSystem {
public:
@@ -111,7 +117,7 @@ class FileSystemTemplate: public FileSystem {
public:
FileSystemTemplate() noexcept = default;
FileSystemTemplate(void *buffer, uint64_t bufferSize, void(*freeBuffer)(char*) = [](const char *buff) { delete buff; }) noexcept;
FileSystemTemplate(void *buffer, uint64_t bufferSize, void(*freeBuffer)(char*) = detail::fsBuffFree) noexcept;
explicit FileSystemTemplate(FileStore fs) noexcept;