[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 7/7] osdep: Enable qemu_open to dup pre-opene
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v4 7/7] osdep: Enable qemu_open to dup pre-opened fd |
Date: |
Mon, 25 Jun 2012 08:34:47 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 |
On 06/25/2012 08:24 AM, Corey Bryant wrote:
>>> + if (fcntl_setfl(ret, O_CLOEXEC, (flags & O_CLOEXEC) ? 1
>>> : 0) < 0) {
>>
>> Broken. O_CLOEXEC _only_ affects open(); to change it on an existing
>> fd, you have to use fcntl(F_GETFD/F_SETFD) (not F_GETFL/F_SETFL).
>>
>>
>
> I'll fix this in v5.
Don't we already have qemu_set_cloexec() for this purpose?
>
> I see your point. I'll call fcntl(F_GETFL) once to get the current
> flags, determine what needs to be set on/off, and then call
> fnctl(F_SETFL) once. In this case I won't be using fcntl_setfl()
> anymore. Do you want me to drop the fcntl_setfl() changes I made?
Or maybe make fcntl_setfl() take a mask of bits to alter? You're right
that it's not worth changing if you won't take advantage of the changes.
>
> Also, I noticed in the fnctl man page that F_SETFL: "On Linux this
> command can change only the O_APPEND, O_ASYNC, O_DIRECT, O_NOATIME, and
> O_NONBLOCK flags." So I'll only set/unset these flags.
O_NDELAY is the obsolete spelling of O_NONBLOCK; which means the only
other flags in your list not supported by Linux are O_LARGEFILE (which I
said was pointless), O_NOCTTY (which only has an impact at open() and
not later on, so it is not worth worrying about), and O_SYNC (so for
that one, you should error out if not set correctly, as the difference
between O_SYNC on vs. off is significant).
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v4 2/7] qapi: Convert getfd and closefd, (continued)
[Qemu-devel] [PATCH v4 1/7] qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg, Corey Bryant, 2012/06/22
[Qemu-devel] [PATCH v4 7/7] osdep: Enable qemu_open to dup pre-opened fd, Corey Bryant, 2012/06/22
[Qemu-devel] [PATCH v4 5/7] block: Prevent /dev/fd/X filename from being detected as floppy, Corey Bryant, 2012/06/22
[Qemu-devel] [PATCH v4 4/7] qapi: Re-arrange monitor.c functions, Corey Bryant, 2012/06/22