aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-08-10 23:26:56 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-08-10 23:26:56 +0000
commite5f0f221444618ba6004d697af2535bdaff906bf (patch)
treedc6285c26798934129a0b9fbfbc68a788ea06177
parent74f7fe561e31637bdbf21aeb817d4a22bbf9c91a (diff)
downloadgdbm-e5f0f221444618ba6004d697af2535bdaff906bf.tar.gz
gdbm-e5f0f221444618ba6004d697af2535bdaff906bf.tar.bz2
Improve gdbm_setopt interface.
* src/gdbm.h.in (GDBM_OPENMASK): New constant. * src/gdbmconst.h: Remove constants duplicated in gdbm.h.in. * src/gdbmdefs.h (gdbm_file_info) <allow_mmap> <mmap_inited>: Replace with a single member: memory_mapping. All callers updated. (GDBM_SETCACHESIZE,GDBM_SETSYNCMODE) (GDBM_SETCENTFREE,GDBM_SETCOALESCEBLKS): New option names. (GDBM_SETMMAP,GDBM_GETMMAP,GDBM_GETFLAGS) (GDBM_GETCACHESIZE,GDBM_GETSYNCMODE,GDBM_GETCENTFREE) (GDBM_GETCOALESCEBLKS,GDBM_GETMAXMAPSIZE): New option codes. * src/gdbmsetopt.c: Implement new options. * doc/gdbm.texinfo: Document new options.
-rw-r--r--ChangeLog18
-rw-r--r--doc/gdbm.texinfo79
-rw-r--r--src/gdbm.h.in30
-rw-r--r--src/gdbmconst.h23
-rw-r--r--src/gdbmdefs.h3
-rw-r--r--src/gdbmopen.c11
-rw-r--r--src/gdbmreorg.c2
-rw-r--r--src/gdbmsetopt.c114
-rw-r--r--src/mmap.c10
9 files changed, 228 insertions, 62 deletions
diff --git a/ChangeLog b/ChangeLog
index 1b358b9..f7a97c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,26 @@
2011-08-11 Sergey Poznyakoff <gray@gnu.org.ua>
+ Improve gdbm_setopt interface.
+
+ * src/gdbm.h.in (GDBM_OPENMASK): New constant.
+ * src/gdbmconst.h: Remove constants duplicated in
+ gdbm.h.in.
+ * src/gdbmdefs.h (gdbm_file_info) <allow_mmap>
+ <mmap_inited>: Replace with a single member: memory_mapping.
+ All callers updated.
+ (GDBM_SETCACHESIZE,GDBM_SETSYNCMODE)
+ (GDBM_SETCENTFREE,GDBM_SETCOALESCEBLKS): New option names.
+ (GDBM_SETMMAP,GDBM_GETMMAP,GDBM_GETFLAGS)
+ (GDBM_GETCACHESIZE,GDBM_GETSYNCMODE,GDBM_GETCENTFREE)
+ (GDBM_GETCOALESCEBLKS,GDBM_GETMAXMAPSIZE): New option codes.
+ * src/gdbmsetopt.c: Implement new options.
+ * doc/gdbm.texinfo: Document new options.
+
+2011-08-11 Sergey Poznyakoff <gray@gnu.org.ua>
+
Improve memory mapping support.
The new code is more flexible and performs better when
lots of inserts are being made (e.g. when populating the
database with new data).
diff --git a/doc/gdbm.texinfo b/doc/gdbm.texinfo
index 5dc8a97..04efeea 100644
--- a/doc/gdbm.texinfo
+++ b/doc/gdbm.texinfo
@@ -736,90 +736,147 @@ The @var{errno} argument is usually the value of the global variable
@code{Gdbm} supports the ability to set certain options on an already
open database.
@deftypefn {gdbm interface} int gdbm_setopt (GDBM_FILE @var{dbf}, int @var{option}, @
void *@var{value}, int @var{size})
-Sets an option on the database.
+Sets an option on the database or returns the value of an option.
The parameters are:
@table @var
@item dbf
The pointer returned by @code{gdbm_open}.
@item option
-The option to be set.
+The option to be set or retreived.
@item value
-A pointer to the value to which @var{option} will be set.
+A pointer to the value to which @var{option} will be set or where to
+place the option value (depending on the option).
@item size
The length of the data pointed to by @var{value}.
@end table
@end deftypefn
The valid options are:
@table @asis
@kwindex GDBM_CACHESIZE
-@item GDBM_CACHESIZE
+@kwindex GDBM_SETCACHESIZE
+@item GDBM_SETCACHESIZE
+@itemx GDBM_CACHESIZE
Set the size of the internal bucket cache. This option may only be
set once on each GDBM_FILE descriptor, and is set automatically to 100
upon the first access to the database. The @var{value} should point
-to an integer holding the desired cache size.
+to a @code{size_t} holding the desired cache size.
+
+The @samp{GDBM_CACHESIZE} option is provided for compatibility with
+earlier versions.
+
+@kwindex GDBM_GETCACHESIZE
+@item GDBM_GETCACHESIZE
+Return the size of the internal bucket cache. The @var{value} should
+point to a @code{size_t} variable, where the size will be stored.
+
+@kwindex GDBM_GETFLAGS
+@item GDBM_GETFLAGS
+Return the flags describing the state of the database. The @var{value} should
+point to a @code{int} variable where to store the flags. The return
+is the same as the flags used when opening the database (@pxref{Open,
+gdbm_open}), except that it reflects the current state (which may have
+been altered by another calls to @code{gdbm_setopt}.
@kwindex GDBM_FASTMODE
@item GDBM_FASTMODE
Enable or disable the @dfn{fast writes mode}, i.e. writes without
subsequent synchronization. The @var{value} should point
to an integer: @samp{TRUE} to enable fast mode, and @samp{FALSE} to
disable it.
This option is retained for compatibility with previous versions of
-@code{gdbm}. Its effect is the reverse of @code{GDBM_SYNCMODE}
+@code{gdbm}. Its effect is the reverse of @code{GDBM_SETSYNCMODE}
(see below).
+@kwindex GDBM_SETSYNCMODE
@kwindex GDBM_SYNCMODE
-@item GDBM_SYNCMODE
+@item GDBM_SETSYNCMODE
+@itemx GDBM_SYNCMODE
Turn on or off file system synchronization operations. This
setting defaults to off. The @var{value} should point
to an integer: @samp{TRUE} to turn synchronization on, and @samp{FALSE} to
turn it off.
Note, that this option is a reverse of @code{GDBM_FASTMODE},
-i.e. calling @code{GDBM_SYNCMODE} with @samp{TRUE} has the same effect
+i.e. calling @code{GDBM_SETSYNCMODE} with @samp{TRUE} has the same effect
as calling @code{GDBM_FASTMODE} with @samp{FALSE}.
+The @samp{GDBM_SYNCMODE} option is provided for compatibility with
+earlier versions.
+
+@kwindex GDBM_GETSYNCMODE
+@item GDBM_GETSYNCMODE
+Return the current synchronization status. The @var{value} should
+point to an @code{int} where the status will be stored.
+
+@kwindex GDBM_SETCENTFREE
@kwindex GDBM_CENTFREE
-@item GDBM_CENTFREE
+@item GDBM_SETCENTFREE
+@itemx GDBM_CENTFREE
@emph{NOTICE: This feature is still under study.}
Set central free block pool to either on or off. The default is off,
which is how previous versions of @code{gdbm} handled free blocks. If
set, this option causes all subsequent free blocks to be placed in the
@emph{global} pool, allowing (in theory) more file space to be reused
more quickly. The @var{value} should point to an integer: @samp{TRUE} to
turn central block pool on, and @samp{FALSE} to turn it off.
+The @samp{GDBM_CENTFREE} option is provided for compatibility with
+earlier versions.
+
+@kwindex GDBM_SETCOALESCEBLKS
@kwindex GDBM_COALESCEBLKS
-@item GDBM_COALESCEBLKS
+@item GDBM_SETCOALESCEBLKS
+@itemx GDBM_COALESCEBLKS
@emph{NOTICE: This feature is still under study.}
Set free block merging to either on or off. The default is off, which
is how previous versions of @code{gdbm} handled free blocks. If set,
this option causes adjacent free blocks to be merged. This can become
a @acronym{CPU} expensive process with time, though, especially if
used in conjunction with GDBM_CENTFREE. The @var{value} should point
to an integer: @samp{TRUE} to turn free block merging on, and @samp{FALSE} to
turn it off.
+@kwindex GDBM_GETCOALESCEBLKS
+@item GDBM_GETCOALESCEBLKS
+Return the current status of free block merging. The @var{value} should
+point to an @code{int} where the status will be stored.
+
@kwindex GDBM_SETMAXMAPSIZE
@item GDBM_SETMAXMAPSIZE
-Sets maximum size of the memory mapped region. The @var{value} should
+Sets maximum size of a memory mapped region. The @var{value} should
point to a value of type @code{size_t}, @code{unsigned long} or
@code{unsigned}. The actual value is rounded to the nearest page
boundary (the page size is obtained from
@code{sysconf(_SC_PAGESIZE)}).
+
+@kwindex GDBM_GETMAXMAPSIZE
+@item GDBM_GETMAXMAPSIZE
+Return the maximum size of a memory mapped region. The @var{value} should
+point to a value of type @code{size_t} where to return the data.
+
+@kwindex GDBM_SETMMAP
+@item GDBM_SETMMAP
+Enable or disable memory mapping mode. The @var{value} should point
+to an integer: @samp{TRUE} to enable memory mapping or @samp{FALSE} to
+disable it.
+
+@kwindex GDBM_GETMMAP
+@item GDBM_GETMMAP
+Check whether memory mapping is enabled. The @var{value} should point
+to an integer where to return the status.
@end table
The return value will be @samp{-1} upon failure, or @samp{0} upon
success. The global variable @code{gdbm_errno} will be set upon failure.
For instance, to set a database to use a cache of 10, after opening it
diff --git a/src/gdbm.h.in b/src/gdbm.h.in
index 8eaee79..da88777 100644
--- a/src/gdbm.h.in
+++ b/src/gdbm.h.in
@@ -32,29 +32,47 @@
/* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who
can create the database. */
#define GDBM_READER 0 /* A reader. */
#define GDBM_WRITER 1 /* A writer. */
#define GDBM_WRCREAT 2 /* A writer. Create the db if needed. */
#define GDBM_NEWDB 3 /* A writer. Always create a new db. */
+#define GDBM_OPENMASK 7 /* Mask for the above. */
+
#define GDBM_FAST 0x10 /* Write fast! => No fsyncs. OBSOLETE. */
#define GDBM_SYNC 0x20 /* Sync operations to the disk. */
#define GDBM_NOLOCK 0x40 /* Don't do file locking operations. */
#define GDBM_NOMMAP 0x80 /* Don't use mmap(). */
/* Parameters to gdbm_store for simple insertion or replacement in the
case that the key is already in the database. */
#define GDBM_INSERT 0 /* Never replace old data with new. */
#define GDBM_REPLACE 1 /* Always replace old data with new. */
/* Parameters to gdbm_setopt, specifing the type of operation to perform. */
-#define GDBM_CACHESIZE 1 /* Set the cache size. */
-#define GDBM_FASTMODE 2 /* Toggle fast mode. OBSOLETE. */
-#define GDBM_SYNCMODE 3 /* Turn on or off sync operations. */
-#define GDBM_CENTFREE 4 /* Keep all free blocks in the header. */
-#define GDBM_COALESCEBLKS 5 /* Attempt to coalesce free blocks. */
-#define GDBM_SETMAXMAPSIZE 6 /* Set maximum mapped memory size */
+#define GDBM_SETCACHESIZE 1 /* Set the cache size. */
+#define GDBM_FASTMODE 2 /* Toggle fast mode. OBSOLETE. */
+#define GDBM_SETSYNCMODE 3 /* Turn on or off sync operations. */
+#define GDBM_SETCENTFREE 4 /* Keep all free blocks in the header. */
+#define GDBM_SETCOALESCEBLKS 5 /* Attempt to coalesce free blocks. */
+#define GDBM_SETMAXMAPSIZE 6 /* Set maximum mapped memory size */
+#define GDBM_SETMMAP 7
+
+/* Compatibility defines: */
+#define GDBM_CACHESIZE GDBM_SETCACHESIZE
+#define GDBM_SYNCMODE GDBM_SETSYNCMODE
+#define GDBM_CENTFREE GDBM_SETCENTFREE
+#define GDBM_COALESCEBLKS GDBM_SETCENTFREE
+
+#define GDBM_GETFLAGS 8
+#define GDBM_GETMMAP 9
+#define GDBM_GETCACHESIZE 10
+#define GDBM_GETSYNCMODE 11
+#define GDBM_GETCENTFREE 12
+#define GDBM_GETCOALESCEBLKS 13
+#define GDBM_GETMAXMAPSIZE 14
+
/* The data and key structure. */
typedef struct {
char *dptr;
int dsize;
} datum;
diff --git a/src/gdbmconst.h b/src/gdbmconst.h
index 7a3f5b9..24eac5f 100644
--- a/src/gdbmconst.h
+++ b/src/gdbmconst.h
@@ -32,35 +32,12 @@
#define GDBM_MAGIC64 0x13579acf /* New 64bit magic number. */
#define GDBM_OMAGIC_SWAP 0xce9a5713 /* OMAGIC swapped. */
#define GDBM_MAGIC32_SWAP 0xcd9a5713 /* MAGIC32 swapped. */
#define GDBM_MAGIC64_SWAP 0xcf9a5713 /* MAGIC64 swapped. */
-/* Parameters to gdbm_open. */
-#define GDBM_READER 0 /* READERS only. */
-#define GDBM_WRITER 1 /* READERS and WRITERS. Can not create. */
-#define GDBM_WRCREAT 2 /* If not found, create the db. */
-#define GDBM_NEWDB 3 /* ALWAYS create a new db. (WRITER) */
-#define GDBM_OPENMASK 7 /* Mask for the above. */
-#define GDBM_FAST 0x10 /* Write fast! => No fsyncs. OBSOLETE. */
-#define GDBM_SYNC 0x20 /* Sync operations to the disk. */
-#define GDBM_NOLOCK 0x40 /* Don't do file locking operations. */
-#define GDBM_NOMMAP 0x80 /* Don't use mmap(). */
-
-/* Parameters to gdbm_store for simple insertion or replacement in the
- case a key to store is already in the database. */
-#define GDBM_INSERT 0 /* Do not overwrite data in the database. */
-#define GDBM_REPLACE 1 /* Replace the old value with the new value. */
-
-/* Parameters to gdbm_setopt, specifing the type of operation to perform. */
-#define GDBM_CACHESIZE 1 /* Set the cache size. */
-#define GDBM_FASTMODE 2 /* Turn on or off fast mode. OBSOLETE. */
-#define GDBM_SYNCMODE 3 /* Turn on or off sync operations. */
-#define GDBM_CENTFREE 4 /* Keep all free blocks in the header. */
-#define GDBM_COALESCEBLKS 5 /* Attempt to coalesce free blocks. */
-
/* In freeing blocks, we will ignore any blocks smaller (and equal) to
IGNORE_SIZE number of bytes. */
#define IGNORE_SIZE 4
/* The number of key bytes kept in a hash bucket. */
#define SMALL 4
diff --git a/src/gdbmdefs.h b/src/gdbmdefs.h
index 2221aa5..e45abf8 100644
--- a/src/gdbmdefs.h
+++ b/src/gdbmdefs.h
@@ -147,14 +147,13 @@ struct gdbm_file_info {
unsigned coalesce_blocks :1;
/* Whether or not we should do file locking ourselves. */
unsigned file_locking :1;
/* Whether or not we're allowing mmap() use. */
- unsigned allow_mmap :1;
- unsigned mmap_inited :1;
+ unsigned memory_mapping :1;
/* Type of file locking in use. */
enum { LOCKING_NONE = 0, LOCKING_FLOCK, LOCKING_LOCKF,
LOCKING_FCNTL } lock_type;
/* The fatal error handling routine. */
diff --git a/src/gdbmopen.c b/src/gdbmopen.c
index a110d64..b1b38b4 100644
--- a/src/gdbmopen.c
+++ b/src/gdbmopen.c
@@ -81,13 +81,13 @@ gdbm_open (const char *file, int block_size, int flags, int mode,
dbf->dir = NULL;
dbf->bucket = NULL;
dbf->header = NULL;
dbf->bucket_cache = NULL;
dbf->cache_size = 0;
- dbf->mmap_inited = FALSE;
+ dbf->memory_mapping = FALSE;
dbf->mapped_size_max = SIZE_T_MAX;
dbf->mapped_region = NULL;
dbf->mapped_size = 0;
dbf->mapped_pos = 0;
dbf->mapped_off = 0;
@@ -106,28 +106,23 @@ gdbm_open (const char *file, int block_size, int flags, int mode,
dbf->fatal_err = fatal_func;
dbf->fast_write = TRUE; /* Default to setting fast_write. */
dbf->file_locking = TRUE; /* Default to doing file locking. */
dbf->central_free = FALSE; /* Default to not using central_free. */
dbf->coalesce_blocks = FALSE; /* Default to not coalescing blocks. */
- dbf->allow_mmap = TRUE; /* Default to using mmap(). */
/* GDBM_FAST used to determine whether or not we set fast_write. */
if (flags & GDBM_SYNC)
{
/* If GDBM_SYNC has been requested, don't do fast_write. */
dbf->fast_write = FALSE;
}
if (flags & GDBM_NOLOCK)
{
dbf->file_locking = FALSE;
}
- if (flags & GDBM_NOMMAP)
- {
- dbf->allow_mmap = FALSE;
- }
/* Open the file. */
need_trunc = FALSE;
switch (flags & GDBM_OPENMASK)
{
case GDBM_READER:
@@ -392,16 +387,16 @@ gdbm_open (const char *file, int block_size, int flags, int mode,
return NULL;
}
}
#if HAVE_MMAP
- if (dbf->allow_mmap)
+ if (!(flags & GDBM_NOMMAP))
{
if (_gdbm_mapped_init (dbf) == 0)
- dbf->mmap_inited = TRUE;
+ dbf->memory_mapping = TRUE;
else
{
/* gdbm_errno should already be set. */
close (dbf->desc);
free (dbf->name);
free (dbf);
diff --git a/src/gdbmreorg.c b/src/gdbmreorg.c
index aed372e..6bde222 100644
--- a/src/gdbmreorg.c
+++ b/src/gdbmreorg.c
@@ -173,13 +173,13 @@ gdbm_reorganize (GDBM_FILE dbf)
free (dbf->bucket_cache[index].ca_data.dptr);
}
free (dbf->bucket_cache);
}
/* Re-initialize mapping if required */
- if (dbf->allow_mmap)
+ if (dbf->memory_mapping)
_gdbm_mapped_init (dbf);
dbf->desc = new_dbf->desc;
dbf->header = new_dbf->header;
dbf->dir = new_dbf->dir;
dbf->bucket = new_dbf->bucket;
diff --git a/src/gdbmsetopt.c b/src/gdbmsetopt.c
index 54a972f..f9494d0 100644
--- a/src/gdbmsetopt.c
+++ b/src/gdbmsetopt.c
@@ -64,64 +64,166 @@ gdbm_setopt (GDBM_FILE dbf, int optflag, void *optval, int optlen)
{
int n;
size_t sz;
switch (optflag)
{
- case GDBM_CACHESIZE:
+ /* Cache size: */
+
+ case GDBM_SETCACHESIZE:
/* Optval will point to the new size of the cache. */
if (dbf->bucket_cache != NULL)
{
gdbm_errno = GDBM_OPT_ALREADY_SET;
return -1;
}
if (get_size (optval, optlen, &sz))
return -1;
return _gdbm_init_cache (dbf, (sz > 9) ? sz : 10);
+ case GDBM_GETCACHESIZE:
+ if (!optval || optlen != sizeof (size_t))
+ {
+ gdbm_errno = GDBM_OPT_ILLEGAL;
+ return -1;
+ }
+ *(size_t*) optval = dbf->cache_size;
+ break;
+
+ /* Obsolete form of GDBM_SETSYNCMODE. */
case GDBM_FASTMODE:
- /* Obsolete form of SYNCMODE. */
if ((n = getbool (optval, optlen)) == -1)
return -1;
dbf->fast_write = n;
break;
-
- case GDBM_SYNCMODE:
+
+ /* SYNC mode: */
+
+ case GDBM_SETSYNCMODE:
/* Optval will point to either true or false. */
if ((n = getbool (optval, optlen)) == -1)
return -1;
dbf->fast_write = !n;
break;
- case GDBM_CENTFREE:
+ case GDBM_GETSYNCMODE:
+ if (!optval || optlen != sizeof (int))
+ {
+ gdbm_errno = GDBM_OPT_ILLEGAL;
+ return -1;
+ }
+ *(int*) optval = !dbf->fast_write;
+ break;
+
+ /* CENTFREE - set or get the stat of the central block repository */
+ case GDBM_SETCENTFREE:
/* Optval will point to either true or false. */
if ((n = getbool (optval, optlen)) == -1)
return -1;
dbf->central_free = n;
break;
- case GDBM_COALESCEBLKS:
+ case GDBM_GETCENTFREE:
+ if (!optval || optlen != sizeof (int))
+ {
+ gdbm_errno = GDBM_OPT_ILLEGAL;
+ return -1;
+ }
+ *(int*) optval = !dbf->central_free;
+ break;
+
+ /* Coalesce state: */
+ case GDBM_SETCOALESCEBLKS:
/* Optval will point to either true or false. */
if ((n = getbool (optval, optlen)) == -1)
return -1;
dbf->coalesce_blocks = n;
break;
+ case GDBM_GETCOALESCEBLKS:
+ if (!optval || optlen != sizeof (int))
+ {
+ gdbm_errno = GDBM_OPT_ILLEGAL;
+ return -1;
+ }
+ *(int*) optval = dbf->coalesce_blocks;
+ break;
+
+ /* Mmap mode */
+ case GDBM_SETMMAP:
+ if ((n = getbool (optval, optlen)) == -1)
+ return -1;
+ __fsync (dbf);
+ if (n == dbf->memory_mapping)
+ return 0;
+ if (n)
+ {
+ if (_gdbm_mapped_init (dbf) == 0)
+ dbf->memory_mapping = TRUE;
+ else
+ return -1;
+ }
+ else
+ {
+ _gdbm_mapped_unmap (dbf);
+ dbf->memory_mapping = FALSE;
+ }
+ break;
+
+ case GDBM_GETMMAP:
+ if (!optval || optlen != sizeof (int))
+ {
+ gdbm_errno = GDBM_OPT_ILLEGAL;
+ return -1;
+ }
+ *(int*) optval = dbf->memory_mapping;
+ break;
+
+ /* Maximum size of a memory mapped region */
case GDBM_SETMAXMAPSIZE:
{
size_t page_size = sysconf (_SC_PAGESIZE);
if (get_size (optval, optlen, &sz))
return -1;
dbf->mapped_size_max = ((sz + page_size - 1) / page_size) *
page_size;
_gdbm_mapped_init (dbf);
break;
}
+ case GDBM_GETMAXMAPSIZE:
+ if (!optval || optlen != sizeof (size_t))
+ {
+ gdbm_errno = GDBM_OPT_ILLEGAL;
+ return -1;
+ }
+ *(size_t*) optval = dbf->mapped_size_max;
+ break;
+
+ /* Flags */
+ case GDBM_GETFLAGS:
+ if (!optval || optlen != sizeof (int))
+ {
+ gdbm_errno = GDBM_OPT_ILLEGAL;
+ return -1;
+ }
+ else
+ {
+ int flags = dbf->read_write;
+ if (!dbf->fast_write)
+ flags |= GDBM_SYNC;
+ if (!dbf->file_locking)
+ flags |= GDBM_NOLOCK;
+ if (!dbf->memory_mapping)
+ flags |= GDBM_NOMMAP;
+ *(int*) optval = flags;
+ }
+ break;
+
default:
gdbm_errno = GDBM_OPT_ILLEGAL;
return -1;
}
return 0;
diff --git a/src/mmap.c b/src/mmap.c
index 2107bd6..f654af3 100644
--- a/src/mmap.c
+++ b/src/mmap.c
@@ -205,13 +205,13 @@ _gdbm_mapped_init (GDBM_FILE dbf)
/* Read LEN bytes from the GDBM file DBF into BUFFER. If mmapping is
not initialized or if it fails, fall back to the classical read(1).
Return number of bytes read or -1 on failure. */
ssize_t
_gdbm_mapped_read (GDBM_FILE dbf, void *buffer, size_t len)
{
- if (dbf->mmap_inited)
+ if (dbf->memory_mapping)
{
ssize_t total = 0;
char *cbuf = buffer;
while (len)
{
@@ -222,13 +222,13 @@ _gdbm_mapped_read (GDBM_FILE dbf, void *buffer, size_t len)
off_t pos = _GDBM_MMAPPED_POS (dbf);
if (_gdbm_mapped_remap (dbf, SUM_FILE_SIZE (dbf, len),
_REMAP_DEFAULT))
{
int rc;
- dbf->mmap_inited = FALSE;
+ dbf->memory_mapping = FALSE;
if (lseek (dbf->desc, pos, SEEK_SET) != pos)
return total > 0 ? total : -1;
rc = read (dbf->desc, cbuf, len);
if (rc == -1)
return total > 0 ? total : -1;
return total + rc;
@@ -255,13 +255,13 @@ _gdbm_mapped_read (GDBM_FILE dbf, void *buffer, size_t len)
/* Write LEN bytes from BUFFER to the GDBM file DBF. If mmapping is
not initialized or if it fails, fall back to the classical write(1).
Return number of bytes written or -1 on failure. */
ssize_t
_gdbm_mapped_write (GDBM_FILE dbf, void *buffer, size_t len)
{
- if (dbf->mmap_inited)
+ if (dbf->memory_mapping)
{
ssize_t total = 0;
char *cbuf = buffer;
while (len)
{
@@ -272,13 +272,13 @@ _gdbm_mapped_write (GDBM_FILE dbf, void *buffer, size_t len)
off_t pos = _GDBM_MMAPPED_POS (dbf);
if (_gdbm_mapped_remap (dbf, SUM_FILE_SIZE (dbf, len),
_REMAP_EXTEND))
{
int rc;
- dbf->mmap_inited = FALSE;
+ dbf->memory_mapping = FALSE;
if (lseek (dbf->desc, pos, SEEK_SET) != pos)
return total > 0 ? total : -1;
rc = write (dbf->desc, cbuf, len);
if (rc == -1)
return total > 0 ? total : -1;
return total + rc;
@@ -309,13 +309,13 @@ _gdbm_mapped_write (GDBM_FILE dbf, void *buffer, size_t len)
Return number of bytes written or -1 on failure. */
off_t
_gdbm_mapped_lseek (GDBM_FILE dbf, off_t offset, int whence)
{
- if (dbf->mmap_inited)
+ if (dbf->memory_mapping)
{
off_t needle;
switch (whence)
{
case SEEK_SET:

Return to:

Send suggestions and report system problems to the System administrator.