From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8eBQ-0006jE-OZ for qemu-devel@nongnu.org; Thu, 02 Jun 2016 21:45:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8eBH-0004PZ-F1 for qemu-devel@nongnu.org; Thu, 02 Jun 2016 21:45:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8eBG-0004PV-DA for qemu-devel@nongnu.org; Thu, 02 Jun 2016 21:45:47 -0400 References: <1464863806-1984-1-git-send-email-xiecl.fnst@cn.fujitsu.com> <1464863806-1984-2-git-send-email-xiecl.fnst@cn.fujitsu.com> <20160602151418.GJ1184@perard.uk.xensource.com> <5750DCB5.7060600@cn.fujitsu.com> From: Eric Blake Message-ID: <5750E143.6020904@redhat.com> Date: Thu, 2 Jun 2016 19:45:39 -0600 MIME-Version: 1.0 In-Reply-To: <5750DCB5.7060600@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vsoT8FQHFilfMMuHnuBflKhlbPT3MCKWu" Subject: Re: [Qemu-devel] [PATCH v5 1/1] Introduce "xen-load-devices-state" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Changlong Xie , Anthony PERARD Cc: qemu devel , Stefano Stabellini , Juan Quintela , Amit Shah , Markus Armbruster , "Dr. David Alan Gilbert" , Wen Congyang , zhanghailiang This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --vsoT8FQHFilfMMuHnuBflKhlbPT3MCKWu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/02/2016 07:26 PM, Changlong Xie wrote: >>> + >>> + ioc =3D 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 o= f >> 0660.) >> >=20 > 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --vsoT8FQHFilfMMuHnuBflKhlbPT3MCKWu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXUOFDAAoJEKeha0olJ0Nq96YH/2z/7EpZsdBCfQMaiEbLsy6d GV7KhhLxBZprWcokLjji0uiep5xB9VAvd5hvQ3WyeYjJB/ERToi7nnTHJQmM47LN Ht3LBv4oNhFDWlQ/AAznZCn2dtxinRxHaxS4y+4HXQb0RngknXQH+cWJOC86JzQw rgfSa7c5rBwLrF8HMGh2XMDhTz3fdB1sGGrA+c4okk7uWnWhFdyUtEDJd5lnOK6w up2dDwRcvNJ++dXxuF6X4zjgV1xrhrOqJGuv3jaeIivSkFjqEHLP8bcNMbo9IgPd YjcJL91R6NdfRV/t9teFkxML1ZTjPNgMArMmTNu1SHI6SI+y8Ae/8Q3u8NFmA6U= =y6aa -----END PGP SIGNATURE----- --vsoT8FQHFilfMMuHnuBflKhlbPT3MCKWu--