summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2009-10-11 20:19:45 +0000
committerjilles <jilles@FreeBSD.org>2009-10-11 20:19:45 +0000
commit874a086f97722040e7f0823d373523c366576960 (patch)
treedc8fbc20c11448869545373007df675e0e5c9bae /lib/libthr
parent3ec32537668ad3e5bf682fd223b5298fa8c172ad (diff)
downloadFreeBSD-src-874a086f97722040e7f0823d373523c366576960.zip
FreeBSD-src-874a086f97722040e7f0823d373523c366576960.tar.gz
Make openat(2) a cancellation point.
This is required by POSIX and matches open(2). Reviewed by: kib, jhb MFC after: 1 month
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/pthread.map5
-rw-r--r--lib/libthr/thread/thr_private.h1
-rw-r--r--lib/libthr/thread/thr_syscalls.c28
3 files changed, 34 insertions, 0 deletions
diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map
index 79bbd4c..62f3ff5 100644
--- a/lib/libthr/pthread.map
+++ b/lib/libthr/pthread.map
@@ -195,6 +195,7 @@ FBSDprivate_1.0 {
__msync;
__nanosleep;
__open;
+ __openat;
__poll;
__pthread_cond_timedwait;
__pthread_cond_wait;
@@ -406,3 +407,7 @@ FBSD_1.1 {
pthread_mutex_setspinloops_np;
pthread_mutex_setyieldloops_np;
};
+
+FBSD_1.2 {
+ openat;
+};
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index e336b2c..57be0ae 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -668,6 +668,7 @@ void _pthread_cleanup_pop(int);
#ifdef _SYS_FCNTL_H_
int __sys_fcntl(int, int, ...);
int __sys_open(const char *, int, ...);
+int __sys_openat(int, const char *, int, ...);
#endif
/* #include <signal.h> */
diff --git a/lib/libthr/thread/thr_syscalls.c b/lib/libthr/thread/thr_syscalls.c
index 698c0c3..d05d68b 100644
--- a/lib/libthr/thread/thr_syscalls.c
+++ b/lib/libthr/thread/thr_syscalls.c
@@ -139,6 +139,7 @@ int __fsync(int);
int __msync(void *, size_t, int);
int __nanosleep(const struct timespec *, struct timespec *);
int __open(const char *, int,...);
+int __openat(int, const char *, int,...);
int __poll(struct pollfd *, unsigned int, int);
ssize_t __read(int, void *buf, size_t);
ssize_t __readv(int, const struct iovec *, int);
@@ -341,6 +342,33 @@ __open(const char *path, int flags,...)
return ret;
}
+__weak_reference(__openat, openat);
+
+int
+__openat(int fd, const char *path, int flags, ...)
+{
+ struct pthread *curthread = _get_curthread();
+ int ret;
+ int mode = 0;
+ va_list ap;
+
+ _thr_cancel_enter(curthread);
+
+ /* Check if the file is being created: */
+ if (flags & O_CREAT) {
+ /* Get the creation mode: */
+ va_start(ap, flags);
+ mode = va_arg(ap, int);
+ va_end(ap);
+ }
+
+ ret = __sys_openat(fd, path, flags, mode);
+
+ _thr_cancel_leave(curthread);
+
+ return ret;
+}
+
__weak_reference(__poll, poll);
int
OpenPOWER on IntegriCloud