patch: when fnctl(fd, F_FULLSYNC, 0) returns ENOTSUP
529931Dec 6 2006 — edited Dec 6 2006I'm trying to run Berkeley DB 4.5.20 on a USB key formatted FAT32 on Mac OS X 10.4.8.
On that plaform, Berkeley DB is compiled with F_FULLSYNC considered available which is true when the file system is HFS+ or its variants but not FAT32. On a FAT32 filesystem, ENOTSUP is returned. This is documented in the OS X fcntl man page. The patch below reverts to regular fsync() if that is the case as is already done, statically, in the code. Is it OK to do this or are there problems with this I'm not aware of ?
Andi..
--- db-4.5.20/os/os_fsync.c 2006-12-06 12:29:17.000000000 -0800
+++ db-4.5.20-patched/os/os_fsync.c 2006-12-06 12:25:25.000000000 -0800
@@ -68,23 +68,28 @@
* Do nothing if the file descriptor has been marked as not requiring
* any sync to disk.
*/
if (F_ISSET(fhp, DB_FH_NOSYNC))
return (0);
if (DB_GLOBAL(j_fsync) != NULL)
ret = DB_GLOBAL(j_fsync)(fhp->fd);
- else
+ else {
#if defined(F_FULLFSYNC)
RETRY_CHK((fcntl(fhp->fd, F_FULLFSYNC, 0)), ret);
+ if (ret == ENOTSUP) {
+ ret = 0;
+ RETRY_CHK((fsync(fhp->fd)), ret);
+ }
#elif defined(HAVE_FDATASYNC)
RETRY_CHK((fdatasync(fhp->fd)), ret);
#else
RETRY_CHK((fsync(fhp->fd)), ret);
#endif
+ }
if (ret != 0) {
__db_syserr(dbenv, ret, "fsync");
ret = __os_posix_err(ret);
}
return (ret);
}