[CRIU] [PATCH v9 3/9] external: add a new "data" option to external

Tycho Andersen tycho.andersen at canonical.com
Wed Oct 19 09:15:09 PDT 2016


We'll use this in the next patch to find the ifindex for a macvlan bridge
in the host's net ns.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 criu/external.c         | 15 +++++++++++++++
 criu/include/external.h |  2 ++
 2 files changed, 17 insertions(+)

diff --git a/criu/external.c b/criu/external.c
index c7ff072..bc6c6d4 100644
--- a/criu/external.c
+++ b/criu/external.c
@@ -27,6 +27,21 @@ bool external_lookup_id(char *id)
 	return false;
 }
 
+void *external_lookup_data(char *key)
+{
+	struct external *ext;
+	int len = strlen(key);
+
+	list_for_each_entry(ext, &opts.external, node) {
+		if (strncmp(ext->id, key, len))
+			continue;
+
+		return ext->data;
+	}
+
+	return ERR_PTR(-ENOENT);
+}
+
 char *external_lookup_by_key(char *key)
 {
 	struct external *ext;
diff --git a/criu/include/external.h b/criu/include/external.h
index 98e4258..d284b79 100644
--- a/criu/include/external.h
+++ b/criu/include/external.h
@@ -3,11 +3,13 @@
 struct external {
 	struct list_head node;
 	char *id;
+	void *data;
 };
 
 extern int add_external(char *key);
 extern bool external_lookup_id(char *id);
 extern char *external_lookup_by_key(char *id);
+extern void *external_lookup_data(char *id);
 extern int external_for_each_type(char *type, int (*cb)(struct external *, void *), void *arg);
 
 static inline char *external_val(struct external *e)
-- 
2.7.4



More information about the CRIU mailing list