Messages in this thread | | | Date | Sun, 30 Aug 2009 18:48:52 +0100 | From | Jamie Lokier <> | Subject | Re: adding proper O_SYNC/O_DSYNC, was Re: O_DIRECT and barriers |
| |
Ulrich Drepper wrote: > On 08/28/2009 09:44 AM, Jamie Lokier wrote: > >Although libc's __new_open() could have this: > > > > /* Old kernels only look at O_DSYNC. It's better than nothing. */ > > if (flags& O_SYNC) > > flags |= O_DSYNC; > > > >Imho, it's better to not do that, and instead have > > > > #define O_SYNC (O_DSYNC|__O_SYNC_KERNEL) > > Why should it be better? You're replacing something the compiler can do > with zero cost with active code.
You misread; I said the zero cost thing is better.
The only reason you might use the active code is this:
/* Upgrade O_DSYNC to O_SYNC. */
flags = fcntl(fd, F_GETFL, 0); flags = (flags | O_SYNC) & ~O_DSYNC; fcntl(fd, F_SETFL, flags);
I'm not sure if that should work in POSIX.
-- Jamie
| |