From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MM3by-0002f7-2W for qemu-devel@nongnu.org; Wed, 01 Jul 2009 13:28:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MM3bt-0002an-Fr for qemu-devel@nongnu.org; Wed, 01 Jul 2009 13:28:45 -0400 Received: from [199.232.76.173] (port=57619 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MM3bt-0002aX-55 for qemu-devel@nongnu.org; Wed, 01 Jul 2009 13:28:41 -0400 Received: from mail-ew0-f211.google.com ([209.85.219.211]:37246) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MM3bs-0006lu-PK for qemu-devel@nongnu.org; Wed, 01 Jul 2009 13:28:40 -0400 Received: by ewy7 with SMTP id 7so1192119ewy.34 for ; Wed, 01 Jul 2009 10:28:39 -0700 (PDT) In-Reply-To: <20090701135404.GB16868@lst.de> References: <20090626175538.GA4077@lst.de> <3b18e1127cac98f7cacb6cca22fed96e@gmail.com> <20090701135404.GB16868@lst.de> Mime-Version: 1.0 (Apple Message framework v624) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <45f1eeaa1ea123585c41d07c49584ead@gmail.com> Content-Transfer-Encoding: 7bit From: G 3 Date: Wed, 1 Jul 2009 13:28:32 -0400 Subject: [Qemu-devel] [PATCH] Substitute O_DSYNC with O_SYNC or O_FSYNC when needed. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoph Hellwig Cc: qemu-devel@nongnu.org On Jul 1, 2009, at 9:54 AM, Christoph Hellwig wrote: > On Fri, Jun 26, 2009 at 03:02:47PM -0400, G 3 wrote: >> /* OS X does not have O_DSYNC */ >> #ifndef O_DSYNC >> #ifdef O_SYNC /* Works on Mac OS 10.4 and >> greater */ >> #define O_DSYNC O_SYNC >> #elif defined(O_FSYNC) /* Works on Mac OS 10.3 and under */ >> #define O_DSYNC O_FSYNC >> #else /* If no substitute is >> available */ >> #define O_DSYNC 0 >> #endif >> #endif > > This still does the NULL sync which can cause silent data loss if no > O_*SYNC is available. If you want to be safe and support either O_SYNC > or O_FSYNC as O_DSYNC replacement the following should be enough: > > /* > * MacOS X does not have O_DSYNC, and in earlier version no O_SYNC > either. > */ > #ifndef O_DSYNC > #ifdef O_SYNC > #define O_DSYNC O_SYNC > #else > #define O_DSYNC O_FSYNC > #endif > #endif > > This patch should be what you want. commit b32354139556d1a807d04aa54ed82610e0f4507a Author: John Arbuckle Date: Wed Jul 1 13:24:37 2009 -0400 Substitute O_DSYNC with O_SYNC or O_FSYNC when needed. Signed-off-by: John Arbuckle diff --git a/block/raw-posix.c b/block/raw-posix.c index 8b1e67c..17338ee 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -81,7 +81,11 @@ /* OS X does not have O_DSYNC */ #ifndef O_DSYNC +#ifdef O_SYNC #define O_DSYNC O_SYNC +#elif defined(O_FSYNC) +#define O_DSYNC O_FSYNC +#endif #endif