improved patch from block-raw-posix.c
PATCH 1/1 improved patch from block-raw-posix.c
This patch is an improvement over a previous patch for the file block-raw-posix.c. This time the code checks to see if O_FSYNC is defined before defining O_SYNC as O_FSYNC. If it isn't defined, then it defines O_SYNC as 0.
Users/misbah/Desktop/block-raw-posix.c renamed from Users/misbah/Desktop/block-raw-posix-original.c +10 -0
@@ -73,6 +73,16 @@ #define DEBUG_BLOCK_PRINT(formatCstr, args...)#endif +/* 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 +/* OS X does not have O_DSYNC */ #ifndef O_DSYNC #define O_DSYNC O_SYNC
Quoted 3 lines · G 3 wrote:
This patch is an improvement over a previous patch for the file
block-raw-posix.c. This time the code checks to see ifO_FSYNCis defined before definingO_SYNCasO_FSYNC. If it isn't defined, then it definesO_SYNCas 0.Signed-off-by ProgrammingKid <[email protected]>
You have to use your real name with Signed-off-by.
See http://kerneltrap.org/files/Jeremy/DCO.txt
Regards,
Anthony Liguori
Review
Quoted 9 lines · On Sun, Jun 21, 2009 at 07:55:43PM -0400, G 3 wrote:
(quoted diff) +9
-0+/* 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 <[email protected]>
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).
block/raw-posix.c +5 -2
@@ -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 */