]> Frank Brehm's Git Trees - config/bruni/etc.git/commitdiff
saving uncommitted changes in /etc prior to emerge run
authorFrank Brehm <frank@brehm-online.com>
Thu, 12 Oct 2017 20:29:05 +0000 (22:29 +0200)
committerFrank Brehm <root@bruni.home.brehm-online.com>
Thu, 12 Oct 2017 20:29:05 +0000 (22:29 +0200)
conf.d/localmount
init.d/sysfs

index e727719445feba2a9697d41d9dceb25c2a93f41f..25ca3cd671abb27b7def3a397661edec9f3e4054 100644 (file)
@@ -3,7 +3,7 @@
 #no_umounts="/dir1:/var/dir2"
 #
 # Mark certain mount points as critical.
-# This contains aspace separated list of mount points which should be
+# This contains a space separated list of mount points which should be
 # considered critical. If one of these mount points cannot be mounted,
 # localmount will fail.
 # By default, this is empty.
index 55e12588366011287308c2b25ce91e52ca0c525b..d2575437253d8895834b56554b036fd3ef44a2b9 100755 (executable)
@@ -107,20 +107,16 @@ mount_misc()
        fi
 }
 
-mount_cgroups()
+cgroup1_base()
 {
-       # set up kernel support for cgroups
-       if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then
-               if grep -qs cgroup /proc/filesystems; then
-                       ebegin "Mounting cgroup filesystem"
-                       local opts="${sysfs_opts},mode=755,size=${rc_cgroupsize:-10m}"
-                       mount -n -t tmpfs -o ${opts} cgroup_root /sys/fs/cgroup
-                       eend $?
-               fi
+       grep -qw cgroup /proc/filesystems || return 0
+       if ! mountinfo -q /sys/fs/cgroup; then
+               ebegin "Mounting cgroup filesystem"
+               local opts="${sysfs_opts},mode=755,size=${rc_cgroupsize:-10m}"
+               mount -n -t tmpfs -o "${opts}" cgroup_root /sys/fs/cgroup
+               eend $?
        fi
 
-       mountinfo -q /sys/fs/cgroup || return 0
-
        if ! mountinfo -q /sys/fs/cgroup/openrc; then
                local agent="/lib64/rc/sh/cgroup-release-agent.sh"
                mkdir /sys/fs/cgroup/openrc
@@ -129,17 +125,96 @@ mount_cgroups()
                        openrc /sys/fs/cgroup/openrc
                printf 1 > /sys/fs/cgroup/openrc/notify_on_release
        fi
+       return 0
+}
 
-       yesno ${rc_controller_cgroups:-YES} && [ -e /proc/cgroups ] || return 0
-       while read name hier groups enabled rest; do
+cgroup1_controllers()
+{
+       yesno "${rc_controller_cgroups:-YES}" && [ -e /proc/cgroups ] || return 0
+       while read -r name _ _ enabled rest; do
                case "${enabled}" in
-                       1)      mountinfo -q /sys/fs/cgroup/${name} && continue
-                               mkdir /sys/fs/cgroup/${name}
-                               mount -n -t cgroup -o ${sysfs_opts},${name} \
-                                       ${name} /sys/fs/cgroup/${name}
+                       1)      mountinfo -q "/sys/fs/cgroup/${name}" && continue
+                               local x
+                               for x in $rc_cgroup_controllers; do
+                               [ "${name}" = "blkio" ] && [ "${x}" = "io" ] &&
+                                       continue 2
+                               [ "${name}" = "${x}" ] &&
+                               continue 2
+                               done
+                               mkdir "/sys/fs/cgroup/${name}"
+                               mount -n -t cgroup -o "${sysfs_opts},${name}" \
+                                       "${name}" "/sys/fs/cgroup/${name}"
                                ;;
                esac
        done < /proc/cgroups
+       return 0
+}
+
+cgroup2_base()
+{
+       local base
+       base="$(cgroup2_find_path)"
+       mkdir -p "${base}"
+       mount -t cgroup2 none -o "${sysfs_opts},nsdelegate" "${base}" 2> /dev/null ||
+               mount -t cgroup2 none -o "${sysfs_opts}" "${base}"
+       return 0
+}
+
+cgroup2_controllers()
+{
+       local active cgroup_path x y
+       cgroup_path="$(cgroup2_find_path)"
+       [ -z "${cgroup_path}" ] && return 0
+       [ -e "${cgroup_path}/cgroup.controllers" ] &&
+       read -r active < "${cgroup_path}/cgroup.controllers"
+       for x in ${rc_cgroup_controllers}; do
+               for y in ${active}; do
+               [ "$x" = "$y" ] &&
+                       [ -e "${cgroup_path}/cgroup.subtree_control" ]&&
+                       echo "+${x}"  > "${cgroup_path}/cgroup.subtree_control"
+               done
+       done
+       return 0
+}
+
+cgroups_hybrid()
+{
+       grep -qw cgroup /proc/filesystems || return 0
+       cgroup1_base
+       if grep -qw cgroup2 /proc/filesystems; then
+               cgroup2_base
+               cgroup2_controllers
+       fi
+       cgroup1_controllers
+       return 0
+}
+
+cgroups_legacy()
+{
+       grep -qw cgroup /proc/filesystems || return 0
+       cgroup1_base
+       cgroup1_controllers
+       return 0
+}
+
+cgroups_unified()
+{
+       cgroup2_base
+       cgroup2_controllers
+       return 0
+}
+
+mount_cgroups()
+{
+       # set up kernel support for cgroups
+       if [ -d /sys/fs/cgroup ]; then
+               case "${rc_cgroup_mode:-hybrid}" in
+               hybrid) cgroups_hybrid ;;
+               legacy) cgroups_legacy ;;
+               unified) cgroups_unified ;;
+               esac
+       fi
+       return 0
 }
 
 restorecon_sys()