diff --git a/src/system/libroot/posix/dirent.c b/src/system/libroot/posix/dirent.c index 5db1f26275..b827ec134d 100644 --- a/src/system/libroot/posix/dirent.c +++ b/src/system/libroot/posix/dirent.c @@ -123,7 +123,10 @@ opendir(const char* path) int fd = _kern_open_dir(-1, path); if (fd < 0) { - errno = fd; + if (fd == B_BAD_VALUE) + errno = B_NOT_A_DIRECTORY; + else + errno = fd; return NULL; }