diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-06-27 17:33:22 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-06-27 17:33:22 +0300 |
commit | 505faa939a83495603b2fd4a5c77d2ca8d5b08df (patch) | |
tree | 3e5550d33744abd9c566d994b6cd3f8cbfac7dd5 /src | |
parent | 3bf70df01fc591e10b204b69074e1ff4074f143b (diff) | |
download | gdbm-505faa939a83495603b2fd4a5c77d2ca8d5b08df.tar.gz gdbm-505faa939a83495603b2fd4a5c77d2ca8d5b08df.tar.bz2 |
New gdbmtool variables: coalesce and centfree
The two boolean variables control the use of free block coalescing and
central free block modes in newly opened databases.
Diffstat (limited to 'src')
-rw-r--r-- | src/gdbmtool.c | 15 | ||||
-rw-r--r-- | src/var.c | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/gdbmtool.c b/src/gdbmtool.c index e99547d..5ae668c 100644 --- a/src/gdbmtool.c +++ b/src/gdbmtool.c | |||
@@ -84,13 +84,13 @@ opendb (char *dbname) | |||
84 | if (!variable_is_true ("lock")) | 84 | if (!variable_is_true ("lock")) |
85 | flags |= GDBM_NOLOCK; | 85 | flags |= GDBM_NOLOCK; |
86 | if (!variable_is_true ("mmap")) | 86 | if (!variable_is_true ("mmap")) |
87 | flags |= GDBM_NOMMAP; | 87 | flags |= GDBM_NOMMAP; |
88 | if (variable_is_true ("sync")) | 88 | if (variable_is_true ("sync")) |
89 | flags |= GDBM_SYNC; | 89 | flags |= GDBM_SYNC; |
90 | 90 | ||
91 | if (open_mode == GDBM_NEWDB) | 91 | if (open_mode == GDBM_NEWDB) |
92 | { | 92 | { |
93 | if (interactive () && variable_is_true ("confirm") && | 93 | if (interactive () && variable_is_true ("confirm") && |
94 | access (dbname, F_OK) == 0) | 94 | access (dbname, F_OK) == 0) |
95 | { | 95 | { |
96 | if (!getyn (_("database %s already exists; overwrite"), dbname)) | 96 | if (!getyn (_("database %s already exists; overwrite"), dbname)) |
@@ -111,12 +111,25 @@ opendb (char *dbname) | |||
111 | } | 111 | } |
112 | 112 | ||
113 | if (cache_size && | 113 | if (cache_size && |
114 | gdbm_setopt (db, GDBM_CACHESIZE, &cache_size, sizeof (int)) == -1) | 114 | gdbm_setopt (db, GDBM_CACHESIZE, &cache_size, sizeof (int)) == -1) |
115 | terror (_("gdbm_setopt failed: %s"), gdbm_strerror (gdbm_errno)); | 115 | terror (_("gdbm_setopt failed: %s"), gdbm_strerror (gdbm_errno)); |
116 | 116 | ||
117 | if (variable_is_true ("coalesce")) | ||
118 | { | ||
119 | int t = 1; | ||
120 | if (gdbm_setopt (db, GDBM_SETCOALESCEBLKS, &t, sizeof (t)) == -1) | ||
121 | terror (_("gdbm_setopt failed: %s"), gdbm_strerror (gdbm_errno)); | ||
122 | } | ||
123 | if (variable_is_true ("centfree")) | ||
124 | { | ||
125 | int t = 1; | ||
126 | if (gdbm_setopt (db, GDBM_SETCENTFREE, &t, sizeof (t)) == -1) | ||
127 | terror (_("gdbm_setopt failed: %s"), gdbm_strerror (gdbm_errno)); | ||
128 | } | ||
129 | |||
117 | if (gdbm_file) | 130 | if (gdbm_file) |
118 | gdbm_close (gdbm_file); | 131 | gdbm_close (gdbm_file); |
119 | 132 | ||
120 | gdbm_file = db; | 133 | gdbm_file = db; |
121 | return 0; | 134 | return 0; |
122 | } | 135 | } |
@@ -56,12 +56,14 @@ static struct variable vartab[] = { | |||
56 | { "cachesize", VART_INT, VARF_DFL }, | 56 | { "cachesize", VART_INT, VARF_DFL }, |
57 | { "blocksize", VART_INT, VARF_DFL }, | 57 | { "blocksize", VART_INT, VARF_DFL }, |
58 | { "open", VART_STRING, VARF_DFL, { NULL }, open_hook }, | 58 | { "open", VART_STRING, VARF_DFL, { NULL }, open_hook }, |
59 | { "lock", VART_BOOL, VARF_INIT, { .bool = 1 } }, | 59 | { "lock", VART_BOOL, VARF_INIT, { .bool = 1 } }, |
60 | { "mmap", VART_BOOL, VARF_INIT, { .bool = 1 } }, | 60 | { "mmap", VART_BOOL, VARF_INIT, { .bool = 1 } }, |
61 | { "sync", VART_BOOL, VARF_INIT, { .bool = 0 } }, | 61 | { "sync", VART_BOOL, VARF_INIT, { .bool = 0 } }, |
62 | { "coalesce", VART_BOOL, VARF_INIT, { .bool = 0 } }, | ||
63 | { "centfree", VART_BOOL, VARF_INIT, { .bool = 0 } }, | ||
62 | { "filemode", VART_INT, VARF_INIT|VARF_OCTAL|VARF_PROT, { .num = 0644 } }, | 64 | { "filemode", VART_INT, VARF_INIT|VARF_OCTAL|VARF_PROT, { .num = 0644 } }, |
63 | { "pager", VART_STRING, VARF_DFL }, | 65 | { "pager", VART_STRING, VARF_DFL }, |
64 | { "quiet", VART_BOOL, VARF_DFL }, | 66 | { "quiet", VART_BOOL, VARF_DFL }, |
65 | { NULL } | 67 | { NULL } |
66 | }; | 68 | }; |
67 | 69 | ||