From 1a5a0344131d850b6417d0ccb198b5026c46bcc4 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 25 Jun 2014 17:34:17 +0400 Subject: [PATCH] libcriu: Add add_ext_mount_map call Signed-off-by: Pavel Emelyanov --- lib/criu.c | 35 +++++++++++++++++++++++++++++++++++ lib/criu.h | 1 + 2 files changed, 36 insertions(+) diff --git a/lib/criu.c b/lib/criu.c index 11ff59bdc..4a6ee2a5e 100644 --- a/lib/criu.c +++ b/lib/criu.c @@ -170,6 +170,41 @@ out: return -ENOMEM; } +int criu_add_ext_mount(char *key, char *val) +{ + int nr; + ExtMountMap **a, *m; + + m = malloc(sizeof(*m)); + if (!m) + goto er; + m->key = strdup(key); + if (!m->key) + goto er_n; + m->val = strdup(val); + if (!m->val) + goto er_k; + + nr = opts->n_ext_mnt + 1; + a = realloc(opts->ext_mnt, nr * sizeof(m)); + if (!a) + goto er_v; + + a[nr - 1] = m; + opts->ext_mnt = a; + opts->n_ext_mnt = nr; + return 0; + +er_v: + free(m->val); +er_k: + free(m->key); +er_n: + free(m); +er: + return -ENOMEM; +} + static CriuResp *recv_resp(int socket_fd) { unsigned char buf[CR_MAX_MSG_SIZE]; diff --git a/lib/criu.h b/lib/criu.h index 3bbad48c1..37ad07235 100644 --- a/lib/criu.h +++ b/lib/criu.h @@ -48,6 +48,7 @@ void criu_set_log_file(char *log_file); void criu_set_cpu_cap(unsigned int cap); void criu_set_root(char *root); int criu_set_exec_cmd(int argc, char *argv[]); +int criu_add_ext_mount(char *key, char *val); /* Here is a table of return values and errno's of functions * from the list down below.