Commit Graph

60 Commits

Author SHA1 Message Date
christos 340e17eb3b Don't attempt to delete a NULL key. Can happen if we were the only key
in a 64K page. Thanks to Juergen Hannken-Illjes for the test.
2005-04-27 23:11:29 +00:00
christos c4e3c4d493 Don't refuse to create a hash database on 0 length files. Treat
them as new files the same way that the btree code does.  Note that
we do the fstat() after the open() instead of re-using the previous
result of the stat() to avoid races (we open with O_EXLOCK when we care).
2005-03-29 23:37:15 +00:00
christos bab13a9d96 Revert previous commit at 1.17. a maximum BSIZE of 65536 ends up stored
as a 0 in the page, but it is supported and it does work.
2005-03-06 03:42:14 +00:00
mycroft b7e6351cc4 hash already uses FD_CLOEXEC -- pay attention to the return value and make it
a hard failure.

Also make btree and recno uses FD_CLOEXEC.
2005-01-19 00:23:44 +00:00
jmc b2f782612f Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
2004-06-20 22:20:14 +00:00
kleink ceeaed078c XPG4.2: when it is attempted to open a database write-only, silently
"upgrade" to use read/write access on the database file.
2004-04-29 18:37:20 +00:00
kleink dbfbef898d XPG4.2: Change member `dsize' of struct datum from int to size_t.
Version dbm_{delete,fetch,firstkey,nextkey,store}() accordingly.
Fixes PRs standards/21402 from Ben Harris and standards/25343 from
Murray Armfield.
2004-04-28 00:10:52 +00:00
kleink 537be69d5c Remove internal names for dbm_*(3); these are not required at this time. 2004-04-27 20:03:45 +00:00
lukem 171d653219 Overhaul how `build.sh tools' are used:
*	Rename "config.h" to "nbtool_config.h" and
	HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
	This makes in more obvious in the source when we're using
	tools/compat/config.h versus "standard autoconf" config.h

    *	Consistently move the inclusion of nbtool_config.h to before
    	<sys/cdefs.h> so that the former can provide __RCSID() (et al),
    	and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
	#if HAVE_NBTOOL_CONFIG_H
	#include "nbtool_config.h"
	#endif
