]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/io.c
tdb2: restore file filling code.
[ccan] / ccan / tdb2 / io.c
index 3c24be6774a3f0a4b841809e5a20a9cfe7f417da..f326d98ba6d03e4c49e37409ae61280ae8a894bb 100644 (file)
@@ -70,6 +70,7 @@ void tdb_mmap(struct tdb_context *tdb)
 static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, bool probe)
 {
        struct stat st;
+       enum TDB_ERROR ecode;
 
        /* We can't hold pointers during this: we could unmap! */
        assert(!tdb->direct_access
@@ -89,8 +90,11 @@ static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, bool probe)
                return -1;
        }
 
-       if (tdb_lock_expand(tdb, F_RDLCK) != 0)
+       ecode = tdb_lock_expand(tdb, F_RDLCK);
+       if (ecode != TDB_SUCCESS) {
+               tdb->ecode = ecode;
                return -1;
+       }
 
        if (fstat(tdb->fd, &st) != 0) {
                tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
@@ -400,7 +404,7 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_len_t addition)
                   file isn't sparse, which would be very bad if we ran out of
                   disk. This must be done with write, not via mmap */
                memset(buf, 0x43, sizeof(buf));
-               if (0 || fill(tdb, buf, sizeof(buf), tdb->map_size, addition) == -1)
+               if (fill(tdb, buf, sizeof(buf), tdb->map_size, addition) == -1)
                        return -1;
                tdb->map_size += addition;
                tdb_mmap(tdb);