[CRIU] [PATCH 21/38] compel: Export version to userspace
Cyrill Gorcunov
gorcunov at openvz.org
Tue Oct 11 09:04:11 PDT 2016
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
Makefile.compel | 2 +-
compel/Makefile | 2 ++
compel/include/uapi/compel.h | 3 +++
compel/src/lib/compel.c | 17 +++++++++++++++++
compel/src/main.c | 12 ++++++++++--
5 files changed, 33 insertions(+), 3 deletions(-)
create mode 100644 compel/src/lib/compel.c
diff --git a/Makefile.compel b/Makefile.compel
index e3edd558d762..ac20d0e55d42 100644
--- a/Makefile.compel
+++ b/Makefile.compel
@@ -1,4 +1,4 @@
-COMPEL_VERSION_HEADER := compel/include/version.h
+COMPEL_VERSION_HEADER := compel/include/compel/version.h
$(COMPEL_VERSION_HEADER): $(SRC_DIR)/Makefile.versions
$(call msg-gen, $(COMPEL_VERSION_HEADER))
diff --git a/compel/Makefile b/compel/Makefile
index cf5973860a72..d419f6715788 100644
--- a/compel/Makefile
+++ b/compel/Makefile
@@ -16,6 +16,8 @@ lib-y += src/lib/handle-elf.o
host-lib-y += src/lib/handle-elf.o
lib-y += src/lib/argv.o
+lib-y += src/lib/compel.o
+
lib-y += src/lib/log.o
host-lib-y += src/lib/log.o
lib-y += src/lib/pack.o
diff --git a/compel/include/uapi/compel.h b/compel/include/uapi/compel.h
index e76e082ca1d7..e6f8d38363d8 100644
--- a/compel/include/uapi/compel.h
+++ b/compel/include/uapi/compel.h
@@ -14,6 +14,9 @@ typedef struct {
long value;
} compel_reloc_t;
+/* Report own version */
+extern void compel_version(unsigned int *major, unsigned int *minor, unsigned int *sublevel);
+
/*
* Packing objects
*/
diff --git a/compel/src/lib/compel.c b/compel/src/lib/compel.c
new file mode 100644
index 000000000000..59585bc8ce10
--- /dev/null
+++ b/compel/src/lib/compel.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "uapi/compel.h"
+
+#include "version.h"
+#include "log.h"
+
+void compel_version(unsigned int *major, unsigned int *minor, unsigned int *sublevel)
+{
+ if (major)
+ *major = COMPEL_SO_VERSION_MAJOR;
+ if (minor)
+ *minor = COMPEL_SO_VERSION_MINOR;
+ if (sublevel)
+ *sublevel = COMPEL_SO_VERSION_SUBLEVEL;
+}
diff --git a/compel/src/main.c b/compel/src/main.c
index 0858f916a1a1..49685e95d208 100644
--- a/compel/src/main.c
+++ b/compel/src/main.c
@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
},
};
- static const char short_opts[] = "a:f:o:s:p:v:r:u:hl:L:";
+ static const char short_opts[] = "a:f:o:s:p:v:r:u:hl:L:V";
static struct option long_opts[] = {
{ "arch", required_argument, 0, 'a' },
{ "file", required_argument, 0, 'f' },
@@ -132,10 +132,11 @@ int main(int argc, char *argv[])
{ "help", required_argument, 0, 'h' },
{ "library", required_argument, 0, 'l' },
{ "library-path",required_argument, 0, 'L' },
+ { "version", no_argument, 0, 'V' },
{ },
};
- if (argc < 3)
+ if (argc < 1)
goto usage;
while (1) {
@@ -189,6 +190,13 @@ int main(int argc, char *argv[])
}
libs[nlibs++] = optarg;
break;
+ case 'V':
+ printf("Version: %d.%d.%d\n",
+ COMPEL_SO_VERSION_MAJOR,
+ COMPEL_SO_VERSION_MINOR,
+ COMPEL_SO_VERSION_SUBLEVEL);
+ exit(0);
+ break;
default:
break;
}
--
2.7.4
More information about the CRIU
mailing list