[evolution-data-server/wip/camel-more-gobject] Seal CamelBlockFile properties and related structures



commit fb2b517a3b0f56d2ab6c0a1cd6d2f50b2716f522
Author: Milan Crha <mcrha redhat com>
Date:   Wed Nov 2 18:24:00 2016 +0100

    Seal CamelBlockFile properties and related structures

 src/camel/camel-block-file.c      |  428 ++++++++++++++++++++++---------------
 src/camel/camel-block-file.h      |   26 +--
 src/camel/camel-partition-table.c |  191 +++++++++--------
 src/camel/camel-partition-table.h |   16 --
 src/camel/camel-text-index.c      |   46 ++--
 5 files changed, 387 insertions(+), 320 deletions(-)
---
diff --git a/src/camel/camel-block-file.c b/src/camel/camel-block-file.c
index 92ec24b..14e68d8 100644
--- a/src/camel/camel-block-file.c
+++ b/src/camel/camel-block-file.c
@@ -44,6 +44,22 @@ struct _CamelBlockFilePrivate {
        GMutex io_lock; /* for all io ops */
 
        guint deleted : 1;
+
+       gchar version[8];
+       gchar *path;
+       CamelBlockFileFlags flags;
+
+       gint fd;
+       gsize block_size;
+
+       CamelBlockRoot *root;
+       CamelBlock *root_block;
+
+       /* make private? */
+       gint block_cache_limit;
+       gint block_cache_count;
+       GQueue block_cache;
+       GHashTable *blocks;
 };
 
 #define CAMEL_BLOCK_FILE_LOCK(kf, lock) (g_mutex_lock(&(kf)->priv->lock))
@@ -74,39 +90,39 @@ block_file_validate_root (CamelBlockFile *bs)
        struct stat st;
        gint retval;
 
-       br = bs->root;
+       br = bs->priv->root;
 
-       retval = fstat (bs->fd, &st);
+       retval = fstat (bs->priv->fd, &st);
 
-       d (printf ("Validate root: '%s'\n", bs->path));
-       d (printf ("version: %.8s (%.8s)\n", bs->root->version, bs->version));
+       d (printf ("Validate root: '%s'\n", bs->priv->path));
+       d (printf ("version: %.8s (%.8s)\n", bs->priv->root->version, bs->priv->version));
        d (printf (
                "block size: %d (%d)%s\n",
-               br->block_size, bs->block_size,
-               br->block_size != bs->block_size ? " BAD":" OK"));
+               br->block_size, bs->priv->block_size,
+               br->block_size != bs->priv->block_size ? " BAD":" OK"));
        d (printf (
                "free: %ld (%d add size < %ld)%s\n",
                (glong) br->free,
-               br->free / bs->block_size * bs->block_size,
+               br->free / bs->priv->block_size * bs->priv->block_size,
                (glong) st.st_size,
                (br->free > st.st_size) ||
-               (br->free % bs->block_size) != 0 ? " BAD":" OK"));
+               (br->free % bs->priv->block_size) != 0 ? " BAD":" OK"));
        d (printf (
                "last: %ld (%d and size: %ld)%s\n",
                (glong) br->last,
-               br->last / bs->block_size * bs->block_size,
+               br->last / bs->priv->block_size * bs->priv->block_size,
                (glong) st.st_size,
                (br->last != st.st_size) ||
-               ((br->last % bs->block_size) != 0) ? " BAD": " OK"));
+               ((br->last % bs->priv->block_size) != 0) ? " BAD": " OK"));
        d (printf (
                "flags: %s\n",
-               (br->flags & CAMEL_BLOCK_FILE_SYNC) ? "SYNC" : "unSYNC"));
+               (br->priv->flags & CAMEL_BLOCK_FILE_SYNC) ? "SYNC" : "unSYNC"));
 
        if (br->last == 0
-           || memcmp (bs->root->version, bs->version, 8) != 0
-           || br->block_size != bs->block_size
-           || (br->free % bs->block_size) != 0
-           || (br->last % bs->block_size) != 0
+           || memcmp (bs->priv->root->version, bs->priv->version, 8) != 0
+           || br->block_size != bs->priv->block_size
+           || (br->free % bs->priv->block_size) != 0
+           || (br->last % bs->priv->block_size) != 0
            || retval == -1
            || st.st_size != br->last
            || br->free > st.st_size
@@ -120,14 +136,14 @@ block_file_validate_root (CamelBlockFile *bs)
 static gint
 block_file_init_root (CamelBlockFile *bs)
 {
-       CamelBlockRoot *br = bs->root;
+       CamelBlockRoot *br = bs->priv->root;
 
-       memset (br, 0, bs->block_size);
-       memcpy (br->version, bs->version, 8);
-       br->last = bs->block_size;
+       memset (br, 0, bs->priv->block_size);
+       memcpy (br->version, bs->priv->version, 8);
+       br->last = bs->priv->block_size;
        br->flags = CAMEL_BLOCK_FILE_SYNC;
        br->free = 0;
-       br->block_size = bs->block_size;
+       br->block_size = bs->priv->block_size;
 
        return 0;
 }
@@ -138,13 +154,13 @@ block_file_finalize (GObject *object)
        CamelBlockFile *bs = CAMEL_BLOCK_FILE (object);
        CamelBlock *bl;
 
-       if (bs->root_block)
+       if (bs->priv->root_block)
                camel_block_file_sync (bs);
 
        /* remove from lru list */
        LOCK (block_file_lock);
 
-       if (bs->fd != -1)
+       if (bs->priv->fd != -1)
                block_file_count--;
 
        /* XXX This is only supposed to be in one block file list
@@ -155,26 +171,24 @@ block_file_finalize (GObject *object)
 
        UNLOCK (block_file_lock);
 
-       while ((bl = g_queue_pop_head (&bs->block_cache)) != NULL) {
+       while ((bl = g_queue_pop_head (&bs->priv->block_cache)) != NULL) {
                if (bl->refcount != 0)
                        g_warning ("Block '%u' still referenced", bl->id);
                g_free (bl);
        }
 
-       g_hash_table_destroy (bs->blocks);
+       g_hash_table_destroy (bs->priv->blocks);
 
-       if (bs->root_block)
-               camel_block_file_unref_block (bs, bs->root_block);
-       g_free (bs->path);
-       if (bs->fd != -1)
-               close (bs->fd);
+       if (bs->priv->root_block)
+               camel_block_file_unref_block (bs, bs->priv->root_block);
+       g_free (bs->priv->path);
+       if (bs->priv->fd != -1)
+               close (bs->priv->fd);
 
        g_mutex_clear (&bs->priv->io_lock);
        g_mutex_clear (&bs->priv->cache_lock);
        g_mutex_clear (&bs->priv->root_lock);
 
-       g_free (bs->priv);
-
        /* Chain up to parent's finalize() method. */
        G_OBJECT_CLASS (camel_block_file_parent_class)->finalize (object);
 }
