summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-01 09:41:25 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-01 09:41:25 +0200
commit9e4a472c109d91ae9550b9474425ce16e081894b (patch)
tree9acdadaee3deefa74fb0bfd17cbec308ef2d4a33
parent8ee087a640c2ecf592555457f38ff152bd2f2d2e (diff)
IMP: NewFS: Update ErrLocal if file we want to create exists.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
-rw-r--r--Comm/herror.hxx12
-rw-r--r--Kernel/KernelKit/HError.hpp2
-rw-r--r--Kernel/KernelKit/PermissionSelector.hxx10
-rw-r--r--Kernel/Sources/FS/NewFS.cxx15
4 files changed, 23 insertions, 16 deletions
diff --git a/Comm/herror.hxx b/Comm/herror.hxx
index bad6f50c..1115e357 100644
--- a/Comm/herror.hxx
+++ b/Comm/herror.hxx
@@ -8,15 +8,19 @@
#include <Comm/newstd.hxx>
-#define ErrLocalIsOk() (kLastError == kErrorSuccess)
-#define ErrLocalFailed() (kLastError != kErrorSuccess)
-#define ErrLocal() kLastError
+#ifdef __KERNEL__
+#error !!! including header in kernel mode !!!
+#endif // __KERNEL__
+
+#define ErrLocalIsOk() (kLastError == kErrorSuccess)
+#define ErrLocalFailed() (kLastError != kErrorSuccess)
+#define ErrLocal() (kLastError)
typedef SInt32 HError;
inline constexpr HError kErrorSuccess = 0;
inline constexpr HError kErrorExecutable = 33;
-inline constexpr HError kErrorExecutableLib = 34; // no such library!!!
+inline constexpr HError kErrorExecutableLib = 34;
inline constexpr HError kErrorFileNotFound = 35;
inline constexpr HError kErrorDirectoryNotFound = 36;
inline constexpr HError kErrorDiskReadOnly = 37;
diff --git a/Kernel/KernelKit/HError.hpp b/Kernel/KernelKit/HError.hpp
index e893f938..4a2bfa0b 100644
--- a/Kernel/KernelKit/HError.hpp
+++ b/Kernel/KernelKit/HError.hpp
@@ -21,7 +21,7 @@ namespace NewOS
inline constexpr HError kErrorSuccess = 0;
inline constexpr HError kErrorExecutable = 33;
- inline constexpr HError kErrorExecutableLib = 34; // no such library!!!
+ inline constexpr HError kErrorExecutableLib = 34;
inline constexpr HError kErrorFileNotFound = 35;
inline constexpr HError kErrorDirectoryNotFound = 36;
inline constexpr HError kErrorDiskReadOnly = 37;
diff --git a/Kernel/KernelKit/PermissionSelector.hxx b/Kernel/KernelKit/PermissionSelector.hxx
index 5745344c..1d972154 100644
--- a/Kernel/KernelKit/PermissionSelector.hxx
+++ b/Kernel/KernelKit/PermissionSelector.hxx
@@ -1,16 +1,16 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
-#ifndef _INC_PERMISSION_SEL_HPP
-#define _INC_PERMISSION_SEL_HPP
+#ifndef _INC_PERMISSION_SEL_HXX_
+#define _INC_PERMISSION_SEL_HXX_
#include <CompilerKit/CompilerKit.hxx>
#include <NewKit/Defines.hpp>
-// kernel mode user.
+// super admin mode user.
#define kMachineUser "Machine"
// user mode users.
@@ -54,4 +54,4 @@ namespace NewOS
};
} // namespace NewOS
-#endif /* ifndef _INC_PERMISSION_SEL_HPP */
+#endif /* ifndef _INC_PERMISSION_SEL_HXX_ */
diff --git a/Kernel/Sources/FS/NewFS.cxx b/Kernel/Sources/FS/NewFS.cxx
index 63aa598e..20451f96 100644
--- a/Kernel/Sources/FS/NewFS.cxx
+++ b/Kernel/Sources/FS/NewFS.cxx
@@ -226,14 +226,17 @@ _Output NewCatalog* NewFSParser::CreateCatalog(_Input const char* name,
name[rt_string_len(name) - 1] == NewFilesystemHelper::Separator())
return nullptr;
- NewCatalog* checkForCpy = this->FindCatalog(name, outLba);
+ NewCatalog* copyExists = this->FindCatalog(name, outLba);
- if (checkForCpy)
+ if (copyExists)
{
- return checkForCpy;
+ kcout << "newoskrnl: copy already exists.\r";
+ ErrLocal() = kErrorFileExists;
+
+ return copyExists;
}
- char parentName[kNewFSNodeNameLen] = {0};
+ Char parentName[kNewFSNodeNameLen] = {0};
for (SizeT indexName = 0UL; indexName < rt_string_len(name); ++indexName)
{
@@ -255,10 +258,10 @@ _Output NewCatalog* NewFSParser::CreateCatalog(_Input const char* name,
SizeT indexReverseCopy = rt_string_len(parentName);
- // zero character.
+ // zero character it.
parentName[--indexReverseCopy] = 0;
- // mandatory / character.
+ // mandatory / character, zero it.
parentName[--indexReverseCopy] = 0;
while (parentName[indexReverseCopy] != NewFilesystemHelper::Separator())