[CRIU] [PATCH 3/6] ext: Add more helpers to mess with external resources.

Pavel Emelyanov xemul at virtuozzo.com
Tue Sep 20 06:26:28 PDT 2016


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/external.c         | 19 +++++++++++++++++++
 criu/include/external.h | 15 +++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/criu/external.c b/criu/external.c
index bb7ef06..f3459df 100644
--- a/criu/external.c
+++ b/criu/external.c
@@ -40,3 +40,22 @@ char *external_lookup_by_key(char *key)
 	return NULL;
 }
 
+int external_for_each_type(char *type, int (*cb)(struct external *, void *), void *arg)
+{
+	struct external *ext;
+	int ln = strlen(type);
+	int ret = 0;
+
+	list_for_each_entry(ext, &opts.external, node) {
+		if (strncmp(ext->id, type, ln))
+			continue;
+		if (ext->id[ln] != '[')
+			continue;
+
+		ret = cb(ext, arg);
+		if (ret)
+			break;
+	}
+
+	return ret;
+}
diff --git a/criu/include/external.h b/criu/include/external.h
index d343732..98e4258 100644
--- a/criu/include/external.h
+++ b/criu/include/external.h
@@ -8,4 +8,19 @@ struct external {
 extern int add_external(char *key);
 extern bool external_lookup_id(char *id);
 extern char *external_lookup_by_key(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)
+{
+	char *aux;
+
+	aux = strchr(e->id, '[');
+	if (aux) {
+		aux = strchr(aux + 1, ']');
+		if (aux && aux[1] == ':')
+			return aux + 2;
+	}
+
+	return NULL;
+}
 #endif
-- 
2.5.0



More information about the CRIU mailing list