to the top of the source files (for the general case).
2003-10-27 00:12:41 +00:00
agc eb7c1594f1 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22280, verified by myself.
2003-08-07 16:42:00 +00:00
christos 5f8d1cd0cc PR/5996: ITOH Yasufumi: lib/libc/db/hash/* writes memory garbage to db file
Fixed by changing malloc's to calloc's where needed.
2003-04-20 20:41:14 +00:00
simonb 276fd1665c The Double-Semi-Colon Police. 2003-01-20 05:29:53 +00:00
christos 14c54c3327 Only allow BSIZE to 1^16 - 1:
- fix off by one error
    - limit the default from the filesystem
2002-12-11 21:20:15 +00:00
itojun 35eb51aa09 use int32_t, instead of int, for on-disk data.
(so that we are safe in the future)
2002-05-30 14:55:47 +00:00
tv c08a2cb7c2 Add hooks for reachover builds from src/tools/compat. 2002-01-21 21:33:42 +00:00
aymeric 9e09072f0e use %p instead of %x when displaying a pointer 2002-01-12 11:26:13 +00:00
wiz 40ac848024 Fix various misspellings of compatible/compatibility. 2001-06-11 01:50:48 +00:00
cgd 579369d368 build new hsearch() code 2001-02-14 05:44:29 +00:00
cgd 603bfd4ff7 nuke old, unredeemably broken DB-based version of hsearch() et al. 2001-02-14 05:41:46 +00:00
mycroft 605490369c Delint.
Remove trailing ; from uses of __weak_alias().  The macro inserts this if
needed.
2000-01-22 22:19:07 +00:00
mycroft 648d6d9529 Only squeeze a short key/value pair onto a page with other complete key/value
pairs, not onto a page containing the end of a big pair.
1999-07-29 08:58:46 +00:00
mycroft 72a2509e35 When deleting a big key, the offset of an empty page should be bsize, not
bsize-1; otherwise an insertion into the empty page will cause the new key to
be elongated by 1 byte.
1999-07-29 07:48:03 +00:00
mycroft 462e381edd Previous bug fix was slightly wrong. In this case, the data must start on a
new page, or we will mistakenly think the first page is the end of the data.
1999-07-29 01:12:57 +00:00
mycroft 343c90058f Return a useful errno value in the overflow case.
Also, print a message to stderr in one more case.
1999-07-29 00:19:43 +00:00
mycroft 14f4149717 Make the packing more dense in a couple of cases. 1999-07-28 19:41:36 +00:00
mycroft ec7d7ed5ec If (keysize+datasize)%(bsize=14)==0, insertion of a `big key' would cause an
invariant (actually, an ugly hack) to fail, and all Hell would break loose.
1999-07-28 19:33:03 +00:00
christos dc1c2ccb47 don't compare non-pointer values against NULL. 1999-07-10 17:48:54 +00:00
kleink 276331d152 Per XSI5, make ENTRY.data a typeless pointer. 1999-02-16 18:23:00 +00:00
kleink 983e1024bf Per XSI5, let hcreate() take a size_t argument. 1999-02-16 18:12:24 +00:00
kleink 3b5a19a494 Dispose the private search.h header and use <search.h>, which is a superset,
instead.
1999-02-16 17:59:18 +00:00
christos 61238e7179 delint 1998-12-09 12:42:46 +00:00
kleink abc6d45e5c Need "namespace.h". 1998-10-14 11:56:28 +00:00
thorpej e79648d085 Add some braces to make egcs happy. 1998-08-18 23:50:08 +00:00
mycroft ea09e5f2d4 Reinitialize the mkstemp() template each time it's used. 1998-07-26 14:05:20 +00:00
thorpej 317d4e84d6 Use pread(2) and pwrite(2) where appropriate. 1998-06-30 21:30:52 +00:00
kleink 23a9b2c5c9 Change the file mode argument to dbopen() and the db backends from int to
mode_t.
1998-05-07 19:24:20 +00:00
kleink 9eb0e33ef6 Change the file mode argument to dbm_open() from int to mode_t. 1998-05-07 19:11:14 +00:00
jtc 43fa6fe319 If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore.  The library will use those
names internally.  Weak aliases are used to provide the original names
to the API.

This is only the first part of this change.  It is most of the functions
which are implemented in C for all NetBSD ports.  Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
1997-07-21 14:06:24 +00:00
christos 00ae392d92 Fix RCSID's
Fix gcc warnings.
1997-07-13 18:51:48 +00:00
mrg 9cd5492c02 - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
1997-01-23 14:01:45 +00:00
jtc 135c9d2460 Rename the errno field in struct htab to err, as the former name
conflicts with a macro implementation of errno.h's errno.
1996-11-07 06:48:01 +00:00
cgd e4cf519e27 fix a bug that shows up only on alphas: ndbm "datum" variables can't be
cast to DBTs, because the 'size' fields are int and size_t,
respectively, and that means that the DBT size field would be
partially filled with garbage on the Alpha.  Bug fix sent to bostic.
1996-05-04 00:38:58 +00:00
cgd 7f7f8e8fe2 reapply diff from rev. 1.7. can't cast pointers to ints; what's really wanted
here is foo != NULL.
1996-05-03 22:16:32 +00:00
cgd 738330da77 merge DB 1.85 changes 1996-05-03 21:38:43 +00:00
mycroft 4c34be6b52 Clean up deleted files. 1995-03-01 00:00:00 +00:00
cgd 2c84ad3a41 add unintrusive Ids 1995-02-27 13:22:58 +00:00
cgd 402f19d1dd add unintrusive Ids 1995-02-27 13:21:44 +00:00
cgd a1388b1815 be a bit nicer with the return value 1994-10-19 03:19:01 +00:00
cgd a6d14e368c clean up import 1994-08-18 00:38:04 +00:00
cgd 98a60eb83a fix sall memory leak. from Christopher Jon Kane <kane@kidd.vet.purdue.edu> 1994-01-13 22:55:55 +00:00