From owner-svn-src-all@FreeBSD.ORG Sun Oct 11 20:19:46 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32E09106568D; Sun, 11 Oct 2009 20:19:46 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 21D478FC1E; Sun, 11 Oct 2009 20:19:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9BKJjp1028242; Sun, 11 Oct 2009 20:19:45 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9BKJjM1028235; Sun, 11 Oct 2009 20:19:45 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <200910112019.n9BKJjM1028235@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 11 Oct 2009 20:19:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197968 - in head/lib: libc/include libc/sys libthr libthr/thread X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Oct 2009 20:19:46 -0000 Author: jilles Date: Sun Oct 11 20:19:45 2009 New Revision: 197968 URL: http://svn.freebsd.org/changeset/base/197968 Log: Make openat(2) a cancellation point. This is required by POSIX and matches open(2). Reviewed by: kib, jhb MFC after: 1 month Modified: head/lib/libc/include/namespace.h head/lib/libc/include/un-namespace.h head/lib/libc/sys/Symbol.map head/lib/libthr/pthread.map head/lib/libthr/thread/thr_private.h head/lib/libthr/thread/thr_syscalls.c Modified: head/lib/libc/include/namespace.h ============================================================================== --- head/lib/libc/include/namespace.h Sun Oct 11 18:21:55 2009 (r197967) +++ head/lib/libc/include/namespace.h Sun Oct 11 20:19:45 2009 (r197968) @@ -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 Modified: head/lib/libc/include/un-namespace.h ============================================================================== --- head/lib/libc/include/un-namespace.h Sun Oct 11 18:21:55 2009 (r197967) +++ head/lib/libc/include/un-namespace.h Sun Oct 11 20:19:45 2009 (r197968) @@ -61,6 +61,7 @@ #undef listen #undef nanosleep #undef open +#undef openat #undef poll #undef pthread_atfork #undef pthread_attr_destroy Modified: head/lib/libc/sys/Symbol.map ============================================================================== --- head/lib/libc/sys/Symbol.map Sun Oct 11 18:21:55 2009 (r197967) +++ head/lib/libc/sys/Symbol.map Sun Oct 11 20:19:45 2009 (r197968) @@ -769,6 +769,8 @@ FBSDprivate_1.0 { __sys_olio_listio; _open; __sys_open; + _openat; + __sys_openat; _pathconf; __sys_pathconf; _pipe; Modified: head/lib/libthr/pthread.map ============================================================================== --- head/lib/libthr/pthread.map Sun Oct 11 18:21:55 2009 (r197967) +++ head/lib/libthr/pthread.map Sun Oct 11 20:19:45 2009 (r197968) @@ -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; +}; Modified: head/lib/libthr/thread/thr_private.h ============================================================================== --- head/lib/libthr/thread/thr_private.h Sun Oct 11 18:21:55 2009 (r197967) +++ head/lib/libthr/thread/thr_private.h Sun Oct 11 20:19:45 2009 (r197968) @@ -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 */ Modified: head/lib/libthr/thread/thr_syscalls.c ============================================================================== --- head/lib/libthr/thread/thr_syscalls.c Sun Oct 11 18:21:55 2009 (r197967) +++ head/lib/libthr/thread/thr_syscalls.c Sun Oct 11 20:19:45 2009 (r197968) @@ -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