flag parameters add-on: remove epoll_create size param

Remove the size parameter from the new epoll_create syscall and renames the
syscall itself.  The updated test program follows.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <fcntl.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <sys/syscall.h>

#ifndef __NR_epoll_create2
# ifdef __x86_64__
#  define __NR_epoll_create2 291
# elif defined __i386__
#  define __NR_epoll_create2 329
# else
#  error "need __NR_epoll_create2"
# endif
#endif

#define EPOLL_CLOEXEC O_CLOEXEC

int
main (void)
{
  int fd = syscall (__NR_epoll_create2, 0);
  if (fd == -1)
    {
      puts ("epoll_create2(0) failed");
      return 1;
    }
  int coe = fcntl (fd, F_GETFD);
  if (coe == -1)
    {
      puts ("fcntl failed");
      return 1;
    }
  if (coe & FD_CLOEXEC)
    {
      puts ("epoll_create2(0) set close-on-exec flag");
      return 1;
    }
  close (fd);

  fd = syscall (__NR_epoll_create2, EPOLL_CLOEXEC);
  if (fd == -1)
    {
      puts ("epoll_create2(EPOLL_CLOEXEC) failed");
      return 1;
    }
  coe = fcntl (fd, F_GETFD);
  if (coe == -1)
    {
      puts ("fcntl failed");
      return 1;
    }
  if ((coe & FD_CLOEXEC) == 0)
    {
      puts ("epoll_create2(EPOLL_CLOEXEC) set close-on-exec flag");
      return 1;
    }
  close (fd);

  puts ("OK");

  return 0;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Acked-by: Davide Libenzi <davidel@xmailserver.org>
Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Ulrich Drepper 2008-07-23 21:29:43 -07:00 committed by Linus Torvalds
parent e38b36f325
commit 9fe5ad9c8c
7 changed files with 17 additions and 15 deletions

View file

@ -828,7 +828,7 @@ ia32_sys_call_table:
.quad compat_sys_timerfd_gettime
.quad compat_sys_signalfd4
.quad sys_eventfd2
.quad sys_epoll_create2
.quad sys_epoll_create1
.quad sys_dup3 /* 330 */
.quad sys_pipe2
.quad sys_inotify_init1

View file

@ -328,7 +328,7 @@ ENTRY(sys_call_table)
.long sys_timerfd_gettime
.long sys_signalfd4
.long sys_eventfd2
.long sys_epoll_create2
.long sys_epoll_create1
.long sys_dup3 /* 330 */
.long sys_pipe2
.long sys_inotify_init1

View file

@ -1046,7 +1046,7 @@ retry:
* RB tree. With the current implementation, the "size" parameter is ignored
* (besides sanity checks).
*/
asmlinkage long sys_epoll_create2(int size, int flags)
asmlinkage long sys_epoll_create1(int flags)
{
int error, fd = -1;
struct eventpoll *ep;
@ -1058,14 +1058,13 @@ asmlinkage long sys_epoll_create2(int size, int flags)
return -EINVAL;
DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d)\n",
current, size));
current, flags));
/*
* Sanity check on the size parameter, and create the internal data
* structure ( "struct eventpoll" ).
* Create the internal data structure ( "struct eventpoll" ).
*/
error = -EINVAL;
if (size <= 0 || (error = ep_alloc(&ep)) < 0) {
error = ep_alloc(&ep);
if (error < 0) {
fd = error;
goto error_return;
}
@ -1081,14 +1080,17 @@ asmlinkage long sys_epoll_create2(int size, int flags)
error_return:
DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n",
current, size, fd));
current, flags, fd));
return fd;
}
asmlinkage long sys_epoll_create(int size)
{
return sys_epoll_create2(size, 0);
if (size < 0)
return -EINVAL;
return sys_epoll_create1(0);
}
/*

View file

@ -334,7 +334,7 @@
#define __NR_timerfd_gettime 326
#define __NR_signalfd4 327
#define __NR_eventfd2 328
#define __NR_epoll_create2 329
#define __NR_epoll_create1 329
#define __NR_dup3 330
#define __NR_pipe2 331
#define __NR_inotify_init1 332

View file

@ -645,8 +645,8 @@ __SYSCALL(__NR_paccept, sys_paccept)
__SYSCALL(__NR_signalfd4, sys_signalfd4)
#define __NR_eventfd2 290
__SYSCALL(__NR_eventfd2, sys_eventfd2)
#define __NR_epoll_create2 291
__SYSCALL(__NR_epoll_create2, sys_epoll_create2)
#define __NR_epoll_create1 291
__SYSCALL(__NR_epoll_create1, sys_epoll_create1)
#define __NR_dup3 292
__SYSCALL(__NR_dup3, sys_dup3)
#define __NR_pipe2 293

View file

@ -18,7 +18,7 @@
#include <linux/fcntl.h>
#include <linux/types.h>
/* Flags for epoll_create2. */
/* Flags for epoll_create1. */
#define EPOLL_CLOEXEC O_CLOEXEC
/* Valid opcodes to issue to sys_epoll_ctl() */

View file

@ -431,7 +431,7 @@ asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp,
fd_set __user *exp, struct timeval __user *tvp);
asmlinkage long sys_epoll_create(int size);
asmlinkage long sys_epoll_create2(int size, int flags);
asmlinkage long sys_epoll_create1(int flags);
asmlinkage long sys_epoll_ctl(int epfd, int op, int fd,
struct epoll_event __user *event);
asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events,