summaryrefslogtreecommitdiff
path: root/libc/misc/dirent
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/dirent')
-rw-r--r--libc/misc/dirent/closedir.c3
-rw-r--r--libc/misc/dirent/opendir.c12
2 files changed, 9 insertions, 6 deletions
diff --git a/libc/misc/dirent/closedir.c b/libc/misc/dirent/closedir.c
index cca03b8f7..dfb53f888 100644
--- a/libc/misc/dirent/closedir.c
+++ b/libc/misc/dirent/closedir.c
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <unistd.h>
#include "dirstream.h"
+#include <not-cancel.h>
int closedir(DIR * dir)
@@ -31,6 +32,6 @@ int closedir(DIR * dir)
__UCLIBC_MUTEX_UNLOCK(dir->dd_lock);
free(dir->dd_buf);
free(dir);
- return close(fd);
+ return close_not_cancel(fd);
}
libc_hidden_def(closedir)
diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c
index b43f60814..66a5cc9e9 100644
--- a/libc/misc/dirent/opendir.c
+++ b/libc/misc/dirent/opendir.c
@@ -12,6 +12,7 @@
#include <unistd.h>
#include <sys/dir.h>
#include <sys/stat.h>
+#include <not-cancel.h>
#include <dirent.h>
#include "dirstream.h"
@@ -34,7 +35,7 @@ static DIR *fd_to_DIR(int fd, __blksize_t size)
free(ptr);
return NULL;
}
- __pthread_mutex_init(&ptr->dd_lock, NULL);
+ __UCLIBC_MUTEX_INIT_VAR(ptr->dd_lock);
return ptr;
}
@@ -81,7 +82,7 @@ DIR *opendir(const char *name)
}
# define O_DIRECTORY 0
#endif
- fd = open(name, O_RDONLY|O_NDELAY|O_DIRECTORY|O_CLOEXEC);
+ fd = open_not_cancel_2(name, O_RDONLY|O_NDELAY|O_DIRECTORY|O_CLOEXEC);
if (fd < 0)
return NULL;
/* Note: we should check to make sure that between the stat() and open()
@@ -93,7 +94,7 @@ DIR *opendir(const char *name)
/* this close() never fails
*int saved_errno;
*saved_errno = errno; */
- close(fd);
+ close_not_cancel_no_status(fd);
/*__set_errno(saved_errno);*/
return NULL;
}
@@ -102,12 +103,13 @@ DIR *opendir(const char *name)
* exec. From "Anna Pluzhnikov" <besp@midway.uchicago.edu>.
*/
#ifndef __ASSUME_O_CLOEXEC
- fcntl(fd, F_SETFD, FD_CLOEXEC);
+ fcntl_not_cancel(fd, F_SETFD, FD_CLOEXEC);
#endif
ptr = fd_to_DIR(fd, statbuf.st_blksize);
+
if (!ptr) {
- close(fd);
+ close_not_cancel_no_status(fd);
__set_errno(ENOMEM);
}
return ptr;