diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-15 14:46:08 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-15 14:57:40 +0300 |
commit | 44ca2b760b393e993b2a42fc489fa170910ad810 (patch) | |
tree | 12aa7390b19bed8aba2535cedb04376c45f820a5 /doc | |
parent | 5580c3248794803a8e45dd58b45933a32637954d (diff) | |
download | gdbm-44ca2b760b393e993b2a42fc489fa170910ad810.tar.gz gdbm-44ca2b760b393e993b2a42fc489fa170910ad810.tar.bz2 |
gdbm_open adjusts requested block size to accomodate integer number of directory offsets.
* src/gdbm.h.in (GDBM_BSEXACT): New flag.
* src/gdbmopen.c (compute_directory_size): New function.
(gdbm_open): When creating new database, adjust the requested
block size so that the block holds integer number of directory
indices. Disable this behavior if GDBM_BSEXACT flag is set
(this reverts to old behavior). Always unset GDBM_BSEXACT if
using block size returned by stat(2). This makes sure gdbm_open
succeeds on file systems reporting block sizes not divisible by
512.
* src/gdbmconst.h (GDBM_MIN_BLOCK_SIZE): New constant.
* src/gdbmimp.c (gdbm_import_from_file): Use GDBM_MIN_BLOCK_SIZE
instead of the hardcoded value.
* NEWS: Document GDBM_BSEXACT.
* doc/gdbm.texi: Likewise.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/gdbm.texi | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/doc/gdbm.texi b/doc/gdbm.texi index d172ad7..8096215 100644 --- a/doc/gdbm.texi +++ b/doc/gdbm.texi @@ -249,27 +249,32 @@ initialization procedure is performed, setting up the initial structure in the file. The arguments are: @table @var @item name The name of the file (the complete name, @code{gdbm} does not append any characters to this name). @item block_size It is used during initialization to determine the size of various constructs. It is the size of a single transfer from disk to memory. This parameter is ignored if the file has been previously -initialized. The minimum size is 512. If the value is less than 512, -the file system block size is used, otherwise the value of -@var{block_size} is used. +initialized. If the value is less than 512, the file system block +size is used instead. The size is adjusted so that the block can hold +exact number of directory entries, so that the effective block size +can be slightly greater than requested. However, if the +@samp{GDBM_BSEXACT} flag is set and the size needs to be adjusted, the +function will return with error status, setting the @samp{gdbm_errno} +variable to @samp{GDBM_BLOCK_SIZE_ERROR}. + @item flags @kwindex GDBM_READER @kwindex GDBM_WRITER @kwindex GDBM_WRCREAT @kwindex GDBM_NEWDB If @code{flags} is set to @samp{GDBM_READER}, the user wants to just read the database and any call to @code{gdbm_store} or @code{gdbm_delete} will fail. Many readers can access the database at the same time. If @code{flags} is set to @samp{GDBM_WRITER}, the user wants both read and write access to the database and requires exclusive access. If @code{flags} is set to @samp{GDBM_WRCREAT}, the user wants both read and write access to the database and wants it created if it does not already exist. If @@ -278,24 +283,30 @@ created, regardless of whether one existed, and wants read and write access to the new database. @kwindex GDBM_SYNC @kwindex GDBM_NOLOCK @kwindex GDBM_NOMMAP The following may also be logically or'd into the database flags: @samp{GDBM_SYNC}, which causes all database operations to be synchronized to the disk, @samp{GDBM_NOLOCK}, which prevents the library from performing any locking on the database file, and @samp{GDBM_NOMMAP}, which disables the memory mapping mechanism. The option @samp{GDBM_FAST} is now obsolete, since @code{gdbm} defaults to no-sync mode. +@kwindex GDBM_BSEXACT +If this flag is set and the requested @var{block_size} cannot be used +without adjustment, @code{gdbm_open} will refuse to create the +databases. In this case it will set the @samp{gdbm_errno} +variable to @samp{GDBM_BLOCK_SIZE_ERROR} and return @samp{NULL}. + @kwindex GDBM_CLOEXEC @cindex close-on-exec If the host @samp{open} call @ifhtml (@uref{http://www.manpagez.com/man/2/open, open(2)}) @end ifhtml @ifnothtml (@pxref{open,,,open(2),open(2) man page}) @end ifnothtml supports the @samp{O_CLOEXEC} flag, the @samp{GDBM_CLOEXEC} can be or'd into the flags, to enable the close-on-exec flag for the database file descriptor. @@ -1224,27 +1235,29 @@ This chapter summarizes error codes which can be set by the functions in @code{gdbm} library. @table @asis @kwindex GDBM_NO_ERROR @item GDBM_NO_ERROR No error occurred. @kwindex GDBM_MALLOC_ERROR @item GDBM_MALLOC_ERROR Memory allocation failed. Not enough memory. @kwindex GDBM_BLOCK_SIZE_ERROR +@kwindex GDBM_BSEXACT @item GDBM_BLOCK_SIZE_ERROR This error is set by the @code{gdbm_open} function (@pxref{Open}), if -the value of its @var{block_size} argument is incorrect. +the value of its @var{block_size} argument is incorrect and the +@samp{GDBM_BSEXACT} flag is set. @kwindex GDBM_FILE_OPEN_ERROR @item GDBM_FILE_OPEN_ERROR The library was not able to open a disk file. This can be set by @code{gdbm_open} (@pxref{Open}), @code{gdbm_export} and @code{gdbm_import} functions (@pxref{Flat files}). Inspect the value of the system @code{errno} variable to get more detailed diagnostics. @kwindex GDBM_FILE_WRITE_ERROR @item GDBM_FILE_WRITE_ERROR |