summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix the representation of octal escapes in gdbmtool outputSergey Poznyakoff2021-08-041-2/+2
| | | | * src/datconv.c (f_stringz, f_string): Use unsigned char *.
* gdbmtool: fix help output representationSergey Poznyakoff2021-08-031-3/+15
|
* New macro: ARRAY_SIZESergey Poznyakoff2021-08-034-12/+14
|
* gdbmtool: control the format in which new databases are createdSergey Poznyakoff2021-08-036-39/+82
| | | | | | | | | | * src/gdbmload.c (_gdbm_str2fmt): New function. * src/proto.h (_gdbm_str2fmt): New proto. * src/gdbmtool.c (open_format): New global variable. (opendb): Add open_format to gdbm_open flags * src/gdbmtool.h (open_format): New extern. * src/var.c: Handle the "format" variable. * doc/gdbm.texi: Document the changes.
* Preserve the database format across dump/restoreSergey Poznyakoff2021-08-032-3/+30
| | | | | | | * src/gdbmdump.c (_gdbm_dump_ascii): New parameter "format" holds the format of the original database. Set version number to 1.1 * src/gdbmload.c (_gdbm_load_file): Handle the "format" parameter.
* Fix typosSergey Poznyakoff2021-08-032-3/+3
|
* Various fixesSergey Poznyakoff2021-08-027-82/+305
| | | | | | | | | | | | | | | | | * doc/gdbm.texi: Document manual crash recovery procedure. Document the gdbmtool "shell" command. Fix chapter headings (remove final point). Replace headings with sections. * src/gdbmopen.c (gdbm_header_avail): Remove const qualifier from 1st argument * src/proto.h (gdbm_file_sync): New proto. * src/gdbmsync.c (gdbm_file_sync): Moved from proto.h. (gdbm_sync): Call _gdbm_end_update to be sure all changes are written to disk. * src/gdbmtool.c: Implement the shell command. (command_lookup): Fix name prefix comparison. * src/gram.y: New token T_SHELL. * src/lex.l: Sub-lexers for shell arguments.
* Fix gdbm_recoverSergey Poznyakoff2021-08-021-0/+7
| | | | | | * src/recover.c (_gdbm_finish_transfer): Close snapshot descriptors, if any. Restore xheader, avail, and avail_size members.
* Fix numsync comparisonSergey Poznyakoff2021-08-022-2/+7
| | | | | * src/gdbmsync.c (gdbm_numsync_cmp): Properly handle unsigned overflow. * tests/gtload.c: New option -numsync.
* New gdbmtool command: snapshotSergey Poznyakoff2021-08-014-11/+298
| | | | | | | * src/gdbmtool.c: New command: "snapshot" * doc/gdbm.texi: Document the snapshot command (gdbmtool). * doc/gdbmtool.1: Likewise. * src/gdbmsync.c: Fix a comment.
* Fix a typo.Sergey Poznyakoff2021-08-011-1/+1
| | | | * src/gdbmsync.c (stat_snapshot): Use EACCES instead of EACCESS.
* Changes in the docs. Minor improvements in gdbm_latest_snapshot.Sergey Poznyakoff2021-07-314-118/+129
| | | | | | | | | | * doc/Makefile.am: Export htmlxref.cnf * doc/htmlxref.cnf: New file. * doc/gdbm.texi: Improve crash-tolerance descriptions. * src/gdbmsync.c (stat_snapshot): Set errno = EACCES if access bits of the snapshot stat are wrong. (gdbm_latest_snapshot): Don't touch ret if returning GDBM_SNAPSHOT_SUSPICIOUS.
* Update the documentationSergey Poznyakoff2021-07-314-217/+190
|
* Minor fixSergey Poznyakoff2021-07-301-1/+1
| | | | * src/gdbmsync.c (gdbm_numsync_cmp): Fix signedness of na, nb
* Minor changeSergey Poznyakoff2021-07-303-10/+8
| | | | | | | * src/gdbmdefs.h (GDBM_HEADER_AVAIL_SIZE): Removed. (GDBM_HEADER_AVAIL_OFFSET): New macro. * src/avail.c: Use dbf->avail_size and GDBM_HEADER_AVAIL_OFFSET. * src/gdbmopen.c: Likewise.
* Avoid eventual alignment problemsSergey Poznyakoff2021-07-305-30/+75
| | | | | | | | | * src/gdbm.magic: Handle extended GDBM format. * src/gdbmdefs.h (gdbm_file_standard_header) (gdbm_file_extended_header): New data types. * src/gdbmopen.c (gdbm_header_avail): Use casts to gdbm_file_*_header to obtain data offsets. * src/gdbmtool.c (print_header_handler): Improve formatting.
* Minor fixSergey Poznyakoff2021-07-291-1/+2
| | | | * src/gdbmsync.c (gdbm_latest_snapshot): Restore missing break.
* Various bugfixes.Sergey Poznyakoff2021-07-295-9/+7
|
* Improve _gdbm_snapshotSergey Poznyakoff2021-07-291-1/+23
| | | | | | * src/gdbmsync.c (_gdbm_snapshot): Before returning, chmod previous snapshot write-only. Change proposed by Terence Kelly on July 23, 2021.
* Mark GDBM_MAGIC constants as unsignedSergey Poznyakoff2021-07-291-10/+10
|
* Implement snapshot selection by numsync.Sergey Poznyakoff2021-07-292-15/+96
| | | | | | | * src/gdbm.h.in (GDBM_SNAPSHOT_SUSPICIOUS): New return code. * src/gdbmsync.c (gdbm_latest_snapshot): Take into account numsync when choosing between the two snapshots. (gdbm_sync): Increase numsync.
* Initialize dptr to non-null storage even if size is 0.Sergey Poznyakoff2021-07-291-1/+1
|
* Test conversion to extended format.Sergey Poznyakoff2021-07-296-0/+336
| | | | | | | | | * src/gdbmdefs.h (gdbm_ext_header): Add new field: version. Pad to 8 integers. * tests/gtconv.c: New auxiliary program. * tests/conv.at: New test. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Likewise.
* Simplify gdbm_file_headerSergey Poznyakoff2021-07-295-45/+276
| | | | | | | | | | | | | | | | * src/gdbm.h.in (gdbm_convert): New proto. * src/gdbmdefs.h: Define GDBM_MAGIC and GDBM_NUMSYNC_MAGIC here. (gdbm_file_header): Remove the union. * src/gdbmopen.c (gdbm_header_avail): Return pointer to gdbm_ext_header in 4th argument. (validate_header_std,validate_header_numsync): Remove avail size verification. It will be checked later in gdbm_fd_open. (gdbm_fd_open): Check avail table size. (gdbm_convert): New function. * src/avail.c (gdbm_avail_traverse): Change the avail table offset calculation. * src/gdbmtool.c: New commands: upgrade, downgrade and sync. Fix output of the "header" command.
* Introduce extended header.Sergey Poznyakoff2021-07-283-26/+64
| | | | | | | | | | | * src/gdbm.h.in (GDBM_NUMSYNC): New flag for gdbm_open * src/gdbmdefs.h (gdbm_ext_header): New struct. (gdbm_file_header): New member of the union v: gdbm_ext_header. * src/gdbmopen.c (gdbm_header_avail): New function. (validate_header): Use dbf->avail. (gdbm_fd_open): Read both database types. Create GDBM_NUMSYNC_MAGIC database if given the GDBM_MAGIC flag.
* Prepare structs gdbm_file_header and gdbm_file_info for changes.Sergey Poznyakoff2021-07-286-85/+159
| | | | | | | | | | | | | | | | | | | | * src/gdbmconst.h (GDBM_NUMSYNC_MAGIC32) (GDBM_NUMSYNC_MAGIC64) (GDBM_NUMSYNC_MAGIC32_SWAP) (GDBM_NUMSYNC_MAGIC64_SWAP): New constants. * src/gdbmdefs.h (gdbm_file_header): Move avail to a union in anticipation of further changes. (gdbm_file_info) <avail, avail_size>: New members. (GDBM_HEADER_AVAIL_SIZE): Redefine. * src/gdbmopen.c (GDBM_NUMSYNC_MAGIC): New define. (validate_header_std) (validate_header_numsync): New functions. (validate_header): Use one of these depending on the magic number. (gdbm_fd_open): Initialize new members of gdbm_file_info. * src/avail.c: Use the GDBM_FILE avail pointer. * src/falloc.c: Likewise. * src/gdbmtool.c: Likewise.
* Fix gdbm_avail_traverse()Sergey Poznyakoff2021-07-222-38/+42
| | | | | | * src/avail.c (gdbm_avail_traverse): Apply callback to the header avail block as well. * src/gdbmtool.c (avail_list_print): Don't print header block separately.
* Improve fsync_to_root. Other minor fixes.Sergey Poznyakoff2021-07-172-39/+45
| | | | | | | | | * src/gdbm.h.in (gdbm_latest_status): Rename to gdbm_latest_snapshot_status. * src/gdbmsync.c (fsync_to_root): Start synching from the snapshot itself. Take care to open it write-only. (gdbm_latest_snapshot): Reorganize to improve readability. [!GDBM_FAILURE_ATOMIC] gdbm_latest_snapshot: Fix signature.
* BugfixSergey Poznyakoff2021-07-171-1/+1
| | | | * src/gdbmsync.c (stat_snapshot): Fix typo (missing parentheses).
* Bugfixes in crash tolerance code.gray@gnu.org2021-07-173-23/+51
| | | | | | | | | | | | | | * doc/gdbm.texi: Document GDBM_SNAPSHOT_BAD * src/gdbm.h.in (GDBM_SNAPSHOT_BAD): New constant. * src/gdbmsync.c (fsync_to_root): Rewrite. Use pointer to traverse the pathname in the reverse direction. Fsync the root directory as well. (gdbm_failure_atomic): Create both snapshots in user write-only mode. (stat_snapshot): Fail if the file is neither readable nor writable. (gdbm_latest_snapshot): Fail if neither file is readable. Fix selection of the snapshot by mtime: prefer the latest one. [!GDBM_FAILURE_ATOMIC]: Provide the placeholder for gdbm_latest_snapshot.
* Document new error codesSergey Poznyakoff2021-07-171-86/+109
|
* Document crash tolerance APISergey Poznyakoff2021-07-172-4/+265
|
* Crash-tolerance based on the patch from Terence Kellygray@gnu.org2021-07-1711-13/+606
|
* Fix https://puszcza.gnu.org.ua/bugs/?515Sergey Poznyakoff2021-07-071-0/+1
| | | | * src/gdbm.h.in: Include sys/types.h
* Version 1.20v1.20Sergey Poznyakoff2021-06-173-5/+5
|
* Enable pre-reading the memory mapped regions on request.Sergey Poznyakoff2021-06-147-16/+52
| | | | | | | | | | | | | | | | | | The commit 4fb2326a4a introduced pre-reading of memory mapped regions. While speeding up searches, it has a negative impact on write operatons, since every remapping effectively re-reads the entire database. See https://github.com/Perl/perl5/issues/18884 for details. * NEWS: Document changes. * doc/gdbm.texi: Document the GDBM_PREREAD flag. * src/gdbm.h.in (GDBM_PREREAD): New flag. * src/gdbmdefs.h (gdbm_file_info): New member: mmap_preread. * src/gdbmopen.c (gdbm_fd_open): Set mmap_preread if requested. * src/gdbmsetopt.c (setopt_gdbm_getflags): Report GDBM_PREREAD flag, if dbf->mmap_preread is set. * src/mmap.c (_gdbm_internal_remap): Use pre-fault reading only if dbf->mmap_preread is set.
* Fix possible integer overflows and cases of undefined behavior.Sergey Poznyakoff2021-04-235-9/+17
| | | | | | | | | | * src/avail.c (avail_comp): Prevent integer overflow. (gdbm_avail_table_valid_p): Likewise. * src/gdbmdefs.h (off_t_sum_ok): Change return type. Return false if any argument is negative. * src/gdbmopen.c (compute_directory_size): Prevent integer overflow. * src/hash.c (_gdbm_hash): Treat dptr elements as unsigned integers.
* Fix minor memory leaks in gdbmtoolSergey Poznyakoff2021-03-222-2/+11
| | | | | * src/datconv.c (dsegm_list_free): Free name if necessary. * src/gram.y (defid): Free $1 when no longer needed.
* Merge branch 'newcache': Bucket cache rewritten from scratch.Sergey Poznyakoff2021-03-2123-584/+1496
|\
| * Enable automatic cache size by default.newcacheSergey Poznyakoff2021-03-218-241/+396
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This provides for the optimal performance. Additional GDBM_XVERIFY flag can be used when opening the database to request extended database verification (entire avail stack will be checked). * src/bucket.c (cache_lookup): Handle cache_size == GDBM_CACHE_AUTO. (_gdbm_cache_init): Likewise. * src/gdbm.h.in (GDBM_XVERIFY): New flag to gdbm_open. (GDBM_CACHE_AUTO): New constant. Define error constants within enum. Fix definition of GDBM_BAD_HASH_ENTRY. * src/gdbmclose.c: Fix misleading comment. * src/gdbmconst.h: Define DEFAULT_CACHESIZE to be GDBM_CACHE_AUTO. * src/gdbmopen.c (gdbm_fd_open): Call gdbm_avail_verify if the GDBM_XVERIFY flag is set. * doc/gdbm.texi: Update. * doc/gdbm.3: Update.
| * More optimizations in cache treeSergey Poznyakoff2021-03-204-91/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | * src/bucket.c (gdbm_dir_entry_valid_p): Inline (cache_lookup): Keep track of cache hits. (_gdbm_get_bucket): Check the cache_entry first. (gdbm_get_cache_stats): Change signature. Return the per-db number of cache hits as well. * src/cachetree.c: Inline static functions. (_gdbm_cache_tree_lookup): Avoid extra level of indirection (nodeptr) at the expense of one additional comparison. * src/gdbm.h.in (gdbm_get_cache_stats): Change signature. * src/gdbmdefs.h (gdbm_file_info) <cache_hits>: New member.
| * Fix memory leak in gdbmtool "next" command.Sergey Poznyakoff2021-03-172-4/+1
| | | | | | | | | | * src/gdbmtool.c (nextkey_handler): Always free the previous key buffer.
| * New functions for traversing the available space stackSergey Poznyakoff2021-03-178-158/+338
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/Makefile.am: Add avail.c * src/avail.c: New file. * src/gdbm.h.in (gdbm_avail_verify): New proto. * src/gdbmdefs.h (GDBM_HEADER_AVAIL_SIZE): New macro. * src/gdbmopen.c (gdbm_avail_table_valid_p) (gdbm_avail_block_validate) (gdbm_bucket_avail_table_validate): Move to avail.c * src/gdbmtool.c (_gdbm_avail_list_size) (_gdbm_print_avail_list): Rewrite using gdbm_avail_traverse. * src/proto.h (gdbm_avail_traverse): New proto. * src/systems.h: Include stddef.h.
| * Follow-up fixes to fd5cf245ea.Sergey Poznyakoff2021-03-174-31/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | These address https://puszcza.gnu.org.ua/bugs/?503 * src/gdbmdefs.h (gdbm_avail_block_valid_p): Remove. * src/gdbmopen.c (gdbm_avail_block_validate): Use inline conditional instead of gdbm_avail_block_valid_p. (gdbm_fd_open): Revert to reading master avail_block in two passes (as was before fd5cf245ea). (validate_header): Add back master avail block consistency check. * src/gdbmtool.c (_gdbm_avail_list_size): Use _gdbm_avail_block_read. * src/recover.c (_gdbm_finish_transfer): Reset dbf->file_size.
| * Verify if key/pair ends at a valid offset before attempting to read it.Sergey Poznyakoff2021-03-166-28/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes https://puszcza.gnu.org.ua/bugs/index.php?502. * src/findkey.c (gdbm_bucket_element_valid_p): Verify also if the key/data pair ends at a valid file offset. (_gdbm_read_entry): Set up the cache data only on success. * src/gdbmdefs.h (gdbm_bucket_element_valid_p): Remove declaration. (gdbm_file_info): New member 'file_size' keeps the recently retrieved value of the file size. It is invalidated wherever data is written to the database. * src/fullio.c (_gdbm_full_write,_gdbm_file_extend): Invalidate dbf->file_size. * src/gdbmopen.c (gdbm_fd_open): Initialize file_size to -1. (_gdbm_file_size): New function. * src/mmap.c (_gdbm_file_size): Remove. * src/proto.h (_gdbm_file_size): New proto.
| * Improve reading and validation of available blocks (avail_block).Sergey Poznyakoff2021-03-165-42/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes http://puszcza.gnu.org.ua/bugs/?501. * src/falloc.c (_gdbm_avail_block_read): New function. (pop_avail_block): Use _gdbm_avail_block_read. * src/gdbmdefs.h: Fix typo in the comment. * src/gdbmopen.c (gdbm_avail_block_validate): Take size of the avail block in bytes as the third argument. All uses changed. (PARTIAL_HEADER_SIZE) (HEADER_AVAIL_SIZE): New macros. (_gdbm_validate_header): Validate the avail block as well. (validate_header): Don't validate the avail block fields here. (gdbm_fd_open): Read partial header up to the avail field, then read entire avail block using _gdbm_avail_block_read. * src/gdbmtool.c (_gdbm_print_avail_list): Fix avail block calculation (one extra entry was assumed). Use _gdbm_avail_block_read to obtain and validate block. * src/proto.h (_gdbm_avail_block_read): New proto. (gdbm_avail_block_validate): Change signature.
| * Fix memory leak in gdbm_recoverSergey Poznyakoff2021-03-161-0/+1
| | | | | | | | * src/recover.c (_gdbm_finish_transfer): Free the cache.
| * Fix bug #499Sergey Poznyakoff2021-03-163-2/+25
| | | | | | | | | | | | | | | | | | | | See http://puszcza.gnu.org.ua/bugs/?499 * src/gdbm.h.in (GDBM_BAD_HASH_ENTRY): New error code. * src/gdbmseq.c (get_next_key): Verify the computed hash and bucket address for the obtained key. * src/gdbmerrno.c (gdbm_errlist): Add error message for GDBM_BAD_HASH_ENTRY.
| * Merge branch 'master' into newcacheSergey Poznyakoff2021-01-096-8/+11
| |\
| * | Update copyright yearsSergey Poznyakoff2021-01-02145-205/+150
| | |