Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965714AbbBDKjm (ORCPT ); Wed, 4 Feb 2015 05:39:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45825 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965652AbbBDKjh (ORCPT ); Wed, 4 Feb 2015 05:39:37 -0500 From: Fam Zheng To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Alexander Viro , Andrew Morton , Kees Cook , Andy Lutomirski , David Herrmann , Alexei Starovoitov , Miklos Szeredi , David Drysdale , Oleg Nesterov , "David S. Miller" , Vivek Goyal , Mike Frysinger , "Theodore Ts'o" , Heiko Carstens , Rasmus Villemoes , Rashika Kheria , Hugh Dickins , Mathieu Desnoyers , Fam Zheng , Peter Zijlstra , linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, Josh Triplett , "Michael Kerrisk (man-pages)" , Paolo Bonzini , Omar Sandoval Subject: [PATCH RFC v2 6/7] epoll: Add implementation for epoll_pwait1 Date: Wed, 4 Feb 2015 18:36:52 +0800 Message-Id: <1423046213-7043-7-git-send-email-famz@redhat.com> In-Reply-To: <1423046213-7043-1-git-send-email-famz@redhat.com> References: <1423046213-7043-1-git-send-email-famz@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2421 Lines: 78 This is the new implementation for poll which uses timespec as timeout, and has a flags parameter. Signed-off-by: Fam Zheng --- fs/eventpoll.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/syscalls.h | 5 +++++ 2 files changed, 39 insertions(+) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 4eb40e0..59b2db9 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -2115,6 +2115,40 @@ out: return ret; } +SYSCALL_DEFINE6(epoll_pwait1, int, epfd, int, flags, + struct epoll_event __user *, events, + int, maxevents, struct timespec __user *, timeout, + void __user *, sig) +{ + size_t sigsetsize = 0; + sigset_t ksigmask; + sigset_t __user *sigmask = NULL; + struct timespec kts; + ktime_t kt = { 0 }; + + if (flags) + return -EINVAL; + if (sig) { + if (!access_ok(VERIFY_READ, sig, sizeof(void *)+sizeof(size_t)) + || __get_user(sigmask, (sigset_t __user * __user *)sig) + || __get_user(sigsetsize, + (size_t __user *)(sig+sizeof(void *)))) + return -EFAULT; + if (sigsetsize != sizeof(sigset_t)) + return -EINVAL; + if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask))) + return -EFAULT; + } + if (timeout) { + if (copy_from_user(&kts, timeout, sizeof(kts))) + return -EFAULT; + kt = timespec_to_ktime(kts); + } + + return epoll_pwait_do(epfd, events, maxevents, CLOCK_MONOTONIC, + kt, &ksigmask); +} + #ifdef CONFIG_COMPAT COMPAT_SYSCALL_DEFINE6(epoll_pwait, int, epfd, struct epoll_event __user *, events, diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 117822c..0c3ecdb 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -631,6 +631,11 @@ asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events, int maxevents, int timeout, const sigset_t __user *sigmask, size_t sigsetsize); +asmlinkage long sys_epoll_pwait1(int epfd, int flags, + struct epoll_event __user *events, + int maxevents, + struct timespec __user *timeout, + void __user *sig); asmlinkage long sys_epoll_ctl_batch(int epfd, int flags, int ncmds, struct epoll_ctl_cmd __user *cmds); -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/