qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v5 1/1] Introduce "xen-load-devices-state"


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v5 1/1] Introduce "xen-load-devices-state"
Date: Thu, 2 Jun 2016 19:45:39 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 06/02/2016 07:26 PM, Changlong Xie wrote:

>>> +
>>> +    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT,
>>> 0660, errp);
>>
>> This does not look right, it looks like it's going to open the file
>> to write to it. You probably want O_RDONLY, also I don't think the
>> O_CREAT flag is needed. (and without O_WRONLY, mode can be 0 instead of
>> 0660.)
>>
> 
> Yes, as you said. We should use 0_RDONLY for open(2), so mode should be 0.

Huh?  mode doesn't affect the current fd, but DOES affect the next
person to open the file.  If you are truly creating the file, then a
mode of 0 means you won't be able to reopen it without chmod.  And if
you are doing O_RDONLY | O_CREAT, all you will be able to create is an
empty file, which is a pretty boring read.  So drop the O_CREAT, and
then you don't need a mode argument at all.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]