* [Qemu-devel] [PATCH] Substitute O_SYNC with O_FSYNC in block/raw-posix.c
@ 2009-06-26 0:59 G 3
2009-06-26 17:55 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: G 3 @ 2009-06-26 0:59 UTC (permalink / raw)
To: qemu-devel
This patch will allow the file block/raw-posix.c to compile on gcc 3.3
on Mac OS 10.3. Since the O_SYNC symbol is missing on this version of
the Mac OS, O_FSYNC will be used in its place.
Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
block/raw-posix.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index fa1a394..baff82d 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -79,6 +79,15 @@
#define DEBUG_BLOCK_PRINT(formatCstr, ...)
#endif
+/* Mac OS less than 10.4 doesn't have O_SYNC */
+#ifndef O_SYNC
+#ifdef O_FSYNC
+#define O_SYNC O_FSYNC
+#else
+#define O_SYNC 0
+#endif
+#endif
+
/* OS X does not have O_DSYNC */
#ifndef O_DSYNC
#define O_DSYNC O_SYNC
--
1.6.3.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] Substitute O_SYNC with O_FSYNC in block/raw-posix.c
2009-06-26 0:59 [Qemu-devel] [PATCH] Substitute O_SYNC with O_FSYNC in block/raw-posix.c G 3
@ 2009-06-26 17:55 ` Christoph Hellwig
[not found] ` <3b18e1127cac98f7cacb6cca22fed96e@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2009-06-26 17:55 UTC (permalink / raw)
To: G 3; +Cc: qemu-devel
On Thu, Jun 25, 2009 at 08:59:35PM -0400, G 3 wrote:
> This patch will allow the file block/raw-posix.c to compile on gcc 3.3
> on Mac OS 10.3. Since the O_SYNC symbol is missing on this version of
> the Mac OS, O_FSYNC will be used in its place.
Same comment about the zero as last time still applies. Also the
look of this is really ugly as you just deinfe O_SYNC only for it
to substitute for O_DSYNC a littler later, with two comments that
together are rather confusing about macos..
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH] Substitute O_DSYNC with O_SYNC or O_FSYNC when needed.
[not found] ` <20090701135404.GB16868@lst.de>
@ 2009-07-01 17:28 ` G 3
2009-07-02 8:48 ` [Qemu-devel] " Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: G 3 @ 2009-07-01 17:28 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: qemu-devel
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 <programmingkidx@gmail.com>
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 <programmingkidx@gmail.com>
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] Re: [PATCH] Substitute O_DSYNC with O_SYNC or O_FSYNC when needed.
2009-07-01 17:28 ` [Qemu-devel] [PATCH] Substitute O_DSYNC with O_SYNC or O_FSYNC when needed G 3
@ 2009-07-02 8:48 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2009-07-02 8:48 UTC (permalink / raw)
To: G 3; +Cc: Christoph Hellwig, qemu-devel
On Wed, Jul 01, 2009 at 01:28:32PM -0400, G 3 wrote:
> This patch should be what you want.
>
> commit b32354139556d1a807d04aa54ed82610e0f4507a
> Author: John Arbuckle <programmingkidx@gmail.com>
> 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 <programmingkidx@gmail.com>
Thanks, looks good to me,
Reviewed-by: Christoph Hellwig <hch@lst.de>
> 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
---end quoted text---
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-07-02 8:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-26 0:59 [Qemu-devel] [PATCH] Substitute O_SYNC with O_FSYNC in block/raw-posix.c G 3
2009-06-26 17:55 ` Christoph Hellwig
[not found] ` <3b18e1127cac98f7cacb6cca22fed96e@gmail.com>
[not found] ` <20090701135404.GB16868@lst.de>
2009-07-01 17:28 ` [Qemu-devel] [PATCH] Substitute O_DSYNC with O_SYNC or O_FSYNC when needed G 3
2009-07-02 8:48 ` [Qemu-devel] " Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).