fix(libc): map directory symlink loop errors

(cherry picked from commit d5e348c7b6846b2cd2cb5d1ecad9ad3493462047)
This commit is contained in:
MarcZX100 2026-10-08 00:24:53 +00:00
parent df6b831400
commit c96100aff1
2 changed files with 10 additions and 0 deletions

View File

@ -17,6 +17,9 @@ int DirectoryError(int error) {
case ENFILE: return 23;
case ENOMEM: return 12;
case ENAMETOOLONG: return 63;
#ifdef ELOOP
case ELOOP: return 62;
#endif
default: return 5;
}
}

View File

@ -42,6 +42,13 @@ int main() {
Require(closedir_nid_postfix(directory) == 0);
Require(opendir_nid_postfix((root / "missing").string().c_str()) == nullptr);
Require(*__error_nid_postfix() == 2);
#ifndef _WIN32
const auto symlinkLoop = root / "symlink-loop";
std::filesystem::create_symlink("symlink-loop", symlinkLoop);
Require(opendir_nid_postfix(symlinkLoop.string().c_str()) == nullptr);
Require(*__error_nid_postfix() == 62);
Require(std::filesystem::remove(symlinkLoop));
#endif
Require(opendir_nid_postfix((root / "sample.txt").string().c_str()) == nullptr);
Require(*__error_nid_postfix() == 20);
Require(opendir_nid_postfix("") == nullptr && *__error_nid_postfix() == 2);