From f3514075a1774176c04c756270085c624d167db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 18 Aug 2003 02:08:58 +0000 Subject: [PATCH] opendir() did not correctly set "errno" if sys_open_dir() failed. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4297 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/unistd/directory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/kernel/libroot/posix/unistd/directory.c b/src/kernel/libroot/posix/unistd/directory.c index a24ee01635..d57dfc70c4 100644 --- a/src/kernel/libroot/posix/unistd/directory.c +++ b/src/kernel/libroot/posix/unistd/directory.c @@ -30,11 +30,13 @@ opendir(const char *path) DIR *dir; int fd = sys_open_dir(path); - if (fd < 0) + if (fd < 0) { + errno = fd; return NULL; + } /* allocate the memory for the DIR structure */ - if ((dir = (DIR*)malloc(sizeof(DIR) + BUFFER_SIZE)) == NULL) { + if ((dir = (DIR *)malloc(sizeof(DIR) + BUFFER_SIZE)) == NULL) { errno = B_NO_MEMORY; sys_close(fd); return NULL;