From: Davide Libenzi <davidel@xmailserver.org>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH v2] eventfd, signalfd, timerfd, epoll_create w/flags
Date: Sun, 27 Apr 2008 22:11:28 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0804272200090.18184@alien.or.mcafeemobile.com> (raw)
In-Reply-To: <200804280315.m3S3FKsw028335@devserv.devel.redhat.com>
On Sun, 27 Apr 2008, Ulrich Drepper wrote:
> + int fflags = 0;
> +
> + if (flags) {
> + if ((flags & EFD_CLOEXEC) != 0) {
> + fflags |= O_CLOEXEC;
> + flags &= ~EFD_CLOEXEC;
> + }
> + if (flags)
> + return -EINVAL;
> + }
...
> + int fflags = 0;
> +
> + if (flags) {
> + if ((flags & EPOLL_CLOEXEC) != 0) {
> + fflags |= O_CLOEXEC;
> + flags &= ~EPOLL_CLOEXEC;
> + }
> + if (flags)
> + return -EINVAL;
> + }
...
> + int fflags = 0;
> +
> + if (flags) {
> + if ((flags & SFD_CLOEXEC) != 0 && ufd == -1) {
> + fflags |= O_CLOEXEC;
> + flags &= ~SFD_CLOEXEC;
> + }
> + if (flags)
> + return -EINVAL;
> + }
...
> + int fflags = 0;
>
> - if (flags)
> - return -EINVAL;
> + if (flags) {
> + if ((flags & TFD_CLOEXEC) != 0) {
> + fflags |= O_CLOEXEC;
> + flags &= ~TFD_CLOEXEC;
> + }
> + if (flags)
> + return -EINVAL;
> + }
Maybe something like:
struct oflags_rmap {
int f, of;
};
unsigned int oflags_remap(const struct oflags_rmap *m, int n,
int f, int *rf)
{
int i;
for (i = 0, *rf = 0; i < n; i++, m++)
if (f & m->f) {
*rf |= m->of;
f &= ~m->f;
}
return f ? -EINVAL: 0;
}
Then, in all the cases above (modulo different "struct oflags_rmap"
fillings):
const struct oflags_rmap ormap[] = {
{ TFD_CLOEXEC, O_CLOEXEC }
};
error = oflags_remap(ormap, ARRAY_SIZE(ormap), flags, &fflags);
- Davide
next prev parent reply other threads:[~2008-04-28 5:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-28 3:15 Ulrich Drepper
2008-04-28 5:11 ` Davide Libenzi [this message]
2008-04-28 5:43 ` Ulrich Drepper
2008-04-28 6:06 ` Davide Libenzi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0804272200090.18184@alien.or.mcafeemobile.com \
--to=davidel@xmailserver.org \
--cc=akpm@linux-foundation.org \
--cc=drepper@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®