s390-tools/mkdump.pl

580 lines
13 KiB
Perl
Raw Normal View History

#!/usr/bin/perl
########################################################################
#
# mkdump.pl - Preparing disks for use as S/390 dump device
#
# Copyright (c) 2011 Tim Hardeck, SUSE LINUX Products GmbH
Accepting request 531958 from home:markkp:branches:Base:System - Modified mkdump perl script to work with the updated version of the IBM tools dasdview, zipl and zgetdump. (bsc#1020336). - Upgraded to version 2.1.0 (Fate#323291). Changes from 2.0.0 to 2.1.0 * Added the following tools: netboot: Scripts for building a PXE-style netboot image for KVM 90-cpi.rules/cpictl: New udev rule to update CPI when KVM is used * Modified lsqeth/zdev to add VNIC Characteristics support Bug fixes * chzcrypt: Corrected handling of insufficient permissions * cpacfstats: Add size setting to perf event * fdasd: Skip partition check with the force option * ttyrun: Fix deprecated BindTo usage in ttyrun-getty@.service.in * lszcrypt: Fix core dump caused by stack overwrite * lszcrypt: Fix random domain printout when no config available * zdev: Fix segfault with unknown qeth attribute * zdev: Fix IPv6 NDP proxy description * zdev: Fix zdev dracut module temp file location * zkey: Correctly detect abbreviated commands * zkey: Validate XTS key: ignore domain and card * zkey: Use octal values instead of S_IRWX* constants * zkey: Properly set umask to prohibit permissions to group and others * zkey: Add -ldl to LDLIBS (not LDFLAGS) * znetconf: Re-add missing line in lsznet.raw * Fix several gcc 7 warnings - Modified s390-tools-sles12-fdasd-skip-partition-check-and-BLKRRPART-ioctl.patch to apply cleanly to this version. - Removed the following obsolete patches: * s390-tools-sles15-zgetdump-Fix-gcc-7-warning.patch * s390-tools-sles15-lscss-Get-rid-of-gcc-7-buffer-truncation-warnings.patch * s390-tools-sles15-Get-rid-of-gcc-7-fall-through-warnings.patch * s390-tools-sles15-lszcrypt-Fix-core-dump-caused-by-stack-overwrite.patch * s390-tools-sles15-dasdinfo-Fix-GCC-7-overflow-warning.patch - Added the following patches (bsc#1056498) - s390-tools-sles15-zgetdump-Fix-gcc-7-warning.patch - s390-tools-sles15-lscss-Get-rid-of-gcc-7-buffer-truncation-warnings.patch - s390-tools-sles15-Get-rid-of-gcc-7-fall-through-warnings.patch - s390-tools-sles15-lszcrypt-Fix-core-dump-caused-by-stack-overwrite.patch - s390-tools-sles15-dasdinfo-Fix-GCC-7-overflow-warning.patch - Upgraded to version 2.0.0 (Fate#323291). - Changes from 1.34.0 to 1.35.0 - cpuplugd: Make default config file location more distribution agnostic Add systemd service unit to start/stop the cpuplug daemon Add force-reload action to init script for LSB-compliance - mon_statd: Add force-reload action to init script for LSB-compliance - chiucvallow: corrected verification return code - lczdev/chzdev: Add support for resolving iSCSI block devices Bug fixes - chzdev, lszdev: Fix incorrect zfcp module parameter name - chreipl: Fix chreipl node for virtio devices - libus2s: Fix busid parsing - zipl/boot: Fix failed start subchannel in FBA loader - Changes from 1.35.0 to 1.36.0 - chzdev/lszdev: Add device resolution for vlan and bonding devices - dasdfmt: Add quick format support - lsdasd/fdasd/dasdfmt/zdsfs: Add query host access to volume support - zfcpdbf: Make timestamp the first field in record output Exclude Payload hex field from log message record output Add Area field to record output Add missing header fields to area record output Print the Record id field for Area area class records Mark oldest and newest trace area records Mark oldest and newest def_err pseudo area records Mark oldest and newest foreign area records Mark oldest and newest log message records Add a warning about low resolution timestamps Add Trace Area Statistics table to script output Add time zone command line option Add collection of domain xml files Bug fixes - zfcpdbf: Move and fix CPU id field output to print_header function Include microseconds in warning threshold calculation Fix parsing of precise syslog timestamps Fix labels for REC ERP action status and ERP step fields - Changes from 1.36.0 to 1.36.1 - zfcpdbf: Support basic HBA record type without warning Restore tracing of handle for port and LUN with HBA records Print full payload for all SAN traces (req, resp, iels) Print payload length everywhere applicable Disambiguate printing of payload record content Bug fixes - fdasd: Prevent buffer overflow - znetconf: Fix detection of chpids as OSX instead of OSM - Changes from 1.36.1 to 1.37.0 - Added dump2tar: sysfs collection helper for dbginfo.sh - qethconf: Remove check for OSN-device - znetconf: Remove OSN-support - lsdasd/tunedasd: Add channel path aware erp - zcrypt: Add multi domain support for zcrypt device driver - scm: Reimplement lsscm in C - chp: Reimplement chchp and lschp in C - dbginfo.sh: Make use of sysinfo collection helper Bug fixes - zfcpdbf: Only cap SAN short payload if pl_len exists - chzdev: Fix bug when configuring QETH devices - libu2s: Prevent buffer overflow - ziomon: No blktrace kill which can corrupt kernel blktrace state - Changes from 1.37.0 to 1.37.1 - dbginfo.sh: Add Docker debug data Bug fixes - lsdasd: Replace continue with return - lscss: Allow to specify devices from subchannel set 3 - mon_fsstatd: Only use physical filesystems Fix double free in error path - mon_procd: Fix segmentation fault - Changes from 1.37.1 to 1.38.0 - systemd: Add new units for cpi, dumpconf, mon_fsstatd, and mon_procd - fdasd: Add new command action 'l' to list known partition types - chmem: Try to online memory to zone movable Starting with kernel 4.13 (commit f1dd2cd1), the default zone for hotplug memory is changed from zone movable to zone normal. In order to preserve the previous default behaviour, chmem will now always try to set memory online to the zone movable, before trying to set it online to the default zone. - zfcpdbf: Print high part of "new" 64 bit SCSI LUN Print payload with full FCP_RSP IU in SCSI trace records - util_opt: Add command specific command line parsing - util_rec: Implement util_rec_iterate() function - util_rec: Record field values can be stored and processed in argz format Bug fixes - zipl/zgetdump: Add missing SCSI multipath dump information to man pages - lsqeth: Fix attributes name: ipa -> ipa_takeover and parp -> rxip Fix lsqeth output of ipa/vipa/rxip addresses of interfaces - zfcpdbf: Fix payload length for zfcp_dbf_hba_bit_err - chzdev: Add implicit qeth layer settings handling - qethqoat: Fix OSA 6S detection - Changes from 1.38.0 to 2.0.0 (also known as 1.39.0) - IBM changed the license to MIT. - Added zkey: Generate, re-encipher, and validate secure AES keys - cpumf: Add hardware counters for z13 and z13s - lscss: Reimplement lscss script in C - lsqeth: Reimplement lsqeth script in C Bug fixes - lscpumf: Fix Perl warnings - Removed the following obsolete patches: s390-tools-sles12sp2-chiucvallow-verify.patch s390-tools-sles12sp2-chreipl-virtio.patch s390-tools-sles12sp2-chzdev-disable-root-update.patch s390-tools-sles12sp2-lscss-allow-to-specify-devices-from-ssid-3.patch s390-tools-sles12sp2-zipl-fix-failed-start-subchannel.patch s390-tools-sles12sp3-chmem-try-to-online-zone-movable.patch s390-tools-sles12sp3-dasdfmt-01-Fix-behaviour-of-t-combined-with-y.patch s390-tools-sles12sp3-dasdfmt-02-Fix-trailing-whitespace.patch s390-tools-sles12sp3-dasdfmt-03-Apply-coding-convention.patch s390-tools-sles12sp3-dasdfmt-04-Use-enhanced-DASD-information.patch s390-tools-sles12sp3-dasdfmt-05-Refactor-do_format_dasd.patch s390-tools-sles12sp3-dasdfmt-06-Make-the-IOCTL-BLKSSZGET-reusable.patch s390-tools-sles12sp3-dasdfmt-07-Add-quick-format-support.patch s390-tools-sles12sp3-dasdfmt-08-Make-progress-output-reusable-and-add-ETR.patch s390-tools-sles12sp3-dasdfmt-09-Add-command-line-argument-check.patch s390-tools-sles12sp3-dasdfmt-10-Add-expand-format-mode.patch s390-tools-sles12sp3-dbginfo-01-libutil-Add-utility-functions.patch s390-tools-sles12sp3-dbginfo-02-dump2tar-Add-sysfs-collection-helper-for-dbginfo.sh-v2.patch s390-tools-sles12sp3-dbginfo-03-dbginfo.sh-Make-use-of-sysinfo-collection-helper.patch s390-tools-sles12sp3-dbginfo-Collect-docker-debug-data.patch s390-tools-sles12sp3-lsdasd-tunedasd-Add-channel-path-aware-erp.patch s390-tools-sles12sp3-mon_fsstatd-fix-double-free-in-error-path-and-skip-virtual-fs.patch s390-tools-sles12sp3-util_proc-fix-memory-allocation-error-messages.patch s390-tools-sles12sp3-ziomon-no-blktrace-kill-which-can-corrupt-kernel-blk.patch - Added s390-tools-sles15-add--ldl-to-LDLIBS.patch to fix a problem with zkey/Makefile. OBS-URL: https://build.opensuse.org/request/show/531958 OBS-URL: https://build.opensuse.org/package/show/Base:System/s390-tools?expand=0&rev=19
2017-10-06 00:49:30 +02:00
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Based on mkdump.sh (c) 2004 Hannes Reinecke, SuSE AG
#
# License:
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
#
########################################################################
use strict;
use warnings;
use Fcntl;
use Getopt::Long;
Accepting request 531958 from home:markkp:branches:Base:System - Modified mkdump perl script to work with the updated version of the IBM tools dasdview, zipl and zgetdump. (bsc#1020336). - Upgraded to version 2.1.0 (Fate#323291). Changes from 2.0.0 to 2.1.0 * Added the following tools: netboot: Scripts for building a PXE-style netboot image for KVM 90-cpi.rules/cpictl: New udev rule to update CPI when KVM is used * Modified lsqeth/zdev to add VNIC Characteristics support Bug fixes * chzcrypt: Corrected handling of insufficient permissions * cpacfstats: Add size setting to perf event * fdasd: Skip partition check with the force option * ttyrun: Fix deprecated BindTo usage in ttyrun-getty@.service.in * lszcrypt: Fix core dump caused by stack overwrite * lszcrypt: Fix random domain printout when no config available * zdev: Fix segfault with unknown qeth attribute * zdev: Fix IPv6 NDP proxy description * zdev: Fix zdev dracut module temp file location * zkey: Correctly detect abbreviated commands * zkey: Validate XTS key: ignore domain and card * zkey: Use octal values instead of S_IRWX* constants * zkey: Properly set umask to prohibit permissions to group and others * zkey: Add -ldl to LDLIBS (not LDFLAGS) * znetconf: Re-add missing line in lsznet.raw * Fix several gcc 7 warnings - Modified s390-tools-sles12-fdasd-skip-partition-check-and-BLKRRPART-ioctl.patch to apply cleanly to this version. - Removed the following obsolete patches: * s390-tools-sles15-zgetdump-Fix-gcc-7-warning.patch * s390-tools-sles15-lscss-Get-rid-of-gcc-7-buffer-truncation-warnings.patch * s390-tools-sles15-Get-rid-of-gcc-7-fall-through-warnings.patch * s390-tools-sles15-lszcrypt-Fix-core-dump-caused-by-stack-overwrite.patch * s390-tools-sles15-dasdinfo-Fix-GCC-7-overflow-warning.patch - Added the following patches (bsc#1056498) - s390-tools-sles15-zgetdump-Fix-gcc-7-warning.patch - s390-tools-sles15-lscss-Get-rid-of-gcc-7-buffer-truncation-warnings.patch - s390-tools-sles15-Get-rid-of-gcc-7-fall-through-warnings.patch - s390-tools-sles15-lszcrypt-Fix-core-dump-caused-by-stack-overwrite.patch - s390-tools-sles15-dasdinfo-Fix-GCC-7-overflow-warning.patch - Upgraded to version 2.0.0 (Fate#323291). - Changes from 1.34.0 to 1.35.0 - cpuplugd: Make default config file location more distribution agnostic Add systemd service unit to start/stop the cpuplug daemon Add force-reload action to init script for LSB-compliance - mon_statd: Add force-reload action to init script for LSB-compliance - chiucvallow: corrected verification return code - lczdev/chzdev: Add support for resolving iSCSI block devices Bug fixes - chzdev, lszdev: Fix incorrect zfcp module parameter name - chreipl: Fix chreipl node for virtio devices - libus2s: Fix busid parsing - zipl/boot: Fix failed start subchannel in FBA loader - Changes from 1.35.0 to 1.36.0 - chzdev/lszdev: Add device resolution for vlan and bonding devices - dasdfmt: Add quick format support - lsdasd/fdasd/dasdfmt/zdsfs: Add query host access to volume support - zfcpdbf: Make timestamp the first field in record output Exclude Payload hex field from log message record output Add Area field to record output Add missing header fields to area record output Print the Record id field for Area area class records Mark oldest and newest trace area records Mark oldest and newest def_err pseudo area records Mark oldest and newest foreign area records Mark oldest and newest log message records Add a warning about low resolution timestamps Add Trace Area Statistics table to script output Add time zone command line option Add collection of domain xml files Bug fixes - zfcpdbf: Move and fix CPU id field output to print_header function Include microseconds in warning threshold calculation Fix parsing of precise syslog timestamps Fix labels for REC ERP action status and ERP step fields - Changes from 1.36.0 to 1.36.1 - zfcpdbf: Support basic HBA record type without warning Restore tracing of handle for port and LUN with HBA records Print full payload for all SAN traces (req, resp, iels) Print payload length everywhere applicable Disambiguate printing of payload record content Bug fixes - fdasd: Prevent buffer overflow - znetconf: Fix detection of chpids as OSX instead of OSM - Changes from 1.36.1 to 1.37.0 - Added dump2tar: sysfs collection helper for dbginfo.sh - qethconf: Remove check for OSN-device - znetconf: Remove OSN-support - lsdasd/tunedasd: Add channel path aware erp - zcrypt: Add multi domain support for zcrypt device driver - scm: Reimplement lsscm in C - chp: Reimplement chchp and lschp in C - dbginfo.sh: Make use of sysinfo collection helper Bug fixes - zfcpdbf: Only cap SAN short payload if pl_len exists - chzdev: Fix bug when configuring QETH devices - libu2s: Prevent buffer overflow - ziomon: No blktrace kill which can corrupt kernel blktrace state - Changes from 1.37.0 to 1.37.1 - dbginfo.sh: Add Docker debug data Bug fixes - lsdasd: Replace continue with return - lscss: Allow to specify devices from subchannel set 3 - mon_fsstatd: Only use physical filesystems Fix double free in error path - mon_procd: Fix segmentation fault - Changes from 1.37.1 to 1.38.0 - systemd: Add new units for cpi, dumpconf, mon_fsstatd, and mon_procd - fdasd: Add new command action 'l' to list known partition types - chmem: Try to online memory to zone movable Starting with kernel 4.13 (commit f1dd2cd1), the default zone for hotplug memory is changed from zone movable to zone normal. In order to preserve the previous default behaviour, chmem will now always try to set memory online to the zone movable, before trying to set it online to the default zone. - zfcpdbf: Print high part of "new" 64 bit SCSI LUN Print payload with full FCP_RSP IU in SCSI trace records - util_opt: Add command specific command line parsing - util_rec: Implement util_rec_iterate() function - util_rec: Record field values can be stored and processed in argz format Bug fixes - zipl/zgetdump: Add missing SCSI multipath dump information to man pages - lsqeth: Fix attributes name: ipa -> ipa_takeover and parp -> rxip Fix lsqeth output of ipa/vipa/rxip addresses of interfaces - zfcpdbf: Fix payload length for zfcp_dbf_hba_bit_err - chzdev: Add implicit qeth layer settings handling - qethqoat: Fix OSA 6S detection - Changes from 1.38.0 to 2.0.0 (also known as 1.39.0) - IBM changed the license to MIT. - Added zkey: Generate, re-encipher, and validate secure AES keys - cpumf: Add hardware counters for z13 and z13s - lscss: Reimplement lscss script in C - lsqeth: Reimplement lsqeth script in C Bug fixes - lscpumf: Fix Perl warnings - Removed the following obsolete patches: s390-tools-sles12sp2-chiucvallow-verify.patch s390-tools-sles12sp2-chreipl-virtio.patch s390-tools-sles12sp2-chzdev-disable-root-update.patch s390-tools-sles12sp2-lscss-allow-to-specify-devices-from-ssid-3.patch s390-tools-sles12sp2-zipl-fix-failed-start-subchannel.patch s390-tools-sles12sp3-chmem-try-to-online-zone-movable.patch s390-tools-sles12sp3-dasdfmt-01-Fix-behaviour-of-t-combined-with-y.patch s390-tools-sles12sp3-dasdfmt-02-Fix-trailing-whitespace.patch s390-tools-sles12sp3-dasdfmt-03-Apply-coding-convention.patch s390-tools-sles12sp3-dasdfmt-04-Use-enhanced-DASD-information.patch s390-tools-sles12sp3-dasdfmt-05-Refactor-do_format_dasd.patch s390-tools-sles12sp3-dasdfmt-06-Make-the-IOCTL-BLKSSZGET-reusable.patch s390-tools-sles12sp3-dasdfmt-07-Add-quick-format-support.patch s390-tools-sles12sp3-dasdfmt-08-Make-progress-output-reusable-and-add-ETR.patch s390-tools-sles12sp3-dasdfmt-09-Add-command-line-argument-check.patch s390-tools-sles12sp3-dasdfmt-10-Add-expand-format-mode.patch s390-tools-sles12sp3-dbginfo-01-libutil-Add-utility-functions.patch s390-tools-sles12sp3-dbginfo-02-dump2tar-Add-sysfs-collection-helper-for-dbginfo.sh-v2.patch s390-tools-sles12sp3-dbginfo-03-dbginfo.sh-Make-use-of-sysinfo-collection-helper.patch s390-tools-sles12sp3-dbginfo-Collect-docker-debug-data.patch s390-tools-sles12sp3-lsdasd-tunedasd-Add-channel-path-aware-erp.patch s390-tools-sles12sp3-mon_fsstatd-fix-double-free-in-error-path-and-skip-virtual-fs.patch s390-tools-sles12sp3-util_proc-fix-memory-allocation-error-messages.patch s390-tools-sles12sp3-ziomon-no-blktrace-kill-which-can-corrupt-kernel-blk.patch - Added s390-tools-sles15-add--ldl-to-LDLIBS.patch to fix a problem with zkey/Makefile. OBS-URL: https://build.opensuse.org/request/show/531958 OBS-URL: https://build.opensuse.org/package/show/Base:System/s390-tools?expand=0&rev=19
2017-10-06 00:49:30 +02:00
my $VERSION = "2.0.3";
my $BLKID = "/sbin/blkid";
my $PARTED = "/usr/sbin/parted";
my $FDASD = "/sbin/fdasd";
my $DASDVIEW = "/sbin/dasdview";
my $DASDFMT = "/sbin/dasdfmt";
my $ZIPL = "/sbin/zipl";
my $UDEVADM = "/sbin/udevadm";
my $ZGETDUMP = "/sbin/zgetdump";
# temporary DASD device configuration file for Zipl
my $MDPATH = "/tmp/mvdump.conf";
# zFCP dump dir, without a leading '/'
my $ZFCP_DUMP_DIR = "mydumps";
my $OPT_DEBUG = 0;
my $OPT_FORCE = 0;
my $OPT_VERBOSE = 0;
sub cleanup
{
# DASD
if (-e $MDPATH) {
system("rm -f $MDPATH");
}
}
sub exit_with
{
my $message = shift();
my $exitcode = shift();
print STDERR "$message Exiting...\n";
cleanup();
# fdasd isn't able to create volume label interactively
# could be fixed with a reformat
if ($exitcode == 65280) {
$exitcode = 12;
}
# bigger exit codes are not supported
if ($exitcode > 255) {
$exitcode = 255;
}
exit($exitcode);
}
sub run_cmd
{
my $cmd = shift();
my $output = "";
if (! $OPT_DEBUG) {
my ($app) = $cmd =~ /\/(\w+) /;
# run command
$output = `$cmd`;
my $exit_code = $?;
# wait for udev to finish processing
system("$UDEVADM settle");
# only print output in case of an error or in verbose mode
if ($output and ($exit_code != 0 or $OPT_VERBOSE)) {
print("$output\n");
}
if ($exit_code != 0) {
exit_with("$app failed with exit code $exit_code", $exit_code);
}
} else {
# only print the command in debug mode
print("\`$cmd\`\n");
}
return($output);
}
sub check_paths
{
for my $path ($BLKID, $PARTED, $FDASD, $DASDVIEW, $DASDFMT, $ZIPL, $UDEVADM, $ZGETDUMP) {
unless ( -x $path) {
exit_with("Command $path is not available.", 13);
}
}
}
sub read_file
{
my $path = shift();
open(my $file, "<", "$path") or exit_with("Unable to access $path: $!.", 15);
my @content = <$file>;
close($file);
# no need for arrays in case of single lines
if (@content > 1) {
return @content;
} else {
chomp($content[0]);
return($content[0]);
}
}
sub is_dasd
{
# remove leading /dev/
my $device = substr(shift(), 5);
if (-r "/sys/block/$device/device/discipline") {
return(1);
} else {
return(0);
}
}
sub is_zfcp
{
# remove leading /dev/
my $device = substr(shift(), 5);
my $devpath = "/sys/block/$device/device";
unless (-r "$devpath/hba_id" or -r "$devpath/type") {
return(0);
}
my $devtype = read_file("$devpath/type");
# SCSI type '0' means disk
if ($devtype == 0) {
return(1);
} else {
return(0);
}
}
sub get_partition_num
{
# remove leading /dev/
my $device = substr(shift, 5);
my $part_num = grep(/\s+$device\d+/, read_file("/proc/partitions"));
return($part_num);
}
sub print_device
{
my $device = shift();
my $only_dump_disks = shift();
my $devpath = "/sys/block/" . substr($device, 5);
my $output = $device;
my $dump_device = 0;
my $size = int(read_file("$devpath/size") / 2048); # 512 Byte blocks
# size can't be read this way in case of unformatted devices
if ($size != 0) {
$output .= "\t${size}MB";
} else {
$output .= "\tunknown";
}
if (is_dasd($device)) {
my ($busid) = readlink("$devpath/device") =~ /(\w\.\w\.\w{4})/;
$output .= "\t$busid";
# check for dump record and list multi volumes
my $zgetdump_output = `$ZGETDUMP -d $device 2>&1`;
my @dump_devs = $zgetdump_output =~ /(\w\.\w\.\w{4})/g;
if (@dump_devs) {
$dump_device = 1;
$output .= "\tdumpdevice";
# no need to output the dump ids for a single device
if (@dump_devs > 1) {
for my $id (@dump_devs) {
$output .= "|$id";
}
}
} else {
# check for single volume dump devices
if ($zgetdump_output =~ /Single-volume DASD dump tool/) {
$dump_device = 1;
$output .= "\tdumpdevice";
}
}
} else {
my $adapter = read_file("$devpath/device/hba_id");
my $wwpn = read_file("$devpath/device/wwpn");
my $lun = read_file("$devpath/device/fcp_lun");
$output .= "\t$adapter\t$wwpn\t$lun";
# check for dump record
my $zgetdump = `$ZGETDUMP -d $device 2>&1`;
if ($? == 0) {
my ($dsize) = ($zgetdump =~ /Maximum dump size\.:\s+([0-9]+) MB/m);
$dsize = $size unless (defined($dsize));
$output = "$device\t${dsize}MB\t$adapter\t$wwpn\t$lun\tdumpdevice";
Accepting request 531958 from home:markkp:branches:Base:System - Modified mkdump perl script to work with the updated version of the IBM tools dasdview, zipl and zgetdump. (bsc#1020336). - Upgraded to version 2.1.0 (Fate#323291). Changes from 2.0.0 to 2.1.0 * Added the following tools: netboot: Scripts for building a PXE-style netboot image for KVM 90-cpi.rules/cpictl: New udev rule to update CPI when KVM is used * Modified lsqeth/zdev to add VNIC Characteristics support Bug fixes * chzcrypt: Corrected handling of insufficient permissions * cpacfstats: Add size setting to perf event * fdasd: Skip partition check with the force option * ttyrun: Fix deprecated BindTo usage in ttyrun-getty@.service.in * lszcrypt: Fix core dump caused by stack overwrite * lszcrypt: Fix random domain printout when no config available * zdev: Fix segfault with unknown qeth attribute * zdev: Fix IPv6 NDP proxy description * zdev: Fix zdev dracut module temp file location * zkey: Correctly detect abbreviated commands * zkey: Validate XTS key: ignore domain and card * zkey: Use octal values instead of S_IRWX* constants * zkey: Properly set umask to prohibit permissions to group and others * zkey: Add -ldl to LDLIBS (not LDFLAGS) * znetconf: Re-add missing line in lsznet.raw * Fix several gcc 7 warnings - Modified s390-tools-sles12-fdasd-skip-partition-check-and-BLKRRPART-ioctl.patch to apply cleanly to this version. - Removed the following obsolete patches: * s390-tools-sles15-zgetdump-Fix-gcc-7-warning.patch * s390-tools-sles15-lscss-Get-rid-of-gcc-7-buffer-truncation-warnings.patch * s390-tools-sles15-Get-rid-of-gcc-7-fall-through-warnings.patch * s390-tools-sles15-lszcrypt-Fix-core-dump-caused-by-stack-overwrite.patch * s390-tools-sles15-dasdinfo-Fix-GCC-7-overflow-warning.patch - Added the following patches (bsc#1056498) - s390-tools-sles15-zgetdump-Fix-gcc-7-warning.patch - s390-tools-sles15-lscss-Get-rid-of-gcc-7-buffer-truncation-warnings.patch - s390-tools-sles15-Get-rid-of-gcc-7-fall-through-warnings.patch - s390-tools-sles15-lszcrypt-Fix-core-dump-caused-by-stack-overwrite.patch - s390-tools-sles15-dasdinfo-Fix-GCC-7-overflow-warning.patch - Upgraded to version 2.0.0 (Fate#323291). - Changes from 1.34.0 to 1.35.0 - cpuplugd: Make default config file location more distribution agnostic Add systemd service unit to start/stop the cpuplug daemon Add force-reload action to init script for LSB-compliance - mon_statd: Add force-reload action to init script for LSB-compliance - chiucvallow: corrected verification return code - lczdev/chzdev: Add support for resolving iSCSI block devices Bug fixes - chzdev, lszdev: Fix incorrect zfcp module parameter name - chreipl: Fix chreipl node for virtio devices - libus2s: Fix busid parsing - zipl/boot: Fix failed start subchannel in FBA loader - Changes from 1.35.0 to 1.36.0 - chzdev/lszdev: Add device resolution for vlan and bonding devices - dasdfmt: Add quick format support - lsdasd/fdasd/dasdfmt/zdsfs: Add query host access to volume support - zfcpdbf: Make timestamp the first field in record output Exclude Payload hex field from log message record output Add Area field to record output Add missing header fields to area record output Print the Record id field for Area area class records Mark oldest and newest trace area records Mark oldest and newest def_err pseudo area records Mark oldest and newest foreign area records Mark oldest and newest log message records Add a warning about low resolution timestamps Add Trace Area Statistics table to script output Add time zone command line option Add collection of domain xml files Bug fixes - zfcpdbf: Move and fix CPU id field output to print_header function Include microseconds in warning threshold calculation Fix parsing of precise syslog timestamps Fix labels for REC ERP action status and ERP step fields - Changes from 1.36.0 to 1.36.1 - zfcpdbf: Support basic HBA record type without warning Restore tracing of handle for port and LUN with HBA records Print full payload for all SAN traces (req, resp, iels) Print payload length everywhere applicable Disambiguate printing of payload record content Bug fixes - fdasd: Prevent buffer overflow - znetconf: Fix detection of chpids as OSX instead of OSM - Changes from 1.36.1 to 1.37.0 - Added dump2tar: sysfs collection helper for dbginfo.sh - qethconf: Remove check for OSN-device - znetconf: Remove OSN-support - lsdasd/tunedasd: Add channel path aware erp - zcrypt: Add multi domain support for zcrypt device driver - scm: Reimplement lsscm in C - chp: Reimplement chchp and lschp in C - dbginfo.sh: Make use of sysinfo collection helper Bug fixes - zfcpdbf: Only cap SAN short payload if pl_len exists - chzdev: Fix bug when configuring QETH devices - libu2s: Prevent buffer overflow - ziomon: No blktrace kill which can corrupt kernel blktrace state - Changes from 1.37.0 to 1.37.1 - dbginfo.sh: Add Docker debug data Bug fixes - lsdasd: Replace continue with return - lscss: Allow to specify devices from subchannel set 3 - mon_fsstatd: Only use physical filesystems Fix double free in error path - mon_procd: Fix segmentation fault - Changes from 1.37.1 to 1.38.0 - systemd: Add new units for cpi, dumpconf, mon_fsstatd, and mon_procd - fdasd: Add new command action 'l' to list known partition types - chmem: Try to online memory to zone movable Starting with kernel 4.13 (commit f1dd2cd1), the default zone for hotplug memory is changed from zone movable to zone normal. In order to preserve the previous default behaviour, chmem will now always try to set memory online to the zone movable, before trying to set it online to the default zone. - zfcpdbf: Print high part of "new" 64 bit SCSI LUN Print payload with full FCP_RSP IU in SCSI trace records - util_opt: Add command specific command line parsing - util_rec: Implement util_rec_iterate() function - util_rec: Record field values can be stored and processed in argz format Bug fixes - zipl/zgetdump: Add missing SCSI multipath dump information to man pages - lsqeth: Fix attributes name: ipa -> ipa_takeover and parp -> rxip Fix lsqeth output of ipa/vipa/rxip addresses of interfaces - zfcpdbf: Fix payload length for zfcp_dbf_hba_bit_err - chzdev: Add implicit qeth layer settings handling - qethqoat: Fix OSA 6S detection - Changes from 1.38.0 to 2.0.0 (also known as 1.39.0) - IBM changed the license to MIT. - Added zkey: Generate, re-encipher, and validate secure AES keys - cpumf: Add hardware counters for z13 and z13s - lscss: Reimplement lscss script in C - lsqeth: Reimplement lsqeth script in C Bug fixes - lscpumf: Fix Perl warnings - Removed the following obsolete patches: s390-tools-sles12sp2-chiucvallow-verify.patch s390-tools-sles12sp2-chreipl-virtio.patch s390-tools-sles12sp2-chzdev-disable-root-update.patch s390-tools-sles12sp2-lscss-allow-to-specify-devices-from-ssid-3.patch s390-tools-sles12sp2-zipl-fix-failed-start-subchannel.patch s390-tools-sles12sp3-chmem-try-to-online-zone-movable.patch s390-tools-sles12sp3-dasdfmt-01-Fix-behaviour-of-t-combined-with-y.patch s390-tools-sles12sp3-dasdfmt-02-Fix-trailing-whitespace.patch s390-tools-sles12sp3-dasdfmt-03-Apply-coding-convention.patch s390-tools-sles12sp3-dasdfmt-04-Use-enhanced-DASD-information.patch s390-tools-sles12sp3-dasdfmt-05-Refactor-do_format_dasd.patch s390-tools-sles12sp3-dasdfmt-06-Make-the-IOCTL-BLKSSZGET-reusable.patch s390-tools-sles12sp3-dasdfmt-07-Add-quick-format-support.patch s390-tools-sles12sp3-dasdfmt-08-Make-progress-output-reusable-and-add-ETR.patch s390-tools-sles12sp3-dasdfmt-09-Add-command-line-argument-check.patch s390-tools-sles12sp3-dasdfmt-10-Add-expand-format-mode.patch s390-tools-sles12sp3-dbginfo-01-libutil-Add-utility-functions.patch s390-tools-sles12sp3-dbginfo-02-dump2tar-Add-sysfs-collection-helper-for-dbginfo.sh-v2.patch s390-tools-sles12sp3-dbginfo-03-dbginfo.sh-Make-use-of-sysinfo-collection-helper.patch s390-tools-sles12sp3-dbginfo-Collect-docker-debug-data.patch s390-tools-sles12sp3-lsdasd-tunedasd-Add-channel-path-aware-erp.patch s390-tools-sles12sp3-mon_fsstatd-fix-double-free-in-error-path-and-skip-virtual-fs.patch s390-tools-sles12sp3-util_proc-fix-memory-allocation-error-messages.patch s390-tools-sles12sp3-ziomon-no-blktrace-kill-which-can-corrupt-kernel-blk.patch - Added s390-tools-sles15-add--ldl-to-LDLIBS.patch to fix a problem with zkey/Makefile. OBS-URL: https://build.opensuse.org/request/show/531958 OBS-URL: https://build.opensuse.org/package/show/Base:System/s390-tools?expand=0&rev=19
2017-10-06 00:49:30 +02:00
$dump_device = 1;
}
}
if ($only_dump_disks) {
if ($dump_device) {
print("$output\n");
}
} else {
print("$output\n");
}
}
sub list_free_disks
{
my $devices_ref = shift();
my $type = shift();
if (@$devices_ref) {
for my $device (@$devices_ref) {
print_device($device);
}
} else {
print STDERR "No free $type devices available!\n";
}
}
sub list_dump_disks
{
my @devices = @_;
if (@devices) {
for my $device (@devices) {
print_device($device, 1);
}
} else {
print STDERR "No dump devices available!\n";
}
}
sub determine_free_disks
{
my @dasd;
my @zfcp;
my @devices;
# gather block devices
my $path="/sys/block/";
opendir(DIR, $path) or exit_with("Unable to find $path: $!", 15);
while (defined(my $file = readdir(DIR))) {
# no need to add other devices then dasd* or sd*
if ($file =~ /^dasd[a-z]+$/ or $file =~ /^sd[a-z]+$/) {
push(@devices, $file);
}
}
closedir(DIR);
for my $entry (@devices) {
# only allow disks, no partitions
my ($device) = $entry =~ /^([a-z]+)$/;
next unless ($device);
$device = "/dev/$device";
# determine if the block device could be accessed exclusively
if(-b $device and sysopen(my $blockdev, $device, O_RDWR|O_EXCL)) {
close($blockdev);
if (is_dasd($device)) {
push(@dasd, $device);
}
if (is_zfcp($device)) {
push(@zfcp, $device);
}
}
# wait for udev to process all events triggered by sysopen(,O_EXCL)
system("$UDEVADM settle");
}
return(\@dasd, \@zfcp);
}
sub prepare_dasd
{
my @devices = @_;
my $format_disks = "";
# check formatting
for my $device (@devices) {
# determine disk layout
Accepting request 531958 from home:markkp:branches:Base:System - Modified mkdump perl script to work with the updated version of the IBM tools dasdview, zipl and zgetdump. (bsc#1020336). - Upgraded to version 2.1.0 (Fate#323291). Changes from 2.0.0 to 2.1.0 * Added the following tools: netboot: Scripts for building a PXE-style netboot image for KVM 90-cpi.rules/cpictl: New udev rule to update CPI when KVM is used * Modified lsqeth/zdev to add VNIC Characteristics support Bug fixes * chzcrypt: Corrected handling of insufficient permissions * cpacfstats: Add size setting to perf event * fdasd: Skip partition check with the force option * ttyrun: Fix deprecated BindTo usage in ttyrun-getty@.service.in * lszcrypt: Fix core dump caused by stack overwrite * lszcrypt: Fix random domain printout when no config available * zdev: Fix segfault with unknown qeth attribute * zdev: Fix IPv6 NDP proxy description * zdev: Fix zdev dracut module temp file location * zkey: Correctly detect abbreviated commands * zkey: Validate XTS key: ignore domain and card * zkey: Use octal values instead of S_IRWX* constants * zkey: Properly set umask to prohibit permissions to group and others * zkey: Add -ldl to LDLIBS (not LDFLAGS) * znetconf: Re-add missing line in lsznet.raw * Fix several gcc 7 warnings - Modified s390-tools-sles12-fdasd-skip-partition-check-and-BLKRRPART-ioctl.patch to apply cleanly to this version. - Removed the following obsolete patches: * s390-tools-sles15-zgetdump-Fix-gcc-7-warning.patch * s390-tools-sles15-lscss-Get-rid-of-gcc-7-buffer-truncation-warnings.patch * s390-tools-sles15-Get-rid-of-gcc-7-fall-through-warnings.patch * s390-tools-sles15-lszcrypt-Fix-core-dump-caused-by-stack-overwrite.patch * s390-tools-sles15-dasdinfo-Fix-GCC-7-overflow-warning.patch - Added the following patches (bsc#1056498) - s390-tools-sles15-zgetdump-Fix-gcc-7-warning.patch - s390-tools-sles15-lscss-Get-rid-of-gcc-7-buffer-truncation-warnings.patch - s390-tools-sles15-Get-rid-of-gcc-7-fall-through-warnings.patch - s390-tools-sles15-lszcrypt-Fix-core-dump-caused-by-stack-overwrite.patch - s390-tools-sles15-dasdinfo-Fix-GCC-7-overflow-warning.patch - Upgraded to version 2.0.0 (Fate#323291). - Changes from 1.34.0 to 1.35.0 - cpuplugd: Make default config file location more distribution agnostic Add systemd service unit to start/stop the cpuplug daemon Add force-reload action to init script for LSB-compliance - mon_statd: Add force-reload action to init script for LSB-compliance - chiucvallow: corrected verification return code - lczdev/chzdev: Add support for resolving iSCSI block devices Bug fixes - chzdev, lszdev: Fix incorrect zfcp module parameter name - chreipl: Fix chreipl node for virtio devices - libus2s: Fix busid parsing - zipl/boot: Fix failed start subchannel in FBA loader - Changes from 1.35.0 to 1.36.0 - chzdev/lszdev: Add device resolution for vlan and bonding devices - dasdfmt: Add quick format support - lsdasd/fdasd/dasdfmt/zdsfs: Add query host access to volume support - zfcpdbf: Make timestamp the first field in record output Exclude Payload hex field from log message record output Add Area field to record output Add missing header fields to area record output Print the Record id field for Area area class records Mark oldest and newest trace area records Mark oldest and newest def_err pseudo area records Mark oldest and newest foreign area records Mark oldest and newest log message records Add a warning about low resolution timestamps Add Trace Area Statistics table to script output Add time zone command line option Add collection of domain xml files Bug fixes - zfcpdbf: Move and fix CPU id field output to print_header function Include microseconds in warning threshold calculation Fix parsing of precise syslog timestamps Fix labels for REC ERP action status and ERP step fields - Changes from 1.36.0 to 1.36.1 - zfcpdbf: Support basic HBA record type without warning Restore tracing of handle for port and LUN with HBA records Print full payload for all SAN traces (req, resp, iels) Print payload length everywhere applicable Disambiguate printing of payload record content Bug fixes - fdasd: Prevent buffer overflow - znetconf: Fix detection of chpids as OSX instead of OSM - Changes from 1.36.1 to 1.37.0 - Added dump2tar: sysfs collection helper for dbginfo.sh - qethconf: Remove check for OSN-device - znetconf: Remove OSN-support - lsdasd/tunedasd: Add channel path aware erp - zcrypt: Add multi domain support for zcrypt device driver - scm: Reimplement lsscm in C - chp: Reimplement chchp and lschp in C - dbginfo.sh: Make use of sysinfo collection helper Bug fixes - zfcpdbf: Only cap SAN short payload if pl_len exists - chzdev: Fix bug when configuring QETH devices - libu2s: Prevent buffer overflow - ziomon: No blktrace kill which can corrupt kernel blktrace state - Changes from 1.37.0 to 1.37.1 - dbginfo.sh: Add Docker debug data Bug fixes - lsdasd: Replace continue with return - lscss: Allow to specify devices from subchannel set 3 - mon_fsstatd: Only use physical filesystems Fix double free in error path - mon_procd: Fix segmentation fault - Changes from 1.37.1 to 1.38.0 - systemd: Add new units for cpi, dumpconf, mon_fsstatd, and mon_procd - fdasd: Add new command action 'l' to list known partition types - chmem: Try to online memory to zone movable Starting with kernel 4.13 (commit f1dd2cd1), the default zone for hotplug memory is changed from zone movable to zone normal. In order to preserve the previous default behaviour, chmem will now always try to set memory online to the zone movable, before trying to set it online to the default zone. - zfcpdbf: Print high part of "new" 64 bit SCSI LUN Print payload with full FCP_RSP IU in SCSI trace records - util_opt: Add command specific command line parsing - util_rec: Implement util_rec_iterate() function - util_rec: Record field values can be stored and processed in argz format Bug fixes - zipl/zgetdump: Add missing SCSI multipath dump information to man pages - lsqeth: Fix attributes name: ipa -> ipa_takeover and parp -> rxip Fix lsqeth output of ipa/vipa/rxip addresses of interfaces - zfcpdbf: Fix payload length for zfcp_dbf_hba_bit_err - chzdev: Add implicit qeth layer settings handling - qethqoat: Fix OSA 6S detection - Changes from 1.38.0 to 2.0.0 (also known as 1.39.0) - IBM changed the license to MIT. - Added zkey: Generate, re-encipher, and validate secure AES keys - cpumf: Add hardware counters for z13 and z13s - lscss: Reimplement lscss script in C - lsqeth: Reimplement lsqeth script in C Bug fixes - lscpumf: Fix Perl warnings - Removed the following obsolete patches: s390-tools-sles12sp2-chiucvallow-verify.patch s390-tools-sles12sp2-chreipl-virtio.patch s390-tools-sles12sp2-chzdev-disable-root-update.patch s390-tools-sles12sp2-lscss-allow-to-specify-devices-from-ssid-3.patch s390-tools-sles12sp2-zipl-fix-failed-start-subchannel.patch s390-tools-sles12sp3-chmem-try-to-online-zone-movable.patch s390-tools-sles12sp3-dasdfmt-01-Fix-behaviour-of-t-combined-with-y.patch s390-tools-sles12sp3-dasdfmt-02-Fix-trailing-whitespace.patch s390-tools-sles12sp3-dasdfmt-03-Apply-coding-convention.patch s390-tools-sles12sp3-dasdfmt-04-Use-enhanced-DASD-information.patch s390-tools-sles12sp3-dasdfmt-05-Refactor-do_format_dasd.patch s390-tools-sles12sp3-dasdfmt-06-Make-the-IOCTL-BLKSSZGET-reusable.patch s390-tools-sles12sp3-dasdfmt-07-Add-quick-format-support.patch s390-tools-sles12sp3-dasdfmt-08-Make-progress-output-reusable-and-add-ETR.patch s390-tools-sles12sp3-dasdfmt-09-Add-command-line-argument-check.patch s390-tools-sles12sp3-dasdfmt-10-Add-expand-format-mode.patch s390-tools-sles12sp3-dbginfo-01-libutil-Add-utility-functions.patch s390-tools-sles12sp3-dbginfo-02-dump2tar-Add-sysfs-collection-helper-for-dbginfo.sh-v2.patch s390-tools-sles12sp3-dbginfo-03-dbginfo.sh-Make-use-of-sysinfo-collection-helper.patch s390-tools-sles12sp3-dbginfo-Collect-docker-debug-data.patch s390-tools-sles12sp3-lsdasd-tunedasd-Add-channel-path-aware-erp.patch s390-tools-sles12sp3-mon_fsstatd-fix-double-free-in-error-path-and-skip-virtual-fs.patch s390-tools-sles12sp3-util_proc-fix-memory-allocation-error-messages.patch s390-tools-sles12sp3-ziomon-no-blktrace-kill-which-can-corrupt-kernel-blk.patch - Added s390-tools-sles15-add--ldl-to-LDLIBS.patch to fix a problem with zkey/Makefile. OBS-URL: https://build.opensuse.org/request/show/531958 OBS-URL: https://build.opensuse.org/package/show/Base:System/s390-tools?expand=0&rev=19
2017-10-06 00:49:30 +02:00
my ($fmtstr) = `$DASDVIEW -x $device` =~ /(\w\w\w) formatted/;
SWITCH:
for($fmtstr) {
if (/NOT/) {
print("Unformatted disk, formatting $device.\n");
$format_disks .= " $device";
last SWITCH;
}
if (/LDL/) {
if ($OPT_FORCE) {
print("Linux disk layout, reformatting $device.\n");
$format_disks .= " $device";
} else {
print("$device was formatted with the Linux disk layout.\n");
print("Unable to use it without reformatting.\n");
exit_with("Re-issue the mkdump command with the --force option.", 12);
}
last SWITCH;
}
if (/CDL/) {
# allow reformatting with force, since fdasd isn't able to create volume label interactively
if ($OPT_FORCE) {
print("Compatible disk layout, force reformatting $device.\n");
$format_disks .= " $device";
} else {
print("$device: Compatible disk layout, Ok to use.\n");
}
last SWITCH;
}
exit_with("Unknown layout ($fmtstr), cannot use disk.", 11);
}
}
# format devices
if ($format_disks) {
#up to eight devices in parallel
run_cmd("$DASDFMT -P 8 -b 4096 -y -f $format_disks");
}
# check partitioning and partition
for my $device (@devices) {
my $part_num = get_partition_num($device);
if ($part_num == 0 or $OPT_FORCE) {
print("Re-partitioning disk $device.\n");
run_cmd("$FDASD -a $device");
} else {
# allow disk with one partition if it don't consist a file system
if ($part_num == 1) {
my ($fstype) = `$BLKID ${device}1` =~ /TYPE=\"(\w+)\"/;
if ($fstype) {
exit_with("Device ${device}1 already contains a filesystem of type $fstype.", 12);
}
} else {
exit_with("$part_num partitions detected, cannot use disk $device.", 12);
}
}
}
}
sub setup_dasddump
{
my @devices = @_;
prepare_dasd(@devices);
# create zipl device configuration file
my $md_path = "/tmp/mvdump.conf";
# don't create files in debug mode
unless ($OPT_DEBUG) {
open(my $file, ">", $md_path) or exit_with("Unable to access $md_path: $!.", 15);
for my $device (@devices) {
print{$file}("${device}1\n");
}
close($file);
}
print("Creating dump record.\n");
run_cmd("${ZIPL} -V -n -M $md_path");
cleanup();
}
sub setup_zfcpdump
{
my $device = shift();
# check partitioning
my $part_num = get_partition_num($device);
if ($part_num == 0 or $OPT_FORCE) {
print("Re-partitioning disk $device.\n");
run_cmd("$PARTED -s -- $device mklabel gpt mkpart primary 0 -1");
} else {
if ($part_num > 1) {
exit_with("$part_num partitions detected, cannot use disk $device.", 12);
}
}
# install bootloader
print("Creating dump record.\n");
run_cmd("${ZIPL} -V -d ${device}1");
cleanup();
}
sub print_version
{
print << "EOF";
mkdump $VERSION
Copyright (c) 2011 SUSE LINUX Products GmbH
License GPLv2 or (at your option) any later version.
<http://www.gnu.org/licenses/gpl-2.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Tim Hardeck <thardeck\@suse.de>.
EOF
exit(0);
}
sub print_usage
{
my $exitcode = shift();
print << "EOF";
Usage: mkdump [OPTIONS] [DEVICE]...
mkdump $VERSION
Prepare one or more volumes for use as S/390 dump device. Supported devices
are ECKD DASD and SCSI over zFCP disks, while multi-volumes are limited to DASD.
Only whole disks can be used, no partitions! If the device is incompatible
formatted/partioned, the script will refuse to install the dump record
unless the --force switch is given.
Disks which are in use or have mounted partitions will not be listed and can't be used.
The mentioning of "dumpdevice" after a disk indicates that it is an already usable dump device. Additionally multi-volume dump devices are indicated by the list of including DASD ids.
Options:
-h, --help display this help and exit
-V, --version display version information and exit
-d, --debug debug mode, do not run programs which commit changes
-v, --verbose be verbose and show command outputs
-f, --force force overwrite of the disk
-l, --list-dump display dump disks
-D, --list-dasd display usable DASD disks (Device, Size, ID, Dump)
-Z, --list-zfcp display usable SCSI over zFCP disks (Device, Size, ID, WWPN, LUN, Dump)
Report bugs on https://bugzilla.novell.com/
EOF
exit($exitcode);
}
sub analyze_cmd_parameters
{
#verbose, debug and force are global
my $opt_help = 0;
my $opt_version = 0;
my $opt_dump = 0;
my $opt_dasd = 0;
my $opt_zfcp = 0;
if (@ARGV == 0) {
print_usage(14);
}
Getopt::Long::Configure('bundling');
GetOptions(
'h|help' => \$opt_help,
'V|version' => \$opt_version,
'd|debug' => \$OPT_DEBUG,
'v|verbose' => \$OPT_VERBOSE,
'f|force' => \$OPT_FORCE,
'l|list-dump' => \$opt_dump,
'D|list-dasd' => \$opt_dasd,
'Z|list-zfcp' => \$opt_zfcp,
) or print_usage(14);
if ($opt_help) {
print_usage(0);
}
if ($opt_version) {
print_version();
}
# determine free dasd and zfcp devices
my ($dasd_ref, $zfcp_ref) = determine_free_disks();
if ($opt_dump) {
list_dump_disks(@$dasd_ref, @$zfcp_ref);
exit 0;
}
if ($opt_dasd) {
list_free_disks(\@$dasd_ref, "dasd");
}
if ($opt_zfcp) {
list_free_disks(\@$zfcp_ref, "zfcp");
}
# allow listing of both device types at the same time
if ($opt_dasd or $opt_zfcp) {
exit 0;
}
# check provided devices and be strict
my @devices;
for my $device (@ARGV) {
if (grep(/$device/, @devices)) {
exit_with("$device is mentioned more than once.", 14);
}
if ( $device =~ /^\/dev\/[a-z]+$/ == 0) {
exit_with("The device parameter $device is inaccurate. Only whole disks are allowed.", 14);
}
if (grep(/$device/, (@$dasd_ref, @$zfcp_ref))) {
if (is_zfcp($device) and @ARGV > 1) {
exit_with("Multi-volume dumps aren't supported with zFCP.", 14);
}
push(@devices, $device);
} else {
if (-b $device) {
exit_with("$device is in use or not a DASD/zFCP disk!", 14);
} else {
exit_with("$device does not exist!", 14);
}
}
}
if (@devices == 0) {
exit_with("No usable devices where provided.", 14);
}
return(@devices);
}
sub main
{
check_paths();
my @devices = analyze_cmd_parameters();
# only one dump device is possible with zFCP which is enforced in analyze_cmd_parameters
if (is_zfcp($devices[0])) {
setup_zfcpdump($devices[0]);
} else {
setup_dasddump(@devices);
}
print("Creating the dump device was successful.\n");
}
main();