From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwXVg-0002zU-LQ for qemu-devel@nongnu.org; Wed, 11 Nov 2015 10:41:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwXUj-0007gH-R4 for qemu-devel@nongnu.org; Wed, 11 Nov 2015 10:40:32 -0500 Received: from e19.ny.us.ibm.com ([129.33.205.209]:44945) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwXUj-0007fa-Nj for qemu-devel@nongnu.org; Wed, 11 Nov 2015 10:39:33 -0500 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Nov 2015 10:39:30 -0500 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <56435595.7010704@redhat.com> References: <1447105745-32358-1-git-send-email-kallan@suse.com> <20151110154059.25378.38107@loki> <56423076.5020408@redhat.com> <20151111140208.31702.72506@loki> <56435595.7010704@redhat.com> Message-ID: <20151111153921.31702.6490@loki> Date: Wed, 11 Nov 2015 09:39:21 -0600 Subject: Re: [Qemu-devel] [PATCH] qga: fix append file open modes for win32 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , Kirk Allan , qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org Quoting Paolo Bonzini (2015-11-11 08:49:57) > = > = > On 11/11/2015 15:02, Michael Roth wrote: > >> GENERIC_READ for files > >> =3D FILE_READ_DATA > >> + FILE_READ_ATTRIBUTES > >> + FILE_READ_EA > >> + SYNCHRONIZE > >> + STANDARD_RIGHTS_READ (which is READ_CONTROL) > >> > >> GENERIC_WRITE for files > >> =3D FILE_APPEND_DATA > >> + FILE_WRITE_DATA > >> + FILE_WRITE_ATTRIBUTES > >> + FILE_WRITE_EA > >> + SYNCHRONIZE > >> + STANDARD_RIGHTS_WRITE (which is READ_CONTROL too!) > >> > >> Of these of course qemu-ga only needs FILE_*_DATA and possibly SYNCHRO= NIZE. > >> > >> The above description doesn't say what happens if you specify > >> FILE_READ_DATA and FILE_APPEND_DATA together, but I guess you can expe= ct > >> it to just work. > > = > > Thanks, this is very helpful. This seems to coincide with > > FILE_GENERIC_WRITE / FILE_GENERIC_READ if you want to access the > > bitmasks directly (though it looks like you can still add flags > > to GENERIC_WRITE / GENERIC_READ): > > = > > https://msdn.microsoft.com/en-us/library/windows/desktop/aa364399(v= =3Dvs.85).aspx > = > Yes, I had missed the FILE_GENERIC_* definitions. I found them now in > mingw as well, and they are exactly what you would expect (an | of the > various flags). > = > > Looks like the crux of it is that FILE_WRITE_DATA causes us not to igno= re > > the start offset (0) for writes, so we end up writing data at the > > beginning of the file instead of the end. > > = > > So I think the following > > should work: > > = > > a: FILE_GENERIC_WRITE & ~FILE_WRITE_DATA > > a+: FILE_GENERIC_READ | FILE_APPEND_DATA > > = > > FILE_APPEND_DATA by itself might work for a:, but for consistency I > > think I'd prefer sticking with the generic set and masking out > > FILE_WRITE_DATA. > = > For a+ I would use any of > = > (FILE_GENERIC_READ | FILE_GENERIC_WRITE) & ~FILE_WRITE_DATA > GENERIC_READ | (FILE_GENERIC_WRITE & ~FILE_WRITE_DATA) > = > Perhaps you can define this: > = > #define FILE_GENERIC_APPEND (FILE_GENERIC_WRITE & ~FILE_WRITE_DATA) > = > and then use > = > a: FILE_GENERIC_APPEND > a+: GENERIC_READ|FILE_GENERIC_APPEND > = > or > = > a: FILE_GENERIC_APPEND > a+: FILE_GENERIC_READ|FILE_GENERIC_APPEND Yah, both are more proper actually (I was relying on FILE_GENERIC_READ already containing the other flags from FILE_GENERIC_WRITE, but that's more likely to break in the future). I think I prefer the former since it avoids confusion on GENERIC_READ vs. FILE_GENERIC_READ differences. Kirk, I'm planning on squashing this into your v2 series, so no need to resubmit. Thanks! > = > ? > = > Paolo >=20