summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2018-05-30 09:45:21 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-05-30 09:45:21 (GMT)
commitb8d5da4c426b21ca0e56fc1cd6f75b49c0668e95 (patch) (unidiff)
tree26cbb1b04cd9febcdd37237c9576ea1c5eff3926
parenta14a6881538229cd938282bd56c7f0d12a089be6 (diff)
downloadgdbm-b8d5da4c426b21ca0e56fc1cd6f75b49c0668e95.tar.gz
gdbm-b8d5da4c426b21ca0e56fc1cd6f75b49c0668e95.tar.bz2
Namespace cleanup
Rename: __read to gdbm_file_read __write to gdbm_file_write __lseek to gdbm_file_seek __fsync to gdbm_file_sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/bucket.c6
-rw-r--r--src/falloc.c4
-rw-r--r--src/findkey.c2
-rw-r--r--src/fullio.c4
-rw-r--r--src/gdbmclose.c2
-rw-r--r--src/gdbmopen.c4
-rw-r--r--src/gdbmsetopt.c2
-rw-r--r--src/gdbmstore.c2
-rw-r--r--src/gdbmsync.c2
-rw-r--r--src/gdbmtool.c4
-rw-r--r--src/proto.h20
-rw-r--r--src/recover.c2
-rw-r--r--src/systems.h16
-rw-r--r--src/update.c8
14 files changed, 41 insertions, 37 deletions
diff --git a/src/bucket.c b/src/bucket.c
index 2289594..e17019c 100644
--- a/src/bucket.c
+++ b/src/bucket.c
@@ -112,7 +112,7 @@ _gdbm_get_bucket (GDBM_FILE dbf, int dir_index)
112 /* It is not in the cache, read it from the disk. */ 112 /* It is not in the cache, read it from the disk. */
113 113
114 /* Position the file pointer */ 114 /* Position the file pointer */
115 file_pos = __lseek (dbf, bucket_adr, SEEK_SET); 115 file_pos = gdbm_file_seek (dbf, bucket_adr, SEEK_SET);
116 if (file_pos != bucket_adr) 116 if (file_pos != bucket_adr)
117 { 117 {
118 GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE); 118 GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
@@ -187,7 +187,7 @@ _gdbm_read_bucket_at (GDBM_FILE dbf, off_t off, hash_bucket *bucket,
187 } 187 }
188 188
189 /* Read the bucket. */ 189 /* Read the bucket. */
190 file_pos = __lseek (dbf, off, SEEK_SET); 190 file_pos = gdbm_file_seek (dbf, off, SEEK_SET);
191 if (file_pos != off) 191 if (file_pos != off)
192 { 192 {
193 GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE); 193 GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
@@ -432,7 +432,7 @@ _gdbm_write_bucket (GDBM_FILE dbf, cache_elem *ca_entry)
432 int rc; 432 int rc;
433 off_t file_pos;/* The return value for lseek. */ 433 off_t file_pos;/* The return value for lseek. */
434 434
435 file_pos = __lseek (dbf, ca_entry->ca_adr, SEEK_SET); 435 file_pos = gdbm_file_seek (dbf, ca_entry->ca_adr, SEEK_SET);
436 if (file_pos != ca_entry->ca_adr) 436 if (file_pos != ca_entry->ca_adr)
437 { 437 {
438 GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE); 438 GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
diff --git a/src/falloc.c b/src/falloc.c
index 13ee0ed..2f21ebe 100644
--- a/src/falloc.c
+++ b/src/falloc.c
@@ -191,7 +191,7 @@ pop_avail_block (GDBM_FILE dbf)
191 } 191 }
192 192
193 /* Read the block. */ 193 /* Read the block. */
194 file_pos = __lseek (dbf, new_el.av_adr, SEEK_SET); 194 file_pos = gdbm_file_seek (dbf, new_el.av_adr, SEEK_SET);
195 if (file_pos != new_el.av_adr) 195 if (file_pos != new_el.av_adr)
196 { 196 {
197 GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE); 197 GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
@@ -321,7 +321,7 @@ push_avail_block (GDBM_FILE dbf)
321 _gdbm_free (dbf, new_loc.av_adr, new_loc.av_size); 321 _gdbm_free (dbf, new_loc.av_adr, new_loc.av_size);
322 322
323 /* Update the disk. */ 323 /* Update the disk. */
324 file_pos = __lseek (dbf, av_adr, SEEK_SET); 324 file_pos = gdbm_file_seek (dbf, av_adr, SEEK_SET);
325 if (file_pos != av_adr) 325 if (file_pos != av_adr)
326 { 326 {
327 GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE); 327 GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
diff --git a/src/findkey.c b/src/findkey.c
index 9bb4553..9c8fd71 100644
--- a/src/findkey.c
+++ b/src/findkey.c
@@ -83,7 +83,7 @@ _gdbm_read_entry (GDBM_FILE dbf, int elem_loc)
83 } 83 }
84 84
85 /* Read into the cache. */ 85 /* Read into the cache. */
86 file_pos = __lseek (dbf, dbf->bucket->h_table[elem_loc].data_pointer, 86 file_pos = gdbm_file_seek (dbf, dbf->bucket->h_table[elem_loc].data_pointer,
87 SEEK_SET); 87 SEEK_SET);
88 if (file_pos != dbf->bucket->h_table[elem_loc].data_pointer) 88 if (file_pos != dbf->bucket->h_table[elem_loc].data_pointer)
89 { 89 {
diff --git a/src/fullio.c b/src/fullio.c
index bdb51cb..84eea60 100644
--- a/src/fullio.c
+++ b/src/fullio.c
@@ -27,7 +27,7 @@ _gdbm_full_read (GDBM_FILE dbf, void *buffer, size_t size)
27 char *ptr = buffer; 27 char *ptr = buffer;
28 while (size) 28 while (size)
29 { 29 {
30 ssize_t rdbytes = __read (dbf, ptr, size); 30 ssize_t rdbytes = gdbm_file_read (dbf, ptr, size);
31 if (rdbytes == -1) 31 if (rdbytes == -1)
32 { 32 {
33 if (errno == EINTR) 33 if (errno == EINTR)
@@ -55,7 +55,7 @@ _gdbm_full_write (GDBM_FILE dbf, void *buffer, size_t size)
55 char *ptr = buffer; 55 char *ptr = buffer;
56 while (size) 56 while (size)
57 { 57 {
58 ssize_t wrbytes = __write (dbf, ptr, size); 58 ssize_t wrbytes = gdbm_file_write (dbf, ptr, size);
59 if (wrbytes == -1) 59 if (wrbytes == -1)
60 { 60 {
61 if (errno == EINTR) 61 if (errno == EINTR)
diff --git a/src/gdbmclose.c b/src/gdbmclose.c
index c638183..ead9187 100644
--- a/src/gdbmclose.c
+++ b/src/gdbmclose.c
@@ -35,7 +35,7 @@ gdbm_close (GDBM_FILE dbf)
35 { 35 {
36 /* Make sure the database is all on disk. */ 36 /* Make sure the database is all on disk. */
37 if (dbf->read_write != GDBM_READER) 37 if (dbf->read_write != GDBM_READER)
38 __fsync (dbf); 38 gdbm_file_sync (dbf);
39 39
40 /* Close the file and free all malloced memory. */ 40 /* Close the file and free all malloced memory. */
41#if HAVE_MMAP 41#if HAVE_MMAP
diff --git a/src/gdbmopen.c b/src/gdbmopen.c
index 22e7ca6..53d62a4 100644
--- a/src/gdbmopen.c
+++ b/src/gdbmopen.c
@@ -429,7 +429,7 @@ gdbm_fd_open (int fd, const char *file_name, int block_size,
429 } 429 }
430 430
431 /* Wait for initial configuration to be written to disk. */ 431 /* Wait for initial configuration to be written to disk. */
432 __fsync (dbf); 432 gdbm_file_sync (dbf);
433 433
434 free (dbf->bucket); 434 free (dbf->bucket);
435 } 435 }
@@ -508,7 +508,7 @@ gdbm_fd_open (int fd, const char *file_name, int block_size,
508 } 508 }
509 509
510 /* Read the hash table directory. */ 510 /* Read the hash table directory. */
511 file_pos = __lseek (dbf, dbf->header->dir, SEEK_SET); 511 file_pos = gdbm_file_seek (dbf, dbf->header->dir, SEEK_SET);
512 if (file_pos != dbf->header->dir) 512 if (file_pos != dbf->header->dir)
513 { 513 {
514 if (!(flags & GDBM_CLOERROR)) 514 if (!(flags & GDBM_CLOERROR))
diff --git a/src/gdbmsetopt.c b/src/gdbmsetopt.c
index ca62290..69e244c 100644
--- a/src/gdbmsetopt.c
+++ b/src/gdbmsetopt.c
@@ -190,7 +190,7 @@ setopt_gdbm_setmmap (GDBM_FILE dbf, void *optval, int optlen)
190 GDBM_SET_ERRNO (dbf, GDBM_OPT_ILLEGAL, FALSE); 190 GDBM_SET_ERRNO (dbf, GDBM_OPT_ILLEGAL, FALSE);
191 return -1; 191 return -1;
192 } 192 }
193 __fsync (dbf); 193 gdbm_file_sync (dbf);
194 if (n == dbf->memory_mapping) 194 if (n == dbf->memory_mapping)
195 return 0; 195 return 0;
196 if (n) 196 if (n)
diff --git a/src/gdbmstore.c b/src/gdbmstore.c
index 6b498b2..b8a1e66 100644
--- a/src/gdbmstore.c
+++ b/src/gdbmstore.c
@@ -160,7 +160,7 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
160 dbf->bucket->h_table[elem_loc].data_size = content.dsize; 160 dbf->bucket->h_table[elem_loc].data_size = content.dsize;
161 161
162 /* Write the data to the file. */ 162 /* Write the data to the file. */
163 file_pos = __lseek (dbf, file_adr, SEEK_SET); 163 file_pos = gdbm_file_seek (dbf, file_adr, SEEK_SET);
164 if (file_pos != file_adr) 164 if (file_pos != file_adr)
165 { 165 {
166 GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR, 166 GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
diff --git a/src/gdbmsync.c b/src/gdbmsync.c
index 10fbaad..5d94cbe 100644
--- a/src/gdbmsync.c
+++ b/src/gdbmsync.c
@@ -34,6 +34,6 @@ gdbm_sync (GDBM_FILE dbf)
34 gdbm_set_errno (dbf, GDBM_NO_ERROR, FALSE); 34 gdbm_set_errno (dbf, GDBM_NO_ERROR, FALSE);
35 35
36 /* Do the sync on the file. */ 36 /* Do the sync on the file. */
37 __fsync (dbf); 37 gdbm_file_sync (dbf);
38 38
39} 39}
diff --git a/src/gdbmtool.c b/src/gdbmtool.c
index 11b6f20..dbb7510 100644
--- a/src/gdbmtool.c
+++ b/src/gdbmtool.c
@@ -227,7 +227,7 @@ _gdbm_avail_list_size (GDBM_FILE dbf, size_t min_size)
227 /* Traverse the stack. */ 227 /* Traverse the stack. */
228 while (temp) 228 while (temp)
229 { 229 {
230 if (__lseek (dbf, temp, SEEK_SET) != temp) 230 if (gdbm_file_seek (dbf, temp, SEEK_SET) != temp)
231 { 231 {
232 terror ("lseek: %s", strerror (errno)); 232 terror ("lseek: %s", strerror (errno));
233 break; 233 break;
@@ -285,7 +285,7 @@ _gdbm_print_avail_list (FILE *fp, GDBM_FILE dbf)
285 /* Print the stack. */ 285 /* Print the stack. */
286 while (temp) 286 while (temp)
287 { 287 {
288 if (__lseek (dbf, temp, SEEK_SET) != temp) 288 if (gdbm_file_seek (dbf, temp, SEEK_SET) != temp)
289 { 289 {
290 terror ("lseek: %s", strerror (errno)); 290 terror ("lseek: %s", strerror (errno));
291 break; 291 break;
diff --git a/src/proto.h b/src/proto.h
index 9592f52..563505f 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -83,4 +83,24 @@ int _gdbm_dump (GDBM_FILE dbf, FILE *fp);
83/* From recover.c */ 83/* From recover.c */
84int _gdbm_next_bucket_dir (GDBM_FILE dbf, int bucket_dir); 84int _gdbm_next_bucket_dir (GDBM_FILE dbf, int bucket_dir);
85 85
86/* I/O macros. */
87#if HAVE_MMAP
88# define gdbm_file_read(_dbf, _buf, _size) \
89 _gdbm_mapped_read(_dbf, _buf, _size)
90# define gdbm_file_write(_dbf, _buf, _size) \
91 _gdbm_mapped_write(_dbf, _buf, _size)
92# define gdbm_file_seek(_dbf, _off, _whn) \
93 _gdbm_mapped_lseek(_dbf, _off, _whn)
94# define gdbm_file_sync(_dbf) \
95 _gdbm_mapped_sync(_dbf)
96#else
97 # define gdbm_file_read(_dbf, _buf, _size)read(_dbf->desc, _buf, _size)
98 # define gdbm_file_write(_dbf, _buf, _size)write(_dbf->desc, _buf, _size)
99 # define gdbm_file_seek(_dbf, _off, _whn)lseek(_dbf->desc, _off, _whn)
100# if HAVE_FSYNC
101 # define gdbm_file_sync(_dbf) fsync(_dbf->desc)
102# else
103 # define gdbm_file_sync(_dbf) { sync(); sync(); }
104# endif
105#endif
86 106
diff --git a/src/recover.c b/src/recover.c
index 074c76f..f6859ea 100644
--- a/src/recover.c
+++ b/src/recover.c
@@ -178,7 +178,7 @@ _gdbm_finish_transfer (GDBM_FILE dbf, GDBM_FILE new_dbf,
178 #endif 178 #endif
179 179
180 /* Make sure the new database is all on disk. */ 180 /* Make sure the new database is all on disk. */
181 __fsync (dbf); 181 gdbm_file_sync (dbf);
182 182
183 /* Force the right stuff for a correct bucket cache. */ 183 /* Force the right stuff for a correct bucket cache. */
184 dbf->cache_entry = &dbf->bucket_cache[0]; 184 dbf->cache_entry = &dbf->bucket_cache[0];
diff --git a/src/systems.h b/src/systems.h
index c678573..750aa51 100644
--- a/src/systems.h
+++ b/src/systems.h
@@ -63,20 +63,4 @@
63# define STDERR_FILENO 2 63# define STDERR_FILENO 2
64#endif 64#endif
65 65
66/* I/O macros. */
67#if HAVE_MMAP
68 # define __read(_dbf, _buf, _size)_gdbm_mapped_read(_dbf, _buf, _size)
69 # define __write(_dbf, _buf, _size)_gdbm_mapped_write(_dbf, _buf, _size)
70 # define __lseek(_dbf, _off, _whn)_gdbm_mapped_lseek(_dbf, _off, _whn)
71 # define __fsync(_dbf) _gdbm_mapped_sync(_dbf)
72#else
73 # define __read(_dbf, _buf, _size)read(_dbf->desc, _buf, _size)
74 # define __write(_dbf, _buf, _size)write(_dbf->desc, _buf, _size)
75 # define __lseek(_dbf, _off, _whn)lseek(_dbf->desc, _off, _whn)
76# if HAVE_FSYNC
77 # define __fsync(_dbf) fsync(_dbf->desc)
78# else
79 # define __fsync(_dbf) { sync(); sync(); }
80# endif
81#endif
82 66
diff --git a/src/update.c b/src/update.c
index f4b8b78..e3ee717 100644
--- a/src/update.c
+++ b/src/update.c
@@ -30,7 +30,7 @@ write_header (GDBM_FILE dbf)
30 off_t file_pos;/* Return value for lseek. */ 30 off_t file_pos;/* Return value for lseek. */
31 int rc; 31 int rc;
32 32
33 file_pos = __lseek (dbf, 0L, SEEK_SET); 33 file_pos = gdbm_file_seek (dbf, 0L, SEEK_SET);
34 if (file_pos != 0) 34 if (file_pos != 0)
35 { 35 {
36 GDBM_SET_ERRNO2 (dbf, GDBM_FILE_SEEK_ERROR, TRUE, GDBM_DEBUG_STORE); 36 GDBM_SET_ERRNO2 (dbf, GDBM_FILE_SEEK_ERROR, TRUE, GDBM_DEBUG_STORE);
@@ -50,7 +50,7 @@ write_header (GDBM_FILE dbf)
50 50
51 /* Sync the file if fast_write is FALSE. */ 51 /* Sync the file if fast_write is FALSE. */
52 if (dbf->fast_write == FALSE) 52 if (dbf->fast_write == FALSE)
53 __fsync (dbf); 53 gdbm_file_sync (dbf);
54 54
55 return 0; 55 return 0;
56} 56}
@@ -94,7 +94,7 @@ _gdbm_end_update (GDBM_FILE dbf)
94 /* Write the directory. */ 94 /* Write the directory. */
95 if (dbf->directory_changed) 95 if (dbf->directory_changed)
96 { 96 {
97 file_pos = __lseek (dbf, dbf->header->dir, SEEK_SET); 97 file_pos = gdbm_file_seek (dbf, dbf->header->dir, SEEK_SET);
98 if (file_pos != dbf->header->dir) 98 if (file_pos != dbf->header->dir)
99 { 99 {
100 GDBM_SET_ERRNO2 (dbf, GDBM_FILE_SEEK_ERROR, TRUE, GDBM_DEBUG_STORE); 100 GDBM_SET_ERRNO2 (dbf, GDBM_FILE_SEEK_ERROR, TRUE, GDBM_DEBUG_STORE);
@@ -114,7 +114,7 @@ _gdbm_end_update (GDBM_FILE dbf)
114 114
115 dbf->directory_changed = FALSE; 115 dbf->directory_changed = FALSE;
116 if (!dbf->header_changed && dbf->fast_write == FALSE) 116 if (!dbf->header_changed && dbf->fast_write == FALSE)
117 __fsync (dbf); 117 gdbm_file_sync (dbf);
118 } 118 }
119 119
120 /* Final write of the header. */ 120 /* Final write of the header. */

Return to:

Send suggestions and report system problems to the System administrator.