summaryrefslogtreecommitdiff
path: root/db/os/os_stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'db/os/os_stat.c')
-rw-r--r--db/os/os_stat.c50
1 files changed, 34 insertions, 16 deletions
diff --git a/db/os/os_stat.c b/db/os/os_stat.c
index 1590e8ecd..cdc362a3b 100644
--- a/db/os/os_stat.c
+++ b/db/os/os_stat.c
@@ -1,24 +1,24 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2003
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: os_stat.c,v 11.8 2000/10/27 20:32:02 dda Exp $";
+static const char revid[] = "$Id: os_stat.c,v 11.24 2003/02/16 15:54:06 bostic Exp $";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#include <sys/stat.h>
+
#include <string.h>
#endif
#include "db_int.h"
-#include "os_jump.h"
/*
* __os_exists --
@@ -31,20 +31,31 @@ __os_exists(path, isdirp)
const char *path;
int *isdirp;
{
+ int ret, retries;
struct stat sb;
- if (__db_jump.j_exists != NULL)
- return (__db_jump.j_exists(path, isdirp));
+ if (DB_GLOBAL(j_exists) != NULL)
+ return (DB_GLOBAL(j_exists)(path, isdirp));
+ retries = 0;
+ do {
+ ret =
#ifdef HAVE_VXWORKS
- if (stat((char *)path, &sb) != 0)
+ stat((char *)path, &sb);
#else
- if (stat(path, &sb) != 0)
+ stat(path, &sb);
#endif
- return (__os_get_errno());
+ if (ret != 0)
+ ret = __os_get_errno();
+ } while ((ret == EINTR || ret == EBUSY) &&
+ ++retries < DB_RETRY);
+
+ if (ret != 0)
+ return (ret);
#if !defined(S_ISDIR) || defined(STAT_MACROS_BROKEN)
-#ifdef DB_WIN32
+#undef S_ISDIR
+#ifdef _S_IFDIR
#define S_ISDIR(m) (_S_IFDIR & (m))
#else
#define S_ISDIR(m) (((m) & 0170000) == 0040000)
@@ -71,24 +82,31 @@ __os_ioinfo(dbenv, path, fhp, mbytesp, bytesp, iosizep)
DB_FH *fhp;
u_int32_t *mbytesp, *bytesp, *iosizep;
{
- int ret;
+ int ret, retries;
struct stat sb;
- if (__db_jump.j_ioinfo != NULL)
- return (__db_jump.j_ioinfo(path,
+ if (DB_GLOBAL(j_ioinfo) != NULL)
+ return (DB_GLOBAL(j_ioinfo)(path,
fhp->fd, mbytesp, bytesp, iosizep));
+ /* Check for illegal usage. */
+ DB_ASSERT(F_ISSET(fhp, DB_FH_OPENED) && fhp->fd != -1);
+
+ retries = 0;
+retry:
if (fstat(fhp->fd, &sb) == -1) {
- ret = __os_get_errno();
+ if (((ret = __os_get_errno()) == EINTR || ret == EBUSY) &&
+ ++retries < DB_RETRY)
+ goto retry;
__db_err(dbenv, "fstat: %s", strerror(ret));
return (ret);
}
/* Return the size of the file. */
if (mbytesp != NULL)
- *mbytesp = sb.st_size / MEGABYTE;
+ *mbytesp = (u_int32_t)(sb.st_size / MEGABYTE);
if (bytesp != NULL)
- *bytesp = sb.st_size % MEGABYTE;
+ *bytesp = (u_int32_t)(sb.st_size % MEGABYTE);
/*
* Return the underlying filesystem blocksize, if available.
@@ -97,7 +115,7 @@ __os_ioinfo(dbenv, path, fhp, mbytesp, bytesp, iosizep)
* Check for a 0 size -- the HP MPE/iX architecture has st_blksize,
* but it's always 0.
*/
-#ifdef HAVE_ST_BLKSIZE
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
if (iosizep != NULL && (*iosizep = sb.st_blksize) == 0)
*iosizep = DB_DEF_IOSIZE;
#else