From 9a0184dae5723488daf16c86ee8a3741cd70f894 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Sat, 10 Aug 2024 16:47:14 +0200 Subject: [IMP] Many fixes inside kernel DLL, fixing filesystem now. Signed-off-by: Amlal EL Mahrouss --- Boot/Sources/BootloaderRsrc.rsrc | 2 -- Boot/Sources/HEL/AMD64/BootATA.cxx | 3 --- Boot/Sources/HEL/AMD64/BootMain.cxx | 11 ++++++++++- CRTKit/__mpcc_alloca.hxx | 2 +- CRTKit/__mpcc_defines.hxx | 2 +- GXKit/build.json | 4 ++-- Icons/default.ico | Bin 4865 -> 0 bytes Kernel/HALKit/AMD64/HalKernelMain.cxx | 1 - Kernel/KernelKit/User.hxx | 2 +- Kernel/KernelRsrc.rsrc | 2 -- Kernel/Sources/FS/NewFS.cxx | 28 +++++++++++++++++++++++----- Kernel/Sources/FileManager.cxx | 8 ++++---- Kernel/Sources/NewFS+FileManager.cxx | 2 ++ Kernel/Sources/User.cxx | 12 ++++++++---- SCIKit/scm.iclparser.inl | 4 ++-- SCIKit/scm.internal.inl | 4 ++-- 16 files changed, 56 insertions(+), 31 deletions(-) delete mode 100644 Icons/default.ico diff --git a/Boot/Sources/BootloaderRsrc.rsrc b/Boot/Sources/BootloaderRsrc.rsrc index 2d2f8a8f..8751672e 100644 --- a/Boot/Sources/BootloaderRsrc.rsrc +++ b/Boot/Sources/BootloaderRsrc.rsrc @@ -1,7 +1,5 @@ #include "../../Kernel/CompilerKit/Version.hxx" -1 ICON "../../Icons/default.ico" - 1 VERSIONINFO FILEVERSION 1,0,0,0 PRODUCTVERSION 1,0,0,0 diff --git a/Boot/Sources/HEL/AMD64/BootATA.cxx b/Boot/Sources/HEL/AMD64/BootATA.cxx index 63956520..f671569a 100644 --- a/Boot/Sources/HEL/AMD64/BootATA.cxx +++ b/Boot/Sources/HEL/AMD64/BootATA.cxx @@ -252,9 +252,6 @@ BootDeviceATA& BootDeviceATA::Write(CharacterTypeUTF8* Buf, const SizeT& SectorS boot_ata_write(lba, this->Leak().mBus, this->Leak().mMaster, Buf, SectorSz, this->Leak().mSize); - BTextWriter writer; - writer.Write("OK\r"); - return *this; } diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx index 21db7823..f35c13ff 100644 --- a/Boot/Sources/HEL/AMD64/BootMain.cxx +++ b/Boot/Sources/HEL/AMD64/BootMain.cxx @@ -200,7 +200,16 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, if (!checkPart.IsPartitionValid()) { - writer.Write("newosldr: Warning, partition isn't valid! Need to repartition it.\r"); + writer.Write("newosldr: Warning, partition isn't valid! repaired it.\rPlease restart the computer now.\r"); + + BDiskFormatFactory::BFileDescriptor root; + root.fFileName[0] = kNewFSRoot[0]; + root.fFileName[1] = 0; + + root.fKind = kNewFSCatalogKindDir; + + checkPart.Format("NewOS (ZKA:)", &root, 1); + EFI::Stop(); } diff --git a/CRTKit/__mpcc_alloca.hxx b/CRTKit/__mpcc_alloca.hxx index 02b31230..cc123ac5 100644 --- a/CRTKit/__mpcc_alloca.hxx +++ b/CRTKit/__mpcc_alloca.hxx @@ -9,7 +9,7 @@ typedef void* ptr_type; typedef __SIZE_TYPE__ size_type; -inline void* __mpcc_alloca_gcc(size_type sz) +inline void* __mpcc_alloca(size_type sz) { return __builtin_alloca(sz); } diff --git a/CRTKit/__mpcc_defines.hxx b/CRTKit/__mpcc_defines.hxx index dbd20493..3047ef2b 100644 --- a/CRTKit/__mpcc_defines.hxx +++ b/CRTKit/__mpcc_defines.hxx @@ -29,7 +29,7 @@ typedef char* caddr_t; #ifdef __GNUC__ #include -#define __mpcc_alloca(sz) __mpcc_alloca_gcc(sz) +#define __mpcc_alloca(sz) __mpcc_alloca(sz) #elif defined(__NDK__) #define __alloca(sz) __mpcc_alloca(sz) diff --git a/GXKit/build.json b/GXKit/build.json index 284fb1b9..824c6b1d 100644 --- a/GXKit/build.json +++ b/GXKit/build.json @@ -2,9 +2,9 @@ "compiler_path": "x86_64-w64-mingw32-gcc", "compiler_std": "c++20", "headers_path": ["../", "./"], - "sources_path": ["*.c", "*.cxx", "*.S"], + "sources_path": ["*.c"], "output_name": "gx.dll", - "compiler_flags": ["-ffreestanding", "-shared", "-std=c17", "-std=c++20", "-fno-rtti", "-fno-exceptions", " -Wl,--subsystem=17"], + "compiler_flags": ["-ffreestanding", "-shared", "-std=c17", " -Wl,--subsystem=17"], "cpp_macros": ["__NEWOSKRNL__", "__DDK_AMD64__", "cGXVersionHighest=1", "cGXVersionLowest=1"] } \ No newline at end of file diff --git a/Icons/default.ico b/Icons/default.ico deleted file mode 100644 index 2ab3d5be..00000000 Binary files a/Icons/default.ico and /dev/null differ diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx index 495cb0be..01153c0e 100644 --- a/Kernel/HALKit/AMD64/HalKernelMain.cxx +++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx @@ -224,7 +224,6 @@ Kernel::Void hal_real_init(Kernel::Void) noexcept const auto cPassword = "password"; #endif - cRoot->TrySave(cPassword); Kernel::UserManager::The()->TryLogIn(cRoot, cPassword); diff --git a/Kernel/KernelKit/User.hxx b/Kernel/KernelKit/User.hxx index 169a8bce..ac0b2bb7 100644 --- a/Kernel/KernelKit/User.hxx +++ b/Kernel/KernelKit/User.hxx @@ -16,7 +16,7 @@ #define kSuperUser "\\Local\\Super" #define kGuestUser "\\Local\\Guest" -#define kUsersFile "\\Users\\$UserMTF" +#define kUsersFile "\\Users\\$MANIFEST" #define kMaxUserNameLen (255) #define kMaxUserTokenLen (4096) diff --git a/Kernel/KernelRsrc.rsrc b/Kernel/KernelRsrc.rsrc index 4cf7e352..113b2176 100644 --- a/Kernel/KernelRsrc.rsrc +++ b/Kernel/KernelRsrc.rsrc @@ -1,5 +1,3 @@ -1 ICON "../Icons/default.ico" - #include "CompilerKit/Version.hxx" 1 VERSIONINFO diff --git a/Kernel/Sources/FS/NewFS.cxx b/Kernel/Sources/FS/NewFS.cxx index 83c39e4b..a332576c 100644 --- a/Kernel/Sources/FS/NewFS.cxx +++ b/Kernel/Sources/FS/NewFS.cxx @@ -221,13 +221,13 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const char* name) /// @param flags the flags of the catalog. /// @param kind the catalog kind. /// @return catalog pointer. -_Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const char* name, +_Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const Char* name, _Input const Int32& flags, _Input const Int32& kind) { if (!sMountpointInterface.GetAddressOf(this->fDriveIndex)) return nullptr; - + Lba outLba = 0UL; /// a directory should have a slash in the end. @@ -610,10 +610,8 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL /// @param catalog the catalog itself /// @param data the data. /// @return if the catalog w rote the contents successfully. -bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, voidPtr data, SizeT sizeOfData, _Input const char* forkName) +bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, voidPtr data, SizeT sizeOfData, _Input const Char* forkName) { - if (sizeOfData > catalog->DataForkSize) - return false; if (!sMountpointInterface.GetAddressOf(this->fDriveIndex)) return false; @@ -656,6 +654,11 @@ bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, voidP StringBuilder::Equals(forkData->ForkName, forkName) && StringBuilder::Equals(forkData->CatalogName, catalog->Name)) { + // ===================================================== // + // Store size of blob now. + // ===================================================== // + forkData->DataSize = sizeOfData; + drive->fPacket.fPacketContent = data; drive->fPacket.fPacketSize = sizeOfData; drive->fPacket.fLba = forkData->DataOffset; @@ -670,6 +673,11 @@ bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, voidP else if (auto catalog = this->GetCatalog(forkData->CatalogName); catalog == nullptr) { + // ===================================================== // + // Store size of blob now. + // ===================================================== // + forkData->DataSize = sizeOfData; + delete catalog; drive->fPacket.fPacketContent = data; @@ -680,6 +688,16 @@ bool NewFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, voidP drive->fOutput(&drive->fPacket); + forkData->Flags = kNewFSFlagCreated; + + drive->fPacket.fPacketContent = forkData; + drive->fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT); + drive->fPacket.fLba = startFork; + + drive->fOutput(&drive->fPacket); + + kcout << "newoskrnl: wrote fork at offset: " << hex_number(forkData->DataOffset) << endl; + delete forkData; return true; } diff --git a/Kernel/Sources/FileManager.cxx b/Kernel/Sources/FileManager.cxx index 634e4fd6..96e42dc9 100644 --- a/Kernel/Sources/FileManager.cxx +++ b/Kernel/Sources/FileManager.cxx @@ -37,13 +37,13 @@ namespace Kernel } /// @brief Mount filesystem. - /// @param mountPtr The filesystem to mount. + /// @param mount_ptr The filesystem to mount. /// @return if it succeeded true, otherwise false. - bool FilesystemManagerInterface::Mount(_Input FilesystemManagerInterface* mountPtr) + bool FilesystemManagerInterface::Mount(_Input FilesystemManagerInterface* mount_ptr) { - if (kMounted == nullptr) + if (mount_ptr != nullptr) { - kMounted = mountPtr; + kMounted = mount_ptr; return true; } diff --git a/Kernel/Sources/NewFS+FileManager.cxx b/Kernel/Sources/NewFS+FileManager.cxx index b1622f77..3d216ca5 100644 --- a/Kernel/Sources/NewFS+FileManager.cxx +++ b/Kernel/Sources/NewFS+FileManager.cxx @@ -25,6 +25,8 @@ namespace Kernel NewFilesystemManager::~NewFilesystemManager() { + kcout << "Destroying it...\r"; + if (fImpl) { delete fImpl; diff --git a/Kernel/Sources/User.cxx b/Kernel/Sources/User.cxx index ee825400..028d184c 100644 --- a/Kernel/Sources/User.cxx +++ b/Kernel/Sources/User.cxx @@ -17,6 +17,9 @@ #include +#define cStdUser (0xCF) +#define cSuperUser (0xEF) + /// BUGS: 0 namespace Kernel @@ -34,7 +37,7 @@ namespace Kernel for (Size i_pass = 0; i_pass < rt_string_len(password); ++i_pass) { Char cur_chr = password[i_pass]; - password[i_pass] = cur_chr + (user->IsStdUser() ? 0xCF : 0xEF); + password[i_pass] = cur_chr + (user->IsStdUser() ? cStdUser : cSuperUser); } return 0; @@ -72,8 +75,9 @@ namespace Kernel if (NewFilesystemManager::GetMounted()) { - if (auto dir = NewFilesystemManager::GetMounted()->CreateDirectory("\\Users"); - dir) + auto dir = NewFilesystemManager::GetMounted()->CreateDirectory("\\Users\\"); + + if (dir) { delete dir; } @@ -84,7 +88,7 @@ namespace Kernel } auto node = NewFilesystemManager::GetMounted()->Create(kUsersFile); - NewFilesystemManager::GetMounted()->Write(this->fUserName.CData(), node, (VoidPtr)token, this->IsStdUser() ? 0xCF : 0xEF, len); + NewFilesystemManager::GetMounted()->Write(this->fUserName.CData(), node, (VoidPtr)token, this->IsStdUser() ? cStdUser : cSuperUser, len); delete node; delete token; diff --git a/SCIKit/scm.iclparser.inl b/SCIKit/scm.iclparser.inl index acedc9d8..5bed133f 100644 --- a/SCIKit/scm.iclparser.inl +++ b/SCIKit/scm.iclparser.inl @@ -9,10 +9,10 @@ Purpose: Base code of SCM. /// @internal -#ifndef __ZECC__ +#ifndef __NDK__ #define object class #define protocol class #define clsid(X) __attribute__((uuid(X))) #warning ! you may be using the clang version of the newos kit, please be cautious that some thing mayn't be present. ! -#endif // !__ZECC__ \ No newline at end of file +#endif // !__NDK__ \ No newline at end of file diff --git a/SCIKit/scm.internal.inl b/SCIKit/scm.internal.inl index e9c969f1..96210889 100644 --- a/SCIKit/scm.internal.inl +++ b/SCIKit/scm.internal.inl @@ -9,13 +9,13 @@ Purpose: Base code of SCM. /// @internal -#ifndef __ZECC__ +#ifndef __NDK__ #define object class #define protocol class #define clsid(X) __attribute__((uuid(X))) #warning ! you may be using the clang version of the newos kit, please be cautious that some thing mayn't be present. ! -#endif // !__ZECC__ +#endif // !__NDK__ // Interfaces are divided between classes. // So that they aren't too big. -- cgit v1.2.3