@@ -200,15 +214,16 @@ block_hash_func (gconstpointer v)
 static void
 camel_block_file_init (CamelBlockFile *bs)
 {
-       bs->fd = -1;
-       bs->block_size = CAMEL_BLOCK_SIZE;
-       g_queue_init (&bs->block_cache);
-       bs->blocks = g_hash_table_new ((GHashFunc) block_hash_func, NULL);
+       bs->priv = G_TYPE_INSTANCE_GET_PRIVATE (bs, CAMEL_TYPE_BLOCK_FILE, CamelBlockFilePrivate);
+
+       bs->priv->fd = -1;
+       bs->priv->block_size = CAMEL_BLOCK_SIZE;
+       g_queue_init (&bs->priv->block_cache);
+       bs->priv->blocks = g_hash_table_new ((GHashFunc) block_hash_func, NULL);
        /* this cache size and the text index size have been tuned for about the best
         * with moderate memory usage.  Doubling the memory usage barely affects performance. */
-       bs->block_cache_limit = 256;
+       bs->priv->block_cache_limit = 256;
 
-       bs->priv = g_malloc0 (sizeof (*bs->priv));
        bs->priv->base = bs;
 
        g_mutex_init (&bs->priv->root_lock);
@@ -240,17 +255,17 @@ block_file_use (CamelBlockFile *bs)
 
        CAMEL_BLOCK_FILE_LOCK (bs, io_lock);
 
-       if (bs->fd != -1)
+       if (bs->priv->fd != -1)
                return 0;
        else if (bs->priv->deleted) {
                CAMEL_BLOCK_FILE_UNLOCK (bs, io_lock);
                errno = ENOENT;
                return -1;
        } else {
-               d (printf ("Turning block file online: %s\n", bs->path));
+               d (printf ("Turning block file online: %s\n", bs->priv->path));
        }
 
-       if ((bs->fd = g_open (bs->path, bs->flags | O_BINARY, 0600)) == -1) {
+       if ((bs->priv->fd = g_open (bs->priv->path, bs->priv->flags | O_BINARY, 0600)) == -1) {
                err = errno;
                CAMEL_BLOCK_FILE_UNLOCK (bs, io_lock);
                errno = err;
@@ -274,16 +289,16 @@ block_file_use (CamelBlockFile *bs)
 
                /* We never hit the current blockfile here, as its removed from the list first */
                bf = nw->base;
-               if (bf->fd != -1) {
+               if (bf->priv->fd != -1) {
                        /* Need to trylock, as any of these lock levels might be trying
                         * to lock the block_file_lock, so we need to check and abort if so */
                        if (CAMEL_BLOCK_FILE_TRYLOCK (bf, root_lock)) {
                                if (CAMEL_BLOCK_FILE_TRYLOCK (bf, cache_lock)) {
                                        if (CAMEL_BLOCK_FILE_TRYLOCK (bf, io_lock)) {
-                                               d (printf ("[%d] Turning block file offline: %s\n", 
block_file_count - 1, bf->path));
+                                               d (printf ("[%d] Turning block file offline: %s\n", 
block_file_count - 1, bf->priv->path));
                                                sync_nolock (bf);
-                                               close (bf->fd);
-                                               bf->fd = -1;
+                                               close (bf->priv->fd);
+                                               bf->priv->fd = -1;
                                                block_file_count--;
                                                CAMEL_BLOCK_FILE_UNLOCK (bf, io_lock);
                                        }
@@ -348,20 +363,20 @@ camel_block_file_new (const gchar *path,
        CamelBlockFile *bs;
 
        bs = g_object_new (CAMEL_TYPE_BLOCK_FILE, NULL);
-       memcpy (bs->version, version, 8);
-       bs->path = g_strdup (path);
-       bs->flags = flags;
+       memcpy (bs->priv->version, version, 8);
+       bs->priv->path = g_strdup (path);
+       bs->priv->flags = flags;
 
-       bs->root_block = camel_block_file_get_block (bs, 0);
-       if (bs->root_block == NULL) {
+       bs->priv->root_block = camel_block_file_get_block (bs, 0);
+       if (bs->priv->root_block == NULL) {
                g_object_unref (bs);
                return NULL;
        }
-       camel_block_file_detach_block (bs, bs->root_block);
-       bs->root = (CamelBlockRoot *) &bs->root_block->data;
+       camel_block_file_detach_block (bs, bs->priv->root_block);
+       bs->priv->root = (CamelBlockRoot *) &bs->priv->root_block->data;
 
        /* we only need these flags on first open */
-       bs->flags &= ~(O_CREAT | O_EXCL | O_TRUNC);
+       bs->priv->flags &= ~(O_CREAT | O_EXCL | O_TRUNC);
 
        class = CAMEL_BLOCK_FILE_GET_CLASS (bs);
 
@@ -370,13 +385,13 @@ camel_block_file_new (const gchar *path,
                d (printf ("Initialise root block: %.8s\n", version));
 
                class->init_root (bs);
-               camel_block_file_touch_block (bs, bs->root_block);
+               camel_block_file_touch_block (bs, bs->priv->root_block);
                if (block_file_use (bs) == -1) {
                        g_object_unref (bs);
                        return NULL;
                }
-               if (sync_block_nolock (bs, bs->root_block) == -1
-                   || ftruncate (bs->fd, bs->root->last) == -1) {
+               if (sync_block_nolock (bs, bs->priv->root_block) == -1
+                   || ftruncate (bs->priv->fd, bs->priv->root->last) == -1) {
                        block_file_unuse (bs);
                        g_object_unref (bs);
                        return NULL;
@@ -387,6 +402,72 @@ camel_block_file_new (const gchar *path,
        return bs;
 }
 
+/**
+ * camel_block_file_get_root:
+ * @bs: a #CamelBlockFile
+ *
+ * Returns: (transfer none): A #CamelBlockRoot of @bs.
+ *
+ * Since: 3.24
+ **/
+CamelBlockRoot *
+camel_block_file_get_root (CamelBlockFile *bs)
+{
+       g_return_val_if_fail (CAMEL_IS_BLOCK_FILE (bs), NULL);
+
+       return bs->priv->root;
+}
+
+/**
+ * camel_block_file_get_root_block:
+ * @bs: a #CamelBlockFile
+ *
+ * Returns: (transfer none): A root #CamelBlock of @bs.
+ *
+ * Since: 3.24
+ **/
+CamelBlock *
+camel_block_file_get_root_block (CamelBlockFile *bs)
+{
+       g_return_val_if_fail (CAMEL_IS_BLOCK_FILE (bs), NULL);
+
+       return bs->priv->root_block;
+}
+
+/**
+ * camel_block_file_get_cache_limit:
+ * @bs: a #CamelBlockFile
+ *
+ * Returns: (transfer none): Current block cache limit of @bs.
+ *
+ * Since: 3.24
+ **/
+gint
+camel_block_file_get_cache_limit (CamelBlockFile *bs)
+{
+       g_return_val_if_fail (CAMEL_IS_BLOCK_FILE (bs), -1);
+
+       return bs->priv->block_cache_limit;
+}
+
+/**
+ * camel_block_file_set_cache_limit:
+ * @bs: a #CamelBlockFile
+ * @block_cache_limit: a new block cache limit to set
+ *
+ * Sets a new block cache limit for @bs.
+ *
+ * Since: 3.24
+ **/
+void
+camel_block_file_set_cache_limit (CamelBlockFile *bs,
+                                 gint block_cache_limit)
+{
+       g_return_if_fail (CAMEL_IS_BLOCK_FILE (bs));
+
+       bs->priv->block_cache_limit = block_cache_limit;
+}
+
 gint
 camel_block_file_rename (CamelBlockFile *bs,
                          const gchar *path)
@@ -400,20 +481,20 @@ camel_block_file_rename (CamelBlockFile *bs,
 
        CAMEL_BLOCK_FILE_LOCK (bs, io_lock);
 
-       ret = g_rename (bs->path, path);
+       ret = g_rename (bs->priv->path, path);
        if (ret == -1) {
                /* Maybe the rename actually worked */
                err = errno;
                if (g_stat (path, &st) == 0
-                   && g_stat (bs->path, &st) == -1
+                   && g_stat (bs->priv->path, &st) == -1
                    && errno == ENOENT)
                        ret = 0;
                errno = err;
        }
 
        if (ret != -1) {
-               g_free (bs->path);
-               bs->path = g_strdup (path);
+               g_free (bs->priv->path);
+               bs->priv->path = g_strdup (path);
        }
 
        CAMEL_BLOCK_FILE_UNLOCK (bs, io_lock);
@@ -430,16 +511,16 @@ camel_block_file_delete (CamelBlockFile *bs)
 
        CAMEL_BLOCK_FILE_LOCK (bs, io_lock);
 
-       if (bs->fd != -1) {
+       if (bs->priv->fd != -1) {
                LOCK (block_file_lock);
                block_file_count--;
                UNLOCK (block_file_lock);
-               close (bs->fd);
-               bs->fd = -1;
+               close (bs->priv->fd);
+               bs->priv->fd = -1;
        }
 
        bs->priv->deleted = TRUE;
-       ret = g_unlink (bs->path);
+       ret = g_unlink (bs->priv->path);
 
        CAMEL_BLOCK_FILE_UNLOCK (bs, io_lock);
 
@@ -465,19 +546,19 @@ camel_block_file_new_block (CamelBlockFile *bs)
 
        CAMEL_BLOCK_FILE_LOCK (bs, root_lock);
 
-       if (bs->root->free) {
-               bl = camel_block_file_get_block (bs, bs->root->free);
+       if (bs->priv->root->free) {
+               bl = camel_block_file_get_block (bs, bs->priv->root->free);
                if (bl == NULL)
                        goto fail;
-               bs->root->free = ((camel_block_t *) bl->data)[0];
+               bs->priv->root->free = ((camel_block_t *) bl->data)[0];
        } else {
-               bl = camel_block_file_get_block (bs, bs->root->last);
+               bl = camel_block_file_get_block (bs, bs->priv->root->last);
                if (bl == NULL)
                        goto fail;
-               bs->root->last += CAMEL_BLOCK_SIZE;
+               bs->priv->root->last += CAMEL_BLOCK_SIZE;
        }
 
-       bs->root_block->flags |= CAMEL_BLOCK_DIRTY;
+       bs->priv->root_block->flags |= CAMEL_BLOCK_DIRTY;
 
        bl->flags |= CAMEL_BLOCK_DIRTY;
        memset (bl->data, 0, CAMEL_BLOCK_SIZE);
@@ -508,9 +589,9 @@ camel_block_file_free_block (CamelBlockFile *bs,
 
        CAMEL_BLOCK_FILE_LOCK (bs, root_lock);
 
-       ((camel_block_t *) bl->data)[0] = bs->root->free;
-       bs->root->free = bl->id;
-       bs->root_block->flags |= CAMEL_BLOCK_DIRTY;
+       ((camel_block_t *) bl->data)[0] = bs->priv->root->free;
+       bs->priv->root->free = bl->id;
+       bs->priv->root_block->flags |= CAMEL_BLOCK_DIRTY;
        bl->flags |= CAMEL_BLOCK_DIRTY;
        camel_block_file_unref_block (bs, bl);
 
@@ -539,16 +620,16 @@ camel_block_file_get_block (CamelBlockFile *bs,
 
        /* Sanity check: Dont allow reading of root block (except before its been read)
         * or blocks with invalid block id's */
-       if ((bs->root == NULL && id != 0)
-           || (bs->root != NULL && (id > bs->root->last || id == 0))
-           || (id % bs->block_size) != 0) {
+       if ((bs->priv->root == NULL && id != 0)
+           || (bs->priv->root != NULL && (id > bs->priv->root->last || id == 0))
+           || (id % bs->priv->block_size) != 0) {
                errno = EINVAL;
                return NULL;
        }
 
        CAMEL_BLOCK_FILE_LOCK (bs, cache_lock);
 
-       bl = g_hash_table_lookup (bs->blocks, GUINT_TO_POINTER (id));
+       bl = g_hash_table_lookup (bs->priv->blocks, GUINT_TO_POINTER (id));
 
        d (printf ("Get  block %08x: %s\n", id, bl?"cached":"must read"));
 
@@ -564,30 +645,30 @@ camel_block_file_get_block (CamelBlockFile *bs,
 
                bl = g_malloc0 (sizeof (*bl));
                bl->id = id;
-               if (lseek (bs->fd, id, SEEK_SET) == -1 ||
-                   camel_read (bs->fd, (gchar *) bl->data, CAMEL_BLOCK_SIZE, NULL, NULL) == -1) {
+               if (lseek (bs->priv->fd, id, SEEK_SET) == -1 ||
+                   camel_read (bs->priv->fd, (gchar *) bl->data, CAMEL_BLOCK_SIZE, NULL, NULL) == -1) {
                        block_file_unuse (bs);
                        CAMEL_BLOCK_FILE_UNLOCK (bs, cache_lock);
                        g_free (bl);
                        return NULL;
                }
 
-               bs->block_cache_count++;
-               g_hash_table_insert (bs->blocks, GUINT_TO_POINTER (bl->id), bl);
+               bs->priv->block_cache_count++;
+               g_hash_table_insert (bs->priv->blocks, GUINT_TO_POINTER (bl->id), bl);
 
                /* flush old blocks */
-               link = g_queue_peek_tail_link (&bs->block_cache);
+               link = g_queue_peek_tail_link (&bs->priv->block_cache);
 
-               while (link != NULL && bs->block_cache_count > bs->block_cache_limit) {
+               while (link != NULL && bs->priv->block_cache_count > bs->priv->block_cache_limit) {
                        CamelBlock *flush = link->data;
 
                        if (flush->refcount == 0) {
                                if (sync_block_nolock (bs, flush) != -1) {
-                                       g_hash_table_remove (bs->blocks, GUINT_TO_POINTER (flush->id));
+                                       g_hash_table_remove (bs->priv->blocks, GUINT_TO_POINTER (flush->id));
                                        g_queue_push_tail (&trash, link);
                                        link->data = NULL;
                                        g_free (flush);
-                                       bs->block_cache_count--;
+                                       bs->priv->block_cache_count--;
                                }
                        }
 
@@ -596,15 +677,15 @@ camel_block_file_get_block (CamelBlockFile *bs,
 
                /* Remove deleted blocks from the cache. */
                while ((link = g_queue_pop_head (&trash)) != NULL)
-                       g_queue_delete_link (&bs->block_cache, link);
+                       g_queue_delete_link (&bs->priv->block_cache, link);
 
                /* UNLOCK io_lock */
                block_file_unuse (bs);
        } else {
-               g_queue_remove (&bs->block_cache, bl);
+               g_queue_remove (&bs->priv->block_cache, bl);
        }
 
-       g_queue_push_head (&bs->block_cache, bl);
+       g_queue_push_head (&bs->priv->block_cache, bl);
        bl->refcount++;
 
        CAMEL_BLOCK_FILE_UNLOCK (bs, cache_lock);
@@ -633,8 +714,8 @@ camel_block_file_detach_block (CamelBlockFile *bs,
 
        CAMEL_BLOCK_FILE_LOCK (bs, cache_lock);
 
-       g_hash_table_remove (bs->blocks, GUINT_TO_POINTER (bl->id));
-       g_queue_remove (&bs->block_cache, bl);
+       g_hash_table_remove (bs->priv->blocks, GUINT_TO_POINTER (bl->id));
+       g_queue_remove (&bs->priv->block_cache, bl);
        bl->flags |= CAMEL_BLOCK_DETACHED;
 
        CAMEL_BLOCK_FILE_UNLOCK (bs, cache_lock);
@@ -656,8 +737,8 @@ camel_block_file_attach_block (CamelBlockFile *bs,
 
        CAMEL_BLOCK_FILE_LOCK (bs, cache_lock);
 
-       g_hash_table_insert (bs->blocks, GUINT_TO_POINTER (bl->id), bl);
-       g_queue_push_tail (&bs->block_cache, bl);
+       g_hash_table_insert (bs->priv->blocks, GUINT_TO_POINTER (bl->id), bl);
+       g_queue_push_tail (&bs->priv->block_cache, bl);
        bl->flags &= ~CAMEL_BLOCK_DETACHED;
 
        CAMEL_BLOCK_FILE_UNLOCK (bs, cache_lock);
@@ -683,11 +764,11 @@ camel_block_file_touch_block (CamelBlockFile *bs,
 
        bl->flags |= CAMEL_BLOCK_DIRTY;
 
-       if ((bs->root->flags & CAMEL_BLOCK_FILE_SYNC) && bl != bs->root_block) {
+       if ((bs->priv->root->flags & CAMEL_BLOCK_FILE_SYNC) && bl != bs->priv->root_block) {
                d (printf ("turning off sync flag\n"));
-               bs->root->flags &= ~CAMEL_BLOCK_FILE_SYNC;
-               bs->root_block->flags |= CAMEL_BLOCK_DIRTY;
-               camel_block_file_sync_block (bs, bs->root_block);
+               bs->priv->root->flags &= ~CAMEL_BLOCK_FILE_SYNC;
+               bs->priv->root_block->flags |= CAMEL_BLOCK_DIRTY;
+               camel_block_file_sync_block (bs, bs->priv->root_block);
        }
 
        CAMEL_BLOCK_FILE_UNLOCK (bs, cache_lock);
@@ -726,11 +807,11 @@ static gint
 sync_block_nolock (CamelBlockFile *bs,
                    CamelBlock *bl)
 {
-       d (printf ("Sync block %08x: %s\n", bl->id, (bl->flags & CAMEL_BLOCK_DIRTY)?"dirty":"clean"));
+       d (printf ("Sync block %08x: %s\n", bl->id, (bl->priv->flags & CAMEL_BLOCK_DIRTY)?"dirty":"clean"));
 
        if (bl->flags & CAMEL_BLOCK_DIRTY) {
-               if (lseek (bs->fd, bl->id, SEEK_SET) == -1
-                   || write (bs->fd, bl->data, CAMEL_BLOCK_SIZE) != CAMEL_BLOCK_SIZE) {
+               if (lseek (bs->priv->fd, bl->id, SEEK_SET) == -1
+                   || write (bs->priv->fd, bl->data, CAMEL_BLOCK_SIZE) != CAMEL_BLOCK_SIZE) {
                        return -1;
                }
                bl->flags &= ~CAMEL_BLOCK_DIRTY;
@@ -745,7 +826,7 @@ sync_nolock (CamelBlockFile *bs)
        GList *head, *link;
        gint work = FALSE;
 
-       head = g_queue_peek_head_link (&bs->block_cache);
+       head = g_queue_peek_head_link (&bs->priv->block_cache);
 
        for (link = head; link != NULL; link = g_list_next (link)) {
                CamelBlock *bl = link->data;
@@ -758,16 +839,16 @@ sync_nolock (CamelBlockFile *bs)
        }
 
        if (!work
-           && (bs->root_block->flags & CAMEL_BLOCK_DIRTY) == 0
-           && (bs->root->flags & CAMEL_BLOCK_FILE_SYNC) != 0)
+           && (bs->priv->root_block->flags & CAMEL_BLOCK_DIRTY) == 0
+           && (bs->priv->root->flags & CAMEL_BLOCK_FILE_SYNC) != 0)
                return 0;
 
        d (printf ("turning on sync flag\n"));
 
-       bs->root->flags |= CAMEL_BLOCK_FILE_SYNC;
-       bs->root_block->flags |= CAMEL_BLOCK_DIRTY;
+       bs->priv->root->flags |= CAMEL_BLOCK_FILE_SYNC;
+       bs->priv->root_block->flags |= CAMEL_BLOCK_DIRTY;
 
-       return sync_block_nolock (bs, bs->root_block);
+       return sync_block_nolock (bs, bs->priv->root_block);
 }
 
 /**
@@ -838,6 +919,11 @@ struct _CamelKeyFilePrivate {
        struct _CamelKeyFile *base;
        GMutex lock;
        guint deleted : 1;
+
+       FILE *fp;
+       gchar *path;
+       gint flags;
+       goffset last;
 };
 
 #define CAMEL_KEY_FILE_LOCK(kf, lock) (g_mutex_lock(&(kf)->priv->lock))
@@ -857,28 +943,26 @@ G_DEFINE_TYPE (CamelKeyFile, camel_key_file, G_TYPE_OBJECT)
 static void
 key_file_finalize (GObject *object)
 {
-       CamelKeyFile *bs = CAMEL_KEY_FILE (object);
+       CamelKeyFile *kf = CAMEL_KEY_FILE (object);
 
        LOCK (key_file_lock);
 
        /* XXX This is only supposed to be in one key file list
         *     at a time, but not sure if we can guarantee which,
         *     so try removing from both lists. */
-       g_queue_remove (&key_file_list, bs->priv);
-       g_queue_remove (&key_file_active_list, bs->priv);
+       g_queue_remove (&key_file_list, kf->priv);
+       g_queue_remove (&key_file_active_list, kf->priv);
 
-       if (bs-> fp) {
+       if (kf->priv->fp) {
                key_file_count--;
-               fclose (bs->fp);
+               fclose (kf->priv->fp);
        }
 
        UNLOCK (key_file_lock);
 
-       g_free (bs->path);
-
-       g_mutex_clear (&bs->priv->lock);
+       g_free (kf->priv->path);
 
-       g_free (bs->priv);
+       g_mutex_clear (&kf->priv->lock);
 
        /* Chain up to parent's finalize() method. */
        G_OBJECT_CLASS (camel_key_file_parent_class)->finalize (object);
@@ -889,28 +973,30 @@ camel_key_file_class_init (CamelKeyFileClass *class)
 {
        GObjectClass *object_class;
 
+       g_type_class_add_private (class, sizeof (CamelKeyFilePrivate));
+
        object_class = G_OBJECT_CLASS (class);
        object_class->finalize = key_file_finalize;
 }
 
 static void
-camel_key_file_init (CamelKeyFile *bs)
+camel_key_file_init (CamelKeyFile *kf)
 {
-       bs->priv = g_malloc0 (sizeof (*bs->priv));
-       bs->priv->base = bs;
+       kf->priv = G_TYPE_INSTANCE_GET_PRIVATE (kf, CAMEL_TYPE_KEY_FILE, CamelKeyFilePrivate);
+       kf->priv->base = kf;
 
-       g_mutex_init (&bs->priv->lock);
+       g_mutex_init (&kf->priv->lock);
 
        LOCK (key_file_lock);
-       g_queue_push_head (&key_file_list, bs->priv);
+       g_queue_push_head (&key_file_list, kf->priv);
        UNLOCK (key_file_lock);
 }
 
 /* 'use' a key file for io */
 static gint
-key_file_use (CamelKeyFile *bs)
+key_file_use (CamelKeyFile *ks)
 {
-       CamelKeyFile *bf;
+       CamelKeyFile *kf;
        gint err, fd;
        const gchar *flag;
        GList *link;
@@ -926,36 +1012,36 @@ key_file_use (CamelKeyFile *bs)
 
        /* TODO: Check header on reset? */
 
-       CAMEL_KEY_FILE_LOCK (bs, lock);
+       CAMEL_KEY_FILE_LOCK (ks, lock);
 
-       if (bs->fp != NULL)
+       if (ks->priv->fp != NULL)
                return 0;
-       else if (bs->priv->deleted) {
-               CAMEL_KEY_FILE_UNLOCK (bs, lock);
+       else if (ks->priv->deleted) {
+               CAMEL_KEY_FILE_UNLOCK (ks, lock);
                errno = ENOENT;
                return -1;
        } else {
-               d (printf ("Turning key file online: '%s'\n", bs->path));
+               d (printf ("Turning key file online: '%s'\n", bs->priv->path));
        }
 
-       if ((bs->flags & O_ACCMODE) == O_RDONLY)
+       if ((ks->priv->flags & O_ACCMODE) == O_RDONLY)
                flag = "rb";
        else
                flag = "a+b";
 
-       if ((fd = g_open (bs->path, bs->flags | O_BINARY, 0600)) == -1
-           || (bs->fp = fdopen (fd, flag)) == NULL) {
+       if ((fd = g_open (ks->priv->path, ks->priv->flags | O_BINARY, 0600)) == -1
+           || (ks->priv->fp = fdopen (fd, flag)) == NULL) {
                err = errno;
                if (fd != -1)
                        close (fd);
-               CAMEL_KEY_FILE_UNLOCK (bs, lock);
+               CAMEL_KEY_FILE_UNLOCK (ks, lock);
                errno = err;
                return -1;
        }
 
        LOCK (key_file_lock);
 
-       link = g_queue_find (&key_file_list, bs->priv);
+       link = g_queue_find (&key_file_list, ks->priv);
        if (link != NULL) {
                g_queue_unlink (&key_file_list, link);
                g_queue_push_tail_link (&key_file_active_list, link);
@@ -968,16 +1054,16 @@ key_file_use (CamelKeyFile *bs)
                struct _CamelKeyFilePrivate *nw = link->data;
 
                /* We never hit the current keyfile here, as its removed from the list first */
-               bf = nw->base;
-               if (bf->fp != NULL) {
+               kf = nw->base;
+               if (kf->priv->fp != NULL) {
                        /* Need to trylock, as any of these lock levels might be trying
                         * to lock the key_file_lock, so we need to check and abort if so */
-                       if (CAMEL_BLOCK_FILE_TRYLOCK (bf, lock)) {
-                               d (printf ("Turning key file offline: %s\n", bf->path));
-                               fclose (bf->fp);
-                               bf->fp = NULL;
+                       if (CAMEL_BLOCK_FILE_TRYLOCK (kf, lock)) {
+                               d (printf ("Turning key file offline: %s\n", kf->priv->path));
+                               fclose (kf->priv->fp);
+                               kf->priv->fp = NULL;
                                key_file_count--;
-                               CAMEL_BLOCK_FILE_UNLOCK (bf, lock);
+                               CAMEL_BLOCK_FILE_UNLOCK (kf, lock);
                        }
                }
 
@@ -990,19 +1076,19 @@ key_file_use (CamelKeyFile *bs)
 }
 
 static void
-key_file_unuse (CamelKeyFile *bs)
+key_file_unuse (CamelKeyFile *kf)
 {
        GList *link;
 
        LOCK (key_file_lock);
-       link = g_queue_find (&key_file_active_list, bs->priv);
+       link = g_queue_find (&key_file_active_list, kf->priv);
        if (link != NULL) {
                g_queue_unlink (&key_file_active_list, link);
                g_queue_push_tail_link (&key_file_list, link);
        }
        UNLOCK (key_file_lock);
 
-       CAMEL_KEY_FILE_UNLOCK (bs, lock);
+       CAMEL_KEY_FILE_UNLOCK (kf, lock);
 }
 
 /**
@@ -1029,28 +1115,28 @@ camel_key_file_new (const gchar *path,
        d (printf ("New key file '%s'\n", path));
 
        kf = g_object_new (CAMEL_TYPE_KEY_FILE, NULL);
-       kf->path = g_strdup (path);
-       kf->fp = NULL;
-       kf->flags = flags;
-       kf->last = 8;
+       kf->priv->path = g_strdup (path);
+       kf->priv->fp = NULL;
+       kf->priv->flags = flags;
+       kf->priv->last = 8;
 
        if (key_file_use (kf) == -1) {
                g_object_unref (kf);
                kf = NULL;
        } else {
-               fseek (kf->fp, 0, SEEK_END);
-               last = ftell (kf->fp);
+               fseek (kf->priv->fp, 0, SEEK_END);
+               last = ftell (kf->priv->fp);
                if (last == 0) {
-                       fwrite (version, sizeof (gchar), 8, kf->fp);
+                       fwrite (version, sizeof (gchar), 8, kf->priv->fp);
                        last += 8;
                }
-               kf->last = last;
+               kf->priv->last = last;
 
-               err = ferror (kf->fp);
+               err = ferror (kf->priv->fp);
                key_file_unuse (kf);
 
                /* we only need these flags on first open */
-               kf->flags &= ~(O_CREAT | O_EXCL | O_TRUNC);
+               kf->priv->flags &= ~(O_CREAT | O_EXCL | O_TRUNC);
 
                if (err) {
                        g_object_unref (kf);
@@ -1074,20 +1160,20 @@ camel_key_file_rename (CamelKeyFile *kf,
 
        CAMEL_KEY_FILE_LOCK (kf, lock);
 
-       ret = g_rename (kf->path, path);
+       ret = g_rename (kf->priv->path, path);
        if (ret == -1) {
                /* Maybe the rename actually worked */
                err = errno;
                if (g_stat (path, &st) == 0
-                   && g_stat (kf->path, &st) == -1
+                   && g_stat (kf->priv->path, &st) == -1
                    && errno == ENOENT)
                        ret = 0;
                errno = err;
        }
 
        if (ret != -1) {
-               g_free (kf->path);
-               kf->path = g_strdup (path);
+               g_free (kf->priv->path);
+               kf->priv->path = g_strdup (path);
        }
 
        CAMEL_KEY_FILE_UNLOCK (kf, lock);
@@ -1104,16 +1190,16 @@ camel_key_file_delete (CamelKeyFile *kf)
 
        CAMEL_KEY_FILE_LOCK (kf, lock);
 
-       if (kf->fp) {
+       if (kf->priv->fp) {
                LOCK (key_file_lock);
                key_file_count--;
                UNLOCK (key_file_lock);
-               fclose (kf->fp);
-               kf->fp = NULL;
+               fclose (kf->priv->fp);
+               kf->priv->fp = NULL;
        }
 
        kf->priv->deleted = TRUE;
-       ret = g_unlink (kf->path);
+       ret = g_unlink (kf->priv->path);
 
        CAMEL_KEY_FILE_UNLOCK (kf, lock);
 
@@ -1160,18 +1246,18 @@ camel_key_file_write (CamelKeyFile *kf,
        size = len;
 
        /* FIXME: Use io util functions? */
-       next = kf->last;
-       if (fseek (kf->fp, kf->last, SEEK_SET) == -1)
+       next = kf->priv->last;
+       if (fseek (kf->priv->fp, kf->priv->last, SEEK_SET) == -1)
                return -1;
 
-       fwrite (parent, sizeof (*parent), 1, kf->fp);
-       fwrite (&size, sizeof (size), 1, kf->fp);
-       fwrite (records, sizeof (records[0]), len, kf->fp);
+       fwrite (parent, sizeof (*parent), 1, kf->priv->fp);
+       fwrite (&size, sizeof (size), 1, kf->priv->fp);
+       fwrite (records, sizeof (records[0]), len, kf->priv->fp);
 
-       if (ferror (kf->fp)) {
-               clearerr (kf->fp);
+       if (ferror (kf->priv->fp)) {
+               clearerr (kf->priv->fp);
        } else {
-               kf->last = ftell (kf->fp);
+               kf->priv->last = ftell (kf->priv->fp);
                *parent = next;
                ret = len;
        }
@@ -1218,11 +1304,11 @@ camel_key_file_read (CamelKeyFile *kf,
        if (key_file_use (kf) == -1)
                return -1;
 
-       if (fseek (kf->fp, pos, SEEK_SET) == -1
-           || fread (&next, sizeof (next), 1, kf->fp) != 1
-           || fread (&size, sizeof (size), 1, kf->fp) != 1
+       if (fseek (kf->priv->fp, pos, SEEK_SET) == -1
+           || fread (&next, sizeof (next), 1, kf->priv->fp) != 1
+           || fread (&size, sizeof (size), 1, kf->priv->fp) != 1
            || size > 1024) {
-               clearerr (kf->fp);
+               clearerr (kf->priv->fp);
                goto fail;
        }
 
@@ -1232,7 +1318,7 @@ camel_key_file_read (CamelKeyFile *kf,
        if (records) {
                camel_key_t *keys = g_malloc (size * sizeof (camel_key_t));
 
-               if (fread (keys, sizeof (camel_key_t), size, kf->fp) != size) {
+               if (fread (keys, sizeof (camel_key_t), size, kf->priv->fp) != size) {
                        g_free (keys);
                        goto fail;
                }
diff --git a/src/camel/camel-block-file.h b/src/camel/camel-block-file.h
index 93f7101..3a3e8da 100644
--- a/src/camel/camel-block-file.h
+++ b/src/camel/camel-block-file.h
@@ -112,22 +112,6 @@ struct _CamelBlock {
 struct _CamelBlockFile {
        GObject parent;
        CamelBlockFilePrivate *priv;
-
-       gchar version[8];
-       gchar *path;
-       CamelBlockFileFlags flags;
-
-       gint fd;
-       gsize block_size;
-
-       CamelBlockRoot *root;
-       CamelBlock *root_block;
-
-       /* make private? */
-       gint block_cache_limit;
-       gint block_cache_count;
-       GQueue block_cache;
-       GHashTable *blocks;
 };
 
 struct _CamelBlockFileClass {
@@ -145,6 +129,11 @@ CamelBlockFile *camel_block_file_new               (const gchar *path,
                                                 gint flags,
                                                 const gchar version[8],
                                                 gsize block_size);
+CamelBlockRoot *camel_block_file_get_root      (CamelBlockFile *bs);
+CamelBlock *   camel_block_file_get_root_block (CamelBlockFile *bs);
+gint           camel_block_file_get_cache_limit(CamelBlockFile *bs);
+void           camel_block_file_set_cache_limit(CamelBlockFile *bs,
+                                                gint block_cache_limit);
 gint           camel_block_file_rename         (CamelBlockFile *bs,
                                                 const gchar *path);
 gint           camel_block_file_delete         (CamelBlockFile *kf);
@@ -174,11 +163,6 @@ typedef struct _CamelKeyFilePrivate CamelKeyFilePrivate;
 struct _CamelKeyFile {
        GObject parent;
        CamelKeyFilePrivate *priv;
-
-       FILE *fp;
-       gchar *path;
-       gint flags;
-       goffset last;
 };
 
 struct _CamelKeyFileClass {
diff --git a/src/camel/camel-partition-table.c b/src/camel/camel-partition-table.c
index e51c16b..1e5659b 100644
--- a/src/camel/camel-partition-table.c
+++ b/src/camel/camel-partition-table.c
@@ -49,6 +49,12 @@
 
 struct _CamelPartitionTablePrivate {
        GMutex lock;    /* for locking partition */
+
+       CamelBlockFile *blocks;
+       camel_block_t rootid;
+
+       /* we keep a list of partition blocks active at all times */
+       GQueue partition;
 };
 
 G_DEFINE_TYPE (CamelPartitionTable, camel_partition_table, G_TYPE_OBJECT)
@@ -59,14 +65,14 @@ partition_table_finalize (GObject *object)
        CamelPartitionTable *table = CAMEL_PARTITION_TABLE (object);
        CamelBlock *bl;
 
-       if (table->blocks != NULL) {
-               while ((bl = g_queue_pop_head (&table->partition)) != NULL) {
-                       camel_block_file_sync_block (table->blocks, bl);
-                       camel_block_file_unref_block (table->blocks, bl);
+       if (table->priv->blocks != NULL) {
+               while ((bl = g_queue_pop_head (&table->priv->partition)) != NULL) {
+                       camel_block_file_sync_block (table->priv->blocks, bl);
+                       camel_block_file_unref_block (table->priv->blocks, bl);
                }
-               camel_block_file_sync (table->blocks);
+               camel_block_file_sync (table->priv->blocks);
 
-               g_object_unref (table->blocks);
+               g_object_unref (table->priv->blocks);
        }
 
        g_mutex_clear (&table->priv->lock);
@@ -91,7 +97,7 @@ camel_partition_table_init (CamelPartitionTable *cpi)
 {
        cpi->priv = CAMEL_PARTITION_TABLE_GET_PRIVATE (cpi);
 
-       g_queue_init (&cpi->partition);
+       g_queue_init (&cpi->priv->partition);
        g_mutex_init (&cpi->priv->lock);
 }
 
@@ -138,7 +144,7 @@ find_partition (CamelPartitionTable *cpi,
        GList *head, *link;
 
        /* first, find the block this key might be in, then binary search the block */
-       head = g_queue_peek_head_link (&cpi->partition);
+       head = g_queue_peek_head_link (&cpi->priv->partition);
 
        for (link = head; link != NULL; link = g_list_next (link)) {
                CamelBlock *bl = link->data;
@@ -191,8 +197,8 @@ camel_partition_table_new (CamelBlockFile *bs,
        g_return_val_if_fail (CAMEL_IS_BLOCK_FILE (bs), NULL);
 
        cpi = g_object_new (CAMEL_TYPE_PARTITION_TABLE, NULL);
-       cpi->rootid = root;
-       cpi->blocks = g_object_ref (bs);
+       cpi->priv->rootid = root;
+       cpi->priv->blocks = g_object_ref (bs);
 
        /* read the partition table into memory */
        do {
@@ -205,7 +211,7 @@ camel_partition_table_new (CamelBlockFile *bs,
                d (printf ("Adding partition block, used = %d, hashid = %08x\n", ptb->used, 
ptb->partition[0].hashid));
 
                /* if we have no data, prime initial block */
-               if (ptb->used == 0 && g_queue_is_empty (&cpi->partition) && ptb->next == 0) {
+               if (ptb->used == 0 && g_queue_is_empty (&cpi->priv->partition) && ptb->next == 0) {
                        pblock = camel_block_file_new_block (bs);
                        if (pblock == NULL) {
                                camel_block_file_unref_block (bs, block);
@@ -226,7 +232,7 @@ camel_partition_table_new (CamelBlockFile *bs,
 
                root = ptb->next;
                camel_block_file_detach_block (bs, block);
-               g_queue_push_tail (&cpi->partition, block);
+               g_queue_push_tail (&cpi->priv->partition, block);
        } while (root);
 
        return cpi;
@@ -246,15 +252,15 @@ camel_partition_table_sync (CamelPartitionTable *cpi)
 
        CAMEL_PARTITION_TABLE_LOCK (cpi, lock);
 
-       if (cpi->blocks) {
+       if (cpi->priv->blocks) {
                GList *head, *link;
 
-               head = g_queue_peek_head_link (&cpi->partition);
+               head = g_queue_peek_head_link (&cpi->priv->partition);
 
                for (link = head; link != NULL; link = g_list_next (link)) {
                        CamelBlock *bl = link->data;
 
-                       ret = camel_block_file_sync_block (cpi->blocks, bl);
+                       ret = camel_block_file_sync_block (cpi->priv->blocks, bl);
                        if (ret == -1)
                                goto fail;
                }
@@ -294,7 +300,7 @@ camel_partition_table_lookup (CamelPartitionTable *cpi,
        ptblock = (CamelBlock *) ptblock_link->data;
        ptb = (CamelPartitionMapBlock *) &ptblock->data;
        block = camel_block_file_get_block (
-               cpi->blocks, ptb->partition[index].blockid);
+               cpi->priv->blocks, ptb->partition[index].blockid);
        if (block == NULL) {
                CAMEL_PARTITION_TABLE_UNLOCK (cpi, lock);
                return 0;
@@ -314,7 +320,7 @@ camel_partition_table_lookup (CamelPartitionTable *cpi,
 
        CAMEL_PARTITION_TABLE_UNLOCK (cpi, lock);
 
-       camel_block_file_unref_block (cpi->blocks, block);
+       camel_block_file_unref_block (cpi->priv->blocks, block);
 
        return keyid;
 }
@@ -346,7 +352,7 @@ camel_partition_table_remove (CamelPartitionTable *cpi,
        ptblock = (CamelBlock *) ptblock_link->data;
        ptb = (CamelPartitionMapBlock *) &ptblock->data;
        block = camel_block_file_get_block (
-               cpi->blocks, ptb->partition[index].blockid);
+               cpi->priv->blocks, ptb->partition[index].blockid);
        if (block == NULL) {
                CAMEL_PARTITION_TABLE_UNLOCK (cpi, lock);
                return FALSE;
@@ -365,14 +371,14 @@ camel_partition_table_remove (CamelPartitionTable *cpi,
                                pkb->keys[i].keyid = pkb->keys[i + 1].keyid;
                                pkb->keys[i].hashid = pkb->keys[i + 1].hashid;
                        }
-                       camel_block_file_touch_block (cpi->blocks, block);
+                       camel_block_file_touch_block (cpi->priv->blocks, block);
                        break;
                }
        }
 
        CAMEL_PARTITION_TABLE_UNLOCK (cpi, lock);
 
-       camel_block_file_unref_block (cpi->blocks, block);
+       camel_block_file_unref_block (cpi->priv->blocks, block);
 
        return TRUE;
 }
@@ -422,7 +428,7 @@ camel_partition_table_add (CamelPartitionTable *cpi,
        ptblock = (CamelBlock *) ptblock_link->data;
        ptb = (CamelPartitionMapBlock *) &ptblock->data;
        block = camel_block_file_get_block (
-               cpi->blocks, ptb->partition[index].blockid);
+               cpi->priv->blocks, ptb->partition[index].blockid);
        if (block == NULL) {
                CAMEL_PARTITION_TABLE_UNLOCK (cpi, lock);
                return -1;
@@ -445,17 +451,17 @@ camel_partition_table_add (CamelPartitionTable *cpi,
 
                if (index > 0) {
                        pblock = camel_block_file_get_block (
-                               cpi->blocks, ptb->partition[index - 1].blockid);
+                               cpi->priv->blocks, ptb->partition[index - 1].blockid);
                        if (pblock == NULL)
                                goto fail;
                        pkb = (CamelPartitionKeyBlock *) &pblock->data;
                }
                if (index < (ptb->used - 1)) {
                        nblock = camel_block_file_get_block (
-                               cpi->blocks, ptb->partition[index + 1].blockid);
+                               cpi->priv->blocks, ptb->partition[index + 1].blockid);
                        if (nblock == NULL) {
                                if (pblock)
-                                       camel_block_file_unref_block (cpi->blocks, pblock);
+                                       camel_block_file_unref_block (cpi->priv->blocks, pblock);
                                goto fail;
                        }
                        nkb = (CamelPartitionKeyBlock *) &nblock->data;
@@ -486,15 +492,15 @@ camel_partition_table_add (CamelPartitionTable *cpi,
                        /* See if we have room in the partition table for this block or need to split that 
too */
                        if (ptb->used >= G_N_ELEMENTS (ptb->partition)) {
                                /* TODO: Could check next block to see if it'll fit there first */
-                               ptnblock = camel_block_file_new_block (cpi->blocks);
+                               ptnblock = camel_block_file_new_block (cpi->priv->blocks);
                                if (ptnblock == NULL) {
                                        if (nblock)
-                                               camel_block_file_unref_block (cpi->blocks, nblock);
+                                               camel_block_file_unref_block (cpi->priv->blocks, nblock);
                                        if (pblock)
-                                               camel_block_file_unref_block (cpi->blocks, pblock);
+                                               camel_block_file_unref_block (cpi->priv->blocks, pblock);
                                        goto fail;
                                }
-                               camel_block_file_detach_block (cpi->blocks, ptnblock);
+                               camel_block_file_detach_block (cpi->priv->blocks, ptnblock);
 
                                /* split block and link on-disk, always sorted */
                                ptn = (CamelPartitionMapBlock *) &ptnblock->data;
@@ -507,18 +513,18 @@ camel_partition_table_add (CamelPartitionTable *cpi,
 
                                /* link in-memory */
                                g_queue_insert_after (
-                                       &cpi->partition,
+                                       &cpi->priv->partition,
                                        ptblock_link, ptnblock);
 
                                /* write in right order to ensure structure */
-                               camel_block_file_touch_block (cpi->blocks, ptnblock);
+                               camel_block_file_touch_block (cpi->priv->blocks, ptnblock);
 #ifdef SYNC_UPDATES
-                               camel_block_file_sync_block (cpi->blocks, ptnblock);
+                               camel_block_file_sync_block (cpi->priv->blocks, ptnblock);
 #endif
                                if (index > len) {
-                                       camel_block_file_touch_block (cpi->blocks, ptblock);
+                                       camel_block_file_touch_block (cpi->priv->blocks, ptblock);
 #ifdef SYNC_UPDATES
-                                       camel_block_file_sync_block (cpi->blocks, ptblock);
+                                       camel_block_file_sync_block (cpi->priv->blocks, ptblock);
 #endif
                                        index -= len;
                                        ptb = ptn;
@@ -527,12 +533,12 @@ camel_partition_table_add (CamelPartitionTable *cpi,
                        }
 
                        /* try get newblock before modifying existing */
-                       newblock = camel_block_file_new_block (cpi->blocks);
+                       newblock = camel_block_file_new_block (cpi->priv->blocks);
                        if (newblock == NULL) {
                                if (nblock)
-                                       camel_block_file_unref_block (cpi->blocks, nblock);
+                                       camel_block_file_unref_block (cpi->priv->blocks, nblock);
                                if (pblock)
-                                       camel_block_file_unref_block (cpi->blocks, pblock);
+                                       camel_block_file_unref_block (cpi->priv->blocks, pblock);
                                goto fail;
                        }
 
@@ -550,18 +556,18 @@ camel_partition_table_add (CamelPartitionTable *cpi,
                        ptb->partition[newindex].blockid = newblock->id;
 
                        if (nblock)
-                               camel_block_file_unref_block (cpi->blocks, nblock);
+                               camel_block_file_unref_block (cpi->priv->blocks, nblock);
                        if (pblock)
-                               camel_block_file_unref_block (cpi->blocks, pblock);
+                               camel_block_file_unref_block (cpi->priv->blocks, pblock);
                } else {
                        newkb = (CamelPartitionKeyBlock *) &newblock->data;
 
                        if (newblock == pblock) {
                                if (nblock)
-                                       camel_block_file_unref_block (cpi->blocks, nblock);
+                                       camel_block_file_unref_block (cpi->priv->blocks, nblock);
                        } else {
                                if (pblock)
-                                       camel_block_file_unref_block (cpi->blocks, pblock);
+                                       camel_block_file_unref_block (cpi->priv->blocks, pblock);
                        }
                }
 
@@ -593,16 +599,16 @@ camel_partition_table_add (CamelPartitionTable *cpi,
                        ptb->partition[newindex].hashid = partid;
                }
 
-               camel_block_file_touch_block (cpi->blocks, ptblock);
+               camel_block_file_touch_block (cpi->priv->blocks, ptblock);
 #ifdef SYNC_UPDATES
-               camel_block_file_sync_block (cpi->blocks, ptblock);
+               camel_block_file_sync_block (cpi->priv->blocks, ptblock);
 #endif
-               camel_block_file_touch_block (cpi->blocks, newblock);
-               camel_block_file_unref_block (cpi->blocks, newblock);
+               camel_block_file_touch_block (cpi->priv->blocks, newblock);
+               camel_block_file_unref_block (cpi->priv->blocks, newblock);
        }
 
-       camel_block_file_touch_block (cpi->blocks, block);
-       camel_block_file_unref_block (cpi->blocks, block);
+       camel_block_file_touch_block (cpi->priv->blocks, block);
+       camel_block_file_unref_block (cpi->priv->blocks, block);
 
        ret = 0;
 fail:
@@ -624,6 +630,13 @@ fail:
 
 struct _CamelKeyTablePrivate {
        GMutex lock;    /* for locking key */
+
+       CamelBlockFile *blocks;
+
+       camel_block_t rootid;
+
+       CamelKeyRootBlock *root;
+       CamelBlock *root_block;
 };
 
 G_DEFINE_TYPE (CamelKeyTable, camel_key_table, G_TYPE_OBJECT)
@@ -633,13 +646,13 @@ key_table_finalize (GObject *object)
 {
        CamelKeyTable *table = CAMEL_KEY_TABLE (object);
 
-       if (table->blocks) {
-               if (table->root_block) {
-                       camel_block_file_sync_block (table->blocks, table->root_block);
-                       camel_block_file_unref_block (table->blocks, table->root_block);
+       if (table->priv->blocks) {
+               if (table->priv->root_block) {
+                       camel_block_file_sync_block (table->priv->blocks, table->priv->root_block);
+                       camel_block_file_unref_block (table->priv->blocks, table->priv->root_block);
                }
-               camel_block_file_sync (table->blocks);
-               g_object_unref (table->blocks);
+               camel_block_file_sync (table->priv->blocks);
+               g_object_unref (table->priv->blocks);
        }
 
        g_mutex_clear (&table->priv->lock);
@@ -676,19 +689,19 @@ camel_key_table_new (CamelBlockFile *bs,
 
        ki = g_object_new (CAMEL_TYPE_KEY_TABLE, NULL);
 
-       ki->blocks = g_object_ref (bs);
-       ki->rootid = root;
+       ki->priv->blocks = g_object_ref (bs);
+       ki->priv->rootid = root;
 
-       ki->root_block = camel_block_file_get_block (bs, ki->rootid);
-       if (ki->root_block == NULL) {
+       ki->priv->root_block = camel_block_file_get_block (bs, ki->priv->rootid);
+       if (ki->priv->root_block == NULL) {
                g_object_unref (ki);
                ki = NULL;
        } else {
-               camel_block_file_detach_block (bs, ki->root_block);
-               ki->root = (CamelKeyRootBlock *) &ki->root_block->data;
+               camel_block_file_detach_block (bs, ki->priv->root_block);
+               ki->priv->root = (CamelKeyRootBlock *) &ki->priv->root_block->data;
 
                k (printf ("Opening key index\n"));
-               k (printf (" first %u\n last %u\n free %u\n", ki->root->first, ki->root->last, 
ki->root->free));
+               k (printf (" first %u\n last %u\n free %u\n", ki->priv->root->first, ki->priv->root->last, 
ki->priv->root->free));
        }
 
        return ki;
@@ -702,7 +715,7 @@ camel_key_table_sync (CamelKeyTable *ki)
 #ifdef SYNC_UPDATES
        return 0;
 #else
-       return camel_block_file_sync_block (ki->blocks, ki->root_block);
+       return camel_block_file_sync_block (ki->priv->blocks, ki->priv->root_block);
 #endif
 }
 
@@ -728,16 +741,16 @@ camel_key_table_add (CamelKeyTable *ki,
 
        CAMEL_KEY_TABLE_LOCK (ki, lock);
 
-       if (ki->root->last == 0) {
-               last = camel_block_file_new_block (ki->blocks);
+       if (ki->priv->root->last == 0) {
+               last = camel_block_file_new_block (ki->priv->blocks);
                if (last == NULL)
                        goto fail;
-               ki->root->last = ki->root->first = last->id;
-               camel_block_file_touch_block (ki->blocks, ki->root_block);
-               k (printf ("adding first block, first = %u\n", ki->root->first));
+               ki->priv->root->last = ki->priv->root->first = last->id;
+               camel_block_file_touch_block (ki->priv->blocks, ki->priv->root_block);
+               k (printf ("adding first block, first = %u\n", ki->priv->root->first));
        } else {
                last = camel_block_file_get_block (
-                       ki->blocks, ki->root->last);
+                       ki->priv->blocks, ki->priv->root->last);
                if (last == NULL)
                        goto fail;
        }
@@ -756,18 +769,18 @@ camel_key_table_add (CamelKeyTable *ki,
                        sizeof (kblast->u.keydata) - kblast->u.keys[kblast->used - 1].offset,
                        left, len));
                if (left < len) {
-                       next = camel_block_file_new_block (ki->blocks);
+                       next = camel_block_file_new_block (ki->priv->blocks);
                        if (next == NULL) {
-                               camel_block_file_unref_block (ki->blocks, last);
+                               camel_block_file_unref_block (ki->priv->blocks, last);
                                goto fail;
                        }
                        kbnext = (CamelKeyBlock *) &next->data;
                        kblast->next = next->id;
-                       ki->root->last = next->id;
-                       d (printf ("adding new block, first = %u, last = %u\n", ki->root->first, 
ki->root->last));
-                       camel_block_file_touch_block (ki->blocks, ki->root_block);
-                       camel_block_file_touch_block (ki->blocks, last);
-                       camel_block_file_unref_block (ki->blocks, last);
+                       ki->priv->root->last = next->id;
+                       d (printf ("adding new block, first = %u, last = %u\n", ki->priv->root->first, 
ki->priv->root->last));
+                       camel_block_file_touch_block (ki->priv->blocks, ki->priv->root_block);
+                       camel_block_file_touch_block (ki->priv->blocks, last);
+                       camel_block_file_unref_block (ki->priv->blocks, last);
                        kblast = kbnext;
                        last = next;
                }
@@ -793,11 +806,11 @@ camel_key_table_add (CamelKeyTable *ki,
                goto fail;
        }
 
-       camel_block_file_touch_block (ki->blocks, last);
-       camel_block_file_unref_block (ki->blocks, last);
+       camel_block_file_touch_block (ki->priv->blocks, last);
+       camel_block_file_unref_block (ki->priv->blocks, last);
 
 #ifdef SYNC_UPDATES
-       camel_block_file_sync_block (ki->blocks, ki->root_block);
+       camel_block_file_sync_block (ki->priv->blocks, ki->priv->root_block);
 #endif
 fail:
        CAMEL_KEY_TABLE_UNLOCK (ki, lock);
@@ -821,7 +834,7 @@ camel_key_table_set_data (CamelKeyTable *ki,
        blockid = keyid & (~(CAMEL_BLOCK_SIZE - 1));
        index = keyid & (CAMEL_BLOCK_SIZE - 1);
 
-       bl = camel_block_file_get_block (ki->blocks, blockid);
+       bl = camel_block_file_get_block (ki->priv->blocks, blockid);
        if (bl == NULL)
                return FALSE;
        kb = (CamelKeyBlock *) &bl->data;
@@ -830,12 +843,12 @@ camel_key_table_set_data (CamelKeyTable *ki,
 
        if (kb->u.keys[index].data != data) {
                kb->u.keys[index].data = data;
-               camel_block_file_touch_block (ki->blocks, bl);
+               camel_block_file_touch_block (ki->priv->blocks, bl);
        }
 
        CAMEL_KEY_TABLE_UNLOCK (ki, lock);
 
-       camel_block_file_unref_block (ki->blocks, bl);
+       camel_block_file_unref_block (ki->priv->blocks, bl);
 
        return TRUE;
 }
@@ -858,7 +871,7 @@ camel_key_table_set_flags (CamelKeyTable *ki,
        blockid = keyid & (~(CAMEL_BLOCK_SIZE - 1));
        index = keyid & (CAMEL_BLOCK_SIZE - 1);
 
-       bl = camel_block_file_get_block (ki->blocks, blockid);
+       bl = camel_block_file_get_block (ki->priv->blocks, blockid);
        if (bl == NULL)
                return FALSE;
        kb = (CamelKeyBlock *) &bl->data;
@@ -873,12 +886,12 @@ camel_key_table_set_flags (CamelKeyTable *ki,
        old = kb->u.keys[index].flags;
        if ((old & set) != (flags & set)) {
                kb->u.keys[index].flags = (old & (~set)) | (flags & set);
-               camel_block_file_touch_block (ki->blocks, bl);
+               camel_block_file_touch_block (ki->priv->blocks, bl);
        }
 
        CAMEL_KEY_TABLE_UNLOCK (ki, lock);
 
-       camel_block_file_unref_block (ki->blocks, bl);
+       camel_block_file_unref_block (ki->priv->blocks, bl);
 
        return TRUE;
 }
@@ -906,7 +919,7 @@ camel_key_table_lookup (CamelKeyTable *ki,
        blockid = keyid & (~(CAMEL_BLOCK_SIZE - 1));
        index = keyid & (CAMEL_BLOCK_SIZE - 1);
 
-       bl = camel_block_file_get_block (ki->blocks, blockid);
+       bl = camel_block_file_get_block (ki->priv->blocks, blockid);
        if (bl == NULL)
                return 0;
 
@@ -936,7 +949,7 @@ camel_key_table_lookup (CamelKeyTable *ki,
 
        CAMEL_KEY_TABLE_UNLOCK (ki, lock);
 
-       camel_block_file_unref_block (ki->blocks, bl);
+       camel_block_file_unref_block (ki->priv->blocks, bl);
 
        return blockid;
 }
@@ -966,7 +979,7 @@ camel_key_table_next (CamelKeyTable *ki,
        CAMEL_KEY_TABLE_LOCK (ki, lock);
 
        if (next == 0) {
-               next = ki->root->first;
+               next = ki->priv->root->first;
                if (next == 0) {
                        CAMEL_KEY_TABLE_UNLOCK (ki, lock);
                        return 0;
@@ -978,7 +991,7 @@ camel_key_table_next (CamelKeyTable *ki,
                blockid = next & (~(CAMEL_BLOCK_SIZE - 1));
                index = next & (CAMEL_BLOCK_SIZE - 1);
 
-               bl = camel_block_file_get_block (ki->blocks, blockid);
+               bl = camel_block_file_get_block (ki->priv->blocks, blockid);
                if (bl == NULL) {
                        CAMEL_KEY_TABLE_UNLOCK (ki, lock);
                        return 0;
@@ -990,7 +1003,7 @@ camel_key_table_next (CamelKeyTable *ki,
                if (index >= kb->used) {
                        /* FIXME: check for loops */
                        next = kb->next;
-                       camel_block_file_unref_block (ki->blocks, bl);
+                       camel_block_file_unref_block (ki->priv->blocks, bl);
                        bl = NULL;
                }
        } while (bl == NULL);
@@ -1004,7 +1017,7 @@ camel_key_table_next (CamelKeyTable *ki,
                 /*|| kb->u.keys[index-1].offset < kb->u.keydata - (gchar *)&kb->u.keys[kb->used]))) {*/
                 || kb->u.keys[index - 1].offset < sizeof (kb->u.keys[0]) * kb->used)))) {
                g_warning ("Block %u invalid scanning keys", bl->id);
-               camel_block_file_unref_block (ki->blocks, bl);
+               camel_block_file_unref_block (ki->priv->blocks, bl);
                CAMEL_KEY_TABLE_UNLOCK (ki, lock);
                return 0;
        }
@@ -1030,7 +1043,7 @@ camel_key_table_next (CamelKeyTable *ki,
 
        CAMEL_KEY_TABLE_UNLOCK (ki, lock);
 
-       camel_block_file_unref_block (ki->blocks, bl);
+       camel_block_file_unref_block (ki->priv->blocks, bl);
 
        return next;
 }
diff --git a/src/camel/camel-partition-table.h b/src/camel/camel-partition-table.h
index 4842f77..50571fa 100644
--- a/src/camel/camel-partition-table.h
+++ b/src/camel/camel-partition-table.h
@@ -103,15 +103,6 @@ struct _CamelPartitionMapBlock {
 struct _CamelPartitionTable {
        GObject parent;
        CamelPartitionTablePrivate *priv;
-
-       CamelBlockFile *blocks;
-       camel_block_t rootid;
-
-       gint (*is_key)(CamelPartitionTable *cpi, const gchar *key, camel_key_t keyid, gpointer data);
-       gpointer is_key_data;
-
-       /* we keep a list of partition blocks active at all times */
-       GQueue partition;
 };
 
 struct _CamelPartitionTableClass {
@@ -171,13 +162,6 @@ struct _CamelKeyBlock {
 struct _CamelKeyTable {
        GObject parent;
        CamelKeyTablePrivate *priv;
-
-       CamelBlockFile *blocks;
-
-       camel_block_t rootid;
-
-       CamelKeyRootBlock *root;
-       CamelBlock *root_block;
 };
 
 struct _CamelKeyTableClass {
diff --git a/src/camel/camel-text-index.c b/src/camel/camel-text-index.c
index 7807753..ba64718 100644
--- a/src/camel/camel-text-index.c
+++ b/src/camel/camel-text-index.c
@@ -234,7 +234,7 @@ text_index_add_name_to_word (CamelIndex *idx,
        CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX (idx)->priv;
        camel_key_t wordid;
        camel_block_t data;
-       struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *) p->blocks->root;
+       struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *) camel_block_file_get_root (p->blocks);
 
        w = g_hash_table_lookup (p->words, word);
        if (w == NULL) {
@@ -259,7 +259,7 @@ text_index_add_name_to_word (CamelIndex *idx,
                                return;
                        }
                        rb->words++;
-                       camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+                       camel_block_file_touch_block (p->blocks, camel_block_file_get_root_block (p->blocks));
                } else {
                        data = camel_key_table_lookup (p->word_index, wordid, NULL, NULL);
                        if (data == 0) {
@@ -290,7 +290,7 @@ text_index_add_name_to_word (CamelIndex *idx,
                        if (camel_key_file_write (p->links, &ww->data, ww->used, ww->names) != -1) {
                                io (printf ("  new data [%x]\n", ww->data));
                                rb->keys++;
-                               camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+                               camel_block_file_touch_block (p->blocks, camel_block_file_get_root_block 
(p->blocks));
                                /* if this call fails - we still point to the old data - not fatal */
                                camel_key_table_set_data (
                                        p->word_index, ww->wordid, ww->data);
@@ -318,7 +318,7 @@ text_index_add_name_to_word (CamelIndex *idx,
                        io (printf ("writing key file entry '%s' [%x]\n", w->word, w->data));
                        if (camel_key_file_write (p->links, &w->data, w->used, w->names) != -1) {
                                rb->keys++;
-                               camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+                               camel_block_file_touch_block (p->blocks, camel_block_file_get_root_block 
(p->blocks));
                                /* if this call fails - we still point to the old data - not fatal */
                                camel_key_table_set_data (
                                        p->word_index, w->wordid, w->data);
@@ -344,14 +344,14 @@ text_index_sync (CamelIndex *idx)
            || p->name_index == NULL || p->name_hash == NULL)
                return 0;
 
-       rb = (struct _CamelTextIndexRoot *) p->blocks->root;
+       rb = (struct _CamelTextIndexRoot *) camel_block_file_get_root (p->blocks);
 
        /* sync/flush word cache */
 
        CAMEL_TEXT_INDEX_LOCK (idx, lock);
 
        /* we sync, bump down the cache limits since we dont need them for reading */
-       p->blocks->block_cache_limit = 128;
+       camel_block_file_set_cache_limit (p->blocks, 128);
        /* this doesn't really need to be dropped, its only used in updates anyway */
        p->word_cache_limit = 1024;
 
@@ -361,7 +361,7 @@ text_index_sync (CamelIndex *idx)
                        if (camel_key_file_write (p->links, &ww->data, ww->used, ww->names) != -1) {
                                io (printf ("  new data [%x]\n", ww->data));
                                rb->keys++;
-                               camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+                               camel_block_file_touch_block (p->blocks, camel_block_file_get_root_block 
(p->blocks));
                                camel_key_table_set_data (
                                        p->word_index, ww->wordid, ww->data);
                        } else {
@@ -473,7 +473,7 @@ text_index_compress_nosync (CamelIndex *idx)
 
        CAMEL_TEXT_INDEX_LOCK (idx, lock);
 
-       rb = (struct _CamelTextIndexRoot *) newp->blocks->root;
+       rb = (struct _CamelTextIndexRoot *) camel_block_file_get_root (newp->blocks);
 
        rb->words = 0;
        rb->names = 0;
@@ -562,7 +562,7 @@ text_index_compress_nosync (CamelIndex *idx)
                name = NULL;
        }
 
-       camel_block_file_touch_block (newp->blocks, newp->blocks->root_block);
+       camel_block_file_touch_block (newp->blocks, camel_block_file_get_root_block (newp->blocks));
 
        if (camel_index_sync (CAMEL_INDEX (newidx)) == -1)
                goto fail;
@@ -677,13 +677,13 @@ text_index_add_name (CamelIndex *idx,
        CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
        camel_key_t keyid;
        CamelIndexName *idn;
-       struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *) p->blocks->root;
+       struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *) camel_block_file_get_root (p->blocks);
 
        CAMEL_TEXT_INDEX_LOCK (idx, lock);
 
        /* if we're adding words, up the cache limits a lot */
        if (p->word_cache_limit < 8192) {
-               p->blocks->block_cache_limit = 1024;
+               camel_block_file_set_cache_limit (p->blocks, 1024);
                p->word_cache_limit = 8192;
        }
 
@@ -703,7 +703,7 @@ text_index_add_name (CamelIndex *idx,
                rb->names++;
        }
 
-       camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+       camel_block_file_touch_block (p->blocks, camel_block_file_get_root_block (p->blocks));
 
        /* TODO: if keyid == 0, we had a failure, we should somehow flag that, but for
         * now just return a valid object but discard its results, see text_index_write_name */
@@ -759,7 +759,7 @@ text_index_delete_name (CamelIndex *idx,
 {
        CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
        camel_key_t keyid;
-       struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *) p->blocks->root;
+       struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *) camel_block_file_get_root (p->blocks);
 
        d (printf ("Delete name: %s\n", name));
 
@@ -770,7 +770,7 @@ text_index_delete_name (CamelIndex *idx,
        keyid = camel_partition_table_lookup (p->name_hash, name);
        if (keyid != 0) {
                rb->deleted++;
-               camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+               camel_block_file_touch_block (p->blocks, camel_block_file_get_root_block (p->blocks));
                camel_key_table_set_flags (p->name_index, keyid, 1, 1);
                camel_partition_table_remove (p->name_hash, name);
        }
@@ -896,7 +896,7 @@ camel_text_index_new (const gchar *path,
        if (p->links == NULL)
                goto fail;
 
-       rb = (struct _CamelTextIndexRoot *) p->blocks->root;
+       rb = (struct _CamelTextIndexRoot *) camel_block_file_get_root (p->blocks);
 
        if (rb->word_index_root == 0) {
                bl = camel_block_file_new_block (p->blocks);
@@ -906,7 +906,7 @@ camel_text_index_new (const gchar *path,
 
                rb->word_index_root = bl->id;
                camel_block_file_unref_block (p->blocks, bl);
-               camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+               camel_block_file_touch_block (p->blocks, camel_block_file_get_root_block (p->blocks));
        }
 
        if (rb->word_hash_root == 0) {
@@ -917,7 +917,7 @@ camel_text_index_new (const gchar *path,
 
                rb->word_hash_root = bl->id;
                camel_block_file_unref_block (p->blocks, bl);
-               camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+               camel_block_file_touch_block (p->blocks, camel_block_file_get_root_block (p->blocks));
        }
 
        if (rb->name_index_root == 0) {
@@ -928,7 +928,7 @@ camel_text_index_new (const gchar *path,
 
                rb->name_index_root = bl->id;
                camel_block_file_unref_block (p->blocks, bl);
-               camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+               camel_block_file_touch_block (p->blocks, camel_block_file_get_root_block (p->blocks));
        }
 
        if (rb->name_hash_root == 0) {
@@ -939,7 +939,7 @@ camel_text_index_new (const gchar *path,
 
                rb->name_hash_root = bl->id;
                camel_block_file_unref_block (p->blocks, bl);
-               camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+               camel_block_file_touch_block (p->blocks, camel_block_file_get_root_block (p->blocks));
        }
 
        p->word_index = camel_key_table_new (p->blocks, rb->word_index_root);
@@ -1064,7 +1064,7 @@ void
 camel_text_index_info (CamelTextIndex *idx)
 {
        CamelTextIndexPrivate *p = idx->priv;
-       struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *) p->blocks->root;
+       struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *) camel_block_file_get_root (p->blocks);
        gint frag;
 
        printf ("Path: '%s'\n", idx->parent.path);
@@ -1918,16 +1918,16 @@ main (gint argc,
 #if 0
        bs = camel_block_file_new ("blocks", "TESTINDX", CAMEL_BLOCK_SIZE);
 
-       root = (struct _CamelIndexRoot *) bs->root;
+       root = (struct _CamelIndexRoot *) camel_block_file_get_root (bs);
        if (root->word_root == 0) {
                keyroot = camel_block_file_new_block (bs);
                root->word_root = keyroot->id;
-               camel_block_file_touch_block (bs, bs->root_block);
+               camel_block_file_touch_block (bs, camel_block_file_get_root_block (bs));
        }
        if (root->word_hash_root == 0) {
                partroot = camel_block_file_new_block (bs);
                root->word_hash_root = partroot->id;
-               camel_block_file_touch_block (bs, bs->root_block);
+               camel_block_file_touch_block (bs, camel_block_file_get_root_block (bs));
        }
 
        ki = camel_key_table_new (bs, root->word_root);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]