summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/src/FS/NeFS.cc
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-12-29 09:57:48 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-12-29 09:57:48 +0100
commit8b7216aaf2dacad7ce67d734d07b047fed8ec01e (patch)
tree7af56dd646a4d12a25024da7ad5e6406ff98f124 /dev/Kernel/src/FS/NeFS.cc
parent5b1bb6cc086047e99a1d246fd2d337bf76887bd8 (diff)
IMPL: NeFS: Add file lock feature and validation for it.
- It is added to hide files from indexing. - And will be used to hide system files. IMPL: Swap: Add SwapDiskDelegate class, will also work on a swap packet structure. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/src/FS/NeFS.cc')
-rw-r--r--dev/Kernel/src/FS/NeFS.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/dev/Kernel/src/FS/NeFS.cc b/dev/Kernel/src/FS/NeFS.cc
index 27a027cd..bf39f7e6 100644
--- a/dev/Kernel/src/FS/NeFS.cc
+++ b/dev/Kernel/src/FS/NeFS.cc
@@ -720,7 +720,8 @@ bool NeFileSystemParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog
/// @param catalog_name the catalog name.
/// @return the newly found catalog.
_Output NFS_CATALOG_STRUCT* NeFileSystemParser::FindCatalog(_Input const Char* catalog_name,
- Lba& out_lba)
+ Lba& out_lba,
+ Bool search_hidden)
{
if (!catalog_name ||
*catalog_name == 0)
@@ -798,7 +799,7 @@ _Output NFS_CATALOG_STRUCT* NeFileSystemParser::FindCatalog(_Input const Char* c
}
}
- kcout << "Fetching catalog...\r";
+ kcout << "Finding catalog...\r";
NeFSSearchThroughCatalogList:
while (drive.fPacket.fPacketGood)
@@ -813,6 +814,14 @@ NeFSSearchThroughCatalogList:
if (StringBuilder::Equals(catalog_name, catalog->Name))
{
+ /// ignore it, it's locked.
+ if (catalog->Status == kNeFSStatusLocked &&
+ !search_hidden)
+ {
+ err_local_get() = kErrorFileLocked;
+ goto NeFSContinueSearch;
+ }
+
/// ignore unallocated catalog, break
if (!(catalog->Flags & kNeFSFlagCreated))
{
@@ -822,8 +831,8 @@ NeFSSearchThroughCatalogList:
NFS_CATALOG_STRUCT* catalogPtr = new NFS_CATALOG_STRUCT();
rt_copy_memory(catalog, catalogPtr, sizeof(NFS_CATALOG_STRUCT));
- kcout << "Found catalog at: " << hex_number(start_catalog_lba) << endl;
- kcout << "Found catalog at: " << catalog->Name << endl;
+ kcout << "Found available catalog at: " << hex_number(start_catalog_lba) << endl;
+ kcout << "Found available catalog at: " << catalog->Name << endl;
out_lba = start_catalog_lba;
return catalogPtr;
@@ -844,6 +853,8 @@ NeFSSearchThroughCatalogList:
goto NeFSSearchThroughCatalogList;
}
+ err_local_get() = kErrorFileNotFound;
+
out_lba = 0UL;
return nullptr;
}
@@ -854,7 +865,7 @@ NeFSSearchThroughCatalogList:
_Output NFS_CATALOG_STRUCT* NeFileSystemParser::GetCatalog(_Input const Char* name)
{
Lba unused = 0;
- return this->FindCatalog(name, unused);
+ return this->FindCatalog(name, unused, true);
}
/// @brief Closes a catalog, (frees it).
@@ -923,6 +934,8 @@ Boolean NeFileSystemParser::RemoveCatalog(_Input const Char* catalog_name)
}
delete catalog;
+ catalog = nullptr;
+
return false;
}