Make openat(2) a cancellation point.

This is required by POSIX and matches open(2).

Reviewed by:	kib, jhb
MFC after:	1 month
This commit is contained in:
Jilles Tjoelker 2009-10-11 20:19:45 +00:00
parent eb9de28f20
commit 29670497af
6 changed files with 38 additions and 0 deletions

View File

@ -80,6 +80,7 @@
#define listen _listen
#define nanosleep _nanosleep
#define open _open
#define openat _openat
#define poll _poll
#define pthread_atfork _pthread_atfork
#define pthread_attr_destroy _pthread_attr_destroy

View File

@ -61,6 +61,7 @@
#undef listen
#undef nanosleep
#undef open
#undef openat
#undef poll
#undef pthread_atfork
#undef pthread_attr_destroy

View File

@ -769,6 +769,8 @@ FBSDprivate_1.0 {
__sys_olio_listio;
_open;
__sys_open;
_openat;
__sys_openat;
_pathconf;
__sys_pathconf;
_pipe;

View File

@ -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;
};

View File

@ -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> */

View File

@ -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