From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QLqGZ-0000a6-QZ for garchives@archives.gentoo.org; Mon, 16 May 2011 05:22:52 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 640DD1C002; Mon, 16 May 2011 05:22:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 253411C002 for ; Mon, 16 May 2011 05:22:44 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 96FC21B401B for ; Mon, 16 May 2011 05:22:43 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id BBBD87448A for ; Mon, 16 May 2011 05:22:42 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <2493a1f32e7ae95f0f3d3c63cb4af7abdc34959b.vapier@gentoo> Subject: [gentoo-commits] proj/openrc:master commit in: net/ X-VCS-Repository: proj/openrc X-VCS-Files: net/ccwgroup.sh X-VCS-Directories: net/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 2493a1f32e7ae95f0f3d3c63cb4af7abdc34959b Date: Mon, 16 May 2011 05:22:42 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 7f42be9bc67e96409cf9a1292bc15d06 commit: 2493a1f32e7ae95f0f3d3c63cb4af7abdc34959b Author: Mike Frysinger gentoo org> AuthorDate: Mon May 16 05:21:20 2011 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Mon May 16 05:22:32 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/openrc.git;a=3D= commit;h=3D2493a1f3 net: ccwgroup: forward port changes from baselayout-1 Quite a bit of work happened in baselayout-1 on the ccwgroup module, but seems it didn't make it into openrc. So forward port all the existing code so we can work with more than just qeth and layer2 options. Signed-off-by: Mike Frysinger gentoo.org> --- net/ccwgroup.sh | 83 +++++++++++++++++++++++++++++++++++++------------= ------ 1 files changed, 56 insertions(+), 27 deletions(-) diff --git a/net/ccwgroup.sh b/net/ccwgroup.sh index 6fcba1d..248b159 100644 --- a/net/ccwgroup.sh +++ b/net/ccwgroup.sh @@ -8,60 +8,89 @@ ccwgroup_depend() before interface } =20 -ccwgroup_pre_start() +ccwgroup_load_modules() { - local ccwgroup=3D"$(_get_array "ccwgroup_${IFVAR}")" - [ -z "${ccwgroup}" ] && return 0 - - if [ ! -d /sys/bus/ccwgroup ]; then - modprobe qeth - if [ ! -d /sys/bus/ccwgroup ]; then + # make sure we have ccwgroup support or this is a crap shoot + if [ ! -d /sys/bus/ccwgroup ] ; then + modprobe -q ccwgroup + if [ ! -d /sys/bus/ccwgroup ] ; then eerror "ccwgroup support missing in kernel" return 1 fi fi =20 - einfo "Enabling ccwgroup on ${IFACE}" - local x=3D ccw=3D first=3D layer2=3D - for x in ${ccwgroup}; do - [ -z "${first}" ] && first=3D${x} - ccw=3D"${ccw}${ccw:+,}${x}" - done - if [ -e /sys/devices/qeth/"${first}" ]; then - echo "0" >/sys/devices/qeth/"${first}"/online + # verify the specific interface is supported + if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then + modprobe $1 >& /dev/null + if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then + eerror "$1 support missing in kernel" + return 1 + fi + fi + + return 0 +} + +ccwgroup_pre_start() +{ + local ccwgroup=3D"$(_get_array "ccwgroup_${IFVAR}")" + [ -z "${ccwgroup}" ] && return 0 + + local ccw_type + eval ccw_type=3D\${ccwgroup_type_${IFVAR}:-qeth} + + ccwgroup_load_modules ${ccw_type} || return 1 + + einfo "Enabling ccwgroup/${ccw_type} on ${IFACE}" + + set -- ${ccwgroup} + local first=3D$1; shift + if [ -e /sys/devices/${ccw_type}/${first}/online ]; then + echo "0" >/sys/devices/${ccw_type}/${first}/online else - echo "${ccw}" >/sys/bus/ccwgroup/drivers/qeth/group + echo "${first}$(printf ',%s' "$@")" >/sys/bus/ccwgroup/drivers/${ccw_t= ype}/group fi - eval layer2=3D\$qeth_layer2_${IFVAR} - echo "${layer2:-0}" > /sys/devices/qeth/"${first}"/layer2 - echo "1" >/sys/devices/qeth/"${first}"/online + + local var val + for var in $(_get_array "ccwgroup_opts_${IFVAR}") online=3D1 ; do + val=3D${var#*=3D} + var=3D${var%%=3D*} + echo "${val}" > /sys/devices/${ccw_type}/${first}/${var} + done eend $? } =20 ccwgroup_pre_stop() { + local path=3D"/sys/class/net/${IFACE}" + # Erase any existing ccwgroup to be safe service_set_value ccwgroup_device "" + service_set_value ccwgroup_type "" =20 - [ ! -L /sys/class/net/"${FACE}"/driver ] && return 0 - local driver=3D"$(readlink /sys/class/net/"${IFACE}"/driver)" - case "${diver}" in - */bus/ccwgroup/*);; + [ ! -L "${path}"/device/driver ] && return 0 + case "$(readlink "${path}"/device/driver)" in + */bus/ccwgroup/*) ;; *) return 0;; esac =20 - local device=3D"$(readlink /sys/class/net/"${IFACE}"/device)" + local device + device=3D"$(readlink "${path}"/device)" device=3D${device##*/} service_set_value ccwgroup_device "${device}" + device=3D"$(readlink "${path}"/device/driver)" + device=3D${device##*/} + service_set_value ccwgroup_type "${device}" } =20 ccwgroup_post_stop() { local device=3D"$(service_get_value ccwgroup_device)" [ -z "${device}" ] && return 0 + local ccw_type=3D"$(service_get_value ccwgroup_type)" =20 - einfo "Disabling ccwgroup on ${iface}" - echo "0" >/sys/devices/qeth/"${device}"/online - echo "1" >/sys/devices/qeth/"${device}"/ungroup + einfo "Disabling ccwgroup/${ccw_type} on ${IFACE}" + echo "0" >/sys/devices/${ccw_type}/"${device}"/online + echo "1" >/sys/devices/${ccw_type}/"${device}"/ungroup eend $? }