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

Submitted by Tycho Andersen on Oct. 19, 2016, 4:15 p.m.

Details

Message ID 1476893715-24058-4-git-send-email-tycho.andersen@canonical.com
State Superseded
Series "Series without cover letter"
Headers show

Commit Message

Tycho Andersen Oct. 19, 2016, 4:15 p.m.
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@canonical.com>
---
 criu/external.c         | 15 +++++++++++++++
 criu/include/external.h |  2 ++
 2 files changed, 17 insertions(+)

Patch hide | download patch | download mbox

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)