1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 1997,2008 Oracle. All rights reserved. 5 * 6 * $Id: os_fsync.c,v 12.13 2008/01/08 20:58:46 bostic Exp $ 7 */ 8 9#include "db_config.h" 10 11#include "db_int.h" 12 13/* 14 * __os_fsync -- 15 * Flush a file descriptor. 16 */ 17int 18__os_fsync(env, fhp) 19 ENV *env; 20 DB_FH *fhp; 21{ 22 DB_ENV *dbenv; 23 int ret; 24 25 dbenv = env == NULL ? NULL : env->dbenv; 26 27 /* 28 * Do nothing if the file descriptor has been marked as not requiring 29 * any sync to disk. 30 */ 31 if (F_ISSET(fhp, DB_FH_NOSYNC)) 32 return (0); 33 34 if (dbenv != NULL && FLD_ISSET(dbenv->verbose, DB_VERB_FILEOPS_ALL)) 35 __db_msg(env, "fileops: flush %s", fhp->name); 36 37 RETRY_CHK((!FlushFileBuffers(fhp->handle)), ret); 38 if (ret != 0) { 39 __db_syserr(env, ret, "FlushFileBuffers"); 40 ret = __os_posix_err(ret); 41 } 42 return (ret); 43} 44