- fixed return value in cpi initscript (#541389)

- updated zfcpconf.sh script from dracut
- added device-mapper support into zipl (#546280)
- added missing check and print NSS name in case an NSS has been IPLed
    (#546297)
- added device_cio_free script and its symlinks
- added qualified return codes and further error handling in znetconf
    (#548487)
This commit is contained in:
Dan Horák 2009-12-22 11:00:08 +00:00
parent 9006f09f29
commit 925b343a65
5 changed files with 4547 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,376 @@
From 62fb535a68f1df693869e4361150259b42c6f211 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Thu, 10 Dec 2009 18:30:52 +0100
Subject: [PATCH 16/16] s390tools-1.8.2-lsreipl-nss
---
ipl_tools/ccw.c | 42 ++++++++++++++++---------------------
ipl_tools/chreipl.h | 9 +++++--
ipl_tools/fcp.c | 13 ++++++-----
ipl_tools/ipl.c | 57 +++++++++++++++++++++++++++++++-------------------
ipl_tools/main.c | 25 +++++++++++++++++-----
ipl_tools/system.c | 3 +-
6 files changed, 87 insertions(+), 62 deletions(-)
diff --git a/ipl_tools/ccw.c b/ipl_tools/ccw.c
index 7959831..eef4550 100644
--- a/ipl_tools/ccw.c
+++ b/ipl_tools/ccw.c
@@ -52,22 +52,19 @@ int isccwdev(const char *devno)
}
-int get_ccw_devno_old_sysfs(char *device, char *devno)
+int get_ccw_devno_old_sysfs(char *device)
{
FILE *filp;
- int len, errorpath, rc;
+ int errorpath;
char path1[4096];
char buf[4096];
- char *match, *s1, *s2;
+ char *match = NULL, *s1, *s2;
errorpath = 1;
- rc = 0;
sprintf(path1, "/sys/block/%s/uevent", device);
filp = fopen(path1, "r");
- if (!filp) {
- rc = -1;
- return rc;
- }
+ if (!filp)
+ return -1;
/*
* the uevent file contains an entry like this:
* PHYSDEVPATH=/devices/css0/0.0.206a/0.0.7e78
@@ -77,16 +74,16 @@ int get_ccw_devno_old_sysfs(char *device, char *devno)
if (match != NULL)
break;
}
+ fclose(filp);
+ if (!match)
+ return -1;
s1 = strchr(buf, '/');
s2 = strrchr(buf, '/');
- len = s2-s1;
- strncpy(devno, s2 + 1, sizeof(devno));
- devno[len] = '\0';
- fclose(filp);
+ strncpy(devno, s2 + 1, sizeof(devno) - 1);
return 0;
}
-int get_ccw_devno_new_sysfs(char *device, char *devno)
+int get_ccw_devno_new_sysfs(char *device)
{
int len, errorpath, rc;
char path2[4096];
@@ -119,8 +116,7 @@ int get_ccw_devno_new_sysfs(char *device, char *devno)
return rc;
}
}
- strncpy(devno, s2 + 1, sizeof(devno));
- devno[len] = '\0';
+ strncpy(devno, s2 + 1, sizeof(devno) - 1);
return 0;
}
@@ -134,16 +130,14 @@ int get_ccw_devno_new_sysfs(char *device, char *devno)
*
* This does not work when booting from tape
*/
-int get_ccw_devno(char *device, char *devno)
+int get_ccw_devno(char *device)
{
- if (get_ccw_devno_old_sysfs(device, devno) != 0) {
- if (get_ccw_devno_new_sysfs(device, devno) != 0) {
- fprintf(stderr, "%s: Failed to lookup the device number\n",
- name);
- return -1;
- }
- }
- return 0;
+ if (get_ccw_devno_old_sysfs(device) == 0)
+ return 0;
+ if (get_ccw_devno_new_sysfs(device) == 0)
+ return 0;
+ fprintf(stderr, "%s: Failed to lookup the device number\n", name);
+ return -1;
}
int get_ccw_dev(char *partition, char *device)
diff --git a/ipl_tools/chreipl.h b/ipl_tools/chreipl.h
index 19a83eb..37807a7 100644
--- a/ipl_tools/chreipl.h
+++ b/ipl_tools/chreipl.h
@@ -34,6 +34,9 @@ extern char saction[8];
extern char name[256];
extern int action;
+#define IPL_TYPE_LEN_MAX 100
+#define NSS_NAME_LEN_MAX 8
+
#define ACT_CCW 1
#define ACT_FCP 2
#define ACT_NODE 3
@@ -63,10 +66,10 @@ int is_valid_case(char *c);
int is_valid_action(char *action);
void parse_shutdown_options(int argc, char **argv);
void strlow(char *s);
-int get_ccw_devno(char *device, char *devno);
-int get_reipl_type(void);
+int get_ccw_devno(char *device);
+int get_reipl_type(char *reipltype);
void parse_lsreipl_options(int argc, char **argv);
-int get_ipl_type();
+int get_ipl_type(char *reipltype);
int get_ipl_loadparam(void);
void print_ipl_settings(void);
int get_sa(char *action, char *file);
diff --git a/ipl_tools/fcp.c b/ipl_tools/fcp.c
index 86fa95b..7a8b4c5 100644
--- a/ipl_tools/fcp.c
+++ b/ipl_tools/fcp.c
@@ -33,12 +33,11 @@
/*
* return the current reipl type from /sys/firmware/reipl/reipl_type
- * 0 = fcp, 1 = ccw, -1, error
+ * 0 = fcp, 1 = ccw, 2 = nss, -1 = unknown
*/
-int get_reipl_type(void)
+int get_reipl_type(char *reipltype)
{
FILE *filp;
- char reipltype[4];
char path[4096];
int rc;
@@ -49,7 +48,7 @@ int get_reipl_type(void)
fprintf(stderr, "%s: Can not open /sys/firmware/"
"reipl/reipl_type: ", name);
fprintf(stderr, "%s\n", strerror(errno));
- return -1;
+ exit(1);
}
rc = fscanf(filp, "%s", reipltype);
fclose(filp);
@@ -57,17 +56,19 @@ int get_reipl_type(void)
fprintf(stderr, "%s: Failed to read "
"/sys/firmware/reipl/reipl_type:", name);
fprintf(stderr, "%s\n", strerror(errno));
- return -1;
+ exit(1);
}
if (strncmp(reipltype, "fcp", strlen("fcp")) == 0)
return T_FCP;
else if (strncmp(reipltype, "ccw", strlen("ccw")) == 0)
return T_CCW;
- /* TODO: add NSS support */
+ else if (strncmp(reipltype, "nss", strlen("nss")) == 0)
+ return T_NSS;
} else {
fprintf(stderr, "%s: Can not open /sys/firmware/reipl/"
"reipl_type:", name);
fprintf(stderr, " %s\n", strerror(errno));
+ exit(1);
}
return -1;
}
diff --git a/ipl_tools/ipl.c b/ipl_tools/ipl.c
index 2bf817a..8cca700 100644
--- a/ipl_tools/ipl.c
+++ b/ipl_tools/ipl.c
@@ -33,12 +33,11 @@
/*
* return the ipl type based on /sys/firmware/ipl/ipl_type
- * returns 0 in case of fcp and 1 in case of ccw, -1 otherwise
+ * returns 0 in case of fcp and 1 in case of ccw, 2 for nss and -1 otherwise
*/
-int get_ipl_type()
+int get_ipl_type(char *reipltype)
{
FILE *filp;
- char reipltype[4];
char path[4096];
int rc;
@@ -49,7 +48,7 @@ int get_ipl_type()
fprintf(stderr, "%s: Can not open /sys/firmware/ipl/"
"ipl_type: ", name);
fprintf(stderr, "%s\n", strerror(errno));
- return -1;
+ exit(1);
}
rc = fscanf(filp, "%s", reipltype);
fclose(filp);
@@ -57,12 +56,14 @@ int get_ipl_type()
fprintf(stderr, "%s: Failed to read "
"/sys/firmware/ipl/ipl_type: ", name);
fprintf(stderr, "%s\n", strerror(errno));
- return -1;
+ exit(1);
}
if (strncmp(reipltype, "fcp", strlen("fcp")) == 0)
return T_FCP;
else if (strncmp(reipltype, "ccw", strlen("ccw")) == 0)
return T_CCW;
+ else if (strncmp(reipltype, "nss", strlen("nss")) == 0)
+ return T_NSS;
} else {
fprintf(stderr, "%s: Can not open /sys/firmware/ipl/"
"ipl_type:", name);
@@ -111,30 +112,38 @@ int get_ipl_loadparam(void)
void print_ipl_settings(void)
{
int rc, type;
- char bootprog[1024], lba[1024];
+ char bootprog[1024], lba[1024], nss_name[NSS_NAME_LEN_MAX + 1];
+ char reipltype[IPL_TYPE_LEN_MAX + 1];
- type = get_ipl_type();
- /*
- * TODO: add nss support
- */
- if (type == 1)
+ type = get_ipl_type(reipltype);
+ switch (type) {
+ case T_NSS:
+ printf("IPL type: nss\n");
+ rc = strrd(nss_name, "/sys/firmware/ipl/name");
+ if (rc != 0)
+ exit(1);
+ printf("Name: %s\n", nss_name);
+ break;
+ case T_CCW:
printf("IPL type: ccw\n");
- if (type == 0)
- printf("IPL type: fcp\n");
- rc = strrd(devno, "/sys/firmware/ipl/device");
- if (rc != 0)
- exit(1) /* the error msg comes from get_ipl_device */;
- if (strlen(devno) > 0)
- printf("Device: %s\n", devno);
- if (type == 1) {
+ rc = strrd(devno, "/sys/firmware/ipl/device");
+ if (rc != 0)
+ exit(1);
+ if (strlen(devno) > 0)
+ printf("Device: %s\n", devno);
rc = get_ipl_loadparam();
if (rc != -1)
printf("Loadparm: %d\n", rc);
else
printf("Loadparm: \n");
- }
- if (type == 0) {
- /* these settings are only available for fcp */
+ break;
+ case T_FCP:
+ printf("IPL type: fcp\n");
+ rc = strrd(devno, "/sys/firmware/ipl/device");
+ if (rc != 0)
+ exit(1);
+ if (strlen(devno) > 0)
+ printf("Device: %s\n", devno);
rc = strrd(wwpn, "/sys/firmware/reipl/fcp/wwpn");
if (rc != -1 && strlen(wwpn) > 0)
printf("WWPN: %s\n", wwpn);
@@ -147,6 +156,10 @@ void print_ipl_settings(void)
rc = strrd(lba, "/sys/firmware/ipl/br_lba");
if (rc != -1 && strlen(lba) > 0)
printf("br_lba: %s\n", lba);
+ break;
+ default:
+ printf("IPL type: %s (unknown)\n", reipltype);
+ break;
}
exit(0);
}
diff --git a/ipl_tools/main.c b/ipl_tools/main.c
index 2eaa043..bcebabe 100644
--- a/ipl_tools/main.c
+++ b/ipl_tools/main.c
@@ -57,13 +57,22 @@ int action; /* either CCW, FCP or NODE */
int lsreipl(int argc, char *argv[])
{
int rc;
- char bootprog[1024], lba[1024], val[9];
+ char bootprog[1024], lba[1024], val[9], reipltype[IPL_TYPE_LEN_MAX + 1];
+ char nss_name[NSS_NAME_LEN_MAX + 1];
/* parse the command line options in getop.c */
parse_lsreipl_options(argc, argv);
- rc = get_reipl_type();
- if (rc == 0) {
+ rc = get_reipl_type(reipltype);
+ switch (rc) {
+ case T_NSS:
+ printf("Re-IPL type: nss\n");
+ rc = strrd(nss_name, "/sys/firmware/reipl/nss/name");
+ if (rc != 0)
+ exit(1);
+ printf("Name: %s\n", nss_name);
+ break;
+ case T_FCP:
printf("Re-IPL type: fcp\n");
rc = strrd(wwpn, "/sys/firmware/reipl/fcp/wwpn");
if (rc != 0)
@@ -90,8 +99,8 @@ int lsreipl(int argc, char *argv[])
printf("bootprog: %s\n", bootprog);
if (strlen(lba) > 0)
printf("br_lba: %s\n", lba);
- }
- if (rc == 1) {
+ break;
+ case T_CCW:
printf("Re-IPL type: ccw\n");
rc = strrd(devno, "/sys/firmware/reipl/ccw/device");
if (rc != 0)
@@ -106,6 +115,10 @@ int lsreipl(int argc, char *argv[])
printf("Loadparm: %s\n", val);
else
printf("Loadparm: \n");
+ break;
+ default:
+ printf("Re-IPL type: %s (unknown)\n", reipltype);
+ break;
}
return 0;
}
@@ -134,7 +147,7 @@ int reipl(int argc, char *argv[])
"partition: %s\n", name, partition);
exit(1);
}
- rc = get_ccw_devno(device, devno);
+ rc = get_ccw_devno(device);
if (rc != 0) {
fprintf(stderr, "%s: Unable to lookup device"
" number for device %s\n", name,
diff --git a/ipl_tools/system.c b/ipl_tools/system.c
index fd5b76b..ca6c5af 100644
--- a/ipl_tools/system.c
+++ b/ipl_tools/system.c
@@ -174,7 +174,7 @@ int strrd(char *string, char *file)
fprintf(stderr, "%s\n", strerror(errno));
exit(1);
}
- rc = fread(string, 4096, 1, filp);
+ rc = fread(string, 1, 4096, filp);
fclose(filp);
/*
* special handling is required for
@@ -193,6 +193,7 @@ int strrd(char *string, char *file)
fprintf(stderr, "%s\n", strerror(errno));
return -1;
} else {
+ string[rc] = 0;
if (string[strlen(string) - 1] == '\n')
string[strlen(string) - 1] = 0;
return 0;
--
1.6.3.3

File diff suppressed because it is too large Load Diff

203
device_cio_free Normal file
View File

@ -0,0 +1,203 @@
#!/bin/sh
#
# Copyright 2009 Red Hat, Inc.
# License: GPLv2
# Author: Dan Horák <dhorak@redhat.com>
#
# unblock devices listed in various config files and wait until they are ready
#
# it uses dasd and zfcp config file
# config file syntax:
# deviceno options
# or
# deviceno WWPN FCPLUN
#
# also processes the system ccw config file and network interface configurations
#
DASDCONFIG=/etc/dasd.conf
ZFCPCONFIG=/etc/zfcp.conf
ZNETCONFIG=/etc/ccw.conf
BLACKLIST=/proc/cio_ignore
VERBOSE=
PATH=/bin:/usr/bin:/sbin:/usr/sbin
ALL_DEVICES=
usage()
{
echo "$0 [-h|--help] [-V|--verbose]"
exit 1
}
# accepts single device, comma-separated lists and dash separated ranges and their combinations
free_device()
{
local DEV
[ -z "$1" ] && return
DEV=$(echo $1 | tr "A-Z" "a-z")
[ $VERBOSE ] && echo "Freeing device(s) $DEV"
if [ echo "free $DEV" > $BLACKLIST 2> /dev/null ]; then
echo "Error: can't free device(s) $DEV"
else
if [ -z $ALL_DEVICES ]; then
ALL_DEVICES=$DEV
else
ALL_DEVICES="$ALL_DEVICES,$DEV"
fi
fi
}
# wait until a device appears on the ccw bus
wait_on_device()
{
local DEVICE_ONLINE DEV
[ -z "$1" ] && return
DEV=$1
DEVICE_ONLINE=/sys/bus/ccw/devices/$DEV/online
[ $VERBOSE ] && echo "Waiting on device $DEV"
[ -f "$DEVICE_ONLINE" ] && return
for t in 1 2 3 4 5
do
sleep $t
[ -f "$DEVICE_ONLINE" ] && return
done
echo "Error: device $DEV still not ready"
}
# check how we were called
case $(basename "$0") in
"dasd_cio_free")
CONFIG=$DASDCONFIG
MODE=dasd
;;
"zfcp_cio_free")
CONFIG=$ZFCPCONFIG
MODE=zfcp
;;
"znet_cio_free")
CONFIG=$ZNETCONFIG
MODE=znet
;;
*)
echo "Error: unknown alias '$CMD'."
echo "Supported aliases are dasd_cio_free, zfcp_cio_free and znet_cio_free."
exit 1
;;
esac
# process command line options
if [ $# -gt 0 ]; then
case $1 in
-V|--verbose)
VERBOSE=yes
shift
;;
-h|--help)
usage
;;
*)
echo "Error: unknown option $1"
usage
;;
esac
fi
if [ ! -f $BLACKLIST ]; then
echo "Error: $BLACKLIST kernel interface doesn't exist"
exit 2
fi
if [ $MODE = "dasd" -o $MODE = "zfcp" ]; then
# process the config file
if [ -f "$CONFIG" ]; then
while read line; do
case $line in
\#*) ;;
*)
[ -z "$line" ] && continue
set $line
free_device $1
;;
esac
done < $CONFIG
fi
fi
if [ $MODE = "dasd" ]; then
# process the device list defined as option for the dasd module
DEVICES=$(modprobe --showconfig | grep "options[[:space:]]\+dasd_mod" | \
sed -e 's/.*[[:space:]]dasd=\([^[:space:]]*\).*/\1/' -e 's/([^)]*)//g' \
-e 's/nopav\|nofcx\|autodetect\|probeonly//g' -e 's/,,/,/g' -e 's/^,//' -e 's/,$//')
free_device $DEVICES
fi
if [ $MODE = "znet" ]; then
# process the config file
if [ -f "$CONFIG" ]; then
while read line; do
case $line in
\#*) ;;
*)
[ -z "$line" ] && continue
# grep 2 or 3 channels from beginning of each line
DEVICES=$(echo $line | egrep -i -o "^([0-9]\.[0-9]\.[a-f0-9]+,){1,2}([0-9]\.[0-9]\.[a-f0-9]+)")
free_device $DEVICES
;;
esac
done < $CONFIG
fi
# process channels from network interface configurations
for line in $(egrep -i -h "^[[:space:]]*SUBCHANNELS=['\"]?([0-9]\.[0-9]\.[a-f0-9]+,){1,2}([0-9]\.[0-9]\.[a-f0-9]+)['\"]?([[:space:]]+#|[[:space:]]*$)" /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null)
do
eval "$line"
free_device $SUBCHANNELS
done
fi
# wait until recently unblocked devices are ready
# at this point we know the content of ALL_DEVICES is syntacticly correct
IFS=","
set $ALL_DEVICES
while [ "$1" ]
do
DEV="$1"
IFS="."
# get the lower bound for range or get the single device
LOWER=${DEV%%-*}
read -a L <<< "$LOWER"
if [ ${#L[@]} -eq 1 ]; then
L[2]=${L[0]}
L[0]=0
L[1]=0
fi
# get the upper bound for range or get the single device
UPPER=${DEV##*-}
read -a U <<< "$UPPER"
if [ ${#U[@]} -eq 1 ]; then
U[2]=${U[0]}
U[0]=0
U[1]=0
fi
# iterate thru all devices
for (( i=0x${L[0]}; i<=0x${U[0]}; i++ )); do
for (( j=0x${L[1]}; j<=0x${U[1]}; j++ )); do
for (( k=0x${L[2]}; k<=0x${U[2]}; k++ )); do
wait_on_device "$(printf %x.%x.%04x $i $j $k)"
done
done
done
# go to the next device
shift
done

View File

@ -8,7 +8,7 @@ Name: s390utils
Summary: Utilities and daemons for IBM System/z
Group: System Environment/Base
Version: 1.8.2
Release: 5%{?dist}
Release: 6%{?dist}
Epoch: 2
License: GPLv2 and GPLv2+ and CPL
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -31,6 +31,7 @@ Source11: cpi.sysconfig
# files for DASD initialization
Source12: dasd.udev
Source13: dasdconf.sh
Source14: device_cio_free
Patch1: 0001-s390-tools-1.5.3-zipl-zfcpdump-2.patch
Patch2: 0002-s390-tools-1.8.1-zipl-automenu.patch
@ -46,6 +47,9 @@ Patch11: 0011-update-readahead-value-for-better-performance.patch
Patch12: 0012-fix-multipath-device-detection-in-ziomon.patch
Patch13: 0013-zipl-handle-status-during-ipl.patch
Patch14: 0014-dasdview-fdasd-fix-floating-point-error-for-unformat.patch
Patch15: 0015-s390tools-1.8.2-zipl-dm.patch
Patch16: 0016-s390tools-1.8.2-lsreipl-nss.patch
Patch17: 0017-qualified-return-codes-and-further-error-handling-in.patch
Patch100: cmsfs-1.1.8-warnings.patch
Patch101: cmsfs-1.1.8-kernel26.patch
@ -117,6 +121,15 @@ be used together with the zSeries (s390) Linux kernel and device drivers.
# Fix floating point error for unformatted devices in fdasd and dasdview (#537144)
%patch14 -p1 -b .dasd-zero-division
# Add device-mapper support into zipl (#546280)
%patch15 -p1 -b .zipl-dm
# Add missing check and print NSS name in case an NSS has been IPLed (#546297)
%patch16 -p1 -b .lsreipl-nss
# Add qualified return codes and further error handling in znetconf (#548487)
%patch17 -p1 -b .znetconf-returncodes
#
# cmsfs
#
@ -190,6 +203,9 @@ rm -rf ${RPM_BUILD_ROOT}
mkdir -p $RPM_BUILD_ROOT{%{_lib},%{_libdir},/sbin,/bin,/boot,%{_mandir}/man1,%{_mandir}/man8,%{_sbindir},%{_bindir},%{_sysconfdir}/{profile.d,udev/rules.d,sysconfig},%{_initddir}}
# workaround an issue in the zipl-device-mapper patch
rm -f zipl/src/zipl_helper.device-mapper.*
make install \
INSTROOT=$RPM_BUILD_ROOT \
MANDIR=$RPM_BUILD_ROOT%{_mandir} \
@ -252,6 +268,14 @@ install -p -m 644 include/vtoc.h $RPM_BUILD_ROOT%{_includedir}/%{name}
install -p -m 644 %{SOURCE11} ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/cpi
install -p -m 755 %{SOURCE10} ${RPM_BUILD_ROOT}%{_initddir}/cpi
# device_cio_free
install -p -m 755 %{SOURCE14} ${RPM_BUILD_ROOT}/sbin
pushd ${RPM_BUILD_ROOT}/sbin
for lnk in dasd zfcp znet; do
ln -sf device_cio_free ${lnk}_cio_free
done
popd
%clean
rm -rf ${RPM_BUILD_ROOT}
@ -422,9 +446,11 @@ fi
%doc README
%doc LICENSE
/sbin/zipl
/sbin/dasd_cio_free
/sbin/dasdfmt
/sbin/dasdinfo
/sbin/dasdview
/sbin/device_cio_free
/sbin/fdasd
/sbin/chccwdev
/sbin/chchp
@ -446,7 +472,9 @@ fi
/sbin/tape390_crypt
/sbin/tunedasd
/sbin/vmcp
/sbin/zfcp_cio_free
/sbin/zgetdump
/sbin/znet_cio_free
/sbin/znetconf
/sbin/dbginfo.sh
%{_sbindir}/lsreipl
@ -798,6 +826,14 @@ User-space development files for the s390/s390x architecture.
%changelog
* Tue Dec 22 2009 Dan Horák <dan[at]danny.cz> 2:1.8.2-6
- fixed return value in cpi initscript (#541389)
- updated zfcpconf.sh script from dracut
- added device-mapper support into zipl (#546280)
- added missing check and print NSS name in case an NSS has been IPLed (#546297)
- added device_cio_free script and its symlinks
- added qualified return codes and further error handling in znetconf (#548487)
* Fri Nov 13 2009 Dan Horák <dan[at]danny.cz> 2:1.8.2-5
- added multiple fixes from IBM (#533955, #537142, #537144)