diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-04-02 07:04:53 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-04-02 07:04:53 +0200 |
| commit | f0811b1e200293c5ccc387d866d0ad49a41bba17 (patch) | |
| tree | a31adbc1d14465e08088a98f1b4b8ebd0936db16 /Private/Source/FileManager.cxx | |
| parent | d445096b8403ad0bdbf0095c50f66ba01fde9f33 (diff) | |
Kernel: New commit, see below.
- Implement FileManager's NewFilesystemManager.
- Add ATA-DMA and ATA-PIO APIs.
- Add the two raw call (fs_newfs_read_raw, fs_newfs_write_raw) to the
NewFS API.
- Add kPRDTTransferStatus to tell if PRD is in use.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Private/Source/FileManager.cxx')
| -rw-r--r-- | Private/Source/FileManager.cxx | 85 |
1 files changed, 84 insertions, 1 deletions
diff --git a/Private/Source/FileManager.cxx b/Private/Source/FileManager.cxx index bbe7d30b..4d3c7d32 100644 --- a/Private/Source/FileManager.cxx +++ b/Private/Source/FileManager.cxx @@ -16,7 +16,9 @@ static FilesystemManagerInterface* kMounted = nullptr; /// @brief FilesystemManager getter. /// @return The mounted filesystem. -FilesystemManagerInterface* FilesystemManagerInterface::GetMounted() { return kMounted; } +FilesystemManagerInterface* FilesystemManagerInterface::GetMounted() { + return kMounted; +} /// @brief Unmount filesystem. /// @return the unmounted filesystem. @@ -42,4 +44,85 @@ bool FilesystemManagerInterface::Mount(FilesystemManagerInterface* mountPtr) { return false; } + +#ifdef __FSKIT_NEWFS__ +/// @brief Opens a new file. +/// @param path +/// @param r +/// @return +NodePtr NewFilesystemManager::Open(const char* path, const char* r) { + if (!path || *path == 0) return nullptr; + + if (!r || *r == 0) return nullptr; + + auto catalog = fImpl->GetCatalog(path); + + if (catalog->Kind != kNewFSCatalogKindFile) { + fImpl->CloseCatalog(catalog); + return nullptr; + } + + return node_cast(catalog); +} + +/// @brief Writes to a catalog +/// @param node +/// @param data +/// @param flags +/// @return +Void NewFilesystemManager::Write(NodePtr node, VoidPtr data, + Int32 flags) { + if ((reinterpret_cast<NewCatalog*>(node))->Kind == kNewFSCatalogKindFile) + fImpl->WriteCatalog(reinterpret_cast<NewCatalog*>(node), data); +} + +/** + * NOTE: Write and Read are implemented using a custom NodePtr, retrieved + * using OpenFork. + */ + +/// @brief Reads from filesystem. +/// @param node +/// @param flags +/// @param sz +/// @return +VoidPtr NewFilesystemManager::Read(NodePtr node, Int32 flags, SizeT sz) { + if ((reinterpret_cast<NewCatalog*>(node))->Kind == kNewFSCatalogKindFile) + return fImpl->ReadCatalog(reinterpret_cast<NewCatalog*>(node), sz); + + return nullptr; +} + +/// @brief Seek from Catalog. +/// @param node +/// @param off +/// @return +bool NewFilesystemManager::Seek(NodePtr node, SizeT off) { + if (!node || off == 0) return false; + + return fImpl->Seek(reinterpret_cast<NewCatalog*>(node), off); +} + +/// @brief Tell where the catalog is/ +/// @param node +/// @return +SizeT NewFilesystemManager::Tell(NodePtr node) { + if (!node) return kNPos; + + return fImpl->Tell(reinterpret_cast<NewCatalog*>(node)); +} + +/// @brief Rewind the catalog. +/// @param node +/// @return +bool NewFilesystemManager::Rewind(NodePtr node) { + if (!node) return false; + + return this->Seek(node, 0); +} + +/// @brief The filesystem implementation. +/// @return +NewFSParser* NewFilesystemManager::GetImpl() noexcept { return fImpl; } +#endif // __FSKIT_NEWFS__ } // namespace NewOS |
