From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MIqq0-00035e-Ua for qemu-devel@nongnu.org; Mon, 22 Jun 2009 17:14:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MIqpw-00032c-73 for qemu-devel@nongnu.org; Mon, 22 Jun 2009 17:14:00 -0400 Received: from [199.232.76.173] (port=40236 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MIqpv-00032N-UQ for qemu-devel@nongnu.org; Mon, 22 Jun 2009 17:13:56 -0400 Received: from verein.lst.de ([213.95.11.210]:38010) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1MIqpv-0004wh-Gw for qemu-devel@nongnu.org; Mon, 22 Jun 2009 17:13:55 -0400 Date: Mon, 22 Jun 2009 23:13:52 +0200 From: Christoph Hellwig Subject: Re: [Qemu-devel] [PATCH] improved patch from block-raw-posix.c Message-ID: <20090622211352.GB8024@lst.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: G 3 Cc: qemu-devel@nongnu.org On Sun, Jun 21, 2009 at 07:55:43PM -0400, G 3 wrote: > +/* O_SYNC isn't available on Mac OS 10.3 and under */ > +/* O_SYNC and O_FSYNC do the same thing */ > +#ifndef O_SYNC > + #ifdef O_FSYNC > + #define O_SYNC O_FSYNC > + #else > + #define O_SYNC 0 > + #endif > +#endif Please don't indent these cpp statements, it makes the code look really ugly. Also I don't think just defining O_SYNC away is good, if something doesn't have either of the O_*SYNC compilation should fail so we can find a workaround to provide data integrity. Personally I'd just go for the simple one below: -- Subject: raw-posix: deal with old MacOS versions that don't have O_SYNC From: Christoph Hellwig MacOS X versions older than 10.4 do not provide O_SYNC, but support the old BSD O_FSYNC flag. So define O_DSYNC as O_FSYNC if not present to be compatible with MacOS X (and possibly other pre-historic BSD derivates). Signed-off-by: Christoph Hellwig Reported-by: G 3 Index: qemu/block/raw-posix.c =================================================================== --- qemu.orig/block/raw-posix.c 2009-06-22 23:08:41.224930238 +0200 +++ qemu/block/raw-posix.c 2009-06-22 23:10:37.403934071 +0200 @@ -79,9 +79,12 @@ #define DEBUG_BLOCK_PRINT(formatCstr, ...) #endif -/* OS X does not have O_DSYNC */ +/* + * OS X does not have O_DSYNC, but provides the old BSDism O_FSYNC. + * (Never versions also have O_SYNC, but let's go for full compatiblity here). + */ #ifndef O_DSYNC -#define O_DSYNC O_SYNC +#define O_DSYNC O_FSYNC #endif /* Approximate O_DIRECT with O_DSYNC if O_DIRECT isn't available */