diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-06-09 15:16:55 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-06-09 15:16:55 +0000 |
commit | bf7997b65c7887d2acda95f5201d818a19d81711 (patch) | |
tree | da3583de3a0b5892f90a4b1eb773a87b554ae37e /db2/os | |
parent | 7646e67e6cc4c738a7b402c60fed39d52db0433b (diff) | |
download | glibc-bf7997b65c7887d2acda95f5201d818a19d81711.zip glibc-bf7997b65c7887d2acda95f5201d818a19d81711.tar.gz glibc-bf7997b65c7887d2acda95f5201d818a19d81711.tar.bz2 |
Update.
1998-06-09 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/sysv/linux/netinet/ip.h (struct ip_options): Define
__data member only for gcc. Reported by ak@muc.de.
* misc/mntent.h: Undo last patch.
* sysdeps/unix/sysv/linux/fstatvfs.c (fstatvfs): Undo last patch.
* misc/tst/mntent.c: Adjust code for this change.
* io/fts.c: Updated from a slightly more recent BSD version.
* io/fts.h: Likewise.
* libc.map: Add __libc_stack_end.
* db2/Makefile (routines): Add lock_region.
* db2/config.h: Update from db-2.4.14.
* db2/db.h: Likewise.
* db2/db_185.h: Likewise.
* db2/db_int.h: Likewise.
* db2/bt_close.c: Likewise.
* db2/bt_compare.c: Likewise.
* db2/bt_conv.c: Likewise.
* db2/bt_cursor.c: Likewise.
* db2/bt_delete.c: Likewise.
* db2/bt_open.c: Likewise.
* db2/bt_page.c: Likewise.
* db2/bt_put.c: Likewise.
* db2/bt_rec.c: Likewise.
* db2/bt_recno.c: Likewise.
* db2/bt_rsearch.c: Likewise.
* db2/bt_search.c: Likewise.
* db2/bt_split.c: Likewise.
* db2/bt_stat.c: Likewise.
* db2/btree.src: Likewise.
* db2/btree_auto.c: Likewise.
* db2/getlong.c: Likewise.
* db2/db_appinit.c: Likewise.
* db2/db_apprec.c: Likewise.
* db2/db_byteorder.c: Likewise.
* db2/db_err.c: Likewise.
* db2/db_log2.c: Likewise.
* db2/db_region.c: Likewise.
* db2/db_salloc.c: Likewise.
* db2/db_shash.c: Likewise.
* db2/db.c: Likewise.
* db2/db.src: Likewise.
* db2/db_auto.c: Likewise.
* db2/db_conv.c: Likewise.
* db2/db_dispatch.c: Likewise.
* db2/db_dup.c: Likewise.
* db2/db_overflow.c: Likewise.
* db2/db_pr.c: Likewise.
* db2/db_rec.c: Likewise.
* db2/db_ret.c: Likewise.
* db2/db_thread.c: Likewise.
* db2/db185.c: Likewise.
* db2/db185_int.h: Likewise.
* db2/dbm.c: Likewise.
* db2/hash.c: Likewise.
* db2/hash.src: Likewise.
* db2/hash_auto.c: Likewise.
* db2/hash_conv.c: Likewise.
* db2/hash_debug.c: Likewise.
* db2/hash_dup.c: Likewise.
* db2/hash_func.c: Likewise.
* db2/hash_page.c: Likewise.
* db2/hash_rec.c: Likewise.
* db2/hash_stat.c: Likewise.
* db2/btree.h: Likewise.
* db2/btree_ext.h: Likewise.
* db2/clib_ext.h: Likewise.
* db2/common_ext.h: Likewise.
* db2/cxx_int.h: Likewise.
* db2/db.h.src: Likewise.
* db2/db_185.h.src: Likewise.
* db2/db_am.h: Likewise.
* db2/db_auto.h: Likewise.
* db2/db_cxx.h: Likewise.
* db2/db_dispatch.h: Likewise.
* db2/db_ext.h: Likewise.
* db2/db_int.h.src: Likewise.
* db2/db_page.h: Likewise.
* db2/db_shash.h: Likewise.
* db2/db_swap.h: Likewise.
* db2/hash.h: Likewise.
* db2/hash_ext.h: Likewise.
* db2/lock.h: Likewise.
* db2/lock_ext.h: Likewise.
* db2/log.h: Likewise.
* db2/log_ext.h: Likewise.
* db2/mp.h: Likewise.
* db2/mp_ext.h: Likewise.
* db2/mutex_ext.h: Likewise.
* db2/os_ext.h: Likewise.
* db2/os_func.h: Likewise.
* db2/queue.h: Likewise.
* db2/shqueue.h: Likewise.
* db2/txn.h: Likewise.
* db2/lock.c: Likewise.
* db2/lock_conflict.c: Likewise.
* db2/lock_deadlock.c: Likewise.
* db2/lock_region.c: Likewise.
* db2/lock_util.c: Likewise.
* db2/log.c: Likewise.
* db2/log.src: Likewise.
* db2/log_archive.c: Likewise.
* db2/log_auto.c: Likewise.
* db2/log_compare.c: Likewise.
* db2/log_findckp.c: Likewise.
* db2/log_get.c: Likewise.
* db2/log_put.c: Likewise.
* db2/log_rec.c: Likewise.
* db2/log_register.c: Likewise.
* db2/mp_bh.c: Likewise.
* db2/mp_fget.c: Likewise.
* db2/mp_fopen.c: Likewise.
* db2/mp_fput.c: Likewise.
* db2/mp_fset.c: Likewise.
* db2/mp_open.c: Likewise.
* db2/mp_pr.c: Likewise.
* db2/mp_region.c: Likewise.
* db2/mp_sync.c: Likewise.
* db2/68020.gcc: Likewise.
* db2/mutex.c: Likewise.
* db2/parisc.gcc: Likewise.
* db2/parisc.hp: Likewise.
* db2/sco.cc: Likewise.
* db2/os_abs.c: Likewise.
* db2/os_alloc.c: Likewise.
* db2/os_config.c: Likewise.
* db2/os_dir.c: Likewise.
* db2/os_fid.c: Likewise.
* db2/os_fsync.c: Likewise.
* db2/os_map.c: Likewise.
* db2/os_oflags.c: Likewise.
* db2/os_open.c: Likewise.
* db2/os_rpath.c: Likewise.
* db2/os_rw.c: Likewise.
* db2/os_seek.c: Likewise.
* db2/os_sleep.c: Likewise.
* db2/os_spin.c: Likewise.
* db2/os_stat.c: Likewise.
* db2/os_unlink.c: Likewise.
* db2/db_archive.c: Likewise.
* db2/db_checkpoint.c: Likewise.
* db2/db_deadlock.c: Likewise.
* db2/db_dump.c: Likewise.
* db2/db_dump185.c: Likewise.
* db2/db_load.c: Likewise.
* db2/db_printlog.c: Likewise.
* db2/db_recover.c: Likewise.
* db2/db_stat.c: Likewise.
* db2/txn.c: Likewise.
* db2/txn.src: Likewise.
* db2/txn_auto.c: Likewise.
* db2/txn_rec.c: Likewise.
* elf/rtld.c: Move definition of __libc_stack_end to ...
* sysdeps/generic/dl-sysdep.h: ...here.
* sysdeps/unix/sysv/linux/fstatvfs.c: Handle nodiratime option.
* sysdeps/unix/sysv/linux/bits/statvfs.h: Define ST_NODIRATIME.
* sysdeps/unix/sysv/linux/sys/mount.h: Define MS_NODIRATIME.
1998-06-08 21:44 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/sysv/linux/fstatvfs.c: Handle constant option string
from mntent correctly.
1998-06-06 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sunrpc/Makefile (generated): Correct typo.
1998-06-04 Philip Blundell <philb@gnu.org>
* elf/elf.h (EM_ARM, et al.): New definitions.
* sysdeps/arm/dl-machine.h: Update for new draft ARM ELF ABI.
Diffstat (limited to 'db2/os')
-rw-r--r-- | db2/os/os_abs.c | 4 | ||||
-rw-r--r-- | db2/os/os_alloc.c | 44 | ||||
-rw-r--r-- | db2/os/os_config.c | 120 | ||||
-rw-r--r-- | db2/os/os_dir.c | 8 | ||||
-rw-r--r-- | db2/os/os_fid.c | 5 | ||||
-rw-r--r-- | db2/os/os_fsync.c | 19 | ||||
-rw-r--r-- | db2/os/os_map.c | 440 | ||||
-rw-r--r-- | db2/os/os_oflags.c | 56 | ||||
-rw-r--r-- | db2/os/os_open.c | 13 | ||||
-rw-r--r-- | db2/os/os_rpath.c | 4 | ||||
-rw-r--r-- | db2/os/os_rw.c | 4 | ||||
-rw-r--r-- | db2/os/os_seek.c | 16 | ||||
-rw-r--r-- | db2/os/os_sleep.c | 7 | ||||
-rw-r--r-- | db2/os/os_spin.c | 41 | ||||
-rw-r--r-- | db2/os/os_stat.c | 27 | ||||
-rw-r--r-- | db2/os/os_unlink.c | 4 |
16 files changed, 664 insertions, 148 deletions
diff --git a/db2/os/os_abs.c b/db2/os/os_abs.c index 872e46d..d9f4970 100644 --- a/db2/os/os_abs.c +++ b/db2/os/os_abs.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_abs.c 10.7 (Sleepycat) 10/24/97"; +static const char sccsid[] = "@(#)os_abs.c 10.8 (Sleepycat) 4/10/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES diff --git a/db2/os/os_alloc.c b/db2/os/os_alloc.c index 27abffb..3578447 100644 --- a/db2/os/os_alloc.c +++ b/db2/os/os_alloc.c @@ -1,26 +1,46 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_alloc.c 10.1 (Sleepycat) 12/1/97"; +static const char sccsid[] = "@(#)os_alloc.c 10.6 (Sleepycat) 5/2/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES #include <sys/types.h> -#include <errno.h> #include <string.h> #endif #include "db_int.h" /* + * __db_strdup -- + * The strdup(3) function for DB. + * + * PUBLIC: char *__db_strdup __P((const char *)); + */ +char * +__db_strdup(str) + const char *str; +{ + size_t len; + char *copy; + + len = strlen(str) + 1; + if ((copy = __db_malloc(len)) == NULL) + return (NULL); + + memcpy(copy, str, len); + return (copy); +} + +/* * XXX * Correct for systems that return NULL when you allocate 0 bytes of memory. * There are several places in DB where we allocate the number of bytes held @@ -28,6 +48,10 @@ static const char sccsid[] = "@(#)os_alloc.c 10.1 (Sleepycat) 12/1/97"; * returns a NULL for that reason (which behavior is permitted by ANSI). We * could make these calls macros on non-Alpha architectures (that's where we * saw the problem), but it's probably not worth the autoconf complexity. + * + * Out of memory. + * We wish to hold the whole sky, + * But we never will. */ /* * __db_calloc -- @@ -42,7 +66,7 @@ __db_calloc(num, size) void *p; size *= num; - if ((p = __db_jump.db_malloc(size == 0 ? 1 : size)) != NULL) + if ((p = __db_jump.j_malloc(size == 0 ? 1 : size)) != NULL) memset(p, 0, size); return (p); } @@ -57,7 +81,15 @@ void * __db_malloc(size) size_t size; { - return (__db_jump.db_malloc(size == 0 ? 1 : size)); +#ifdef DIAGNOSTIC + void *p; + + p = __db_jump.j_malloc(size == 0 ? 1 : size); + memset(p, 0xff, size == 0 ? 1 : size); + return (p); +#else + return (__db_jump.j_malloc(size == 0 ? 1 : size)); +#endif } /* @@ -71,5 +103,5 @@ __db_realloc(ptr, size) void *ptr; size_t size; { - return (__db_jump.db_realloc(ptr, size == 0 ? 1 : size)); + return (__db_jump.j_realloc(ptr, size == 0 ? 1 : size)); } diff --git a/db2/os/os_config.c b/db2/os/os_config.c index 7a89ba5..4150c84 100644 --- a/db2/os/os_config.c +++ b/db2/os/os_config.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_config.c 10.12 (Sleepycat) 1/8/98"; +static const char sccsid[] = "@(#)os_config.c 10.26 (Sleepycat) 5/23/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -20,22 +20,6 @@ static const char sccsid[] = "@(#)os_config.c 10.12 (Sleepycat) 1/8/98"; #include "db_int.h" /* - * __os_oldwin -- - * Return if Windows 95 (as opposed to Windows NT). - * - * PUBLIC: int __os_oldwin __P((void)); - */ -int -__os_oldwin() -{ -#ifdef _WIN32 - return ((GetVersion() & 0x80000000) != 0); -#else - return (0); -#endif -} - -/* * XXX * We provide our own extern declarations so that we don't collide with * systems that get them wrong, e.g., SunOS. @@ -47,13 +31,20 @@ __os_oldwin() #define imported #endif +/* + * XXX + * HP/UX MPE doesn't have fsync, but you can build one using FCONTROL. + */ +#ifdef __hp3000s900 +#define fsync __mpe_fsync +#endif + imported extern int close __P((int)); imported extern void free __P((void *)); imported extern int fsync __P((int)); imported extern void *malloc __P((size_t)); imported extern int open __P((const char *, int, ...)); imported extern ssize_t read __P((int, void *, size_t)); -imported extern char *strdup __P((const char *)); imported extern void *realloc __P((void *, size_t)); imported extern int unlink __P((const char *)); imported extern ssize_t write __P((int, const void *, size_t)); @@ -63,7 +54,7 @@ imported extern ssize_t write __P((int, const void *, size_t)); * This list of interfaces that applications can replace. In some * cases, the user is permitted to replace the standard ANSI C or * POSIX 1003.1 call, e.g., malloc or read. In others, we provide - * a local interface to the functionality, e.g., __os_map. + * a local interface to the functionality, e.g., __os_ioinfo. */ struct __db_jumptab __db_jump = { close, /* DB_FUNC_CLOSE */ @@ -74,20 +65,26 @@ struct __db_jumptab __db_jump = { fsync, /* DB_FUNC_FSYNC */ __os_ioinfo, /* DB_FUNC_IOINFO */ malloc, /* DB_FUNC_MALLOC */ - __os_map, /* DB_FUNC_MAP */ + NULL, /* DB_FUNC_MAP */ open, /* DB_FUNC_OPEN */ read, /* DB_FUNC_READ */ realloc, /* DB_FUNC_REALLOC */ + NULL, /* DB_FUNC_RUNLINK */ __os_seek, /* DB_FUNC_SEEK */ __os_sleep, /* DB_FUNC_SLEEP */ - strdup, /* DB_FUNC_STRDUP */ unlink, /* DB_FUNC_UNLINK */ - __os_unmap, /* DB_FUNC_UNMAP */ + NULL, /* DB_FUNC_UNMAP */ write, /* DB_FUNC_WRITE */ NULL /* DB_FUNC_YIELD */ }; -int __db_tsl_spins; /* DB_TSL_SPINS */ +DB_GLOBALS __db_global_values = { + 1, /* DB_MUTEXLOCKS */ + 0, /* DB_REGION_ANON, DB_REGION_NAME */ + 0, /* DB_REGION_INIT */ + 0, /* DB_TSL_SPINS */ + 0 /* DB_PAGEYIELD */ +}; /* * db_jump_set -- @@ -99,74 +96,68 @@ db_jump_set(func, which) int which; { switch (which) { - case DB_FUNC_CALLOC: - /* - * XXX - * Obsolete, calloc is no longer called by DB. - */ - break; case DB_FUNC_CLOSE: - __db_jump.db_close = (int (*) __P((int)))func; + __db_jump.j_close = (int (*) __P((int)))func; break; case DB_FUNC_DIRFREE: - __db_jump.db_dirfree = (void (*) __P((char **, int)))func; + __db_jump.j_dirfree = (void (*) __P((char **, int)))func; break; case DB_FUNC_DIRLIST: - __db_jump.db_dirlist = + __db_jump.j_dirlist = (int (*) __P((const char *, char ***, int *)))func; break; case DB_FUNC_EXISTS: - __db_jump.db_exists = (int (*) __P((const char *, int *)))func; + __db_jump.j_exists = (int (*) __P((const char *, int *)))func; break; case DB_FUNC_FREE: - __db_jump.db_free = (void (*) __P((void *)))func; + __db_jump.j_free = (void (*) __P((void *)))func; break; case DB_FUNC_FSYNC: - __db_jump.db_fsync = (int (*) __P((int)))func; + __db_jump.j_fsync = (int (*) __P((int)))func; break; case DB_FUNC_IOINFO: - __db_jump.db_ioinfo = (int (*) __P((const char *, + __db_jump.j_ioinfo = (int (*) __P((const char *, int, u_int32_t *, u_int32_t *, u_int32_t *)))func; break; case DB_FUNC_MALLOC: - __db_jump.db_malloc = (void *(*) __P((size_t)))func; + __db_jump.j_malloc = (void *(*) __P((size_t)))func; break; case DB_FUNC_MAP: - __db_jump.db_map = - (int (*) __P((int, size_t, int, int, void **)))func; + __db_jump.j_map = (int (*) + __P((char *, int, size_t, int, int, int, void **)))func; break; case DB_FUNC_OPEN: - __db_jump.db_open = (int (*) __P((const char *, int, ...)))func; + __db_jump.j_open = (int (*) __P((const char *, int, ...)))func; break; case DB_FUNC_READ: - __db_jump.db_read = + __db_jump.j_read = (ssize_t (*) __P((int, void *, size_t)))func; break; case DB_FUNC_REALLOC: - __db_jump.db_realloc = (void *(*) __P((void *, size_t)))func; + __db_jump.j_realloc = (void *(*) __P((void *, size_t)))func; + break; + case DB_FUNC_RUNLINK: + __db_jump.j_runlink = (int (*) __P((char *)))func; break; case DB_FUNC_SEEK: - __db_jump.db_seek = - (int (*) __P((int, size_t, db_pgno_t, u_long, int)))func; + __db_jump.j_seek = (int (*) + __P((int, size_t, db_pgno_t, u_int32_t, int, int)))func; break; case DB_FUNC_SLEEP: - __db_jump.db_sleep = (int (*) __P((u_long, u_long)))func; - break; - case DB_FUNC_STRDUP: - __db_jump.db_strdup = (char *(*) __P((const char *)))func; + __db_jump.j_sleep = (int (*) __P((u_long, u_long)))func; break; case DB_FUNC_UNLINK: - __db_jump.db_unlink = (int (*) __P((const char *)))func; + __db_jump.j_unlink = (int (*) __P((const char *)))func; break; case DB_FUNC_UNMAP: - __db_jump.db_unmap = (int (*) __P((void *, size_t)))func; + __db_jump.j_unmap = (int (*) __P((void *, size_t)))func; break; case DB_FUNC_WRITE: - __db_jump.db_write = + __db_jump.j_write = (ssize_t (*) __P((int, const void *, size_t)))func; break; case DB_FUNC_YIELD: - __db_jump.db_yield = (int (*) __P((void)))func; + __db_jump.j_yield = (int (*) __P((void)))func; break; default: return (EINVAL); @@ -182,11 +173,32 @@ int db_value_set(value, which) int value, which; { + int ret; + switch (which) { + case DB_MUTEXLOCKS: + DB_GLOBAL(db_mutexlocks) = value; + break; + case DB_PAGEYIELD: + DB_GLOBAL(db_pageyield) = value; + break; + case DB_REGION_ANON: + if (value != 0 && (ret = __db_mapanon_ok(0)) != 0) + return (ret); + DB_GLOBAL(db_region_anon) = value; + break; + case DB_REGION_INIT: + DB_GLOBAL(db_region_init) = value; + break; + case DB_REGION_NAME: + if (value != 0 && (ret = __db_mapanon_ok(1)) != 0) + return (ret); + DB_GLOBAL(db_region_anon) = value; + break; case DB_TSL_SPINS: if (value <= 0) return (EINVAL); - __db_tsl_spins = value; + DB_GLOBAL(db_tsl_spins) = value; break; default: return (EINVAL); diff --git a/db2/os/os_dir.c b/db2/os/os_dir.c index 10fb8b6..14a10ad 100644 --- a/db2/os/os_dir.c +++ b/db2/os/os_dir.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_dir.c 10.13 (Sleepycat) 10/28/97"; +static const char sccsid[] = "@(#)os_dir.c 10.15 (Sleepycat) 4/26/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -32,13 +32,9 @@ static const char sccsid[] = "@(#)os_dir.c 10.13 (Sleepycat) 10/28/97"; #endif #include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> #endif #include "db_int.h" -#include "common_ext.h" /* * __os_dirlist -- diff --git a/db2/os/os_fid.c b/db2/os/os_fid.c index 6820b88..cf48c01 100644 --- a/db2/os/os_fid.c +++ b/db2/os/os_fid.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996, 1997 + * Copyright (c) 1996, 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_fid.c 10.9 (Sleepycat) 10/24/97"; +static const char sccsid[] = "@(#)os_fid.c 10.11 (Sleepycat) 4/26/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -16,7 +16,6 @@ static const char sccsid[] = "@(#)os_fid.c 10.9 (Sleepycat) 10/24/97"; #include <sys/stat.h> #include <errno.h> -#include <stdlib.h> #include <string.h> #include <time.h> #endif diff --git a/db2/os/os_fsync.c b/db2/os/os_fsync.c index 7b001ce..e1f271a 100644 --- a/db2/os/os_fsync.c +++ b/db2/os/os_fsync.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_fsync.c 10.3 (Sleepycat) 10/25/97"; +static const char sccsid[] = "@(#)os_fsync.c 10.5 (Sleepycat) 4/19/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -32,3 +32,18 @@ __db_fsync(fd) { return (__os_fsync(fd) ? errno : 0); } + +#ifdef __hp3000s900 +#include <fcntl.h> + +int +__mpe_fsync(fd) + int fd; +{ + extern FCONTROL(short, short, void *); + + FCONTROL(_MPE_FILENO(fd), 2, NULL); /* Flush the buffers */ + FCONTROL(_MPE_FILENO(fd), 6, NULL); /* Write the EOF */ + return (0); +} +#endif diff --git a/db2/os/os_map.c b/db2/os/os_map.c index b155318..5f0fd79 100644 --- a/db2/os/os_map.c +++ b/db2/os/os_map.c @@ -1,47 +1,395 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996, 1997 + * Copyright (c) 1996, 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_map.c 10.7 (Sleepycat) 10/25/97"; +static const char sccsid[] = "@(#)os_map.c 10.19 (Sleepycat) 5/3/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES #include <sys/types.h> +#ifdef HAVE_MMAP #include <sys/mman.h> +#endif + +#ifdef HAVE_SHMGET +#include <sys/ipc.h> +#include <sys/shm.h> +#endif #include <errno.h> +#include <string.h> #endif #include "db_int.h" +#include "common_ext.h" + +#ifdef HAVE_MMAP +static int __os_map __P((char *, int, size_t, int, int, int, void **)); +#endif +#ifdef HAVE_SHMGET +static int __os_shmget __P((char *, REGINFO *)); +#endif /* - * __os_map -- - * Map in some shared memory backed by a file descriptor. + * __db_mapanon_ok -- + * Return if this OS can support anonymous memory regions. + * + * PUBLIC: int __db_mapanon_ok __P((int)); + */ +int +__db_mapanon_ok(need_names) + int need_names; +{ + int ret; + + ret = EINVAL; + + /* + * If we don't have spinlocks, we have to have a file descriptor + * for fcntl(2) locking, which implies using mmap(2) to map in a + * regular file. Theoretically, we could probably find ways to + * get a file descriptor to lock other types of shared regions, + * but I don't see any reason to do so. + * + * If need_names is set, the application wants to share anonymous + * memory among multiple processes, so we have to have a way to + * name it. This requires shmget(2), on UNIX systems. + */ +#ifdef HAVE_SPINLOCKS +#ifdef HAVE_SHMGET + ret = 0; +#endif +#ifdef HAVE_MMAP +#ifdef MAP_ANON + if (!need_names) + ret = 0; +#endif +#ifdef MAP_ANONYMOUS + if (!need_names) + ret = 0; +#endif +#else + COMPQUIET(need_names, 0); +#endif /* HAVE_MMAP */ +#endif /* HAVE_SPINLOCKS */ + + return (ret); +} + +/* + * __db_mapinit -- + * Return if shared regions need to be initialized. + * + * PUBLIC: int __db_mapinit __P((void)); + */ +int +__db_mapinit() +{ + /* + * Historically, some systems required that all of the bytes of the + * region be written before it could be mmapped and accessed randomly. + * We have the option of setting REGION_INIT_NEEDED at configuration + * time if we're running on one of those systems. + */ +#ifdef REGION_INIT_NEEDED + return (1); +#else + return (0); +#endif +} + +/* + * __db_mapregion -- + * Attach to a shared memory region. + * + * PUBLIC: int __db_mapregion __P((char *, REGINFO *)); + */ +int +__db_mapregion(path, infop) + char *path; + REGINFO *infop; +{ + int called, ret; + + called = 0; + ret = EINVAL; + + /* If the user replaces the map call, call through their interface. */ + if (__db_jump.j_map != NULL) { + F_SET(infop, REGION_HOLDINGSYS); + return (__db_jump.j_map(path, infop->fd, infop->size, + 1, F_ISSET(infop, REGION_ANONYMOUS), 0, &infop->addr)); + } + + if (F_ISSET(infop, REGION_ANONYMOUS)) { + /* + * !!! + * If we're creating anonymous regions: + * + * If it's private, we use mmap(2). The problem with using + * shmget(2) is that we may be creating a region of which the + * application isn't aware, and if the application crashes + * we'll have no way to remove the system resources for the + * region. + * + * If it's not private, we use the shmget(2) interface if it's + * available, because it allows us to name anonymous memory. + * If shmget(2) isn't available, use the mmap(2) calls. + * + * In the case of anonymous memory, using mmap(2) means the + * memory isn't named and only the single process and its + * threads can access the region. + */ +#ifdef HAVE_MMAP +#ifdef MAP_ANON +#define HAVE_MMAP_ANONYMOUS 1 +#else +#ifdef MAP_ANONYMOUS +#define HAVE_MMAP_ANONYMOUS 1 +#endif +#endif +#endif +#ifdef HAVE_MMAP_ANONYMOUS + if (!called && F_ISSET(infop, REGION_PRIVATE)) { + called = 1; + ret = __os_map(path, + infop->fd, infop->size, 1, 1, 0, &infop->addr); + } +#endif +#ifdef HAVE_SHMGET + if (!called) { + called = 1; + ret = __os_shmget(path, infop); + } +#endif +#ifdef HAVE_MMAP + /* + * If we're trying to join an unnamed anonymous region, fail -- + * that's not possible. + */ + if (!called) { + called = 1; + + if (!F_ISSET(infop, REGION_CREATED)) { + __db_err(infop->dbenv, + "cannot join region in unnamed anonymous memory"); + return (EINVAL); + } + + ret = __os_map(path, + infop->fd, infop->size, 1, 1, 0, &infop->addr); + } +#endif + } else { + /* + * !!! + * If we're creating normal regions, we use the mmap(2) + * interface if it's available because it's POSIX 1003.1 + * standard and we trust it more than we do shmget(2). + */ +#ifdef HAVE_MMAP + if (!called) { + called = 1; + + /* Mmap(2) regions that aren't anonymous can grow. */ + F_SET(infop, REGION_CANGROW); + + ret = __os_map(path, + infop->fd, infop->size, 1, 0, 0, &infop->addr); + } +#endif +#ifdef HAVE_SHMGET + if (!called) { + called = 1; + ret = __os_shmget(path, infop); + } +#endif + } + return (ret); +} + +/* + * __db_unmapregion -- + * Detach from the shared memory region. + * + * PUBLIC: int __db_unmapregion __P((REGINFO *)); + */ +int +__db_unmapregion(infop) + REGINFO *infop; +{ + int called, ret; + + called = 0; + ret = EINVAL; + + if (__db_jump.j_unmap != NULL) + return (__db_jump.j_unmap(infop->addr, infop->size)); + +#ifdef HAVE_SHMGET + if (infop->segid != INVALID_SEGID) { + called = 1; + ret = shmdt(infop->addr) ? errno : 0; + } +#endif +#ifdef HAVE_MMAP + if (!called) { + called = 1; + ret = munmap(infop->addr, infop->size) ? errno : 0; + } +#endif + return (ret); +} + +/* + * __db_unlinkregion -- + * Remove the shared memory region. + * + * PUBLIC: int __db_unlinkregion __P((char *, REGINFO *)); + */ +int +__db_unlinkregion(name, infop) + char *name; + REGINFO *infop; +{ + int called, ret; + + called = 0; + ret = EINVAL; + + if (__db_jump.j_runlink != NULL) + return (__db_jump.j_runlink(name)); + +#ifdef HAVE_SHMGET + if (infop->segid != INVALID_SEGID) { + called = 1; + ret = shmctl(infop->segid, IPC_RMID, NULL) ? errno : 0; + } +#else + COMPQUIET(infop, NULL); +#endif +#ifdef HAVE_MMAP + if (!called) { + called = 1; + ret = 0; + } +#endif + return (ret); +} + +/* + * __db_mapfile -- + * Map in a shared memory file. + * + * PUBLIC: int __db_mapfile __P((char *, int, size_t, int, void **)); + */ +int +__db_mapfile(path, fd, len, is_rdonly, addr) + char *path; + int fd, is_rdonly; + size_t len; + void **addr; +{ + if (__db_jump.j_map != NULL) + return (__db_jump.j_map(path, fd, len, 0, 0, is_rdonly, addr)); + +#ifdef HAVE_MMAP + return (__os_map(path, fd, len, 0, 0, is_rdonly, addr)); +#else + return (EINVAL); +#endif +} + +/* + * __db_unmapfile -- + * Unmap the shared memory file. * - * PUBLIC: int __os_map __P((int, size_t, int, int, void **)); + * PUBLIC: int __db_unmapfile __P((void *, size_t)); */ int -__os_map(fd, len, is_private, is_rdonly, addr) - int fd, is_private, is_rdonly; +__db_unmapfile(addr, len) + void *addr; + size_t len; +{ + if (__db_jump.j_unmap != NULL) + return (__db_jump.j_unmap(addr, len)); + +#ifdef HAVE_MMAP + return (munmap(addr, len) ? errno : 0); +#else + return (EINVAL); +#endif +} + +#ifdef HAVE_MMAP +/* + * __os_map -- + * Call the mmap(2) function. + */ +static int +__os_map(path, fd, len, is_region, is_anonymous, is_rdonly, addr) + char *path; + int fd, is_region, is_anonymous, is_rdonly; size_t len; void **addr; { void *p; int flags, prot; - flags = is_private ? MAP_PRIVATE : MAP_SHARED; + COMPQUIET(path, NULL); + + /* + * If it's read-only, it's private, and if it's not, it's shared. + * Don't bother with an additional parameter. + */ + flags = is_rdonly ? MAP_PRIVATE : MAP_SHARED; + + if (is_region && is_anonymous) { + /* + * BSD derived systems use MAP_ANON; Digital Unix and HP/UX + * use MAP_ANONYMOUS. + */ +#ifdef MAP_ANON + flags |= MAP_ANON; +#endif +#ifdef MAP_ANONYMOUS + flags |= MAP_ANONYMOUS; +#endif + fd = -1; + } +#ifdef MAP_FILE + if (!is_region || !is_anonymous) { + /* + * Historically, MAP_FILE was required for mapping regular + * files, even though it was the default. Some systems have + * it, some don't, some that have it set it to 0. + */ + flags |= MAP_FILE; + } +#endif + + /* + * I know of no systems that implement the flag to tell the system + * that the region contains semaphores, but it's not an unreasonable + * thing to do, and has been part of the design since forever. I + * don't think anyone will object, but don't set it for read-only + * files, it doesn't make sense. + */ #ifdef MAP_HASSEMAPHORE - flags |= MAP_HASSEMAPHORE; + if (!is_rdonly) + flags |= MAP_HASSEMAPHORE; #endif + prot = PROT_READ | (is_rdonly ? 0 : PROT_WRITE); -#ifndef MAP_FAILED /* XXX: Mmap(2) failure return. */ + /* MAP_FAILED was not defined in early mmap implementations. */ +#ifndef MAP_FAILED #define MAP_FAILED -1 #endif if ((p = @@ -51,21 +399,67 @@ __os_map(fd, len, is_private, is_rdonly, addr) *addr = p; return (0); } +#endif +#ifdef HAVE_SHMGET /* - * __os_unmap -- - * Release the specified shared memory. - * - * PUBLIC: int __os_unmap __P((void *, size_t)); + * __os_shmget -- + * Call the shmget(2) family of functions. */ -int -__os_unmap(addr, len) - void *addr; - size_t len; +static int +__os_shmget(path, infop) + REGINFO *infop; + char *path; { - /* - * !!! - * The argument len is always the same length as was mapped. - */ - return (munmap(addr, len) ? errno : 0); + key_t key; + int shmflg; + + if (F_ISSET(infop, REGION_CREATED)) { + /* + * The return key from ftok(3) is not guaranteed to be unique. + * The nice thing about the shmget(2) interface is that it + * allows you to name anonymous pieces of memory. The evil + * thing about it is that the name space is separate from the + * filesystem. + */ +#ifdef __hp3000s900 + {char mpe_path[MAXPATHLEN]; + /* + * MPE ftok() is broken as of 5.5pp4. If the file path does + * not start with '/' or '.', then ftok() tries to interpret + * the file path in MPE syntax instead of POSIX HFS syntax. + * The workaround is to prepend "./" to these paths. See HP + * SR 5003416081 for details. + */ + if (*path != '/' && *path != '.') { + if (strlen(path) + strlen("./") + 1 > sizeof(mpe_path)) + return (ENAMETOOLONG); + mpe_path[0] = '.'; + mpe_path[1] = '/'; + (void)strcpy(mpe_path + 2, path); + path = mpe_path; + } + } +#endif + if ((key = ftok(path, 1)) == (key_t)-1) + return (errno); + + shmflg = IPC_CREAT | 0600; + if ((infop->segid = shmget(key, infop->size, shmflg)) == -1) + return (errno); + } + + if ((infop->addr = shmat(infop->segid, NULL, 0)) == (void *)-1) { + /* + * If we're trying to join the region and failing, assume + * that there was a reboot and the region no longer exists. + */ + if (!F_ISSET(infop, REGION_CREATED)) + errno = EAGAIN; + return (errno); + } + + F_SET(infop, REGION_HOLDINGSYS); + return (0); } +#endif diff --git a/db2/os/os_oflags.c b/db2/os/os_oflags.c index 3656eef..388c1c6 100644 --- a/db2/os/os_oflags.c +++ b/db2/os/os_oflags.c @@ -1,18 +1,19 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_oflags.c 10.2 (Sleepycat) 10/24/97"; +static const char sccsid[] = "@(#)os_oflags.c 10.6 (Sleepycat) 4/19/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES #include <sys/types.h> +#include <sys/stat.h> #include <fcntl.h> #endif @@ -23,13 +24,13 @@ static const char sccsid[] = "@(#)os_oflags.c 10.2 (Sleepycat) 10/24/97"; * __db_oflags -- * Convert open(2) flags to DB flags. * - * PUBLIC: int __db_oflags __P((int)); + * PUBLIC: u_int32_t __db_oflags __P((int)); */ -int +u_int32_t __db_oflags(oflags) int oflags; { - int dbflags; + u_int32_t dbflags; /* * XXX @@ -46,3 +47,48 @@ __db_oflags(oflags) dbflags |= DB_TRUNCATE; return (dbflags); } + +/* + * __db_omode -- + * Convert a permission string to the correct open(2) flags. + * + * PUBLIC: int __db_omode __P((const char *)); + */ +int +__db_omode(perm) + const char *perm; +{ + int mode; + +#ifndef S_IRUSR +#if defined(_WIN32) || defined(WIN16) +#define S_IRUSR S_IREAD /* R for owner */ +#define S_IWUSR S_IWRITE /* W for owner */ +#define S_IRGRP 0 /* R for group */ +#define S_IWGRP 0 /* W for group */ +#define S_IROTH 0 /* R for other */ +#define S_IWOTH 0 /* W for other */ +#else +#define S_IRUSR 0000400 /* R for owner */ +#define S_IWUSR 0000200 /* W for owner */ +#define S_IRGRP 0000040 /* R for group */ +#define S_IWGRP 0000020 /* W for group */ +#define S_IROTH 0000004 /* R for other */ +#define S_IWOTH 0000002 /* W for other */ +#endif /* _WIN32 || WIN16 */ +#endif + mode = 0; + if (perm[0] == 'r') + mode |= S_IRUSR; + if (perm[1] == 'w') + mode |= S_IWUSR; + if (perm[2] == 'r') + mode |= S_IRGRP; + if (perm[3] == 'w') + mode |= S_IWGRP; + if (perm[4] == 'r') + mode |= S_IROTH; + if (perm[5] == 'w') + mode |= S_IWOTH; + return (mode); +} diff --git a/db2/os/os_open.c b/db2/os/os_open.c index a628765..e960377 100644 --- a/db2/os/os_open.c +++ b/db2/os/os_open.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_open.c 10.20 (Sleepycat) 11/27/97"; +static const char sccsid[] = "@(#)os_open.c 10.26 (Sleepycat) 5/4/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -25,12 +25,13 @@ static const char sccsid[] = "@(#)os_open.c 10.20 (Sleepycat) 11/27/97"; * __db_open -- * Open a file descriptor. * - * PUBLIC: int __db_open __P((const char *, int, int, int, int *)); + * PUBLIC: int __db_open __P((const char *, u_int32_t, u_int32_t, int, int *)); */ int __db_open(name, arg_flags, ok_flags, mode, fdp) const char *name; - int arg_flags, ok_flags, mode, *fdp; + u_int32_t arg_flags, ok_flags; + int mode, *fdp; { int fd, flags; @@ -54,7 +55,7 @@ __db_open(name, arg_flags, ok_flags, mode, fdp) else flags |= O_RDWR; -#ifdef _WIN32 +#if defined(_WIN32) || defined(WIN16) #ifdef _MSC_VER if (arg_flags & DB_SEQUENTIAL) flags |= _O_SEQUENTIAL; @@ -80,7 +81,7 @@ __db_open(name, arg_flags, ok_flags, mode, fdp) (void)__os_unlink(name); #endif -#if !defined(_WIN32) && !defined(macintosh) +#if !defined(_WIN32) && !defined(WIN16) /* * Deny access to any child process; done for Win32 by O_NOINHERIT, * MacOS has neither child processes nor fd inheritance. diff --git a/db2/os/os_rpath.c b/db2/os/os_rpath.c index 44fd4ec..23867b3 100644 --- a/db2/os/os_rpath.c +++ b/db2/os/os_rpath.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_rpath.c 10.2 (Sleepycat) 10/24/97"; +static const char sccsid[] = "@(#)os_rpath.c 10.3 (Sleepycat) 4/10/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES diff --git a/db2/os/os_rw.c b/db2/os/os_rw.c index 48f7fdc..7591041 100644 --- a/db2/os/os_rw.c +++ b/db2/os/os_rw.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_rw.c 10.6 (Sleepycat) 10/25/97"; +static const char sccsid[] = "@(#)os_rw.c 10.7 (Sleepycat) 4/10/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES diff --git a/db2/os/os_seek.c b/db2/os/os_seek.c index e27044b..159425c 100644 --- a/db2/os/os_seek.c +++ b/db2/os/os_seek.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_seek.c 10.6 (Sleepycat) 10/25/97"; +static const char sccsid[] = "@(#)os_seek.c 10.9 (Sleepycat) 4/19/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -24,19 +24,21 @@ static const char sccsid[] = "@(#)os_seek.c 10.6 (Sleepycat) 10/25/97"; * __os_seek -- * Seek to a page/byte offset in the file. * - * PUBLIC: int __os_seek __P((int, size_t, db_pgno_t, u_long, int)); + * PUBLIC: int __os_seek __P((int, size_t, db_pgno_t, u_int32_t, int, int)); */ int -__os_seek(fd, pgsize, pageno, relative, whence) +__os_seek(fd, pgsize, pageno, relative, isrewind, whence) int fd; size_t pgsize; db_pgno_t pageno; - u_long relative; - int whence; + u_int32_t relative; + int isrewind, whence; { off_t offset; - offset = pgsize * pageno + relative; + offset = (off_t)pgsize * pageno + relative; + if (isrewind) + offset = -offset; return (lseek(fd, offset, whence) == -1 ? errno : 0); } diff --git a/db2/os/os_sleep.c b/db2/os/os_sleep.c index 2d2cb71..6a5b91f 100644 --- a/db2/os/os_sleep.c +++ b/db2/os/os_sleep.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_sleep.c 10.8 (Sleepycat) 10/25/97"; +static const char sccsid[] = "@(#)os_sleep.c 10.10 (Sleepycat) 4/27/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -42,7 +42,8 @@ __os_sleep(secs, usecs) struct timeval t; /* Don't require that the values be normalized. */ - for (; usecs >= 1000000; ++secs, usecs -= 1000000); + for (; usecs >= 1000000; ++secs, usecs -= 1000000) + ; /* * It's important that we yield the processor here so that other diff --git a/db2/os/os_spin.c b/db2/os/os_spin.c index fb693c2..2fd21d0 100644 --- a/db2/os/os_spin.c +++ b/db2/os/os_spin.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_spin.c 10.3 (Sleepycat) 11/25/97"; +static const char sccsid[] = "@(#)os_spin.c 10.7 (Sleepycat) 5/20/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -29,28 +29,33 @@ static const char sccsid[] = "@(#)os_spin.c 10.3 (Sleepycat) 11/25/97"; int __os_spin() { - extern int __db_tsl_spins; + static long sys_val; /* If the application specified the spins, use its value. */ - if (__db_tsl_spins != 0) - return (__db_tsl_spins); + if (DB_GLOBAL(db_tsl_spins) != 0) + return (DB_GLOBAL(db_tsl_spins)); + + /* If we've already figured this out, return the value. */ + if (sys_val != 0) + return (sys_val); /* * XXX - * Sysconf: Solaris uses _SC_NPROCESSORS_ONLN to return the number - * of online processors. I don't know if this call is portable or - * not. + * Solaris and Linux use _SC_NPROCESSORS_ONLN to return the number of + * online processors. We don't want to repeatedly call sysconf because + * it's quite expensive (requiring multiple filesystem accesses) under + * Debian Linux. + * + * Spin 50 times per processor -- we have anecdotal evidence that this + * is a reasonable value. */ #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) - { - long sys_val; - - sys_val = sysconf(_SC_NPROCESSORS_ONLN); - if (sys_val > 0) - return (sys_val * 50); - } + if ((sys_val = sysconf(_SC_NPROCESSORS_ONLN)) > 1) + sys_val *= 50; + else + sys_val = 1; +#else + sys_val = 1; #endif - - /* Default to a single processor. */ - return (1); + return (sys_val); } diff --git a/db2/os/os_stat.c b/db2/os/os_stat.c index 73600b6..e7d3f24 100644 --- a/db2/os/os_stat.c +++ b/db2/os/os_stat.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_stat.c 10.11 (Sleepycat) 1/8/98"; +static const char sccsid[] = "@(#)os_stat.c 10.15 (Sleepycat) 4/27/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -16,11 +16,9 @@ static const char sccsid[] = "@(#)os_stat.c 10.11 (Sleepycat) 1/8/98"; #include <sys/stat.h> #include <errno.h> -#include <string.h> #endif #include "db_int.h" -#include "common_ext.h" /* * __os_exists -- @@ -37,8 +35,17 @@ __os_exists(path, isdirp) if (stat(path, &sb) != 0) return (errno); + +#if !defined(S_ISDIR) || defined(STAT_MACROS_BROKEN) +#if defined(_WIN32) || defined(WIN16) +#define S_ISDIR(m) (_S_IFDIR & (m)) +#else +#define S_ISDIR(m) (((m) & 0170000) == 0040000) +#endif +#endif if (isdirp != NULL) *isdirp = S_ISDIR(sb.st_mode); + return (0); } @@ -69,10 +76,16 @@ __os_ioinfo(path, fd, mbytesp, bytesp, iosizep) if (bytesp != NULL) *bytesp = sb.st_size % MEGABYTE; - /* Return the underlying filesystem blocksize, if available. */ + /* + * Return the underlying filesystem blocksize, if available. + * + * XXX + * Check for a 0 size -- HP's MPE architecture has st_blksize, + * but it's always 0. + */ #ifdef HAVE_ST_BLKSIZE - if (iosizep != NULL) - *iosizep = sb.st_blksize; + if (iosizep != NULL && (*iosizep = sb.st_blksize) == 0) + *iosizep = DB_DEF_IOSIZE; #else if (iosizep != NULL) *iosizep = DB_DEF_IOSIZE; diff --git a/db2/os/os_unlink.c b/db2/os/os_unlink.c index 473ce77..3a1fa3f 100644 --- a/db2/os/os_unlink.c +++ b/db2/os/os_unlink.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997 + * Copyright (c) 1997, 1998 * Sleepycat Software. All rights reserved. */ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)os_unlink.c 10.4 (Sleepycat) 10/28/97"; +static const char sccsid[] = "@(#)os_unlink.c 10.5 (Sleepycat) 4/10/98"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES |