]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup.so: Add a function to get the library version
authorTom Hromatka <tom.hromatka@oracle.com>
Wed, 15 Dec 2021 21:22:20 +0000 (21:22 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 3 Feb 2022 21:42:44 +0000 (14:42 -0700)
Add a function, cgroup_version(), that returns the current
version of the libcgroup library.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
configure.ac
include/libcgroup/.gitignore [new file with mode: 0644]
include/libcgroup/groups.h
include/libcgroup/init.h.in [moved from include/libcgroup/init.h with 80% similarity]
src/api.c
src/libcgroup-internal.h
src/libcgroup.map

index 2e6b0a5aaba999d452624dc83947f01f79da100e..b87ba2bd76aa056ab572393d4e050b9f08d86e56 100644 (file)
@@ -207,6 +207,7 @@ AC_CONFIG_FILES([Makefile
        scripts/init.d/cgred
        samples/Makefile
        include/Makefile
+       include/libcgroup/init.h
        doc/Makefile
        doc/man/Makefile
        dist/Makefile
diff --git a/include/libcgroup/.gitignore b/include/libcgroup/.gitignore
new file mode 100644 (file)
index 0000000..6d7255a
--- /dev/null
@@ -0,0 +1 @@
+init.h
index 0960a7d37a330bee05a4bc4f019fe2a244d4393c..c30cbb94031d49fa72aa9839c1c7fb336def2848 100644 (file)
@@ -607,6 +607,16 @@ int cgroup_convert_cgroup(struct cgroup * const out_cgroup,
                          const struct cgroup * const in_cgroup,
                          enum cg_version_t in_version);
 
+/**
+ * Get the cgroup version of a controller.  Version is set to CGROUP_UNK
+ * if the version cannot be determined.
+ *
+ * @param controller The controller of interest
+ * @param version The version of the controller
+ */
+int cgroup_get_controller_version(const char * const controller,
+               enum cg_version_t * const version);
+
 /**
  * @}
  * @}
similarity index 80%
rename from include/libcgroup/init.h
rename to include/libcgroup/init.h.in
index ea2dcc98bc60868fb22bff0461345514053df4ea..9c63e684ada6f921ab53f2bd20f09c1c75602626 100644 (file)
 extern "C" {
 #endif
 
+#define CGROUP_VER_MAJOR       @LIBRARY_VERSION_MAJOR@
+#define CGROUP_VER_MINOR       @LIBRARY_VERSION_MINOR@
+#define CGROUP_VER_RELEASE     @LIBRARY_VERSION_RELEASE@
+
+struct cgroup_library_version {
+       unsigned int major;
+       unsigned int minor;
+       unsigned int release;
+};
+
+/**
+ * Query the library version information
+ *
+ * This function returns a pointer to a populated cgroup_library_version
+ * struct.  The caller does not need to free the structure when finished.
+ *
+ */
+const struct cgroup_library_version *cgroup_version(void);
+
 /**
  * @defgroup group_init 1. Initialization
  * @{
index 353f82fdb0b849c27809596afd1533faf766f738..ae4761e53d7b99b4a5fc61582d5c2afd6b4d07db 100644 (file)
--- a/src/api.c
+++ b/src/api.c
 #include <linux/un.h>
 #include <grp.h>
 
+const struct cgroup_library_version library_version = {
+       .major = CGROUP_VER_MAJOR,
+       .minor = CGROUP_VER_MINOR,
+       .release = CGROUP_VER_RELEASE,
+};
+
 /*
  * The errno which happend the last time (have to be thread specific)
  */
@@ -5777,3 +5783,8 @@ int cgroup_get_controller_version(const char * const controller,
 
        return ECGROUPNOTEXIST;
 }
+
+const struct cgroup_library_version *cgroup_version(void)
+{
+       return &library_version;
+}
index 16a9265887911602a6500317b57260c7b7b90879..e704adaee1809b28967e7219b01509b57132156d 100644 (file)
@@ -308,16 +308,6 @@ extern void cgroup_dictionary_iterator_end(void **handle);
  */
 int cg_chmod_path(const char *path, mode_t mode, int owner_is_umask);
 
-/**
- * Get the cgroup version of a controller.  Version is set to CGROUP_UNK
- * if the version cannot be determined.
- *
- * @param controller The controller of interest
- * @param version The version of the controller
- */
-int cgroup_get_controller_version(const char * const controller,
-               enum cg_version_t * const version);
-
 /**
  * Build the path to the tasks or cgroup.procs file
  *
index 3ce7e1b00c582dba9ce9182bc6f11a88b20ed808..99788ac56f459cd965f613a00b417c1b03880084 100644 (file)
@@ -144,4 +144,5 @@ CGROUP_3.0 {
        cgroup_convert_cgroup;
        cgroup_cgxget;
        cgroup_cgxset;
+       cgroup_version;
 } CGROUP_2.0;