aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Shelton <stuart@shelton.me>2016-10-16 11:48:07 +0100
committerStuart Shelton <stuart@shelton.me>2016-10-16 13:31:15 +0100
commit525ad3a1405615e3b7dfcff253833ee11b3e658c (patch)
treee1675ed4ac0f991489cd7d1e5cceed57375ff801 /dev-libs/libcgroup
parentUpdate sys-devel/gcc-apple-4.2.1_p5666-r2 (diff)
downloadsrcshelton-525ad3a1405615e3b7dfcff253833ee11b3e658c.tar.gz
srcshelton-525ad3a1405615e3b7dfcff253833ee11b3e658c.tar.bz2
srcshelton-525ad3a1405615e3b7dfcff253833ee11b3e658c.zip
Add dev-libs/libcgroup-0.41, dev-libs/libcgroup-0.41-r4, update README.md
Diffstat (limited to 'dev-libs/libcgroup')
-rw-r--r--dev-libs/libcgroup/Manifest15
-rw-r--r--dev-libs/libcgroup/files/cgconfig.confd4
-rw-r--r--dev-libs/libcgroup/files/cgconfig.confd-r17
-rw-r--r--dev-libs/libcgroup/files/cgconfig.initd137
-rw-r--r--dev-libs/libcgroup/files/cgconfig.initd-r171
-rw-r--r--dev-libs/libcgroup/files/cgred.confd17
-rw-r--r--dev-libs/libcgroup/files/cgred.confd-r25
-rw-r--r--dev-libs/libcgroup/files/cgred.initd41
-rw-r--r--dev-libs/libcgroup/files/cgred.initd-r124
-rw-r--r--dev-libs/libcgroup/files/libcgroup-0.41-remount.patch40
-rw-r--r--dev-libs/libcgroup/files/libcgroup-0.41-reorder-headers.patch28
-rw-r--r--dev-libs/libcgroup/files/libcgroup-0.41-replace_DECLS.patch225
-rw-r--r--dev-libs/libcgroup/files/libcgroup-0.41-replace_INLCUDES.patch74
-rw-r--r--dev-libs/libcgroup/libcgroup-0.41-r4.ebuild94
-rw-r--r--dev-libs/libcgroup/libcgroup-0.41.ebuild105
15 files changed, 887 insertions, 0 deletions
diff --git a/dev-libs/libcgroup/Manifest b/dev-libs/libcgroup/Manifest
new file mode 100644
index 00000000..35113db7
--- /dev/null
+++ b/dev-libs/libcgroup/Manifest
@@ -0,0 +1,15 @@
+AUX cgconfig.confd 131 SHA256 ac52788366561ca6b79bca0e9fc9630568401b4301e386e6851fd8eb75a539ab SHA512 9bb289c20c3230414888e82be2b7a1389ac652143bcbbc746d0731c46a2f1404b4bc8154c90b59ebc53520107fe2f04c9eb5df742451887947b8a3b7a4c31f00 WHIRLPOOL 18a04c20d6d61e1416cd0f5ecc6502c6839a7cb0f873b29c7d2f799b2a0032c8e5c91ac11357829b04df3be474b8b9fe47cc958ec191e75ccdf5bce1ebabc1ea
+AUX cgconfig.confd-r1 205 SHA256 500b3f3a35eaa94b42ba6f9895498e4bfad44bbf36655782a2de3f78e9e1a23e SHA512 f5f1d0d09266417276f93434ad47116452e1ab18d736ce08e7c63f797b2d2180a490cdef1f3dd9d960c88426f1dc5b12dcf72b09de765d52d281feceffe7550d WHIRLPOOL 1d4c05b253f67ff5a8a6a927e21abc355567814d166b070416b8bddca60122e28b82cce00390b4f9b0c5472b54a18562c7e5d16eaa73e2a36d4824eb67a8ce2f
+AUX cgconfig.initd 3213 SHA256 909d5df9ba551d2f4329fef6c2d4eadbf1ccb097623991606a9149e8050a560f SHA512 b9f5adbd14b969dc77b59edef299aef3c74303c6287f103c4e05c75abeacb43bff58f908ad179df3d318c049255523b979324267a130c12def63444898e091ea WHIRLPOOL e419b019f4f7d85d67a4a7f7d45b022c6a171c4ceb6894a4ce54bff13a63b1a0c7025e85201ad1a5ad0d06af866ced3daf13112ef1d2a4b6bad4ab33f76119a5
+AUX cgconfig.initd-r1 1414 SHA256 553cc30a0fc63127c5deb2471d6b54e707971ea59c652e7e12b612b306b82a8d SHA512 871946b23ba7f640c7fc1e30bbc4a3c01051bbd486ef0b6cc2f7d554a53e2934c3b8c714b8cb59451c0c04cea7143e713746a5f573ea902f9279f9092046f0dc WHIRLPOOL 13db6fb052ce950fbaa971a8c681a9ffbb4a469eff51a1b9efc6b84c4c310febfba2b8dcb851a33a4ce7c4a8121463974ad984401fd712a44f5deb8c10c31a06
+AUX cgred.confd 485 SHA256 72c00285c1f89f3a0564418c33bd02dfbcee2ae90f540a885ef57d1ef940a04c SHA512 871b7e7df26bf6b4164d5ec04e9998b0bd3f354e75ba2306b330e382eadd38ad044f85cfaa122a5a2e600fb4f39e1a7fe7778551a05dfc3e0ae095621c965996 WHIRLPOOL d48d486aee627cd16e10493deae5419b96759f851df35444b6f27a0fdfabaaf0173770fb3ca39085524b53dc6454ca6b3b04e2cdf0e1aa840ddf8cbfe5f032f5
+AUX cgred.confd-r2 160 SHA256 52b8d2f417e21c0cd80289286483b554d6ab6bd33d2bb3f279736d869aee6d49 SHA512 5b83b2413e36184671cfd7d654fa0b06940360790aed3c235cdb8eb168c17a703c1a72654fdbf57459ac493f79fd87e90deb33e89297929ca5f681dfa80a7078 WHIRLPOOL 365e6da43baacbf0ea56d11df1a001f0e7db803f9886764b5c7835c1e21862b4bcf328b64a99b35ab76624eda7818bf36bb4c40950fc9a24c978ca882596cbe5
+AUX cgred.initd 950 SHA256 f7c7f63f63d3a3ffe6992c971a1f6faf8ce784a6d30fbdb0d49659be8ca637ce SHA512 cfa70c25c40c29d3dc1249f808f58365fa5ec09f4918edd971ac088a33a810cefa15c7ccf5b7ce75813301b104bf5fad23f752363600c10af7f1ecbb30f4aa15 WHIRLPOOL a80a6fae47f68e2abe57b688db1b9dc9d1397943f13054f96eda594dc6b8d7a6e25128961b0d72a5bbea88631e4f7f2b1d836032d8a9dd56a56e580a7a9cca02
+AUX cgred.initd-r1 507 SHA256 4f0b5bb2f8fa62205450bb033140a1e7027c99d90a3416bb3ee75e4b7b760085 SHA512 3304e048e0e08b49d416538549d9afd51d52b4edfe26058e1e0fae08fe890d6c814b9f68fe78161d0434d4b0270a700b8789c0b5f3e75aefb79d00bb0b849e35 WHIRLPOOL 1b6160e3b4b9e8a022353eccb73703c10e42962b8e121e8fe0317fe2443703854b82672efb180d61f6a3e2d591d0e8e0033bf480303dd83165f231b311725934
+AUX libcgroup-0.41-remount.patch 1341 SHA256 7b2a904684c3a4d219d3a21f79393792ab1b6ed6e3a6676c77804419f62dde30 SHA512 2574780bdee4e564064d7a8163c7c41d12fb1a38a0a9f0c5cb9b5bce1b148403a4e81e80badb4d8d080f4ccb498a5a9edef6e518d591a652970c6b3f29436ed4 WHIRLPOOL 4bc3f26ee0b4614113e2b97880e062555c345dc32be73b00bf6466c5d0b58cdba8dadcd392d4a51e9824f0fe8829acdeb77660c5ae778f1f2f9c037bd8c4d6fb
+AUX libcgroup-0.41-reorder-headers.patch 953 SHA256 92cab0cc9dc4d8728892dcea7aaba3990b51cec94dd5b8ba36f1d997f114d773 SHA512 4f8d4b49668dc0ddae373ab922422a0e933cb6c46af05d01da498c657b5a8df1ea62e644b8ac3db7e7818d33ba21c06d1902b7915f6aaf76f8f96107515433d4 WHIRLPOOL acefa8c8835a66afb6710b040452ecaa179293e8b182f59a82aba85bd6ac2c1bb448270cfe8b8098dd80b7cde1d33ca3bd65c2b4d7babf75bb0896e6101d2381
+AUX libcgroup-0.41-replace_DECLS.patch 5193 SHA256 488cad79e7d4bf8d82b8ddd695d550ff151850027980daa921ccfef5d3f4823b SHA512 c7601810e491764c30e8adfadd65e1b1b578a07af24df62cc9a7b291622d806fc196a98e01957b5acbd3bca072617bd0ff54cae200a8e6c21b5cca4d18cd45db WHIRLPOOL b02b3aa0ac7053d2bd8a359eae1ff552760e63f424594d7fa2e4130656adde861445660509a5d00a4fcc6cb49edfcaca80197d0ba8ba84575a87e0465ad9feb7
+AUX libcgroup-0.41-replace_INLCUDES.patch 3064 SHA256 eef2516f9d4b99bf724491704a078ec4f5b73636718035a56aa334a213ac08da SHA512 17c8fa471347da4973969b954f966501d54889050766dfdd225235dd4539bb4249d57e719fa7a894aadc2e0f7296d233c89c44c96291a9266c958ca3a319541b WHIRLPOOL 3da9801690571e4a66b94304ecf7c2884d739ebc789803a03d3f1f14163f47ee4e90649164d3092bc3a0aee57404805a2ca852fc2ac237df6c9a55dde6696616
+DIST libcgroup-0.41.tar.bz2 500120 SHA256 e4e38bdc7ef70645ce33740ddcca051248d56b53283c0dc6d404e17706f6fb51 SHA512 1aedb02cd2ce3bc2e2a328a247a92976ad0978ca4d3aee4eb671fbcc6bb270348efc78dcf84f27fc500f8bfb9bb57c7d6e4d429ef2bc69e4e5118b7cd895a6bd WHIRLPOOL 3941ec9362dd7da1c5d1b9eaf2b44303982a04d460ab92946201b1fe952c2f94e19950e9a08104c262eb982d8e64bcf290f1b95115aaba11d8b1457b715a3646
+EBUILD libcgroup-0.41-r4.ebuild 2339 SHA256 7f516c4e951ee0560240845cdc8789057227123bcc479f6b9cae53a8e7327e4a SHA512 f5235020627cb23a2aa15feb64b549542b04e41368d71b58b550f0962bbcaf5ec68ce524e422635a2863978a1f12de7cd7f985be6844e31494177b9c8d8b1746 WHIRLPOOL 204a41bea68b15a245dddab33b20ca185baa08da3fb916f2d662b0169918f4bfb4de77ce02cd66478310d9aeb5a670eb559575f0f2f0bc81a344baec32911f54
+EBUILD libcgroup-0.41.ebuild 2893 SHA256 1dee80639708edcf585d68ad925d4af1bc1126f51737b0e697fab1fed2c60c92 SHA512 4e548054dc11b571fe1f3215d77ded12fccd01d93c3ba94fe0dea6eca51de3be1ead74ff502a2e0a83899ef0e5329f1e2ff697a3011d8ea8c036070dab2f86e5 WHIRLPOOL c2463403a86f8a757a6a522b5122f2d6a1892bd97fd535a98d11d4489b349d4aa669af653c36c6fb426c633c229d0cd99f93ff521c5484b918b99ac62f89bd9f
diff --git a/dev-libs/libcgroup/files/cgconfig.confd b/dev-libs/libcgroup/files/cgconfig.confd
new file mode 100644
index 00000000..e41730ae
--- /dev/null
+++ b/dev-libs/libcgroup/files/cgconfig.confd
@@ -0,0 +1,4 @@
+# /etc/conf.d/cgconfig: config file for /etc/init.d/cgconfig
+
+# Configuration file location
+#CONFIG_FILE=/etc/cgroup/cgconfig.conf
diff --git a/dev-libs/libcgroup/files/cgconfig.confd-r1 b/dev-libs/libcgroup/files/cgconfig.confd-r1
new file mode 100644
index 00000000..334958ef
--- /dev/null
+++ b/dev-libs/libcgroup/files/cgconfig.confd-r1
@@ -0,0 +1,7 @@
+# /etc/conf.d/cgconfig: config file for /etc/init.d/cgconfig
+
+# Configuration file location
+CG_CONFIGFILE=/etc/cgroup/cgconfig.conf
+
+# Enable calssifying pid according to rules if necessary
+CG_CLASSIFY=No
diff --git a/dev-libs/libcgroup/files/cgconfig.initd b/dev-libs/libcgroup/files/cgconfig.initd
new file mode 100644
index 00000000..b29021ad
--- /dev/null
+++ b/dev-libs/libcgroup/files/cgconfig.initd
@@ -0,0 +1,137 @@
+#!/sbin/openrc-run
+#
+# Control Groups Configuration Startup
+#
+# This script runs the cgconfigparser utility to parse and setup
+# the control group filesystem. It uses ${CONFIG_FILE}
+# and parses the configuration specified in there.
+#
+CGCONFIGPARSER="/usr/sbin/cgconfigparser"
+CGROUP_FS="cgroup"
+CONFIG_FILE="${CONFIG_FILE:-/etc/cgroup/cgconfig.conf}"
+MOUNTS_FILE="/proc/self/mounts"
+RULES_FILE="/etc/cgroup/cgrules.conf"
+
+# Support multiple mount points
+declare -i MAX_INDEX=0
+declare -a MOUNT_POINTS MOUNT_OPTIONS
+
+parse_mounts() {
+ local device mount_point fs_type options other
+
+ while read device mount_point fs_type options other; do
+ if grep -q " ${CGROUP_FS} " <<<" ${fs_type} "; then
+ let MAX_INDEX++
+ MOUNT_POINTS[${MAX_INDEX}]="${mount_point}"
+ MOUNT_OPTIONS[${MAX_INDEX}]="${options}"
+ fi
+ done < "${MOUNTS_FILE}"
+
+ return 0
+}
+
+move_all_to_init_class() {
+ local directory
+ local -i i
+
+ for i in $( seq 1 ${MAX_INDEX} ); do
+ pushd "${MOUNT_POINTS[$i]}" >/dev/null 2>&1 || continue
+
+ if grep -qw "${MOUNT_POINTS[$i]}" "${MOUNTS_FILE}"; then
+ for directory in $( find . -depth -type d ); do
+ if [ "${directory}" != "." ]; then
+ # cat fails with "Argument list too long" error
+ sed -nu p < "${directory}"/tasks > tasks
+ rmdir "${directory}"
+ fi
+ done
+ else
+ ewarn "Resource control filesystem not mounted"
+ fi
+
+ popd >/dev/null 2>&1
+ done
+
+ return 0
+}
+
+umount_fs() {
+ local -i i
+
+ for i in $( seq 1 ${MAX_INDEX} ); do
+ umount "${MOUNT_POINTS[$i]}" >/dev/null 2>&1 && \
+ rmdir "${MOUNT_POINTS[$i]}" >/dev/null 2>&1
+ done
+}
+
+start_pre() {
+ if ! "${CGCONFIGPARSER}" -l "${CONFIG_FILE}" >/dev/null 2>&1; then
+ eend 1 "Failed to parse '${CONFIG_FILE}':"
+ eerror "$( "${CGCONFIGPARSER}" -l "${CONFIG_FILE}" 2>&1 )"
+
+ return 1
+ fi
+}
+
+start() {
+ local user controller default_cgroup mp
+ local -i i j rc=0
+
+ ebegin "Setting up CGroups"
+
+ # Mount filesystem and create cgroups
+ parse_mounts
+
+ # Find default cgroup name from rules file
+ if [ -f "${RULES_FILE}" ]; then
+ read user controller default_cgroup <<<"$( grep -m1 '^\*\s' "${RULES_FILE}" )"
+ if [ "${default_cgroup}" = '*' ]; then
+ ewarn "'${RULES_FILE}' contains invalid default cgroup '${default_cgroup}'"
+ unset default_cgroup
+ fi
+ fi
+ # Use predefined name if none was found
+ if [ -z "${default_cgroup}" ]; then
+ default_cgroup=sysdefault
+ fi
+
+ # Create a default cgroup for tasks to return back to
+ for i in $( seq 1 ${MAX_INDEX} ); do
+ mp="${MOUNT_POINTS[$i]}"
+
+ [ -n "${mp}" ] || {
+ rc=1
+ continue
+ }
+
+ # Ignore if directory already exists
+ mkdir -p "${mp}"/"${default_cgroup}"
+ find "${mp}"/ -name tasks | xargs chmod a+rw
+ chmod go-w "${mp}"/tasks
+
+ # Special rule for cpusets
+ if grep -qw cpuset <<<"${MOUNT_OPTIONS[$i]}"; then
+ cat "${mp}"/cpuset.cpus > "${mp}"/"${default_cgroup}"/cpuset.cpus
+ cat "${mp}"/cpuset.mems > "${mp}"/"${default_cgroup}"/cpuset.mems
+ fi
+
+ # Classify everything to default cgroup
+ for j in $( ps --no-headers -eL o tid ); do
+ echo "${j}" > "${mp}"/"${default_cgroup}"/tasks 2>/dev/null
+ done
+ done
+
+ eend ${rc} "cgroup setup failed"
+}
+
+stop() {
+ ebegin "Stopping cgconfig service"
+
+ parse_mounts
+
+ move_all_to_init_class
+
+ umount_fs
+
+ eend 0
+}
diff --git a/dev-libs/libcgroup/files/cgconfig.initd-r1 b/dev-libs/libcgroup/files/cgconfig.initd-r1
new file mode 100644
index 00000000..6a264bc3
--- /dev/null
+++ b/dev-libs/libcgroup/files/cgconfig.initd-r1
@@ -0,0 +1,71 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: 0615259f52f90b30ec1e902012d4b55f8610a9ed $
+
+CGCONFIGPARSER="/usr/sbin/cgconfigparser"
+CGCLASSIFY="/usr/bin/cgclassify"
+: ${CG_CONFIGFILE:=/etc/cgroup/cgconfig.conf}
+description="Control Group Configuration Service"
+
+cgconfig_umount() {
+ local ctrl eq mnt_pnt mnt_pts
+
+ while read ctrl eq mnt_pnt; do
+ case "${ctrl}" in
+ (\#*) continue ;;
+ (mount*) mnt_pts=true;;
+ (\}*) mnt_pts= ;;
+ (*)
+ [ -n "${mnt_pts}" ] || continue
+
+ mnt_pnt="${mnt_pnt%;}"
+
+ ebegin "Unmounting ${mnt_pnt}"
+ umount "${mnt_pnt}"
+ eend "$?"
+ ;;
+ esac
+ done < "${CG_CONFIGFILE}"
+}
+
+start() {
+ local l
+ local -i rc
+
+ ebegin "Setting up CGroups"
+ ${CGCONFIGPARSER} --load=${CG_CONFIGFILE} >/dev/null 2>&1
+ rc=${?}
+ if [ "0" != "${rc}" ]; then
+ eindent
+ ${CGCONFIGPARSER} --load=${CG_CONFIGFILE} 2>&1 | \
+ while read -r l; do
+ eerror "${l}"
+ done
+ eoutdent
+ fi
+ eend ${rc}
+}
+
+start_post() {
+ local -i pid
+
+ # Classify PID according to the rules if requested
+ yesno "${CG_CLASSIFY}" || return 0
+
+ if ! [ -x "${CGCLASSIFY}" ]; then
+ eerror "Cannot locate '$( basename "${CGCLASSIFY}" )' binary"
+ return 1
+ fi
+
+ ebegin "Classifying PID to CGroups"
+ for pid in $( ps --no-headers -eL o tid ); do
+ "${CGCLASSIFY}" ${pid}
+ done
+
+ eend ${?}
+}
+
+stop() {
+ cgconfig_umount
+}
diff --git a/dev-libs/libcgroup/files/cgred.confd b/dev-libs/libcgroup/files/cgred.confd
new file mode 100644
index 00000000..663ffc0c
--- /dev/null
+++ b/dev-libs/libcgroup/files/cgred.confd
@@ -0,0 +1,17 @@
+# /etc/conf.d/cgred.conf: config file for /etc/init.d/cgred
+
+# Uncomment the following line to log to specified file instead of syslog
+#LOG_FILE="/var/log/cgrulesengd.log"
+
+# Uncomment the second line to run CGroup Rules Engine in non-daemon mode
+#NODAEMON=""
+NODAEMON="--nodaemon"
+
+# Uncomment the second line to disable logging for CGroup Rules Engine
+# Uncomment the third line to enable more verbose logging.
+#LOG=""
+LOG="--nolog"
+#LOG="-v"
+
+# PID file
+PID_FILE=/var/run/cgred.pid
diff --git a/dev-libs/libcgroup/files/cgred.confd-r2 b/dev-libs/libcgroup/files/cgred.confd-r2
new file mode 100644
index 00000000..cdc7a7c5
--- /dev/null
+++ b/dev-libs/libcgroup/files/cgred.confd-r2
@@ -0,0 +1,5 @@
+# /etc/conf.d/cgred.conf: config file for /etc/init.d/cgred
+
+# Options to pass to cgrulesengd;
+# See the cgrulesengd(8) man page for more info.
+CGRED_OPTS="-n"
diff --git a/dev-libs/libcgroup/files/cgred.initd b/dev-libs/libcgroup/files/cgred.initd
new file mode 100644
index 00000000..d507e09a
--- /dev/null
+++ b/dev-libs/libcgroup/files/cgred.initd
@@ -0,0 +1,41 @@
+#!/sbin/openrc-run
+#
+# CGroups Rules Engine Daemon
+#
+# This is a daemon for automatically classifying processes into cgroups based
+# on UID/GID.
+#
+opts="${opts} reload"
+
+CGRULESENGD="/usr/sbin/cgrulesengd"
+PID_FILE=${PID_FILE:-"/var/run/cgred.pid"}
+
+depend() {
+ need cgconfig
+ use logger
+}
+
+start() {
+ local options="${NODAEMON} ${LOG}"
+ if [[ -n "${LOG_FILE}" ]]; then
+ options="${options} --log-file=${LOG_FILE}"
+ fi
+
+ ebegin "Starting CGroup Rules Engine Daemon"
+ start-stop-daemon --start --pidfile "${PID_FILE}" --make-pidfile \
+ --background --exec "${CGRULESENGD}" -- ${options} >/dev/null
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping CGroup Rules Engine Daemon"
+ start-stop-daemon --stop --pidfile "${PID_FILE}" --exec "${CGRULESENGD}"
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading CGroup Rules Engine Daemon"
+ start-stop-daemon --stop --signal USR2 --oknodo --background \
+ --pidfile "${PID_FILE}" --make-pidfile --exec "${CGRULESENGD}"
+ eend $?
+}
diff --git a/dev-libs/libcgroup/files/cgred.initd-r1 b/dev-libs/libcgroup/files/cgred.initd-r1
new file mode 100644
index 00000000..974e7a8e
--- /dev/null
+++ b/dev-libs/libcgroup/files/cgred.initd-r1
@@ -0,0 +1,24 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: 6bc7ef5df3550fcca91689fbe326c95bc45b1319 $
+
+command="/usr/sbin/cgrulesengd"
+command_args="${CGRED_OPTS}"
+command_background="1"
+pidfile="/var/run/cgred.pid"
+description="CGroups Rules Engine Daemon"
+extra_started_commands="reload"
+
+depend()
+{
+ need cgconfig
+ use logger
+}
+
+reload()
+{
+ ebegin "Reloading CGroup Rules Engine Daemon"
+ kill -USR2 $(cat "${pidfile}")
+ eend $?
+}
diff --git a/dev-libs/libcgroup/files/libcgroup-0.41-remount.patch b/dev-libs/libcgroup/files/libcgroup-0.41-remount.patch
new file mode 100644
index 00000000..8befa1df
--- /dev/null
+++ b/dev-libs/libcgroup/files/libcgroup-0.41-remount.patch
@@ -0,0 +1,40 @@
+--- src/config.c.dist 2016-10-16 12:22:38.344574293 +0100
++++ src/config.c 2016-10-16 12:36:28.752158488 +0100
+@@ -670,7 +670,7 @@ static int cgroup_config_mount_fs(void)
+
+ ret = stat(curr->mount.path, &buff);
+
+- if (ret < 0 && errno != ENOENT) {
++ if (ret < 0 && ENOENT != errno) {
+ cgroup_err("Error: cannot access %s: %s\n",
+ curr->mount.path, strerror(errno));
+ last_errno = errno;
+@@ -678,7 +678,7 @@ static int cgroup_config_mount_fs(void)
+ goto out_err;
+ }
+
+- if (errno == ENOENT) {
++ if (ENOENT == errno) {
+ ret = cg_mkdir_p(curr->mount.path);
+ if (ret) {
+ cgroup_err("Error: cannot create directory %s\n",
+@@ -702,6 +702,19 @@ static int cgroup_config_mount_fs(void)
+ ret = mount(CGROUP_FILESYSTEM, curr->mount.path,
+ CGROUP_FILESYSTEM, 0, curr->name);
+
++ if (ret < 0 && EBUSY == errno) {
++ /*
++ * If the mountpoint is already present, then
++ * we shouldn't fail... but mount returns EBUSY
++ * in three circumstances, only one of which
++ * we're concerned with. Let's try remounting
++ * the mountpoint instead, to confirm it is
++ * present...
++ */
++ ret = mount(CGROUP_FILESYSTEM, curr->mount.path,
++ CGROUP_FILESYSTEM, MS_REMOUNT, curr->name);
++ }
++
+ if (ret < 0) {
+ cgroup_err("Error: cannot mount %s to %s: %s\n",
+ curr->name, curr->mount.path,
diff --git a/dev-libs/libcgroup/files/libcgroup-0.41-reorder-headers.patch b/dev-libs/libcgroup/files/libcgroup-0.41-reorder-headers.patch
new file mode 100644
index 00000000..78a3d09a
--- /dev/null
+++ b/dev-libs/libcgroup/files/libcgroup-0.41-reorder-headers.patch
@@ -0,0 +1,28 @@
+libcgroup-internal.h: reorder the header stacking.
+
+`man 3 fts` not only specifies the headers to be included, but
+also the order. <fts.h> must be included after <sys/types.h>
+and <sys/stats.h>. On glibc and uClibc systems, an incorrect
+order does not pose a problem, but on musl this leads to undefine
+types such as dev_t and friends.
+
+Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
+
+diff -Naur libcgroup-0.41.orig/src/libcgroup-internal.h libcgroup-0.41/src/libcgroup-internal.h
+--- libcgroup-0.41.orig/src/libcgroup-internal.h 2015-07-13 21:08:26.740965713 -0400
++++ libcgroup-0.41/src/libcgroup-internal.h 2015-07-13 21:09:40.774962164 -0400
+@@ -21,12 +21,12 @@
+ #endif
+
+ #include "config.h"
+-#include <fts.h>
+ #include <libcgroup.h>
+ #include <limits.h>
+ #include <pthread.h>
+-#include <sys/stat.h>
+ #include <sys/types.h>
++#include <sys/stat.h>
++#include <fts.h>
+ #include <setjmp.h>
+
+ /* Maximum number of mount points/controllers */
diff --git a/dev-libs/libcgroup/files/libcgroup-0.41-replace_DECLS.patch b/dev-libs/libcgroup/files/libcgroup-0.41-replace_DECLS.patch
new file mode 100644
index 00000000..77010931
--- /dev/null
+++ b/dev-libs/libcgroup/files/libcgroup-0.41-replace_DECLS.patch
@@ -0,0 +1,225 @@
+Replace __BEGIN_DECLS and __END_DECLS with extern "C".
+
+The macros __BEGIN_DECLS and __END_DECLS are a GNU-ism found in
+glibc and uClibc, but not musl. We replace them by the more general
+extern "C" { ... } block exposed only if we have __cplusplus.
+
+Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
+
+diff -Naur libcgroup-0.41.orig/include/libcgroup/config.h libcgroup-0.41/include/libcgroup/config.h
+--- libcgroup-0.41.orig/include/libcgroup/config.h 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/include/libcgroup/config.h 2015-07-11 23:19:20.451977284 +0000
+@@ -9,7 +9,9 @@
+ #include <features.h>
+ #endif
+
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+
+ /**
+ * @defgroup group_config 5. Configuration
+@@ -107,6 +109,8 @@
+ * @}
+ * @}
+ */
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+
+ #endif /*_LIBCGROUP_CONFIG_H*/
+diff -Naur libcgroup-0.41.orig/include/libcgroup/error.h libcgroup-0.41/include/libcgroup/error.h
+--- libcgroup-0.41.orig/include/libcgroup/error.h 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/include/libcgroup/error.h 2015-07-11 23:19:34.253977328 +0000
+@@ -9,7 +9,9 @@
+ #include <features.h>
+ #endif
+
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+
+ /**
+ * @defgroup group_errors 6. Error handling
+@@ -99,6 +101,8 @@
+ * @}
+ * @}
+ */
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+
+ #endif /* _LIBCGROUP_INIT_H */
+diff -Naur libcgroup-0.41.orig/include/libcgroup/groups.h libcgroup-0.41/include/libcgroup/groups.h
+--- libcgroup-0.41.orig/include/libcgroup/groups.h 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/include/libcgroup/groups.h 2015-07-11 23:19:40.305977347 +0000
+@@ -11,7 +11,9 @@
+ #include <stdbool.h>
+ #endif
+
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+
+ /**
+ * Flags for cgroup_delete_cgroup_ext().
+@@ -577,6 +579,8 @@
+ */
+
+
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+
+ #endif /* _LIBCGROUP_GROUPS_H */
+diff -Naur libcgroup-0.41.orig/include/libcgroup/init.h libcgroup-0.41/include/libcgroup/init.h
+--- libcgroup-0.41.orig/include/libcgroup/init.h 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/include/libcgroup/init.h 2015-07-11 23:19:46.369977366 +0000
+@@ -9,7 +9,9 @@
+ #include <features.h>
+ #endif
+
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+
+ /**
+ * @defgroup group_init 1. Initialization
+@@ -58,6 +60,8 @@
+ * @}
+ * @}
+ */
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+
+ #endif /* _LIBCGROUP_INIT_H */
+diff -Naur libcgroup-0.41.orig/include/libcgroup/iterators.h libcgroup-0.41/include/libcgroup/iterators.h
+--- libcgroup-0.41.orig/include/libcgroup/iterators.h 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/include/libcgroup/iterators.h 2015-07-11 23:19:53.353977388 +0000
+@@ -11,7 +11,9 @@
+ #include <features.h>
+ #endif
+
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+
+ /**
+ * @defgroup group_iterators 3. Iterators
+@@ -423,6 +425,8 @@
+ * @}
+ */
+
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+
+ #endif /* _LIBCGROUP_ITERATORS_H */
+diff -Naur libcgroup-0.41.orig/include/libcgroup/log.h libcgroup-0.41/include/libcgroup/log.h
+--- libcgroup-0.41.orig/include/libcgroup/log.h 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/include/libcgroup/log.h 2015-07-11 23:19:58.922977406 +0000
+@@ -11,7 +11,9 @@
+
+ #include <stdarg.h>
+
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+
+ /**
+ * @defgroup group_log 7. Logging
+@@ -142,6 +144,8 @@
+ * @}
+ * @}
+ */
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+
+ #endif /* _LIBCGROUP_LOG_H */
+diff -Naur libcgroup-0.41.orig/include/libcgroup/tasks.h libcgroup-0.41/include/libcgroup/tasks.h
+--- libcgroup-0.41.orig/include/libcgroup/tasks.h 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/include/libcgroup/tasks.h 2015-07-11 23:20:03.329977420 +0000
+@@ -12,7 +12,9 @@
+ #include <stdbool.h>
+ #endif
+
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+
+ /** Flags for cgroup_change_cgroup_uid_gid(). */
+ enum cgflags {
+@@ -204,6 +206,8 @@
+ * @}
+ * @}
+ */
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+
+ #endif /* _LIBCGROUP_TASKS_H */
+diff -Naur libcgroup-0.41.orig/src/daemon/cgrulesengd.h libcgroup-0.41/src/daemon/cgrulesengd.h
+--- libcgroup-0.41.orig/src/daemon/cgrulesengd.h 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/src/daemon/cgrulesengd.h 2015-07-11 23:20:34.282977519 +0000
+@@ -17,7 +17,9 @@
+
+ #include <features.h>
+
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+
+ #include "config.h"
+ #include "libcgroup.h"
+@@ -119,7 +121,9 @@
+ */
+ void cgre_catch_term(int signum);
+
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+
+ #endif /* _CGRULESENGD_H */
+
+diff -Naur libcgroup-0.41.orig/src/libcgroup-internal.h libcgroup-0.41/src/libcgroup-internal.h
+--- libcgroup-0.41.orig/src/libcgroup-internal.h 2015-07-11 23:16:37.497976764 +0000
++++ libcgroup-0.41/src/libcgroup-internal.h 2015-07-11 23:20:22.299977481 +0000
+@@ -16,7 +16,9 @@
+
+ #define __LIBCG_INTERNAL
+
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+
+ #include "config.h"
+ #include <fts.h>
+@@ -279,6 +281,8 @@
+ */
+ int cg_chmod_path(const char *path, mode_t mode, int owner_is_umask);
+
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+
+ #endif
diff --git a/dev-libs/libcgroup/files/libcgroup-0.41-replace_INLCUDES.patch b/dev-libs/libcgroup/files/libcgroup-0.41-replace_INLCUDES.patch
new file mode 100644
index 00000000..191de87d
--- /dev/null
+++ b/dev-libs/libcgroup/files/libcgroup-0.41-replace_INLCUDES.patch
@@ -0,0 +1,74 @@
+Replace INCLUDES with AM_CPPFLAGS in Makefile.am
+
+We replace the deprecated INCLUDES with AM_CPPFLAGS in all
+Makefile.am's.
+
+Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
+
+diff -Naur libcgroup-0.41.orig/src/Makefile.am libcgroup-0.41/src/Makefile.am
+--- libcgroup-0.41.orig/src/Makefile.am 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/src/Makefile.am 2015-07-13 14:36:38.922428040 +0000
+@@ -9,7 +9,7 @@
+
+ CLEANFILES = lex.c parse.c parse.h
+
+-INCLUDES = -I$(top_srcdir)/include
++AM_CPPFLAGS = -I$(top_srcdir)/include
+ lib_LTLIBRARIES = libcgroup.la
+ libcgroup_la_SOURCES = parse.h parse.y lex.l api.c config.c libcgroup-internal.h libcgroup.map wrapper.c log.c
+ libcgroup_la_LIBADD = -lpthread
+diff -Naur libcgroup-0.41.orig/src/bindings/Makefile.am libcgroup-0.41/src/bindings/Makefile.am
+--- libcgroup-0.41.orig/src/bindings/Makefile.am 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/src/bindings/Makefile.am 2015-07-13 14:37:12.267428146 +0000
+@@ -1,5 +1,5 @@
+ SUBDIRS = .
+-INCLUDES = -I$(top_srcdir)/include
++AM_CPPFLAGS = -I$(top_srcdir)/include
+
+ lib_LTLIBRARIES = _libcgroup.la
+ _libcgroup_la_SOURCES = libcgroup.c
+@@ -11,5 +11,5 @@
+
+ libcgroup.c: libcgroup.p $(top_srcdir)/include/libcgroup.h
+ cp libcgroup.p libcgroup.i
+- $(CC) $(INCLUDES) -DSWIG -E $(top_srcdir)/include/libcgroup.h >> libcgroup.i
++ $(CC) $(CPPFLAGS) -DSWIG -E $(top_srcdir)/include/libcgroup.h >> libcgroup.i
+ $(SWIG) -python -o libcgroup.c libcgroup.i
+diff -Naur libcgroup-0.41.orig/src/daemon/Makefile.am libcgroup-0.41/src/daemon/Makefile.am
+--- libcgroup-0.41.orig/src/daemon/Makefile.am 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/src/daemon/Makefile.am 2015-07-13 14:36:55.781428093 +0000
+@@ -1,4 +1,4 @@
+-INCLUDES = -I $(top_srcdir)/include
++AM_CPPFLAGS = -I $(top_srcdir)/include
+
+ if WITH_DAEMON
+
+diff -Naur libcgroup-0.41.orig/src/pam/Makefile.am libcgroup-0.41/src/pam/Makefile.am
+--- libcgroup-0.41.orig/src/pam/Makefile.am 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/src/pam/Makefile.am 2015-07-13 14:36:28.768428007 +0000
+@@ -1,4 +1,4 @@
+-INCLUDES = -I $(top_srcdir)/include
++AM_CPPFLAGS = -I $(top_srcdir)/include
+
+ if WITH_PAM
+
+diff -Naur libcgroup-0.41.orig/src/tools/Makefile.am libcgroup-0.41/src/tools/Makefile.am
+--- libcgroup-0.41.orig/src/tools/Makefile.am 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/src/tools/Makefile.am 2015-07-13 14:36:19.098427976 +0000
+@@ -1,4 +1,4 @@
+-INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/include
++AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include
+ LDADD = $(top_builddir)/src/.libs/libcgroup.la
+
+ if WITH_TOOLS
+diff -Naur libcgroup-0.41.orig/tests/Makefile.am libcgroup-0.41/tests/Makefile.am
+--- libcgroup-0.41.orig/tests/Makefile.am 2014-01-13 14:05:56.000000000 +0000
++++ libcgroup-0.41/tests/Makefile.am 2015-07-13 14:37:23.146428181 +0000
+@@ -1,6 +1,6 @@
+ SUBDIRS = tools
+
+-INCLUDES = -I$(top_srcdir)/include
++AM_CPPFLAGS = -I$(top_srcdir)/include
+ LDADD = $(top_builddir)/src/.libs/libcgroup.la
+
+ # compile the tests, but do not install them
diff --git a/dev-libs/libcgroup/libcgroup-0.41-r4.ebuild b/dev-libs/libcgroup/libcgroup-0.41-r4.ebuild
new file mode 100644
index 00000000..59b09c21
--- /dev/null
+++ b/dev-libs/libcgroup/libcgroup-0.41-r4.ebuild
@@ -0,0 +1,94 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: 168967680085858acc048a2a115c56ae6a5bbe78 $
+
+EAPI="5"
+
+inherit autotools eutils flag-o-matic linux-info pam
+
+DESCRIPTION="Tools and libraries to configure and manage kernel control groups"
+HOMEPAGE="http://libcg.sourceforge.net/"
+SRC_URI="mirror://sourceforge/project/libcg/${PN}/v${PV}/${P}.tar.bz2"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="amd64 ~ppc ~ppc64 ~x86"
+IUSE="+daemon elibc_musl pam static-libs +tools"
+
+RDEPEND="pam? ( virtual/pam )"
+
+DEPEND="
+ ${RDEPEND}
+ sys-devel/bison
+ sys-devel/flex
+ elibc_musl? ( sys-libs/fts-standalone )
+ "
+REQUIRED_USE="daemon? ( tools )"
+
+DOCS=(README_daemon README README_systemd INSTALL)
+pkg_setup() {
+ local CONFIG_CHECK="~CGROUPS"
+ if use daemon; then
+ CONFIG_CHECK="${CONFIG_CHECK} ~CONNECTOR ~PROC_EVENTS"
+ fi
+ linux-info_pkg_setup
+}
+
+src_prepare() {
+ epatch "${FILESDIR}"/${P}-replace_DECLS.patch
+ epatch "${FILESDIR}"/${P}-replace_INLCUDES.patch
+ epatch "${FILESDIR}"/${P}-reorder-headers.patch
+ epatch "${FILESDIR}"/${P}-remount.patch
+
+ # Change rules file location
+ sed -e 's:/etc/cgrules.conf:/etc/cgroup/cgrules.conf:' \
+ -i src/libcgroup-internal.h || die "sed failed"
+ sed -e 's:/etc/cgconfig.conf:/etc/cgroup/cgconfig.conf:' \
+ -i src/libcgroup-internal.h || die "sed failed"
+ sed -e 's:\(pam_cgroup_la_LDFLAGS.*\):\1\ -avoid-version:' \
+ -i src/pam/Makefile.am || die "sed failed"
+ sed -e 's#/var/run#/run#g' -i configure.in || die "sed failed"
+
+ eautoreconf
+}
+
+src_configure() {
+ local my_conf
+
+ if use pam; then
+ my_conf=" --enable-pam-module-dir=$(getpam_mod_dir) "
+ fi
+
+ use elibc_musl && append-ldflags "-lfts"
+ econf \
+ $(use_enable static-libs static) \
+ $(use_enable daemon) \
+ $(use_enable pam) \
+ $(use_enable tools) \
+ ${my_conf}
+}
+
+src_test() {
+ # Use mount cgroup to build directory
+ # sandbox restricted to trivial build,
+ # possible kill Diego tanderbox ;)
+ true
+}
+
+src_install() {
+ default
+ prune_libtool_files --all
+
+ insinto /etc/cgroup
+ doins samples/*.conf || die
+
+ if use tools; then
+ newconfd "${FILESDIR}"/cgconfig.confd-r1 cgconfig || die
+ newinitd "${FILESDIR}"/cgconfig.initd-r1 cgconfig || die
+ fi
+
+ if use daemon; then
+ newconfd "${FILESDIR}"/cgred.confd-r2 cgred || die
+ newinitd "${FILESDIR}"/cgred.initd-r1 cgred || die
+ fi
+}
diff --git a/dev-libs/libcgroup/libcgroup-0.41.ebuild b/dev-libs/libcgroup/libcgroup-0.41.ebuild
new file mode 100644
index 00000000..038f0397
--- /dev/null
+++ b/dev-libs/libcgroup/libcgroup-0.41.ebuild
@@ -0,0 +1,105 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: df8b956101bb2b0497c2de3b58f28044413ec7e9 $
+
+EAPI="5"
+
+AUTOTOOLS_AUTORECONF=1
+
+inherit eutils linux-info pam autotools-utils
+
+DESCRIPTION="Tools and libraries to configure and manage kernel control groups"
+HOMEPAGE="http://libcg.sourceforge.net/"
+SRC_URI="mirror://sourceforge/project/libcg/${PN}/v${PV}/${P}.tar.bz2"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="amd64 ppc ~ppc64 x86"
+IUSE="+daemon debug pam static-libs +tools debug"
+
+RDEPEND="pam? ( virtual/pam )"
+
+DEPEND="
+ ${RDEPEND}
+ sys-devel/bison
+ sys-devel/flex
+ "
+REQUIRED_USE="daemon? ( tools )"
+
+DOCS=(README_daemon README README_systemd INSTALL)
+pkg_setup() {
+ local CONFIG_CHECK="~CGROUPS"
+ if use daemon; then
+ CONFIG_CHECK="${CONFIG_CHECK} ~CONNECTOR ~PROC_EVENTS"
+ fi
+ linux-info_pkg_setup
+}
+
+src_prepare() {
+
+ # Change rules file location
+ sed -e 's:/etc/cgrules.conf:/etc/cgroup/cgrules.conf:' \
+ -i src/libcgroup-internal.h || die "sed failed"
+ sed -e 's:\(pam_cgroup_la_LDFLAGS.*\):\1\ -avoid-version:' \
+ -i src/pam/Makefile.am || die "sed failed"
+ sed -e 's#/var/run#/run#g' -i configure.in || die "sed failed"
+
+ autotools-utils_src_prepare
+}
+
+src_configure() {
+ local my_conf
+
+ if use pam; then
+ my_conf=" --enable-pam-module-dir=$(getpam_mod_dir) "
+ fi
+
+ local myeconfargs=(
+ $(use_enable daemon)
+ $(use_enable debug)
+ $(use_enable pam)
+ $(use_enable tools)
+ ${my_conf}
+ )
+ autotools-utils_src_configure
+}
+
+src_test() {
+ # Use mount cgroup to build directory
+ # sandbox restricted to trivial build,
+ # possible kill Diego tanderbox ;)
+ true
+}
+
+src_install() {
+ autotools-utils_src_install
+ prune_libtool_files --all
+
+ insinto /etc/cgroup
+ doins samples/*.conf || die
+
+ if use tools; then
+ newconfd "${FILESDIR}"/cgconfig.confd cgconfig || die
+ newinitd "${FILESDIR}"/cgconfig.initd cgconfig || die
+ fi
+
+ if use daemon; then
+ newconfd "${FILESDIR}"/cgred.confd cgred || die
+ newinitd "${FILESDIR}"/cgred.initd cgred || die
+ fi
+}
+
+pkg_postinst() {
+ elog "Read the kernel docs on cgroups, related schedulers, and the"
+ elog "block I/O controllers. The Redhat Resource Management Guide"
+ elog "is also helpful. DO NOT enable the cgroup namespace subsytem"
+ elog "if you want a custom config, rule processing, etc. This option"
+ elog "should only be enabled for a VM environment. The UID wildcard"
+ elog "rules seem to work only without a custom config (since wildcards"
+ elog "don't work in config blocks). Specific user-id configs *do*"
+ elog "work, but be careful about how the mem limits add up if using"
+ elog "the memory.limit_* directives. There should be a basic task"
+ elog "partitioning into the default group when running cgred with no"
+ elog "specific config blocks or rules (other than the mount directive)."
+ elog "See the docs for the pam module config, and as always, RTFM..."
+}