From: G 3 <programmingkidx@gmail.com>
To: Jamie Lokier <jamie@shareable.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] replace O_SYNC with O_FSYNC
Date: Sat, 20 Jun 2009 20:46:54 -0400 [thread overview]
Message-ID: <cfdb22474af3ce70f5c20e4e5869b338@gmail.com> (raw)
In-Reply-To: <20090620233005.GB29958@shareable.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.
prev parent reply other threads:[~2009-06-21 0:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-20 2:22 [Qemu-devel] [PATCH] replace O_SYNC with O_FSYNC m a
2009-06-20 14:31 ` Anthony Liguori
2009-06-20 18:59 ` Avi Kivity
2009-06-20 19:03 ` François Revol
2009-06-20 19:15 ` Avi Kivity
2009-06-20 23:25 ` Jamie Lokier
2009-06-21 10:01 ` Andreas Färber
2009-06-24 18:25 ` Jamie Lokier
2009-06-24 18:54 ` Andreas Färber
2009-06-24 18:59 ` Filip Navara
2009-06-24 19:08 ` Jamie Lokier
2009-06-20 20:46 ` Anthony Liguori
2009-06-21 9:01 ` Avi Kivity
2009-06-20 19:16 ` Christoph Hellwig
2009-06-20 23:30 ` Jamie Lokier
2009-06-20 23:37 ` Anthony Liguori
2009-06-21 0:41 ` G 3
2009-06-24 18:27 ` Jamie Lokier
2009-06-21 0:46 ` G 3 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cfdb22474af3ce70f5c20e4e5869b338@gmail.com \
--to=programmingkidx@gmail.com \
--cc=jamie@shareable.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).