db

os_fsync.c

Go to the documentation of this file.
00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1997, 1998, 1999, 2000
00005  * Sleepycat Software. All rights reserved.
00006  */
00007 
00008 #include "config.h"
00009 
00010 #ifndef lint
00011 static const char revid[] = "$Id: os__fsync_8c-source.html,v 1.1 2008年06月08日 10:21:15 sebdiaz Exp $";
00012 #endif /* not lint */
00013 
00014 #ifndef NO_SYSTEM_INCLUDES
00015 #include <sys/types.h>
00016 
00017 #include <fcntl.h> /* XXX: Required by __hp3000s900 */
00018 #include <unistd.h>
00019 #include <string.h>
00020 #endif
00021 
00022 #include "db_int.h"
00023 #include "os_jump.h"
00024 
00025 #ifdef HAVE_VXWORKS
00026 #include "ioLib.h"
00027 
00028 #define fsync(fd) __vx_fsync(fd);
00029 
00030 int
00031 __vx_fsync(fd)
00032 int fd;
00033 {
00034 int ret;
00035 
00036 /*
00037  * The results of ioctl are driver dependent. Some will return the
00038  * number of bytes sync'ed. Only if it returns 'ERROR' should we
00039  * flag it.
00040  */
00041 if ((ret = ioctl(fd, FIOSYNC, 0)) != ERROR)
00042 return (0);
00043 return (ret);
00044 }
00045 #endif
00046 
00047 #ifdef __hp3000s900
00048 #define fsync(fd) __mpe_fsync(fd);
00049 
00050 int
00051 __mpe_fsync(fd)
00052 int fd;
00053 {
00054 extern FCONTROL(short, short, void *);
00055 
00056 FCONTROL(_MPE_FILENO(fd), 2, NULL); /* Flush the buffers */
00057 FCONTROL(_MPE_FILENO(fd), 6, NULL); /* Write the EOF */
00058 return (0);
00059 }
00060 #endif
00061 
00062 /*
00063  * CDB___os_fsync --
00064  * Flush a file descriptor.
00065  *
00066  * PUBLIC: int CDB___os_fsync __P((DB_ENV *, DB_FH *));
00067  */
00068 int
00069 CDB___os_fsync(dbenv, fhp)
00070 DB_ENV *dbenv;
00071 DB_FH *fhp;
00072 {
00073 int ret;
00074 
00075 /*
00076  * Do nothing if the file descriptor has been marked as not requiring
00077  * any sync to disk.
00078  */
00079 if (F_ISSET(fhp, DB_FH_NOSYNC))
00080 return (0);
00081 
00082 ret = CDB___db_jump.j_fsync != NULL ?
00083 CDB___db_jump.j_fsync(fhp->fd) : fsync(fhp->fd);
00084 
00085 if (ret != 0) {
00086 ret = CDB___os_get_errno();
00087 CDB___db_err(dbenv, "fsync %s", strerror(ret));
00088 }
00089 return (ret);
00090 }

Generated on Sun Jun 8 10:56:38 2008 for GNUmifluz by doxygen 1.5.5

AltStyle によって変換されたページ (->オリジナル) /