diff options
Diffstat (limited to 'bdb/os/os_open.c')
-rw-r--r-- | bdb/os/os_open.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/bdb/os/os_open.c b/bdb/os/os_open.c index cdc75cd737b..0a4dbadc6e8 100644 --- a/bdb/os/os_open.c +++ b/bdb/os/os_open.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997, 1998, 1999, 2000 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "$Id: os_open.c,v 11.21 2001/01/11 18:19:53 bostic Exp $"; +static const char revid[] = "$Id: os_open.c,v 11.37 2002/06/21 20:35:16 sandstro Exp $"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -42,6 +42,15 @@ __os_open(dbenv, name, flags, mode, fhp) oflags = 0; +#ifdef DIAGNOSTIC +#define OKFLAGS \ + (DB_OSO_CREATE | DB_OSO_DIRECT | DB_OSO_EXCL | DB_OSO_LOG | \ + DB_OSO_RDONLY | DB_OSO_REGION | DB_OSO_SEQ | DB_OSO_TEMP | \ + DB_OSO_TRUNC) + if ((ret = __db_fchk(dbenv, "__os_open", flags, OKFLAGS)) != 0) + return (ret); +#endif + #if defined(O_BINARY) /* * If there's a binary-mode open flag, set it, we never want any @@ -84,6 +93,11 @@ __os_open(dbenv, name, flags, mode, fhp) if (LF_ISSET(DB_OSO_TRUNC)) oflags |= O_TRUNC; +#ifdef HAVE_O_DIRECT + if (LF_ISSET(DB_OSO_DIRECT)) + oflags |= O_DIRECT; +#endif + #ifdef HAVE_QNX if (LF_ISSET(DB_OSO_REGION)) return (__os_region_open(dbenv, name, oflags, mode, fhp)); @@ -92,6 +106,11 @@ __os_open(dbenv, name, flags, mode, fhp) if ((ret = __os_openhandle(dbenv, name, oflags, mode, fhp)) != 0) return (ret); +#ifdef HAVE_DIRECTIO + if (LF_ISSET(DB_OSO_DIRECT)) + (void)directio(fhp->fd, DIRECTIO_ON); +#endif + /* * Delete any temporary file. * @@ -102,8 +121,18 @@ __os_open(dbenv, name, flags, mode, fhp) * reasonable way to avoid the race (playing signal games isn't worth * the portability nightmare), so we just live with it. */ - if (LF_ISSET(DB_OSO_TEMP)) + if (LF_ISSET(DB_OSO_TEMP)) { +#if defined(HAVE_UNLINK_WITH_OPEN_FAILURE) || defined(CONFIG_TEST) + if ((ret = __os_strdup(dbenv, name, &fhp->name)) != 0) { + (void)__os_closehandle(dbenv, fhp); + (void)__os_unlink(dbenv, name); + return (ret); + } + F_SET(fhp, DB_FH_UNLINK); +#else (void)__os_unlink(dbenv, name); +#endif + } return (0); } @@ -136,7 +165,7 @@ __os_region_open(dbenv, name, oflags, mode, fhp) if (fcntl(fhp->fd, F_SETFD, 1) == -1) { ret = __os_get_errno(); __db_err(dbenv, "fcntl(F_SETFD): %s", strerror(ret)); - __os_closehandle(fhp); + __os_closehandle(dbenv, fhp); } else #endif F_SET(fhp, DB_FH_VALID); @@ -147,7 +176,7 @@ __os_region_open(dbenv, name, oflags, mode, fhp) */ err: if (newname != NULL) - __os_free(newname, 0); + __os_free(dbenv, newname); return (ret); } @@ -155,7 +184,9 @@ err: * __os_shmname -- * Translate a pathname into a shm_open memory object name. * + * PUBLIC: #ifdef HAVE_QNX * PUBLIC: int __os_shmname __P((DB_ENV *, const char *, char **)); + * PUBLIC: #endif */ int __os_shmname(dbenv, name, newnamep) @@ -206,7 +237,7 @@ __os_shmname(dbenv, name, newnamep) * If we have a path component, copy and return it. */ ret = __os_strdup(dbenv, p, newnamep); - __os_free(tmpname, 0); + __os_free(dbenv, tmpname); return (ret); } @@ -215,11 +246,11 @@ __os_shmname(dbenv, name, newnamep) * Add a leading slash, and copy the remainder. */ size = strlen(tmpname) + 2; - if ((ret = __os_malloc(dbenv, size, NULL, &p)) != 0) + if ((ret = __os_malloc(dbenv, size, &p)) != 0) return (ret); p[0] = '/'; memcpy(&p[1], tmpname, size-1); - __os_free(tmpname, 0); + __os_free(dbenv, tmpname); *newnamep = p; return (0); } |