fix: distinct fake inodes for directories in stat()

stat() synthesized path-hash inodes for regular files but left
st_ino = 0 for directories. GCC's include-path setup deduplicates
directories by (st_dev, st_ino), so every directory on MontaukOS
compared equal and cc1plus silently dropped all C++ include dirs
except the first - <iostream> resolved but the target-specific
bits/c++config.h directory was gone. Directories now get the same
path-hash inodes as files. (Different spellings of one directory
hash differently; the harmless direction - a dir may be searched
twice, never dropped.)

Native GCC relinked against the fixed libc.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
2026-07-17 10:51:05 +02:00
co-authored by Claude Fable 5
parent 1c851a3627
commit 6b88db35f2
3 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once
#define MONTAUK_BUILD_NUMBER 25
#define MONTAUK_BUILD_NUMBER 26
+10
View File
@@ -2305,6 +2305,16 @@ int stat(const char *path, struct stat *buf) {
if (_path_is_directory(path)) {
buf->st_mode = S_IFDIR;
buf->st_size = 0;
/* Directories need distinct fake inodes too: GCC's include
path setup deduplicates directories by (st_dev, st_ino), so
leaving 0 here made every directory "the same" and all but
one include dir was silently dropped. */
unsigned long ino = 5381;
for (const char *p = path; *p; p++) {
ino = ino * 33 + (unsigned char)*p;
}
buf->st_ino = ino | 1;
buf->st_nlink = 1;
return 0;
}
Binary file not shown.