Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuslan Kuprieiev <rkuprieiev@cloudlinux.com>2016-10-13 16:07:00 +0300
committerPavel Emelyanov <xemul@virtuozzo.com>2016-10-24 16:00:15 +0300
commit4f329dd4b2687d0cf233ab7a1c143b7d17a0fe7e (patch)
treed83f145f195371d7d2bd2db086f7219250ce4c27 /lib/c/criu.c
parent6178668e6a6b81e50ddb8d8b1fc735850ebb9aca (diff)
lib: add inherit_fd
It is already present in CLI and RPC, so libcriu should reflect it too. travis-ci: success for lib: add inherit_fd Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Diffstat (limited to 'lib/c/criu.c')
-rw-r--r--lib/c/criu.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/c/criu.c b/lib/c/criu.c
index 5c65d9fa4..a7df66a7a 100644
--- a/lib/c/criu.c
+++ b/lib/c/criu.c
@@ -799,6 +799,47 @@ int criu_add_irmap_path(char *path)
return criu_local_add_irmap_path(global_opts, path);
}
+int criu_local_add_inherit_fd(criu_opts *opts, int fd, char *key)
+{
+ int nr;
+ InheritFd **a, *f;
+
+ /* Inheriting is only supported with swrk mode */
+ if (opts->service_comm != CRIU_COMM_BIN)
+ return -1;
+
+ f = malloc(sizeof(*f));
+ if (!f)
+ goto er;
+ inherit_fd__init(f);
+
+ f->fd = fd;
+ f->key = strdup(key);
+ if (!f->key)
+ goto er_f;
+
+ nr = opts->rpc->n_inherit_fd + 1;
+ a = realloc(opts->rpc->inherit_fd, nr * sizeof(f));
+ if (!a)
+ goto err_k;
+
+ a[nr - 1] = f;
+ opts->rpc->inherit_fd = a;
+ opts->rpc->n_inherit_fd = nr;
+ return 0;
+err_k:
+ free(f->key);
+er_f:
+ free(f);
+er:
+ return -ENOMEM;
+}
+
+int criu_add_inherit_fd(int fd, char *key)
+{
+ return criu_local_add_inherit_fd(global_opts, fd, key);
+}
+
static CriuResp *recv_resp(int socket_fd)
{
unsigned char *buf = NULL;