feat: Rust std target + ruststd tests; SYS_EXIT_GROUP; fix mkdir/create under missing parent
This commit is contained in:
1 parent
9e66c3b249
commit
e87bd358a6
20 files changed
+657
-97
No files matched your search
@@ -89,6 +89,20 @@ namespace Fs::Ramdisk {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Mkdir/Create must not conjure entries under a missing parent: the
|
||||
// table is flat, so "a/b/" with no "a/" entry is invisible to ReadDir of
|
||||
// the parent and makes "a" fail Stat, Delete and recursive removal.
|
||||
static bool ParentExists(const char* path) {
|
||||
char normalized[MaxNameLen];
|
||||
int len = NormalizePath(path, normalized, MaxNameLen);
|
||||
if (len < 0) return false;
|
||||
while (len > 0 && normalized[len - 1] != '/') len--;
|
||||
if (len <= 1) return true; // parent is the root
|
||||
normalized[len - 1] = '\0';
|
||||
int idx = FindEntryByPath(normalized);
|
||||
return idx >= 0 && fileTable[idx].isDirectory;
|
||||
}
|
||||
|
||||
void Initialize(void* moduleData, uint64_t moduleSize) {
|
||||
Kt::KernelLogStream(Kt::OK, "Ramdisk") << "Parsing USTAR archive (" << moduleSize << " bytes)";
|
||||
|
||||
@@ -442,6 +456,8 @@ namespace Fs::Ramdisk {
|
||||
}
|
||||
}
|
||||
|
||||
if (!ParentExists(path)) return -1;
|
||||
|
||||
// Create new file entry
|
||||
FileEntry& entry = fileTable[fileCount];
|
||||
|
||||
@@ -531,6 +547,8 @@ namespace Fs::Ramdisk {
|
||||
}
|
||||
}
|
||||
|
||||
if (!ParentExists(path)) return -1;
|
||||
|
||||
// Create directory entry (stored with trailing slash for tar convention)
|
||||
FileEntry& entry = fileTable[fileCount];
|
||||
|
||||
|
||||
Reference in new issue
Block a user