diff options
author | Dave Barach <dave@barachs.net> | 2016-11-24 16:34:20 -0500 |
---|---|---|
committer | Dave Barach <dave@barachs.net> | 2016-11-24 16:36:01 -0500 |
commit | 23a7412bda2c14b21deda66bc5555c9ee680dec8 (patch) | |
tree | 393b2d8879417e617ae7628ffca0c2def5250eda /svm/svmdbtool.c | |
parent | 4e969f9c188e79b6b03589b91fadf33062c2152c (diff) |
String (key,value) pair serialization
Change-Id: I0e713b5ee82e246d4e5bca138683f3205e984561
Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'svm/svmdbtool.c')
-rw-r--r-- | svm/svmdbtool.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/svm/svmdbtool.c b/svm/svmdbtool.c index a98b22a1272..a0af15fcbbf 100644 --- a/svm/svmdbtool.c +++ b/svm/svmdbtool.c @@ -121,6 +121,32 @@ dump_strings (char *chroot_path) } static void +serialize_strings (char *chroot_path, char *filename) +{ + svmdb_client_t *c; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + (void) svmdb_local_serialize_strings (c, filename); + svmdb_unmap (c); +} + +static void +unserialize_strings (char *chroot_path, char *filename) +{ + svmdb_client_t *c; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + (void) svmdb_local_unserialize_strings (c, filename); + svmdb_unmap (c); +} + +static void test_vlib_vec_rate (char *chroot_path, f64 vr) { svmdb_client_t *c; @@ -344,6 +370,7 @@ main (int argc, char **argv) u8 *vbl = 0, *value = 0; char *chroot_path = 0; u8 *chroot_path_u8; + u8 *filename; uword size; f64 vr; int uid, gid, rv; @@ -467,6 +494,18 @@ main (int argc, char **argv) vec_free (s); svmdbtool_main.gid = grp->gr_gid; } + else if (unformat (&input, "serialize-strings %s", &filename)) + { + vec_add1 (filename, 0); + serialize_strings (chroot_path, (char *) filename); + parsed++; + } + else if (unformat (&input, "unserialize-strings %s", &filename)) + { + vec_add1 (filename, 0); + unserialize_strings (chroot_path, (char *) filename); + parsed++; + } else { break; |