Compare commits

...

206 Commits

Author SHA1 Message Date
Jan Höppner
3f1bd3bb66 New release s390-tools-2.5.0
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Dan Horák
0fbc4edd29 zipl: Compute the bootloader stage size to workaround PIE
Closes: #30
Signed-off-by: Dan Horák <dan@danny.cz>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Javier Martinez Canillas
b8a9f0d1d3 scripts: Add script to switch zipl config to a BootLoaderSpec setup
Add a zipl-switch-to-blscfg script that can be used to switch the zipl
configuration in a system to use the BootLoaderSpec (BLS) config files
to define the IPL sections instead of having them defined in zipl.conf.

Closes: #28
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Javier Martinez Canillas
d280e5b1fa zipl: Add BootLoaderSpec support
The BootLoaderSpec (BLS) defines a file format for boot configurations,
so bootloaders can parse these files and create their boot menu entries
by using the information provided by them [0].

This allow to configure the boot items as drop-in files in a directory
instead of having to parse and modify a bootloader configuration file.

If the /boot/loader/entries exists and there are BLS files there, then
these are parsed and configuration sections are added without the need
to have these in a zipl.conf file.

A different BLS directory can be specified from the command line using
the --blsdir option.

[0]: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/

GitHub-ID: #28
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Javier Martinez Canillas
e04acab0ed zipl: Return number of allocated tokens in scan_file()
The function returns 0 on success and a negative number on error but is
useful to know how many tokens were allocated. This will be used by the
BLS parsing code to determine if needs to allocate mor tokens or not to
parse the BLS fragments.

GitHub-ID: #28
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Jens Remus
d868ce5ec7 lsluns: print a message if no adapter or port exists
lsluns lists nothing and returns with return code 0 if no adapter (FCP
device) or target port exists in sysfs. This can be confusing for the user.

Print a message if no adapter exists. Print a message if no port exists on
any adapter.

Reported-by: Thorsten Diehl <thorsten.diehl@de.ibm.com>
Suggested-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Ingo Franzki
dec58c349e zkey: Typo in message
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Peter Oberparleiter
d82f5e1f49 zdev: Fix blocking chzdev call/udev rules with cmb_enable
Changing the cmb_enable attribute of a CCW device can cause a blocked
chzdev process or udev rule. This problem occurs when the device is
offline, cmb_enable is 0, and chzdev is used to set cmb_enable=1 and
online=1 at the same time.

The following call will block:

chzdev 190d -a cmb_enable=1 online=1

The following call will generate a udev rule that will block subsequent
calls to 'udevadm settle':

chzdev 190d -p online=1 cmb_enable=1

Fix this by ensuring that cmb_enable is only set when the CCW device
is not online.

Reported-by: André Wild <wild@linux.vnet.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Peter Oberparleiter
156450f359 zdev: Implement support for early device configuration
Enable user to specify that a device should be configured early, that is
during the initial RAM-disk boot phase. This may be necessary, e.g. to
override auto-configuration for a device which is also applied during
that boot phase. It may also be used to manually specify devices that
are required to access the root file system, such as networking devices.

Users can mark devices as requiring early configuration by specifying
a value of 1 for the newly added internal attribute zdev:early:

 # chzdev dasd-eckd 0.0.1234 -p zdev:early=1

This can be changed back by removing the attribute setting, or by
setting the attribute value to 0:

 # chzdev dasd-eckd 0.0.1234 -p -r zdev:early

or

 # chzdev dasd-eckd 0.0.1234 -p zdev:early=0

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Peter Oberparleiter
c0392efa39 zdev: Implement internal device attributes
This change adds base infrastructure for implementing internal device
attributes. In the context of the zdev tools, an internal device
attribute is a new type of device attribute with the following
characteristics:

  - Can be set and removed like normal device attributes
  - Affects zdev-internal handling only
  - Does not correspond to an actual device attribute, that is
    it has no representation in SysFS
  - Can not be set in the active configuration
  - Name starts with "zdev:" to prevent conflicts with actual
    device attributes

Values for internal device attributes are stored in udev rules alongside
the normal persistent configuration of a device. They are encoded as
udev environment variables. Note that they have no further effect on
udev processing.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Peter Oberparleiter
3c5644ccfd zdev: Integrate firmware auto-configuration with initramfs-tools
Add initramfs-tools scripts that apply firmware-provided I/O
configuration data as auto-configuration during boot. This way, all I/O
devices configured by DPM are automatically brought online without
further user interaction.

This mechanism is active by default. It can be deactivated by specifying
the following parameter on the kernel command line:

  rd.zdev=no-auto

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Peter Oberparleiter
3fb356ebd2 zdev: Integrate firmware auto-configuration with dracut
Add a dracut hook that applies firmware-provided I/O configuration data
as auto-configuration during boot. This way, all I/O devices configured
by DPM are automatically brought online without further user
interaction.

This mechanism is active by default. It can be deactivated by specifying
the following parameter on the kernel command line:

  rd.zdev=no-auto

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Peter Oberparleiter
fe68ec513d zdev: Add support for handling auto-configuration data
Auto-configuration is the name of a new configuration target that is
supported by chzdev and lszdev besides the existing active and
persistent configuration targets. Directives created in this new
configuration are stored as udev rules in the /run/udev/rules.d
directory.

Auto-configuration directives are only in effect if there are no
directives for the same device in the user-provided persistent
configuration. This allows users to override auto-configuration
directives if necessary.

Due to the volatile nature of the /run directory, auto-configuration
directives are cleared on reboot. Therefore mechanisms that generate
auto-configuration directives must recreate them on every boot.

The lszdev tool displays auto-configuration data both in list view
as well as in detail view. Users can specify the new option --auto-conf
to only show data from this configuration target.

Mechanisms that generate automated configuration directives can use
chzdev together with the --auto-conf option to create the corresponding
udev rules.

Note: This change does not include a mechanism that generates
      auto-configuration directives.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Peter Oberparleiter
a86fb8b091 zdev: Write zfcp-lun udev rules to separate files
Change chzdev's udev rule generation from the previous approach of
combining all zfcp-lun udev rules associated with an FCP device into a
single file to storing zfcp-lun udev rules in one file per zfcp-lun.
This is done to enable per-device udev rule masking.

With udev rule masking, if a udev rule file by the same name exists in
both /etc and /run, the udev daemon will only consider the rules found
in /etc.

The auto-configuration feature will make use of per-device udev rule
masking to introduce a new class of configuration data (stored in /run)
that is only active if no user-provided configuration data (in /etc)
exists.

In addition, change chzdev to allow the regeneration of udev rules by
using the --force command line like in the following example:

 # chzdev zfcp-lun --configured --enable --persistent --force

This can be used to convert all existing zfcp-lun udev rules from the
old format to the new one.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Peter Oberparleiter
f32bff9688 zdev: Implement --no-settle
There are some situations where running "udevadm settle" can result in
a deadlock, such as in the early stages of initial RAM-disk processing.

Introduce a new command-line option --no-settle that can be used to
suppress calling "udevadm settle" to allow chzdev to be run in such
situations.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Peter Oberparleiter
7d355b0fec zdev: Add support for reading firmware configuration files
Add support for reading firmware-provided I/O configuration data files.
Such configuration files are generated by the Dynamic Partition Manager
and made available via a kernel interface for consumption by Linux.

To read a firmware configuration file, use the existing --import option:

 # chzdev --import /sys/firmware/sclp_sd/config/data

This will apply all I/O configuration data found in the specified file
to the persistent configuration.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Peter Oberparleiter
ab4445c261 zdev: Prepare for firmware configuration file support
Apply some changes to existing functions and data structures to simplify
the firmware configuration file support implementation.

 - Make qeth and dasd subtype objects non-static
 - Change the existing helper functions for reading file contents into
   memory to also support binary functions
 - Move some configuration file import functions to make them available
   for use in other source files

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Jan Höppner
e14363373b Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-08 15:03:30 +02:00
Jan Höppner
d9ca409978 New release s390-tools-2.4.0
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 15:27:24 +02:00
Jan Höppner
13596f18da udev: Replace WAIT_FOR with TEST keyword
The udev rule for SCSI devices is still using the WAIT_FOR keyword,
which was used to make sure that a file does in fact exist before any
rule is applied. That keyword, however, was removed with systemd-220 and
is therefore no longer valid, which in turn leads to errors on newer
systems.

Use the TEST keyword instead to check the existence of a file before we
apply any rules.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 14:28:32 +02:00
Ingo Franzki
80b66da1d8 zkey: Update README to add info about packaging requirements
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 14:28:32 +02:00
Hendrik Brueckner
3eb9af9c97 zkey: let packaging create the zkeyadm group and permission setup
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 14:28:32 +02:00
Ingo Franzki
f093d0bfd4 zkey: Man page updates
Add documentation for the new keystore related zkey commands.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Ingo Franzki
6a2f4fd376 zkey: Create key repository and group during make install
Create the default keystore directory '/etc/zkey/repository'
and the user group 'zkeyadm' during make install.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Ingo Franzki
e2f92e4079 zkey: Add keystore related commands
Add new commands to the zkey utility to store secure AES keys in
the secure key repository provided by the keystore implementation
introduced in the previous commit.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Ingo Franzki
c944f23d7e zkey: Add keystore implementation
Add a keystore implementation that stores secure AES keys in a
key repository, located in a directory, e.g. '/etc/zkey/repository'.
The keystore allows you to generate, validate, re-encipher, modify,
list, delete, etc secure keys.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Ingo Franzki
5872f8a21b zkey: Externalize secure key back-end functions
To reduce the size of the zkey.c source file, all routines that
deal with secure keys are moved to a new source file pkey.c.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Ingo Franzki
a090a1ffe8 zkey: Add helper functions for comma separated string handling
Comma separated strings are used in property values to store
multiple values in one property. These helper functions allow to
work with such comma separated strings.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Ingo Franzki
5e24f74fde zkey: Add build dependency to OpenSSL (libcrypto)
The integrity support for the properties file routines use
SHA-256 to build a hash of the keys and values of a property file.
The codes uses the EVP_DigestInit_ex, EVP_DigestUpdate, and
EVP_DigestFinal from the libcrypto library (OpenSSL).

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Ingo Franzki
340da73bb7 zkey: Add properties file handling routines
In preparation for a new feature, introduce property file
handling routines. A property file stores key value pairs
in a text file. Optionally a hash of all keys and values
contained in the properties file can be generated to
ensure integrity of the properties file and to detect
manual modifications.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
f642019bcc cpumf: Add IBM z14 ZR1 to the CPU Measurement Facility model list
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
7cc542352e zgetdump: Update the man page
Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
cf99ea019e zgetdump: Add 'Dump file size' field for zgetdump -i output
Add 'Dump file size' field for zgetdump -i output to show the actual size
of dump file in s390 extended format on disk in megabytes.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
15c22ec742 zgetdump: Add verbose option
Add verbose option for zgetdump to display the detailed layout of memory
map when printing dump info for s390_ext or ELF dump format.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
45ac847dc9 zgetdump: Adjust zgetdump for ELF formatted dumps
Adjust ELF formatted dump processing by zgetdump tool in order to handle
so-called zero loads using zero memory chunks introduced with s390
extended dump format.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
4a223c70f2 zgetdump: Update zgetdump to process the new dump format
Update zgetdump tool to process dumps of the new s390 extended format.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
26d636f234 zgetdump: Update zgetdump to process the new dump tool
Update 'zgetdump -d' to process the new DASD dump tool installed (single
volume or multi-volume).

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
aade05b01d zgetdump: Update s390 dump common functions
Update df_s390_dumper structure and dumper reading functions to read
certain dumper fields instead of the entire dump tool.
Update other s390 dump common functions in preparation for the new dumper
and the new s390 extended dump format.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
c3821f0821 zipl: Update progress_print() function
Adjust progress_print() function to print dump progress message based on
the time interval thus printing the message with a regular rate.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
ac0ac48f6f zipl: Extend DASD stand-alone dumpers to drop zero pages
Update zipl DASD standalone dumpers for single-volume, multi-volume and FBA
to drop the sets of zero pages when dumping memory to disk. Thus, all
continuous sets of zero-megabytes in the memory are dropped during the dump
stage.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
54519b4465 zipl: Update page_is_valid() function to avoid tprot usage
Old implementation was using Test Protection (TPROT) instruction to
validate the memory page. Given that it is a rather slow instruction and
the fact that we only need to validate the read-access for a page, we can
use simple Load or Insert Character instruction to test that.
The new version of page_is_valid() without a TPROT is introduced.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.vnet.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
9f2e406525 zipl: Fixing program check handler function
The program check handler has a bug in calculating the address of the target
to jump to. Furthermore the use of relative addresses in the exception table
can lead to situations where the (calculated) fault is not unique. Storing
the absolute address of the fault and target in the exception table solves
both problems.
This patch is intended to:
  - Modify exception table to store the absolute address of 'fault' and
    'target' points
  - Adjust program check handler function pgm_check_handler_fn() accordingly

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.vnet.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Vasily Gorbik
edaad2a927 chreipl: correct read-only attributes handling
chreipl could only be used as root (effective userid 0), which is
explicitly checked upon invocation.

"access" call is a wrong method to check super user read/write access
for sysfs files, because it is simply always returns 0 (success), despite
actual sysfs file permissions or underlying sysfs file callbacks setup.
The only guaranteed way of checking sysfs file super user access is an
actual open call with the corresponding access mode.

The problem is that chreipl always tries to update some sysfs attributes
even through they are not specified as command line arguments. Together
with a broken sysfs file access checks this leads to inability to use
the tool, when some sysfs attributes are read-only (which is the case
on older systems where diag308 set does not work).

$ chreipl ccw -d 0.0.ec5a
chreipl: Could not open "reipl/ccw/parm" (Permission denied)

The change fixes access checks, which are in place to handle "diag308
set does not work" case (presence of read-only sysfs attributes).

Also replaces R_OK with F_OK in "set_target_type_auto" to underline that
only file presence is checked, not an actual read access.

Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Vasily Gorbik
262a827ab4 chreipl: make write_str_errno return errno as the name suggests
Make write_str_errno return errno in all error cases, so that it would
be usable in scenarious where open call could fail and we just want to
get an errno, not to exit.

This function is currently only used by chshut in a context where
such a change wouldn't hurt debug ability.

159         if (write_str_errno(argv[2], path))
160                 ERR_EXIT_ERRNO("Could not set \"%s\"", path);

Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Vasily Gorbik
4b33d80595 chreipl: correct fcp reipl sysfs write sequence
kdump reipl implementation relies on os_info kernel structure
residing in old memory being dumped. os_info contains reipl block, which
is used (if valid) by the kdump kernel for reipl parameters.

The problem is that the reipl block and its checksum inside
os_info is updated only when /sys/firmware/reipl/reipl_type is
written. This sets an offset of a reipl block for "reipl_type" and
re-calculates reipl block checksum. Any further alteration of values
under /sys/firmware/reipl/{reipl_type}/ without subsequent write to
/sys/firmware/reipl/reipl_type lead to incorrect os_info reipl block
checksum. In such a case kdump kernel ignores it and reboots using
default logic.

This change makes sure that all fcp values are written before
reipl_type, to avoid potential problem with incorrect checksum.

Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Sa Liu
4c401162c0 dbginfo: Add VM commands to query protection settings.
Signed-off-by: Sa Liu <saliu@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
168acec5ea zgetdump: Avoid the Segfault on processing dumps with memory limit
When dump is not complete or dump memory limit is set, zgetdump might end up
with the Segfault on reading Vector Registers. That might take place when
the Vector Registers save area is beyond the dump memory limit.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.vnet.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
aab339d3e3 cpumf: Make short descriptions common for extended counter sets
The short descriptions for a counter in the extender counter
set should be identical for all models.
This patch fixes minor differences.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
1f459af568 cpumf: Add short description for crypto counter set
Add short description to the crypto counter set definition
file.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
46f09a0adc cpumf: Add short description for diag counter set
Add a short description to the diagnosis counter set
definition file.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
f65003a14e cpumf: Add short description for zEC12 extended counter set
Add a short description to the zEC12 extended counter set
definition file.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
e092b4024a cpumf: Add short description for z196 extended counter set
Add a short description to the z196 extended counter set
definition file.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
9d7bab18a4 cpumf: Add short description for z14 extended counter set
Add a short description to the z14 extended counter set
definition file.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
8688d47e3d cpumf: Add short description for z13 extended counter set
Add a short description to the z13 extended counter set
definition file.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
04bb72c0dc cpumf: Add short description for z10 extended counter set
Add a short description to the z10 extended counter set
definition file.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
1c065082d2 cpumf: Add short description for basic counters level 3
Add a short description to the basic counter first
version number 3 definition file.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
38642e6905 cpumf: Add short description for basic counters level 1
Add a short description to the basic counter first
version number 1 definition file.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
ebdf888a2f cpumf: Fix typo in counter 135
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Hendrik Brueckner
9745e4678a cpumf: correct counter name for z13 and z14
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Sebastian Ott
33a17df9fc lscss: fix scanning for defunct devices
util_scandir doesn't work with "/" at the end of the format string.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Sebastian Ott
4ff7aeff39 lscss: fix double free in print_defunct_devices
double free or corruption (out)

Program received signal SIGABRT, Aborted.
0x000003fffdd40404 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x000003fffdd40404 in raise () from /lib64/libc.so.6
#1  0x000003fffdd41ec2 in abort () from /lib64/libc.so.6
#2  0x000003fffdd88d8e in __libc_message () from /lib64/libc.so.6
#3  0x000003fffdd905c8 in malloc_printerr () from /lib64/libc.so.6
#4  0x000003fffdd98dfa in free () from /lib64/libc.so.6
#5  0x0000000001005994 in util_ptr_vec_free (count=<optimized out>, ptr_vec=0x101de90) at ../include/lib/util_base.h:46
#6  util_scandir_free (de_vec=0x101de90, count=<optimized out>) at util_scandir.c:174
#7  0x00000000010043ce in print_defunct_devices (rec=rec@entry=0x10114f0,
    path=path@entry=0x101cc80 "/sys/devices/css0/defunct") at lscss.c:678
#8  0x0000000001004cfe in print_subchannels_of_type (type_requested=type_requested@entry=SUBCHANNEL_TYPE_IO,
    rec=rec@entry=0x10114f0) at lscss.c:726
#9  0x0000000001003888 in cmd_lscss () at lscss.c:761
#10 main (argc=<optimized out>, argv=<optimized out>) at lscss.c:932

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
edb75870b5 cpumf_helper.in: Fix output of shortdesc
The cpumf_helper.in is called to parse counter definition
files stored in /usr/share/s390-tools/cpumf directory and
returns perl references to be examined by other perl tools
such as lsctrdef.

cpumf_helper.in expects several keywords in the counter
definition files, one is 'shortdesc' which contains
a short description of the purpose of the counter.

However this short description not is stored in the hash
field shortdesc keyed by counter number 'ctr' because the
wrong key is used.

Output before:
{
  '64' => {
            'desc' => 'Total number of the PRNG functions issued by the CPU',
            'name' => 'PRNG_FUNCTIONS',
            'set' => 8
          },
  '65' => {
            'desc' => 'Total number of CPU cycles when the DEA/AES coprocessor is busy performing PRNG functions issued by the CPU',
            'name' => 'PRNG_CYCLES',
            'set' => 8
          },
  ....
  'ctr' => {   <-------- WRONG
             'shortdesc' => 'AES Blocked Cycles'
           }
}

Output with this patch:
{
  '64' => {
            'desc' => 'Total number of the PRNG functions issued by the CPU',
            'name' => 'PRNG_FUNCTIONS',
            'set' => 8,
            'shortdesc' => 'PRNG Functions'
          },
  '65' => {
            'desc' => 'Total number of CPU cycles when the DEA/AES coprocessor is busy performing PRNG functions issued by the CPU',
            'name' => 'PRNG_CYCLES',
            'set' => 8,
            'shortdesc' => 'PRNG Cycles'
          },
  ...
}

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
a3c746846d cpumf: add missing Description: tag for z13/z14/ctr:128
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
4044accf03 vmcp: Use libutil functions util_prg and util_opt
Use helper functions in libutil for command line parsing
and help text output.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
943e7e7198 vmcp: Use libvmcp and remove local vmcp code
Use the new libvmcp.a to send commands to z/VM CP.
The error messages remain unchanged.

Local header file vmcp.h now only contains variable definitions
and some defines used by vmcp.c. Move them to the source file
and remove the now empty header file.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
4f00cb6346 vmur: Use libvmcp and remove local vmcp code
Use the new libvmcp.a to send commands to z/VM CP.
The error messages remain unchanged.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
9d55086720 lsqeth: Use libvmcp and remove local vmcp code
Use the new libvmcp.a to send commands to z/VM CP.
The error messages remain unchanged.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
eaa2ef6ba4 libvmcp: Add common vmcp code to the lib
This patch prevents code duplication in vmcp related programs.
Some applications such as vmur, vmcp, and lsqeth
use z/VM CP commands to query information. Each program
uses its own defines and code.

Supply a library and common header file to use common code.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Mikhail Zaslonko
37c3752b31 zgetdump: Remove unused function prototype
Signed-off-by: Mikhail Zaslonko <zaslonko@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Philipp Rudo
8585efadbe zipl: Remove unused inline assembly load
Signed-off-by: Philipp Rudo <prudo@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Harald Freudenberger
13648dd6f4 zcrypt: Corrections at the chzcrypt man page.
Fixed typo and added one sentence to explain more details
about online switching of queue devices.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
427dff3450 s390-tools: Move function util_strstrip
This patch
 - moves function util_strstrip to libutil/util_libc.c and deletes the
   extra files util_strstip.[ch]
 - adds doxygen comments for util_strstrip()
 - provides an example on how to use util_strstrip().

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Stefan Haberland
08bc0a947a zipl: fix some warnings in zipl_helper
Fix some warnings found by sparse.
Declare one function static and change static variables to defines.

Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Stefan Haberland
c3d583fe9c zipl: remove unused include
Remove unused include to fix an error reported by make C=1.

  CHECK   zipl/src/zipl_helper.device-mapper.o
../../include/lib/dasd_base.h:159:20: error: redefinition of struct hd_geometry
../../common.mak:234: recipe for target 'zipl_helper.device-mapper.o' failed
make: *** [zipl_helper.device-mapper.o] Error 1

The structure hd_geometry is defined in dasd_base.h.

Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Gerald Schaefer
983a72dab9 hmcdrvfs: fix parsing of link count >= 1000
hmcdrvfs will ignore files with a link count >= 1000, due to an inconsistency
in the input data. The parsing code relies on having spaces between the
different fields in its input data. When a file has a link count >= 1000,
there will be no space, and the "link count" field will be placed directly
after the previous "mode" field. This will confuse the parser, and all such
files will not be accesible.

The "mode" field will never contain digits, so in order to fix this issue,
the parser can recognize the "link count" field by the presence of a digit.

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
811152c08a s390-tools: Use util_strstrip in vmur
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Thomas Richter
6a1b9cf10a s390-tools: Add function util_strstrip
Function strstrip strips leading and trailung
spaces from a given string.
During review it was decided to move this function
to the libutil library to make it available for other tools.

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-05-07 13:42:03 +02:00
Rafael Fonseca
599b141b8a zipl: Rewrite helper script in C
To remove the perl dependency from zipl rewrite the helper script in C.

Closes: #18

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-02-16 10:39:10 +01:00
Sebastian Ott
b9e47e356b dbginfo: gather nvme related data
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-02-16 10:38:08 +01:00
Michael Holzheu
5e2a477bbf zfcpdump: Remove file system check from zfcpdump_initramfs.txt
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-02-16 10:37:05 +01:00
Michael Holzheu
bba34cb975 zfcpdump: Add /dev/sda to zfcpdump_initramfs.txt
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-02-16 10:36:43 +01:00
Michael Holzheu
a674011c0d zgetdump: Remove superfluous member 'size'
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-02-16 10:36:27 +01:00
Michael Holzheu
c78b5cd2ba zgetdump: Remove superfluous members from dfi_mem_chunk
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-02-16 10:36:08 +01:00
Michael Holzheu
f3e374ac77 zgetdump: Fix typo
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-02-16 10:35:22 +01:00
Michael Holzheu
1e6a9dbd56 AUTHORS: Cleanup
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2018-01-30 17:02:50 +01:00
Stefan Haberland
564a2601f6 Prepare for next release
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 16:01:36 +01:00
Stefan Haberland
f4eb7e4907 New release s390-tools-2.3.0
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 16:01:29 +01:00
Philipp Kern
c5a91199e3 zipl: Always build and link without PIE.
Compilers in Debian and Ubuntu default to enabling PIE for all binaries.
This is a poor fit for boot loader code that has strict requirements
for its layout. Hence always forcefully disable PIE.

As older compilers still need to be supported, no-pie usage is
conditional on CC's -dumpspecs output.

Fixes: #3

Signed-off-by: Philipp Kern <pkern@debian.org>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:38:41 +01:00
Hendrik Brueckner
144bddbf5b cpumf: correct z14 counter number
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:37:19 +01:00
Hendrik Brueckner
36ef451e6b CHANGELOG: Add z14 hardware counter support
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:36:48 +01:00
Hendrik Brueckner
1064e5b9cc cpumf/cpumf_helper: read split counter sets (part 2/2)
Update the cpumf helper program to read the split counter set
definition files.  Changes to higher-level program like lscpumf
are not necessary.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:36:23 +01:00
Hendrik Brueckner
d121ffa3f0 cpumf/z14: split counter sets according to CFVN/CSVN (part 1/2)
With z14, the counters in the problem-state are reduced resulting
in an increased first version number of the CPUM CF.  To adapt to
this change, split the counter sets according to their counter
first and second version number.  The second version number controls
the crypto-activity and extended counter set.  Treat the crypto-activity
counter set as generic, as the extended counter set is already handled
based on hardware models.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:35:39 +01:00
Martin Schwidefsky
57f18c5f59 cpumf: Add extended counter defintion files for IBM z14
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
[brueckner: Prefer plural for counter names]
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:35:18 +01:00
Peter Oberparleiter
3b2a8777b1 common.mak: Fix disappearing check errors
When 'make C=1' reports a fatal error for a source file, re-running
'make C=1' will no longer report this error because the target object
file was successfully created before the check was run.

Fix this by moving the check before the compilation step so that the
object file is not built in case of a fatal check error.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Reviewed-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:33:38 +01:00
Michael Holzheu
89ead069f9 util_list: Use util_malloc() for util_list_new()
Since now util_list_new() internally fails for out-of-memory situations,
we can also remove some NULL pointer checks.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2018-01-29 18:15:03 +01:00
Dan Horák
05de40cdeb Replace delimiter char in sed expressions
Use a character, that can't be used in rpm Version and Release tag, as
the delimiter in sed expressions.

Fixes: #25

Signed-off-by: Dan Horák <dan@danny.cz>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2018-01-22 13:50:36 +01:00
Mikhail Zaslonko
a74103dba7 zgetdump: Fix overflow/truncation in part_off calculation
When calculating partition start offset during multi-volume dump processing,
the result of multiplication is truncated to 32-bits thus resulting in
invalid behavior in case the real offset is beyond 4Gig boundary.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.vnet.ibm.com>
Reviewed-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2018-01-22 13:50:07 +01:00
Sa Liu
b4868c21bf Add VM command to query processor
Signed-off-by: Sa Liu <saliu@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2018-01-22 13:49:02 +01:00
Rafael Fonseca
8826028bdc dasdfmt: Use libdasd provided ioctl functions
Closes: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 16:16:51 +01:00
Rafael Fonseca
09aa7f2010 dasdfmt: Apply project's code conventions
GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 16:16:13 +01:00
Rafael Fonseca
e7d3638c6b dasdview: Use libdasd provided functions
GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 16:15:50 +01:00
Rafael Fonseca
68b0b4c268 dasdview: Apply project's coding conventions
GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 16:15:15 +01:00
Rafael Fonseca
caeb4470cd zdsfs: Use libdasd provided ioctl functions
GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 16:14:09 +01:00
Rafael Fonseca
8b11ea73ac fdasd: Use libdasd for DASD ioctls
GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 16:05:02 +01:00
Rafael Fonseca
45e20a5044 fdasd: Apply project's coding conventions
GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 16:04:19 +01:00
Rafael Fonseca
105b30a805 dasdinfo: Use libdasd for DASD ioctls
GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 14:49:49 +01:00
Rafael Fonseca
70a7fc3e72 dasdinfo: Apply project's coding convention
GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 14:15:54 +01:00
Rafael Fonseca
2d3774932b vtoc: hd_geometry is already defined in libdasd
GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 14:13:09 +01:00
Rafael Fonseca
a5c1923d32 libdasd: Add common DASD ioctl's to the lib
This will avoid code duplication in dasd-related programs.

GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 14:11:14 +01:00
Peter Oberparleiter
0348a8443e zdev: Fix zdev dracut module aborting on unknown root device
Running dracut when the root device is not known to zdev (for example
because it is located on a virtio block device) will cause the zdev
dracut module to incorrectly return an error in the installkernel()
function. As a result dracut aborts with an error.

Fix this by ensuring that the non-zero exit code resulting from lszdev
not being able to determine the root device is not passed on to the
calling function. Also remove unnecessary error output in this case
by leaving the install() function early when the root device is not
known to zdev.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-07 17:38:34 +01:00
Michael Holzheu
dba9616a5b Prepare for next release
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-07 17:38:21 +01:00
Michael Holzheu
44598496c5 New release s390-tools-2.2.0
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-07 14:36:50 +01:00
Peter Oberparleiter
2a6a28023b zdev: Enable running chzdev from unknown root devices
When a persistent device configuration is changed, chzdev tries to
find out if it needs to perform additional steps to make this change
persistent. If this check fails, for example because the root device
is located on a RAM-disk, or on a device type not managed by chzdev,
the tool reports an error and exits with non-zero exit code:

  chzdev: Could not determine device that provides /

or

  chzdev: Could not determine device that provides loop0

This behavior unnecessarily restricts chzdev from being used in
scripted environments like an installation initial RAM-disk.

Fix this by removing the non-zero exit code and moving the message to
verbose output mode only.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-06 16:00:36 +01:00
Jan Höppner
e581fa3fea dasdinfo: Fix false line breaks
Commit 61b60baf57 ("dasdinfo: Fix GCC 7 overflow warning") erroneously
introduced line breaks to the UID (-u) output. To be consistent with the
extended uid ouput code, keep the newley indroduced line breaks and
remove the additional one from the string split above instead.

Fixes: 61b60baf57 ("dasdinfo: Fix GCC 7 overflow warning")
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-06 16:00:16 +01:00
Michael Holzheu
0382659f4f ipl_tools: Use quotes for local include files
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-06 16:00:08 +01:00
Michael Holzheu
e767a2b99d build process: Fix parallel build for libutil
When building libutil in parallel, it can happen that the archive
file is created twice:

 $ cd libutil
 $ make -j
  ...
  CC      libutil/util_rec_example.o
  AR      libutil/libutil.a
  AR      libutil/libutil.a
  LINK    libutil/util_base_example

This can lead to the following build error:

 $ make -j OPT_FLAGS="-pipe"
   ..//libutil/libutil.a(util_path.o): In function `sys_mount_point':
   util_path.c:56: undefined reference to `util_proc_mnt_get_entry'
   util_path.c:60: undefined reference to `util_proc_mnt_free_entry'
   collect2: error: ld returned 1 exit status
   ../common.mak:232: recipe for target 'util_path_example' failed

The problem is that the following rule from common.mak is triggered in
the libutil directory:

 $(rootdir)/libutil/libutil.a: $(rootdir)/libutil
      $(MAKE) -C $(rootdir)/libutil/ libutil.a
 .PHONY: $(rootdir)/libutil

To prevent this rule, use the local "libutil.a" as dependency for the
example binaries.

Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-06 15:59:58 +01:00
Michael Holzheu
869f629746 CONTRIBUTING: Outline steps to submit and rework code
For GitHub and git beginners explain in more detail how to submit s390-tools
contributions as pull requests, how to update already submitted code
and how to rebase a contribution branch.

Based on the initial proposal from: Jens Remus <jremus@linux.vnet.ibm.com>

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.vnet.ibm.com>
2017-11-30 15:18:28 +01:00
Rafael Fonseca
7b8d09e62e ziomon: fix typo when checking for attribute existence
Fix possible c&p mistake when checking the presence of `queue_full` attribute
in old kernels. There should be no impact on how the tool works other than
exiting gracefully in case the attribute does not exist.

Fixes: #21

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-28 18:54:39 +01:00
Michael Holzheu
5a8eee163b osasnmpd: Use ALL_CFLAGS instead of directly CFLAGS
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-28 18:51:30 +01:00
Michael Holzheu
75a45158ad util_path_example: Improve output of is_xxx
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:25 +01:00
Michael Holzheu
16c4074e47 util_path_example: Add example for new util_path_exists() function
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:19 +01:00
Michael Holzheu
2b92bc4c08 util_path: Make true/false handling consistent with other functions
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:10 +01:00
Michael Holzheu
d0e2caf0ff util_path: Add description for util_path_exists()
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:05 +01:00
Rafael Fonseca
d542138868 zdev: use libutil provided path functions
Closes: #20

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:59:31 +01:00
Rafael Fonseca
df133846b5 util_path: add function to check if a path exists
GitHub-ID: #20

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:58:57 +01:00
Jens Remus
283e0bd5ea CONTRIBUTING: Clarifications to Signed-off-by requirement
Mention that the Signed-off-by line should be at the bottom of every commit
message and that the e-mail address must be valid.

Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:58:29 +01:00
Jens Remus
5ae3ec72b2 CODINGSTYLE: Add links to the Linux kernel coding style and checkpatch
Add link to the Linux kernel coding style on https://www.kernel.org/ and
convert link to the checkpatch tool into a proper Markdown link.

Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:58:18 +01:00
Jens Remus
d9e9f7185f CODINGSTYLE: Add link to libutil
Format reference to libutil in code style and add link to its subdirectory.

Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:58:03 +01:00
Jens Remus
532d87d281 CONTRIBUTING: Fix spelling of GitHub
Spell GitHub in camel case as it is done on https://github.com/.

Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:57:31 +01:00
Michael Holzheu
8600296030 osasnmpd: Add -fPIC to CFLAGS to fix build on Fedora 27
On Fedora 27 "net-snmp-config --agent-libs" returns
"--specs=/usr/lib/rpm/redhat/redhat-hardened-ld" which introduces "-pie":

 # cat /usr/lib/rpm/redhat/redhat-hardened-ld
 *self_spec:
 + %{!static:%{!shared:%{!r:-pie}}}
 *link:
 + -z now

This leads to the following link error:

 /usr/bin/ld: osasnmpd.o: `getopt_long@@GLIBC_2.2' non-PLT reloc for symbol
              defined in shared library and accessed from executable
              (rebuild file with -fPIC ?)
 /usr/bin/ld: final link failed: Bad value

Add -fPIC to CLFAGS as a workaround to enbable linking again.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:57:21 +01:00
Michael Holzheu
3908725d3b zfcpdump: Add HAVE_LIBC_STATIC check
For systems that do not have glibc-static installed, print the
following error message when building zfcpdump:

 s390-tools/zfcpdump # make
   REQCHK  zfcpdump (stdio.h)
 ****************************************************************
 * Missing build requirement for: zfcpdump                      *
 * Install package..............: glibc-static or libc-dev      *
 * You can skip build with......: make HAVE_LIBC_STATIC=0       *
 ****************************************************************

To allow the check add a new compiler/linker option to the "check_dep"
macro and do full compile/link instead of a simple compile.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:57:12 +01:00
Gerald Schaefer
780133f825 mon_tools: Improve systemctl start error handling
This fixes the same issue as in commit 82c8148983 ("cpuplugd: Improve
systemctl start error handling") for mon_tools (mon_procd and mon_fsstatd).

Currently "systemctl start mon_procd/fsstatd" does not report any errors
in case the startup fails.

Example (with mon_procd):

 (change interval in /etc/sysconfig/mon_procd to an invalid value "abc")
 # systemctl start mon_procd

The reason is that for type=simple systemd forks/execs mon_procd and if
that is successful immediately returns. There is no way to find out if the
initial startup fails.

Fix this by using type=fork and running the process in the background. In
this case systemd waits until the initial process returns.

In addition use PIDFile and ensure that the pid file is already available
when the initial process returns. To achieve this, use startup
synchronization via pipe. Without that systemd would print the following
warning:

systemd[1]: mon_procd.service: PID file /var/run/mon_procd.pid not readable
            (yet?) after start: No such file or directory

With this patch, an early startup error like in the example above, is now
reported correctly in "systemctl start":

 # systemctl start mon_procd
   Job for mon_procd.service failed because the control process exited...
   See "systemctl status mon_procd.service" and "journalctl -xe" for ...
 # journalctl -xe | grep mon_procd
   mon_procd[3184]: Error: Invalid interval (needs to be greater than 0)

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-20 20:33:17 +01:00
Michael Holzheu
82c8148983 cpuplugd: Improve systemctl start error handling
Currently "systemctl start cpuplugd" does not report any errors in
case the startup fails.

Example:

 # mv /etc/cpuplugd.conf /etc/cpuplugd.conf.xxx
 # systemctl start cpuplugd

The reason is that for type=simple systemd forks/execs cpuplugd and if
that is successful immediately returns. There is no way to find out
if the initial startup fails.

Fix this by using type=fork and running cpuplugd in the background. In
this case systemd waits until the initial process returns.

In addition use PIDFile and ensure that the pid file is already available
when the initial cpuplugd process returns. To achieve this, replace the
daemon() function by our own implementation that introduces startup
synchronization via pipe. Without that systemd would print the following
warning:

systemd[1]: cpuplugd.service: PID file /var/run/cpuplugd.pid not readable
                              (yet?) after start: No such file or directory

With this patch, an early startup error like in the example above, is now
reported correctly in "systemctl start":

 # systemctl start cpuplugd
   Job for cpuplugd.service failed because the control process exited...
   See "systemctl status cpuplugd.service" and "journalctl -xe" for ...
 # journalctl -ex | grep cpuplugd
   Nov 16 15:52:27 ... cpuplugd[5096]: Opening configuration file failed:
                                       No such file or directory

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Acked-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
2017-11-20 20:29:20 +01:00
Michael Holzheu
c12c4af760 Start CODINGSTYLE document and add table with abbreviations
To get consistent and readable code let's try to advertise some common
abbreviations.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-20 14:58:09 +01:00
Michael Holzheu
f595bce3c0 systemd: Use SYSCONFDIR instead of /etc for 'make install'
Suggested-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-20 14:57:58 +01:00
André Wild
0768fbbb20 chzdev.8: Fix chzdev examples
This patch fixes two examples which are shown in the man page of chzdev.

Signed-off-by: André Wild <wild@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-20 14:56:47 +01:00
Michael Holzheu
523d833eb3 ziomon: Re-add missing line in ziomon_fcpconf
During the GPL to MIT conversion process from v1.39.0 to v2.0.0 one line has
been lost by accident. Fix this and re-add that line again.

Fixes: #17

Reported-by: Mikhail Obirvalger
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-16 18:26:34 +01:00
Christian Ehrhardt
3fc01e7520 mk-pxelinux-ramfs: make infinite loop a timeout
So far it infinitely retried the bootscript, that doesn#t seem
reasonable. Per IRC discussion this is now changed to a 600 sec timeout
waiting for a config to appear to then run once on that config.

In case the pxe boot fails the it is now no more a retry loop, but
instead considered a crash as init exits.

Closes: #16

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:46:09 +01:00
Christian Ehrhardt
9259370891 mk-pxelinux-ramfs: fix escaping kexec appends
Currently multiple entries in a single append is broken by how the
shell in busybox escapes them. No usual grouping with " or ' will
work but calling them directly but without the --append in the
variable will let busybox do the right thing.

GitHub-ID: #16

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:46:09 +01:00
Christian Ehrhardt
7b84e30471 mk-pxelinux-ramfs: case insensitive arg parsing
Many documentations refer to kernel, initrd, ... arguments
in upper case so the grep/sed should support both.

GitHub-ID: #16

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:46:09 +01:00
Christian Ehrhardt
9c2a0649f2 mk-pxelinux-ramfs: improve console output
Currently for a user the pxe boot seems unclear and it
is hard to follow what is going on.

- Report on when (re-)starting the bootscript.
- Report configs fetched (Without e.g. on a virsh console
  one only sees a loop of timeouts.)
- Report which config is missing on the PXE_CONF check
- Report kexec calls made

GitHub-ID: #16

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:46:09 +01:00
Gerald Schaefer
778292e771 lsmem/chmem: Remove tools
lsmem/chmem moved to util-linux >= 2.30, remove them from s390-tools.

For kernels >= 4.13, the default memory zone for hotplug memory was
changed from zone MOVABLE to zone NORMAL. In order to keep using zone
MOVABLE for memory hotplug, either use the lsmem/chmem tools from
s390-tools version 2.1.0, or an updated version of the util-linux
version of lsmem/chmem that contains the following util-linux git
commits (included in util-linux 2.32):

60a7e9e94e49 "lsmem/chmem: add memory zone awareness"
0a4320f5e785 "tests/lsmem: update lsmem test with ZONES column"
afee3f204247 "lsmem/chmem: add memory zone awareness to bash-completion"

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:46:09 +01:00
Sa Liu
c21e464856 dbginfo: Show thread with ps command.
Signed-off-by: Sa Liu <saliu@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:38:21 +01:00
Peter Oberparleiter
a060dc22db zdev: Use correct path to vmcp binary
The zdev tools use a hard-coded path to locate the vmcp binary. Since
this path may differ between distributions, the vmcp binary may not be
successfully located in all cases. Fix this by using the BINDIR macro
to determine the correct path. This macro is also used during
installation of the vmcp binary itself.

Reviewed-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-13 14:53:06 +01:00
Michael Holzheu
66f0090989 systemd: Install also the unit configuration files
If SYSTEMDSYSTEMUNITDIR is defined, the systemd units are automatically
installed. Therefore consequently also install the required config files
in that case.

Example:

 $ make install SYSTEMDSYSTEMUNITDIR=/usr/lib/systemd/system/

Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-13 14:52:58 +01:00
Rafael Fonseca
5d10b925c8 zipl: remove invalid dasdview command line option
dasdview command does not accept the '-f' option so because of that the
command will always fail.

Fixes: #10

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:49:04 +01:00
Michael Holzheu
7076d19c7f iucvterm: Add "all" to make install dependency
When doing parallel builds, we currently get the following error for
iucvterm:

 ~/s390-tools/iucvterm (bb/holzheu/install-configs)# make install  -j
   INSTALL iucvterm
   CC      iucvterm/src/iucvconn.o
   INSTALL iucvterm/src
   CC      iucvterm/src/getopt.o
 install: cannot stat 'iucvconn': No such file or directory
 install: cannot stat 'iucvtty': No such file or directory
 Makefile:19: recipe for target 'install' failed

Fix this and "all" as explicit dependency to the install target.

Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:39:13 +01:00
Fedor Loshakov
69199219bc ziomon: fix non-zero return code in ziomon_util
Use additional variable to store return code from
parse_params function for distinguishing return
codes from help and version from others in ziomon_util

Before patch applied:

 # /usr/sbin/ziomon_util --help
 Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q <msgq_path> ...
 # echo $?
 255

 # /usr/sbin/ziomon_util --version
 ziomon_util: ziomon utilization monitor, version ...
 # echo $?
 255

After patch applied:

 # /usr/sbin/ziomon_util --help
 Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q <msgq_path> ...
 # echo $?
 0

 # /usr/sbin/ziomon_util --version
 ziomon_util: ziomon utilization monitor, version ...
 # echo $?
 0

Signed-off-by: Fedor Loshakov <loshakov@linux.vnet.ibm.com>
Suggested-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:38:39 +01:00
Hendrik Brueckner
f0116ee79c cpi: add missing Install section to service unit
The cpi service unit requires an Install section to tell systemd
when to start the cpi service.  Add an install section and start
cpi for the multi-user target.

Reported-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:37:38 +01:00
Harald Freudenberger
4ad5e29f2f lszcrypt: fix date and wrong indentation
The man page date was AUG 2008. Changed to OCT 2017.
A previous commit had a wrong indentation on following
options text for lszcrypt. Fixed.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:37:28 +01:00
Michael Holzheu
a0d3e3a1a8 CHANGELOG: lszcrypt: CEX6S exploitation
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:35:41 +01:00
Jan Höppner
1261105fe2 dasdinfo: Fix truncation warning
Commit 3c80f7e025 ("dasdinfo: fix buffer overflow warning") changed a
sprintf call to snprintf to avoid a buffer overflow warning. However,
GCC 7 now warns about a potential truncation with snprintf:

dasdinfo.c: In function 'main':
dasdinfo.c:577:18: warning: '%s' directive output may be truncated
writing up to 255 bytes into a region of size 69 [-Wformat-truncation=]
      "/sys/block/%s/device/uid", dir_entry->d_name);
                  ^~
dasdinfo.c:576:4: note: 'snprintf' output between 23 and 278 bytes into
a destination of size 80
    snprintf(*uidfile, RD_BUFFER_SIZE,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "/sys/block/%s/device/uid", dir_entry->d_name);
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We could get around this by increasing the buffer. Though, the current
buffer size is already plenty and we know better anyway.
Avoid the warning by simply checking the return value of snprintf and
display an error in case data was truncated nonetheless.

Fixes: 3c80f7e025 ("dasdinfo: fix buffer overflow warning")
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-18 16:58:49 +02:00
Harald Freudenberger
31866fbfa4 lszcrypt: CEX6S exploitation
With z14 there comes a new crypto card 'CEX6S'.

This patch introduces the s390-tools changes needed
to list the new card and show the capabilities correctly.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-18 14:53:06 +02:00
Hendrik Brueckner
e179b7a9ac iucvterm: include ctype for toupper()
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-18 14:49:57 +02:00
Hannes Reinecke
5e4577d76b Update gitignore to not exclude init.d and rules.d directories
Fixes: #9

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-12 20:22:43 +02:00
Hannes Reinecke
496c257bf2 dasdfmt: drop 'device_id' parameter
Drop device_id parameter from dasdfmt_info() and pass in 'optind'
directly.

Closes: #8

Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-12 20:22:25 +02:00
Hannes Reinecke
0028f166aa dasdfmt: Fixup device name handling
get_device_name() contains a chunk of unreachable code, as the
'name' argument is never filled with any value.
So turn things around to have get_device_name() always fill the
'name' argument with the real device name, and remove the
devname entry from the dasdfmt_info_t structure.

GitHub-ID: #8

Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-12 20:22:13 +02:00
Hannes Reinecke
97047896ab dasdfmt: Fixup dasdfmt_get_volser()
dasdfmt_get_volser() opens its own private filedescriptor
despite the global filedes already being opened.
And we should be passing in only the bits of the info structure
that we actually need.

GitHub-ID: #8

Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-12 20:14:03 +02:00
Dan Horák
94fcd8dc18 use TOOLS_LIBDIR in definition of ZFCPDUMP_DIR
Fixes: #6

Signed-off-by: Dan Horák <dan@danny.cz>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:13:27 +02:00
Jens Remus
afdecb4a57 lsluns: update s390-tools CHANGELOG and README for preceding commits
Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:11:49 +02:00
Steffen Maier
e5f9279295 lsluns: complement alternative tools with lszdev
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:10:56 +02:00
Steffen Maier
55f0b001d1 lsluns: document restriction to zfcp-only systems
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:10:39 +02:00
Steffen Maier
5f768dd52d lsluns: point out IBM Storwize configuration requirements
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:10:15 +02:00
Steffen Maier
0daa7ba0b5 lsluns: clarify discovery use case, relation to NPIV and to zfcp auto LUN scan
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:09:48 +02:00
Jens Remus
e748fff347 lsluns: enhance usage statement and man page
The wording in the lsluns usage statement and man page was misleading
in several aspects:

* lsluns does not list all LUNs, just those discovered in the FC SAN
* lsluns -a should only be used to display the LUN encryption status

Fix filter option arguments. Clarify filter option usage. Refer to
lszfcp and lsscsi.

Reported-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:09:17 +02:00
Jens Remus
d81c423429 lsluns: fix flawed formatting of man page
The formatting in the SYNOPSIS, OPTIONS, and EXAMPLES sections was flawed
in the lsluns(8) man page:

* The comma between short and long options were erroneously formatted in
  bold, which would indicate to be typed exactly as shown. [see man(1)]

* The option parameters (e.g. adapter and port) were erroneously formatted
  in bold instead of italic text (usually displayed as underlined on the
  console), which would again indicate to be typed exactly as shown instead
  of to be replaced with the appropriate argument. [see man(1)]

* Ellipses were missing after the the options that may be specified multiple
  times (e.g. adapter and port). [see man(1)]

* Dashes in options in the SYNOPSIS and OPTIONS section needed to be
  escaped. [see man-pages(7)]

* User input in example shell sessions should have been formatted in bold.
  [see man-pages(7)]

Correct formatting based on man(7) and man-pages(7) man pages as reference.
Add proper spacing between options and their surrounding square brackets and
between the three periods of ellipses.

Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:08:57 +02:00
Jens Remus
c993ad89c5 lsluns: do not print confusing messages when a filter matches nothing
lsluns printed potentially confusing messages when a filter or combination
of filters matched nothing:

    No valid combination found for adapter '0.0.1906'. Removing from
    resource list.
    No valid combination found for port '0x50050763071845e3'. Removing from
    resource list.
...

To the user it is potentially unclear which 'combination' is actually being
referred to, as only one part of the combination is mentioned, and what the
ominous 'resource list' is. The later information is merely useful for a
developer to debug the script.

Such a message was written for every user supplied filter that did not
contribute anything to the resulting subset that is being listed, although
the filter actually might match something when used standalone.

Additionally those messages were printed to stdout instead of stderr. As
there is no debug or verbose switch and the information level of those
messages is low, we may simply discard them.

Reported-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:08:35 +02:00
Jens Remus
398f9ceac8 lsluns: do not scan (all) if filters match nothing
Fix the following undesired behavior of lsluns to scan all resources if the
user provided filters did not match anything:

    No valid combination found for adapter '5080'. Removing from resource
    list.
No valid parameters left, using all available resources in system.
Scanning for LUNs on adapter 0.0.5080
...

Scanning can be resource consumptive. So if a user already wants to filter,
possibly to reduce resource consumption, he does not want to happen to scan
everything and thus consume the worst case of resources.

Instead print a message to inform the user why nothing was scanned.

Reported-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:08:09 +02:00
Philipp Rudo
f0d8bc02a7 util_prg: Delete douplicate copyright header
Signed-off-by: Philipp Rudo <prudo@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:07:48 +02:00
Michael Holzheu
aba46da2d0 Prepare for next release
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:07:31 +02:00
Philipp Rudo
ddfe2bf59b README: add glibc-static to dependencies
Signed-off-by: Philipp Rudo <prudo@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:07:14 +02:00
Michael Holzheu
364b4c0686 New release s390-tools-2.1.0
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-25 14:15:15 +02:00
Michael Holzheu
8818e229cc CHANGELOG: Update for 90-cpi.rules
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-22 16:57:39 +02:00
Michael Holzheu
ed18044925 Add changelog for 2.1.0
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-22 16:53:02 +02:00
Stefan Haberland
3c80f7e025 dasdinfo: fix buffer overflow warning
Fix a possible buffer overflow.
The buffer overflow is only theoretical since the device name is max
8 characters in length.

This fixes following gcc 7 warning:

 dasdinfo.c: In function 'main':
 dasdinfo.c:576:33: warning: '%s' directive writing up to 255 bytes into a
                                   region of size 69 [-Wformat-overflow=]
     sprintf(*uidfile,"/sys/block/%s/device/uid",
                                  ^~
 In file included from /usr/include/stdio.h:862:0,
                  from dasdinfo.c:15:
 /usr/include/bits/stdio2.h:33:10: note: '__builtin___sprintf_chk' output
                    between 23 and 278 bytes into a destination of size 80
    return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-22 16:52:45 +02:00
Michael Holzheu
70243b8135 cpictl: Make --help/--version help text s390-tools compliant
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-22 16:21:44 +02:00
Claudio Imbrenda
2f461f673e cpi: add missing help line
The information shown with the --help option did not mention the -v or
--version option which can be used to retrieve the version information.

This patch fixes it.

Fixes: 7179f5de2a1582 ("cpi: Introduce new udev rule and integrate with systemd unit")
Signed-off-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Reference-ID: VS1706
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-22 16:21:31 +02:00
Hans Wippel
c0dc514af8 zdev: Fix segfault with unknown qeth attribute
This patch fixes a segfault in the qeth get_layer function that occurs
when an unknown attribute is used in combination with the force option.

Signed-off-by: Hans Wippel <hwippel@linux.vnet.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-22 16:20:53 +02:00
Hans Wippel
e831269e74 zdev: Add support for VNIC Characteristics
This patch adds support for the qeth attributes that are used to
configure VNIC Characteristics.

VNIC Characteristics and BridgePort are mutually exclusive. Thus, this
patch also adds a check function for conflicting settings to the qeth
code. Also, the output when VNIC Characteristics is active is added to
the BridgePort attribute descriptions.

Signed-off-by: Hans Wippel <hwippel@linux.vnet.ibm.com>
Acked-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-22 16:20:04 +02:00
Ursula Braun
063425d515 znetconf: Re-add missing line in lsznet.raw
Re-add a missing line that was removed by accident when creating the
new s390-tools-2.0.0 release from s390-tools-1.39.0.

Fixes: b627b8d8e1 ("Initial s390-tools-2.0.0 import")
Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-22 16:18:02 +02:00
Jan Höppner
61b60baf57 dasdinfo: Fix GCC 7 overflow warning
With GCC 7 we get the following warning as a potential overflow might
happen, if d_name gets too big:

dasdinfo.c: In function 'main':
dasdinfo.c:611:37: warning: '%s' directive writing up to 255 bytes into
  a region of size 69 [-Wformat-overflow=]
   sprintf(sys_dev_path, "/sys/block/%s/dev", dir_entry->d_name);
                                     ^~
dasdinfo.c:611:3: note: 'sprintf' output between 16 and 271 bytes into a
  destination of size 80
   sprintf(sys_dev_path, "/sys/block/%s/dev", dir_entry->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This could be fixed by simply increasing the buffer size. However, there
is a little bit more to it and the way files are currently read can be
simplified.
Do this by using the libutil functions to read files and clean up a
little along the way.

Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-15 05:07:42 +02:00
Jan Höppner
cd085dc721 fdasd: Skip partition check with the force option
Before writing data to the disk, fdasd always checks whether a partition
is specified to prevent writing partition tables to a partition.

However, this also prevents the user from writing partition tables to
loop devices > loop0, even when the force option is specified.
Technically, those are not partitions.

Therefore, allow writing partition tables to partitions when the force
option is specified.

Fixes: #4

Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-15 05:05:58 +02:00
Hans Wippel
c2cb410b8f zconf: Add VNIC Characteristics support to lsqeth
This patch adds the qeth attributes that are used to configure
VNIC Characteristics to lsqeth.

The output of lsqeth comprises two columns: one for attribute names, one
for attribute values. Not all VNIC Characteristics attribute names fit
in the corresponding column. Thus, this patch also increases the width
of the attribute names column by 2 characters.

Signed-off-by: Hans Wippel <hwippel@linux.vnet.ibm.com>
Reviewed-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-15 05:04:56 +02:00
Hans Wippel
0b4686dd76 zdev: Fix IPv6 NDP proxy description
Currently, the qeth attributes that are used to configure IPv6 NDP proxy
are described as ARP proxy attributes. This patch changes the titles and
descriptions from ARP to NDP.

Signed-off-by: Hans Wippel <hwippel@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-15 05:04:16 +02:00
Claudio Imbrenda
ca50924acb cpi: Introduce new udev rule and integrate with systemd unit
Add a new udev rule that is triggered when a KVM VM is started
on the system the very first time. This rule reports over the
sysfs CPI kernel interface that the system is a KVM host.

Currently the cpi.service systemd unit already works with
the CPI sysfs interface. Introduce a new internal utility
script "cpictl" that is used by both the udev rule and
the systemd unit to guarantee coordinated access to the
kernel CPU interface.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-15 05:03:04 +02:00
Michael Holzheu
8ff6af3a4b lscss: Get rid of gcc 7 buffer truncation warnings
With gcc 7 we get warnings for code like the following:

  44 #define MAX_BUFFER_SIZE_FOR_SUBCHANNEL_ATTRIBUTES      37
 406         char buf[MAX_BUFFER_SIZE_FOR_SUBCHANNEL_ATTRIBUTES];
 416                 device = de_vec[0]->d_name;
 417                 snprintf(buf, sizeof(buf), "%s", device);

 $ grep -r 'd_name\[' /usr/include/
 /usr/include/bits/dirent.h:    char d_name[256];

The compiler assumes that d_name can be up to 255 characters. Therefore
it produces the following warning:

   CC      zconf/css/lscss.o
 lscss.c: In function 'print_sch_io':
 lscss.c:417:31: warning: '%s' directive output may be truncated writing
    up to 255 bytes into a region of size 37 [-Wformat-truncation=]
    snprintf(buf, sizeof(buf), "%s", device);
                               ^~
 In file included from /usr/include/stdio.h:936:0,
                  from lscss.c:10:
 /usr/include/bits/stdio2.h:64:10: note: '__builtin_snprintf' output
                    between 1 and 256 bytes into a destination of size 37
    return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         __bos (__s), __fmt, __va_arg_pack ());
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix this and use larger buffer sizes to keep gcc quiet.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-06 13:05:12 +02:00
Michael Holzheu
221e74c27c Get rid of gcc 7 "fall through" warnings
With gcc 7 we get warnings like the following:

 fdasd.c: In function 'main':
 fdasd.c:3055:4: warning: this statement may fall through
                          [-Wimplicit-fallthrough=]
     fdasd_exit(&anchor, 0);
     ^~~~~~~~~~~~~~~~~~~~~~
 fdasd.c:3056:3: note: here
    default:
    ^~~~~~~

Fix this by marking functions with "__noreturn" to help gcc.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-06 13:05:01 +02:00
Michael Holzheu
6c3c721275 zgetdump: Fix gcc 7 warning
With gcc 7 the compiler checks for sprintf() the maxium possible resulting
string based on the used datatypes.

Example:

 struct vol {
          ...
          char bus_id[9];
          ...
 }

 sprintf(vol->bus_id, "0.%x.%04x", ssid, vol_parm->devno);

The compiler can prove that "ssid" comes from "u8" and "vol_parm->devno"
from "u16". Therefore the resulting maximum string can be 0.ff.ffff which
requires 10 bytes.

This leads to the following warning:

 dfi_s390mv.c: In function 'volumes_init':
 dfi_s390mv.c:243:45: warning: '__builtin___snprintf_chk' output may be
  truncated before the last format character [-Wformat-truncation=]
  snprintf(vol->bus_id, sizeof(vol->bus_id), "0.%x.%04x", ssid,
                                             ^~~~~~~~~~~
 In file included from /usr/include/stdio.h:936:0,
                  from dfi_s390mv.c:15:
 /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output
    between 9 and 10 bytes into a destination of size 9
    return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         __bos (__s), __fmt, __va_arg_pack ());
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To get rid of the warning use 10 instead of 9 bytes for the bus_id.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-06 13:04:50 +02:00
Harald Freudenberger
93d91679c3 cpacfstats: Add size setting to perf event
The newer perf_event_open syscall needs a struct
perf_event_attr with the size field set correctly. Older
versions did not even provide this field. However, this
field is now set to the correct size value.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-06 13:04:19 +02:00
Harald Freudenberger
6b8b336cf0 lszcrypt: Fix core dump caused by stack overwrite.
There was a too tight buffer allocated on the stack
which was overwritten by just one byte caused to
dump the application on function exit's stack check.
Reviewed all the buffer sizes and adapted them
to the need of the functions.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-06 13:03:31 +02:00
Michael Holzheu
616d379c60 bin/mk-authors: Add script for updating AUTHORS.md file
If called without parameters it updates the authors file with new authors
since last release tag. With the -t option a specific tag can be specified.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
2017-09-06 13:03:06 +02:00
Viktor Mihajlovski
f3f16a7ca4 netboot: Scripts for building a PXE-style netboot image for KVM
A set of scripts and a short documentation describing how to build
a network boot image simulating a PXELINUX-style boot process.

Starting with QEMU 2.10 it is possible to boot a KVM guest over a
network interface using DHCP/BOOTP. The boot process is triggered by
the network boot firmware that is part of QEMU and follows the usual
network boot pattern: a DHCP request is issued by the client and
answered by a DHCP/BOOTP server. The DHCP reply will contain a
TFPT server identification and a bootfile name. The client will
retrieve the bootfile from the TFTP server, load it into memory
and IPL it.

A very common way of setting up a boot server has been defined
by PXELINUX, an open source implementation of PXE. With PXELINUX
the bootfile is a small network boot loader that will retrieve
a potentially client-specific configuration file containing
further instructions for the final boot process (kernel, ramdisk,...).

The set of sample scripts contained in the netboot directory provide
directions for a Linux distributor or a boot server administrator
on how to build a network boot image usable for a simplified
PXELINUX-style network boot setup for s390.

Note that the sample scripts are implementing only a subset of PXELINUX
functionality, specifically the config file parsing. In order to
get full functionality, a more specialized boot loader program
like petitboot or pxe-kexec must be used in the ramdisk.

Further, a sample Dockerfile is provided along with instructions on how
to build the network boot image in a Docker container.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-31 17:41:15 +02:00
Harald Freudenberger
d029030308 chzcrypt: Corrected handling of insufficient permissions.
The -d and -e options did not show any failure message when
executed with insufficient permissions (e.g. not root user).
Now the behaviour is equal to the other options: A message
'chzcrypt: Error - can't write to xxx. Wrong permissions or
wrong tools version' is printed.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-31 17:41:15 +02:00
Harald Freudenberger
097c498340 lszcrypt: fix wrong wording in man page
The -c option was listed with <device-id> and the text
explained that device id may be a card or queue device id.
The --capability option only allows a card as argument so
the man page has been corrected to show this now correctly.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-31 17:41:15 +02:00
Harald Freudenberger
73d5e17026 lszcrypt: fix random domain printout when no config available
The sysfs files ap_control_domain_mask and ap_usage_domain_mask
may hold just a string "not supported" if there's no crypto
configuration available. However, lszcrypt always processed
the content of these files as hex number and so produced funny
output if there's no configuration data available.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-31 17:41:15 +02:00
Peter Oberparleiter
f3e552d67c zdev: Fix zdev dracut module temp file location
During processing, the zdev-provided dracut module creates a temporary
file using the mktemp tool. Due to a missing path specification
in the filename template, mktemp tries to create the temporary file
in the current working directory which fails if that directory is not
writable:

  # cd /sys
  # dracut -Nf
  mktemp: failed to create file via template 'dracut-zdev.XXXX': No such
  file or directory
  chzdev: Could not write to file : No such file or directory
  sed: can't read : No such file or directory
  chzdev: Could not open file : No such file or directory

Fix this by specifying option --tmpdir when calling mktemp.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-31 17:41:15 +02:00
Hendrik Brueckner
5ba519973f zkey: rename abrev_len -> abbrev_len
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-31 17:41:15 +02:00
Hendrik Brueckner
18f1730b92 zkey: correctly detect abbreviated commands
Abbreviated commands are not recognized and zkey issues an invalid
command error.

In is_command(), the abbreviated command string is copied into the
command_str variable.  Because this variable is not initialized and,
thus, might contain arbitrary data, a NUL-terminated is not guaranteed.
The following string comparison is very likely to fail.  Correct this
problem by comparing up to the length of the command string only.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-31 17:41:15 +02:00
Hendrik Brueckner
f1a5ab20b7 zkey: add blank between option and argument
Few options are displayed with their argument concatenated.  This
is due to the nature of the .BR roff macro.  Ensure to separate them
with a blank (using "\~" which is an unbreakable space that stretches
like a normal inter-word space when a line is adjusted).

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-31 17:41:15 +02:00
Philipp Kern
39382ec5fd systemd: Fix deprecated BindTo usage in ttyrun-getty@.service.in
BindTo was renamed to BindsTo in systemd back in v187 from July 2012.

Fixes: #1

Signed-off-by: Philipp Kern <pkern@debian.org>
Acked-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-23 10:41:55 +02:00
Ingo Franzki
2e8ad91d3d zkey: validate XTS key: ignore domain and card
When validating an XTS key, the 2 key parts are validated separately.
This can happen on different crypto cards, when more than one crypto
card is available to the system. Each key part can be validated on
a different card, however, the 2 cards need to have the same master
key, thus the master key validation pattern contained in the 2 key
parts are checked.

Signed-off-by: Ingo Franzki <ifranzki@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-22 19:24:48 +02:00
Michael Holzheu
7548b470c2 Prepare for next release
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-21 12:54:52 +02:00
Hendrik Brueckner
b4714e6113 zkey: use octal values instead of S_IRWX* constants
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-21 12:36:33 +02:00
Hendrik Brueckner
fe0b2d96f7 zkey: properly set umask to prohibit permissions to group and others
Set the umask for the zkey process to clear permissions for genernated
secure key files for group and others.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-21 12:36:33 +02:00
Hendrik Brueckner
b53793d1b6 zkey: add -ldl to LDLIBS (not LDFLAGS)
The LDFLAGS content is added before the object files causing unresolved
symbol dereferences during the build.  This actually happens so far on
Debian/Ubuntu instances.

Hence, use LDLIBS instead.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-21 12:36:33 +02:00
Ingo Franzki
9b5568d2ef zkey: Typo in man page
Signed-off-by: Ingo Franzki <ifranzki@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-21 12:36:33 +02:00
232 changed files with 16743 additions and 5268 deletions

4
.gitignore vendored
View File

@@ -3,7 +3,7 @@
#
*.o
*.a
*.d
*.o.d
#
# Ignore generated executables and other generated files
@@ -46,6 +46,7 @@ libutil/util_prg_example
libutil/util_rec_example
libutil/util_scandir_example
libzds/libzds.a
libvmcp/vmcp_example
mon_tools/mon_fsstatd
mon_tools/mon_procd
osasnmpd/osasnmpd
@@ -86,4 +87,5 @@ zipl/boot/*.exec
zipl/boot/data.h
zipl/src/chreipl_helper.device-mapper
zipl/src/zipl
zipl/src/zipl_helper.device-mapper
zkey/zkey

View File

@@ -10,15 +10,19 @@ List of all individuals having contributed content to s390-tools
- Benjamin Block
- Carsten Otte
- Christian Borntraeger
- Christian Ehrhardt
- Christof Schmitt
- Claudio Imbrenda
- Clemens von Mann
- Dan Horak
- Despina Papadopoulou
- Eberhard Pasch
- Einar Lueck
- Erwin Vicari
- Eugene Dvurechenski
- Eugene Crosser
- Eugene Dvurechenski
- Farhan Ali
- Fedor Loshakov
- Felix Beck
- Frank Blaschka
- Frank Munzert
@@ -26,8 +30,9 @@ List of all individuals having contributed content to s390-tools
- Fritz Elfert
- Gerald Schaefer
- Gerhard Tonn
- Hans Wippel
- Hannes Reinecke
- Hans-Joachim Picht
- Hans Wippel
- Harald Freudenberger
- Heiko Carstens
- Hendrik Brueckner
@@ -40,6 +45,7 @@ List of all individuals having contributed content to s390-tools
- Jan Glauber
- Jan Hoeppner
- Jan Willeke
- Javier Martinez Canillas
- Jean-Baptiste Joret
- Jens Remus
- Jochen Roehrig
@@ -62,6 +68,9 @@ List of all individuals having contributed content to s390-tools
- Mikhail Zaslonko
- Peter Oberparleiter
- Peter Tiedemann
- Philipp Kern
- Philipp Rudo
- Rafael Fonseca
- Raimund Schroeder
- Ralph Wuerthner
- Rene Trumpp
@@ -88,6 +97,7 @@ List of all individuals having contributed content to s390-tools
- Thomas Weber
- Ursula Braun
- Utz Bacher
- Vasily Gorbik
- Viktor Mihajlovski
- Volker Sameske
- Wolfgang Taphorn

View File

@@ -1,11 +1,110 @@
Release history for s390-tools (MIT version)
--------------------------------------------
* __v2.5.0 (2018-06-08)__
For Linux kernel version: 4.17
Changes of existing tools:
- zdev: Add support for reading firmware configuration files
- zipl: Add BootLoaderSpec support
- scripts: Add script to switch zipl config to a BootLoaderSpec setup
Bug Fixes:
- lsluns: Print a message if no adapter or port exists
* __v2.4.0 (2018-05-07)__
For Linux kernel version: 4.16
Changes of existing tools:
- dbginfo: Gather nvme related data
- zipl: Rewrite helper script in C
- libutil: Add function util_strstrip
- libvmcp: Introduce libvmcp
- zipl: Extend DASD stand-alone dumpers to drop zero pages
- zgetdump: Add verbose option
- zgetdump: Add 'Dump file size' field for zgetdump -i output
- cpumf: Add IBM z14 ZR1 to the CPU Measurement Facility model list
- zkey: Add build dependency to OpenSSL (libcrypto)
- zkey: Add keystore implementation
Bug Fixes:
- hmcdrvfs: fix parsing of link count >= 1000
- zgetdump: Avoid Segfault on processing dumps with memory limit
- chreipl: correct fcp reipl sysfs write sequence
- udev: Replace WAIT_FOR with TEST keyword
* __v2.3.0 (2018-01-30)__
For Linux kernel version: 4.15
Changes of existing tools:
- lscpumf: Add support for IBM z14 hardware counters
- libdasd: Introduce libdasd and use for dasd tools
- zipl: Always build and link without PIE
Bug Fixes:
- zgetdump: Fix handling of DASD multi-volume dump for partitions above 4 GB
- zdev: Fix zdev dracut module aborting on unknown root device
* __v2.2.0 (2017-12-07)__
For Linux kernel version: 4.14
Removed tools:
- lsmem/chmem: Moved to util-linux >= 2.30
Changes of existing tools:
- lszcrypt: Add CEX6S support
- cpuplugd/mon_tools: Improve systemctl start error handling
- systemd: Install also the unit configuration files
Bug Fixes:
- build process: Fix parallel build for libutil
- cpi: Add missing Install section to service unit
- lsluns: Do not scan (all) if filters match nothing
- lsluns: Enhance usage statement and man page
- zdev: Use correct path to vmcp binary
- ziomon: Re-add missing line in ziomon_fcpconf
- ziomon: Fix non-zero return code in ziomon_util
- zipl: Remove invalid dasdview command line option
* __v2.1.0 (2017-09-25)__
For Linux kernel version: 4.13
Added new 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
Changes of existing tools:
- lsqeth/zdev: 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
* __v2.0.0 (2017-08-21)__
- Publish package under the MIT license with the same contents as
the already available s390-tools-1.39.0
Previous releases of s390-tools can be found on the IBM Developer Works web pages:
Previous releases of s390-tools can be found on the IBM Developer Works
web pages:
- https://www.ibm.com/developerworks/linux/linux390/s390-tools.html

47
CODINGSTYLE.md Normal file
View File

@@ -0,0 +1,47 @@
Coding guidelines for s390-tools
================================
For s390-tools the preferred language is C. We provide libraries, e.g.
[`libutil`](libutil) that should be used by all tools if possible.
The coding style is based on the Linux [kernel guidelines]. Therefore, use
the [checkpatch] tool for verification before you submit a patch.
[kernel guidelines]: https://www.kernel.org/doc/html/latest/process/coding-style.html
[checkpatch]: https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl
Below we describe some additional things that we want you to consider when
writing new code for s390-tools.
This package started in 2001 and has a long "tradition" - therefore, older tools
might not follow all recommendations. Note that when changing existing code,
consistency could have priority over applying rules.
Standard abbreviations
----------------------
The abbreviations below are recommended to be used in the source code.
| __Short Name__ | __Long Name__ |
|:----------------|:--------------------------------------------------|
| attr | Attribute |
| blk | Block |
| buf | Buffer |
| col | Column |
| count | Count |
| desc | Description |
| dir | Directory |
| fd | File descriptor (open) |
| fp | File pointer (fopen) |
| len | Length |
| lib | Library |
| mod | Module |
| nr | Number |
| parm | Parameter |
| path | File path |
| ptr | Pointer |
| rc | Return code |
| size | Size |
| src | Source |
| str | String |
| sym | Symbol |

View File

@@ -42,24 +42,222 @@ Developer's Certificate of Origin 1.1
this project or the open source license(s) involved.
```
If you can certify the above, just add a line saying:
If you can certify the above, just add a line stating the following at the
bottom of each of your commit messages:
```
Signed-off-by: Random Developer <random@developer.example.org>
```
Please use your real name (no pseudonyms or anonymous contributions).
Please use your real name and a valid e-mail address (no pseudonyms or anonymous
contributions).
Submitting code
---------------
The preferred way is to create a github pull request for your code.
The preferred way is to create GitHub pull requests for your code contributions.
Please create separate pull requests for each logical enhancement, new feature,
or fix.
Coding guidelines
-----------------
For s390-tools the preferred language is C. We provide libraries, e.g. libutil
that should be used by all tools if possible.
Before you submit your code please consider our recommendations in the
[CODINGSTYLE](CODINGSTYLE.md) document.
The coding style is based on the Linux kernel guidelines. Therefore, use
the checkpatch tool [1] for verification before you submit a patch.
GitHub workflow for contributions
---------------------------------
In the examples below we use this fictive identity:
[1] https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl
- Name: Random Developer
- E-mail: random@developer.example.org
- GitHub ID: random-developer
### Setup GitHub and local git
1. Create a fork of this repository by clicking the `Fork` button on the top
right of the [s390-tools](https://github.com/ibm-s390-tools/s390-tools)
main page
2. Clone your forked repository to your local development system
```
$ git clone https://github.com/random-developer/s390-tools.git
```
3. Configure a remote called "upstream" pointing to the official
s390-tools repository on GitHub
```
$ cd s390-tools
~/s390-tools $ git remote add upstream https://github.com/ibm-s390-tools/s390-tools.git
```
4. Verify your remotes
```
~/s390-tools $ git remote -v
origin https://github.com/random-developer/s390-tools.git (fetch)
origin https://github.com/random-developer/s390-tools.git (push)
upstream https://github.com/ibm-s390-tools/s390-tools.git (fetch)
upstream https://github.com/ibm-s390-tools/s390-tools.git (push)
```
You now have two remotes: The "origin" remote points to your fork
and the "upstream" remote to the official s390-tools repository.
5. Configure your git user name and e-mail
```
~/s390-tools $ git config user.name "Random Developer"
~/s390-tools $ git config user.email "random@developer.example.com"
```
### Create a pull request
1. Create and checkout a new branch for your contribution
```
~/s390-tools $ git checkout -b contrib-doc-pr
```
2. Make your changes to the code
```
~/s390-tools $ vim CONTRIBUTING.md
```
3. Build and test your contribution
```
~/s390-tools $ make clean all
~/s390-tools $ # Whatever you have to do for testing
```
4. Commit your changes
```
~/s390-tools $ git add CONTRIBUTING.md
~/s390-tools $ git commit -s
```
Provide a meaningful commit message including your "Signed-off-by" line to
each commit:
```
CONTRIBUTING: Outline steps to submit code
Explain in more detail how to submit s390-tools contributions as GitHub
pull requests.
Signed-off-by: Random Developer <random@developer.example.com>
```
5. Use the [checkpatch] tool to validate your commits
```
~/s390-tools $ checkpatch.pl --no-tree --git master..HEAD
```
Interpret the checkpatch messages wisely - e.g. the 80 character rule can be
ignored for printf format strings.
[checkpatch]: https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl
6. Push the changes to your fork of the repository
```
~/s390-tools $ git push origin contrib-doc-pr
```
7. Go to the GitHub website of your s390-tools fork and create a pull request
for your branch "contrib-doc-pr"
### Update a pull request during review
If there are changes requested during the review process, you have to update
your code in the pull request.
To retain the existing review comments, add commits on top of your pull request
branch. Depending on the size and number of changes, a rebase of the pull
request might be required. This will be communicated during the review.
1. Update your code with new commits
```
~/s390-tools $ vi CONTRIBUTING.md
~/s390-tools $ git add CONTRIBUTING.md
~/s390-tools $ git commit -s -m "CONTRIBUTING: Add update PR info"
```
2. Update your pull request by pushing changes
```
~/s390-tools $ git push origin contrib-doc-pr
```
### Finalize a pull request
After the review process is finished or if you are explicitly asked for it,
you have to create a clean commit series.
1. Save branch to "contrib-doc-pr.v1"
```
$ cd s390-tools
~/s390-tools $ git branch contrib-doc-pr.v1
```
2. Use interactive git rebase to merge commits, adjust commit messages,
and rebase onto your local master branch
```
~/s390-tools $ git rebase -i master
```
An editor is started and shows the following:
```
pick 2c73b9fc CONTRIBUTING: Outline steps to submit code
pick fcfb0412 CONTRIBUTING: Add update PR info
```
To merge the update into the original commit, replace "pick fcfb0412"
with "squash fcfb0412".
```
pick 2c73b9fc CONTRIBUTING: Outline steps to submit code
squash fcfb0412 CONTRIBUTING: Add update PR info
```
Save the document and exit the editor to finish the merge. Another editor
window is presented to modify the commit message.
You now could change the commit message as follows:
```
CONTRIBUTING: Outline steps to submit code
Explain in more detail how to submit s390-tools contributions as GitHub
pull requests and how to update already submitted pull requests.
Signed-off-by: Random Developer <random@developer.example.com>
```
With interactive rebasing you can also change the order of commits and
modify commit messages with "reword".
3. Use `git push` with the force option to replace the existing pull request
with your locally modified commits
```
~/s390-tools $ git push --force origin contrib-doc-pr
```
### Rebase a pull request
If changes are made to the master branch in the official s390-tools
repository you may be asked to rebase your branch with your contribution
onto it. This can be required to prevent any merge conflicts that might
arise when integrating your contribution.
1. Fetch all upstream changes from the official s390-tools repository,
rebase your local master branch and update the master branch
on your fork
```
~/s390-tools $ git fetch upstream
~/s390-tools $ git checkout master
~/s390-tools $ git rebase upstream/master
~/s390-tools $ git push origin master
```
2. Rebase your branch with your contribution onto the master branch of
the official s390-tools repository
```
~/s390-tools $ git checkout contrib-doc-pr
~/s390-tools $ git rebase master
```
3. Use `git push` with the force option to replace the existing pull
request with your locally modified commits
```
~/s390-tools $ git push --force origin contrib-doc-pr
```

View File

@@ -3,12 +3,12 @@ ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/ar
# Include common definitions
include common.mak
LIB_DIRS = libvtoc libu2s libutil libzds libdasd libvmdump libccw
LIB_DIRS = libvtoc libu2s libutil libzds libdasd libvmdump libccw libvmcp
TOOL_DIRS = zipl zdump fdasd dasdfmt dasdview tunedasd \
tape390 osasnmpd qetharp ip_watcher qethconf scripts zconf \
vmconvert vmcp man mon_tools dasdinfo vmur cpuplugd ipl_tools \
ziomon iucvterm hyptop cmsfs-fuse qethqoat zfcpdump zdsfs cpumf \
systemd hmcdrvfs cpacfstats zdev dump2tar zkey
systemd hmcdrvfs cpacfstats zdev dump2tar zkey netboot etc
SUB_DIRS = $(LIB_DIRS) $(TOOL_DIRS)
all: $(TOOL_DIRS)

View File

@@ -11,6 +11,7 @@ The package also contains the following files:
* [LICENSE](LICENSE): The MIT license that applies to this package
* [CHANGELOG](CHANGELOG.md): The history of s390-tools versions
* [AUTHORS](AUTHORS.md): A list of all authors of the s390-tools package
* [CODINGSTYLE](CODINGSTYLE.md): Recommendations for writing s390-tools code
Package contents
----------------
@@ -35,6 +36,8 @@ Package contents
- 57-osasnmpd.rules: udev rules for osasnmpd.
- 60-readahead.rules: udev rules to set increased "default max readahead".
- 40-z90crypt.rules: udev rules for z90crypt driver
- 90-cpi.rules: udev rule to update Control-Program-Information when KVM is
used.
* systemd units:
- cpi.service: Unit to apply CPI settings
@@ -122,14 +125,13 @@ Package contents
- lsscm: List information about available Storage Class Memory
Increments.
- chchp: Modify channel-path state.
- lsluns: List available SCSI LUNs depending on adapter or port.
- lsluns: List LUNs discovered in the FC SAN,
or show encryption state of attached LUNs.
- lszcrypt: Show Information about zcrypt devices and configuration.
- chzcrypt: Modify the zcrypt configuration.
- znetconf: List and configure network devices for s390 network adapters.
- cio_ignore: Query and modify the contents of the CIO device driver
blacklist.
- lsmem: Display the online status of the available memory.
- chmem: Set hotplug memory online or offline.
- dasdstat: Configure and format the debugfs based DASD statistics data.
* zkey:
@@ -234,6 +236,10 @@ Package contents
arbitrary files. It works even when the size of the actual file content
is not known beforehand (e.g. FIFOs, sysfs files).
* netboot:
Provides simple tools to create a binary that can be used to implement
simple network boot setups following the PXELINUX conventions.
For more information refer to the following publications:
* "Device Drivers, Features, and Commands" chapter "Useful Linux commands"
@@ -250,19 +256,22 @@ HAVE_FUSE=0`".
The following table provides an overview of the used libraries and
build options:
| __LIBRARY__|__BUILD OPTION__| __TOOLS__ |
|------------|:--------------:|:-------------------------------------:|
| fuse | `HAVE_FUSE` | cmsfs-fuse, zdsfs, hmcdrvfs, zgetdump |
| zlib | `HAVE_ZLIB` | zgetdump, dump2tar |
| ncurses | `HAVE_NCURSES` | hyptop |
| pfm | `HAVE_PFM` | cpacfstats |
| net-snmp | `HAVE_SNMP` | osasnmpd |
| __LIBRARY__ | __BUILD OPTION__ | __TOOLS__ |
|----------------|:------------------:|:-------------------------------------:|
| fuse | `HAVE_FUSE` | cmsfs-fuse, zdsfs, hmcdrvfs, zgetdump |
| zlib | `HAVE_ZLIB` | zgetdump, dump2tar |
| ncurses | `HAVE_NCURSES` | hyptop |
| pfm | `HAVE_PFM` | cpacfstats |
| net-snmp | `HAVE_SNMP` | osasnmpd |
| glibc-static | `HAVE_LIBC_STATIC` | zfcpdump |
| openssl | `HAVE_OPENSSL` | zkey |
This table lists additional build or install options:
| __COMPONENT__ | __OPTION__ | __TOOLS__ |
|----------------|:----------------:|:-------------------------------:|
| dracut | `HAVE_DRACUT` | zdev |
| initramfs-tools| `HAVE_INITRAMFS` | zdev |
The s390-tools build process uses "pkg-config" if available and hard-coded
compiler and linker options otherwise.
@@ -280,9 +289,9 @@ the different tools are provided:
http://net-snmp.sourceforge.net
* lsluns:
For executing the lsluns script the sg_luns command must be available.
The sg_luns executable is part of the SCSI generic device driver package
(sg3 utils/sg utils).
For executing the lsluns script the sg_luns and sg_inq commands must
be available. The sg_luns and sg_inq executables are part of the
SCSI generic device driver package (sg3 utils/sg utils).
* ziomon tools:
For running the ziomon tools the following tools/packages are required:
@@ -359,3 +368,12 @@ the different tools are provided:
For running znetconf these programs are required:
- modprobe (kmod)
- vmcp (s390-tools)
* zkey:
For building the zkey tools you need openssl version 0.9.7 or newer installed
(openssl-devel.rpm). Tip: you may skip the zkey build by adding
`HAVE_OPENSSL=0` to the make invocation.
A new group 'zkeyadm' needs to be created and all users intending to use the
tool must be added to this group. The owner of the default key repository
'/etc/zkey/repository' must be set to group 'zkeyadm' with write permission
for this group.

135
bin/mk-authors Executable file
View File

@@ -0,0 +1,135 @@
#!/bin/bash
#
# mk-authors - Update the s390-tools authors file (AUTHORS.md)
#
# Invocation examples:
#
# $ mk-authors
# $ mk-authors -t v2.0.0
#
# Copyright IBM Corp. 2017
#
# s390-tools is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.
cmd=$(basename $0)
authors_file="AUTHORS.md"
cleanup()
{
test -f $authors_file_tmp && rm -f $authors_file_tmp
}
trap cleanup EXIT
#
# Print usage information
#
print_usage()
{
cat <<EoUSAGE
Usage: $cmd [-t LAST_GIT_TAG]
Add all new authors since last release to the $authors_file file. Without
the -t option the tool uses the last available git tag as last release.
The tool should be called form the s390-tools master branch.
OPTIONS
-t, --tag LAST_GIT_TAG Use git tag LAST_GIT_TAG as starting point
-h, --help Print this help, then exit
EoUSAGE
}
#
# Print help hint for option parsing error
#
print_parse_error_and_exit()
{
echo "Try '$cmd -h' for more information." >&2
exit 1
}
#
# Parse options
#
opts=$(getopt -o ht: -l help,tag: -n $cmd -- "$@")
if [ $? != 0 ]; then
print_parse_error_and_exit
fi
# Use eval to remove getopt quotes
eval set -- $opts
while [ -n $1 ]; do
case $1 in
-h | --help)
print_usage
exit 0
;;
-t | --tag)
release_tag_last=$2
shift 2
;;
--)
shift
break
;;
*)
break
;;
esac
done
if [ $# != 0 ]; then
echo "$cmd: Invalid argument $1" >&2
print_parse_error_and_exit
fi
#
# Get git root and last release tag
#
git_root=$(git rev-parse --show-toplevel 2> /dev/null)
if [ $? -ne 0 ]; then
echo "$cmd: Use tool within s390-tools git repository" >&2
print_parse_error_and_exit
fi
authors_file_path=$git_root/$authors_file
# Get last release tag if not specified via -t
if [ -z $release_tag_last ]; then
tag_commit=$(git rev-list --tags --max-count=1)
release_tag_last=$(git describe --tags $tag_commit)
fi
# Verify release tag
git show $release_tag_last &> /dev/null
if [ $? -ne 0 ]; then
echo "$cmd: Cannot find tag '$release_tag_last'" >&2
print_parse_error_and_exit
fi
#
# Update authors file
#
# Create temporary file for new author list
authors_file_tmp=$(mktemp /tmp/authors.XXXXXX)
echo "$cmd: Adding new authors since tag: $release_tag_last"
{
# Print authors list without header
tail -n +4 $authors_file_path
# Add the new authors
git log --format="- %an" $release_tag_last..
# Then sort everything and remove duplicates
} | sort | uniq > $authors_file_tmp
# Create new AUTHORS file with header ...
cat <<EoHEADER > $authors_file_path
List of all individuals having contributed content to s390-tools
----------------------------------------------------------------
EoHEADER
# ... and add new content
cat $authors_file_tmp >> $authors_file_path
cat <<EoUPDATE_MSG
- Updated file: $authors_file_path
- Verify changes with: git diff $authors_file_path
- Do a manual *cleanup* before commiting if necessary.
EoUPDATE_MSG

View File

@@ -5,7 +5,7 @@ COMMON_INCLUDED = true
# The variable "DISTRELEASE" should be overwritten in rpm spec files with:
# "make DISTRELEASE=%{release}" and "make install DISTRELEASE=%{release}"
VERSION = 2
RELEASE = 0
RELEASE = 5
PATCHLEVEL = 0
DISTRELEASE = build-$(shell date +%Y%m%d)
S390_TOOLS_RELEASE = $(VERSION).$(RELEASE).$(PATCHLEVEL)-$(DISTRELEASE)
@@ -113,9 +113,10 @@ DEFAULT_LDFLAGS = -rdynamic
# $2: Name of include file to check
# $3: Name of required devel package
# $4: Option to skip build (e.g. HAVE_FUSE=0)
# $5: Additional compiler & linker options (optional)
#
check_dep=\
printf "\#include <%s>" $2 | ( $(CC) $(filter-out --coverage, $(ALL_CFLAGS)) $(ALL_CPPFLAGS) -c -o /dev/null -xc - ) > /dev/null 2>&1; \
printf "\#include <%s>\n int main(void) {return 0;}" $2 | ( $(CC) $(filter-out --coverage, $(ALL_CFLAGS)) $(ALL_CPPFLAGS) $5 -o /dev/null -xc - ) > /dev/null 2>&1; \
if [ $$? != 0 ]; \
then \
printf " REQCHK %s (%s)\n" $1 $2; \
@@ -167,13 +168,14 @@ MANDIR = $(INSTALLDIR)/usr/share/man
VARDIR = $(INSTALLDIR)/var
TOOLS_DATADIR = $(INSTALLDIR)/usr/share/s390-tools
TOOLS_LIBDIR = $(INSTALLDIR)/lib/s390-tools
ZFCPDUMP_DIR = $(INSTALLDIR)/lib/s390-tools/zfcpdump
ZFCPDUMP_DIR = $(TOOLS_LIBDIR)/zfcpdump
# Systemd support files are installed only if a directory is specified
# for SYSTEMDSYSTEMUNITDIR (e.g. /lib/systemd/system)
SYSTEMDSYSTEMUNITDIR =
INSTDIRS = $(USRSBINDIR) $(USRBINDIR) $(BINDIR) $(LIBDIR) $(MANDIR) \
$(SYSCONFDIR) $(TOOLS_LIBDIR) $(TOOLS_DATADIR) \
$(SYSCONFDIR) $(SYSCONFDIR)/sysconfig \
$(TOOLS_LIBDIR) $(TOOLS_DATADIR) \
$(ZFCPDUMP_DIR) $(SYSTEMDSYSTEMUNITDIR)
OWNER = $(shell id -un)
GROUP = $(shell id -gn)
@@ -193,12 +195,14 @@ ALL_CFLAGS = -DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
-DS390_TOOLS_LIBDIR=$(TOOLS_LIBDIR) \
-DS390_TOOLS_DATADIR=$(TOOLS_DATADIR) \
-DS390_TOOLS_SYSCONFDIR=$(SYSCONFDIR) \
-DS390_TOOLS_BINDIR=$(BINDIR) \
$(CFLAGS)
CXXFLAGS ?= $(DEFAULT_CFLAGS) $(OPT_FLAGS)
ALL_CXXFLAGS = -DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
-DS390_TOOLS_LIBDIR=$(TOOLS_LIBDIR) \
-DS390_TOOLS_DATADIR=$(TOOLS_DATADIR) \
-DS390_TOOLS_SYSCONFDIR=$(SYSCONFDIR) \
-DS390_TOOLS_BINDIR=$(BINDIR) \
$(CXXFLAGS)
ALL_CPPFLAGS = -I $(rootdir)include $(CPPFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
@@ -214,12 +218,22 @@ endif
export AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP INSTALL CFLAGS CXXFLAGS \
LDFLAGS CPPFLAGS ALL_CFLAGS ALL_CXXFLAGS ALL_LDFLAGS ALL_CPPFLAGS
ifneq ($(shell $(CC_SILENT) -dumpspecs 2>/dev/null | grep -e '[^f]no-pie'),)
NO_PIE_CFLAGS := -fno-pie
NO_PIE_LINKFLAGS := -no-pie
NO_PIE_LDFLAGS := -no-pie
else
NO_PIE_CFLAGS :=
NO_PIE_LINKFLAGS :=
NO_PIE_LDFLAGS :=
endif
# Overwrite implicite makefile rules for having nice compile output
%.o: %.c
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
ifeq ("${C}","1")
$(CHECKTOOL) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
endif
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
%.o: %.cpp
$(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $@
@@ -324,6 +338,10 @@ $(rootdir)/libvmdump/libvmdump.a: $(rootdir)/libvmdump
$(MAKE) -C $(rootdir)/libvmdump/ libvmdump.a
.PHONY: $(rootdir)/libvmdump
$(rootdir)/libvmcp/libvmcp.a: $(rootdir)/libvmcp
$(MAKE) -C $(rootdir)/libvmcp/ libvmcp.a
.PHONY: $(rootdir)/libvmcp
$(rootdir)/zipl/boot/data.o:
$(MAKE) -C $(rootdir)/zipl/boot/ data.o

View File

@@ -97,6 +97,7 @@ int perf_init(void)
memset(&pfm_event, 0, sizeof(pfm_event));
pfm_arg.attr = &pfm_event;
pfm_arg.size = sizeof(pfm_arg);
pfm_event.size = sizeof(pfm_event);
/* search for the counter's corresponding pfm name */
for (i = ALL_COUNTER-1; i >= 0; i--)

View File

@@ -4,10 +4,12 @@ include ../common.mak
CPUMF_DATADIR = $(TOOLS_DATADIR)/cpumf
DATA_FILES = cpum-cf-hw-counter.map cpum-cf-generic.ctr \
DATA_FILES = cpum-cf-hw-counter.map \
cpum-cf-cfvn-1.ctr cpum-cf-cfvn-3.ctr \
cpum-cf-csvn-generic.ctr \
cpum-cf-extended-z10.ctr cpum-cf-extended-z196.ctr \
cpum-cf-extended-zEC12.ctr cpum-sf-modes.ctr \
cpum-cf-extended-z13.ctr
cpum-cf-extended-z13.ctr cpum-cf-extended-z14.ctr
LIB_FILES = bin/cpumf_helper
USRBIN_SCRIPTS = bin/lscpumf
USRSBIN_SCRIPTS = bin/chcpumf

54
cpumf/bin/cpumf_helper.in Normal file → Executable file
View File

@@ -172,7 +172,7 @@ sub cpumf_parse_ctrdef($;$)
# Parse short description (optional)
if ($line =~ m/^Short-Description:\s*(\S.*)?$/) {
$h->{ctr}->{shortdesc} = $1 || "";
$h->{$ctr}->{shortdesc} = $1 || "";
# Parse start of counter description
} elsif ($line =~ m/^Description:\s*(\S.*)?$/) {
@@ -210,6 +210,8 @@ my $system_z_hwtype_map = {
2828 => 'IBM zEnterprise BC12',
2964 => 'IBM z13',
2965 => 'IBM z13s',
3906 => 'IBM z14',
3907 => 'IBM z14 ZR1',
};
sub get_hardware_type()
@@ -228,6 +230,28 @@ sub get_hardware_type()
return $type;
}
sub get_cpum_cf_version()
{
my $SL;
my $v = {
cfvn => 0,
csvn => 0,
};
return $v unless open($SL, '<', $SERVICE_LEVELS);
while (my $line = <$SL>) {
# CPU-MF: Counter facility: version=3.5
if ($line =~ m/^CPU-MF: Counter facility: version=(\d+)\.(\d+)/) {
$v->{cfvn} = $1; # Counter First Version Number
$v->{csvn} = $2; # Counter Second Version Number
last;
}
}
close($SL);
return $v
}
sub cpumf_load_ctrdef($;$)
{
my $hw_type = shift();
@@ -236,10 +260,20 @@ sub cpumf_load_ctrdef($;$)
my $ctrmap = cpumf_hardware_counter_map();
return unless $ctrmap;
# Obtain CPU-MF counter facility versions
my $version = get_cpum_cf_version();
# List of "generic" counter sets
my @def = ();
push @def, "cfvn-" . $version->{cfvn};
push @def, "csvn-generic";
my $h = {};
# Load generic counter sets
cpumf_parse_ctrdef($ctrmap->{0}, $h) or
croak "Failed to read generic counter definition: $!\n";
# Load counter set definition
foreach my $ent (@def) {
cpumf_parse_ctrdef($ctrmap->{$ent}, $h) or
croak "Failed to read counter definition for $ent: $!\n";
}
# Load hardware model specific counter set(s)
if ($hw_type && $ctrmap->{$hw_type}) {
# Hardware-model specific counter sets are:
@@ -322,7 +356,7 @@ sub cpumf_helper_main()
GetOptions(
"i|info" => \$conf->{opt_info},
"c|counter=i" => \$conf->{opt_ctr},
"ctr-def=i" => \$conf->{opt_ctrdef},
"ctr-def=s" => \$conf->{opt_ctrdef},
"hardware-type" => \$conf->{opt_hwtype},
"ctr-set-names" => \$conf->{opt_ctrset_names},
"ctr-set-ids" => \$conf->{opt_ctrset_ids},
@@ -427,11 +461,13 @@ B<--ctr-def> option and specify the System z hardware type.
Displays the System z hardware type.
=item B<--ctr-def> I<hardware_type>
=item B<--ctr-def> I<ctr-definition>
Displays detailed information about a particular counter set for the specified
System z hardware type, I<hardware_type>. If you specify zero for
I<hardware_type>, type-independent counter sets are displayed.
Displays detailed information about the specified counter definition.
Valid counter definitions start with C<cfvn-> or <csvn-> followed by
the counter first/second version number of the CPU-Measurement Counter
Facility. To display counter information of model-specific counter
sets, specify the System z hardware type for I<ctr-definition>.
=item B<--ctr-set-names>

View File

@@ -0,0 +1,60 @@
Counter: 0 Name:CPU_CYCLES
Short-Description:CPU Cycles
Description:
Cycle Count
.
Counter: 1 Name:INSTRUCTIONS
Short-Description:Instructions
Description:
Instruction Count
.
Counter: 2 Name:L1I_DIR_WRITES
Short-Description:L1I Directory Writes
Description:
Level-1 I-Cache Directory Write Count
.
Counter: 3 Name:L1I_PENALTY_CYCLES
Short-Description:L1I Penalty Cycles
Description:
Level-1 I-Cache Penalty Cycle Count
.
Counter: 4 Name:L1D_DIR_WRITES
Short-Description:L1D Directory Writes
Description:
Level-1 D-Cache Directory Write Count
.
Counter: 5 Name:L1D_PENALTY_CYCLES
Short-Description:L1D Penalty Cycles
Description:
Level-1 D-Cache Penalty Cycle Count
.
Counter: 32 Name:PROBLEM_STATE_CPU_CYCLES
Short-Description:Problem-State CPU Cycles
Description:
Problem-State Cycle Count
.
Counter: 33 Name:PROBLEM_STATE_INSTRUCTIONS
Short-Description:Problem-State Instructions
Description:
Problem-State Instruction Count
.
Counter: 34 Name:PROBLEM_STATE_L1I_DIR_WRITES
Short-Description:Problem-State L1I Directory Writes
Description:
Problem-State Level-1 I-Cache Directory Write Count
.
Counter: 35 Name:PROBLEM_STATE_L1I_PENALTY_CYCLES
Short-Description:Problem-State L1I Penalty Cycles
Description:
Problem-State Level-1 I-Cache Penalty Cycle Count
.
Counter: 36 Name:PROBLEM_STATE_L1D_DIR_WRITES
Short-Description:Problem-State L1D Directory Writes
Description:
Problem-State Level-1 D-Cache Directory Write Count
.
Counter: 37 Name:PROBLEM_STATE_L1D_PENALTY_CYCLES
Short-Description:Problem-State L1D Penalty Cycles
Description:
Problem-State Level-1 D-Cache Penalty Cycle Count
.

View File

@@ -0,0 +1,40 @@
Counter: 0 Name:CPU_CYCLES
Short-Description:CPU Cycles
Description:
Cycle Count
.
Counter: 1 Name:INSTRUCTIONS
Short-Description:Instructions
Description:
Instruction Count
.
Counter: 2 Name:L1I_DIR_WRITES
Short-Description:L1I Directory Writes
Description:
Level-1 I-Cache Directory Write Count
.
Counter: 3 Name:L1I_PENALTY_CYCLES
Short-Description:L1I Penalty Cycles
Description:
Level-1 I-Cache Penalty Cycle Count
.
Counter: 4 Name:L1D_DIR_WRITES
Short-Description:L1D Directory Writes
Description:
Level-1 D-Cache Directory Write Count
.
Counter: 5 Name:L1D_PENALTY_CYCLES
Short-Description:L1D Penalty Cycles
Description:
Level-1 D-Cache Penalty Cycle Count
.
Counter: 32 Name:PROBLEM_STATE_CPU_CYCLES
Short-Description:Problem-State CPU Cycles
Description:
Problem-State Cycle Count
.
Counter: 33 Name:PROBLEM_STATE_INSTRUCTIONS
Short-Description:Problem-State Instructions
Description:
Problem-State Instruction Count
.

View File

@@ -1,130 +1,98 @@
Counter: 0 Name:CPU_CYCLES
Description:
Cycle Count
.
Counter: 1 Name:INSTRUCTIONS
Description:
Instruction Count
.
Counter: 2 Name:L1I_DIR_WRITES
Description:
Level-1 I-Cache Directory Write Count
.
Counter: 3 Name:L1I_PENALTY_CYCLES
Description:
Level-1 I-Cache Penalty Cycle Count
.
Counter: 4 Name:L1D_DIR_WRITES
Description:
Level-1 D-Cache Directory Write Count
.
Counter: 5 Name:L1D_PENALTY_CYCLES
Description:
Level-1 D-Cache Penalty Cycle Count
.
Counter: 32 Name:PROBLEM_STATE_CPU_CYCLES
Description:
Problem-State Cycle Count
.
Counter: 33 Name:PROBLEM_STATE_INSTRUCTIONS
Description:
Problem-State Instruction Count
.
Counter: 34 Name:PROBLEM_STATE_L1I_DIR_WRITES
Description:
Problem-State Level-1 I-Cache Directory Write Count
.
Counter: 35 Name:PROBLEM_STATE_L1I_PENALTY_CYCLES
Description:
Problem-State Level-1 I-Cache Penalty Cycle Count
.
Counter: 36 Name:PROBLEM_STATE_L1D_DIR_WRITES
Description:
Problem-State Level-1 D-Cache Directory Write Count
.
Counter: 37 Name:PROBLEM_STATE_L1D_PENALTY_CYCLES
Description:
Problem-State Level-1 D-Cache Penalty Cycle Count
.
Counter: 64 Name:PRNG_FUNCTIONS
Short-Description:PRNG Functions
Description:
Total number of the PRNG functions issued by the CPU
.
Counter: 65 Name:PRNG_CYCLES
Short-Description:PRNG Cycles
Description:
Total number of CPU cycles when the DEA/AES coprocessor is busy
performing PRNG functions issued by the CPU
.
Counter: 66 Name:PRNG_BLOCKED_FUNCTIONS
Short-Description:PRNG Blocked Functions
Description:
Total number of the PRNG functions that are issued by the CPU and are
blocked because the DEA/AES coprocessor is busy performing a function
issued by another CPU
.
Counter: 67 Name:PRNG_BLOCKED_CYCLES
Short-Description:PRNG Blocked Cycles
Description:
Total number of CPU cycles blocked for the PRNG functions issued by
the CPU because the DEA/AES coprocessor is busy performing a function
issued by another CPU
.
Counter: 68 Name:SHA_FUNCTIONS
Short-Description:SHA Functions
Description:
Total number of SHA functions issued by the CPU
.
Counter: 69 Name:SHA_CYCLES
Short-Description:SHA Cycles
Description:
Total number of CPU cycles when the SHA coprocessor is busy performing
the SHA functions issued by the CPU
.
Counter: 70 Name:SHA_BLOCKED_FUNCTIONS
Short-Description:SHA Blocked Functions
Description:
Total number of the SHA functions that are issued by the CPU and are
blocked because the SHA coprocessor is busy performing a function issued
by another CPU
.
Counter: 71 Name:SHA_BLOCKED_CYCLES
Short-Description:SHA Bloced Cycles
Description:
Total number of CPU cycles blocked for the SHA functions issued by the
CPU because the SHA coprocessor is busy performing a function issued
by another CPU
.
Counter: 72 Name:DEA_FUNCTIONS
Short-Description:DEA Functions
Description:
Total number of the DEA functions issued by the CPU
.
Counter: 73 Name:DEA_CYCLES
Short-Description:DEA Cycles
Description:
Total number of CPU cycles when the DEA/AES coprocessor is busy
performing the DEA functions issued by the CPU
.
Counter: 74 Name:DEA_BLOCKED_FUNCTIONS
Short-Description:DEA Blocked Functions
Description:
Total number of the DEA functions that are issued by the CPU and are
blocked because the DEA/AES coprocessor is busy performing a function
issued by another CPU
.
Counter: 75 Name:DEA_BLOCKED_CYCLES
Short-Description:DEA Blocked Cycles
Description:
Total number of CPU cycles blocked for the DEA functions issued by the
CPU because the DEA/AES coprocessor is busy performing a function issued
by another CPU
.
Counter: 76 Name:AES_FUNCTIONS
Short-Description:AES Functions
Description:
Total number of AES functions issued by the CPU
.
Counter: 77 Name:AES_CYCLES
Short-Description:AES Cycles
Description:
Total number of CPU cycles when the DEA/AES coprocessor is busy
performing the AES functions issued by the CPU
.
Counter: 78 Name:AES_BLOCKED_FUNCTIONS
Short-Description:AES Blocked Functions
Description:
Total number of AES functions that are issued by the CPU and are blocked
because the DEA/AES coprocessor is busy performing a function issued
by another CPU
.
Counter: 79 Name:AES_BLOCKED_CYCLES
Short-Description:AES Blocked Cycles
Description:
Total number of CPU cycles blocked for the AES functions issued by the
CPU because the DEA/AES coprocessor is busy performing a function issued

View File

@@ -1,96 +1,114 @@
Counter: 128 Name:L1I_L2_SOURCED_WRITES
Short-Description:L1I L2 Sourced Writes
Description:
A directory write to the Level-1 I-Cache directory where the returned
cache line was sourced from the Level-2 (L1.5) cache
.
Counter: 129 Name:L1D_L2_SOURCED_WRITES
Short-Description:L1D L2 Sourced Writes
Description:
A directory write to the Level-1 D-Cache directory where the installed
cache line was sourced from the Level-2 (L1.5) cache
.
Counter: 130 Name:L1I_L3_LOCAL_WRITES
Short-Description:L1I L3 Local Writes
Description:
A directory write to the Level-1 I-Cache directory where the installed
cache line was sourced from the Level-3 cache that is on the same book
as the Instruction cache (Local L2 cache)
.
Counter: 131 Name:L1D_L3_LOCAL_WRITES
Short-Description:L1D L3 Local Writes
Description:
A directory write to the Level-1 D-Cache directory where the installtion
cache line was source from the Level-3 cache that is on the same book
as the Data cache (Local L2 cache)
.
Counter: 132 Name:L1I_L3_REMOTE_WRITES
Short-Description:L1I L3 Remote Writes
Description:
A directory write to the Level-1 I-Cache directory where the installed
cache line was sourced from a Level-3 cache that is not on the same
book as the Instruction cache (Remote L2 cache)
.
Counter: 133 Name:L1D_L3_REMOTE_WRITES
Short-Description:L1D L3 Remote Writes
Description:
A directory write to the Level-1 D-Cache directory where the installed
cache line was sourced from a Level-3 cache that is not on the same
book as the Data cache (Remote L2 cache)
.
Counter: 134 Name:L1D_LMEM_SOURCED_WRITES
Short-Description:L1D Local Memory Sourced Writes
Description:
A directory write to the Level-1 D-Cache directory where the installed
cache line was sourced from memory that is attached to the same book
as the Data cache (Local Memory)
.
Counter: 135 Name:L1I_LMEM_SOURCED_WRITES
Short-Description:L1I Local Memory Sourced Writes
Description:
A directory write to the Level-1 I-Cache where the installed cache
line was sourced from memory that is attached to the s ame book as the
Instruction cahe (local Memory)
Instruction cache (Local Memory)
.
Counter: 136 Name:L1D_RO_EXCL_WRITES
Short-Description:L1D Read-only Exclusive Writes
Description:
A directory write to the Level-1 D-Cache where the line was originally
in a Read-Only state in the cache but has been updated to be in the
Exclusive state that allows stores to the cache line
.
Counter: 137 Name:L1I_CACHELINE_INVALIDATES
Short-Description:L1I Cacheline Invalidates
Description:
A cache line in the Level-1 I-Cache has been invalidated by a store on
the same CPU as the Level-1 I-Cache
.
Counter: 138 Name:ITLB1_WRITES
Short-Description:ITLB1 Writes
Description:
A translation entry has been written into the Level-1 Instruction
Translation Lookaside Buffer
.
Counter: 139 Name:DTLB1_WRITES
Short-Description:DTLB1 Writes
Description:
A translation entry has been written to the Level-1 Data Translation
Lookaside Buffer
.
Counter: 140 Name:TLB2_PTE_WRITES
Short-Description:TLB2 PTE Writes
Description:
A translation entry has been written to the Level-2 TLB Page Table
Entry arrays
.
Counter: 141 Name:TLB2_CRSTE_WRITES
Short-Description:TLB2 CRSTE Writes
Description:
A translation entry has been written to the Level-2 TLB Common Region
Segment Table Entry arrays
.
Counter: 142 Name:TLB2_CRSTE_HPAGE_WRITES
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
Description:
A translation entry has been written to the Level-2 TLB Common Region
Segment Table Entry arrays for a one-megabyte large page translation
.
Counter: 145 Name:ITLB1_MISSES
Short-Description:ITLB1 Misses
Description:
Level-1 Instruction TLB miss in progress. Incremented by one for every
cycle an ITLB1 miss is in progress
.
Counter: 146 Name:DTLB1_MISSES
Short-Description:DTLB1 Misses
Description:
Level-1 Data TLB miss in progress. Incremented by one for every cycle
an DTLB1 miss is in progress
.
Counter: 147 Name:L2C_STORES_SENT
Short-Description:L2C Stores Sent
Description:
Incremented by one for every store sent to Level-2 (L1.5) cache
.

View File

@@ -16,288 +16,343 @@
#
# Extended Counter Set
# ---------------------------------------------------------------------
Counter:128 Name:L1D_WRITES_RO_EXCL
Counter:128 Name:L1D_RO_EXCL_WRITES
Short-Description:L1D Read-only Exclusive Writes
Description:
A directory write to the Level-1 Data cache where the line was
originally in a Read-Only state in the cache but has been updated
to be in the Exclusive state that allows stores to the cache line.
.
Counter:129 Name:DTLB1_WRITES
Short-Description:DTLB1 Writes
Description:
A translation entry has been written to the Level-1 Data Translation
Lookaside Buffer
.
Counter:130 Name:DTLB1_MISSES
Short-Description:DTLB1 Misses
Description:
Level-1 Data TLB miss in progress. Incremented by one for every cycle
a DTLB1 miss is in progress.
.
Counter:131 Name:DTLB1_HPAGE_WRITES
Short-Description:DTLB1 One-Megabyte Page Writes
Description:
A translation entry has been written to the Level-1 Data Translation
Lookaside Buffer for a one-megabyte page
.
Counter:132 Name:DTLB1_GPAGE_WRITES
Short-Description:DTLB1 Two-Gigabyte Page Writes
A translation entry has been written to the Level-1 Data Translation
Lookaside Buffer for a two-gigabyte page.
.
Counter:133 Name:L1D_L2D_SOURCED_WRITES
Short-Description:L1D L2D Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from the Level-2 Data cache
.
Counter:134 Name:ITLB1_WRITES
Short-Description:ITLB1 Writes
Description:
A translation entry has been written to the Level-1 Instruction
Translation Lookaside Buffer
.
Counter:135 Name:ITLB1_MISSES
Short-Description:ITLB1 Misses
Description:
Level-1 Instruction TLB miss in progress. Incremented by one for every
cycle an ITLB1 miss is in progress
.
Counter:136 Name:L1I_L2I_SOURCED_WRITES
Short-Description:L1I L2I Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from the Level-2 Instruction cache
.
Counter:137 Name:TLB2_PTE_WRITES
Short-Description:TLB2 PTE Writes
Description:
A translation entry has been written to the Level-2 TLB Page Table
Entry arrays
.
Counter:138 Name:TLB2_CRSTE_HPAGE_WRITES
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
Description:
A translation entry has been written to the Level-2 TLB Combined Region
Segment Table Entry arrays for a one-megabyte large page translation
.
Counter:139 Name:TLB2_CRSTE_WRITES
Short-Description:TLB2 CRSTE Writes
Description:
A translation entry has been written to the Level-2 TLB Combined Region
Segment Table Entry arrays
.
Counter:140 Name:TX_C_TEND
Short-Description:Completed TEND instructions in constrained TX mode
Description:
A TEND instruction has completed in a constrained transactional-execution
mode
.
Counter:141 Name:TX_NC_TEND
Short-Description:Completed TEND instructions in non-constrained TX mode
Description:
A TEND instruction has completed in a non-constrained
transactional-execution mode
.
Counter:143 Name:L1C_TLB1_MISSES
Short-Description:L1C TLB1 Misses
Description:
Increments by one for any cycle where a Level-1 cache or Level-1 TLB miss
is in progress.
.
Counter:144 Name:L1D_ONCHIP_L3_SOURCED_WRITES
Short-Description:L1D On-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Chip Level-3 cache without intervention
.
Counter:145 Name:L1D_ONCHIP_L3_SOURCED_WRITES_IV
Short-Description:L1D On-Chip L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Chip Level-3 cache with intervention
.
Counter:146 Name:L1D_ONNODE_L4_SOURCED_WRITES
Short-Description:L1D On-Node L4 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Node Level-4 cache
.
Counter:147 Name:L1D_ONNODE_L3_SOURCED_WRITES_IV
Short-Description:L1D On-Node L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Node Level-3 cache with intervention
.
Counter:148 Name:L1D_ONNODE_L3_SOURCED_WRITES
Short-Description:L1D On-Node L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Node Level-3 cache without intervention
.
Counter:149 Name:L1D_ONDRAWER_L4_SOURCED_WRITES
Short-Description:L1D On-Drawer L4 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Drawer Level-4 cache
.
Counter:150 Name:L1D_ONDRAWER_L3_SOURCED_WRITES_IV
Short-Description:L1D On-Drawer L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Drawer Level-3 cache with intervention
.
Counter:151 Name:L1D_ONDRAWER_L3_SOURCED_WRITES
Short-Description:L1D On-Drawer L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Drawer Level-3 cache without intervention
.
Counter:152 Name:L1D_OFFDRAWER_SCOL_L4_SOURCED_WRITES
Short-Description:L1D Off-Drawer Same-Column L4 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Drawer Same-Column Level-4 cache
.
Counter:153 Name:L1D_OFFDRAWER_SCOL_L3_SOURCED_WRITES_IV
Short-Description:L1D Off-Drawer Same-Column L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Drawer Same-Column Level-3 cache with
intervention
.
Counter:154 Name:L1D_OFFDRAWER_SCOL_L3_SOURCED_WRITES
Short-Description:L1D Off-Drawer Same-Column L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Drawer Same-Column Level-3 cache
without intervention
.
Counter:155 Name:L1D_OFFDRAWER_FCOL_L4_SOURCED_WRITES
Short-Description:L1D Off-Drawer Far-Column L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Drawer Far-Column Level-4 cache
.
Counter:156 Name:L1D_OFFDRAWER_FCOL_L3_SOURCED_WRITES_IV
Short-Description:L1D Off-Drawer Far-Column L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Drawer Far-Column Level-3 cache with
intervention
.
Counter:157 Name:L1D_OFFDRAWER_FCOL_L3_SOURCED_WRITES
Short-Description:L1D Off-Drawer Far-Column L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Drawer Far-Column Level-3 cache
without intervention
.
Counter:158 Name:L1D_ONNODE_MEM_SOURCED_WRITES
Short-Description:L1D On-Node Memory Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Node memory
.
Counter:159 Name:L1D_ONDRAWER_MEM_SOURCED_WRITES
Short-Description:L1D On-Drawer Memory Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Drawer memory
.
Counter:160 Name:L1D_OFFDRAWER_MEM_SOURCED_WRITES
Short-Description:L1D Off-Drawer Memory Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Drawer memory
.
Counter:161 Name:L1D_ONCHIP_MEM_SOURCED_WRITES
Short-Description:L1D On-Chip Memory Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Chip memory
.
Counter:162 Name:L1I_ONCHIP_L3_SOURCED_WRITES
Short-Description:L1I On-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an On-Chip Level-3 cache without
intervention
.
Counter:163 Name:L1I_ONCHIP_L3_SOURCED_WRITES_IV
Short-Description:L1I On-Chip L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an On Chip Level-3 cache with
intervention
.
Counter:164 Name:L1I_ONNODE_L4_SOURCED_WRITES
Short-Description:L1I On-Chip L4 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an On-Node Level-4 cache
.
Counter:165 Name:L1I_ONNODE_L3_SOURCED_WRITES_IV
Short-Description:L1I On-Node L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from an On-Node Level-3 cache
with intervention
.
Counter:166 Name:L1I_ONNODE_L3_SOURCED_WRITES
Short-Description:L1I On-Node L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from an On-Node Level-3 cache
without intervention
.
Counter:167 Name:L1I_ONDRAWER_L4_SOURCED_WRITES
Short-Description:L1I On-Drawer L4 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from an On-Drawer Level-4 cache
.
Counter:168 Name:L1I_ONDRAWER_L3_SOURCED_WRITES_IV
Short-Description:L1I On-Drawer L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from an On-Drawer Level-3 cache
with intervention
.
Counter:169 Name:L1I_ONDRAWER_L3_SOURCED_WRITES
Short-Description:L1I On-Drawer L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from an On-Drawer Level-3 cache
without intervention
.
Counter:170 Name:L1I_OFFDRAWER_SCOL_L4_SOURCED_WRITES
Short-Description:L1I Off-Drawer Same-Column L4 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from an Off-Drawer Same-Column
Level-4 cache
.
Counter:171 Name:L1I_OFFDRAWER_SCOL_L3_SOURCED_WRITES_IV
Short-Description:L1I Off-Drawer Same-Column L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from an Off-Drawer Same-Column
Level-3 cache with intervention
.
Counter:172 Name:L1I_OFFDRAWER_SCOL_L3_SOURCED_WRITES
Short-Description:L1I Off-Drawer Same-Column L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from an Off-Drawer Same-Column
Level-3 cache without intervention
.
Counter:173 Name:L1I_OFFDRAWER_FCOL_L4_SOURCED_WRITES
Short-Description:L1I Off-Drawer Far-Column L4 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from an Off-Drawer Far-Column
Level-4 cache
.
Counter:174 Name:L1I_OFFDRAWER_FCOL_L3_SOURCED_WRITES_IV
Short-Description:L1I Off-Drawer Far-Column L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from an Off-Drawer Far-Column
Level-3 cache with intervention
.
Counter:175 Name:L1I_OFFDRAWER_FCOL_L3_SOURCED_WRITES
Short-Description:L1I Off-Drawer Far-Column L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from an Off-Drawer Far-Column
Level-3 cache without intervention
.
Counter:176 Name:L1I_ONNODE_MEM_SOURCED_WRITES
Short-Description:L1I On-Node Memory Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from On-Node memory
.
Counter:177 Name:L1I_ONDRAWER_MEM_SOURCED_WRITES
Short-Description:L1I On-Drawer Memory Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from On-Drawer memory
.
Counter:178 Name:L1I_OFFDRAWER_MEM_SOURCED_WRITES
Short-Description:L1I Off-Drawer Memory Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from On-Drawer memory
.
Counter:179 Name:L1I_ONCHIP_MEM_SOURCED_WRITES
Short-Description:L1I On-Chip Memory Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where
the returned cache line was sourced from On-Chip memory
.
Counter:218 Name:TX_NC_TABORT
Short-Description:Aborted transactions in non-constrained TX mode
Description:
A transaction abort has occurred in a non-constrained
transactional-execution mode
.
Counter:219 Name:TX_C_TABORT_NO_SPECIAL
Short-Description:Aborted transactions in constrained TX mode not using special completion logic
Description:
A transaction abort has occurred in a constrained transactional-execution
mode and the CPU is not using any special logic to allow the transaction
to complete
.
Counter:220 Name:TX_C_TABORT_SPECIAL
Short-Description:Aborted transactions in constrained TX mode using special completion logic
Description:
A transaction abort has occurred in a constrained transactional-execution
mode and the CPU is using special logic to allow the transaction to
@@ -307,10 +362,12 @@ complete
# MT-diagnostic counter set
# ---------------------------------------------------------------------
Counter:448 Name:MT_DIAG_CYCLES_ONE_THR_ACTIVE
Short-Description:Cycle count with one thread active
Description:
Cycle count with one thread active
.
Counter:449 Name:MT_DIAG_CYCLES_TWO_THR_ACTIVE
Short-Description:Cycle count with two threads active
Description:
Cycle count with two threads active
.

View File

@@ -0,0 +1,357 @@
# Counter decriptions for the
# IBM z14 extended counter and MT-diagnostic counter set
#
# Notes for transactional-execution mode symbolic names:
# TX .. transactional-execution mode
# NC .. nonconstrained
# C .. constrained
#
# Undefined counters in the extended counter set:
# 142
# 158-161
# 176-223
# 227-231
# 233-242
# 246-255
# Undefined counters in the MT-diagnostic counter set:
# 450-495
#
#
# Extended Counter Set
# ---------------------------------------------------------------------
Counter:128 Name:L1D_RO_EXCL_WRITES
Short-Description:L1D Read-only Exclusive Writes
Description:
A directory write to the Level-1 Data cache where the line was
originally in a Read-Only state in the cache but has been updated
to be in the Exclusive state that allows stores to the cache line
.
Counter:129 Name:DTLB2_WRITES
Short-Description:DTLB2 Writes
Description:
A translation has been written into The Translation Lookaside
Buffer 2 (TLB2) and the request was made by the data cache
.
Counter:130 Name:DTLB2_MISSES
Short-Description:DTLB2 Misses
Description:
A TLB2 miss is in progress for a request made by the data cache.
Incremented by one for every TLB2 miss in progress for the Level-1
Data cache on this cycle
.
Counter:131 Name:DTLB2_HPAGE_WRITES
Short-Description:DTLB2 One-Megabyte Page Writes
Description:
A translation entry was written into the Combined Region and Segment
Table Entry array in the Level-2 TLB for a one-megabyte page or a
Last Host Translation was done
.
Counter:132 Name:DTLB2_GPAGE_WRITES
Short-Description:DTLB2 Two-Gigabyte Page Writes
Description:
A translation entry for a two-gigabyte page was written into the
Level-2 TLB
.
Counter:133 Name:L1D_L2D_SOURCED_WRITES
Short-Description:L1D L2D Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the
returned cache line was sourced from the Level-2 Data cache
.
Counter:134 Name:ITLB2_WRITES
Short-Description:ITLB2 Writes
Description:
A translation entry has been written into the Translation Lookaside
Buffer 2 (TLB2) and the request was made by the instruction cache
.
Counter:135 Name:ITLB2_MISSES
Short-Description:ITLB2 Misses
Description:
A TLB2 miss is in progress for a request made by the instruction cache.
Incremented by one for every TLB2 miss in progress for the Level-1
Instruction cache in a cycle
.
Counter:136 Name:L1I_L2I_SOURCED_WRITES
Short-Description:L1I L2I Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from the Level-2 Instruction cache
.
Counter:137 Name:TLB2_PTE_WRITES
Short-Description:TLB2 PTE Writes
Description:
A translation entry was written into the Page Table Entry array in the
Level-2 TLB
.
Counter:138 Name:TLB2_CRSTE_WRITES
Short-Description:TLB2 CRSTE Writes
Description:
Translation entries were written into the Combined Region and Segment
Table Entry array and the Page Table Entry array in the Level-2 TLB
.
Counter:139 Name:TLB2_ENGINES_BUSY
Short-Description:TLB2 Engines Busy
Description:
The number of Level-2 TLB translation engines busy in a cycle
.
Counter:140 Name:TX_C_TEND
Short-Description:Completed TEND instructions in constrained TX mode
Description:
A TEND instruction has completed in a constrained transactional-execution
mode
.
Counter:141 Name:TX_NC_TEND
Short-Description:Completed TEND instructions in non-constrained TX mode
Description:
A TEND instruction has completed in a non-constrained
transactional-execution mode
.
Counter:143 Name:L1C_TLB2_MISSES
Short-Description:L1C TLB2 Misses
Description:
Increments by one for any cycle where a level-1 cache or level-2 TLB miss
is in progress
.
Counter:144 Name:L1D_ONCHIP_L3_SOURCED_WRITES
Short-Description:L1D On-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Chip Level-3 cache without intervention
.
Counter:145 Name:L1D_ONCHIP_MEMORY_SOURCED_WRITES
Short-Description:L1D On-Chip Memory Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Chip memory
.
Counter:146 Name:L1D_ONCHIP_L3_SOURCED_WRITES_IV
Short-Description:L1D On-Chip L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Chip Level-3 cache with intervention
.
Counter:147 Name:L1D_ONCLUSTER_L3_SOURCED_WRITES
Short-Description:L1D On-Cluster L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Cluster Level-3 cache withountervention
.
Counter:148 Name:L1D_ONCLUSTER_MEMORY_SOURCED_WRITES
Short-Description:L1D On-Cluster Memory Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Cluster memory
.
Counter:149 Name:L1D_ONCLUSTER_L3_SOURCED_WRITES_IV
Short-Description:L1D On-Cluster L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Cluster Level-3 cache with intervention
.
Counter:150 Name:L1D_OFFCLUSTER_L3_SOURCED_WRITES
Short-Description:L1D Off-Cluster L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Cluster Level-3 cache without
intervention
.
Counter:151 Name:L1D_OFFCLUSTER_MEMORY_SOURCED_WRITES
Short-Description:L1D Off-Cluster Memory Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from Off-Cluster memory
.
Counter:152 Name:L1D_OFFCLUSTER_L3_SOURCED_WRITES_IV
Short-Description:L1D Off-Cluster L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Cluster Level-3 cache with intervention
.
Counter:153 Name:L1D_OFFDRAWER_L3_SOURCED_WRITES
Short-Description:L1D Off-Drawer L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Drawer Level-3 cache without
intervention
.
Counter:154 Name:L1D_OFFDRAWER_MEMORY_SOURCED_WRITES
Short-Description:L1D Off-Drawer Memory Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from Off-Drawer memory
.
Counter:155 Name:L1D_OFFDRAWER_L3_SOURCED_WRITES_IV
Short-Description:L1D Off-Drawer L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Drawer Level-3 cache with intervention
.
Counter:156 Name:L1D_ONDRAWER_L4_SOURCED_WRITES
Short-Description:L1D On-Drawer L4 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Drawer Level-4 cache
.
Counter:157 Name:L1D_OFFDRAWER_L4_SOURCED_WRITES
Short-Description:L1D Off-Drawer L4 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from Off-Drawer Level-4 cache
.
Counter:158 Name:L1D_ONCHIP_L3_SOURCED_WRITES_RO
Short-Description:L1D On-Chip L3 Sourced Writes read-only
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Chip L3 but a read-only invalidate was
done to remove other copies of the cache line
.
Counter:162 Name:L1I_ONCHIP_L3_SOURCED_WRITES
Short-Description:L1I On-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache ine was sourced from an On-Chip Level-3 cache without
intervention
.
Counter:163 Name:L1I_ONCHIP_MEMORY_SOURCED_WRITES
Short-Description:L1I On-Chip Memory Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache ine was sourced from On-Chip memory
.
Counter:164 Name:L1I_ONCHIP_L3_SOURCED_WRITES_IV
Short-Description:L1I On-Chip L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache ine was sourced from an On-Chip Level-3 cache with
intervention
.
Counter:165 Name:L1I_ONCLUSTER_L3_SOURCED_WRITES
Short-Description:L1I On-Cluster L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an On-Cluster Level-3 cache without
intervention
.
Counter:166 Name:L1I_ONCLUSTER_MEMORY_SOURCED_WRITES
Short-Description:L1I On-Cluster Memory Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an On-Cluster memory
.
Counter:167 Name:L1I_ONCLUSTER_L3_SOURCED_WRITES_IV
Short-Description:L1I On-Cluster L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from On-Cluster Level-3 cache with
intervention
.
Counter:168 Name:L1I_OFFCLUSTER_L3_SOURCED_WRITES
Short-Description:L1I Off-Cluster L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off-Cluster Level-3 cache without
intervention
.
Counter:169 Name:L1I_OFFCLUSTER_MEMORY_SOURCED_WRITES
Short-Description:L1I Off-Cluster Memory Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from Off-Cluster memory
.
Counter:170 Name:L1I_OFFCLUSTER_L3_SOURCED_WRITES_IV
Short-Description:L1I Off-Cluster L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off-Cluster Level-3 cache with
intervention
.
Counter:171 Name:L1I_OFFDRAWER_L3_SOURCED_WRITES
Short-Description:L1I Off-Drawer L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off-Drawer Level-3 cache without
intervention
.
Counter:172 Name:L1I_OFFDRAWER_MEMORY_SOURCED_WRITES
Short-Description:L1I Off-Drawer Memory Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from Off-Drawer memory
.
Counter:173 Name:L1I_OFFDRAWER_L3_SOURCED_WRITES_IV
Short-Description:L1I Off-Drawer L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off-Drawer Level-3 cache with
intervention
.
Counter:174 Name:L1I_ONDRAWER_L4_SOURCED_WRITES
Short-Description:L1I On-Drawer L4 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from On-Drawer Level-4 cache
.
Counter:175 Name:L1I_OFFDRAWER_L4_SOURCED_WRITES
Short-Description:L1I Off-Drawer L4 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from Off-Drawer Level-4 cache
.
Counter:224 Name:BCD_DFP_EXECUTION_SLOTS
Short-Description:BCD DFP Execution Slots
Description:
Count of floating point execution slots used for finished Binary Coded
Decimal to Decimal Floating Point conversions. Instructions: CDZT,
CXZT, CZDT, CZXT
.
Counter:225 Name:VX_BCD_EXECUTION_SLOTS
Short-Description:VX BCD Execution Slots
Description:
Count of floating point execution slots used for finished vector arithmetic
Binary Coded Decimal instructions. Instructions: VAP, VSP, VMPVMSP, VDP,
VSDP, VRP, VLIP, VSRP, VPSOPVCP, VTP, VPKZ, VUPKZ, VCVB, VCVBG, VCVDVCVDG
.
Counter:226 Name:DECIMAL_INSTRUCTIONS
Short-Description:Decimal Instructions
Description:
Decimal instructions dispatched. Instructions: CVB, CVD, AP, CP, DP, ED,
EDMK, MP, SRP, SP, ZAP
.
Counter:232 Name:LAST_HOST_TRANSLATIONS
Short-Description:Last host translation done
Description:
Last Host Translation done
.
Counter:243 Name:TX_NC_TABORT
Short-Description:Aborted transactions in non-constrained TX mode
Description:
A transaction abort has occurred in a non-constrained
transactional-execution mode
.
Counter:244 Name:TX_C_TABORT_NO_SPECIAL
Short-Description:Aborted transactions in constrained TX mode not using special completion logic
Description:
A transaction abort has occurred in a constrained transactional-execution
mode and the CPU is not using any special logic to allow the transaction
to complete
.
Counter:245 Name:TX_C_TABORT_SPECIAL
Short-Description:Aborted transactions in constrained TX mode using special completion logic
Description:
A transaction abort has occurred in a constrained transactional-execution
mode and the CPU is using special logic to allow the transaction to
complete
.
#
# MT-diagnostic counter set
# ---------------------------------------------------------------------
Counter:448 Name:MT_DIAG_CYCLES_ONE_THR_ACTIVE
Short-Description:Cycle count with one thread active
Description:
Cycle count with one thread active
.
Counter:449 Name:MT_DIAG_CYCLES_TWO_THR_ACTIVE
Short-Description:Cycle count with two threads active
Description:
Cycle count with two threads active
.

View File

@@ -1,121 +1,145 @@
Counter: 128 Name:L1D_L2_SOURCED_WRITES
Short-Description:L1D L2 Sourced Writes
Description:
A directory write to the Level-1 D-Cache directory where the returned
cache line was sourced from the Level-2 cache
.
Counter: 129 Name:L1I_L2_SOURCED_WRITES
Short-Description:L1I L2 Sourced Writes
Description:
A directory write to the Level-1 I-Cache directory where the returned
cache line was sourced from the Level-2 cache
.
Counter: 130 Name:DTLB1_MISSES
Short-Description:DTLB1 Misses
Description:
Level-1 Data TLB miss in progress. Incremented by one for every cycle
a DTLB1 miss is in progress.
.
Counter: 131 Name:ITLB1_MISSES
Short-Description:ITLB1 Misses
Description:
Level-1 Instruction TLB miss in progress. Incremented by one for every
cycle a ITLB1 miss is in progress.
.
Counter: 133 Name:L2C_STORES_SENT
Short-Description:L2C Stores Sent
Description:
Incremented by one for every store sent to Level-2 cache
.
Counter: 134 Name:L1D_OFFBOOK_L3_SOURCED_WRITES
Short-Description:L1D Off-Book L3 Sourced Writes
Description:
A directory write to the Level-1 D-Cache directory where the returned
cache line was sourced from an Off Book Level-3 cache
.
Counter: 135 Name:L1D_ONBOOK_L4_SOURCED_WRITES
Short-Description:L1D On-Book L4 Sourced Writes
Description:
A directory write to the Level-1 D-Cache directory where the returned
cache line was sourced from an On Book Level-4 cache
.
Counter: 136 Name:L1I_ONBOOK_L4_SOURCED_WRITES
Short-Description:L1I On-Book L4 Sourced Writes
Description:
A directory write to the Level-1 I-Cache directory where the returned
cache line was sourced from an On Book Level-4 cache
.
Counter: 137 Name:L1D_RO_EXCL_WRITES
Short-Description:L1D Read-only Exclusive Writes
Description:
A directory write to the Level-1 D-Cache where the line was originally
in a Read-Only state in the cache but has been updated to be in the
Exclusive state that allows stores to the cache line
.
Counter: 138 Name:L1D_OFFBOOK_L4_SOURCED_WRITES
Short-Description:L1D Off-Book L4 Sourced Writes
Description:
A directory write to the Level-1 D-Cache directory where the returned
cache line was sourced from an Off Book Level-4 cache
.
Counter: 139 Name:L1I_OFFBOOK_L4_SOURCED_WRITES
Short-Description:L1I Off-Book L4 Sourced Writes
Description:
A directory write to the Level-1 I-Cache directory where the returned
cache line was sourced from an Off Book Level-4 cache
.
Counter: 140 Name:DTLB1_HPAGE_WRITES
Short-Description:DTLB1 One-Megabyte Page Writes
Description:
A translation entry has been written to the Level-1 Data Translation
Lookaside Buffer for a one-megabyte page
.
Counter: 141 Name:L1D_LMEM_SOURCED_WRITES
Short-Description:L1D Local Memory Sourced Writes
Description:
A directory write to the Level-1 D-Cache where the installed cache line
was sourced from memory that is attached to the same book as the Data
cache (Local Memory)
.
Counter: 142 Name:L1I_LMEM_SOURCED_WRITES
Short-Description:L1I Local Memory Sourced Writes
Description:
A directory write to the Level-1 I-Cache where the installed cache
line was sourced from memory that is attached to the same book as the
Instruction cache (Local Memory)
.
Counter: 143 Name:L1I_OFFBOOK_L3_SOURCED_WRITES
Short-Description:L1I Off-Book L3 Sourced Writes
Description:
A directory write to the Level-1 I-Cache directory where the returned
cache line was sourced from an Off Book Level-3 cache
.
Counter: 144 Name:DTLB1_WRITES
Short-Description:DTLB1 Writes
Description:
A translation entry has been written to the Level-1 Data Translation
Lookaside Buffer
.
Counter: 145 Name:ITLB1_WRITES
Short-Description:ITLB1 Writes
Description:
A translation entry has been written to the Level-1 Instruction
Translation Lookaside Buffer
.
Counter: 146 Name:TLB2_PTE_WRITES
Short-Description:TLB2 PTE Writes
Description:
A translation entry has been written to the Level-2 TLB Page Table
Entry arrays
.
Counter: 147 Name:TLB2_CRSTE_HPAGE_WRITES
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
Description:
A translation entry has been written to the Level-2 TLB Common Region
Segment Table Entry arrays for a one-megabyte large page translation
.
Counter: 148 Name:TLB2_CRSTE_WRITES
Short-Description:TLB2 CRSTE Writes
Description:
A translation entry has been written to the Level-2 TLB Common Region
Segment Table Entry arrays
.
Counter: 150 Name:L1D_ONCHIP_L3_SOURCED_WRITES
Short-Description:L1D On-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 D-Cache directory where the returned
cache line was sourced from an On Chip Level-3 cache
.
Counter: 152 Name:L1D_OFFCHIP_L3_SOURCED_WRITES
Short-Description:L1D Off-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 D-Cache directory where the returned
cache line was sourced from an Off Chip/On Book Level-3 cache
.
Counter: 153 Name:L1I_ONCHIP_L3_SOURCED_WRITES
Short-Description:L1I On-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 I-Cache directory where the returned
cache line was sourced from an On Chip Level-3 cache
.
Counter: 155 Name:L1I_OFFCHIP_L3_SOURCED_WRITES
Short-Description:L1I Off-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 I-Cache directory where the returned
cache line was sourced from an Off Chip/On Book Level-3 cache

View File

@@ -1,98 +1,117 @@
Counter: 128 Name:DTLB1_MISSES
Short-Description:DTLB1 Misses
Description:
Level-1 Data TLB miss in progress. Incremented by one for every cycle
a DTLB1 miss is in progress.
.
Counter:129 Name:ITLB1_MISSES
Short-Description:ITLB1 Misses
Description:
Level-1 Instruction TLB miss in progress. Incremented by one for every
cycle a ITLB1 miss is in progress.
.
Counter:130 Name:L1D_L2I_SOURCED_WRITES
Short-Description:L1D L2I Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from the Level-2 Instruction cache
.
Counter:131 Name:L1I_L2I_SOURCED_WRITES
Short-Description:L1I L2I Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from the Level-2 Instruction cache
.
Counter:132 Name:L1D_L2D_SOURCED_WRITES
Short-Description:L1D L2D Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from the Level-2 Data cache
.
Counter:133 Name:DTLB1_WRITES
Short-Description:DTLB1 Writes
Description:
A translation entry has been written to the Level-1 Data Translation
Lookaside Buffer
.
Counter:135 Name:L1D_LMEM_SOURCED_WRITES
Short-Description:L1D Local Memory Sourced Writes
Description:
A directory write to the Level-1 Data cache where the installed cache line
was sourced from memory that is attached to the same book as the Data
cache (Local Memory)
.
Counter:137 Name:L1I_LMEM_SOURCED_WRITES
Short-Description:L1I Local Memory Sourced Writes
Description:
A directory write to the Level-1 Instruction cache where the installed cache
line was sourced from memory that is attached to the same book as the
Instruction cache (Local Memory)
.
Counter:138 Name:L1D_RO_EXCL_WRITES
Short-Description:L1D Read-only Exclusive Writes
Description:
A directory write to the Level-1 D-Cache where the line was originally
in a Read-Only state in the cache but has been updated to be in the
Exclusive state that allows stores to the cache line
.
Counter:139 Name:DTLB1_HPAGE_WRITES
Short-Description:DTLB1 One-Megabyte Page Writes
Description:
A translation entry has been written to the Level-1 Data Translation
Lookaside Buffer for a one-megabyte page
.
Counter:140 Name:ITLB1_WRITES
Short-Description:ITLB1 Writes
Description:
A translation entry has been written to the Level-1 Instruction
Translation Lookaside Buffer
.
Counter:141 Name:TLB2_PTE_WRITES
Short-Description:TLB2 PTE Writes
Description:
A translation entry has been written to the Level-2 TLB Page Table
Entry arrays
.
Counter:142 Name:TLB2_CRSTE_HPAGE_WRITES
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
Description:
A translation entry has been written to the Level-2 TLB Common Region
Segment Table Entry arrays for a one-megabyte large page translation
.
Counter:143 Name:TLB2_CRSTE_WRITES
Short-Description:TLB2 CRSTE Writes
Description:
A translation entry has been written to the Level-2 TLB Common Region
Segment Table Entry arrays
.
Counter:144 Name:L1D_ONCHIP_L3_SOURCED_WRITES
Short-Description:L1D On-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On Chip Level-3 cache without intervention
.
Counter:145 Name:L1D_OFFCHIP_L3_SOURCED_WRITES
Short-Description:L1D Off-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off Chip/On Book Level-3 cache without
intervention
.
Counter:146 Name:L1D_OFFBOOK_L3_SOURCED_WRITES
Short-Description:L1D Off-Book L3 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off Book Level-3 cache without intervention
.
Counter:147 Name:L1D_ONBOOK_L4_SOURCED_WRITES
Short-Description:L1D On-Book L4 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On Book Level-4 cache
.
Counter:148 Name:L1D_OFFBOOK_L4_SOURCED_WRITES
Short-Description:L1D Off-Book L4 Sourced Writes
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off Book Level-4 cache
@@ -104,16 +123,19 @@ cache line was sourced from an Off Book Level-4 cache
# C .. constrained
#
Counter:149 Name:TX_NC_TEND
Short-Description:Completed TEND instructions in non-constrained TX mode
Description:
A TEND instruction has completed in a nonconstrained
transactional-execution mode
.
Counter:150 Name:L1D_ONCHIP_L3_SOURCED_WRITES_IV
Short-Description:L1D On-Chip L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from a On Chip Level-3 cache with intervention
.
Counter:151 Name:L1D_OFFCHIP_L3_SOURCED_WRITES_IV
Short-Description:L1D Off-Chip L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off Chip/On Book Level-3 cache with
@@ -121,73 +143,86 @@ intervention
.
# XXX Remove SOURCED from L1D_OFFBOOK_L3_SOURCED_WRITES...
Counter:152 Name:L1D_OFFBOOK_L3_SOURCED_WRITES_IV
Short-Description:L1D Off-Book L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off Book Level-3 cache with intervention
.
Counter:153 Name:L1I_ONCHIP_L3_SOURCED_WRITES
Short-Description:L1I On-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an On Chip Level-3 cache without
intervention
.
Counter:154 Name:L1I_OFFCHIP_L3_SOURCED_WRITES
Short-Description:L1I Off-Chip L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off Chip/On Book Level-3 cache
without intervention
.
Counter:155 Name:L1I_OFFBOOK_L3_SOURCED_WRITES
Short-Description:L1I Off-Book L3 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off Book Level-3 cache without
intervention
.
Counter:156 Name:L1I_ONBOOK_L4_SOURCED_WRITES
Short-Description:L1I On-Book L4 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an On Book Level-4 cache
.
Counter:157 Name:L1I_OFFBOOK_L4_SOURCED_WRITES
Short-Description:L1I Off-Book L4 Sourced Writes
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off Book Level-4 cache
.
Counter:158 Name:TX_C_TEND
Short-Description:Completed TEND instructions in constrained TX mode
Description:
A TEND instruction has completed in a constrained transactional-execution
mode
.
Counter:159 Name:L1I_ONCHIP_L3_SOURCED_WRITES_IV
Short-Description:L1I On-Chip L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an On Chip Level-3 cache with
intervention
.
Counter:160 Name:L1I_OFFCHIP_L3_SOURCED_WRITES_IV
Short-Description:L1I Off-Chip L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off Chip/On Book Level-3 cache
with intervention
.
Counter:161 Name:L1I_OFFBOOK_L3_SOURCED_WRITES_IV
Short-Description:L1I Off-Book L3 Sourced Writes with Intervention
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off Book Level-3 cache with
intervention
.
Counter:177 Name:TX_NC_TABORT
Short-Description:Aborted transactions in non-constrained TX mode
Description:
A transaction abort has occurred in a nonconstrained
transactional-execution mode
.
Counter:178 Name:TX_C_TABORT_NO_SPECIAL
Short-Description:Aborted transactions in constrained TX mode not using special completion logic
Description:
A transaction abort has occurred in a constrained transactional-execution
mode and the CPU is not using any special logic to allow the transaction
to complete
.
Counter:179 Name:TX_C_TABORT_SPECIAL
Short-Description:Aborted transactions in constrained TX mode using special completion logic
Description:
A transaction abort has occurred in a constrained transactional-execution
mode and the CPU is using special logic to allow the transaction to

View File

@@ -1,11 +1,22 @@
# CPU-measurement facilities
#
# Mapping of IBM System z hardware types to extended counter set defintions
# Mapping of:
# 1. CPU-MF counter first/second version numbers to "generic" counter
# definitions
# 2. IBM z Systems hardware to respective extended counter set definitions
#
#
{
# Definition # File name
0 => 'cpum-cf-generic.ctr',
# CFVN
'cfvn-1' => 'cpum-cf-cfvn-1.ctr',
'cfvn-3' => 'cpum-cf-cfvn-3.ctr',
# CSVN
'csvn-generic' => 'cpum-cf-csvn-generic.ctr',
# Extended counters
2097 => 'cpum-cf-extended-z10.ctr',
2098 => 'cpum-cf-extended-z10.ctr',
2817 => 'cpum-cf-extended-z196.ctr',
@@ -14,4 +25,6 @@
2828 => 'cpum-cf-extended-zEC12.ctr',
2964 => 'cpum-cf-extended-z13.ctr',
2965 => 'cpum-cf-extended-z13.ctr',
3906 => 'cpum-cf-extended-z14.ctr',
3907 => 'cpum-cf-extended-z14.ctr',
};

View File

@@ -3,11 +3,13 @@
#
# Basic-sampling mode
Counter: 0xB0000 Name:SF_CYCLES_BASIC
Short-Description:Sample CPU Cycles Using Basic-sampling Mode
Description:
Sample CPU cycles using basic-sampling mode
.
# Diagnostic-sampling mode (includes basic-sampling)
Counter: 0xBD000 Name:SF_CYCLES_BASIC_DIAG
Short-Description:Sample CPU Cycle Using Diagnostic-sampling Mode (not for ordinary use)
Description:
Sample CPU cycle using diagnostic-sampling mode (not for ordinary use)
.

View File

@@ -197,10 +197,10 @@ int is_online(int cpuid);
long get_cmmpages_size();
void parse_options(int argc, char **argv);
void check_if_started_twice();
void store_pid(void);
void handle_signals(void);
void handle_sighup(void);
void reload_daemon(void);
int daemonize(void);
int check_cmmfiles(void);
void check_config();
void set_cmm_pages(long size);

View File

@@ -9,6 +9,10 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "cpuplugd.h"
const char *name = NAME;
@@ -49,7 +53,7 @@ void print_version()
/*
* Store daemon's pid so it can be stopped
*/
void store_pid(void)
static int store_pid(void)
{
FILE *filp;
@@ -57,10 +61,62 @@ void store_pid(void)
if (!filp) {
cpuplugd_error("cannot open pid file %s: %s\n", pid_file,
strerror(errno));
exit(1);
return -1;
}
fprintf(filp, "%d\n", getpid());
fclose(filp);
return 0;
}
/*
* Run daemon in background and write pid file
*/
int daemonize(void)
{
int fd, pipe_fds[2], startup_rc = 1;
pid_t pid;
if (pipe(pipe_fds) == -1) {
cpuplugd_error("cannot create pipe\n");
return -1;
}
pid = fork();
if (pid < 0)
goto close_pipe;
if (pid != 0) {
/* Wait for startup return code from daemon */
if (read(pipe_fds[0], &startup_rc, sizeof(startup_rc)) == -1)
cpuplugd_error("cannot read from pipe\n");
/* On success daemon has written pid file at this point */
exit(startup_rc);
}
/* Create new session */
if (setsid() < 0)
goto notify_parent;
/* Redirect stdin/out/err to /dev/null */
fd = open("/dev/null", O_RDWR, 0);
if (fd == -1)
goto notify_parent;
if (dup2(fd, STDIN_FILENO) < 0)
goto notify_parent;
if (dup2(fd, STDOUT_FILENO) < 0)
goto notify_parent;
if (dup2(fd, STDERR_FILENO) < 0)
goto notify_parent;
/* Create pid file */
if (store_pid() < 0)
goto notify_parent;
startup_rc = 0;
notify_parent:
/* Inform waiting parent about startup return code */
if (write(pipe_fds[1], &startup_rc, sizeof(startup_rc)) == -1) {
cpuplugd_error("cannot write to pipe\n");
startup_rc = 1;
}
close_pipe:
close(pipe_fds[0]);
close(pipe_fds[1]);
return startup_rc ? -1 : 0;
}
/*

View File

@@ -418,13 +418,11 @@ int main(int argc, char *argv[])
check_config();
if (!foreground) {
rc = daemon(1, 0);
rc = daemonize();
if (rc < 0)
cpuplugd_exit("Detach from terminal failed: %s\n",
strerror(errno));
}
/* Store daemon pid */
store_pid();
/* Unlock lock file */
flock(fd, LOCK_UN);
close(fd);

View File

@@ -2,6 +2,7 @@
* dasdfmt - Format DASD ECKD devices for use by Linux
*
* Copyright IBM Corp. 1999, 2017
* Copyright Red Hat Inc. 2017
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -12,6 +13,7 @@
#include <sys/time.h>
#include <sys/utsname.h>
#include "lib/dasd_base.h"
#include "lib/dasd_sys.h"
#include "lib/util_opt.h"
#include "lib/util_prg.h"
@@ -26,6 +28,7 @@
#define SEC_PER_HOUR (60 * 60)
static int filedes;
static char dev_filename[PATH_MAX];
static int disk_disabled;
static format_data_t format_params;
static format_mode_t mode;
@@ -33,7 +36,6 @@ static char *prog_name;
static volatile sig_atomic_t program_interrupt_in_progress;
static int reqsize;
static const struct util_prg prg = {
.desc = "Use dasdfmt to format a DASD ECKD device for use by Linux.\n"
"DEVICE is the node of the device (e.g. '/dev/dasda').",
@@ -265,24 +267,6 @@ static void draw_progress(dasdfmt_info_t *info, int cyl, unsigned int cylinders,
}
}
static int reread_partition_table(void)
{
int i = 0;
int rc = -1;
/* If the BLKRRPART ioctl fails, it is most likely due to
the device just beeing in use by udev. So it is worthwhile
to retry the ioctl after a second as it is likely to succeed.
*/
while (rc && (i < 5)) {
++i;
rc = ioctl(filedes, BLKRRPART, NULL);
if (rc)
sleep(1);
}
return rc;
}
/*
* Helper function for recs_per_track.
*/
@@ -312,16 +296,18 @@ static unsigned int recs_per_track(struct dasd_eckd_characteristics *rdc,
kn = ceil_quot(kl + 6, 232) + 1;
return 1729 / (10 + 9 + ceil_quot(kl + 6 * kn, 34) +
9 + ceil_quot(dl + 6 * dn, 34));
} else
} else {
return 1729 / (10 + 9 + ceil_quot(dl + 6 * dn, 34));
}
case 0x9345:
dn = ceil_quot(dl + 6, 232) + 1;
if (kl) {
kn = ceil_quot(kl + 6, 232) + 1;
return 1420 / (18 + 7 + ceil_quot(kl + 6 * kn, 34) +
ceil_quot(dl + 6 * dn, 34));
} else
} else {
return 1420 / (18 + 7 + ceil_quot(dl + 6 * dn, 34));
}
}
return 0;
}
@@ -404,7 +390,7 @@ static void evaluate_format_error(dasdfmt_info_t *info, format_check_t *cdata,
break;
case DASD_FMT_ERR_RECORD_ID:
ERRMSG("Invalid record ID at cyl: %d trk: %d rec: %d.\n",
cyl, head, cdata->rec);
cyl, head, cdata->rec);
break;
case DASD_FMT_ERR_KEY_LENGTH:
ERRMSG("Invalid key length (found %d, expected %d) "
@@ -414,6 +400,30 @@ static void evaluate_format_error(dasdfmt_info_t *info, format_check_t *cdata,
}
}
static void disk_enable(void)
{
int err;
err = dasd_disk_enable(filedes);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDENABLE failed (%s)\n", prog_name,
strerror(err));
disk_disabled = 0;
}
static void disk_disable(const char *device)
{
int err;
err = dasd_disk_disable(device, &filedes);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDDISABLE failed. (%s)\n", prog_name,
strerror(err));
disk_disabled = 1;
}
/*
* signal handler:
* enables the disk again in case of SIGTERM, SIGINT and SIGQUIT
@@ -428,27 +438,18 @@ static void program_interrupt_signal(int sig)
if (disk_disabled) {
printf("Re-accessing the device...\n");
rc = ioctl(filedes, BIODASDENABLE, &format_params);
if (rc)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (signal handler) IOCTL "
"BIODASDENABLE failed (%s)\n", prog_name,
strerror(errno));
disk_enable();
}
printf("Rereading the partition table...\n");
rc = reread_partition_table();
rc = dasd_reread_partition_table(dev_filename, 5);
if (rc) {
ERRMSG("%s: (signal handler) Re-reading partition table "
"failed. (%s)\n", prog_name, strerror(errno));
"failed. (%s)\n", prog_name, strerror(rc));
} else {
printf("Exiting...\n");
}
rc = close(filedes);
if (rc)
ERRMSG("%s: (signal handler) Unable to close device (%s)\n",
prog_name, strerror(errno));
signal(sig, SIG_DFL);
raise(sig);
}
@@ -456,46 +457,34 @@ static void program_interrupt_signal(int sig)
/*
* check given device name for blanks and some special characters
*/
static void get_device_name(dasdfmt_info_t *info, char *name, int argc,
char *argv[])
static void get_device_name(char *devname,
int optind, int argc, char *argv[])
{
struct util_proc_dev_entry dev_entry;
struct stat dev_stat;
if (info->device_id + 1 < argc)
if (optind + 1 < argc)
ERRMSG_EXIT(EXIT_MISUSE,
"%s: More than one device specified!\n", prog_name);
if (info->device_id >= argc)
if (optind >= argc)
ERRMSG_EXIT(EXIT_MISUSE, "%s: No device specified!\n",
prog_name);
if (info->device_id < argc) {
strcpy(info->devname, argv[info->device_id]);
} else {
if ((strchr(name, ' ') != NULL) || (strchr(name, '#') != NULL) ||
(strchr(name, '[') != NULL) || (strchr(name, ']') != NULL) ||
(strchr(name, '!') != NULL) || (strchr(name, '>') != NULL) ||
(strchr(name, '(') != NULL) || (strchr(name, '<') != NULL) ||
(strchr(name, ')') != NULL) || (strchr(name, ':') != NULL) ||
(strchr(name, '&') != NULL) || (strchr(name, ';') != NULL))
ERRMSG_EXIT(EXIT_MISUSE, "%s: Your filename contains "
"blanks or special characters!\n",
prog_name);
if (strlen(argv[optind]) >= PATH_MAX)
ERRMSG_EXIT(EXIT_MISUSE, "%s: device name too long!\n",
prog_name);
strcpy(devname, argv[optind]);
strncpy(info->devname, name, PATH_MAX - 1);
info->devname[PATH_MAX - 1] = '\0';
}
if (stat(info->devname, &dev_stat) != 0)
if (stat(devname, &dev_stat) != 0)
ERRMSG_EXIT(EXIT_MISUSE, "%s: Could not get information for "
"device node %s: %s\n", prog_name, info->devname,
"device node %s: %s\n", prog_name, devname,
strerror(errno));
if (minor(dev_stat.st_rdev) & PARTN_MASK) {
ERRMSG_EXIT(EXIT_MISUSE, "%s: Unable to format partition %s. "
"Please specify a device.\n", prog_name,
info->devname);
devname);
}
if (util_proc_dev_get_entry(dev_stat.st_rdev, 1, &dev_entry) == 0) {
@@ -505,34 +494,19 @@ static void get_device_name(dasdfmt_info_t *info, char *name, int argc,
prog_name, dev_entry.name);
} else {
printf("%s WARNING: Unable to get driver name for device node %s",
prog_name, info->devname);
prog_name, devname);
}
}
/*
* Retrieve DASD information
*/
static void get_device_info(dasdfmt_info_t *info)
static void get_blocksize(const char *device, unsigned int *blksize)
{
dasd_information2_t dasd_info;
int err;
if (ioctl(filedes, BIODASDINFO2, &dasd_info))
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl call to retrieve "
"device information failed (%s).\n",
prog_name, strerror(errno));
info->dasd_info = dasd_info;
}
/*
* Retrieve blocksize of device
*/
static void get_blocksize(unsigned int *blksize)
{
if (ioctl(filedes, BLKSSZGET, blksize) != 0)
err = dasd_get_blocksize(device, blksize);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl to get the blocksize "
"of the device failed (%s).\n", prog_name,
strerror(errno));
strerror(err));
}
/*
@@ -546,7 +520,7 @@ static void check_blocksize(dasdfmt_info_t *info, unsigned int blksize)
info->dasd_info.format == DASD_FORMAT_NONE)
return;
get_blocksize(&dev_blksize);
get_blocksize(dev_filename, &dev_blksize);
if (dev_blksize != blksize) {
ERRMSG_EXIT(EXIT_FAILURE, "WARNING: Device is formatted with a "
"different blocksize (%d).\nUse --mode=full to "
@@ -586,18 +560,17 @@ static void check_layout(dasdfmt_info_t *info, unsigned int intensity)
/*
* check for disk type and set some variables (e.g. usage count)
*/
static void check_disk(dasdfmt_info_t *info)
static void check_disk(dasdfmt_info_t *info, char *devname)
{
int ro, errno_save;
int err;
bool ro;
if (ioctl(filedes, BLKROGET, &ro) != 0) {
errno_save = errno;
close(filedes);
err = dasd_is_ro(devname, &ro);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE,
"%s: the ioctl call to retrieve read/write "
"status information failed (%s)\n",
prog_name, strerror(errno_save));
}
prog_name, strerror(err));
if (ro)
ERRMSG_EXIT(EXIT_FAILURE, "Disk is read only!\n");
@@ -609,13 +582,13 @@ static void check_disk(dasdfmt_info_t *info)
if (strncmp(info->dasd_info.type, "ECKD", 4) != 0) {
ERRMSG_EXIT(EXIT_FAILURE,
"%s: Unsupported disk type\n%s is not an "
"ECKD disk!\n", prog_name, info->devname);
"ECKD disk!\n", prog_name, devname);
}
if (dasd_sys_raw_track_access(info->devname)) {
if (dasd_sys_raw_track_access(devname)) {
ERRMSG_EXIT(EXIT_FAILURE,
"%s: Device '%s' is in raw-track access mode\n",
prog_name, info->devname);
prog_name, devname);
}
}
@@ -787,9 +760,11 @@ static format_check_t check_track_format(dasdfmt_info_t *info, format_data_t *p)
.stop_unit = p->stop_unit
}, 0
};
int err;
if (ioctl(filedes, BIODASDCHECKFMT, &cdata)) {
if (errno == ENOTTY) {
err = dasd_check_format(dev_filename, &cdata);
if (err != 0) {
if (err == ENOTTY) {
ERRMSG("%s: Missing kernel support for format checking",
prog_name);
if (mode == EXPAND) {
@@ -800,7 +775,7 @@ static format_check_t check_track_format(dasdfmt_info_t *info, format_data_t *p)
ERRMSG_EXIT(EXIT_FAILURE, ".\n");
}
ERRMSG_EXIT(EXIT_FAILURE, "%s: Could no check format: %s\n",
prog_name, strerror(errno));
prog_name, strerror(err));
}
return cdata;
@@ -816,7 +791,7 @@ static int process_tracks(dasdfmt_info_t *info, unsigned int cylinders,
format_data_t step = *format_params;
unsigned long step_value;
unsigned long cur_trk;
int cyl = 0;
int cyl = 0, err;
check_hashmarks(info);
@@ -839,10 +814,11 @@ static int process_tracks(dasdfmt_info_t *info, unsigned int cylinders,
break;
}
} else {
if (ioctl(filedes, BIODASDFMT, &step) != 0)
err = dasd_format_disk(filedes, &step);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl call "
"to format tracks failed. (%s)\n",
prog_name, strerror(errno));
prog_name, strerror(err));
}
cyl = cur_trk / heads + 1;
@@ -935,7 +911,8 @@ static format_data_t ask_user_for_blksize(format_data_t params)
/*
* print all information needed to format the device
*/
static void dasdfmt_print_info(dasdfmt_info_t *info, volume_label_t *vlabel,
static void dasdfmt_print_info(dasdfmt_info_t *info, char *devname,
volume_label_t *vlabel,
unsigned int cylinders, unsigned int heads,
format_data_t *p)
{
@@ -945,7 +922,7 @@ static void dasdfmt_print_info(dasdfmt_info_t *info, volume_label_t *vlabel,
cylinders, heads, (cylinders * heads));
printf("\nI am going to format the device ");
printf("%s in the following way:\n", info->devname);
printf("%s in the following way:\n", devname);
printf(" Device number of device : 0x%x\n", info->dasd_info.devno);
printf(" Labelling device : %s\n",
(info->writenolabel) ? "no" : "yes");
@@ -970,28 +947,19 @@ static void dasdfmt_print_info(dasdfmt_info_t *info, volume_label_t *vlabel,
/*
* get volser
*/
static int dasdfmt_get_volser(dasdfmt_info_t *info, char *volser)
static int dasdfmt_get_volser(char *devname, dasd_information2_t *dasd_info,
char *volser)
{
unsigned int blksize;
int f;
volume_label_t vlabel;
f = open(info->devname, O_RDONLY);
if (f == -1)
ERRMSG_EXIT(EXIT_FAILURE, "%s: Unable to open device %s: %s\n",
prog_name, info->devname, strerror(errno));
get_blocksize(devname, &blksize);
get_blocksize(&blksize);
if (close(f) != 0)
ERRMSG("%s: error during close: %s\ncontinuing...\n",
prog_name, strerror(errno));
if ((strncmp(info->dasd_info.type, "ECKD", 4) == 0) &&
(!info->dasd_info.FBA_layout)) {
if ((strncmp(dasd_info->type, "ECKD", 4) == 0) &&
!dasd_info->FBA_layout) {
/* OS/390 and zOS compatible disk layout */
vtoc_read_volume_label(info->devname,
info->dasd_info.label_block * blksize,
vtoc_read_volume_label(devname,
dasd_info->label_block * blksize,
&vlabel);
vtoc_volume_label_get_volser(&vlabel, volser);
return 0;
@@ -1012,25 +980,25 @@ static void dasdfmt_write_labels(dasdfmt_info_t *info, volume_label_t *vlabel,
format5_label_t f5;
format7_label_t f7;
unsigned int blksize;
int rc;
int rc, fd;
void *ipl1_record, *ipl2_record;
int ipl1_record_len, ipl2_record_len;
if (info->verbosity > 0)
printf("Retrieving dasd information... ");
get_blocksize(&blksize);
get_blocksize(dev_filename, &blksize);
/*
* Don't rely on the cylinders returned by HDIO_GETGEO, they might be
* to small. geo is only used to get the number of sectors, which may
* vary depending on the format.
*/
if (ioctl(filedes, HDIO_GETGEO, &geo) != 0)
rc = dasd_get_geo(dev_filename, &geo);
if (rc != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (write labels) IOCTL "
"HDIO_GETGEO failed (%s).\n",
prog_name, strerror(errno));
prog_name, strerror(rc));
if (info->verbosity > 0)
printf("ok\n");
@@ -1056,26 +1024,40 @@ static void dasdfmt_write_labels(dasdfmt_info_t *info, volume_label_t *vlabel,
ipl2_record_len = sizeof(ipl2.data);
}
if (lseek(filedes, 0, SEEK_SET) != 0)
fd = open(dev_filename, O_RDWR);
if (fd < 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: Unable to open device "
"'%s' (%s)\n", prog_name, dev_filename,
strerror(errno));
if (lseek(fd, 0, SEEK_SET) != 0) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek command 0 failed "
"(%s)\n", prog_name, strerror(errno));
}
rc = write(filedes, ipl1_record, ipl1_record_len);
if (rc != ipl1_record_len)
rc = write(fd, ipl1_record, ipl1_record_len);
if (rc != ipl1_record_len) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Writing the bootstrap IPL1 "
"failed, only wrote %d bytes.\n", prog_name, rc);
}
label_position = blksize;
rc = lseek(filedes, label_position, SEEK_SET);
if (rc != label_position)
rc = lseek(fd, label_position, SEEK_SET);
if (rc != label_position) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek command to %i failed "
"(%s).\n", prog_name, label_position,
strerror(errno));
}
rc = write(filedes, ipl2_record, ipl2_record_len);
if (rc != ipl2_record_len)
rc = write(fd, ipl2_record, ipl2_record_len);
if (rc != ipl2_record_len) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Writing the bootstrap IPL2 "
"failed, only wrote %d bytes.\n", prog_name, rc);
}
/* write VTOC */
vtoc_init_format4_label(&f4, geo.cylinders, cylinders, heads,
@@ -1091,32 +1073,36 @@ static void dasdfmt_write_labels(dasdfmt_info_t *info, volume_label_t *vlabel,
if (info->verbosity > 0)
printf("Writing label...\n");
rc = lseek(filedes, label_position, SEEK_SET);
if (rc != label_position)
rc = lseek(fd, label_position, SEEK_SET);
if (rc != label_position) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek command to %i failed "
"(%s).\n", prog_name, label_position,
strerror(errno));
}
/*
* Note: cdl volume labels do not contain the 'formatted_blocks' part
* and ldl labels do not contain the key field
*/
if (info->cdl_format) {
rc = write(filedes, vlabel, (sizeof(*vlabel) -
sizeof(vlabel->formatted_blocks)));
rc = write(fd, vlabel, (sizeof(*vlabel) -
sizeof(vlabel->formatted_blocks)));
} else {
vlabel->ldl_version = 0xf2; /* EBCDIC '2' */
vlabel->formatted_blocks = cylinders * heads * geo.sectors;
rc = write(filedes, &vlabel->vollbl, (sizeof(*vlabel)
- sizeof(vlabel->volkey)));
rc = write(fd, &vlabel->vollbl, (sizeof(*vlabel)
- sizeof(vlabel->volkey)));
}
if (((rc != sizeof(*vlabel) - sizeof(vlabel->formatted_blocks)) &&
info->cdl_format) ||
((rc != (sizeof(*vlabel) - sizeof(vlabel->volkey))) &&
(!info->cdl_format)))
!info->cdl_format)) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Error writing volume label "
"(%d).\n", prog_name, rc);
}
if (info->verbosity > 0)
printf("Writing VTOC... ");
@@ -1124,48 +1110,62 @@ static void dasdfmt_write_labels(dasdfmt_info_t *info, volume_label_t *vlabel,
label_position = (VTOC_START_CC * heads + VTOC_START_HH) *
geo.sectors * blksize;
rc = lseek(filedes, label_position, SEEK_SET);
if (rc != label_position)
rc = lseek(fd, label_position, SEEK_SET);
if (rc != label_position) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek command to %i failed "
"(%s).\n", prog_name, label_position,
strerror(errno));
}
/* write VTOC FMT4 DSCB */
rc = write(filedes, &f4, sizeof(format4_label_t));
if (rc != sizeof(format4_label_t))
rc = write(fd, &f4, sizeof(format4_label_t));
if (rc != sizeof(format4_label_t)) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Error writing FMT4 label "
"(%d).\n", prog_name, rc);
}
label_position += blksize;
rc = lseek(filedes, label_position, SEEK_SET);
if (rc != label_position)
rc = lseek(fd, label_position, SEEK_SET);
if (rc != label_position) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek to %i failed (%s).\n",
prog_name, label_position, strerror(errno));
}
/* write VTOC FMT5 DSCB */
rc = write(filedes, &f5, sizeof(format5_label_t));
if (rc != sizeof(format5_label_t))
rc = write(fd, &f5, sizeof(format5_label_t));
if (rc != sizeof(format5_label_t)) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Error writing FMT5 label "
"(%d).\n", prog_name, rc);
}
if ((cylinders * heads) > BIG_DISK_SIZE) {
label_position += blksize;
rc = lseek(filedes, label_position, SEEK_SET);
if (rc != label_position)
rc = lseek(fd, label_position, SEEK_SET);
if (rc != label_position) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek to %i failed "
"(%s).\n", prog_name, label_position,
strerror(errno));
}
/* write VTOC FMT 7 DSCB (only on big disks) */
rc = write(filedes, &f7, sizeof(format7_label_t));
if (rc != sizeof(format7_label_t))
rc = write(fd, &f7, sizeof(format7_label_t));
if (rc != sizeof(format7_label_t)) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Error writing FMT7 "
"label (rc=%d).\n", prog_name, rc);
}
}
fsync(filedes);
fsync(fd);
close(fd);
if (info->verbosity > 0)
printf("ok\n");
@@ -1245,27 +1245,25 @@ static void dasdfmt_prepare_and_format(dasdfmt_info_t *info,
.intensity = ((p->intensity & ~DASD_FMT_INT_FMT_NOR0)
| DASD_FMT_INT_INVAL)
};
int err;
if (!((info->withoutprompt) && (info->verbosity < 1)))
if (!(info->withoutprompt && (info->verbosity < 1)))
printf("Formatting the device. This may take a while "
"(get yourself a coffee).\n");
if (info->verbosity > 0)
printf("Detaching the device...\n");
if (ioctl(filedes, BIODASDDISABLE, p) != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDDISABLE failed. (%s)\n", prog_name,
strerror(errno));
disk_disabled = 1;
disk_disable(dev_filename);
if (info->verbosity > 0)
printf("Invalidate first track...\n");
if (ioctl(filedes, BIODASDFMT, &temp) != 0)
err = dasd_format_disk(filedes, &temp);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (invalidate first track) IOCTL "
"BIODASDFMT failed. (%s)\n", prog_name,
strerror(errno));
strerror(err));
/* except track 0 from standard formatting procss */
p->start_unit = 1;
@@ -1280,19 +1278,16 @@ static void dasdfmt_prepare_and_format(dasdfmt_info_t *info,
if (info->verbosity > 0)
printf("Revalidate first track...\n");
if (ioctl(filedes, BIODASDFMT, &temp) != 0)
err = dasd_format_disk(filedes, &temp);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (re-validate first track) IOCTL"
" BIODASDFMT failed (%s)\n", prog_name,
strerror(errno));
strerror(err));
if (info->verbosity > 0)
printf("Re-accessing the device...\n");
if (ioctl(filedes, BIODASDENABLE, p) != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDENABLE failed. (%s)\n", prog_name,
strerror(errno));
disk_disabled = 0;
disk_enable();
}
/*
@@ -1301,18 +1296,14 @@ static void dasdfmt_prepare_and_format(dasdfmt_info_t *info,
static void dasdfmt_expand_format(dasdfmt_info_t *info, unsigned int cylinders,
unsigned int heads, format_data_t *p)
{
if (!((info->withoutprompt) && (info->verbosity < 1)))
if (!(info->withoutprompt && (info->verbosity < 1)))
printf("Formatting the device. This may take a while "
"(get yourself a coffee).\n");
if (info->verbosity > 0)
printf("Detaching the device...\n");
if (ioctl(filedes, BIODASDDISABLE, p) != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDDISABLE failed. (%s)\n", prog_name,
strerror(errno));
disk_disabled = 1;
disk_disable(dev_filename);
dasdfmt_format(info, cylinders, heads, p);
@@ -1322,11 +1313,7 @@ static void dasdfmt_expand_format(dasdfmt_info_t *info, unsigned int cylinders,
if (info->verbosity > 0)
printf("Re-accessing the device...\n");
if (ioctl(filedes, BIODASDENABLE, p) != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDENABLE failed. (%s)\n", prog_name,
strerror(errno));
disk_disabled = 0;
disk_enable();
}
/*
@@ -1338,6 +1325,7 @@ static void dasdfmt_quick_format(dasdfmt_info_t *info, unsigned int cylinders,
{
format_check_t cdata = { .expect = {0}, 0 };
format_data_t tmp = *p;
int err;
if (info->force) {
printf("Skipping format check due to --force.\n");
@@ -1364,33 +1352,29 @@ static void dasdfmt_quick_format(dasdfmt_info_t *info, unsigned int cylinders,
}
}
if (!((info->withoutprompt) && (info->verbosity < 1)))
if (!(info->withoutprompt && (info->verbosity < 1)))
printf("Formatting the first two tracks of the device.\n");
/* Disable the device before we do anything */
if (ioctl(filedes, BIODASDDISABLE, p))
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl to disable the device "
"failed. (%s)\n", prog_name, strerror(errno));
disk_disabled = 1;
disk_disable(dev_filename);
/* Now do the actual formatting of our first two tracks */
if (ioctl(filedes, BIODASDFMT, p))
err = dasd_format_disk(filedes, p);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl to format the device "
"failed. (%s)\n", prog_name, strerror(errno));
"failed. (%s)\n", prog_name, strerror(err));
/* Re-Enable the device so that we can continue working with it */
if (ioctl(filedes, BIODASDENABLE, p))
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl to enable the device "
"failed. (%s)\n", prog_name, strerror(errno));
disk_disabled = 0;
disk_enable();
}
static void do_format_dasd(dasdfmt_info_t *info, volume_label_t *vlabel,
static void do_format_dasd(dasdfmt_info_t *info, char *devname,
volume_label_t *vlabel,
format_data_t *p, unsigned int cylinders,
unsigned int heads)
{
char inp_buffer[5];
int count;
int count, err;
p->start_unit = 0;
@@ -1408,19 +1392,19 @@ static void do_format_dasd(dasdfmt_info_t *info, volume_label_t *vlabel,
}
if ((info->verbosity > 0) || !info->withoutprompt || info->testmode)
dasdfmt_print_info(info, vlabel, cylinders, heads, p);
dasdfmt_print_info(info, devname, vlabel, cylinders, heads, p);
count = u2s_get_host_access_count(info->devname);
count = u2s_get_host_access_count(devname);
if (info->force_host) {
if (count > 1) {
ERRMSG_EXIT(EXIT_FAILURE,
"\n%s: Disk %s is online on OS instances in %d different LPARs.\n"
"Note: Your installation might include z/VM systems that are configured to\n"
"automatically vary on disks, regardless of whether they are subsequently used.\n\n",
prog_name, info->devname, count);
prog_name, devname, count);
} else if (count < 0) {
ERRMSG("\nHosts access information not available for disk %s.\n\n",
info->devname);
devname);
return;
}
} else if (count > 1)
@@ -1429,7 +1413,7 @@ static void do_format_dasd(dasdfmt_info_t *info, volume_label_t *vlabel,
"Ensure that the disk is not being used by a system outside your LPAR.\n"
"Note: Your installation might include z/VM systems that are configured to\n"
"automatically vary on disks, regardless of whether they are subsequently used.\n",
info->devname, count);
devname, count);
if (!info->testmode) {
if (!info->withoutprompt) {
@@ -1467,9 +1451,10 @@ static void do_format_dasd(dasdfmt_info_t *info, volume_label_t *vlabel,
dasdfmt_write_labels(info, vlabel, cylinders, heads);
printf("Rereading the partition table... ");
if (reread_partition_table()) {
err = dasd_reread_partition_table(dev_filename, 5);
if (err != 0) {
ERRMSG("%s: error during rereading the partition "
"table: %s.\n", prog_name, strerror(errno));
"table: %s.\n", prog_name, strerror(err));
} else {
printf("ok\n");
}
@@ -1480,12 +1465,10 @@ int main(int argc, char *argv[])
{
dasdfmt_info_t info = {
.dasd_info = {0},
{0}
};
volume_label_t vlabel;
char old_volser[7];
char dev_filename[PATH_MAX];
char str[ERR_LENGTH];
char buf[7];
@@ -1624,7 +1607,6 @@ int main(int argc, char *argv[])
break;
case -1:
/* End of options string - start of devices list */
info.device_id = optind;
break;
default:
ERRMSG_EXIT(EXIT_MISUSE, "Try '%s --help' for more"
@@ -1655,20 +1637,19 @@ int main(int argc, char *argv[])
if (info.print_hashmarks)
PARSE_PARAM_INTO(info.hashstep, hashstep_str, 10, "hashstep");
get_device_name(&info, dev_filename, argc, argv);
get_device_name(dev_filename, optind, argc, argv);
filedes = open(info.devname, O_RDWR);
if (filedes == -1)
ERRMSG_EXIT(EXIT_FAILURE, "%s: Unable to open device %s: %s\n",
prog_name, info.devname, strerror(errno));
get_device_info(&info);
rc = dasd_get_info(dev_filename, &info.dasd_info);
if (rc != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl call to retrieve "
"device information failed (%s).\n",
prog_name, strerror(rc));
/* Either let the user specify the blksize or get it from the kernel */
if (!info.blksize_specified) {
if (!(mode == FULL ||
info.dasd_info.format == DASD_FORMAT_NONE) || info.check)
get_blocksize(&format_params.blksize);
get_blocksize(dev_filename, &format_params.blksize);
else
format_params = ask_user_for_blksize(format_params);
}
@@ -1684,15 +1665,16 @@ int main(int argc, char *argv[])
exit(1);
}
if (dasdfmt_get_volser(&info, old_volser) == 0)
if (dasdfmt_get_volser(dev_filename,
&info.dasd_info, old_volser) == 0)
vtoc_volume_label_set_volser(&vlabel, old_volser);
else
ERRMSG_EXIT(EXIT_FAILURE,
"%s: VOLSER not found on device %s\n",
prog_name, info.devname);
prog_name, dev_filename);
}
check_disk(&info);
check_disk(&info, dev_filename);
if (check_param(str, ERR_LENGTH, &format_params) < 0)
ERRMSG_EXIT(EXIT_MISUSE, "%s: %s\n", prog_name, str);
@@ -1703,11 +1685,8 @@ int main(int argc, char *argv[])
if (info.check)
check_disk_format(&info, cylinders, heads, &format_params);
else
do_format_dasd(&info, &vlabel, &format_params, cylinders, heads);
if (close(filedes) != 0)
ERRMSG("%s: error during close: %s\ncontinuing...\n",
prog_name, strerror(errno));
do_format_dasd(&info, dev_filename, &vlabel,
&format_params, cylinders, heads);
return 0;
}

View File

@@ -31,120 +31,6 @@
* SECTION: Definition needed for DASD-API (see dasd.h) *
****************************************************************************/
#define DASD_IOCTL_LETTER 'D'
/*
* struct dasd_information2_t
* represents any data about the device, which is visible to userspace.
* including format and features.
*/
typedef struct dasd_information2_t {
unsigned int devno; /* S/390 devno */
unsigned int real_devno; /* for aliases */
unsigned int schid; /* S/390 subchannel identifier */
unsigned int cu_type : 16; /* from SenseID */
unsigned int cu_model : 8; /* from SenseID */
unsigned int dev_type : 16; /* from SenseID */
unsigned int dev_model : 8; /* from SenseID */
unsigned int open_count;
unsigned int req_queue_len;
unsigned int chanq_len; /* length of chanq */
char type[4]; /* from discipline.name, */
/* 'none' for unknown */
unsigned int status; /* current device level */
unsigned int label_block; /* where to find the VOLSER */
unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
unsigned int characteristics_size;
unsigned int confdata_size;
char characteristics[64]; /* from read_device_characteristics */
char configuration_data[256]; /* from read_configuration_data */
unsigned int format; /* format info like formatted/cdl/ldl/... */
unsigned int features; /* dasd features like 'ro',... */
unsigned int reserved0; /* reserved for further use ,... */
unsigned int reserved1; /* reserved for further use ,... */
unsigned int reserved2; /* reserved for further use ,... */
unsigned int reserved3; /* reserved for further use ,... */
unsigned int reserved4; /* reserved for further use ,... */
unsigned int reserved5; /* reserved for further use ,... */
unsigned int reserved6; /* reserved for further use ,... */
unsigned int reserved7; /* reserved for further use ,... */
} dasd_information2_t;
struct dasd_eckd_characteristics {
unsigned short cu_type;
struct {
unsigned char support:2;
unsigned char async:1;
unsigned char reserved:1;
unsigned char cache_info:1;
unsigned char model:3;
} __attribute__ ((packed)) cu_model;
unsigned short dev_type;
unsigned char dev_model;
struct {
unsigned char mult_burst:1;
unsigned char RT_in_LR:1;
unsigned char reserved1:1;
unsigned char RD_IN_LR:1;
unsigned char reserved2:4;
unsigned char reserved3:8;
unsigned char defect_wr:1;
unsigned char XRC_supported:1;
unsigned char reserved4:1;
unsigned char striping:1;
unsigned char reserved5:4;
unsigned char cfw:1;
unsigned char reserved6:2;
unsigned char cache:1;
unsigned char dual_copy:1;
unsigned char dfw:1;
unsigned char reset_alleg:1;
unsigned char sense_down:1;
} __attribute__ ((packed)) facilities;
unsigned char dev_class;
unsigned char unit_type;
unsigned short no_cyl;
unsigned short trk_per_cyl;
unsigned char sec_per_trk;
unsigned char byte_per_track[3];
unsigned short home_bytes;
unsigned char formula;
union {
struct {
unsigned char f1;
unsigned short f2;
unsigned short f3;
} __attribute__ ((packed)) f_0x01;
struct {
unsigned char f1;
unsigned char f2;
unsigned char f3;
unsigned char f4;
unsigned char f5;
} __attribute__ ((packed)) f_0x02;
} __attribute__ ((packed)) factors;
unsigned short first_alt_trk;
unsigned short no_alt_trk;
unsigned short first_dia_trk;
unsigned short no_dia_trk;
unsigned short first_sup_trk;
unsigned short no_sup_trk;
unsigned char MDR_ID;
unsigned char OBR_ID;
unsigned char director;
unsigned char rd_trk_set;
unsigned short max_rec_zero;
unsigned char reserved1;
unsigned char RWANY_in_LR;
unsigned char factor6;
unsigned char factor7;
unsigned char factor8;
unsigned char reserved2[3];
unsigned char reserved3[6];
unsigned int long_no_cyl;
} __attribute__ ((packed));
/*
* Represents possible format modes that can be specified when formatting
* a DASD.
@@ -159,17 +45,6 @@ static const char mode_str[3][10] = {
"Full", "Quick", "Expand"
};
/*
* struct format_data_t
* represents all data necessary to format a dasd
*/
typedef struct format_data_t {
unsigned int start_unit; /* from track */
unsigned int stop_unit; /* to track */
unsigned int blksize; /* sectorsize */
unsigned int intensity;
} format_data_t;
/*
* values to be used for format_data_t.intensity
* 0/8: normal format
@@ -183,24 +58,6 @@ typedef struct format_data_t {
#define DASD_FMT_INT_COMPAT 8 /* use OS/390 compatible disk layout */
#define DASD_FMT_INT_FMT_NOR0 16 /* remove permission to write record zero */
/*
* struct format_check_t
* represents all data necessary to evaluate the format of
* different tracks of a dasd
*/
typedef struct format_check_t {
/* Input */
struct format_data_t expect;
/* Output */
unsigned int result; /* Error indication (DASD_FMT_ERR_*) */
unsigned int unit; /* Track that is in error */
unsigned int rec; /* Record that is in error */
unsigned int num_records; /* Records in the track in error */
unsigned int blksize; /* Block-size of first record in error */
unsigned int key_length; /* Key length of first record in error */
} format_check_t;
/*
* values to be used in format_check_t for indicating
* possible format errors
@@ -221,33 +78,6 @@ typedef struct format_check_t {
#define DASD_FORMAT_LDL 1
#define DASD_FORMAT_CDL 2
/* Disable the volume (for Linux) */
#define BIODASDDISABLE _IO(DASD_IOCTL_LETTER,0)
/* Enable the volume (for Linux) */
#define BIODASDENABLE _IO(DASD_IOCTL_LETTER,1)
/* Get information on a dasd device (enhanced) */
#define BIODASDINFO2 _IOR(DASD_IOCTL_LETTER, 3, dasd_information2_t)
/* #define BIODASDFORMAT _IOW(IOCTL_LETTER,0,format_data_t) , deprecated */
#define BIODASDFMT _IOW(DASD_IOCTL_LETTER,1,format_data_t)
/* Check device format according to format_data_t */
#define BIODASDCHECKFMT _IOWR(DASD_IOCTL_LETTER, 2, format_check_t)
/****************************************************************************
* SECTION: Further IOCTL Definitions (see fs.h and hdreq.h ) *
****************************************************************************/
/* re-read partition table */
#define BLKRRPART _IO(0x12,95)
/* get block device sector size */
#define BLKSSZGET _IO(0x12,104)
/* get read-only status (0 = read_write) */
#define BLKROGET _IO(0x12,94)
/* get device geometry */
#define HDIO_GETGEO 0x0301
/****************************************************************************
* SECTION: DASDFMT internal types *
****************************************************************************/
@@ -291,7 +121,6 @@ typedef struct bootstrap2 {
typedef struct dasdfmt_info {
dasd_information2_t dasd_info;
char devname[PATH_MAX];
int verbosity;
int testmode;
int withoutprompt;
@@ -304,7 +133,6 @@ typedef struct dasdfmt_info {
int cdl_format;
int blksize_specified;
int reqsize_specified;
int device_id;
int keep_volser;
int force_host;
int layout_specified;

View File

@@ -1,7 +1,8 @@
include ../common.mak
libs = $(rootdir)/libu2s/libu2s.a \
$(rootdir)/libutil/libutil.a
$(rootdir)/libutil/libutil.a \
$(rootdir)/libdasd/libdasd.a
all: dasdinfo

View File

@@ -22,16 +22,14 @@
#include <sys/utsname.h>
#include <unistd.h>
#include "lib/dasd_base.h"
#include "lib/util_base.h"
#include "lib/util_file.h"
#include "lib/util_opt.h"
#include "lib/util_prg.h"
#include "lib/zt_common.h"
#define READCHUNK 80
#define BLKSSZGET _IO(0x12,104)
#define DASD_IOCTL_LETTER 'D'
#define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,struct dasd_information)
#define BIODASDINFO2 _IOR(DASD_IOCTL_LETTER,3,struct dasd_information2)
#define RD_BUFFER_SIZE 80
#define TEMP_DEV_MAX_RETRIES 1000
static const struct util_prg prg = {
@@ -99,67 +97,7 @@ struct volume_label {
char volid[6];
} __attribute__ ((packed));
struct dasd_information2 {
unsigned int devno;
unsigned int real_devno;
unsigned int schid;
unsigned int cu_type : 16;
unsigned int cu_model : 8;
unsigned int dev_type : 16;
unsigned int dev_model : 8;
unsigned int open_count;
unsigned int req_queue_len;
unsigned int chanq_len;
char type[4];
unsigned int status;
unsigned int label_block;
unsigned int FBA_layout;
unsigned int characteristics_size;
unsigned int confdata_size;
char characteristics[64];
char configuration_data[256];
unsigned int format;
unsigned int features;
unsigned int reserved0;
unsigned int reserved1;
unsigned int reserved2;
unsigned int reserved3;
unsigned int reserved4;
unsigned int reserved5;
unsigned int reserved6;
unsigned int reserved7;
};
struct dasd_information {
unsigned int devno;
unsigned int real_devno;
unsigned int schid;
unsigned int cu_type : 16;
unsigned int cu_model : 8;
unsigned int dev_type : 16;
unsigned int dev_model : 8;
unsigned int open_count;
unsigned int req_queue_len;
unsigned int chanq_len;
char type[4];
unsigned int status;
unsigned int label_block;
unsigned int FBA_layout;
unsigned int characteristics_size;
unsigned int confdata_size;
char characteristics[64];
char configuration_data[256];
};
struct dasd_data
{
struct dasd_information2 dasd_info;
int dasd_info_version;
int blksize;
};
static char EBCtoASC[256] =
{
static char EBCtoASC[256] = {
/* 0x00 NUL SOH STX ETX *SEL HT *RNL DEL */
0x00, 0x01, 0x02, 0x03, 0x07, 0x09, 0x07, 0x7F,
/* 0x08 -GE -SPS -RPT VT FF CR SO SI */
@@ -226,86 +164,64 @@ static char EBCtoASC[256] =
0x38, 0x39, 0x07, 0x07, 0x9A, 0x07, 0x07, 0x07
};
static char *dinfo_ebcdic_dec (char *source, char *target, int l)
static char *dinfo_ebcdic_dec(char *source, char *target, int l)
{
int i;
for (i = 0; i < l; i++)
target[i]=EBCtoASC[(unsigned char)(source[i])];
target[i] = EBCtoASC[(unsigned char)(source[i])];
return target;
}
static int dinfo_read_dasd_uid (char *uidfile, char *readbuf, int readbuflen)
static int dinfo_read_dasd_uid(char *uidfile, char *readbuf)
{
FILE *dasduid;
int offset = 0;
if ((dasduid = fopen(uidfile,"r")) == NULL)
return -1;
while (fgets(readbuf + offset, READCHUNK, dasduid) &&
readbuf[strlen(readbuf)-1] != '\n' ) {
offset += READCHUNK-1;
if ( offset+READCHUNK-1 >= readbuflen ) {
readbuf = realloc(readbuf,
readbuflen + READCHUNK-1);
readbuflen += READCHUNK-1;
}
}
fclose(dasduid);
if (strlen(readbuf) <= 1)
return -1;
return 0;
return util_file_read_line(readbuf, RD_BUFFER_SIZE, uidfile);
}
static int dinfo_read_dasd_vlabel (char *device, struct volume_label *vlabel,
char *readbuf)
static int dinfo_read_dasd_vlabel(char *device, struct volume_label *vlabel,
char *readbuf)
{
struct dasd_data data;
struct volume_label tmp;
int vlsize = sizeof(struct volume_label);
dasd_information2_t dasd_info;
unsigned long vlabel_start;
unsigned int blksize;
char vollbl[5];
int f;
char *space;
if ((f = open(device, O_RDONLY)) < 0) {
printf("Could not open device node.\n");
goto error;
}
if (ioctl(f, BLKSSZGET, &data.blksize) != 0) {
if (dasd_get_blocksize(device, &blksize) != 0) {
printf("Unable to figure out block size.\n");
goto error;
}
if (ioctl(f, BIODASDINFO2, &data.dasd_info) == 0)
data.dasd_info_version = 2;
else {
if (ioctl(f, BIODASDINFO, &data.dasd_info) != 0) {
printf("Unable to figure out DASD informations.\n");
goto error;
}
if (dasd_get_info(device, &dasd_info) != 0) {
printf("Unable to figure out DASD informations.\n");
goto error;
}
vlabel_start = data.dasd_info.label_block * data.blksize;
if (lseek(f, vlabel_start, SEEK_SET) < 0)
f = open(device, O_RDONLY);
if (f < 0) {
printf("Could not open device node.\n");
goto error;
}
vlabel_start = dasd_info.label_block * blksize;
if (lseek(f, vlabel_start, SEEK_SET) < 0)
goto error_close;
bzero(vlabel, vlsize);
if (read(f, vlabel, vlsize) != vlsize) {
printf("Could not read volume label.\n");
goto error;
goto error_close;
}
if (data.dasd_info.FBA_layout) {
if (dasd_info.FBA_layout) {
bzero(&tmp, vlsize);
memcpy(&tmp, vlabel, vlsize);
memcpy(vlabel->vollbl, &tmp, vlsize-4);
memcpy(vlabel->vollbl, &tmp, vlsize - 4);
}
close(f);
@@ -320,16 +236,17 @@ static int dinfo_read_dasd_vlabel (char *device, struct volume_label *vlabel,
(strncmp(vollbl, "CMS1", 4) == 0)) {
strncpy(readbuf, vlabel->volid, 6);
dinfo_ebcdic_dec(readbuf, readbuf, 6);
space = strchr(readbuf,' ');
space = strchr(readbuf, ' ');
if (space)
*space = 0;
} else
} else {
strcpy(readbuf, "");
}
return 0;
error:
error_close:
close(f);
error:
return -1;
}
@@ -340,7 +257,7 @@ static void *dinfo_malloc(size_t size)
result = malloc(size);
if (result == NULL) {
printf("Could not allocate %lld bytes of memory",
(unsigned long long) size);
(unsigned long long)size);
}
return result;
}
@@ -351,7 +268,7 @@ static char *dinfo_make_path(char *dirname, char *filename)
size_t len;
len = strlen(dirname) + strlen(filename) + 2;
result = (char *) dinfo_malloc(len);
result = (char *)dinfo_malloc(len);
if (result == NULL)
return NULL;
sprintf(result, "%s/%s", dirname, filename);
@@ -361,8 +278,8 @@ static char *dinfo_make_path(char *dirname, char *filename)
static int dinfo_create_devnode(dev_t dev, char **devno)
{
char *result;
char * pathname[] = { "/dev", getenv("TMPDIR"), "/tmp",
getenv("HOME"), "." , "/"};
char *pathname[] = { "/dev", getenv("TMPDIR"), "/tmp",
getenv("HOME"), ".", "/"};
char filename[] = "dasdinfo0000";
mode_t mode;
unsigned int path;
@@ -373,10 +290,10 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
mode = S_IFBLK | S_IRWXU;
/* Try several locations for the temporary device node. */
for (path=0; path < sizeof(pathname) / sizeof(pathname[0]); path++) {
for (path = 0; path < UTIL_ARRAY_SIZE(pathname); path++) {
if (pathname[path] == NULL)
continue;
for (retry=0; retry < TEMP_DEV_MAX_RETRIES; retry++) {
for (retry = 0; retry < TEMP_DEV_MAX_RETRIES; retry++) {
sprintf(filename, "dasdinfo%04d", retry);
result = dinfo_make_path(pathname[path], filename);
if (result == NULL)
@@ -385,7 +302,8 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
if (rc == 0) {
/* Need this test to cover
* 'nodev'-mounted
* filesystems. */
* filesystems.
*/
fd = open(result, O_RDONLY);
if (fd != -1) {
close(fd);
@@ -394,8 +312,9 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
}
remove(result);
retry = TEMP_DEV_MAX_RETRIES;
} else if (errno != EEXIST)
} else if (errno != EEXIST) {
retry = TEMP_DEV_MAX_RETRIES;
}
free(result);
}
}
@@ -411,15 +330,16 @@ static void dinfo_free_devnode(char *device)
}
}
static int dinfo_extract_dev(dev_t *dev, char *str, int readbuflen)
static int dinfo_extract_dev(dev_t *dev, char *str)
{
char tmp[readbuflen];
char tmp[RD_BUFFER_SIZE];
char *p = NULL;
int ma, mi;
bzero(tmp, readbuflen);
strncpy(tmp, str, readbuflen);
if ((p = strchr(tmp, ':')) == NULL) {
bzero(tmp, RD_BUFFER_SIZE);
strncpy(tmp, str, RD_BUFFER_SIZE);
p = strchr(tmp, ':');
if (p == NULL) {
printf("Error: unable to extract major/minor\n");
return -1;
}
@@ -435,37 +355,17 @@ static int dinfo_extract_dev(dev_t *dev, char *str, int readbuflen)
static int dinfo_get_dev_from_blockdev(char *blockdev, dev_t *dev)
{
FILE *dasddev;
int offset = 0;
char *devfile = NULL;
char *readbuf = NULL;
int readbuflen = READCHUNK;
if ((devfile = dinfo_malloc(readbuflen)) == NULL)
return -1;
sprintf(devfile,"/sys/block/%s/dev", blockdev);
if ((readbuf = dinfo_malloc(readbuflen)) == NULL) {
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
if (!readbuf) {
printf("Error: Not enough memory to allocate readbuffer\n");
return -1;
}
if ((dasddev = fopen(devfile,"r")) == NULL)
if (util_file_read_line(readbuf, RD_BUFFER_SIZE,
"/sys/block/%s/dev", blockdev) < 0)
return -1;
while (fgets(readbuf + offset, READCHUNK, dasddev) &&
readbuf[strlen(readbuf)-1] != '\n' ) {
offset += READCHUNK-1;
if (offset+READCHUNK-1 >= readbuflen) {
readbuf = realloc(readbuf,
readbuflen + READCHUNK-1);
readbuflen += READCHUNK-1;
}
}
fclose(dasddev);
if (dinfo_extract_dev(dev, readbuf, readbuflen) != 0)
if (dinfo_extract_dev(dev, readbuf) != 0)
return -1;
return 0;
@@ -478,6 +378,7 @@ dinfo_is_busiddir(const char *fpath, const struct stat *UNUSED(sb),
char *tempdir;
char linkdir[128];
ssize_t i;
if (tflag != FTW_D || (strncmp((fpath + ftwbuf->base), searchbusid,
strlen(searchbusid)) != 0))
return FTW_CONTINUE;
@@ -493,7 +394,7 @@ dinfo_is_busiddir(const char *fpath, const struct stat *UNUSED(sb),
if ((i < 0) || (i >= 128))
return -1;
/* append '\0' because readlink returns non zero terminated string */
tempdir[i+1] = '\0';
tempdir[i + 1] = '\0';
if (strstr(linkdir, "dasd") == NULL)
return FTW_CONTINUE;
free(busiddir);
@@ -509,15 +410,17 @@ dinfo_find_entry(const char *dir, const char *searchstring,
{
DIR *directory = NULL;
struct dirent *dir_entry = NULL;
directory = opendir(dir);
if (directory == NULL)
return -1;
while ((dir_entry = readdir(directory)) != NULL) {
/* compare if the found entry has exactly the same name
and type as searched */
/* compare if the found entry has exactly the same name and type
* as searched
*/
if ((strncmp(dir_entry->d_name, searchstring,
strlen(searchstring)) == 0)
&& (dir_entry->d_type & type)) {
strlen(searchstring)) == 0) &&
(dir_entry->d_type & type)) {
*result = strdup(dir_entry->d_name);
if (*result == NULL)
goto out;
@@ -580,14 +483,11 @@ out2:
static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
{
struct stat stat_buffer;
char stat_dev[READCHUNK];
char sys_dev_path[READCHUNK];
char stat_dev[RD_BUFFER_SIZE];
char *readbuf;
DIR *directory = NULL;
struct dirent *dir_entry = NULL;
FILE *block_dev;
int readbuflen = READCHUNK;
int offset;
int rc = 0;
if (stat(devnode, &stat_buffer) != 0) {
printf("Error: could not stat %s\n", devnode);
@@ -597,38 +497,35 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
sprintf(stat_dev, "%d:%d", major(stat_buffer.st_rdev),
minor(stat_buffer.st_rdev));
if ((directory = opendir("/sys/block/")) == NULL) {
directory = opendir("/sys/block/");
if (directory == NULL) {
printf("Error: could not open directory /sys/block\n");
return -1;
}
if ((readbuf = dinfo_malloc(readbuflen)) == NULL) {
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
if (!readbuf) {
printf("Error: Not enough memory to allocate readbuffer\n");
return -1;
}
while ((dir_entry = readdir(directory)) != NULL) {
sprintf(sys_dev_path, "/sys/block/%s/dev", dir_entry->d_name);
if ((block_dev = fopen(sys_dev_path,"r")) == NULL)
if (util_file_read_line(readbuf, RD_BUFFER_SIZE,
"/sys/block/%s/dev",
dir_entry->d_name) < 0)
continue;
offset = 0;
while (fgets(readbuf + offset, READCHUNK, block_dev) &&
readbuf[strlen(readbuf)-1] != '\n' ) {
offset += READCHUNK-1;
if ( offset+READCHUNK-1 >= readbuflen ) {
readbuf = realloc(readbuf,
readbuflen + READCHUNK-1);
readbuflen += READCHUNK-1;
}
}
fclose(block_dev);
if (strncmp(stat_dev, readbuf,
MAX(strlen(stat_dev), strlen(readbuf)-1)) == 0) {
sprintf(*uidfile,"/sys/block/%s/device/uid",
dir_entry->d_name);
MAX(strlen(stat_dev), strlen(readbuf) - 1)) == 0) {
rc = snprintf(*uidfile, RD_BUFFER_SIZE,
"/sys/block/%s/device/uid",
dir_entry->d_name);
if (rc >= RD_BUFFER_SIZE) {
fprintf(stderr,
"Error: Device name was truncated\n");
return -1;
}
break;
}
}
@@ -637,14 +534,13 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
return 0;
}
int main(int argc, char * argv[])
int main(int argc, char *argv[])
{
struct utsname uname_buf;
int version, release;
char *uidfile = NULL;
char *device = NULL;
char *readbuf = NULL;
int readbuflen = READCHUNK;
dev_t dev;
int export = 0;
int c;
@@ -682,13 +578,13 @@ int main(int argc, char * argv[])
print_vlabel = 1;
break;
case 'i':
busid=strdup(optarg);
busid = strdup(optarg);
break;
case 'b':
blockdev=strdup(optarg);
blockdev = strdup(optarg);
break;
case 'd':
devnode=strdup(optarg);
devnode = strdup(optarg);
break;
case 'e':
export = 1;
@@ -708,11 +604,11 @@ int main(int argc, char * argv[])
}
uname(&uname_buf);
sscanf(uname_buf.release, "%d.%d", &version,&release);
if (strcmp(uname_buf.sysname,"Linux") ||
sscanf(uname_buf.release, "%d.%d", &version, &release);
if (strcmp(uname_buf.sysname, "Linux") ||
version < 2 || (version == 2 && release < 6)) {
printf("%s %d.%d is not supported\n", uname_buf.sysname,
version,release);
version, release);
exit(1);
}
@@ -733,15 +629,16 @@ int main(int argc, char * argv[])
exit(1);
}
if (((readbuf = dinfo_malloc(readbuflen)) == NULL) ||
((uidfile = dinfo_malloc(readbuflen)) == NULL))
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
uidfile = dinfo_malloc(RD_BUFFER_SIZE);
if (!(readbuf && uidfile))
exit(1);
/* try to read the uid attribute */
if (busid) {
sprintf(uidfile,"/sys/bus/ccw/devices/%s/uid", busid);
sprintf(uidfile, "/sys/bus/ccw/devices/%s/uid", busid);
} else if (blockdev) {
sprintf(uidfile,"/sys/block/%s/device/uid", blockdev);
sprintf(uidfile, "/sys/block/%s/device/uid", blockdev);
} else if (devnode) {
if (dinfo_get_uid_from_devnode(&uidfile, devnode) != 0)
goto error;
@@ -753,7 +650,7 @@ int main(int argc, char * argv[])
}
if (print_uid) {
if (dinfo_read_dasd_uid(uidfile, readbuf, readbuflen) == 0) {
if (dinfo_read_dasd_uid(uidfile, readbuf) == 0) {
/* look for the 4th '.' and cut there */
srchuid = readbuf - 1;
for (i = 0; i < 4; ++i) {
@@ -761,25 +658,23 @@ int main(int argc, char * argv[])
if (!srchuid)
break;
}
if (srchuid) {
srchuid[0] = '\n';
srchuid[1] = 0;
}
if (export) {
printf("ID_UID=%s",readbuf);
} else
printf("%s",readbuf);
if (srchuid)
srchuid[0] = '\0';
if (export)
printf("ID_UID=%s\n", readbuf);
else
printf("%s\n", readbuf);
if (!print_vlabel && !print_extended_uid)
goto out;
}
}
if (print_extended_uid) {
if (dinfo_read_dasd_uid(uidfile, readbuf, readbuflen) == 0) {
if (export) {
printf("ID_XUID=%s",readbuf);
} else
printf("%s",readbuf);
if (dinfo_read_dasd_uid(uidfile, readbuf) == 0) {
if (export)
printf("ID_XUID=%s\n", readbuf);
else
printf("%s\n", readbuf);
if (!print_vlabel)
goto out;
}
@@ -808,15 +703,16 @@ int main(int argc, char * argv[])
goto error;
} else if (devnode) {
if ((device = dinfo_malloc(readbuflen)) == NULL)
device = dinfo_malloc(RD_BUFFER_SIZE);
if (!device)
exit(1);
strcpy(device, devnode);
}
if (dinfo_read_dasd_vlabel(device, &vlabel, readbuf) == 0) {
if (export) {
printf("ID_SERIAL=%s\n",readbuf);
} else
if (export)
printf("ID_SERIAL=%s\n", readbuf);
else
printf("%s\n", readbuf);
goto out;
}

File diff suppressed because it is too large Load Diff

View File

@@ -17,139 +17,6 @@
* SECTION: Definitions needed for DASD-API (see dasd.h)
*******************************************************************************/
#define DASD_IOCTL_LETTER 'D'
/*
* struct dasd_information_t
* represents any data about the device, which is visible to userspace.
* including foramt and features.
*/
typedef struct dasd_information_t {
unsigned int devno; /* S/390 devno */
unsigned int real_devno; /* for aliases */
unsigned int schid; /* S/390 subchannel identifier */
unsigned int cu_type : 16; /* from SenseID */
unsigned int cu_model : 8; /* from SenseID */
unsigned int dev_type : 16; /* from SenseID */
unsigned int dev_model : 8; /* from SenseID */
unsigned int open_count;
unsigned int req_queue_len;
unsigned int chanq_len; /* length of chanq */
char type[4]; /* from discipline.name, 'none' for unknown */
unsigned int status; /* current device level */
unsigned int label_block; /* where to find the VOLSER */
unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
unsigned int characteristics_size;
unsigned int confdata_size;
char characteristics[64]; /* from read_device_characteristics */
char configuration_data[256]; /* from read_configuration_data */
} dasd_information_t;
typedef struct dasd_information2_t {
unsigned int devno; /* S/390 devno */
unsigned int real_devno; /* for aliases */
unsigned int schid; /* S/390 subchannel identifier */
unsigned int cu_type : 16; /* from SenseID */
unsigned int cu_model : 8; /* from SenseID */
unsigned int dev_type : 16; /* from SenseID */
unsigned int dev_model : 8; /* from SenseID */
unsigned int open_count;
unsigned int req_queue_len;
unsigned int chanq_len; /* length of chanq */
char type[4]; /* from discipline.name, 'none' for unknown */
unsigned int status; /* current device level */
unsigned int label_block; /* where to find the VOLSER */
unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
unsigned int characteristics_size;
unsigned int confdata_size;
unsigned char characteristics[64];/*from read_device_characteristics */
unsigned char configuration_data[256];/*from read_configuration_data */
unsigned int format; /* format info like formatted/cdl/ldl/... */
unsigned int features; /* dasd features like 'ro',... */
unsigned int reserved0; /* reserved for further use ,... */
unsigned int reserved1; /* reserved for further use ,... */
unsigned int reserved2; /* reserved for further use ,... */
unsigned int reserved3; /* reserved for further use ,... */
unsigned int reserved4; /* reserved for further use ,... */
unsigned int reserved5; /* reserved for further use ,... */
unsigned int reserved6; /* reserved for further use ,... */
unsigned int reserved7; /* reserved for further use ,... */
} dasd_information2_t;
struct dasd_eckd_characteristics {
unsigned short cu_type;
struct {
unsigned char support:2;
unsigned char async:1;
unsigned char reserved:1;
unsigned char cache_info:1;
unsigned char model:3;
} __attribute__ ((packed)) cu_model;
unsigned short dev_type;
unsigned char dev_model;
struct {
unsigned char mult_burst:1;
unsigned char RT_in_LR:1;
unsigned char reserved1:1;
unsigned char RD_IN_LR:1;
unsigned char reserved2:4;
unsigned char reserved3:8;
unsigned char defect_wr:1;
unsigned char XRC_supported:1;
unsigned char reserved4:1;
unsigned char striping:1;
unsigned char reserved5:4;
unsigned char cfw:1;
unsigned char reserved6:2;
unsigned char cache:1;
unsigned char dual_copy:1;
unsigned char dfw:1;
unsigned char reset_alleg:1;
unsigned char sense_down:1;
} __attribute__ ((packed)) facilities;
unsigned char dev_class;
unsigned char unit_type;
unsigned short no_cyl;
unsigned short trk_per_cyl;
unsigned char sec_per_trk;
unsigned char byte_per_track[3];
unsigned short home_bytes;
unsigned char formula;
union {
struct {
unsigned char f1;
unsigned short f2;
unsigned short f3;
} __attribute__ ((packed)) f_0x01;
struct {
unsigned char f1;
unsigned char f2;
unsigned char f3;
unsigned char f4;
unsigned char f5;
} __attribute__ ((packed)) f_0x02;
} __attribute__ ((packed)) factors;
unsigned short first_alt_trk;
unsigned short no_alt_trk;
unsigned short first_dia_trk;
unsigned short no_dia_trk;
unsigned short first_sup_trk;
unsigned short no_sup_trk;
unsigned char MDR_ID;
unsigned char OBR_ID;
unsigned char director;
unsigned char rd_trk_set;
unsigned short max_rec_zero;
unsigned char reserved1;
unsigned char RWANY_in_LR;
unsigned char factor6;
unsigned char factor7;
unsigned char factor8;
unsigned char reserved2[3];
unsigned char reserved3[6];
unsigned int long_no_cyl;
} __attribute__ ((packed));
/*
* values to be used for dasd_information2_t.format
* 0x00: NOT formatted
@@ -170,21 +37,6 @@ struct dasd_eckd_characteristics {
#define DASD_FEATURE_READONLY 1
#define DASD_FEATURE_USEDIAG 2
/* Get information on a dasd device (enhanced) */
#define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
#define BIODASDINFO2 _IOR(DASD_IOCTL_LETTER,3,dasd_information2_t)
/********************************************************************************
* SECTION: Further IOCTL Definitions (see fs.h and hdreq.h)
*******************************************************************************/
/* get block device sector size */
#define BLKSSZGET _IO(0x12,104)
/* return device size in bytes (u64 *arg) */
#define BLKGETSIZE64 _IOR(0x12,114,size_t)
/* get device geometry */
#define HDIO_GETGEO 0x0301
/********************************************************************************
* SECTION: DASDVIEW internal types
*******************************************************************************/
@@ -215,7 +67,7 @@ typedef struct dasdview_info
char device[PATH_MAX];
dasd_information2_t dasd_info;
int dasd_info_version;
int blksize;
unsigned int blksize;
struct hd_geometry geo;
u_int32_t hw_cylinders;

16
etc/Makefile Normal file
View File

@@ -0,0 +1,16 @@
include ../common.mak
CONFIG_FILES =
ifneq (${SYSTEMDSYSTEMUNITDIR},)
CONFIG_FILES += cpuplugd.conf sysconfig/cpi sysconfig/dumpconf \
sysconfig/mon_fsstatd sysconfig/mon_procd
endif
install:
for file in $(CONFIG_FILES); do \
$(INSTALL) -g $(GROUP) -o $(OWNER) \
-m 644 $$file $(DESTDIR)$(SYSCONFDIR)/$$file ; \
done
.PHONY: all install clean

View File

@@ -4,6 +4,11 @@
# The system and sysplex names consist of up to eight characters of
# the following set: A-Z, 0-9, $, @, #, and blank.
#
# CPI system type
#
CPI_SYSTEM_TYPE="LINUX"
#
# CPI system name
#

View File

@@ -7,7 +7,7 @@ SUBSYSTEM!="block", GOTO="ra_end"
ACTION!="add", GOTO="ra_change"
# on device add set initial readahead to 512 (instead of in kernel 128)
KERNEL=="sd*[!0-9]", WAIT_FOR="queue/read_ahead_kb", ATTR{queue/read_ahead_kb}="512"
KERNEL=="sd*[!0-9]", TEST=="queue/read_ahead_kb", ATTR{queue/read_ahead_kb}="512"
LABEL="ra_change"

View File

@@ -0,0 +1,6 @@
#
# Rules to trigger cpictl when KVM is used
# This file should be installed in /etc/udev/rules.d
#
SUBSYSTEM=="misc", KERNEL=="kvm", ENV{CREATED}=="1", ENV{EVENT}=="create", RUN+="/lib/s390-tools/cpictl -b kvm"

View File

@@ -11,6 +11,7 @@
#include <stdio.h>
#include <sys/sysmacros.h>
#include "lib/dasd_base.h"
#include "lib/dasd_sys.h"
#include "lib/util_base.h"
#include "lib/util_opt.h"
@@ -220,8 +221,7 @@ static u_int32_t get_usable_cylinders(fdasd_anchor_t *anc)
return anc->f4->DS4DCYL;
/* normal volume */
if (anc->f4->DS4DEVCT.DS4DEVFG & ALTERNATE_CYLINDERS_USED)
cyl = anc->f4->DS4DEVCT.DS4DSCYL -
(u_int16_t) anc->f4->DS4DEVAC;
cyl = anc->f4->DS4DEVCT.DS4DSCYL - (u_int16_t)anc->f4->DS4DEVAC;
else
cyl = anc->f4->DS4DEVCT.DS4DSCYL;
@@ -230,9 +230,8 @@ static u_int32_t get_usable_cylinders(fdasd_anchor_t *anc)
static void get_addr_of_highest_f1_f8_label(fdasd_anchor_t *anc, cchhb_t *addr)
{
u_int8_t record;
/* We have to count the follwing labels:
/* We have to count the following labels:
* one format 4
* one format 5
* format 7 only if we have moren then BIG_DISK_SIZE tracks
@@ -308,7 +307,7 @@ static void fdasd_cleanup(fdasd_anchor_t *anchor)
/*
* Exit fdasd.
*/
static void fdasd_exit(fdasd_anchor_t *anchor, int rc)
static void __noreturn fdasd_exit(fdasd_anchor_t *anchor, int rc)
{
fdasd_cleanup(anchor);
exit(rc);
@@ -769,7 +768,7 @@ static int fdasd_parse_conffile(fdasd_anchor_t *anc,
} else {
errno = 0;
anc->confdata[i].start = strtol(token[0],
(char **) NULL, 10);
(char **)NULL, 10);
if (errno != 0 || anc->confdata[i].start == 0) {
snprintf(err_str, ERROR_STRING_SIZE,
"invalid partition start in config "
@@ -784,7 +783,7 @@ static int fdasd_parse_conffile(fdasd_anchor_t *anc,
} else {
errno = 0;
anc->confdata[i].stop = strtol(token[1],
(char **) NULL, 10);
(char **)NULL, 10);
if (errno != 0 || anc->confdata[i].stop == 0) {
snprintf(err_str, ERROR_STRING_SIZE,
"invalid partition end in config "
@@ -884,9 +883,9 @@ static void fdasd_check_conffile_input(fdasd_anchor_t *anc,
anc->fspace_trk = start - FIRST_USABLE_TRK;
if (i < USABLE_PARTITIONS - 1) {
if (anc->confdata[i+1].start != 0)
if (anc->confdata[i + 1].start != 0)
part_info->fspace_trk =
anc->confdata[i+1].start-stop-1;
anc->confdata[i + 1].start - stop - 1;
else
part_info->fspace_trk = last_trk - stop;
} else if (i == USABLE_PARTITIONS - 1) {
@@ -916,17 +915,17 @@ static void fdasd_verify_device(fdasd_anchor_t *anc, char *name)
if (!S_ISBLK(dst.st_mode)) {
snprintf(err_str, ERROR_STRING_SIZE,
"Device '%s' (%d/%d) is not a block device\n", name,
(unsigned short) major(dst.st_rdev),
(unsigned short) minor(dst.st_rdev));
(unsigned short)major(dst.st_rdev),
(unsigned short)minor(dst.st_rdev));
fdasd_error(anc, device_verification_failed, err_str);
}
if (minor(dst.st_rdev) & PARTN_MASK) {
if (!anc->force_virtual && minor(dst.st_rdev) & PARTN_MASK) {
snprintf(err_str, ERROR_STRING_SIZE,
"Partition '%s' (%d/%d) detected where device is "
"required\n", name,
(unsigned short) major(dst.st_rdev),
(unsigned short) minor(dst.st_rdev));
(unsigned short)major(dst.st_rdev),
(unsigned short)minor(dst.st_rdev));
fdasd_error(anc, device_verification_failed, err_str);
}
@@ -962,8 +961,8 @@ static void fdasd_verify_device(fdasd_anchor_t *anc, char *name)
if (anc->verbose) {
printf("Verification successful for '%s' (%d/%d)\n", name,
(unsigned short) major(dst.st_rdev),
(unsigned short) minor(dst.st_rdev));
(unsigned short)major(dst.st_rdev),
(unsigned short)minor(dst.st_rdev));
}
}
@@ -1028,15 +1027,13 @@ static void fdasd_verify_options(fdasd_anchor_t *anc)
}
}
if (anc->auto_partition &&
(options.conffile || anc->print_table)) {
if (anc->auto_partition && (options.conffile || anc->print_table)) {
fdasd_error(anc, parser_failed,
"Option 'auto' cannot be used with "
"'config' and 'table'.\n");
}
if (options.conffile &&
(anc->print_table)) {
if (options.conffile && anc->print_table) {
fdasd_error(anc, parser_failed,
"Option 'config' cannot be used with"
" 'table'.\n");
@@ -1232,26 +1229,13 @@ static int fdasd_get_volser(fdasd_anchor_t *anc, char *volser)
*/
static void fdasd_reread_partition_table(fdasd_anchor_t *anc)
{
char err_str[ERROR_STRING_SIZE];
int fd;
if (!anc->silent)
printf("rereading partition table...\n");
fd = open(options.device, O_RDONLY);
if (fd < 0) {
snprintf(err_str, ERROR_STRING_SIZE,
"Could not open device '%s' "
"in read-only mode!\n", options.device);
fdasd_error(anc, unable_to_open_disk, err_str);
}
if (ioctl(fd, BLKRRPART, NULL) != 0) {
close(fd);
if (dasd_reread_partition_table(options.device, 1) != 0) {
fdasd_error(anc, unable_to_ioctl, "Error while rereading "
"partition table.\nPlease reboot!");
}
close(fd);
}
/*
@@ -1335,7 +1319,7 @@ static void fdasd_write_vtoc_labels(fdasd_anchor_t *anc)
while (getpos(anc, k) > -1)
k++;
setpos(anc, k, i-1);
setpos(anc, k, i - 1);
strncpy(ch, "LINUX.V "
" ", 44);
@@ -1414,7 +1398,7 @@ static void fdasd_write_labels(fdasd_anchor_t *anc)
if (anc->vtoc_changed)
fdasd_write_vtoc_labels(anc);
if ((anc->vtoc_changed) || (anc->vlabel_changed))
if (anc->vtoc_changed || anc->vlabel_changed)
fdasd_reread_partition_table(anc);
}
@@ -1500,9 +1484,9 @@ static void fdasd_reuse_vtoc(fdasd_anchor_t *anc)
if (!anc->silent) {
snprintf(str, INPUT_BUF_SIZE,
"WARNING: this will re-create your VTOC "
"entries using the partition\n "
"information of your existing VTOC. Continue?");
"WARNING: this will re-create your VTOC "
"entries using the partition\n "
"information of your existing VTOC. Continue?");
if (yes_no(str) != 0)
return;
@@ -1637,9 +1621,11 @@ static void fdasd_change_part_type(fdasd_anchor_t *anc)
printf("\n");
part_type = 0;
while (part_type < 1 || part_type > UTIL_ARRAY_SIZE(partition_types) - 1) {
while (!isdigit(part_type =
read_char("new partition type: ")));
while (part_type < 1 ||
part_type > UTIL_ARRAY_SIZE(partition_types) - 1) {
do {
part_type = read_char("new partition type: ");
} while (!isdigit(part_type));
part_type -= 48;
}
@@ -2094,7 +2080,8 @@ static void fdasd_check_disk_access(fdasd_anchor_t *anc)
{
char err_str[ERROR_STRING_SIZE];
format1_label_t f1;
int fd, pos, ro;
int fd, pos;
bool ro;
fd = open(options.device, O_RDONLY);
if (fd == -1) {
@@ -2127,7 +2114,9 @@ static void fdasd_check_disk_access(fdasd_anchor_t *anc)
fdasd_error(anc, unable_to_seek_disk, err_str);
}
if (ioctl(fd, BLKROGET, &ro) != 0) {
close(fd);
if (dasd_is_ro(options.device, &ro) != 0) {
snprintf(err_str, ERROR_STRING_SIZE,
"Could not get read-only status for device '%s'.",
options.device);
@@ -2138,8 +2127,6 @@ static void fdasd_check_disk_access(fdasd_anchor_t *anc)
"You will not be able to save any changes.\n\n",
options.device);
}
close(fd);
}
/*
@@ -2171,16 +2158,18 @@ static unsigned int recs_per_track(unsigned short dev_type, unsigned int kl,
kn = ceil_quot(kl + 6, 232) + 1;
return 1729 / (10 + 9 + ceil_quot(kl + 6 * kn, 34) +
9 + ceil_quot(dl + 6 * dn, 34));
} else
} else {
return 1729 / (10 + 9 + ceil_quot(dl + 6 * dn, 34));
}
case DASD_9345_TYPE:
dn = ceil_quot(dl + 6, 232) + 1;
if (kl) {
kn = ceil_quot(kl + 6, 232) + 1;
return 1420 / (18 + 7 + ceil_quot(kl + 6 * kn, 34) +
ceil_quot(dl + 6 * dn, 34));
} else
} else {
return 1420 / (18 + 7 + ceil_quot(dl + 6 * dn, 34));
}
}
return 0;
}
@@ -2214,21 +2203,12 @@ static void fdasd_get_geometry(fdasd_anchor_t *anc)
struct dasd_eckd_characteristics *characteristics;
unsigned long long size_in_bytes;
char err_str[ERROR_STRING_SIZE];
dasd_information_t dasd_info;
int fd, blksize = 0;
dasd_information2_t dasd_info;
unsigned int blksize = 0;
fd = open(options.device, O_RDONLY);
if (fd < 0) {
snprintf(err_str, ERROR_STRING_SIZE,
"Could not open device '%s' "
"in read-only mode!\n", options.device);
fdasd_error(anc, unable_to_open_disk, err_str);
}
if (ioctl(fd, BLKGETSIZE64, &size_in_bytes) != 0) {
close(fd);
if (dasd_get_blocksize_in_bytes(options.device, &size_in_bytes) != 0)
fdasd_error(anc, unable_to_ioctl,
"Could not retrieve disk size.");
}
/*
* If anc->force_virtual is set, we do no real geometry detection.
* anc->dev_type and anc->blksize have already been set via command
@@ -2247,7 +2227,6 @@ static void fdasd_get_geometry(fdasd_anchor_t *anc)
geo.start = 0;
anc->label_pos = 2 * anc->blksize;
anc->devno = 0;
close(fd);
if (anc->verbose) {
printf("The force option is active. "
"The following geometry will be used:\n"
@@ -2259,24 +2238,21 @@ static void fdasd_get_geometry(fdasd_anchor_t *anc)
return;
}
if (ioctl(fd, HDIO_GETGEO, &geo) != 0) {
close(fd);
if (dasd_get_geo(options.device, &geo) != 0) {
fdasd_error(anc, unable_to_ioctl,
"Could not retrieve disk geometry information.");
}
if (ioctl(fd, BLKSSZGET, &blksize) != 0) {
close(fd);
if (dasd_get_blocksize(options.device, &blksize) != 0) {
fdasd_error(anc, unable_to_ioctl,
"Could not retrieve blocksize information.");
}
/* get disk type */
if (ioctl(fd, BIODASDINFO, &dasd_info) != 0) {
if (dasd_get_info(options.device, &dasd_info) != 0) {
if (anc->verbose)
printf("BIODASDINFO ioctl failed,"
" use disk geometry only.\n");
/* verify that the geometry matches a 3390 DASD */
if (!fdasd_verify_geometry(DASD_3390_TYPE, blksize, &geo)) {
close(fd);
fdasd_error(anc, wrong_disk_type,
"Disk geometry does not match a DASD device"
" of type 3390.");
@@ -2356,8 +2332,6 @@ static void fdasd_get_geometry(fdasd_anchor_t *anc)
anc->label_pos = dasd_info.label_block * blksize;
anc->devno = dasd_info.devno;
}
close(fd);
}
/*
@@ -2384,10 +2358,8 @@ fdasd_read_int(unsigned long low, unsigned long dflt, unsigned long high,
}
while (1) {
while (!isdigit(read_char(msg_txt))
&& (*line_ptr != '-' &&
*line_ptr != '+' &&
*line_ptr != '\0'))
while (!isdigit(read_char(msg_txt)) &&
(*line_ptr != '-' && *line_ptr != '+' && *line_ptr != '\0'))
continue;
if ((*line_ptr == '+' || *line_ptr == '-') && base != lower) {
if (*line_ptr == '+')
@@ -2411,13 +2383,13 @@ fdasd_read_int(unsigned long low, unsigned long dflt, unsigned long high,
break;
case 'm':
case 'M':
trk *= (1024*1024);
trk *= (1024 * 1024);
trk /= anc->blksize;
trk /= geo.sectors;
break;
case 'g':
case 'G':
trk *= (1024*1024*1024);
trk *= (1024 * 1024 * 1024);
trk /= anc->blksize;
trk /= geo.sectors;
break;
@@ -2546,7 +2518,6 @@ static int fdasd_get_partition_data(fdasd_anchor_t *anc, extent_t *part_extent,
limit = part_tmp->start_trk - 1;
break;
}
}
if (start == limit) {
@@ -2642,7 +2613,7 @@ static void fdasd_enqueue_new_partition(fdasd_anchor_t *anc)
FIRST_USABLE_TRK;
}
} else {
/* there are partitons in front of the new one */
/* there are partitions in front of the new one */
if (part_info->start_trk == part_info->prev->end_trk + 1) {
/* new partition is right behind the previous one */
part_info->fspace_trk = part_info->prev->fspace_trk -
@@ -2797,7 +2768,7 @@ static void fdasd_remove_partition(fdasd_anchor_t *anc)
/*
* writes a standard volume label and a standard VTOC with
* only one partition to disc. With this function is it
* possible to create one partiton in non-interactive mode,
* possible to create one partition in non-interactive mode,
* which can be used within shell scripts
*/
static void fdasd_auto_partition(fdasd_anchor_t *anc)
@@ -3067,7 +3038,6 @@ int main(int argc, char *argv[])
fdasd_recreate_vtoc(&anchor);
anchor.option_recreate = 0;
}
}
return -1;

View File

@@ -14,125 +14,8 @@
* SECTION: Definitions needed for DASD-API (see dasd.h) *
*****************************************************************************/
#define DASD_IOCTL_LETTER 'D'
#define DASD_PARTN_BITS 2
/*
* struct dasd_information_t
* represents any data about the device, which is visible to userspace.
* including foramt and featueres.
*/
typedef struct dasd_information_t {
unsigned int devno; /* S/390 devno */
unsigned int real_devno; /* for aliases */
unsigned int schid; /* S/390 subchannel identifier */
unsigned int cu_type : 16; /* from SenseID */
unsigned int cu_model : 8; /* from SenseID */
unsigned int dev_type : 16; /* from SenseID */
unsigned int dev_model : 8; /* from SenseID */
unsigned int open_count;
unsigned int req_queue_len;
unsigned int chanq_len; /* length of chanq */
char type[4]; /* from discipline.name, 'none' for */
/* unknown */
unsigned int status; /* current device level */
unsigned int label_block; /* where to find the VOLSER */
unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
unsigned int characteristics_size;
unsigned int confdata_size;
char characteristics[64]; /* from read_device_characteristics */
char configuration_data[256]; /* from read_configuration_data */
} dasd_information_t;
struct dasd_eckd_characteristics {
unsigned short cu_type;
struct {
unsigned char support:2;
unsigned char async:1;
unsigned char reserved:1;
unsigned char cache_info:1;
unsigned char model:3;
} __attribute__ ((packed)) cu_model;
unsigned short dev_type;
unsigned char dev_model;
struct {
unsigned char mult_burst:1;
unsigned char RT_in_LR:1;
unsigned char reserved1:1;
unsigned char RD_IN_LR:1;
unsigned char reserved2:4;
unsigned char reserved3:8;
unsigned char defect_wr:1;
unsigned char XRC_supported:1;
unsigned char reserved4:1;
unsigned char striping:1;
unsigned char reserved5:4;
unsigned char cfw:1;
unsigned char reserved6:2;
unsigned char cache:1;
unsigned char dual_copy:1;
unsigned char dfw:1;
unsigned char reset_alleg:1;
unsigned char sense_down:1;
} __attribute__ ((packed)) facilities;
unsigned char dev_class;
unsigned char unit_type;
unsigned short no_cyl;
unsigned short trk_per_cyl;
unsigned char sec_per_trk;
unsigned char byte_per_track[3];
unsigned short home_bytes;
unsigned char formula;
union {
struct {
unsigned char f1;
unsigned short f2;
unsigned short f3;
} __attribute__ ((packed)) f_0x01;
struct {
unsigned char f1;
unsigned char f2;
unsigned char f3;
unsigned char f4;
unsigned char f5;
} __attribute__ ((packed)) f_0x02;
} __attribute__ ((packed)) factors;
unsigned short first_alt_trk;
unsigned short no_alt_trk;
unsigned short first_dia_trk;
unsigned short no_dia_trk;
unsigned short first_sup_trk;
unsigned short no_sup_trk;
unsigned char MDR_ID;
unsigned char OBR_ID;
unsigned char director;
unsigned char rd_trk_set;
unsigned short max_rec_zero;
unsigned char reserved1;
unsigned char RWANY_in_LR;
unsigned char factor6;
unsigned char factor7;
unsigned char factor8;
unsigned char reserved2[3];
unsigned char reserved3[6];
unsigned int long_no_cyl;
} __attribute__ ((packed));
/* Get information on a dasd device (enhanced) */
#define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
/*****************************************************************************
* SECTION: Further IOCTL Definitions (see fs.h and hdreq.h) *
*****************************************************************************/
#define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
#define BLKRRPART _IO(0x12,95) /* re-read partition table */
#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* device size in bytes (u64 *arg)*/
/* get device geometry */
#define HDIO_GETGEO 0x0301
/*****************************************************************************
* SECTION: FDASD internal types *
*****************************************************************************/

View File

@@ -49,7 +49,7 @@ install: all install-scripts
install-scripts: lshmc
@for i in $^; do \
cat $$i | \
sed -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
sed -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
>$(DESTDIR)$(USRSBINDIR)/$$i; \
chown $(OWNER).$(GROUP) $(DESTDIR)$(USRSBINDIR)/$$i; \
chmod 755 $(DESTDIR)$(USRSBINDIR)/$$i; \

View File

@@ -821,10 +821,13 @@ static char *hmcdrv_parse_line(char *line, char *namebuf,
if ((*line != '\0') && (*line != '\n')) {
field = hmcdrv_parse_ntoken(field, line, &attr);
while ((*line != '\0') &&
(*line != '\n') &&
!isspace(*line))
while ((*line != '\0') && (*line != '\n')) {
if (isspace(*line))
break;
if (field == 1 && isdigit(*line))
break;
++line; /* search end of field */
}
}
} /* while */

View File

@@ -348,7 +348,7 @@ void hyptop_text_mode(void)
/*
* Exit hyptop
*/
void hyptop_exit(int rc)
void __noreturn hyptop_exit(int rc)
{
hyptop_text_mode();
exit(rc);

View File

@@ -216,7 +216,7 @@ extern void win_cpu_types_init(void);
* Misc functions
*/
extern void hyptop_update_term(void);
extern void hyptop_exit(int rc);
extern void __noreturn hyptop_exit(int rc);
extern void hyptop_text_mode(void);
#endif /* HYPTOP_H */

207
include/lib/dasd_base.h Normal file
View File

@@ -0,0 +1,207 @@
/*
* dasd_base - Library for DASD related functions
*
* DASD related helper functions for accessing device information
*
* Copyright IBM Corp. 2013, 2017
* Copyright Red Hat Inc. 2017
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#ifndef LIB_DASD_BASE_H
#define LIB_DASD_BASE_H
#ifdef __linux__
#include <linux/hdreg.h>
#endif
#include <stdbool.h>
#include <stdio.h>
#include <sys/ioctl.h>
typedef struct dasd_information2_t {
unsigned int devno; /* S/390 devno */
unsigned int real_devno; /* for aliases */
unsigned int schid; /* S/390 subchannel identifier */
unsigned int cu_type : 16; /* from SenseID */
unsigned int cu_model : 8; /* from SenseID */
unsigned int dev_type : 16; /* from SenseID */
unsigned int dev_model : 8; /* from SenseID */
unsigned int open_count;
unsigned int req_queue_len;
unsigned int chanq_len; /* length of chanq */
char type[4]; /* from discipline.name, 'none' for unknown */
unsigned int status; /* current device level */
unsigned int label_block; /* where to find the VOLSER */
unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
unsigned int characteristics_size;
unsigned int confdata_size;
unsigned char characteristics[64];/*from read_device_characteristics */
unsigned char configuration_data[256];/*from read_configuration_data */
unsigned int format; /* format info like formatted/cdl/ldl/... */
unsigned int features; /* dasd features like 'ro',... */
unsigned int reserved0; /* reserved for further use ,... */
unsigned int reserved1; /* reserved for further use ,... */
unsigned int reserved2; /* reserved for further use ,... */
unsigned int reserved3; /* reserved for further use ,... */
unsigned int reserved4; /* reserved for further use ,... */
unsigned int reserved5; /* reserved for further use ,... */
unsigned int reserved6; /* reserved for further use ,... */
unsigned int reserved7; /* reserved for further use ,... */
} dasd_information2_t;
struct dasd_eckd_characteristics {
unsigned short cu_type;
struct {
unsigned char support:2;
unsigned char async:1;
unsigned char reserved:1;
unsigned char cache_info:1;
unsigned char model:3;
} __attribute__ ((packed)) cu_model;
unsigned short dev_type;
unsigned char dev_model;
struct {
unsigned char mult_burst:1;
unsigned char RT_in_LR:1;
unsigned char reserved1:1;
unsigned char RD_IN_LR:1;
unsigned char reserved2:4;
unsigned char reserved3:8;
unsigned char defect_wr:1;
unsigned char XRC_supported:1;
unsigned char reserved4:1;
unsigned char striping:1;
unsigned char reserved5:4;
unsigned char cfw:1;
unsigned char reserved6:2;
unsigned char cache:1;
unsigned char dual_copy:1;
unsigned char dfw:1;
unsigned char reset_alleg:1;
unsigned char sense_down:1;
} __attribute__ ((packed)) facilities;
unsigned char dev_class;
unsigned char unit_type;
unsigned short no_cyl;
unsigned short trk_per_cyl;
unsigned char sec_per_trk;
unsigned char byte_per_track[3];
unsigned short home_bytes;
unsigned char formula;
union {
struct {
unsigned char f1;
unsigned short f2;
unsigned short f3;
} __attribute__ ((packed)) f_0x01;
struct {
unsigned char f1;
unsigned char f2;
unsigned char f3;
unsigned char f4;
unsigned char f5;
} __attribute__ ((packed)) f_0x02;
} __attribute__ ((packed)) factors;
unsigned short first_alt_trk;
unsigned short no_alt_trk;
unsigned short first_dia_trk;
unsigned short no_dia_trk;
unsigned short first_sup_trk;
unsigned short no_sup_trk;
unsigned char MDR_ID;
unsigned char OBR_ID;
unsigned char director;
unsigned char rd_trk_set;
unsigned short max_rec_zero;
unsigned char reserved1;
unsigned char RWANY_in_LR;
unsigned char factor6;
unsigned char factor7;
unsigned char factor8;
unsigned char reserved2[3];
unsigned char reserved3[6];
unsigned int long_no_cyl;
} __attribute__ ((packed));
/*
* struct format_data_t
* represents all data necessary to format a dasd
*/
typedef struct format_data_t {
unsigned int start_unit; /* from track */
unsigned int stop_unit; /* to track */
unsigned int blksize; /* sectorsize */
unsigned int intensity;
} format_data_t;
/*
* struct format_check_t
* represents all data necessary to evaluate the format of
* different tracks of a dasd
*/
typedef struct format_check_t {
/* Input */
struct format_data_t expect;
/* Output */
unsigned int result; /* Error indication (DASD_FMT_ERR_*) */
unsigned int unit; /* Track that is in error */
unsigned int rec; /* Record that is in error */
unsigned int num_records; /* Records in the track in error */
unsigned int blksize; /* Block-size of first record in error */
unsigned int key_length; /* Key length of first record in error */
} format_check_t;
#ifndef __linux__
/* definition from hdreg.h */
struct hd_geometry {
unsigned char heads;
unsigned char sectors;
unsigned short cylinders;
unsigned long start;
};
#endif
#define DASD_IOCTL_LETTER 'D'
/* Disable the volume (for Linux) */
#define BIODASDDISABLE _IO(DASD_IOCTL_LETTER, 0)
/* Enable the volume (for Linux) */
#define BIODASDENABLE _IO(DASD_IOCTL_LETTER, 1)
/* Get information on a dasd device (enhanced) */
#define BIODASDINFO2 _IOR(DASD_IOCTL_LETTER, 3, dasd_information2_t)
/* #define BIODASDFORMAT _IOW(IOCTL_LETTER,0,format_data_t) , deprecated */
#define BIODASDFMT _IOW(DASD_IOCTL_LETTER, 1, format_data_t)
/* Check device format according to format_data_t */
#define BIODASDCHECKFMT _IOWR(DASD_IOCTL_LETTER, 2, format_check_t)
/********************************************************************************
* SECTION: Further IOCTL Definitions (see fs.h and hdreq.h)
*******************************************************************************/
/* get read-only status (0 = read_write) */
#define BLKROGET _IO(0x12, 94)
/* re-read partition table */
#define BLKRRPART _IO(0x12, 95)
/* get block device sector size */
#define BLKSSZGET _IO(0x12, 104)
/* return device size in bytes (u64 *arg) */
#define BLKGETSIZE64 _IOR(0x12, 114, size_t)
#ifndef __linux__ /* from <linux/hdreg.h> */
#define HDIO_GETGEO 0x0301
#endif
int dasd_check_format(const char *device, format_check_t *p);
int dasd_format_disk(int fd, format_data_t *p);
int dasd_disk_disable(const char *device, int *fd);
int dasd_disk_enable(int fd);
int dasd_get_blocksize(const char *device, unsigned int *blksize);
int dasd_get_blocksize_in_bytes(const char *device, unsigned long long *blksize);
int dasd_get_geo(const char *device, struct hd_geometry *geo);
int dasd_get_info(const char *device, dasd_information2_t *info);
int dasd_is_ro(const char *device, bool *ro);
int dasd_reread_partition_table(const char *device, int ntries);
#endif /* LIB_DASD_BASE_H */

View File

@@ -14,6 +14,10 @@
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Allocate memory or panic in case of failure
*
@@ -125,4 +129,10 @@ int __util_vsprintf(const char *func, const char *file, int line,
char *util_strcat_realloc(char *str1, const char *str2);
void util_str_toupper(char *str);
char *util_strstrip(char *s);
#ifdef __cplusplus
}
#endif
#endif /** LIB_UTIL_LIBC_H @} */

View File

@@ -20,5 +20,6 @@ bool util_path_is_readable(const char *fmt, ...);
bool util_path_is_writable(const char *fmt, ...);
bool util_path_is_dir(const char *fmt, ...);
bool util_path_is_reg_file(const char *fmt, ...);
bool util_path_exists(const char *fmt, ...);
#endif /** LIB_UTIL_PATH_H @} */

View File

@@ -18,12 +18,6 @@
#include <stdlib.h>
#include <string.h>
/**
* Copyright IBM Corp. 2016, 2017
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
struct util_prg_copyright {
/** Name of the copyright owner, e.g. IBM */
const char *owner;

52
include/lib/vmcp.h Normal file
View File

@@ -0,0 +1,52 @@
/*
* vmcp - z/VM CP command library
*
* Copyright IBM Corp. 2005, 2018
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#ifndef LIB_VMCP_H
#define LIB_VMCP_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#define VMCP_DEVICE_NODE "/dev/vmcp" /* VMCP device name */
#define VMCP_DEFAULT_BUFSZ 0x4000 /* VMCP default buffer size */
/*
* Error codes returned by vmcp() function. This enables the caller
* to emit a detailed error message on the type of failure.
*/
#define VMCP_SUCCESS 0 /* VMCP operation completed successfully */
#define VMCP_ERR_OPEN (-1) /* Error Open of VMCP device */
#define VMCP_ERR_SETBUF (-2) /* Error VMCP_SETBUF ioctl */
#define VMCP_ERR_READ (-3) /* Error VMCP read system call */
#define VMCP_ERR_GETCODE (-4) /* Error VMCP_GETCODE ioctl */
#define VMCP_ERR_GETSIZE (-5) /* Error VMCP_GETSIZE ioctl */
#define VMCP_ERR_TOOSMALL (-6) /* Error VMCP buffer too small for
* response
*/
#define VMCP_ERR_WRITE (-7) /* Error VMCP write system call */
struct vmcp_parm {
const char *cpcmd;
unsigned int buffer_size;
bool do_upper;
int cprc;
char *response;
unsigned int response_size;
};
int vmcp(struct vmcp_parm *cp);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -19,6 +19,7 @@
#include <time.h>
#include <unistd.h>
#include "lib/dasd_base.h"
#define LINE_LENGTH 80
#define VTOC_START_CC 0x0
@@ -40,14 +41,6 @@
#define VTOC_ERROR "VTOC error:"
/* definition from hdreq.h */
struct hd_geometry {
unsigned char heads;
unsigned char sectors;
unsigned short cylinders;
unsigned long start;
};
typedef struct ttr
{
u_int16_t tt;

View File

@@ -25,6 +25,7 @@
#define RELEASE_STRING STRINGIFY (S390_TOOLS_RELEASE)
#define TOOLS_LIBDIR STRINGIFY (S390_TOOLS_LIBDIR)
#define TOOLS_SYSCONFDIR STRINGIFY (S390_TOOLS_SYSCONFDIR)
#define TOOLS_BINDIR STRINGIFY (S390_TOOLS_BINDIR)
#define __noreturn __attribute__((noreturn))
#define __packed __attribute__((packed))

View File

@@ -8,7 +8,7 @@ clean:
rm -f *.o core xcec-bridge
install: ip_watcher.pl xcec-bridge start_hsnc.sh
$(SED) -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
$(SED) -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
< start_hsnc.sh >$(DESTDIR)$(USRSBINDIR)/start_hsnc.sh; \
chown $(OWNER).$(GROUP) $(DESTDIR)$(USRSBINDIR)/start_hsnc.sh; \
chmod 755 $(DESTDIR)$(USRSBINDIR)/start_hsnc.sh; \

View File

@@ -97,7 +97,7 @@ static struct locals {
enum reipl_type reipl_type; /* CCW, FCP, NSS */
} l;
static void print_usage_chreipl_exit(void)
static void __noreturn print_usage_chreipl_exit(void)
{
printf(usage_chreipl, g.prog_name);
exit(0);
@@ -445,7 +445,7 @@ static void set_target_type_auto(const char *arg)
{
char busid[10];
if (access(arg, R_OK) == 0) {
if (access(arg, F_OK) == 0) {
set_target_type(TT_NODE, 1);
return;
}
@@ -539,12 +539,19 @@ static void parse_chreipl_options(int argc, char *argv[])
parse_pos_args(&argv[optind], argc - optind);
}
static void verify_write_access(const char *path, const char *attr)
static void check_exists(const char *path, const char *attr)
{
char fpath[PATH_MAX];
snprintf(fpath, sizeof(fpath), "/sys/firmware/%s", path);
if (access(fpath, W_OK) != 0)
if (access(fpath, F_OK) != 0)
ERR_EXIT("System does not allow to set %s", attr);
}
static void write_str_optional(char *string, char *file, int exit_on_fail,
const char *attr)
{
if (write_str_errno(string, file) && exit_on_fail)
ERR_EXIT("System does not allow to set %s", attr);
}
@@ -585,22 +592,18 @@ static void chreipl_ccw(void)
ERR_EXIT("Could not find DASD CCW device \"%s\"", l.busid);
}
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_CCW_MAX) {
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
strlen(l.bootparms), BOOTPARMS_CCW_MAX);
}
/*
* On old systems that use CCW reipl loadparm cannot be set
*/
if (l.loadparm_set)
verify_write_access("reipl/ccw/loadparm", "loadparm");
if (l.bootparms_set) {
verify_write_access("reipl/ccw/parm", "boot parameters");
if (strlen(l.bootparms) > BOOTPARMS_CCW_MAX)
ERR_EXIT("Maximum boot parameter length exceeded "
"(%zu/%u)", strlen(l.bootparms),
BOOTPARMS_CCW_MAX);
}
if (access("/sys/firmware/reipl/ccw/parm", W_OK) == 0)
write_str(l.bootparms, "reipl/ccw/parm");
if (access("/sys/firmware/reipl/ccw/loadparm", W_OK) == 0)
write_str(l.loadparm, "reipl/ccw/loadparm");
write_str_optional(l.loadparm, "reipl/ccw/loadparm", l.loadparm_set,
"loadparm");
write_str_optional(l.bootparms, "reipl/ccw/parm", l.bootparms_set,
"boot parameters");
write_str(l.busid, "reipl/ccw/device");
write_str("ccw", "reipl/reipl_type");
@@ -616,27 +619,21 @@ static void chreipl_fcp(void)
ERR_EXIT("Device is on cio_ignore list, try \"cio_ignore -r %s\"?", l.busid);
ERR_EXIT("Could not find FCP device \"%s\"", l.busid);
}
verify_write_access("reipl/fcp/device", "\"fcp\" re-IPL target");
check_exists("reipl/fcp/device", "\"fcp\" re-IPL target");
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_FCP_MAX) {
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
strlen(l.bootparms), BOOTPARMS_FCP_MAX);
}
/*
* On old systems the FCP reipl loadparm cannot be set
*/
if (l.loadparm_set)
verify_write_access("reipl/fcp/loadparm", "loadparm");
if (l.bootparms_set) {
verify_write_access("reipl/fcp/scp_data", "boot parameters");
if (strlen(l.bootparms) > BOOTPARMS_FCP_MAX)
ERR_EXIT("Maximum boot parameter length exceeded "
"(%zu/%u)", strlen(l.bootparms),
BOOTPARMS_FCP_MAX);
}
if (access("/sys/firmware/reipl/fcp/scp_data", W_OK) == 0)
write_str(l.bootparms, "reipl/fcp/scp_data");
if (access("/sys/firmware/reipl/fcp/loadparm", W_OK) == 0)
write_str(l.loadparm, "reipl/fcp/loadparm");
write_str_optional(l.loadparm, "reipl/fcp/loadparm", l.loadparm_set,
"loadparm");
write_str_optional(l.bootparms, "reipl/fcp/scp_data", l.bootparms_set,
"boot parameters");
write_str(l.busid, "reipl/fcp/device");
write_str(l.wwpn, "reipl/fcp/wwpn");
write_str(l.lun, "reipl/fcp/lun");
write_str("fcp", "reipl/reipl_type");
/*
* set the boot record logical block address. Master boot
* record. It is always 0 for Linux
@@ -645,6 +642,7 @@ static void chreipl_fcp(void)
if (!l.bootprog_set)
sprintf(l.bootprog, "0");
write_str(l.bootprog, "reipl/fcp/bootprog");
write_str("fcp", "reipl/reipl_type");
print_fcp(0, 0);
}
@@ -652,17 +650,14 @@ static void chreipl_fcp(void)
static void chreipl_nss(void)
{
check_nss_opts();
verify_write_access("reipl/nss/name", "\"nss\" re-IPL target");
if (l.bootparms_set) {
verify_write_access("reipl/nss/parm", "boot parameters");
if (strlen(l.bootparms) > BOOTPARMS_NSS_MAX)
ERR_EXIT("Maximum boot parameter length exceeded "
"(%zu/%u)", strlen(l.bootparms),
BOOTPARMS_NSS_MAX);
check_exists("reipl/nss/name", "\"nss\" re-IPL target");
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_NSS_MAX) {
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
strlen(l.bootparms), BOOTPARMS_NSS_MAX);
}
write_str_optional(l.bootparms, "reipl/nss/parm", l.bootparms_set,
"boot parameters");
write_str(l.nss_name, "reipl/nss/name");
if (access("/sys/firmware/reipl/nss/parm", W_OK) == 0)
write_str(l.bootparms, "reipl/nss/parm");
write_str("nss", "reipl/reipl_type");
print_nss(0);
}

View File

@@ -34,7 +34,7 @@ static const char *const usage_chshut =
" -h, --help Print this help, then exit\n"
" -v, --version Print version information, then exit\n";
static void print_usage_chshut_exit(void)
static void __noreturn print_usage_chshut_exit(void)
{
printf(usage_chshut, g.prog_name);
exit(0);

View File

@@ -25,7 +25,7 @@ static const char *const usage_lsreipl =
" -h, --help Print this help, then exit\n"
" -v, --version Print version information, then exit\n";
static void print_usage_lsreipl_exit(void)
static void __noreturn print_usage_lsreipl_exit(void)
{
printf(usage_lsreipl, g.prog_name);
exit(0);

View File

@@ -20,7 +20,7 @@ static const char *const usage_lsshut =
" -h, --help Print this help, then exit\n"
" -v, --version Print version information, then exit\n";
static void print_usage_lsshut_exit(void)
static __noreturn void print_usage_lsshut_exit(void)
{
printf(usage_lsshut, g.prog_name);
exit(0);

View File

@@ -24,6 +24,8 @@
#include <sys/types.h>
#include <unistd.h>
#include "lib/zt_common.h"
#define IPL_TYPE_LEN_MAX 100
#define NSS_NAME_LEN_MAX 8
@@ -57,8 +59,8 @@ extern void read_str(char *string, const char *file, size_t len);
extern void read_fw_str(char *string, const char *file, size_t len);
extern void print_fw_str(const char *fmt, const char *dir, const char *file);
extern void print_version_exit(void);
extern void print_help_hint_exit(void);
extern void __noreturn print_version_exit(void);
extern void __noreturn print_help_hint_exit(void);
/*
* FCP

View File

@@ -14,14 +14,14 @@
struct globals g;
void print_help_hint_exit(void)
void __noreturn print_help_hint_exit(void)
{
fprintf(stderr, "Try '%s' --help' for more information.\n",
g.prog_name);
exit(1);
}
void print_version_exit(void)
void __noreturn print_version_exit(void)
{
printf("%s: Linux on System z shutdown actions version %s\n",
g.prog_name, RELEASE_STRING);

View File

@@ -129,7 +129,7 @@ int write_str_errno(char *string, char *file)
snprintf(path, sizeof(path), "/sys/firmware/%s", file);
fh = open(path, O_WRONLY);
if (fh < 0)
ERR_EXIT_ERRNO("Could not open \"%s\"", file);
return errno;
if (write(fh, value, strlen(value)) < 0)
return errno;
close(fh);

View File

@@ -15,7 +15,7 @@ SYSTOOLS = ttyrun
all: $(PROGRAMS) $(SYSTOOLS)
check:
install:
install: all
for prg in $(PROGRAMS); do \
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 $$prg $(DESTDIR)$(USRBINDIR) ; \
done

View File

@@ -8,6 +8,7 @@
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#include <ctype.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
@@ -71,8 +72,8 @@ static const struct tool_info iucv_tool[2] = {
};
static void usage_exit(const struct tool_info *prg, int is_error,
const char *msg)
static void __noreturn usage_exit(const struct tool_info *prg, int is_error,
const char *msg)
{
if (msg != NULL)
fprintf(stderr, _("%s: %s\n"), prg->name, msg);
@@ -80,7 +81,7 @@ static void usage_exit(const struct tool_info *prg, int is_error,
exit(is_error ? 1 : 0); /* rc=1 .. invalid args */
}
static void version_exit(const struct tool_info *prg)
static void __noreturn version_exit(const struct tool_info *prg)
{
printf(_("%s: IUCV Terminal Applications, version %s\n"),
prg->name, RELEASE_STRING);

View File

@@ -62,13 +62,13 @@ static const char usage[] =
"-h, --help Displays this help, then exits.\n"
"-v, --version Displays version information, then exits.\n";
static void help_exit(const char *prg)
static void __noreturn help_exit(const char *prg)
{
printf(usage, prg, prg);
exit(EXIT_SUCCESS);
}
static void version_exit(const char *prg)
static void __noreturn version_exit(const char *prg)
{
printf("%s: Start a program if a terminal device is available, "
"version %s\n", prg, RELEASE_STRING);

View File

@@ -4,7 +4,7 @@ lib = libdasd.a
all: $(lib)
objects = dasd_sys.o
objects = dasd_sys.o dasd_ioctl.o
$(lib): $(objects) Makefile

263
libdasd/dasd_ioctl.c Normal file
View File

@@ -0,0 +1,263 @@
/*
* dasd_ioctl - Library for dasd-related ioctls
*
* DASD related helper functions for accessing device information via ioctls
*
* Copyright IBM Corp. 2013, 2017
* Copyright Red Hat Inc. 2017
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "lib/dasd_base.h"
#define COULD_NOT_OPEN_WARN(device) \
warn("Could not open device '%s'", device)
#define COULD_NOT_CLOSE_WARN \
warn("Unable to close device")
#define RUN_IOCTL(fd, req, argp) \
do { \
if (ioctl(fd, req, argp) != 0) { \
int err = errno; \
if (err != EBADF) \
dasd_close_device(fd); \
return err; \
} \
} while (0)
static int dasd_open_device(const char *device, int flags)
{
int fd;
fd = open(device, flags);
if (fd == -1)
COULD_NOT_OPEN_WARN(device);
return fd;
}
static void dasd_close_device(int fd)
{
if (close(fd) != 0)
COULD_NOT_CLOSE_WARN;
}
/*
* Get DASD block size information for device
*
* @param[in] device node device node's name
* @param[out] blksize the block size
*
* @retval 0 in case of success
* @retval errno in case of failure
*
*/
int dasd_get_blocksize(const char *device, unsigned int *blksize)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BLKSSZGET, blksize);
dasd_close_device(fd);
return 0;
}
/*
* Get DASD block size information (in bytes) for device
*
* @param[in] device node device node's name
* @param[out] blksize block size in bytes
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_get_blocksize_in_bytes(const char *device, unsigned long long *blksize)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BLKGETSIZE64, blksize);
dasd_close_device(fd);
return 0;
}
/*
* Get DASD disk information for device
*
* @param[in] device node device node's name
* @param[out] info pointer to dasd information
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_get_info(const char *device, dasd_information2_t *info)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BIODASDINFO2, info);
dasd_close_device(fd);
return 0;
}
/*
* Get DASD disk geometry information for device
*
* @param[in] device node device node's name
* @param[out] geo pointer to device geometry information
*
* @retval errno in case of failure
* @retval 0 in case of success
*/
int dasd_get_geo(const char *device, struct hd_geometry *geo)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, HDIO_GETGEO, geo);
dasd_close_device(fd);
return 0;
}
/*
* Get DASD read/write status information for device
*
* @param[in] device node device node's name
* @param[out] ro read-only status (1 for ro, 0 for rw)
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_is_ro(const char *device, bool *ro)
{
int fd, val;
fd = dasd_open_device(device, O_RDWR);
RUN_IOCTL(fd, BLKROGET, &val);
*ro = (val != 0) ? true : false;
return 0;
}
/*
* Disable DASD disk.
*
* @param[in] device node device node's name
*
* @retval 0 in case of success
* @retval errno in case of failure
*
* Note: Before BIODASDFMT can be called, a DASD has to be disabled (or rather
* put into a BASIC state) via BIODASDDISABLE. However, if you disable the DASD,
* close the file descriptor, and then try to reopen it, it won't work as the
* device isn't fully usable anymore. For BIODASDFMT to work, the file
* descriptor opened for BIODASDISABLE has to be kept open until BIODASDFMT has
* finished.
*/
int dasd_disk_disable(const char *device, int *fd)
{
*fd = dasd_open_device(device, O_RDWR);
RUN_IOCTL(*fd, BIODASDDISABLE, NULL);
return 0;
}
/*
* Enable DASD disk
*
* @param[in] device node device node's name
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_disk_enable(int fd)
{
RUN_IOCTL(fd, BIODASDENABLE, NULL);
dasd_close_device(fd);
return 0;
}
/*
* Format DASD disk
*
* @param[in] fd device node's file descriptor
* @param[in] p format options
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_format_disk(int fd, format_data_t *p)
{
RUN_IOCTL(fd, BIODASDFMT, p);
return 0;
}
/*
* Check DASD format
*
* @param[in] device node device node's name
* @param[in] p format params
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_check_format(const char *device, format_check_t *p)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BIODASDCHECKFMT, p);
dasd_close_device(fd);
return 0;
}
/*
* Reread partition table
*
* @param[in] device node device node's name
* @param[in] ntries maximum number of tries
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_reread_partition_table(const char *device, int ntries)
{
int i, fd, err = 0;
fd = dasd_open_device(device, O_RDONLY);
/*
* If the BLKRRPART ioctl fails, it is most likely due to the device
* just being in use by udev. So it is worthwhile to retry the ioctl
* after a second as it is likely to succeed.
*/
for (i = 0; i < ntries; i++) {
if (ioctl(fd, BLKRRPART, NULL) != 0) {
err = errno;
sleep(1);
} else {
err = 0;
break;
}
}
dasd_close_device(fd);
return err;
}

View File

@@ -28,17 +28,17 @@ objects = util_base.o \
util_proc.o \
util_rec.o
util_base_example: util_base_example.o $(rootdir)/libutil/libutil.a
util_panic_example: util_panic_example.o $(rootdir)/libutil/libutil.a
util_path_example: util_path_example.o $(rootdir)/libutil/libutil.a
util_scandir_example: util_scandir_example.o $(rootdir)/libutil/libutil.a
util_file_example: util_file_example.o $(rootdir)/libutil/libutil.a
util_libc_example: util_libc_example.o $(rootdir)/libutil/libutil.a
util_opt_example: util_opt_example.o $(rootdir)/libutil/libutil.a
util_opt_command_example: util_opt_command_example.o $(rootdir)/libutil/libutil.a
util_panic_example: util_panic_example.o $(rootdir)/libutil/libutil.a
util_prg_example: util_prg_example.o $(rootdir)/libutil/libutil.a
util_rec_example: util_rec_example.o $(rootdir)/libutil/libutil.a
util_base_example: util_base_example.o $(lib)
util_panic_example: util_panic_example.o $(lib)
util_path_example: util_path_example.o $(lib)
util_scandir_example: util_scandir_example.o $(lib)
util_file_example: util_file_example.o $(lib)
util_libc_example: util_libc_example.o $(lib)
util_opt_example: util_opt_example.o $(lib)
util_opt_command_example: util_opt_command_example.o $(lib)
util_panic_example: util_panic_example.o $(lib)
util_prg_example: util_prg_example.o $(lib)
util_rec_example: util_rec_example.o $(lib)
$(lib): $(objects)

View File

@@ -198,3 +198,33 @@ int __util_vsprintf(const char *func, const char *file, int line,
rc != -1, "Could not format string\n");
return rc;
}
/**
* Strip leading and trailing spaces from string
*
* Remove string \a s leading and trailing spaces
*
* @param[in,out] s String to manipulate
*
* @returns Pointer to first non-space character in string \a s
*/
char *util_strstrip(char *s)
{
size_t size;
char *end;
size = strlen(s);
if (!size)
return s;
end = s + size - 1;
while (end >= s && isspace(*end))
end--;
*(end + 1) = '\0';
while (*s && isspace(*s))
s++;
return s;
}

View File

@@ -10,10 +10,13 @@
//! [code]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lib/util_libc.h"
#include "lib/util_panic.h"
#define EXAMPLE_WORD " /sys/devices/system/cpu "
/*
* Demonstrate that out of memory is automatically handled via panic()
*/
@@ -22,6 +25,12 @@ int main(void)
unsigned long ulong_max = (unsigned long)-1;
void *ptr;
char *zeroes, *str;
char buffer[sizeof(EXAMPLE_WORD)];
strcat(buffer, EXAMPLE_WORD);
fprintf(stderr, "Try to remove leading and trailing spaces from "
"\"%s\"\nresult = \"%s\"\n", EXAMPLE_WORD,
util_strstrip(buffer));
/* Use util_strcat_realloc() for string concatenation */
fprintf(stderr, "Try to concatenate \"Hello\", \", \" and \"world!\": ");

View File

@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_libc.h"
#include "lib/util_list.h"
/*
@@ -45,10 +46,8 @@ void util_list_init_offset(struct util_list *list, unsigned long offset)
*/
struct util_list *util_list_new_offset(unsigned long offset)
{
struct util_list *list = malloc(sizeof(*list));
struct util_list *list = util_malloc(sizeof(*list));
if (!list)
return NULL;
util_list_init_offset(list, offset);
return list;
}

View File

@@ -194,3 +194,26 @@ free_str:
free(path);
return rc;
}
/**
* Test if path to directory or file exists
*
* This function has the same semantics as "-e path" in bash.
*
* @param[in] fmt Format string for path to test
* @param[in] ... Variable arguments for format string
*
* @returns true Path exists
* false Otherwise
*/
bool util_path_exists(const char *fmt, ...)
{
va_list ap;
char *path;
bool rc;
UTIL_VASPRINTF(&path, fmt, ap);
rc = access(path, F_OK) == 0 ? true : false;
free(path);
return rc;
}

View File

@@ -55,18 +55,22 @@ static void test_util_path_sysfs(void)
static void test_path(const char *path)
{
printf("%-20s: ", path);
if (util_path_exists(path))
printf("exists=yes ");
else
printf("exists=no ");
if (util_path_is_readable(path))
printf("read=yes, ");
printf("read=yes ");
else
printf("read=no , ");
printf("read=no ");
if (util_path_is_writable(path))
printf("write=yes, ");
printf("write=yes ");
else
printf("write=no , ");
printf("write=no ");
if (util_path_is_reg_file(path))
printf("reg_file=yes");
printf("reg_file=yes ");
else
printf("reg_file=no ");
printf("reg_file=no ");
if (util_path_is_dir(path))
printf("dir=yes");
else

18
libvmcp/Makefile Normal file
View File

@@ -0,0 +1,18 @@
include ../common.mak
lib = libvmcp.a
examples = vmcp_example
all: $(lib) $(examples)
objects = vmcp.o
$(lib): $(objects)
install: all
vmcp_example: vmcp_example.o $(lib) $(rootdir)/libutil/libutil.a
clean:
rm -f *.o $(lib) $(examples)

134
libvmcp/vmcp.c Normal file
View File

@@ -0,0 +1,134 @@
/*
* vmcp - z/VM CP function library
*
* Copyright IBM Corp. 2018
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include "lib/util_libc.h"
#include "lib/vmcp.h"
#define VMCP_DEVICE_NODE "/dev/vmcp"
#define VMCP_GETSIZE _IOR(0x10, 3, int)
#define VMCP_SETBUF _IOW(0x10, 2, int)
#define VMCP_GETCODE _IOR(0x10, 1, int)
/*
* Read at most COUNT bytes from FD into memory at location BUF.
* Return number of bytes read on success, -1 on error.
*/
static ssize_t read_buffer(int fd, char *buf, ssize_t count)
{
ssize_t ret, done;
for (done = 0; done < (ssize_t)count; done += ret) {
ret = read(fd, &buf[done], count - done);
if (ret == -1 && errno == EINTR)
continue;
if (ret == -1)
return -1;
if (ret == 0)
break;
}
return done;
}
/**
* Submit a command to z/VM CP and return the response, the size in bytes
* of the response and CP command response code.
*
* The member response contains the response from CP. It is a pointer
* to a malloc'ed buffer which must be freed by the caller when the return
* code is zero or VMCP_ERR_TOOSMALL.
*
* @param[in,out] cmd Pointer to struct vmcp_parm.
* @param[in] cpcmd Pointer to CP command string.
* @param[in] do_upper If true convert cpcmd string to upper case.
* @param[out] cprc Return code of the CP command.
* @param[out] response Return buffer, has been allocated via malloc()
* must be freed by caller, see below.
* @param[out] response_size Size of the response in bytes, can be larger
* than buffer_size.
*
* @returns Zero on success or a negative error number on failure.
* @retval VMCP_SUCCESS Success valid members: cprc, response,
* response_size
* @retval VMCP_ERR_OPEN Error opening VMCP device, valid members: none
* @retval VMCP_ERR_SETBUF Error setting buffer, valid members: none
* @retval VMCP_ERR_GETCODE Error getting cp exit code, valid members: none
* @retval VMCP_ERR_WRITE Error write CP command, valid members: none
* @retval VMCP_ERR_GETSIZE Error reading response size,
* valid members: cprc
* @retval VMCP_ERR_READ Error reading resp
* @retval VMCP_ERR_TOOSMALL Error response buffer too small, response
* truncated, valid members: cprc, response,
* response_size
*/
int vmcp(struct vmcp_parm *cmd)
{
int rc = VMCP_SUCCESS, fd, len;
char *cpcmd;
cmd->response = NULL;
cmd->response_size = 0;
cmd->cprc = 0;
fd = open(VMCP_DEVICE_NODE, O_RDWR);
if (fd == -1)
return VMCP_ERR_OPEN;
cpcmd = util_strdup(cmd->cpcmd); /* Exits on failure */
if (cmd->do_upper)
util_str_toupper(cpcmd);
if (ioctl(fd, VMCP_SETBUF, &cmd->buffer_size) == -1) {
rc = VMCP_ERR_SETBUF;
goto fail;
}
if (write(fd, cpcmd, strlen(cpcmd)) == -1) {
rc = VMCP_ERR_WRITE;
goto fail;
}
if (ioctl(fd, VMCP_GETCODE, &cmd->cprc) == -1) {
rc = VMCP_ERR_GETCODE;
goto fail;
}
if (ioctl(fd, VMCP_GETSIZE, &cmd->response_size) == -1) {
rc = VMCP_ERR_GETSIZE;
goto fail;
}
if (cmd->response_size <= cmd->buffer_size) {
len = cmd->response_size;
} else {
len = cmd->buffer_size;
rc = VMCP_ERR_TOOSMALL;
}
/* Exits on failure */
cmd->response = (char *)util_zalloc(len + 1);
if (read_buffer(fd, cmd->response, len) == -1) {
rc = VMCP_ERR_READ;
free(cmd->response);
cmd->response = NULL;
}
fail:
close(fd);
free(cpcmd);
return rc;
}

65
libvmcp/vmcp_example.c Normal file
View File

@@ -0,0 +1,65 @@
/**
* vmcp_example - Example program for vmcp.c
*
* Copyright 2018 IBM Corp.
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
//! [code]
#include <stdio.h>
#include <stdlib.h>
#include <err.h>
#include "lib/vmcp.h"
/*
* Demonstrate vmcp() function usage
*/
int main(void)
{
struct vmcp_parm cp;
int rc;
cp.cpcmd = "q osa";
cp.buffer_size = VMCP_DEFAULT_BUFSZ;
cp.do_upper = true;
rc = vmcp(&cp);
switch (rc) {
case VMCP_SUCCESS:
printf("%s\n", cp.response);
free(cp.response);
break;
case VMCP_ERR_OPEN:
errx(EXIT_FAILURE, "Could not open device %s", VMCP_DEVICE_NODE);
break;
case VMCP_ERR_SETBUF:
errx(EXIT_FAILURE, "Could not set buffer size");
break;
case VMCP_ERR_GETCODE:
errx(EXIT_FAILURE, "Could not query return code");
break;
case VMCP_ERR_GETSIZE:
errx(EXIT_FAILURE, "Could not query response size");
break;
case VMCP_ERR_WRITE:
errx(EXIT_FAILURE, "Could not issue CP command");
break;
case VMCP_ERR_READ:
errx(EXIT_FAILURE, "Could not read CP response");
break;
case VMCP_ERR_TOOSMALL:
free(cp.response);
printf("Response truncated (requires %u bytes)\n",
cp.response_size);
errx(EXIT_FAILURE, "Response buffer (%u bytes) too small",
cp.buffer_size);
break;
}
return EXIT_SUCCESS;
}
//! [code]

View File

@@ -13,16 +13,13 @@
*/
#include <errno.h>
#include <fcntl.h>
#include <linux/types.h>
#include <malloc.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
#include "lib/dasd_base.h"
#include "lib/libzds.h"
#include "lib/u2s.h"
#include "lib/util_base.h"
@@ -31,13 +28,6 @@
/** @cond PRIVATE */
/******************************************************************************/
/* ioctl related definitions */
/******************************************************************************/
/* device size in bytes (u64 *arg) */
#define BLKGETSIZE64 _IOR(0x12, 114, size_t)
/******************************************************************************/
/* libzds structure definitions */
@@ -415,17 +405,7 @@ int lzds_zdsroot_alloc(struct zdsroot **root)
memset(tmproot, 0, sizeof(*tmproot));
tmproot->dasdlist = util_list_new(struct dasd, list);
if (!tmproot->dasdlist) {
free(tmproot);
return ENOMEM;
}
tmproot->datasetlist = util_list_new(struct dataset, list);
if (!tmproot->dasdlist) {
util_list_free(tmproot->dasdlist);
free(tmproot);
return ENOMEM;
}
*root = tmproot;
@@ -480,18 +460,11 @@ void lzds_zdsroot_free(struct zdsroot *root)
*/
static int dasd_read_geometry(struct dasd *dasd)
{
int fd;
unsigned long long size_in_bytes;
errorlog_clear(dasd->log);
fd = open(dasd->device, O_RDONLY);
if (fd < 0)
return errorlog_add_message(
&dasd->log, NULL, EIO,
"read geometry: could not open device %s\n",
dasd->device);
if (ioctl(fd, BLKGETSIZE64, &size_in_bytes) != 0)
if (dasd_get_blocksize_in_bytes(dasd->device, &size_in_bytes) != 0)
return errorlog_add_message(
&dasd->log, NULL, EIO,
"read geometry: could not get size from device %s\n",
@@ -505,7 +478,6 @@ static int dasd_read_geometry(struct dasd *dasd)
dasd->label_block = 2;
dasd->heads = 15;
dasd->cylinders = (size_in_bytes / (dasd->heads * RAWTRACKSIZE));
close(fd);
return 0;
}
@@ -822,10 +794,6 @@ static int errorlog_alloc(struct errorlog **log)
return ENOMEM;
memset(tmplog, 0, sizeof(*tmplog));
tmplog->entries = util_list_new(struct errormsg, list);
if (!tmplog->entries) {
free(tmplog);
return ENOMEM;
}
*log = tmplog;
return 0;
}
@@ -2203,8 +2171,6 @@ static int dataset_member_analysis(struct dataset *ds)
dataset_free_memberlist(ds);
ds->memberlist = util_list_new(struct pdsmember, list);
if (!ds->memberlist)
return ENOMEM;
/* track buffer must be page aligned for O_DIRECT */
trackdata = memalign(4096, RAWTRACKSIZE);

View File

@@ -90,17 +90,18 @@ static void fsstatd_open_monwriter(void)
/*
* Store daemon's pid so it can be stopped
*/
static void store_pid(void)
static int store_pid(void)
{
FILE *f = fopen(pid_file, "w");
if (!f) {
syslog(LOG_ERR, "cannot open pid file %s: %s", pid_file,
strerror(errno));
exit(1);
return -1;
}
fprintf(f, "%d\n", getpid());
fclose(f);
return 0;
}
/*
@@ -244,41 +245,64 @@ static void fsstatd_write_ent(struct mntent *ent, time_t curr_time,
*/
static void fsstatd_daemonize(void)
{
int pipe_fds[2], startup_rc = 1;
pid_t pid;
if (pipe(pipe_fds) == -1) {
syslog(LOG_ERR, "pipe error: %s\n", strerror(errno));
exit(1);
}
/* Fork off the parent process */
pid = fork();
if (pid < 0) {
syslog(LOG_ERR, "fork error: %s\n", strerror(errno));
exit(1);
}
if (pid > 0)
exit(0);
if (pid > 0) {
/* Wait for startup return code from daemon */
if (read(pipe_fds[0], &startup_rc, sizeof(startup_rc)) == -1)
syslog(LOG_ERR, "pipe read error: %s\n", strerror(errno));
/* With startup_rc == 0, pid file was written at this point */
exit(startup_rc);
}
/* Change the file mode mask */
umask(0);
/* Store daemon pid */
store_pid();
/* Catch SIGINT and SIGTERM to clean up pid file on exit */
fsstatd_handle_signals();
/* Create a new SID for the child process */
if (setsid() < 0) {
syslog(LOG_ERR, "setsid error: %s\n", strerror(errno));
exit(1);
goto notify_parent;
}
/* Change the current working directory */
if (chdir("/") < 0) {
syslog(LOG_ERR, "chdir error: %s\n", strerror(errno));
exit(1);
goto notify_parent;
}
/* Close out the standard file descriptors */
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
/* Store daemon pid */
if (store_pid() < 0)
goto notify_parent;
startup_rc = 0;
notify_parent:
/* Inform waiting parent about startup return code */
if (write(pipe_fds[1], &startup_rc, sizeof(startup_rc)) == -1) {
syslog(LOG_ERR, "pipe write error: %s\n", strerror(errno));
exit(1);
}
if (startup_rc != 0)
exit(startup_rc);
}
static int fsstatd_do_work(void)

View File

@@ -109,17 +109,18 @@ static void procd_open_monwriter(void)
/*
* Store daemon's pid so it can be stopped
*/
static void store_pid(void)
static int store_pid(void)
{
FILE *f = fopen(pid_file, "w");
if (!f) {
syslog(LOG_ERR, "cannot open pid file %s: %s", pid_file,
strerror(errno));
exit(1);
return -1;
}
fprintf(f, "%d\n", getpid());
fclose(f);
return 0;
}
/*
@@ -897,41 +898,64 @@ static void read_tasks(void)
*/
static void procd_daemonize(void)
{
int pipe_fds[2], startup_rc = 1;
pid_t pid;
if (pipe(pipe_fds) == -1) {
syslog(LOG_ERR, "pipe error: %s\n", strerror(errno));
exit(1);
}
/* Fork off the parent process */
pid = fork();
if (pid < 0) {
syslog(LOG_ERR, "fork error: %s\n", strerror(errno));
exit(1);
}
if (pid > 0)
exit(0);
if (pid > 0) {
/* Wait for startup return code from daemon */
if (read(pipe_fds[0], &startup_rc, sizeof(startup_rc)) == -1)
syslog(LOG_ERR, "pipe read error: %s\n", strerror(errno));
/* With startup_rc == 0, pid file was written at this point */
exit(startup_rc);
}
/* Change the file mode mask */
umask(0);
/* Store daemon pid */
store_pid();
/* Catch SIGINT and SIGTERM to clean up pid file on exit */
procd_handle_signals();
/* Create a new SID for the child process */
if (setsid() < 0) {
syslog(LOG_ERR, "setsid error: %s\n", strerror(errno));
exit(1);
goto notify_parent;
}
/* Change the current working directory */
if (chdir("/") < 0) {
syslog(LOG_ERR, "chdir error: %s\n", strerror(errno));
exit(1);
goto notify_parent;
}
/* Close out the standard file descriptors */
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
/* Store daemon pid */
if (store_pid() < 0)
goto notify_parent;
startup_rc = 0;
notify_parent:
/* Inform waiting parent about startup return code */
if (write(pipe_fds[1], &startup_rc, sizeof(startup_rc)) == -1) {
syslog(LOG_ERR, "pipe write error: %s\n", strerror(errno));
exit(1);
}
if (startup_rc != 0)
exit(startup_rc);
}
static int procd_do_work(void)

21
netboot/Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
#
# Sample Dockerfile to build PXE-style boot image for KVM on s390
#
FROM s390x/ubuntu:16.04
RUN apt-get update && apt-get install -y \
linux-image-4.4.0-78-generic \
make \
wget \
bzip2 \
linux-headers-4.4.0-78-generic \
gcc \
kexec-tools \
file
RUN mkdir /netboot
COPY . /netboot
RUN cd /netboot && make -f Makefile.pxelinux.0 KERNEL_VERSION=4.4.0-78-generic

16
netboot/Makefile Normal file
View File

@@ -0,0 +1,16 @@
# Install the netboot image build scripts as samples
include ../common.mak
NETBOOT_SAMPLEDIR=$(TOOLS_DATADIR)/netboot
all:
install: all
$(INSTALL) -d -m 755 $(DESTDIR)$(NETBOOT_SAMPLEDIR)
$(INSTALL) -m 755 mk-s390image mk-pxelinux-ramfs \
$(DESTDIR)$(NETBOOT_SAMPLEDIR)
$(INSTALL) -m 644 Dockerfile Makefile.pxelinux.0 README.md \
$(DESTDIR)$(NETBOOT_SAMPLEDIR)
.PHONY: all install clean

View File

@@ -0,0 +1,46 @@
# Sample Makefile to produce a pxe-style netboot image
# matching the currently active kernel.
# If the image is to be build for a different kernel version
# the KERNEL_VERSION variable must be overridden
# To use a local busybox installation, change BBINSTALL
# to point to the local busybox install path
ifeq ("$(KERNEL_VERSION)","")
KERNEL_VERSION=$(shell uname -r)
endif
export KERNEL_VERSION
filetype=$(shell file $1 | grep "Linux S390")
s390_check=$(if $(call filetype,$1), $1)
prefixes=image vmlinux vmlinuz
kernel_images=$(foreach prefix, $(prefixes), \
$(call s390_check,/boot/$(prefix)-$(KERNEL_VERSION)))
KERNEL_IMAGE=$(firstword $(kernel_images))
ifeq ($(KERNEL_IMAGE),)
$(error Could not find a kernel image under /boot)
endif
BUSYBOX=busybox-1.27.1
BBINSTALL=$(BUSYBOX)/_install
all: $(KERNEL_IMAGE) pxelinux.initramfs
/bin/bash mk-s390image $(KERNEL_IMAGE) pxelinux.0 -r pxelinux.initramfs
pxelinux.initramfs: $(BBINSTALL)
/bin/bash mk-pxelinux-ramfs -b $< -k $(KERNEL_VERSION) $@
$(BUSYBOX)/_install:
wget https://busybox.net/downloads/$(BUSYBOX).tar.bz2
tar xjf $(BUSYBOX).tar.bz2
make -C $(BUSYBOX) defconfig
make -C $(BUSYBOX) install
install:
clean:
$(RM) pxelinux.0 pxelinux.initramfs $(BUSYBOX).tar.bz2
$(RM) -r $(BUSYBOX)
.PHONY: all install clean

99
netboot/README.md Normal file
View File

@@ -0,0 +1,99 @@
# How to build a PXELINUX-style network boot image for KVM
## Synopsis
To build a PXELINUX-style netboot image usable for KVM a s390 Linux system
with access to the internet is required.
Running the following command will generate the netboot image pxlinux.0:
` $ make -f Makefile.pxelinux.0`
Alternatively you can use docker to build the image:
```
$ docker build -t pxelinux0 .
$ docker run --rm -v $(pwd):/out pxelinux0 cp /netboot/pxelinux.0 /out
$ docker rmi pxelinux0
```
The resulting file pxelinux.0 must be copied to the system acting as
DHCP/BOOTP server for the KVM installation.
## Full Description
Starting with QEMU 2.10 it is possible to boot s390 virtual machines over a
network interface using DHCP. As usual for DHCP/BOOTP a single bootable image
is copied from the boot server, loaded into memory and booted. In order to
boot a Linux Operating System, it is typically necessary to load a kernel
together with an initial ramdisk (initramfs) and optionally specify some kernel
command line parameters.
Alternatively, on s390 it is possible to load a single file consisting of
the kernel image followed by an initial ramdisk. Such single boot images can
be provided by a Linux distributor, e.g. on the installation media.
Single boot images can also easily be built from pre-existing kernel/initramfs
pairs by concatenating these files. In order to allow the kernel to find the
ramdisk, it is necessary to update the 8 bytes at location 0x10408 with the
offset value of the ramdisk in the new binary, and the 8 bytes at location
0x10410 with the size of the ramdisk. Both values need to be updated in binary,
big endian format.
Since PXELINUX, the PXE boot implementation provided by the Syslinux project,
has introduced a popular way to set up network boot servers for Linux, it
is desirable that s390 network boot setups can be done in a similar way.
A boot image simulating a PXELINUX-like boot for s390 can be easily
constructed by combining a Linux kernel with a small fit-to-purpose initial
ramdisk as described above. For practical purposes, using the host kernel is
a reasonable way for this kind of approach. If possible, the initial ramdisk
should be independent of the host, which is not always possible, as the kernel
might require modules for e.g. virtio network and block devices.
### Example: Building a PXELINUX-style boot image
The approach described below consists of bundling some shell scripts, busybox
and the kexec binary bundled into the initial ramdisk.
The init process can be a simple shell script that will mount a few essential
file systems, like /dev, /proc, and /sys, start a DHCP client (e.g. busybox's
udchpc) and then invoke another script to perform the network boot.
udchpc will invoke the script /usr/share/udhcpc/default.script in response
to DHCP server messages to perform configuration actions.
The sample default.script delivered with busybox can be used for that purpose,
but needs to be extended to evaluate the bootp specific DHCP options (most
important the tftp server address) and store them for use by the boot script.
The boot script itself has to retrieve the PXELINUX configuration from the
tftp server according to the rules described [here][1] then retrieve the
remote kernel and initial ramdisk and finally use kexec to boot the network
kernel.
In essence, the following steps are performed to produce the initial
ramdisk:
1. Create a skeleton initramfs directory structure
2. Create the init script, the boot script and the DHCP default script
3. Copy kexec and it's dependencies from the host into the initramfs
4. Copy virtio network and block modules of the host's active kernel into
the initramfs
5. Copy the busybox binaries into the initramfs.
6. Copy the DHCP configuration and PXE boot scripts to the initramfs
7. Build the ramdisk (in compressed CPIO format)
8. Concatenate the kernel image and the initial ramdisk, and adjust the
ramdisk offset as described above.
Steps 1 to 7 are performed by the sample script mk-pxelinux-ramfs, while step
8 is done with the help of mk-s390image.
The binary resulting from the procedure described above can now be deployed
to a DHCP/BOOTP server. This server should also act as a TFTP server for the
PXELINUX configuration and binary files needed to complete the network boot.
Alternatively, it is possible to use programs like [petitboot][2] or
[pxe-kexec][3] in the initial ramdisk, as these provide more sophisticated
and robust processing of PXELINUX-style configurations.
[1]: http://www.syslinux.org/wiki/index.php?title=PXELINUX
[2]: https://github.com/open-power/petitboot
[3]: https://sourceforge.net/projects/pxe-kexec.berlios/

410
netboot/mk-pxelinux-ramfs Executable file
View File

@@ -0,0 +1,410 @@
#!/bin/bash
#
# netboot - PXE-style boot for KVM on s390
#
# Sample script to build an initramfs image suitable for performing a
# PXELINUX-style boot for KVM guests from a DHCP/BOOTP Server.
# Has to be executed on the KVM host where it will be deployed and needs
# to be re-run after kernel updates on the host, unless the virtio
# drivers are statically built into the host kernel.
#
# The script requires a busybox install tree, e.g. resulting from a build
# from source, after make defconfig && make install
#
# To keep things simple, we don't include udev but use devtmpfs
# which means the host kernel must have been built with CONFIG_DEVTMPFS=y
#
# Sample invocation:
#
# ./mk-pxelinux-ramfs -b /downloads/busyboxdir pxelinux.initramfs
#
# Copyright IBM Corp. 2017
#
# s390-tools is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.
# Variables
cmd=$(basename $0)
busyboxdir=
builddir=
initramfs=
success=no
# Cleanup on exit
cleanup()
{
if [ -n $builddir ]
then
rm -rf $builddir
fi
}
trap cleanup EXIT
# Usage
usage()
{
cat <<-EOF
Usage: $cmd -b BUSYBOX_DIR [-k KERNEL_VERSION] INITRAMFS_FILE
Build a PXELINUX style boot initramfs INITRAMFS_FILE using a busybox installed
in BUSYBOX_DIR and kernel modules from the currently running kernel or from
the kernel version specified with the '-k KERNEL_VERSION' option.
OPTIONS
-b Search installed busybox in directory BUSYBOX_DIR
-k Use KERNEL_VERSION instead of currently running kernel
-h Print this help, then exit
EOF
}
# Get shared objects for binary
sharedobjs()
{
ldd $1 | sed -e 's?[^/]*??' -e 's/(.*)//'
}
# Check args
args=$(getopt b:k:h $*)
if [ $? = 0 ]
then
set -- $args
while [ -n $1 ]
do
case $1 in
-b) busyboxdir=$2; shift 2;;
-k) kernelversion=$2; shift 2;;
-h) usage; exit 0;;
--) shift; break;;
*) echo "$cmd: Unexpected argument $1, exiting..." >&2; exit 1;;
esac
done
fi
if [ $# != 1 -o "$busyboxdir" = "" ]
then
usage >&2
exit 1
fi
# Full output file path
initramfs=$(readlink -m $(dirname $1))/$(basename $1)
# Exit on error
set -e
# Module locations
if [ -n $kernelversion ]; then
moddir=/lib/modules/$kernelversion
else
moddir=/lib/modules/$(uname -r)
fi
netdir=$moddir/kernel/drivers/net
blkdir=$moddir/kernel/drivers/block
# Setup build directory
builddir=$(mktemp -d)
echo "$cmd: Building in $builddir"
ramfsdirs="/bin /dev /etc /lib64 /lib /mnt /proc /run /sbin /sys /tmp /usr /var"
for d in $ramfsdirs
do
mkdir -p $builddir/$d
done
# Kexec
echo "$cmd: Copying kexec"
# Install both binary and required shared libraries
OLDPATH=$PATH
PATH=$OLDPATH:/sbin:/usr/sbin
kexec_bin=$(which kexec)
kexec_sos=$(sharedobjs $kexec_bin)
PATH=$OLDPATH
cp $kexec_bin $builddir/sbin
for so in $kexec_sos
do
mkdir -p $builddir/$(dirname $so)
cp $so $builddir/$(dirname $so)
done
# virtio module(s), if present
echo "$cmd: Copying virtio modules"
mkdir -p $builddir/$netdir
mkdir -p $builddir/$blkdir
set +e
cp $netdir/virtio_net.ko $builddir/$netdir 2> /dev/null
cp $blkdir/virtio_blk.ko $builddir/$blkdir 2> /dev/null
set -e
# Busybox (+ dependencies)
echo "$cmd: Copying busybox files"
cp -a $busyboxdir/* $builddir
busybox_sos=$(sharedobjs $busyboxdir/bin/busybox)
for so in $busybox_sos
do
mkdir -p $builddir/$(dirname $so)
cp $so $builddir/$(dirname $so)
done
# ad_packet module(s), if present
echo "$cmd: Copying af_packet modules"
packetdir=$moddir/kernel/net/packet
mkdir -p $builddir/$packetdir
set +e
cp $packetdir/* $builddir/$packetdir 2> /dev/null
set -e
# Init script
echo "$cmd: Making init script"
# --- begin init script
cat <<'EOF' > $builddir/init
#!/bin/sh
/bin/mount -t devtmpfs none /dev
/bin/mount -t proc none /proc
/bin/mount -t sysfs none /sys
/bin/mount -t tmpfs none /run
/sbin/modprobe virtio_net
/sbin/udhcpc -O pxeconffile -O pxepathprefix &
/sbin/pxeboot.script
EOF
# --- end init script
chmod +x $builddir/init
# udhcpc script
echo "$cmd: Making DHCP script"
mkdir -p $builddir/usr/share/udhcpc
# -- begin dhcp script
cat <<'EOF' > $builddir/usr/share/udhcpc/default.script
#!/bin/sh
# Setup name resolution and PXE boot configuration
# called by udhcpc
RESOLVCONF="/etc/resolv.conf"
PXECONF="/etc/pxe.conf"
ccidr()
{
# clumsy netmask to cidr transformation
# with minimal sanity checking
OLDIFS=$IFS
IFS=.
c=0
n=4
for i in $1
do
n=$(/usr/bin/expr $n - 1)
case $i in
255) c=$(/usr/bin/expr $c + 8);;
254) c=$(/usr/bin/expr $c + 7); break;;
252) c=$(/usr/bin/expr $c + 6); break;;
248) c=$(/usr/bin/expr $c + 5); break;;
240) c=$(/usr/bin/expr $c + 4); break;;
224) c=$(/usr/bin/expr $c + 3); break;;
192) c=$(/usr/bin/expr $c + 2); break;;
128) c=$(/usr/bin/expr $c + 1); break;;
0) break;;
*) c=0; break;;
esac
if [ $n = 0 ]
then
break
fi
done
IFS=$OLDIFS
echo $c
}
echo "DHCP response $1: "
case "$1" in
deconfig)
echo " interface: $interface"
/sbin/ip route flush table all
/sbin/ip addr flush $interface
/sbin/ip link set $interface up
/bin/rm -f $PXECONF $RESOLVCONF
;;
renew|bound)
echo " interface: $interface $ip $subnet"
echo " router: $router"
echo " domain: $domain $dns"
echo " tftp: $siaddr"
# flush routes
/sbin/ip route flush table all
# setup if link
/sbin/ip addr flush $interface
/sbin/ip link set $interface up
# setup if addr
if [ -n "$subnet" ]
then
maskedip="$ip"/$(ccidr $subnet)
else
maskedip="ip"
fi
/sbin/ip addr add $maskedip broadcast $broadcast dev $interface
# setup default routes
if [ -n "$router" ]
then
/sbin/ip route add default via $router
fi
# setup resolv.conf
if [ -n "$domain" ]
then
echo "search $domain" > $RESOLVCONF
for i in $dns
do
echo " nameserver $i" >> $RESOLVCONF
done
fi
# pxe control
if [ -n "$siaddr" ]
then
echo "siaddr=$siaddr" > $PXECONF
echo "interface=$interface" >> $PXECONF
echo "ip=$ip" >> $PXECONF
fi
;;
nak)
;;
*)
exit 1
;;
esac
exit 0
EOF
# -- end dhcp script
chmod +x $builddir/usr/share/udhcpc/default.script
# pxeboot script
echo "$cmd: Making PXE boot script"
# -- begin pxeboot script
cat <<'EOF' > $builddir/sbin/pxeboot.script
#!/bin/sh
# Perform a PXE style boot using kexec
# Supports only super-simple config files
set -e
# Check if a valid pxe conf is available
# so far a non configurable 600 sec timeout
PXE_CONF=/etc/pxe.conf
TIMEOUT=600
WAITED=0
echo "waiting for pxe config from DHCP (max $TIMEOUT sec)"
while [ ! -f $PXE_CONF ]
do
sleep 1
WAITED=$(($WAITED + 1))
if [ $WAITED -gt $TIMEOUT ]
then
echo Error waiting for PXE configuration from DHCP
exit
fi
done
# Source the DHCP-generated TFTP info
# Currently we are just looking for siaddr
. $PXE_CONF
# Retrieve the config (default only for now)
CONFIGS=""
if [ -n "$siaddr" ];
then
# Enable UUID based config on s390
if [ $(/bin/uname -m) = "s390x" ]
then
set +e
uuid=$(/bin/grep UUID /proc/sysinfo | tail -1 | tr -d ' ' | cut -d ':' -f 2) 2> /dev/null
set -e
else
# not caring for other arches right now
uuid=""
fi
CONFIGS="$CONFIGS $uuid"
# Enable MAC based config
ifaddr=$(/bin/cat /sys/class/net/$interface/address | tr ':' '-')
CONFIGS="$CONFIGS 01-$ifaddr"
# Enable IP based config
iphex=$(printf %02X $(echo $ip | tr '.' ' '))
for i in 8 7 6 5 4 3 2 1
do
CONFIGS="$CONFIGS $(echo $iphex | cut -c 1-$i)"
done
# Finally enable default config
CONFIGS="$CONFIGS default"
set +e
for c in $CONFIGS
do
echo "fetching config pxelinux.cfg/$c from $siaddr"
if /usr/bin/tftp -g -l /tmp/config -r pxelinux.cfg/$c $siaddr
then
break
fi
done
fi
if [ ! -f /tmp/config ]
then
echo no config found
exit
fi
# Simple config file parsing, only one entry allowed
kernel=$(/bin/grep -i "^[[:space:]]*kernel" /tmp/config | sed "s/^[[:space:]]*kernel[[:space:]]*//I")
initrd=$(/bin/grep -i "^[[:space:]]*initrd" /tmp/config | sed "s/^[[:space:]]*initrd[[:space:]]*//I")
append=$(/bin/grep -i "^[[:space:]]*append" /tmp/config | sed "s/^[[:space:]]*append[[:space:]]*//I")
if [ -z "$kernel" ]
then
echo no kernel statement found in config
exit
else
echo fetch kernel $kernel from $siaddr
/usr/bin/tftp -g -l /tmp/kernel -r $kernel $siaddr
fi
if [ -n "$initrd" ]
then
echo fetch initrd $initrd from $siaddr
/usr/bin/tftp -g -l /tmp/initrd -r $initrd $siaddr
INITRD="--initrd=/tmp/initrd"
else
INITRD=""
fi
if [ -z "$append" ]; then
echo "Kexec load: kexec -l /tmp/kernel $INITRD"
kexec -l /tmp/kernel $INITRD
else
echo "Kexec load: kexec -l /tmp/kernel $INITRD --append=\"$append\""
kexec -l /tmp/kernel $INITRD --append="$append"
fi
kexec -e
EOF
# -- end pxeboot script
chmod +x $builddir/sbin/pxeboot.script
# The final initramfs
echo Building initramfs
cd $builddir
find . | cpio -o -Hnewc | gzip - > $initramfs
cd $OLDPWD

171
netboot/mk-s390image Executable file
View File

@@ -0,0 +1,171 @@
#!/bin/bash
#
# netboot - PXE-style boot for KVM on s390
#
# Sample script to build a single s390 boot image consisting of
# kernel, an initial ramdisk and kernel parameters from
# individual components. Note that bash is required to run this script!
#
# Sample invocation:
#
# ./mk-s390image /boot/image -r /boot/initrd image
#
# The resulting image can be used to build a bootable
# ISO or as firmware image for KVM.
#
# Copyright IBM Corp. 2017
#
# s390-tools is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.
# Offsets
OFFS_INITRD_START_BYTES=66568
OFFS_INITRD_SIZE_BYTES=66576
OFFS_COMMANDLINE_BYTES=66688
MAX_PARMFILE_SIZE=896
# Variables
cmd=$(basename $0)
kernel=
ramdisk=
parmfile=
image=
binval=
success=no
# Cleanup on exit
cleanup()
{
if [ -n "$binval" ]
then
rm -f $binval
fi
if [ -n "$image" -a $success = no ]
then
rm $image
fi
}
trap cleanup EXIT
# Usage
usage()
{
cat <<-EOF
Usage: $cmd KERNEL BOOT_IMAGE [-r RAMDISK] [-p PARMFILE]
Build an s390 image BOOT_IMAGE suitable for CD/tape/network boot or as a
KVM firmware image using a stripped Linux kernel file KERNEL.
OPTIONS
-p Use PARMFILE with kernel parameters in the image
-r Include RAMDISK in the image
-h Print this help, then exit
EOF
}
# Convert decimal number to big endian doubleword
dec2be64()
{
local num=$1
local b
local i
for i in $(seq 1 8)
do
b="\\x$(printf '%x' $(expr $num % 256))$b"
num=$(expr $num / 256) || true
done
printf $b
}
# Do the image build
dobuild()
{
local i
local kernel_size
local ramdisk_size
local ramdisk_offset
local parmfile_size
# check whether all specified files exist
for i in $kernel $ramdisk $parmfile
do
if [ ! -f $i ]
then
echo "$cmd: File $i not found" >&2
return 1
fi
done
if ! file -b $(readlink -f $kernel) | grep "Linux S390" > /dev/null
then
echo "$cmd: Unrecognized file format for $kernel" >&2
return 1
fi
# from now on we SHOULD only fail on disk shortage
# or file permissions, let the shell handle that
set -e
# copy over kernel padded with zeroes to page boundary
dd if=$kernel of=$image bs=4096 conv=sync status=none
# append ramdisk if specified
if [ "$ramdisk" != "" ]
then
ramdisk_size=$(du -b $ramdisk | cut -f1)
kernel_size=$(du -b $kernel | cut -f1)
ramdisk_offset=$(du -b $image | cut -f1)
cat $ramdisk >> $image
binval=$(mktemp)
dec2be64 $ramdisk_offset > $binval
dd seek=$OFFS_INITRD_START_BYTES if=$binval of=$image bs=1 \
count=8 conv=notrunc status=none
dec2be64 $ramdisk_size > $binval
dd seek=$OFFS_INITRD_SIZE_BYTES if=$binval of=$image bs=1 \
count=8 conv=notrunc status=none
fi
# set cmdline
if [ "$parmfile" != "" ]
then
parmfile_size=$(du -b $parmfile | cut -f1)
if [ $parmfile_size -le $MAX_PARMFILE_SIZE ]
then
dd seek=$OFFS_COMMANDLINE_BYTES bs=1 if=$parmfile \
of=$image conv=notrunc status=none
else
echo "$cmd: Size $parmfile_size of $parmfile exceeds command line limit of $MAX_PARMFILE_SIZE" >&2
return 1
fi
fi
# we've done it
success=yes
}
# check args and build
args=$(getopt "r:p:h" $*)
if [ $? = 0 ]
then
set -- $args
while [ $1 != "" ]
do
case $1 in
-r) ramdisk=$2; shift 2;;
-p) parmfile=$2; shift 2;;
-h) usage; exit 0;;
--) shift; break;;
*) echo "$cmd: Unexpected argument $1, exiting..." >&2; exit 1;;
esac
done
fi
if [ $# = 2 ]
then
kernel=$1
image=$2
dobuild
exit 0
fi
# something wasn't right
usage >&2
exit 1

View File

@@ -1,6 +1,9 @@
include ../common.mak
LDLIBS = `net-snmp-config --agent-libs`
CFLAGS += `net-snmp-config --cflags`
# On some Linux systems `net-snmp-config --agent-libs` introduces -pie,
# therefore add -fPIC to prevent link failures.
ALL_CFLAGS += -fPIC
ALL_CFLAGS += `net-snmp-config --cflags`
OBJS = ibmOSAMib.o ibmOSAMibUtil.o osasnmpd.o

View File

@@ -3,7 +3,7 @@ include ../common.mak
all:
install: qethconf
$(SED) -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
$(SED) -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
< qethconf >$(DESTDIR)$(BINDIR)/qethconf; \
chown $(OWNER).$(GROUP) $(DESTDIR)$(BINDIR)/qethconf; \
chmod 755 $(DESTDIR)$(BINDIR)/qethconf; \

View File

@@ -1,7 +1,7 @@
include ../common.mak
SCRIPTS = dbginfo.sh zfcpdbf scsi_logging_level
MAN_PAGES = dbginfo.sh.1 zfcpdbf.1
SCRIPTS = dbginfo.sh zfcpdbf zipl-switch-to-blscfg scsi_logging_level
MAN_PAGES = dbginfo.sh.1 zfcpdbf.1 zipl-switch-to-blscfg.1
all:
@@ -10,12 +10,17 @@ install:
@for i in $(SCRIPTS); \
do \
cat $$i | \
sed -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
sed -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
>$(DESTDIR)$(BINDIR)/$$i; \
chown $(OWNER):$(GROUP) $(DESTDIR)$(BINDIR)/$$i; \
chmod 755 $(DESTDIR)$(BINDIR)/$$i; \
done
sed -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' cpictl > \
$(DESTDIR)$(TOOLS_LIBDIR)/cpictl
chown $(OWNER):$(GROUP) $(DESTDIR)$(TOOLS_LIBDIR)/cpictl
chmod 775 $(DESTDIR)$(TOOLS_LIBDIR)/cpictl
@for i in $(MAN_PAGES); \
do \
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 644 $$i \

275
scripts/cpictl Executable file
View File

@@ -0,0 +1,275 @@
#!/bin/bash
#
# cpictl - Configure the Control-Program-Information (CPI) settings
#
# This is an internal helper script that is used by the "cpi.service"
# systemd unit and the "90-cpi.rules" udev rule.
#
# The bash shell is really needed. Other shells have different ideas of how
# bitwise operators work.
#
# Copyright 2017 IBM Corp.
#
# s390-tools is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.
#
readonly CPI_LOCK="/var/lock/cpictl.lock"
readonly PRG="${0##*/}"
readonly SYSTEM_LEVEL_PATH="/sys/firmware/cpi/system_level"
readonly SYSTEM_TYPE_PATH="/sys/firmware/cpi/system_type"
readonly SYSTEM_NAME_PATH="/sys/firmware/cpi/system_name"
readonly SYSPLEX_NAME_PATH="/sys/firmware/cpi/sysplex_name"
readonly CPI_SET="/sys/firmware/cpi/set"
declare LEVEL
declare TYPE
declare NAME
declare SYSPLEX
declare -i DRYRUN=0
# Exit codes
readonly EXIT_SUCCESS=0
readonly EXIT_FAILURE=1
readonly EXIT_ARG_TOO_LONG=3
readonly EXIT_INVALID_CHARS=4
print_help_and_exit()
{
cat <<EndHelp
Usage: $PRG [OPTIONS]
Configure the Control-Program-Information (CPI) settings.
-b, --set-bit BIT Set and commit the bit BIT in the flags
-e, --environment Set and commit the system type, level, name and
sysplex name with values taken from environment
variables
-h, --help Print this help, then exit
-L, --level LEVEL Set and commit OS level to LEVEL (format xx.yy.zzABCD)
-N, --name SYSTEM Set and commit the system name to SYSTEM
-S, --sysplex SYSPLEX Set and commit the sysplex name to SYSPLEX
-T, --type TYPE Set and commit OS type to TYPE
-v, --version Print version information, then exit
--commit Ignore all other options and commit any uncommitted
values
--dry-run Do not actually set or commit anything, but show what
would be done
--show Ignore all other options and show current (possibly
uncommitted) values
Environment variables used for the --defaults option:
CPI_SYSTEM_TYPE, CPI_SYSTEM_LEVEL, CPI_SYSTEM_NAME, CPI_SYSPLEX_NAME
Available bits for the --set-bit option:
kvm: Indicate that system is a KVM host
The maximum length for system type, system name, and sysplex name is 8
characters. The allowed characters are: [A-Z0-9 @#$]
This tool should be called as root.
EndHelp
exit $EXIT_SUCCESS
}
print_version_and_exit()
{
cat <<EndVersion
$PRG: Configure the CPI settings version %S390_TOOLS_VERSION%
Copyright IBM Corp. 2017
EndVersion
exit $EXIT_SUCCESS
}
cpi_show()
{
cat <<-EndShow
System type: $(cat "$SYSTEM_TYPE_PATH")
System level: $(cat "$SYSTEM_LEVEL_PATH")
System name: $(cat "$SYSTEM_NAME_PATH")
Sysplex name: $(cat "$SYSPLEX_NAME_PATH")
EndShow
}
print_parse_error_and_exit()
{
echo "Try '$PRG --help' for more information." >&2
exit $EXIT_FAILURE
}
fail_with()
{
echo "$1" >&2
echo "Try '$PRG --help' for more information." >&2
exit ${2:-$EXIT_FAILURE}
}
cpi_commit()
{
echo 1 > "$CPI_SET"
}
do_length_check()
{
[ ${#1} -gt 8 ] &&
fail_with "$PRG: Specified $2 too long. The maximum length is 8 characters." $EXIT_ARG_TOO_LONG
}
do_character_check()
{
echo "$1" | grep -q -E '^[a-zA-Z0-9@#$ ]*$' ||
fail_with "$PRG: Invalid characters in $2. Valid characters are: A-Z0-9 @#$" $EXIT_INVALID_CHARS
}
cpi_set_bit()
{
LEVEL=$(printf '0x%x' $((LEVEL | (1 << (63 - $1)) )) )
}
cpi_set_oslevel()
{
local kver=$(echo "${1:-$(uname -r)}" | grep -E -o '^[0-9]+[.][0-9]+[.][0-9]+')
local maj=$((${kver%%.*} % 256))
local min=${kver#*.}
min=$((${min%.*} % 256))
local rev=$((${kver##*.} % 256))
local hexlevel=$(printf '0x%02x%02x%02x' $maj $min $rev)
LEVEL=$(printf '0x%016x' $(((LEVEL & 0xFFFFFFFFFF000000) | hexlevel)))
}
cpi_set_type()
{
TYPE="$1"
do_length_check "$TYPE" "system type"
do_character_check "$TYPE" "system type"
}
cpi_set_sysplex()
{
SYSPLEX="$1"
do_length_check "$SYSPLEX" "sysplex name"
do_character_check "$SYSPLEX" "sysplex name"
}
cpi_set_name()
{
NAME="$1"
do_length_check "$NAME" "system name"
do_character_check "$NAME" "system name"
}
# cpictl starts here
if [ $# -le 0 ]; then
echo "$PRG: No parameters specified"
print_parse_error_and_exit
fi
opts=$(getopt -o b:ehL:N:S:T:v -l set-bit:,environment,help,level:,name:,sysplex:,type:,commit,dry-run,show,version -n $PRG -- "$@")
if [ $? -ne 0 ]; then
print_parse_error_and_exit
fi
# This guarantees that only one instance will be running, and will serialize
# the execution of multiple instances
[ -e "$CPI_LOCK" -a ! -w "$CPI_LOCK" ] &&
fail_with "$PRG: Cannot access lock file: $CPI_LOCK"
[ ! -w "${CPI_LOCK%/*}" ] &&
fail_with "$PRG: Cannot access lock file: $CPI_LOCK"
exec 9<> "$CPI_LOCK"
flock -x 9
# Get current values from sys/firmware
read LEVEL < "$SYSTEM_LEVEL_PATH"
read TYPE < "$SYSTEM_TYPE_PATH"
read NAME < "$SYSTEM_NAME_PATH"
read SYSPLEX < "$SYSPLEX_NAME_PATH"
# Parse command line options: Use eval to remove getopt quotes
eval set -- $opts
while [ -n $1 ]; do
case "$1" in
--help|-h)
print_help_and_exit
;;
--version|-v)
print_version_and_exit
;;
-b|--set-bit)
case "$2" in
kvm)
cpi_set_bit 0
;;
*)
fail_with "$PRG: Unknown bit \"$2\" for the $1 option"
;;
esac
shift 2
;;
-L|--level)
cpi_set_oslevel "$2"
shift 2
;;
-e|--environment)
cpi_set_type "$CPI_SYSTEM_TYPE"
cpi_set_name "$CPI_SYSTEM_NAME"
cpi_set_oslevel "$CPI_SYSTEM_LEVEL"
cpi_set_sysplex "$CPI_SYSPLEX_NAME"
shift
;;
-T|--type)
cpi_set_type "$2"
shift 2
;;
-S|--sysplex)
cpi_set_sysplex "$2"
shift 2
;;
-N|--name)
cpi_set_name "$2"
shift 2
;;
--show)
cpi_show
exit $EXIT_SUCCESS
;;
--commit)
cpi_commit
exit $EXIT_SUCCESS
;;
--dry-run)
DRYRUN=1
shift
;;
--)
shift
break
;;
*)
break;
;;
esac
done
# Print settings for --dry-run or commit them to sysfs otherwise
if [ $DRYRUN -eq 1 ]; then
cat <<-EndDryrun
System type: $TYPE
System level: $LEVEL
System name: $NAME
Sysplex name: $SYSPLEX
EndDryrun
else
echo "$LEVEL" > "$SYSTEM_LEVEL_PATH"
echo "$TYPE" > "$SYSTEM_TYPE_PATH"
echo "$NAME" > "$SYSTEM_NAME_PATH"
echo "$SYSPLEX" > "$SYSPLEX_NAME_PATH"
cpi_commit
fi
exit $EXIT_SUCCESS

View File

@@ -182,11 +182,14 @@ readonly OUTPUT_FILE_XML="${WORKPATH}domain_xml"
# File that includes the docker inspect output
readonly OUTPUT_FILE_DOCKER="${WORKPATH}docker_inspect.out"
# File that includes nvme related information
readonly OUTPUT_FILE_NVME="${WORKPATH}nvme.out"
# Mount point of the debug file system
readonly MOUNT_POINT_DEBUGFS="/sys/kernel/debug"
# The amount of steps running the whole collections
readonly COLLECTION_COUNT=11
readonly COLLECTION_COUNT=12
# The kernel version (e.g. '2' from 2.6.32 or '3' from 3.2.1)
readonly KERNEL_VERSION=$(uname -r 2>/dev/null | cut -d'.' -f1)
@@ -375,7 +378,8 @@ CMDS="uname -a\
:runlevel\
:iptables -L\
:ulimit -a\
:ps -eo pid,tid,nlwp,policy,user,tname,ni,pri,psr,sgi_p,stat,wchan,start_time,time,pcpu,pmem,vsize,size,rss,share,command\
:ps -emo pid,tid,nlwp,policy,user,tname,ni,pri,psr,sgi_p,stat,wchan,start_time,time,pcpu,pmem,vsize,size,rss,share,command\
:ps -eHo pid,tid,nlwp,policy,user,tname,ni,pri,psr,sgi_p,stat,wchan,start_time,time,pcpu,pmem,vsize,size,rss,share,command\
:ps axX\
:dmesg -s 1048576\
:last\
@@ -470,6 +474,8 @@ VM_CMDS="q userid\
:q privclass\
:q cplevel\
:q cpservice\
:q cpprot user\
:q specex\
:q ssi\
:q cpus\
:q srm\
@@ -508,6 +514,7 @@ VM_CMDS="q userid\
:q cache\
:q nic\
:q pav\
:q proc\
:q proc topology\
:q mt\
:q qioass\
@@ -824,6 +831,25 @@ collect_docker() {
pr_log_stdout " "
}
########################################
collect_nvme() {
local NVME
pr_syslog_stdout "11 of ${COLLECTION_COUNT}: Collecting nvme output"
call_run_command "nvme list" "${OUTPUT_FILE_NVME}"
for NVME in /dev/nvme[0-9]*; do
if [ -c $NVME ]; then
call_run_command "smartctl -x $NVME" "${OUTPUT_FILE_NVME}"
call_run_command "nvme fw-log $NVME" "${OUTPUT_FILE_NVME}"
call_run_command "nvme smart-log $NVME" "${OUTPUT_FILE_NVME}"
call_run_command "nvme error-log $NVME" "${OUTPUT_FILE_NVME}"
fi
done
pr_log_stdout " "
}
########################################
post_processing() {
local file_mtime
@@ -831,7 +857,7 @@ post_processing() {
local tmp_file
local file_name
pr_syslog_stdout "11 of ${COLLECTION_COUNT}: Postprocessing"
pr_syslog_stdout "${COLLECTION_COUNT} of ${COLLECTION_COUNT}: Postprocessing"
find "${WORKPATH}etc/libvirt/qemu/" -maxdepth 1 -name "*.xml" 2>/dev/null | while IFS= read -r file_name; do
file_mtime_epoche=$(stat --format=%Y "${file_name}")
@@ -1116,6 +1142,8 @@ collect_domain_xml
collect_docker
collect_nvme
post_processing
create_package

213
scripts/zipl-switch-to-blscfg Executable file
View File

@@ -0,0 +1,213 @@
#!/bin/bash
#
# zipl-switch-to-blscfg - Switch zipl to use BootLoaderSpec configuration
#
# Copyright 2018 Red Hat, Inc.
#
# s390-tools is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.
#
readonly SCRIPTNAME="${0##*/}"
declare -A zipl_to_bls
zipl_to_bls["image"]="linux"
zipl_to_bls["ramdisk"]="initrd"
zipl_to_bls["parameters"]="options"
print_error() {
echo "$1" >&2
exit 1
}
function on_exit() {
if ! rm -rf $TMP; then
echo "Delete temporary files failed!" >&2
exit 1
fi
}
if ! TMP="$(mktemp -d)"; then
print_error "Creating a temporary dir for config files failed!"
fi
trap 'on_exit' EXIT
print_version() {
cat <<EOF
${SCRIPTNAME}: version %S390_TOOLS_VERSION%
Copyright Red Hat, Inc. 2018
EOF
}
print_usage()
{
print_version
cat <<EOF
Usage: ${SCRIPTNAME} [OPTIONS]
Switches the zipl boot-loader configuration to use BootLoaderSpec files.
Options:
-h, --help print this help and exit
-v, --version print version information and exit
--backup-suffix=SUFFIX suffix used for backup files, defaults to .bak
--bls-directory=DIR path to generate BLS files, defaults to /boot/loader/entries
--config-file=FILE path to zipl configuration file, defaults to /etc/zipl.conf
--ignore-default ignore the default option from the zipl configuration file
--use-version-name use the section kernel version as the BLS file name
EOF
}
OPTS="$(getopt -o hv --long help,version,backup-suffix:,bls-directory:,config-file:,\
ignore-default,use-version-name -n \'$SCRIPTNAME\' -- "$@")"
eval set -- "$OPTS"
BACKUP_SUFFIX=.bak
BLS_DIR="/boot/loader/entries"
CMDLINE_LINUX_DEBUG=" systemd.log_level=debug systemd.log_target=kmsg"
LINUX_DEBUG_VERSION_POSTFIX="_with_debugging"
LINUX_DEBUG_TITLE_POSTFIX=" with debugging"
CONFIG="/etc/zipl.conf"
while [ ${#} -gt 0 ]; do
case "$1" in
--help|-h)
print_usage
exit 0
;;
--version|-v)
print_version
exit 0
;;
--backup-suffix)
BACKUP_SUFFIX=${2}
shift
;;
--bls-directory)
BLS_DIR=${2}
shift
;;
--config-file)
CONFIG=${2}
shift
;;
--ignore-default)
ignore_default=true
;;
--use-version-name)
version_name=true
;;
--)
shift
break
;;
*)
echo >&2
echo "${SCRIPTNAME}: invalid option \"${1}\"" >&2
echo "Try '${SCRIPTNAME} --help' for more information" >&2
echo >&2
exit 1
;;
esac
shift
done
TMP_CONFIG="${TMP}/${CONFIG##*/}"
[[ -d "$BLS_DIR" ]] || mkdir -m 0700 -p "$BLS_DIR"
if [ -f /etc/machine-id ]; then
read MACHINE_ID < /etc/machine-id
MACHINE_ID=${MACHINE_ID}-
fi
count=0
OUTPUT=""
TARGET=""
while IFS='= ' read key val; do
# for BLS the default kernel is always the latest one
if [[ $key == \#* ]] || [[ $key == "default" && $ignore_default == true ]]; then
continue
fi
# remove spaces
key="$(echo $key | sed -e 's/^[ \t"]*//;s/[ \t"]*$//')"
if [[ $key = \[*] ]]; then
if [[ $key == "[defaultboot]" ]]; then
OUTPUT=${TMP_CONFIG}
echo $key >> ${OUTPUT}
else
key="${key%\]}"
key="${key#\[}"
section=$key
OUTPUT=${BLS_DIR}/${MACHINE_ID}${section}.conf
if [ -f "${OUTPUT}" ]; then
print_error "BLS file ${OUTPUT} already exists"
fi
fi
elif [[ $val ]]; then
val="$(echo $val | sed -e 's/^[ \t"]*//;s/[ \t"]*$//')"
if [[ $key == "target" ]]; then
if [ -z ${TARGET} ]; then
echo $key=$val >> ${TMP_CONFIG}
TARGET=$val
else if [ "${TARGET}" != "${val}" ]; then
print_error "BLS is only supported if all sections have the same target"
fi
fi
else
if [ -n "${zipl_to_bls[$key]}" ]; then
if [[ $key = "image" && $version_name == true ]]; then
if [[ $val = *"vmlinuz-"* ]]; then
version="${val##*/vmlinuz-}"
else
version="${val##*/}"
fi
echo "version $version" >> ${OUTPUT}
if [[ $version = *"rescue"* ]]; then
FILENAME=${BLS_DIR}/${MACHINE_ID}0-rescue.conf
else
FILENAME=${BLS_DIR}/${MACHINE_ID}${version}.conf
fi
if [[ ${OUTPUT} != ${FILENAME} ]]; then
if [ -f "${FILENAME}" ]; then
print_error "BLS file ${FILENAME} already exists"
fi
mv ${OUTPUT} ${FILENAME}
if [ ! $? -eq 0 ]; then
print_error "Creating BLS file ${FILENAME} failed"
fi
OUTPUT=${FILENAME}
fi
elif [[ $key = "image" ]]; then
echo "version $section" >> ${OUTPUT}
fi
echo "${zipl_to_bls[$key]} ${val}" >> ${OUTPUT}
else
echo $key=$val >> ${TMP_CONFIG}
fi
fi
fi
done < "${CONFIG}"
if [ -f "${CONFIG}${BACKUP_SUFFIX}" ]; then
print_error "Backup file ${CONFIG}${BACKUP_SUFFIX} already exists"
fi
cp -af "${CONFIG}" "${CONFIG}${BACKUP_SUFFIX}"
mv "${TMP_CONFIG}" "${CONFIG}"
zipl > /dev/null
if [ ! $? -eq 0 ]; then
mv "${CONFIG}${BACKUP_SUFFIX}" "${CONFIG}"
fi
exit 0

View File

@@ -0,0 +1,45 @@
.TH ZIPL-SWITCH-TO-BLSCFG 1 "April 2018" "s390-tools"
.SH NAME
zipl-switch-to-blscfg \- Switch zipl to use BootLoaderSpec configuration
.SH SYNOPSIS
.br
\fBzipl-switch-to-blscfg\fP [OPTIONS]
.br
\fBzipl-switch-to-blscfg\fP {\-h|\-v}
.SH DESCRIPTION
This script switches the zipl boot-loader configuration to use BootLoaderSpec files
to define IPL sections. For each Linux kernel defined in the zipl.conf config file,
a BLS fragment is generated in the BLS directory specified. Also, the zipl.conf is
modified it only contains global configurations, all IPL sections comes from BLS.
.SH OPTIONS
.TP
\fB\-h\fP, \fB\-\-help\fP
Print this help and exit
.TP
\fB\-v\fP, \fB\-\-version\fP
Print version information and exit
.TP
\fB\-\-backup-suffix <SUFFIX>\fP
The suffix used for backup files, defaults to .bak.
.TP
\fB\-\-bls-directory <DIRECTORY>\fP
The DIRECTORY where the BLS fragments will be generated. The directory is created if it doesn't exists, by default /boot/loader/entries is used.
.TP
\fB\-\-config-file <FILE>\fP
The FILE used for zipl configuration file, defaults to /etc/zipl.conf.
.TP
\fB\-\-ignore-default\fP
Ignore the default option from the zipl configuration file
.TP
\fB\-\-use-version-name\fP
Use the section kernel version as the BLS file name

View File

@@ -35,10 +35,12 @@ clean:
real_usrbin_dir=$(USRBINDIR); \
real_usrsbin_dir=$(USRSBINDIR); \
real_toolslib_dir=$(TOOLS_LIBDIR); \
real_sysconf_dir=$(SYSCONFDIR); \
$(SED) -e "s#@bin_path@#$$real_bin_dir#g" \
-e "s#@usrbin_path@#$$real_usrbin_dir#g" \
-e "s#@usrsbin_path@#$$real_usrsbin_dir#g" \
-e "s#@toolslib_path@#$$real_toolslib_dir#g" \
-e "s#@sysconf_path@#$$real_sysconf_dir#g" \
-e 's#@S390_TOOLS_RELEASE@#$(S390_TOOLS_RELEASE)#g' \
< $< > $@

View File

@@ -19,7 +19,7 @@ Type=oneshot
# Specify a file with the environment variables using the EnvironmentFile=
# service property.
#
EnvironmentFile=/etc/sysconfig/cpi
EnvironmentFile=@sysconf_path@/sysconfig/cpi
#
# Alternatively, you can specify the environment variables directly,
# using the Environment= service properties, which can be overridden by
@@ -35,12 +35,9 @@ EnvironmentFile=/etc/sysconfig/cpi
# Environment=CPI_SYSTEM_LEVEL=
# Environment=CPI_SYSTEM_TYPE=LINUX
#
# Apply settings
ExecStartPre=/bin/sh -c 'if test -n "$CPI_SYSTEM_TYPE"; then echo $CPI_SYSTEM_TYPE |tr a-z A-Z > /sys/firmware/cpi/system_type; fi'
ExecStartPre=/bin/sh -c 'if test -n "$CPI_SYSTEM_NAME"; then echo $CPI_SYSTEM_NAME |tr a-z A-Z > /sys/firmware/cpi/system_name; fi'
ExecStartPre=/bin/sh -c 'if test -n "$CPI_SYSPLEX_NAME"; then echo $CPI_SYSPLEX_NAME |tr a-z A-Z > /sys/firmware/cpi/sysplex_name; fi'
ExecStartPre=/bin/sh -c 'test -n "$CPI_SYSTEM_LEVEL" || CPI_SYSTEM_LEVEL="$(uname -r)" ; echo $CPI_SYSTEM_LEVEL |cut -d- -f1 | tr . " " |xargs printf "0x0000000000%02x%02x%02x\n" > /sys/firmware/cpi/system_level'
#
# Sending data to the HMC/SE
ExecStart=/bin/sh -c 'echo 1 > /sys/firmware/cpi/set'
ExecStart=@toolslib_path@/cpictl -e
[Install]
WantedBy=multi-user.target

View File

@@ -13,10 +13,11 @@ Documentation=man:cpuplugd(8) man:cpuplugd.conf(5)
After=remote-fs.target
[Service]
ExecStart=@usrsbin_path@/cpuplugd -f -c /etc/cpuplugd.conf
ExecStart=@usrsbin_path@/cpuplugd -c @sysconf_path@/cpuplugd.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Type=simple
Type=forking
PIDFile=/var/run/cpuplugd.pid
[Install]
WantedBy=multi-user.target

View File

@@ -18,7 +18,7 @@ After=remote-fs.target
# Specify a file with the environment variables using the EnvironmentFile=
# service property.
#
EnvironmentFile=/etc/sysconfig/mon_fsstatd
EnvironmentFile=@sysconf_path@/sysconfig/mon_fsstatd
#
# Alternatively, you can specify the environment variables directly,
# using the Environment= service property, which can be overridden by
@@ -30,10 +30,11 @@ EnvironmentFile=/etc/sysconfig/mon_fsstatd
ExecStartPre=-/sbin/modprobe monwriter
ExecStartPre=/sbin/udevadm settle --timeout=10
ExecStart=@usrsbin_path@/mon_fsstatd -a -i $FSSTAT_INTERVAL
ExecStart=@usrsbin_path@/mon_fsstatd -i $FSSTAT_INTERVAL
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Type=simple
Type=forking
PIDFile=/var/run/mon_fsstatd.pid
[Install]
WantedBy=multi-user.target

View File

@@ -18,7 +18,7 @@ After=remote-fs.target
# Specify a file with the environment variables using the EnvironmentFile=
# service property.
#
EnvironmentFile=/etc/sysconfig/mon_procd
EnvironmentFile=@sysconf_path@/sysconfig/mon_procd
#
# Alternatively, you can specify the environment variables directly,
# using the Environment= service property, which can be overridden by
@@ -30,10 +30,11 @@ EnvironmentFile=/etc/sysconfig/mon_procd
ExecStartPre=-/sbin/modprobe monwriter
ExecStartPre=/sbin/udevadm settle --timeout=10
ExecStart=@usrsbin_path@/mon_procd -a -i $PROC_INTERVAL
ExecStart=@usrsbin_path@/mon_procd -i $PROC_INTERVAL
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Type=simple
Type=forking
PIDFile=/var/run/mon_procd.pid
[Install]
WantedBy=multi-user.target

View File

@@ -11,7 +11,7 @@
[Unit]
Description=TTYRun on %I
Documentation=man:ttyrun(8) man:agetty(8)
BindTo=dev-%i.device
BindsTo=dev-%i.device
After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service
After=rc-local.service
Before=getty.target

View File

@@ -2,7 +2,9 @@ include ../common.mak
all: vmcp
vmcp: vmcp.o
libs = $(rootdir)/libvmcp/libvmcp.a $(rootdir)/libutil/libutil.a
vmcp: vmcp.o $(libs)
install: all
$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man8

View File

@@ -4,7 +4,7 @@
* Tool for accessing the control program of z/VM using the
* kernel module vmcp
* return codes:
* 0: everything was fine (VMCP_OK)
* 0: everything was fine (EXIT_SUCCESS)
* 1: CP returned a nn zero response code (VMCP_CP)
* 2: the response buffer was not large enough (VMCP_BUF)
* 3: an internal Linux error occurred (VMCP_LIN)
@@ -28,33 +28,58 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/param.h>
#include <unistd.h>
#include "vmcp.h"
#include "lib/zt_common.h"
#include "lib/vmcp.h"
#include "lib/util_opt.h"
#include "lib/util_prg.h"
#define MAXBUFFER 1048576
#define MINBUFFER 4096
#define MAXCMDLEN 240
#define VMCP_OK 0
#define VMCP_CP 1
#define VMCP_BUF 2
#define VMCP_LIN 3
#define VMCP_OPT 4
static int keep_case = 0;
static int buffersize = 8192;
static int buffersize = VMCP_DEFAULT_BUFSZ;
static char command[MAXCMDLEN + 1];
static void print_help(const char *name)
{
printf("%s: z/VM CP command interface.\n%s", name, help_text);
}
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "keepcase", no_argument, NULL, 'k' },
.desc = "Do not convert CP-command string to uppercase",
},
{
.option = { "buffer", required_argument, NULL, 'b' },
.argument = "SIZE",
.desc = "Specify buffer size in bytes, kilobytes (k) "
"or megabytes (M). SIZE range from 4096 to 1048576 "
"bytes"
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
static void print_version(const char *name)
{
printf("%s: z/VM CP command interface version %s\n"
"Copyright IBM Corp. 2005, 2017\n",
name, RELEASE_STRING);
}
static void uppercase(char *string)
{
while (*string != '\0') {
*string = toupper(*string);
string++;
static const struct util_prg prg = {
.desc = "z/VM CP command interface",
.args = "CP-command",
.copyright_vec = {
{
.owner = "IBM Corp.",
.pub_first = 2005,
.pub_last = 2018,
},
UTIL_PRG_COPYRIGHT_END
}
}
};
/* Parse STRING for buffer size in bytes, allowing size modifier suffix 'k' and
* 'm'. Return buffer size in bytes on success, -1 on error. */
@@ -95,17 +120,18 @@ static int parse_args(int argc, char **argv)
int index;
do {
opt = getopt_long(argc, argv, opt_string, options, NULL);
opt = util_opt_getopt_long(argc, argv);
switch (opt) {
case -1:
/* Reached end of parameter list. */
break;
case 'h':
print_help(argv[0]);
exit(VMCP_OK);
util_prg_print_help();
util_opt_print_help();
exit(EXIT_SUCCESS);
case 'v':
print_version(argv[0]);
exit(VMCP_OK);
util_prg_print_version();
exit(EXIT_SUCCESS);
case 'k':
keep_case = 1;
break;
@@ -137,7 +163,8 @@ static int parse_args(int argc, char **argv)
strcat(command, argv[index]);
}
if (strlen(command) == 0) {
print_help(argv[0]);
util_prg_print_help();
util_opt_print_help();
return VMCP_OPT;
}
return VMCP_OK;
@@ -148,25 +175,6 @@ static inline void linux_error(const char *message)
fprintf(stderr, "Error: %s: %s\n", message, strerror(errno));
}
/* Read at most COUNT bytes from FD into memory at location BUF. Return
* number of bytes read on success, -1 on error. */
static ssize_t read_buffer(int fd, char *buf, size_t count)
{
ssize_t ret;
ssize_t done;
for (done = 0; done < (ssize_t) count; done += ret) {
ret = read(fd, &buf[done], count - done);
if (ret == -1 && errno == EINTR)
continue;
if (ret == -1)
return -1;
if (ret == 0)
break;
}
return done;
}
/* Write COUNT bytes to FD from memory at location BUF. Return number of bytes
* written on success, -1 otherwise. */
static ssize_t write_buffer(int fd, const char *buf, size_t count)
@@ -188,77 +196,54 @@ static ssize_t write_buffer(int fd, const char *buf, size_t count)
int main(int argc, char **argv)
{
struct vmcp_parm cp;
int ret;
int fd;
int response_code;
int response_size;
char *buffer;
util_prg_init(&prg);
util_opt_init(opt_vec, NULL);
ret = parse_args(argc, argv);
if (ret != VMCP_OK)
return ret;
if (!keep_case)
uppercase(command);
cp.buffer_size = buffersize;
cp.cpcmd = command;
cp.do_upper = !keep_case;
buffer = malloc(buffersize);
if (!buffer) {
linux_error("Could not allocate return buffer");
ret = vmcp(&cp);
switch (ret) {
case VMCP_ERR_OPEN:
linux_error("Could not open device " VMCP_DEVICE_NODE);
return VMCP_LIN;
}
fd = open(DEVICE_NODE, O_RDWR);
if (fd == -1) {
linux_error("Could not open device " DEVICE_NODE);
free(buffer);
return VMCP_LIN;
}
if (ioctl(fd, VMCP_SETBUF, &buffersize) == -1) {
case VMCP_ERR_SETBUF:
linux_error("Could not set buffer size");
free(buffer);
close(fd);
return VMCP_LIN;
}
if (write(fd, command, strlen(command)) == -1) {
case VMCP_ERR_WRITE:
linux_error("Could not issue CP command");
free(buffer);
close(fd);
return VMCP_LIN;
}
if (ioctl(fd, VMCP_GETCODE, &response_code) == -1) {
case VMCP_ERR_GETCODE:
linux_error("Could not query return code");
free(buffer);
close(fd);
return VMCP_LIN;
}
if (ioctl(fd, VMCP_GETSIZE, &response_size) == -1) {
case VMCP_ERR_GETSIZE:
linux_error("Could not query response size");
free(buffer);
close(fd);
return VMCP_LIN;
}
ret = read_buffer(fd, buffer, buffersize);
if (ret == -1) {
case VMCP_ERR_READ:
linux_error("Could not read CP response");
free(buffer);
close(fd);
return VMCP_LIN;
}
write_buffer(STDOUT_FILENO, buffer, ret);
if (response_size > buffersize) {
write_buffer(STDOUT_FILENO, cp.response,
MIN(cp.response_size, cp.buffer_size));
free(cp.response);
if (ret == VMCP_ERR_TOOSMALL) {
fprintf(stderr, "Error: output (%d bytes) was truncated, try "
"--buffer to increase size\n", response_size);
free(buffer);
close(fd);
"--buffer to increase size\n", cp.response_size);
return VMCP_BUF;
}
if (response_code > 0) {
if (cp.cprc > 0) {
fprintf(stderr, "Error: non-zero CP response for command '%s': "
"#%d\n", command, response_code);
free(buffer);
close(fd);
"#%d\n", command, cp.cprc);
return VMCP_CP;
}
free(buffer);
close(fd);
return VMCP_OK;
return EXIT_SUCCESS;
}

View File

@@ -1,59 +0,0 @@
/*
* vmcp - Send commands to the z/VM control program
*
* Definitions used by vmcp
*
* Copyright IBM Corp. 2005, 2017
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#ifndef __vmcp_h__
#define __vmcp_h__
#include <getopt.h>
#include <sys/ioctl.h>
#include "lib/zt_common.h"
#define DEVICE_NODE "/dev/vmcp"
#define VMCP_GETCODE _IOR(0x10, 1, int)
#define VMCP_SETBUF _IOW(0x10, 2, int)
#define VMCP_GETSIZE _IOR(0x10, 3, int)
#define MAXBUFFER 1048576
#define MINBUFFER 4096
#define MAXCMDLEN 240
#define VMCP_OK 0
#define VMCP_CP 1
#define VMCP_BUF 2
#define VMCP_LIN 3
#define VMCP_OPT 4
static struct option options[] = {
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{"keepcase", no_argument, NULL, 'k'},
{"buffer", required_argument, NULL, 'b'},
{NULL, 0, NULL, 0}
};
static const char opt_string[] = "+hvkb:";
static const char help_text[] =
"Usage:\n"
"vmcp [-k] [-b <size>] command\n"
"vmcp [-h|-v]\n\n"
"Options:\n"
"-h or --help :Print usage information, then exit\n"
"-v or --version :Print version information, then exit\n"
"-k or --keepcase :Using this option, vmcp does not convert the command\n"
" to uppercase. The default is to translate the command\n"
" string.\n"
"-b <size> or :defines the buffer size for the response\n"
"--buffer=<size> valid values are from 4096 to 1048576 bytes\n"
" the k and M suffixes are also supported\n";
#endif

View File

@@ -5,7 +5,9 @@ LDLIBS += -lz
all: vmur
libs = $(rootdir)/libvmdump/libvmdump.a
libs = $(rootdir)/libvmdump/libvmdump.a \
$(rootdir)/libvmcp/libvmcp.a $(rootdir)/libutil/libutil.a
objects = vmur.o
vmur: $(objects) $(libs)

View File

@@ -31,9 +31,13 @@
#include "lib/vmdump.h"
#include "lib/zt_common.h"
#include "lib/util_libc.h"
#include "lib/vmcp.h"
#include "vmur.h"
#define CP_PREFIX_LEN 11
/* Program name */
static char *prog_name;
@@ -243,24 +247,6 @@ fail:
ERR_EXIT("Could not initialize signal handler (errno = %i)\n", errno);
}
/*
* Read at most COUNT bytes from FD into memory at location BUF.
* Return number of bytes read on success, -1 on error.
*/
static ssize_t read_buf(int fd, char *buf, ssize_t count)
{
ssize_t rc, len;
for (len = 0; len < count; len += rc) {
rc = read(fd, &buf[len], count - len);
if (rc == -1)
return -1;
if (rc == 0)
break;
}
return len;
}
/*
* Strip leading CP header from error message
*/
@@ -293,64 +279,63 @@ static void cperr_exit(char *cpcmd, int cprc, char *buf)
static void _cpcmd(char *cpcmd, char **resp, int *rc, int retry, int upper)
{
int fd, len, cprc, bufsize = VMCP_BUFSIZE;
char *buf;
struct vmcp_parm cp;
char cmd[MAXCMDLEN];
int ret;
strcpy(cmd, cpcmd);
if (upper)
to_upper(cmd);
cp.cpcmd = cmd;
cp.do_upper = upper;
cp.buffer_size = VMCP_DEFAULT_BUFSZ;
fd = open(VMCP_DEVICE_NODE, O_RDWR);
if (fd == -1)
retry:
ret = vmcp(&cp);
switch (ret) {
case VMCP_ERR_OPEN:
ERR_EXIT("Could not issue CP command: \"%s\"\n"
"Ensure that vmcp kernel module is loaded!\n", cmd);
do {
if (ioctl(fd, VMCP_SETBUF, &bufsize) == -1)
goto fail;
if (write(fd, cmd, strlen(cmd)) == -1)
goto fail;
if (ioctl(fd, VMCP_GETCODE, &cprc) == -1)
goto fail;
if (ioctl(fd, VMCP_GETSIZE, &len) == -1)
goto fail;
if (len <= bufsize)
break;
else if (retry)
bufsize = len;
else
ERR_EXIT("Not enough buffer space (%i/%i) for CP "
"command '%s'.\nSorry, please issue command "
"on your 3270 console!\n", len, bufsize, cmd);
} while (1);
buf = (char *) malloc(len + 1);
if (!buf)
ERR_EXIT("Out of memory for CP command '%s'\n", cmd);
memset(buf, 0, len + 1);
if (read_buf(fd, buf, len) == -1)
case VMCP_ERR_SETBUF:
goto fail;
case VMCP_ERR_WRITE:
goto fail;
case VMCP_ERR_GETCODE:
goto fail;
case VMCP_ERR_GETSIZE:
goto fail;
case VMCP_ERR_READ:
goto fail;
case VMCP_ERR_TOOSMALL:
if (retry) {
cp.buffer_size = cp.response_size;
free(cp.response);
goto retry;
}
ERR_EXIT("Not enough buffer space (%u/%u) for CP "
"command '%s'.\nSorry, please issue command "
" on your 3270 console!\n", cp.response_size,
cp.buffer_size, cmd);
}
if (rc == NULL) {
if (cprc != 0) {
if (cp.cprc != 0) {
/* caller wants us to handle the error */
cperr_exit(cmd, cprc, buf);
cperr_exit(cmd, cp.cprc, cp.response);
}
} else {
*rc = cprc;
*rc = cp.cprc;
}
if (resp)
*resp = buf;
*resp = cp.response;
else
free(buf);
close(fd);
free(cp.response);
return;
fail:
@@ -1369,30 +1354,6 @@ static void close_reader(struct vmur *info, const char *hold)
cpcmd(cmd, NULL, NULL, 0);
}
/*
* strip leading and trailing blanks
*/
static char *strstrip(char *s)
{
size_t size;
char *end;
size = strlen(s);
if (!size)
return s;
end = s + size - 1;
while (end >= s && isspace(*end))
end--;
*(end + 1) = '\0';
while (*s && isspace(*s))
s++;
return s;
}
/*
* Check whether reader can handle class of reader spool file
*/
@@ -1431,9 +1392,9 @@ static int get_filename_from_reader(struct vmur *info)
sprintf(cmd, "QUERY RDR * %s ALL SHORTDATE", info->spoolid);
cpcmd(cmd, &buf, NULL, 0);
memcpy(name, &buf[130], 8);
strstrip(name);
util_strstrip(name);
memcpy(type, &buf[140], 8);
strstrip(type);
util_strstrip(type);
free(buf);
if (strlen(name) == 0) {
ERR("Please specify name to receive "

View File

@@ -31,14 +31,6 @@ do { \
ERR_EXIT(str " can only be specified once.\n"); \
} while (0)
#define VMCP_DEVICE_NODE "/dev/vmcp"
#define VMCP_BUFSIZE 0x4000
#define VMCP_GETSIZE _IOR(0x10, 3, int)
#define VMCP_SETBUF _IOW(0x10, 2, int)
#define VMCP_GETCODE _IOR(0x10, 1, int)
#define CP_PREFIX_LEN 11
#define VMRDR_DEVICE_NODE "/dev/vmrdr-0.0.000c"
#define VMPUN_DEVICE_NODE "/dev/vmpun-0.0.000d"
#define VMPRT_DEVICE_NODE "/dev/vmprt-0.0.000e"

View File

@@ -4,9 +4,9 @@
include ../common.mak
SCRIPTS = lsdasd lstape chccwdev lszfcp cio_ignore znetconf dasdstat
USRSBIN_SCRIPTS = lsmem chmem lsluns
USRSBIN_SCRIPTS = lsluns
MANPAGES= lsdasd.8 lstape.8 chccwdev.8 lszfcp.8 lsluns.8 \
cio_ignore.8 znetconf.8 chmem.8 lsmem.8 dasdstat.8
cio_ignore.8 znetconf.8 dasdstat.8
SUB_DIRS = zcrypt scm chp css qeth
@@ -23,7 +23,7 @@ install: install-scripts install-manpages install-usrsbin-scripts $(SUB_DIRS)
install-scripts: $(SCRIPTS)
@for i in $^; do \
cat $$i | \
sed -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
sed -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
>$(DESTDIR)$(BINDIR)/$$i; \
chown $(OWNER).$(GROUP) $(DESTDIR)$(BINDIR)/$$i; \
chmod 755 $(DESTDIR)$(BINDIR)/$$i; \
@@ -32,7 +32,7 @@ install-scripts: $(SCRIPTS)
install-usrsbin-scripts: $(USRSBIN_SCRIPTS)
@for i in $^; do \
cat $$i | \
sed -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
sed -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
>$(DESTDIR)$(USRSBINDIR)/$$i; \
chown $(OWNER).$(GROUP) $(DESTDIR)$(USRSBINDIR)/$$i; \
chmod 755 $(DESTDIR)$(USRSBINDIR)/$$i; \

View File

@@ -1,334 +0,0 @@
#!/usr/bin/perl
#
# chmem - Tool to change memory hotplug status
#
# Copyright IBM Corp. 2010, 2017
#
# s390-tools is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.
#
use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case no_auto_abbrev);
use File::Basename;
my $script_name = fileparse($0);
my $online = 0;
my $offline = 0;
my $memdir = "/sys/devices/system/memory";
my $block_size = 0;
my $max_block_nr = 0;
my $devices = {};
my $dev_size;
my $blocks_per_dev = 0;
my $devs_per_block = 0;
my $ret = 0;
my @entries;
sub chmem_usage()
{
print <<HERE;
Usage: $script_name [OPTIONS] SIZE|RANGE
The $script_name command sets a particular size or range of memory online
or offline.
Specify SIZE as <size>[m|M|g|G]. With m or M, <size> specifies the memory
size in MB (1024 x 1024 bytes). With g or G, <size> specifies the memory size
in GB (1024 x 1024 x 1024 bytes). The default unit is MB.
Specify RANGE in the form 0x<start>-0x<end> as shown in the output of the
lsmem command. <start> is the hexadecimal address of the first byte and <end>
is the hexadecimal address of the last byte in the memory range.
SIZE and RANGE must be aligned to the Linux memory block size, as shown in
the output of the lsmem command.
OPTIONS
-e, --enable
Set the given RANGE or SIZE of memory online.
-d, --disable
Set the given RANGE or SIZE of memory offline.
-h, --help
Print a short help text, then exit.
-v, --version
Print the version number, then exit.
HERE
}
sub chmem_version()
{
print "$script_name: version %S390_TOOLS_VERSION%\n";
print "Copyright IBM Corp. 2010, 2017\n";
}
sub chmem_get_dev_size()
{
my ($device, $old_device, $block, $old_block) = (0, 0, 0, 0);
foreach (@entries) {
$_ =~ /memory(\d+)/;
$block = $1;
$device = `cat $_/phys_device`;
chomp($device);
if ($device > $old_device) {
$dev_size = int((($block - $old_block) * $block_size) /
($device - $old_device));
last;
}
$dev_size += $block_size;
$old_block = $block;
}
}
sub chmem_online($)
{
my $block = shift;
qx(echo online_movable > $memdir/memory$block/state 2>/dev/null);
if ($? >> 8 != 0) {
qx(echo online > $memdir/memory$block/state 2>/dev/null);
}
return $? >> 8;
}
sub chmem_offline($)
{
my $block = shift;
qx(echo offline > $memdir/memory$block/state 2>/dev/null);
return $? >> 8;;
}
sub chmem_read_attr($$$)
# parameters: state, device, block
{
my @attributes = qw(state phys_device);
foreach (0..1) {
$_[$_] = `cat $memdir/memory$_[2]/$attributes[$_]`;
chomp($_[$_]);
}
}
sub chmem_read_devices()
{
my $block = 0;
my $device = 0;
my $old_device = 0;
my $blocks = 0;
my $state;
foreach (@entries) {
$_ =~ /memory(\d+)/;
$block = $1;
chmem_read_attr($state, $device, $block);
if ($device != $old_device) {
$devices->{$old_device}->{'id'} = $old_device;
$devices->{$old_device}->{'blocks'} = $blocks;
$old_device = $device;
$blocks = 0;
}
if ($state eq "online") {
$blocks++;
}
}
$devices->{$old_device}->{'blocks'} = $blocks;
$devices->{$old_device}->{'id'} = $old_device;
}
sub chmem_dev_action($$)
{
my ($dev_id, $blocks) = @_;
my ($start_block, $end_block, $tmp_block, $max_blocks);
my $state;
my $i = 0;
my $count = 0;
if ($blocks_per_dev > 0) {
$start_block = $dev_id * $blocks_per_dev;
$end_block = $start_block + $blocks_per_dev - 1;
$max_blocks = $blocks_per_dev;
} else {
$start_block = int($dev_id / $devs_per_block);
$end_block = $start_block;
$max_blocks = 1;
}
if ($blocks > $max_blocks) {
$blocks = $max_blocks;
}
while ($count < $blocks && $i < $max_blocks) {
$tmp_block = $online ? $start_block + $i : $end_block - $i;
$state = `cat $memdir/memory$tmp_block/state`;
chomp($state);
if ($offline && $state eq "online") {
$count++ unless chmem_offline($tmp_block);
}
if ($online && $state eq "offline") {
$count++ unless chmem_online($tmp_block);
}
$i++;
}
return $count;
}
sub chmem_size($)
{
my $size = shift;
my ($blocks, $dev_blocks, $dev_id);
$blocks = int($size / $block_size);
if ($online) {
foreach my $device (sort {$b->{'blocks'} <=> $a->{'blocks'} ||
$a->{'id'} <=> $b->{'id'}}
values %{$devices}) {
$dev_blocks = $device->{'blocks'};
$dev_id = $device->{'id'};
if ($dev_blocks < $blocks_per_dev || $dev_blocks == 0) {
$blocks -= chmem_dev_action($dev_id, $blocks);
if ($blocks == 0) {
last;
}
}
}
if ($blocks > 0) {
printf(STDERR "chmem: Could only set %lu MB of memory ".
"online.\n", $size - $blocks * $block_size);
$ret = 1;
}
} else {
foreach my $device (sort {$a->{'blocks'} <=> $b->{'blocks'} ||
$b->{'id'} <=> $a->{'id'}}
values %{$devices}) {
$dev_blocks = $device->{'blocks'};
$dev_id = $device->{'id'};
if ($dev_blocks > 0) {
$blocks -= chmem_dev_action($dev_id, $blocks);
if ($blocks == 0) {
last;
}
}
}
if ($blocks > 0) {
printf(STDERR "chmem: Could only set %lu MB of memory ".
"offline.\n", $size - $blocks * $block_size);
$ret = 1;
}
}
}
sub chmem_range($$)
{
my ($start, $end) = @_;
my $block = 0;
my $state;
while ($start < $end && $block < $max_block_nr) {
$block = int($start / ($block_size << 20));
$state = `cat $memdir/memory$block/state`;
chomp($state);
if ($online && $state eq "offline") {
if (chmem_online($block)) {
printf(STDERR "chmem: Could not set ".
"0x%016x-0x%016x online\n", $start,
$start + ($block_size << 20) - 1);
$ret = 1;
}
}
if ($offline && $state eq "online") {
if (chmem_offline($block)) {
printf(STDERR "chmem: Could not set ".
"0x%016x-0x%016x offline\n", $start,
$start + ($block_size << 20) - 1);
$ret = 1;
}
}
$start += $block_size << 20;
}
}
sub chmem_check()
{
$block_size = `cat $memdir/block_size_bytes`;
chomp($block_size);
if ($block_size =~ /(?:0x)?([[:xdigit:]]+)/) {
$block_size = unpack("Q", pack("H16",
substr("0" x 16 . $1, -16)));
$block_size = $block_size >> 20;
} else {
die "chmem: Unknown block size format in sysfs.\n";
}
if ($online == 0 && $offline == 0) {
die "chmem: Please specify one of the options -e or -d.\n";
}
if ($online == 1 && $offline == 1) {
die "chmem: You cannot specify both options -e and -d.\n";
}
chmem_get_dev_size();
if ($dev_size >= $block_size) {
$blocks_per_dev = int($dev_size / $block_size);
} else {
$devs_per_block = int($block_size / $dev_size);
}
}
sub chmem_action()
{
my ($start, $end, $size, $unit);
if (!defined($ARGV[0])) {
die "chmem: Missing size or range.\n";
}
if ($ARGV[0] =~ /^0x([[:xdigit:]]+)-0x([[:xdigit:]]+)$/) {
$start = unpack("Q", pack("H16", substr("0" x 16 . $1, -16)));
$end = unpack("Q", pack("H16", substr("0" x 16 . $2, -16)));
if ($start % ($block_size << 20) ||
($end + 1) % ($block_size << 20)) {
die "chmem: Start address and (end address + 1) must ".
"be aligned to memory block size ($block_size MB).\n";
}
chmem_range($start, $end);
} else {
if ($ARGV[0] =~ m/^(\d+)([mg]?)$/i) {
$size = $1;
$unit = $2 || "";
if ($unit =~ /g/i) {
$size = $size << 10;
}
if ($size % $block_size) {
die "chmem: Size must be aligned to memory ".
"block size ($block_size MB).\n";
}
chmem_size($size);
} else {
printf(STDERR "chmem: Invalid size or range: %s\n",
$ARGV[0]);
exit 1;
}
}
}
# Main
unless (GetOptions('v|version' => sub {chmem_version(); exit 0;},
'h|help' => sub {chmem_usage(); exit 0;},
'e|enable' => \$online,
'd|disable' => \$offline)) {
die "Try '$script_name --help' for more information.\n";
};
@entries = (sort {length($a) <=> length($b) || $a cmp $b} <$memdir/memory*>);
if (@entries == 0) {
die "chmem: No memory hotplug interface in sysfs ($memdir).\n";
}
$entries[-1] =~ /memory(\d+)/;
$max_block_nr = $1;
chmem_read_devices();
chmem_check();
chmem_action();
exit $ret;

Some files were not shown because too many files have changed in this diff Show More