diff --git a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp index 92417673..8d0505b5 100644 --- a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp +++ b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp @@ -315,7 +315,7 @@ Error FileStoreTemplate::remove(uint64_t id) { template Error FileStoreTemplate::read(uint64_t id, void *out, FsSize_t outSize, FsSize_t *size) const { - oxTracef("ox.fs.FileStoreTemplate.read", "Attempting to read from inode {}", id); + oxTracef("ox.fs.FileStoreTemplate.read", "Attempting to read inode {}", id); auto src = find(static_cast(id)); // error check if (!src.valid()) { @@ -333,7 +333,7 @@ Error FileStoreTemplate::read(uint64_t id, void *out, FsSize_t outSize, oxTracef("ox.fs.FileStoreTemplate.read.fail", "Could not read data section of item: {}", id); oxTracef("ox.fs.FileStoreTemplate.read.fail", "Item data section size: {}, Expected size: {}", srcData.size(), outSize); - return OxError(1); + return OxError(1, "Invalid inode"); } ox::memcpy(out, srcData, srcData.size()); @@ -341,7 +341,7 @@ Error FileStoreTemplate::read(uint64_t id, void *out, FsSize_t outSize, *size = src.size(); } - return OxError(0); + return {}; } template diff --git a/deps/ox/src/ox/fs/filesystem/directory.hpp b/deps/ox/src/ox/fs/filesystem/directory.hpp index da89322a..dd03c6ab 100644 --- a/deps/ox/src/ox/fs/filesystem/directory.hpp +++ b/deps/ox/src/ox/fs/filesystem/directory.hpp @@ -44,6 +44,7 @@ struct OX_PACKED DirectoryEntry { constexpr DirectoryEntry() noexcept = default; Error init(InodeId_t inode, ox::CRStringView name, size_t bufferSize) noexcept { + oxTracef("ox.fs.DirectoryEntry.init", "inode: {}, name: {}, bufferSize: {}", inode, name, bufferSize); m_bufferSize = static_cast(bufferSize); auto d = data(); if (d.valid()) { @@ -190,10 +191,10 @@ template Error Directory::write(PathIterator path, uint64_t inode64) noexcept { const auto inode = static_cast(inode64); ox::StringView name; - oxReturnError(path.next(name)); if (path.next().hasNext()) { // not yet at target directory, recurse to next one oxTracef("ox.fs.Directory.write", "Attempting to write to next sub-Directory: {} of {}", name, path.fullPath()); + oxReturnError(path.get(name)); oxRequire(nextChild, findEntry(name)); oxTracef("ox.fs.Directory.write", "{}: {}", name, nextChild); if (nextChild) { @@ -204,6 +205,7 @@ Error Directory::write(PathIterator path, uint64_t inode64 } } else { oxTrace("ox.fs.Directory.write", path.fullPath()); + oxReturnError(path.next(name)); // insert the new entry on this directory // get the name // find existing version of directory diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.hpp b/deps/ox/src/ox/fs/filesystem/filesystem.hpp index c39f556d..ebe98d00 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.hpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.hpp @@ -323,6 +323,7 @@ Error FileSystemTemplate::move(CRStringView src, CRStringV template Error FileSystemTemplate::readFilePath(CRStringView path, void *buffer, std::size_t buffSize) noexcept { + oxTrace("ox.fs.FileSystemTemplate.readFilePath", path); oxRequire(fd, fileSystemData()); Directory rootDir(m_fs, fd.rootDirInode); oxRequire(s, stat(path)); @@ -342,6 +343,7 @@ Result FileSystemTemplate::directAccessPath(C template Error FileSystemTemplate::readFileInode(uint64_t inode, void *buffer, std::size_t buffSize) noexcept { + oxTracef("ox.fs.FileSystemTemplate.readFileInode", "{}", inode); oxRequire(s, stat(inode)); if (s.size > buffSize) { return OxError(1, "Buffer to small to load file"); @@ -409,24 +411,29 @@ Error FileSystemTemplate::resize() noexcept { template Error FileSystemTemplate::resize(uint64_t size, void *buffer) noexcept { oxReturnError(m_fs.resize(static_cast(size), buffer)); - return OxError(0); + return {}; } template -Error FileSystemTemplate::writeFilePath(CRStringView path, const void *buffer, uint64_t size, FileType fileType) noexcept { +Error FileSystemTemplate::writeFilePath( + CRStringView path, + const void *buffer, + uint64_t size, + FileType fileType) noexcept { + oxTrace("ox.fs.FileSystemTemplate.writeFilePath", path); auto [inode, err] = find(path); if (err) { - oxRequire(generatedId, m_fs.generateInodeId()); - inode = generatedId; + oxReturnError(m_fs.generateInodeId().moveTo(inode)); oxRequireM(rootDir, this->rootDir()); oxReturnError(rootDir.write(path, inode)); } oxReturnError(writeFileInode(inode, buffer, size, fileType)); - return OxError(0); + return {}; } template Error FileSystemTemplate::writeFileInode(uint64_t inode, const void *buffer, uint64_t size, FileType fileType) noexcept { + oxTrace("ox.fs.FileSystemTemplate.writeFileInode", ox::itoa(inode)); return m_fs.write(inode, buffer, static_cast(size), static_cast(fileType)); } diff --git a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp index 57c08185..91bff12d 100644 --- a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp +++ b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp @@ -100,7 +100,6 @@ Result PassThroughFS::statPath(CRStringView path) const noexcept { FileType::Directory : FileType::NormalFile; oxTracef("ox.fs.PassThroughFS.statInode", "{} {}", ec.message(), path); const uint64_t size = type == FileType::Directory ? 0 : std::filesystem::file_size(p, ec); - oxTracef("ox.fs.PassThroughFS.statInode", "{} {}", ec.message(), path); oxTracef("ox.fs.PassThroughFS.statInode.size", "{} {}", path, size); oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: stat failed")); return FileStat{0, 0, size, type}; diff --git a/deps/ox/src/ox/fs/filesystem/pathiterator.hpp b/deps/ox/src/ox/fs/filesystem/pathiterator.hpp index 2c7c88ad..e2047c76 100644 --- a/deps/ox/src/ox/fs/filesystem/pathiterator.hpp +++ b/deps/ox/src/ox/fs/filesystem/pathiterator.hpp @@ -29,8 +29,6 @@ class PathIterator { Error dirPath(char *pathOut, std::size_t pathOutSize); - Error fileName(char *out, std::size_t outSize); - Error next(StringView &fileName); Error get(StringView &fileName); diff --git a/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp b/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp index b7d2f2d0..e09f8371 100644 --- a/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp +++ b/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp @@ -174,7 +174,7 @@ template NodeBuffer::NodeBuffer(std::size_t size) noexcept { m_header.size = static_cast(size); ox::memset(this + 1, 0, size - sizeof(*this)); - oxTracef("ox.NodeBuffer.constructor", "{}", m_header.firstItem.get()); + oxTracef("ox.ptrarith.NodeBuffer.constructor", "{}", m_header.firstItem.get()); } template diff --git a/deps/ox/src/ox/fs/ptrarith/ptr.hpp b/deps/ox/src/ox/fs/ptrarith/ptr.hpp index 31b00854..99940050 100644 --- a/deps/ox/src/ox/fs/ptrarith/ptr.hpp +++ b/deps/ox/src/ox/fs/ptrarith/ptr.hpp @@ -224,7 +224,7 @@ constexpr const Ptr Ptr::subPtr(s template template constexpr const Ptr Ptr::subPtr(size_t offset) const noexcept { - oxTracef("ox.fs.Ptr.subPtr", "{} {} {} {} {}", m_itemOffset, this->size(), offset, m_itemSize, (m_itemSize - offset)); + oxTracef("ox.ptrarith.Ptr.subPtr", "{} {} {} {} {}", m_itemOffset, this->size(), offset, m_itemSize, (m_itemSize - offset)); return subPtr(offset, m_itemSize - offset); } @@ -237,7 +237,7 @@ constexpr Ptr Ptr::subPtr(size_t template template constexpr Ptr Ptr::subPtr(size_t offset) noexcept { - oxTracef("ox.fs.Ptr.subPtr", "{} {} {} {} {}", m_itemOffset, this->size(), offset, m_itemSize, (m_itemSize - offset)); + oxTracef("ox.ptrarith.Ptr.subPtr", "{} {} {} {} {}", m_itemOffset, this->size(), offset, m_itemSize, (m_itemSize - offset)); return subPtr(offset, m_itemSize - offset); }