diff options
Diffstat (limited to 'Private/Source')
| -rw-r--r-- | Private/Source/CodeManager.cxx | 3 | ||||
| -rw-r--r-- | Private/Source/FileManager.cxx | 85 | ||||
| -rw-r--r-- | Private/Source/NewFS+IO.cxx | 13 | ||||
| -rw-r--r-- | Private/Source/ProcessTeam.cxx | 2 |
4 files changed, 89 insertions, 14 deletions
diff --git a/Private/Source/CodeManager.cxx b/Private/Source/CodeManager.cxx index db2a7017..b8725b98 100644 --- a/Private/Source/CodeManager.cxx +++ b/Private/Source/CodeManager.cxx @@ -11,8 +11,9 @@ using namespace NewOS; /// @brief Executes a new process from a function. kernel code only. +/// @note This sets up a new stack, anything on the main function that calls the kernel will not be accessible. /// @param main the start of the process. -/// @return +/// @return if the process was started or not. bool execute_from_image(MainKind main, const char* processName) noexcept { if (!main) return false; 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 diff --git a/Private/Source/NewFS+IO.cxx b/Private/Source/NewFS+IO.cxx index fb13362e..8264f7fa 100644 --- a/Private/Source/NewFS+IO.cxx +++ b/Private/Source/NewFS+IO.cxx @@ -29,21 +29,12 @@ using namespace NewOS; -enum { - kHCFSSubDriveA, - kHCFSSubDriveB, - kHCFSSubDriveC, - kHCFSSubDriveD, - kHCFSSubDriveInvalid, - kHCFSSubDriveCount, -}; - /// @brief Read from newfs disk. /// @param Mnt mounted interface. /// @param DrvTrait drive info /// @param DrvIndex drive index. /// @return -Int32 fs_newfs_read(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex) { +Int32 fs_newfs_read_raw(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex) { if (!Mnt) return -1; DrvTrait.fPacket.fPacketGood = false; @@ -75,7 +66,7 @@ Int32 fs_newfs_read(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvInd /// @param DrvTrait drive info /// @param DrvIndex drive index. /// @return -Int32 fs_newfs_write(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex) { +Int32 fs_newfs_write_raw(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex) { if (!Mnt) return -1; DrvTrait.fPacket.fPacketGood = false; diff --git a/Private/Source/ProcessTeam.cxx b/Private/Source/ProcessTeam.cxx index dbbcab24..df4cd55d 100644 --- a/Private/Source/ProcessTeam.cxx +++ b/Private/Source/ProcessTeam.cxx @@ -6,7 +6,7 @@ /***********************************************************************************/ /// @file ProcessTeam.cxx -/// @brief ProcessHeader Team API. +/// @brief Process Team API. /***********************************************************************************/ #include <KernelKit/ProcessScheduler.hpp> |
