From 4f2d7949f03e1c198bc888f2d05f421d35c57e21 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Mon, 9 Oct 2017 18:53:29 +0100 Subject: reinit the tree, so we can have metadata --- sys-block/tgt/files/tgt-1.0.69-sysmacros.patch | 38 ++++++++ sys-block/tgt/files/tgtd.confd | 4 + sys-block/tgt/files/tgtd.initd | 124 +++++++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 sys-block/tgt/files/tgt-1.0.69-sysmacros.patch create mode 100644 sys-block/tgt/files/tgtd.confd create mode 100644 sys-block/tgt/files/tgtd.initd (limited to 'sys-block/tgt/files') diff --git a/sys-block/tgt/files/tgt-1.0.69-sysmacros.patch b/sys-block/tgt/files/tgt-1.0.69-sysmacros.patch new file mode 100644 index 000000000000..0b28f02e2821 --- /dev/null +++ b/sys-block/tgt/files/tgt-1.0.69-sysmacros.patch @@ -0,0 +1,38 @@ +https://bugs.gentoo.org/580594 +https://github.com/fujita/tgt/pull/25 + +From b092c6fe330a2eacf4b1d4eb093fad8e2fbcaed9 Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Sun, 27 Nov 2016 18:47:24 -0500 +Subject: [PATCH] fix build w/newer glibc +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Building with newer glibc versions fails like so: +bs_sg.c: In function ‘chk_sg_device’: +bs_sg.c:354:6: error: implicit declaration of function ‘major’ [-Werror=implicit-function-declaration] + if (major(st.st_rdev) == SCSI_GENERIC_MAJOR) + +This is because glibc is dropping the implicit sys/sysmacros.h include +from sys/types.h and making the few projects that need it include it +explicitly. +--- + usr/bs_sg.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/usr/bs_sg.c b/usr/bs_sg.c +index 66f4a3b22a18..fb544056f258 100644 +--- a/usr/bs_sg.c ++++ b/usr/bs_sg.c +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + #include + #include + #include +-- +2.11.0.rc2 + diff --git a/sys-block/tgt/files/tgtd.confd b/sys-block/tgt/files/tgtd.confd new file mode 100644 index 000000000000..fd4c098eaef2 --- /dev/null +++ b/sys-block/tgt/files/tgtd.confd @@ -0,0 +1,4 @@ +# Here you can specify options that are passed directly to tgt daemon +TGTD_OPTS="" + +# vim: ft=gentoo-conf-d diff --git a/sys-block/tgt/files/tgtd.initd b/sys-block/tgt/files/tgtd.initd new file mode 100644 index 000000000000..4931e2e38e93 --- /dev/null +++ b/sys-block/tgt/files/tgtd.initd @@ -0,0 +1,124 @@ +#!/sbin/openrc-run +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +TGTD_CONFIG=/etc/tgt/targets.conf + +TASK=$1 + +depend() { + need net +} + +start() { + ebegin "Starting target framework daemon" + ebegin "Starting ${SVCNAME}" + # Start tgtd first. + start-stop-daemon --start --quiet \ + --name tgtd \ + --exec /usr/sbin/tgtd -- \ + ${TGTD_OPTS} + RETVAL=$? + if [ "$RETVAL" -ne 0 ] ; then + echo "Could not start tgtd (is tgtd already running?)" + exit 1 + fi + # We need to wait for 1 second before do anything with tgtd + sleep 1 + # Put tgtd into "offline" state until all the targets are configured. + # We don't want initiators to (re)connect and fail the connection + # if it's not ready + tgtadm --op update --mode sys --name State -v offline + # Configure the targets. + tgt-admin --update ALL -c $TGTD_CONFIG + # Put tgtd into "ready" state. + tgtadm --op update --mode sys --name State -v ready + eend $? +} + +stop() { + ebegin "Stopping ${SVCNAME}" + ebegin "Stopping target framework daemon" + # start-stop-daemon --stop --exec /usr/sbin/tgtd --quiet + if [ "$RUNLEVEL" = 0 -o "$RUNLEVEL" = 6 ] ; then + forcedstop + fi + # Remove all targets. It only removes targets which are not in use. + tgt-admin --update ALL -c /dev/null >/dev/null 2>&1 + # tgtd will exit if all targets were removed + tgtadm --op delete --mode system >/dev/null 2>&1 + RETVAL=$? + if [ "$RETVAL" -eq 107 ] ; then + echo "tgtd is not running" + if [ "$TASK" != "restart" ] ; then + exit 1 + fi + elif [ "$RETVAL" -ne 0 ] ; then + echo "Some initiators are still connected - could not stop tgtd" + exit 2 + fi + # echo -n + eend $? +} + +forcedstop() { + # NOTE: Forced shutdown of the iscsi target may cause data corruption + # for initiators that are connected. + echo "Force-stopping target framework daemon" + # Offline everything first. May be needed if we're rebooting, but + # expect the initiators to reconnect cleanly when we boot again + # (i.e. we don't want them to reconnect to a tgtd which is still + # working, but the target is gone). + tgtadm --op update --mode sys --name State -v offline >/dev/null 2>&1 + RETVAL=$? + if [ "$RETVAL" -eq 107 ] ; then + echo "tgtd is not running" + if [ "$TASK" != "restart" ] ; then + exit 1 + fi + else + tgt-admin --offline ALL + # Remove all targets, even if they are still in use. + tgt-admin --update ALL -c /dev/null -f + # It will shut down tgtd only after all targets were removed. + tgtadm --op delete --mode system + RETVAL=$? + if [ "$RETVAL" -ne 0 ] ; then + echo "Failed to shutdown tgtd" + exit 1 + fi + fi + echo -n +} + +reload() { + echo "Updating target framework daemon configuration" + # Update configuration for targets. Only targets which + # are not in use will be updated. + tgt-admin --update ALL -c $TGTD_CONFIG >/dev/null 2>&1 + RETVAL=$? + if [ "$RETVAL" -eq 107 ] ; then + echo "tgtd is not running" + exit 1 + fi +} + +forcedreload() { + echo "Force-updating target framework daemon configuration" + # Update configuration for targets, even those in use. + tgt-admin --update ALL -f -c $TGTD_CONFIG >/dev/null 2>&1 + RETVAL=$? + if [ "$RETVAL" -eq 107 ] ; then + echo "tgtd is not running" + exit 1 + fi +} + +status() { + TGTD_PROC=$(pidof -c -o $$ -o %PPID tgtd) + if [ -n "$TGTD_PROC" ] ; then + echo "tgtd is running. Run 'tgt-admin -s' to see detailed target info." + else + echo "tgtd is NOT running." + fi +} -- cgit v1.2.3