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

[Xen-changelog] [xen-unstable] xenstored: support for tdb_copy with TDB_INTERNAL



# HG changeset patch
# User Alex Zeffertt <alex.zeffertt@xxxxxxxxxxxxx>
# Date 1328812413 0
# Node ID b06f156d5d7209ea8e53cd5caf4c4e5b93768150
# Parent  d847e5c4b6c9b7cd9c7cf449dfd87ffb077a50fa
xenstored: support for tdb_copy with TDB_INTERNAL

The tdb_copy function should honor the TDB_INTERNAL flag for in-memory
databases; this is required to run in mini-os which does not use a
filesystem.

Signed-off-by: Diego Ongaro <diego.ongaro@xxxxxxxxxx>
Signed-off-by: Alex Zeffertt <alex.zeffertt@xxxxxxxxxxxxx>
Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---


diff -r d847e5c4b6c9 -r b06f156d5d72 tools/xenstore/tdb.c
--- a/tools/xenstore/tdb.c      Thu Feb 09 18:33:33 2012 +0000
+++ b/tools/xenstore/tdb.c      Thu Feb 09 18:33:33 2012 +0000
@@ -2103,6 +2103,41 @@
        int fd, saved_errno;
        TDB_CONTEXT *copy;
 
+       if (tdb->flags & TDB_INTERNAL) {
+               struct tdb_header *copydb;
+               
+               copy = talloc_zero(outfile, TDB_CONTEXT);
+               if (copy == NULL) {
+                       errno = ENOMEM;
+                       goto intfail;
+               }
+               memcpy(copy, tdb, sizeof(TDB_CONTEXT));
+
+               if (copy->name || copy->locked || copy->device || copy->inode) {
+                       fprintf(stderr, "tdb_copy assumption(s) failed\n");
+                       goto intfail;
+               }
+
+               copydb = talloc_zero_size(copy, copy->map_size);
+               if (copydb == NULL) {
+                       errno = ENOMEM;
+                       goto intfail;
+               }
+               memcpy(copydb, copy->map_ptr, copy->map_size);
+               copy->map_ptr = (char*) copydb;
+
+               if (tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0) == -1)
+                       goto intfail;
+
+               copy->next = tdbs;
+               tdbs = copy;
+
+               return copy;
+intfail:
+               talloc_free(copy);
+               return NULL;
+       }
+
        fd = open(outfile, O_TRUNC|O_CREAT|O_WRONLY, 0640);
        if (fd < 0)
                return NULL;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.