libcgroup: update to 2.0.3

Upstream moved to GitHub.

Backport non GNU strerror_r patch.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2024-05-14 17:08:44 -07:00
parent 3fc2a136e8
commit 206752dd9c
4 changed files with 56 additions and 254 deletions

View File

@@ -1,12 +1,12 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=libcgroup PKG_NAME:=libcgroup
PKG_VERSION:=0.41 PKG_VERSION:=2.0.3
PKG_RELEASE:=3 PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/libcg PKG_SOURCE_URL:=https://github.com/libcgroup/libcgroup/releases/download/v$(PKG_VERSION)
PKG_HASH:=e4e38bdc7ef70645ce33740ddcca051248d56b53283c0dc6d404e17706f6fb51 PKG_HASH:=b29b5704de3d0fadf199fe4e17eeeaecba7f0dd1b85569c96eec37c7672e3026
PKG_MAINTAINER:=Daniel Danzberger <daniel@dd-wrt.com> PKG_MAINTAINER:=Daniel Danzberger <daniel@dd-wrt.com>
PKG_LICENSE:=LGPL-2.1-or-later PKG_LICENSE:=LGPL-2.1-or-later

View File

@@ -1,240 +0,0 @@
--- a/include/libcgroup/config.h
+++ b/include/libcgroup/config.h
@@ -5,12 +5,10 @@
#error "Only <libcgroup.h> should be included directly."
#endif
-#ifndef SWIG
-#include <features.h>
+#ifdef __cplusplus
+extern "C" {
#endif
-__BEGIN_DECLS
-
/**
* @defgroup group_config 5. Configuration
* @{
@@ -107,6 +105,8 @@ int cgroup_config_create_template_group(
* @}
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /*_LIBCGROUP_CONFIG_H*/
--- a/include/libcgroup/error.h
+++ b/include/libcgroup/error.h
@@ -5,12 +5,10 @@
#error "Only <libcgroup.h> should be included directly."
#endif
-#ifndef SWIG
-#include <features.h>
+#ifdef __cplusplus
+extern "C" {
#endif
-__BEGIN_DECLS
-
/**
* @defgroup group_errors 6. Error handling
* @{
@@ -99,6 +97,8 @@ int cgroup_get_last_errno(void);
* @}
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_INIT_H */
--- a/include/libcgroup/groups.h
+++ b/include/libcgroup/groups.h
@@ -6,12 +6,13 @@
#endif
#ifndef SWIG
-#include <features.h>
#include <sys/types.h>
#include <stdbool.h>
#endif
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
/**
* Flags for cgroup_delete_cgroup_ext().
@@ -577,6 +578,8 @@ char *cgroup_get_cgroup_name(struct cgro
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_GROUPS_H */
--- a/include/libcgroup/init.h
+++ b/include/libcgroup/init.h
@@ -5,12 +5,10 @@
#error "Only <libcgroup.h> should be included directly."
#endif
-#ifndef SWIG
-#include <features.h>
+#ifdef __cplusplus
+extern "C" {
#endif
-__BEGIN_DECLS
-
/**
* @defgroup group_init 1. Initialization
* @{
@@ -58,6 +56,8 @@ int cgroup_get_subsys_mount_point(const
* @}
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_INIT_H */
--- a/include/libcgroup/iterators.h
+++ b/include/libcgroup/iterators.h
@@ -8,10 +8,11 @@
#ifndef SWIG
#include <sys/types.h>
#include <stdio.h>
-#include <features.h>
#endif
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
/**
* @defgroup group_iterators 3. Iterators
@@ -423,6 +424,8 @@ int cgroup_get_subsys_mount_point_end(vo
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_ITERATORS_H */
--- a/include/libcgroup/log.h
+++ b/include/libcgroup/log.h
@@ -5,13 +5,11 @@
#error "Only <libcgroup.h> should be included directly."
#endif
-#ifndef SWIG
-#include <features.h>
-#endif
-
#include <stdarg.h>
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
/**
* @defgroup group_log 7. Logging
@@ -142,6 +140,8 @@ extern int cgroup_parse_log_level_str(co
* @}
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_LOG_H */
--- a/include/libcgroup/tasks.h
+++ b/include/libcgroup/tasks.h
@@ -8,11 +8,12 @@
#include <libcgroup/groups.h>
#ifndef SWIG
-#include <features.h>
#include <stdbool.h>
#endif
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
/** Flags for cgroup_change_cgroup_uid_gid(). */
enum cgflags {
@@ -204,6 +205,8 @@ int cgroup_register_unchanged_process(pi
* @}
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_TASKS_H */
--- a/src/daemon/cgrulesengd.h
+++ b/src/daemon/cgrulesengd.h
@@ -15,9 +15,9 @@
#ifndef _CGRULESENGD_H
#define _CGRULESENGD_H
-#include <features.h>
-
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
#include "config.h"
#include "libcgroup.h"
@@ -119,7 +119,9 @@ void cgre_flash_templates(int signum);
*/
void cgre_catch_term(int signum);
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _CGRULESENGD_H */
--- a/src/libcgroup-internal.h
+++ b/src/libcgroup-internal.h
@@ -16,7 +16,9 @@
#define __LIBCG_INTERNAL
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
#include "config.h"
#include <fts.h>
@@ -279,6 +281,8 @@ extern void cgroup_dictionary_iterator_e
*/
int cg_chmod_path(const char *path, mode_t mode, int owner_is_umask);
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif

View File

@@ -0,0 +1,51 @@
From 942ef655237b90909edf53eafd121842cdc07ce1 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 13 Jan 2023 12:44:07 -0700
Subject: [PATCH] api: Use GNU strerror_r when available
GNU strerror_r is only available in glibc, musl impelents the XSI
version which is slightly different, therefore check if GNU version is
available before using it, otherwise use the XSI compliant version.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Minor formatting change so that the line doesn't exceed 100 chars
---
configure.ac | 5 +++++
src/api.c | 9 +++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
--- a/configure.ac
+++ b/configure.ac
@@ -186,6 +186,11 @@ AC_FUNC_REALLOC
AC_FUNC_STAT
AC_CHECK_FUNCS([getmntent hasmntopt memset mkdir rmdir strdup])
+orig_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -D_GNU_SOURCE"
+AC_FUNC_STRERROR_R
+CFLAGS="$orig_CFLAGS"
+
AC_SEARCH_LIBS(
[fts_open],
[fts],
--- a/src/api.c
+++ b/src/api.c
@@ -4598,9 +4598,14 @@ const char *cgroup_strerror(int code)
{
int idx = code % ECGROUPNOTCOMPILED;
- if (code == ECGOTHER)
+ if (code == ECGOTHER) {
+#ifdef STRERROR_R_CHAR_P
return strerror_r(cgroup_get_last_errno(), errtext, MAXLEN);
-
+#else
+ return strerror_r(cgroup_get_last_errno(), errtext, sizeof (errtext)) ?
+ "unknown error" : errtext;
+#endif
+ }
if (idx >= sizeof(cgroup_strerror_codes)/sizeof(cgroup_strerror_codes[0]))
return "Invalid error code";

View File

@@ -1,9 +0,0 @@
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
AUTOMAKE_OPTIONS = foreign
-SUBDIRS = dist doc include samples scripts src tests
+SUBDIRS = dist include samples scripts src
EXTRA_DIST = README_daemon libcgroup.doxyfile README_systemd