xenstored support for in-memory rather than FS based trivial DB (needed to run on mini-OS)
PATCH 12/24 xenstored support for in-memory rather than FS based trivial DB (needed to run on mini-OS)
tdb_copy (a xen modification to tdb?) should honor the TDB_INTERNAL flag for in-memory databases.
TODO: leaks memory on error case
Signed-off-by Diego Ongaro <[email protected]>
Signed-off-by Alex Zeffertt <[email protected]>
---
tools/xenstore/tdb.c +36 -0
@@ -2103,6 +2103,42 @@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: +/* TODO (leaking memory is easier) */ +return NULL ; + } + fd =open (outfile,O_TRUNC |O_CREAT |O_WRONLY ,0640 );if (fd <0 )return NULL ;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel