summaryrefslogtreecommitdiff
path: root/metadata
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2009-06-22 16:14:51 +0200
committerAlexander Larsson <alexl@redhat.com>2009-06-23 15:10:28 +0200
commit57e0344d2e0d406dde842c0031c77ad0eddc43b3 (patch)
tree544c5ac854e217f01a734e98674276e998ac1f44 /metadata
parent86952f9372709c264a0f273022920af039902d56 (diff)
downloadgvfs-57e0344d2e0d406dde842c0031c77ad0eddc43b3.tar.gz
Implement setting stringv in MetaTree
Diffstat (limited to 'metadata')
-rw-r--r--metadata/metatree.c58
-rw-r--r--metadata/metatree.h2
2 files changed, 57 insertions, 3 deletions
diff --git a/metadata/metatree.c b/metadata/metatree.c
index 5dd9a523..c044b28c 100644
--- a/metadata/metatree.c
+++ b/metadata/metatree.c
@@ -846,6 +846,29 @@ meta_journal_entry_new_set (guint64 mtime,
return meta_journal_entry_finish (out);
}
+static GString *
+meta_journal_entry_new_setv (guint64 mtime,
+ const char *path,
+ const char *key,
+ char **value)
+{
+ GString *out;
+ int i;
+
+ out = meta_journal_entry_init (JOURNAL_OP_SETV_KEY, mtime, path);
+ append_string (out, key);
+
+ /* Pad to 32bit */
+ while (out->len % 4 != 0)
+ g_string_append_c (out, 0);
+
+ append_uint32 (out, g_strv_length ((char **)value));
+ for (i = 0; value[i] != NULL; i++)
+ append_string (out, value[i]);
+
+ return meta_journal_entry_finish (out);
+}
+
/* Call with writer lock held */
static gboolean
meta_journal_add_entry (MetaJournal *journal,
@@ -2165,9 +2188,40 @@ gboolean
meta_tree_set_stringv (MetaTree *tree,
const char *path,
const char *key,
- const char **value)
+ char **value)
{
- return FALSE;
+ GString *entry;
+ guint64 mtime;
+ gboolean res;
+
+ g_static_rw_lock_writer_lock (&metatree_lock);
+
+ if (tree->journal == NULL ||
+ !tree->journal->journal_valid)
+ {
+ res = FALSE;
+ goto out;
+ }
+
+ mtime = time (NULL);
+
+ entry = meta_journal_entry_new_setv (mtime, path, key, value);
+
+ res = TRUE;
+ retry:
+ if (!meta_journal_add_entry (tree->journal, entry))
+ {
+ if (meta_tree_flush_locked (tree))
+ goto retry;
+
+ res = FALSE;
+ }
+
+ g_string_free (entry, TRUE);
+
+ out:
+ g_static_rw_lock_writer_unlock (&metatree_lock);
+ return res;
}
static char *
diff --git a/metadata/metatree.h b/metadata/metatree.h
index 14a3eb87..f034144f 100644
--- a/metadata/metatree.h
+++ b/metadata/metatree.h
@@ -71,4 +71,4 @@ gboolean meta_tree_set_string (MetaTree *tree,
gboolean meta_tree_set_stringv (MetaTree *tree,
const char *path,
const char *key,
- const char **value);
+ char **value);