Re: [PATCH] alternative to sys_indirect, part 1

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Michael Kerrisk
Date: Thursday, April 24, 2008 - 5:34 am

On 4/24/08, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:

That''s not quite true.  There is still the problem of accept().

It's worth trying to summarize all of the syscalls that create file
descriptors to get a handle on how many new syscalls might really be
required.  AFAIK, the list below is all of the syscalls that create
FDs on Linux.

The following system calls all have a flags argument that either
already has a O_CLOEXEC functionality, or to which that functionality
could be added:

* open()
* openat()
* fcntl(F_DUPFD)
* timerfd_create()
* mq_open() (on Linux MQ descriptors are really just file descriptors)

For the following system calls, we could overload another argument for
the purpose:
* socket() (using the 'type' argument, as per Alan's suggestion)

The following syscalls don't have a flags argument, but does it
matter?  For each of them there is an alternative API that can be used
instead, if the functionality is required.

* dup2() -- use fcntl(F_DUPFD) instead
* dup() -- use fcntl(F_DUPFD) instead
* creat() -- use open() instead

The following system call doesn't have a flags argument, but we could
conceivably overload the existing 'fd' argument.  When creating a new
file descriptor, the 'fd' argument must be -1.  We could say that to
create a new fd, the argument must be say NEW_SIGNALFD, defined as
-MAXINT, ORed with the desired flags.

* signalfd()  (glibc API supplies a flags argument, but the syscall
doesn't have one)

The following system calls don't have a flags argument, and the only
way to solve the problem is a new syscall, or sys_indirect().

* eventfd()  (glibc API supplies a flags argument, but the syscall
doesn't have one)
* accept()
* pipe()
* inotify_init()
* epoll_create()

So the alternative to sys_indirect(), at least for the purpose of
O_CLOEXEC and similar, would be to create 5 new system calls (or six,
if one finds the signalfd() hack too ugly, which perhaps it is; or 7
if one doesn't like Alan's suggestion for socket() -- if one went the
route of new syscalls, then I'd suggest creating a new socket()-type
syscall with a flags argument).

Cheers,

Michael


-- 
I'll likely only see replies if they are CCed to mtk.manpages at gmail dot com
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] alternative to sys_indirect, part 1, Ulrich Drepper, (Wed Apr 23, 9:03 pm)
Re: [PATCH] alternative to sys_indirect, part 1, Alan Cox, (Thu Apr 24, 3:25 am)
Re: [PATCH] alternative to sys_indirect, part 1, Michael Kerrisk, (Thu Apr 24, 5:27 am)
Re: [PATCH] alternative to sys_indirect, part 1, Michael Kerrisk, (Thu Apr 24, 5:34 am)
Re: [PATCH] alternative to sys_indirect, part 1, David Collier-Brown, (Thu Apr 24, 5:46 am)
Re: [PATCH] alternative to sys_indirect, part 1, Ulrich Drepper, (Thu Apr 24, 7:18 am)
Re: [PATCH] alternative to sys_indirect, part 1, Alan Cox, (Thu Apr 24, 7:24 am)
Re: [PATCH] alternative to sys_indirect, part 1, Alan Cox, (Thu Apr 24, 7:42 am)
Re: [PATCH] alternative to sys_indirect, part 1, Ulrich Drepper, (Thu Apr 24, 7:49 am)
Re: [PATCH] alternative to sys_indirect, part 1, Alan Cox, (Thu Apr 24, 8:03 am)
Re: [PATCH] alternative to sys_indirect, part 1, Michael Kerrisk, (Thu Apr 24, 8:05 am)
Re: [PATCH] alternative to sys_indirect, part 1, Ulrich Drepper, (Thu Apr 24, 8:16 am)
Re: [PATCH] alternative to sys_indirect, part 1, Ulrich Drepper, (Thu Apr 24, 8:19 am)
Re: [PATCH] alternative to sys_indirect, part 1, Alan Cox, (Thu Apr 24, 8:24 am)
Re: [PATCH] alternative to sys_indirect, part 1, Alan Cox, (Thu Apr 24, 8:27 am)
Re: [PATCH] alternative to sys_indirect, part 1, Linus Torvalds, (Thu Apr 24, 8:29 am)
Re: [PATCH] alternative to sys_indirect, part 1, Alan Cox, (Thu Apr 24, 8:38 am)
Re: [PATCH] alternative to sys_indirect, part 1, David Miller, (Thu Apr 24, 8:39 am)
Re: [PATCH] alternative to sys_indirect, part 1, Alan Cox, (Thu Apr 24, 8:42 am)
Re: [PATCH] alternative to sys_indirect, part 1, Jakub Jelinek, (Thu Apr 24, 8:44 am)
Re: [PATCH] alternative to sys_indirect, part 1, Alan Cox, (Thu Apr 24, 8:45 am)
Re: [PATCH] alternative to sys_indirect, part 1, Ulrich Drepper, (Thu Apr 24, 8:45 am)
Re: [PATCH] alternative to sys_indirect, part 1, David Miller, (Thu Apr 24, 9:00 am)
Re: [PATCH] alternative to sys_indirect, part 1, Michael Kerrisk, (Thu Apr 24, 9:03 am)
Re: [PATCH] alternative to sys_indirect, part 1, Ulrich Drepper, (Thu Apr 24, 9:04 am)
Re: [PATCH] alternative to sys_indirect, part 1, Michael Kerrisk, (Thu Apr 24, 9:06 am)
Re: [PATCH] alternative to sys_indirect, part 1, David Miller, (Thu Apr 24, 9:09 am)
Re: [PATCH] alternative to sys_indirect, part 1, Linus Torvalds, (Thu Apr 24, 9:30 am)
Re: [PATCH] alternative to sys_indirect, part 1, Michael Kerrisk, (Thu Apr 24, 9:45 am)
Re: [PATCH] alternative to sys_indirect, part 1, Michael Kerrisk, (Thu Apr 24, 9:48 am)
Re: [PATCH] alternative to sys_indirect, part 1, Evgeniy Polyakov, (Thu Apr 24, 9:49 am)
Re: [PATCH] alternative to sys_indirect, part 1, Ulrich Drepper, (Thu Apr 24, 9:52 am)
Re: [PATCH] alternative to sys_indirect, part 1, H. Peter Anvin, (Thu Apr 24, 10:20 am)
Re: [PATCH] alternative to sys_indirect, part 1, Ulrich Drepper, (Thu Apr 24, 10:31 am)
Re: [PATCH] alternative to sys_indirect, part 1, H. Peter Anvin, (Thu Apr 24, 10:34 am)
Re: [PATCH] alternative to sys_indirect, part 1, dean gaudet, (Sat Apr 26, 3:41 pm)