From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MIBDH-00075X-Rq for qemu-devel@nongnu.org; Sat, 20 Jun 2009 20:47:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MIBDG-00074m-Vu for qemu-devel@nongnu.org; Sat, 20 Jun 2009 20:47:15 -0400 Received: from [199.232.76.173] (port=56491 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MIBDG-00074S-La for qemu-devel@nongnu.org; Sat, 20 Jun 2009 20:47:14 -0400 Received: from mx20.gnu.org ([199.232.41.8]:50167) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MIBDG-0001ue-5g for qemu-devel@nongnu.org; Sat, 20 Jun 2009 20:47:14 -0400 Received: from yw-out-1718.google.com ([74.125.46.154]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MIBDF-0006R5-IU for qemu-devel@nongnu.org; Sat, 20 Jun 2009 20:47:13 -0400 Received: by yw-out-1718.google.com with SMTP id 5so1355326ywr.82 for ; Sat, 20 Jun 2009 17:47:12 -0700 (PDT) In-Reply-To: <20090620233005.GB29958@shareable.org> References: <20f282157f4df2f513fdb51427be26c7@hotpop.com> <20090620191629.GB25835@lst.de> <20090620233005.GB29958@shareable.org> Mime-Version: 1.0 (Apple Message framework v624) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: G 3 Subject: Re: [Qemu-devel] [PATCH] replace O_SYNC with O_FSYNC Date: Sat, 20 Jun 2009 20:46:54 -0400 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jamie Lokier Cc: qemu-devel@nongnu.org On Jun 20, 2009, at 7:30 PM, Jamie Lokier wrote: > Christoph Hellwig wrote: >> On Fri, Jun 19, 2009 at 10:22:07PM -0400, m a wrote: >>> This patch replaces O_SYNC with O_FSYNC. These two flags do the same >>> thing, but only O_FSYNC is available in Mac OS 10.3 and under. It >>> only >>> replaces O_SYNC if it doesn't exist. This patch allows the file >>> block-raw-posix.c to compile on Mac OS 10.3. This is my first time >>> submitting a patch, so there might have been a few mistakes made. >> >> But O_SYNC is a standard posix flag, while O_FSYNC appears to be >> a BSD extension. Also the actual code uses O_DSYNC anyway, which >> also is in Posix but not actually natively supported by some OSes, >> e.g. Linux (but still provided in libc there). > > If O_FSYNC and O_SYNC do the same thing, and O_SYNC is used anywhere, > there's no harm in this for portability: > > #if !defined(O_SYNC) && defined(O_FSYNC) > #define O_SYNC O_FSYNC > #endif > > The patch assumes O_FSYNC is defined if O_SYNC isn't, which is wrong. > >>> /* OS X does not have O_DSYNC */ >>> #ifndef O_DSYNC >>> #define O_DSYNC O_SYNC >> >> So if the code here is correct and Darwin is the only supported OS >> where >> O_DSYNC is missing we could just replace the O_SYNC in the last line >> with O_FSYNC. > > I agree, though the comment might be misleading, if there's another > supported OS without O_DSYNC. > > -- Jamie > > Your logic does make sense. I guess I should have done this instead: #ifndef O_SYNC #ifdef O_FSYNC #define O_SYNC O_FSYNC #else #define O_SYNC 0 #endif #endif Defining O_SYNC as zero is ok because this flag is 'ORed' with other flags.