Compare commits

...

416 Commits

Author SHA1 Message Date
Jan Höppner
bf9fd47918 New release s390-tools-2.9.0
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 15:13:36 +02:00
Jan Höppner
5aec1dc2a1 cpuplugd: Always free file pointer
The file pointer in the functions is_online() and cpu_is_configured() is
only freed in the good case. Make sure it is always freed.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:17:40 +02:00
Jan Höppner
cf730a9632 zipl: Fix compile warning
bootmap.c: In function ‘check_secure_boot_support’:
bootmap.c:131:2: warning: ignoring return value of ‘fscanf’, declared
with attribute warn_unused_result [-Wunused-result]
  fscanf(fp, "%d", &val);
  ^~~~~~~~~~~~~~~~~~~~~~

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:17:40 +02:00
Jan Höppner
73bab8e1a1 zpcictl: Fix compile warning
zpcictl.c: In function ‘sysfs_read_value’:
zpcictl.c:154:2: warning: ignoring return value of ‘fscanf’, declared with
attribute warn_unused_result [-Wunused-result]
  fscanf(fp, "%x", &val);
  ^~~~~~~~~~~~~~~~~~~~~~

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:17:40 +02:00
Ingo Franzki
f97d048643 zkey: Allow to associate non-existing APQNs with a key
Add option --no-apqn-check to the generate, import, change, and
validate commands to disable checking of the specified APQNs.

With this option a currently non-existing APQN can be associated
with a key. This is useful to associate APQNs that exist only on
other systems, such as disaster recovery systems, but not on the
current system. When generating keys, at least one of the specified
APQNs must be available to generate the key.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Steffen Maier
d8c630e5f4 zfcpdbf: warn about ambiguous payload records with dup reqid & payarea
Function get_payload_records() reading from disk, blindly adds payload
record (junks) to a list in a 2-stage hierarchical hash keyed with
request ID and PAY area.

On adapter offline/online, zfcp resets the request ID to re-start with 1.
Hence it's not a unique foreign key in the lifetime of the PAY area.

The last payload record (junks) read for the same request ID and PAY area
is the one printed as named PAY field in the tool output.
This is not necessarily the chronologically last record due to PAY area
wrapping.

With this workaround, we:
* warn on reading PAY records if ambiguous entries occurred,
* print additional PAY timestamps which the user can compare
  with the actual trace record timestamps to determine if they are close
  enough to indicate a match.

We only found this by accident because we kept "short" "payload" being a
built-in part of some actual trace record types in areas HBA, SAN, SCSI.
For above cases, the full PAYload did not match the
built-in "short" "payload".

While at it, also add a comment that PAY output can also be wrong
in another case when junks of multi-part PAY records are missing due
to PAY area wrapping.

Below is an abbreviated example output with this workaround:

Loading trace records ...(this might take a while)
Warning: Ambiguous PAYload records. reqid:0000000000000037 area:san_res

...

Timestamp      : 2017-07-07-18:01:34:574827
Area           : SAN
...
Tag            : fssct_1
Request ID     : 0x0000000000000037
Destination ID : 0x00fffffc
SAN req short  : 01000000 fc020000 01720ffc 00000000
                 00000008
SAN req length : 20

Timestamp      : 2017-07-07-18:01:34:619310         ------------------+
Area           : SAN                                                  |
...                                                                   |
Tag            : fsscth2                                              |
Request ID     : 0x0000000000000037                                   |
Destination ID : 0x00fffffc                                           |
SAN resp short : 01000000 fc020000 80020000 00000000                  |
                 00671a07 00000000 c05076ff d6801850                  |
                 00671a7e 00000000 c05076ff d6801968                  |
SAN resp length: 16384                                                |
Payload time   : 2017-07-07-18:16:17:165708          <== does not match
San resp info  : 01000000 fc020000 80020000 00000000 <== wrong
                 4a49424d 20202020 20323936 34202020 <== wrong
                 20202020 20202020 20303230 30303030 <== wrong
                 30303745 43383720 20504348 49443a20 <== wrong
                 30313938 204e5049 5620556c 7049643a <== wrong
                 20303536 30303330 30202020 00000000 <== wrong
                 00000000 00000000 00000000 00000000 <== wrong
                 ...                                 <== wrong

...

Timestamp      : 2017-07-07-18:16:17:165713
Area           : SAN
...
Tag            : fsscth2
Request ID     : 0x0000000000000037             <== same reqid & pay "area"
Destination ID : 0x00fffffc
SAN resp short : 01000000 fc020000 80020000 00000000
                 4a49424d 20202020 20323936 34202020
                 20202020 20202020 20303230 30303030
SAN resp length: 273
Payload time   : 2017-07-07-18:16:17:165708          <== 2nd & last, match
                                                         close to Timestamp
San resp info  : 01000000 fc020000 80020000 00000000
                 4a49424d 20202020 20323936 34202020
                 20202020 20202020 20303230 30303030
                 30303745 43383720 20504348 49443a20
                 30313938 204e5049 5620556c 7049643a
                 20303536 30303330 30202020 00000000
                 00000000 00000000 00000000 00000000
                 ...

Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Heiko Carstens
45132ce1ee libutil: fix build breakage
/usr/bin/ld: ../..//libutil/libutil.a(util_sys.o): in function `util_sys_get_dev_addr':
/home/builder/s390-tools/libutil/util_sys.c:52: undefined reference to `major'
/usr/bin/ld: /home/builder/s390-tools/libutil/util_sys.c:53: undefined reference to `minor'
collect2: error: ld returned 1 exit status
make[2]: *** [../../common.mak:243: zipl] Error 1
make[1]: *** [Makefile:8: all] Error 2
make: *** [Makefile:52: zipl] Error 2

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Jan Höppner
57a797350c libu2s: Remove the library
There are no users of libu2s anymore. Remove it.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Jan Höppner
75e3afb6a0 libdasd: Move get_host_access_count() to libdasd
Reading DASD specific sysfs attributes should be collected in one
library. Move get_host_access_count() to libdasd/dasd_sys.

Remove the old implementation and update any user accordingly.
Also, fix the build order for zdsfs.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Jan Höppner
7915c9257b zpcictl: Use libutil to identify the slot id of a device
Rather than using an own implementation, use util_sys_get_dev_addr()
provided by libutil instead.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Jan Höppner
6014d07cb1 dasdview/libdasd/zipl: Use util_sys_get_dev_addr() instead of u2s_getbusid()
Use the newer and more robust libutil provided function
util_sys_get_dev_addr() to identify a device address for any former user
of u2s_getbusid().

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Jan Höppner
5d2ebe5301 libutil: Introduce util_sys and util_sys_get_dev_addr()
Many tools need to identify the device address of a given device. So
far, either the tool had its own implementation, or u2s_getbusid() was
used. Though, u2s_getbusid() was mainly designed for and used by the
DASD tools.

Introduce util_sys with a first function util_sys_get_dev_addr() which
provides a more universal way to identify the device address which is
not limited to one particular device type. The device address represents
either a busid (e.g. DASD), slot address (NVMe), H:C:T:L tuple (SCSI),
or other id types associated with a device.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Jan Höppner
ab510cff39 libdasd: Provide definition for bus id size
dasdview and libdasd deal with DASD bus ids and should use a definition
for the size. libu2s already provides a definition, which is used by
dasdview. However, the size of 32 is a bit much and the definition
should be part of libdasd.

Including the terminating null byte ('\0') and considering a DASD bus id
length of 8 characters (e.g. 0.0.4711), this leads to a size of 9.

Provide such a definition via libdasd and update any user.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Jan Höppner
8c06dea4e5 libdasd: Use util_path_sysfs() to construct sysfs paths
Don't rely on rather arbitrary values for the string buffer size of
different sysfs paths. Instead use util_path_sysfs(), which allocates
the exact amount of memory necessary for a certain path string.

As these path strings are dynamically constructed, potential buffer
overflows can hereby be avoided and make the library functions more
robust.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Dan Horák
0efacac5b8 zipl: update stage3 objcopy command for gcc9
The objcopy command for stage3.bin needs to take the new rodata section
into account.
See also PR https://github.com/ibm-s390-tools/s390-tools/pull/60.

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/61
Signed-off-by: Dan Horák <dan@danny.cz>
Acked-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Stefan Haberland
6ea645b345 zipl: add secure boot man page updates
Add zipl and zipl.conf man page updates.

The zipl man page will look like:

       -S <SWITCH> or --secure <SWITCH>
               Control the zIPL secure boot support.  <SWITCH> can take one of three values:

                 auto (default)
                   Write signatures if available and supported by the system.
                 1
                   Signatures are written independent of support indicated by the local
                   system. Also missing signatures for stage 3 and kernel IPL files
                   will result in an error.
                 0
                   No signatures will be written.

The zipl.conf man page will look like:

       secure = auto/1/0 (configuration only)

              Configuration section:
              Control the zIPL secure boot support.  Set this option to one of the following:

                -  auto: Write signatures if available and supported by the system.

                -  1: Signatures are written independent of support indicated by the local system.
		   Also missing signatures for stage 3 and kernel IPL files will result in an error.

                -  0: No signatures will be written.

                   The default value for 'secure' is auto.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-29 17:17:48 +02:00
Stefan Haberland
331b54d573 zipl: secure boot - verify load address
To ensure that only verified code is executed the stage 3 loader has
to check if the load psw points to an address that has previously been
verified by the machine loader.

If secure boot is enabled the IPL process will only continue if the
verification was successful.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-29 17:17:45 +02:00
Stefan Haberland
7e7a77675d zipl: re-order variable declaration
For better readbility re-arrange the variable declaration.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-29 17:17:42 +02:00
Stefan Haberland
dc2e439550 zipl: add dummy section for stage3 heap and stack
The firmware needs to know which memory locations are used by
the stage 3 loader so that it can allocate its own memory.
To indicate the usage of the heap and stack area of the stage 3 loader
add a dummy component to block this memory area for the firmware.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-29 17:17:40 +02:00
Stefan Haberland
75d4317f20 zipl: pad stage3 binary
The stage 3 loader size has to be a multiple of the filesystem
blocksize so that the signature maps with the later in memory
stage 3 loader. The lowest common blocksize is 4k so the image
is padded to a 4k boundary.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-29 17:17:37 +02:00
Stefan Haberland
58a7462f65 zipl: add secure boot switch
Add a command line option and configuration section keyword to control
the zIPL secure boot support. This option is named "secure" and can take
one of three values:

  auto (default)
    Write signatures if available and supported by the system.
  1
    Signatures are written independent of support indicated by the local
    system. Also missing signatures for stage 3 and kernel IPL files
    will result in an error.
  0
    No signatures will be written.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-29 17:17:33 +02:00
Stefan Haberland
7c7e10ed8f zipl: detect signed files and create bootmap components
Add support for parsing IPL file signatures as produced by the Linux
kernel's sign-file tool. When preparing a disk for IPL, the signatures
will be added as separate data components that can be used by the Secure
Boot firmware feature to validate the integrity of the IPL files.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-29 17:17:30 +02:00
Stefan Haberland
0c1a63ce5e zipl: dynamically build component name array
Change the fixed component entry text array to a more dynamic approach
to allow easier extension and make the order changeable.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-29 17:17:25 +02:00
Stefan Haberland
6825645a21 zipl: Move stage 3 loader to external file
The first component that gets control after IPL is the zIPL-provided
stage 3 boot loader. This boot loader is based on a binary image linked
into the zIPL executable. When preparing a disk for IPL, zIPL updates
runtime parameters in the boot loader image and writes the resulting
data to disk.

To support the Secure Boot firmware feature, the stage 3 code must be
signed, and can therefore no longer contain variable parameter portions.
Also the boot loader image should be accessible as a separate file to
enable the use of external programs for creating the signature.

This patch moves the stage 3 boot loader code to an external file
location and splits out the parameter portion into a separate, unsigned
on-disk component.

The new memory layout of the stage 3 loader during its execution looks
as follows:

 * 0x0000-0x1fff        Lowcore
 * 0x2000-0x5fff        Memory allocation (heap)
 * 0x7000-0x8fff        free
 * 0x9000-0x9fff        Stage3 parameter
 * 0xa000-0xcfff        Stage3 code
 * 0xd000-0xefff        Section: bss, rodata, data
 * 0xf000-0xffff        Stack

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-29 17:17:21 +02:00
Stefan Haberland
e764f460c4 zipl: Do not strip kernel image IPL header
The binary Linux kernel image is built to be loaded to memory address
0x0 but the first 64 kbyte contain an IPL header that is not used for
disk IPL. zIPL strips away this IPL header when writing IPL records to
disk, loads the remaining data to memory address 0x10000 and uses the
memory area below that for its own boot loader code.

The Secure Boot firmware feature checks the integrity of an installed
image during IPL using a checksum that was generated for the full image.
Since the checksum becomes invalid if the IPL header is removed, zIPL
must be changed to write the full image to disk.

This patch modifies the zIPL logic to no longer strip away the IPL
header. Instead the full image is loaded to a higher memory address and
relocated by the stage 3 boot loader code to its final location.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-29 17:17:16 +02:00
Jan Höppner
63089835b0 README.md: Add runtime requirement for dbginfo.sh
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-29 17:17:16 +02:00
Ingo Franzki
e4cd42900f zkey: Fix a problem with changing a volume association of a key
When a 'zkey change' command is used to change (i.e. set) the volume
association of a key, and the new volume association contains a volume
that is already assigned to the key to be changed, the command fails
with an error that the volume is already associated to the key.

This commit fixes the problems and allows to set such a volume
association. When setting a new association the current association of
the key to be changed is of no relevance, since the set operation
replaces the current association with the new association.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-15 15:17:55 +02:00
Stefan Raspl
7f033938b8 lschp: add support for specifying a CHPID
We keep things simple and allow for only a single CHPID to be specified.

Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
Reviewed-by: Sebastian Ott <sebott@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-15 15:16:25 +02:00
Fedor Loshakov
f2dee9f542 ziomon: fix utilization data recording with multi-digit scsi hosts
s390-tools-1.9.0 introduced a new way of recognizing of multipath
device paths with using of sed command invocation in ziomon script.
With this new way of recognizing, if there are paths, related to
multipath device, with SCSI host ID longer, than one digit,
ziomon incorrectly parses the multipath -l command output. It
erroneously cuts off all but the least significant digit of the
SCSI host ID (H) of paths in H:B:T:L format (Host:Bus:Target:Lun).
This leads to passing of hosts (-a) and paths (-l) with
non-existing SCSI host ID to ziomon_util. In turn ziomon_util
cannot recognize hosts with non-existing SCSI host ID and issues
an error.

Also, wrong sed command invocation could lead to receiving of
duplicate LUNs by ziomon after parsing of multipath -l command
output. Then ziomon excludes duplicates from WRP_LUNS, which
leads to mismatch between number of LUNs and number of detected
block devices and issues ziomon script error, without starting
ziomon_util and without writing to specified log file.

The regular expression to match a path in H:B:T:L format started
with a greedy ".*", which erroneously consumed parts of the SCSI
host ID (H). This patch replaces the greedy ".*" by "[^0-9]*",
so that sed command does not consume parts of the SCSI host ID
any more.

Test example with unique SCSI host IDs:
$ multipath -l
...
mpathc (36005076307ffc5e300000000000083f5) dm-2 IBM     ,2107900
size=20G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='service-time 0' prio=0 status=active
  |- 10:0:0:1089814659 sdb 8:16  active undef running
  `- 11:0:0:1089814659 sdf 8:80  active undef running
...

Behavior without fix applied:
$ ziomon -d 5 -o log /dev/mapper/mpathc
Check devices...done
NOTE: No size limit specified, run without a limit.
Estimated maximum disk space required for log data: approx. <1 MBytes
Collecting configuration data...done
Start data collection processes...ziomon_util: Path does not exist: /sys/class/scsi_host/host0/utilization - correct kernel version?
ziomon_util: Path does not exist: /sys/class/scsi_host/host0/utilization - correct kernel version?
ziomon_util: Path does not exist: /sys/class/scsi_host/host0/queue_full - correct kernel version?
ziomon_util: Path does not exist: /sys/class/scsi_host/host1/utilization - correct kernel version?
ziomon_util: Path does not exist: /sys/class/scsi_host/host1/queue_full - correct kernel version?
failed
ziomon: Failed to determine ziomon_util pid
Shutting down
Shutting down blktrace process
Shutting down blkiomon process
Shutting down ziomon_zfcpdd process
blkiomon: terminated by signal
Shutting down data manager

User can see more information, when using ziomon with -V option:
...
=== WRP_LUNS         : 0:0:0:1089814659 1:0:0:1089814659
=== WRP_HOST_ADAPTERS: host0 host1
...
=== starting ziomon_util: ziomon_util -V  -a 0 -a 1  -l 0:0:0:1089814659 -l 1:0:0:1089814659 ...
...

User can also see this type of errors, while using
ziorep_traffic or ziorep_utilization tools:
$ ziorep_traffic -t1 log.log
Extracting config data...done
ziorep_traffic: Could not retrieve initial data - data files corrupted or broken, or the .agg file is missing.

Behavior with fix applied:
$ ziomon -d 5 -o log /dev/mapper/mpathc
Check devices...done
NOTE: No size limit specified, run without a limit.
Estimated maximum disk space required for log data: approx. <1 MBytes
Collecting configuration data...done
Start data collection processes...done
Collecting data...done
Shutting down
Shutting down data manager

User can see more information, when using ziomon with -V option:
...
=== WRP_LUNS         : 10:0:0:1089814659 11:0:0:1089814659
=== WRP_HOST_ADAPTERS: host10 host11
...
=== starting ziomon_util: ziomon_util -V  -a 10 -a 11  -l 10:0:0:1089814659 -l 11:0:0:1089814659 ...
...

Test example with duplicate SCSI host IDs:
$ multipath -l
...
mpathc (36005076307ffc5e300000000000083f5) dm-1 IBM     ,2107900
size=20G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='service-time 0' prio=0 status=active
  |- 0:0:0:1089814659  sdb 8:16  active undef running
  `- 10:0:0:1089814659 sdf 8:80  active undef running
...

Behavior without fix applied:
$ ziomon -d 5 -o log /dev/mapper/mpathc
Check devices...done
ziomon: Number of LUNs does not match number of devices: 2 devices and 1 LUNs

User can see more information, when using ziomon with -V option:
...
    === #Devices total   : 2
    === WRP_DEVICES      : /dev/sdb /dev/sdf
    === WRP_LUNS         : 0:0:0:1089814659
    === WRP_HOST_ADAPTERS: host0
...

Behavior with fix applied:
$ ziomon -d 5 -o log /dev/mapper/mpathc
Check devices...done
NOTE: No size limit specified, run without a limit.
Estimated maximum disk space required for log data: approx. <1 MBytes
Collecting configuration data...done
Start data collection processes...done
Collecting data...done
Shutting down
Shutting down data manager

User can see more information, when using ziomon with -V option:
...
=== #Devices total   : 2
=== WRP_DEVICES      : /dev/sdb /dev/sdf
=== WRP_LUNS         : 0:0:0:1089814659 10:0:0:1089814659
=== WRP_HOST_ADAPTERS: host0 host10
...
=== starting ziomon_util: ziomon_util -V  -a 0 -a 10  -l 0:0:0:1089814659 -l 10:0:0:1089814659 ...
...

Signed-off-by: Fedor Loshakov <loshakov@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-11 13:19:36 +02:00
Jan Höppner
c7a255fcd9 zpcictl: Check for regular directory
In case a regular directory was specified, rather than a device node,
the check if the device exists will pass. The following code paths then
assume a slot id was specified. This in turn may lead to a buffer
overflow when the device data is copied to to the zpci_device struct.

Check if the specified path is a regular directory and prevent a
possible later buffer overflow and copying wrong data respectively.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-04-01 12:41:17 +02:00
Steffen Maier
be7b854969 lszfcp: also mark FCP devices (hosts) that are not available
Also mark FCP devices with CHPID that is logically varied off,
e.g. after running "chchp -v 0 60".
Such FCP devices can be online, not failed, and are not defunct,
so the other existing markers do not appear.

Shows potential issues with FCP devices at one glance.

Examples:

$ lszfcp -He
0.0.1900 host0 NotAvailable

$ lszfcp -HeV
/sys/devices/css0/0.0.010d/0.0.1900 NotAvailable
/sys/class/fc_host/host0
/sys/class/scsi_host/host0

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Complements: 4036e80b26 ("lszfcp: add new output marker for non-good FCP devices (hosts)")
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-27 14:57:40 +01:00
Jan Höppner
05a0f8e0eb gitignore: Add zcryptstats
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Ingo Franzki
43fcb694bf zcryptstats: add new tool to readme
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Ingo Franzki
8be43a1f16 zcryptstats: Add man page
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Ingo Franzki
7b4a05e5a3 zcryptstats: Add new zcryptstats tool
The zcryptstats tool displays usage statistics of IBM Crypto Express
adapters. It obtains cryptographic performance measurement data
periodically and displays the data for each cryptographic device for
each interval. A cryptographic device can be either a card device or
a queue device (APQN).

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Steffen Maier
9911a95144 CHANGELOG: lszfcp: fix regressions
Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Steffen Maier
9c56255a70 lszfcp: new command line option to show module parameters
I often use "systool -v -m zfcp" but that's a bit longish to type
and contains more output than just the parameters I'm interested in.
"tail /sys/module/zfcp/parameters/*" is also not so nice.
"lszfcp -Z" makes it very easy and can be combined with the other
existing output options of lszfcp.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Steffen Maier
a20cabccc4 lszfcp: sdev attributes for scsi_disk, block, integrity, queue, iosched
Show if command line option for more attribute details specified twice
and depending on existence in sysfs (i.e. not for non-disk such as tape).

Abbreviated examples:

$ lszfcp -DVeamm
/sys/devices/css0/0.0.0019/0.0.1880/0x50050763031bd327/0x4045400300000000
/sys/bus/ccw/drivers/zfcp/0.0.1880/host2/rport-2:0-0/target2:0:0/2:0:0:1073954885
/sys/block/sdd /sys/class/scsi_generic/sg3
Class = "zfcp_unit"
    access_denied       = "0"
    access_readonly     = "0"
    access_shared       = "0"
    failed              = "0"
    in_recovery         = "0"
    status              = "0x54000000"
Class = "scsi_device"
    ...
    modalias            = "scsi:t-0x00"
    model               = "2107900"
    scsi_level          = "6"
    state               = "running"
    type                = "0"
    ...
    zfcp_access_denied  = "0"
    zfcp_failed         = "0"
    zfcp_in_recovery    = "0"
    zfcp_status         = "0x54000000"
Class = "scsi_disk"
    allow_restart       = "0"
    app_tag_own         = "1"
    cache_type          = "write back"
    FUA                 = "0"
    manage_start_stop   = "0"
    max_medium_access_timeouts = "2"
    max_write_same_blocks = "65535"
    protection_mode     = "dix1"
    protection_type     = "1"
    provisioning_mode   = "unmap"
    thin_provisioning   = "1"
    zeroing_mode        = "writesame"
Class = "block"
    alignment_offset    = "0"
    capability          = "50"
    dev                 = "8:48"
    discard_alignment   = "0"
    size                = "2097152"
    ...
    uevent              = "MAJOR=8"
Class = "block_integrity"
    device_is_integrity_capable = "1"
    format              = "T10-DIF-TYPE1-IP"
    protection_interval_bytes = "512"
    read_verify         = "1"
    tag_size            = "2"
    write_generate      = "1"
Class = "block_queue"
    add_random          = "1"
    chunk_sectors       = "0"
    dax                 = "0"
    discard_granularity = "1073741824"
    discard_max_bytes   = "4294966784"
    discard_max_hw_bytes = "4294966784"
    discard_zeroes_data = "0"
    hw_sector_size      = "512"
    io_poll             = "0"
    io_poll_delay       = "0"
    iostats             = "1"
    logical_block_size  = "512"
    max_discard_segments = "1"
    max_hw_sectors_kb   = "1076"
    max_integrity_segments = "269"
    max_sectors_kb      = "1076"
    max_segments        = "269"
    max_segment_size    = "4096"
    minimum_io_size     = "512"
    nomerges            = "0"
    nr_requests         = "128"
    optimal_io_size     = "0"
    physical_block_size = "512"
    read_ahead_kb       = "512"
    rotational          = "1"
    rq_affinity         = "1"
    scheduler           = "noop [deadline] cfq"
    write_cache         = "write back"
    write_same_max_bytes = "33553920"
    write_zeroes_max_bytes = "33553920"
    zoned               = "none"
Class = "block_queue_iosched"
    fifo_batch          = "16"
    front_merges        = "1"
    read_expire         = "500"
    write_expire        = "5000"
    writes_starved      = "2"

/sys/devices/css0/0.0.0222/0.0.3c80/0x2002000e1115c62f/0x0000000000000000
/sys/bus/ccw/drivers/zfcp/0.0.3c80/host4/rport-4:0-2/target4:0:2/4:0:2:0
Class = "zfcp_unit"
    access_denied       = "0"
    access_readonly     = "0"
    access_shared       = "0"
    failed              = "0"
    in_recovery         = "0"
    status              = "0x54000000"
Class = "scsi_device"
    ...
    modalias            = "scsi:t-0x01"
    model               = "ULT3580-TD6"
    scsi_level          = "7"
    state               = "running"
    type                = "1"
    ...
    zfcp_access_denied  = "0"
    zfcp_failed         = "0"
    zfcp_in_recovery    = "0"
    zfcp_status         = "0x54000000"

/sys/devices/css0/0.0.0222/0.0.3c80/0x2002000e1115c62f/0x0001000000000000
/sys/bus/ccw/drivers/zfcp/0.0.3c80/host4/rport-4:0-2/target4:0:2/4:0:2:1
Class = "zfcp_unit"
    access_denied       = "0"
    access_readonly     = "0"
    access_shared       = "0"
    failed              = "0"
    in_recovery         = "0"
    status              = "0x54000000"
Class = "scsi_device"
    ...
    modalias            = "scsi:t-0x08"
    model               = "3573-TL"
    scsi_level          = "6"
    state               = "running"
    type                = "8"
    ...
    zfcp_access_denied  = "0"
    zfcp_failed         = "0"
    zfcp_in_recovery    = "0"
    zfcp_status         = "0x54000000"

/sys/devices/css0/0.0.0222/0.0.3c80/0x500507630313d327/0xffffffffffffffff failed
-
Class = "zfcp_unit"
    access_denied       = "0"
    access_readonly     = "0"
    access_shared       = "0"
    failed              = "1"
    in_recovery         = "0"
    status              = "0x00000000"

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Steffen Maier
f67758160e lszfcp: allow to show zfcp_units without associated SCSI device
Useful to detect configuration errors and FCP LUN typos.

Example:

$ lszfcp -De
0.0.3c80/0x500507630313d327/0xffffffffffffffff - failed

$ lszfcp -DeV
/sys/devices/css0/0.0.0222/0.0.3c80/0x500507630313d327/0xffffffffffffffff failed
-

$ lszfcp -Deam
0.0.3c80/0x500507630313d327/0xffffffffffffffff - failed
Class = "zfcp_unit"
    access_denied       = "0"
    access_readonly     = "0"
    access_shared       = "0"
    failed              = "1"
    in_recovery         = "0"
    status              = "0x00000000"

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Steffen Maier
e84287e76e lszfcp: attribute details for: css, zfcp_port, zfcp_unit
Consistency with "lszfcp -Ha" which includes zfcp_adapter as class=ccw.
Attribute details are especially useful to show the driver-internal status.

For FCP devices (hosts), "css" shows subchannel details including CHPID.

Abbreviated examples:

$ lszfcp -PVeam -b 0.0.50c0 -p 0x500507680b2481fa
- (NoMoreZfcpPort:0.0.50c0/0x500507680b2481fa)
/sys/class/fc_remote_ports/rport-6:0-2 NotOnline
Class = "fc_remote_ports"
    dev_loss_tmo        = "60"
    fast_io_fail_tmo    = "off"
    maxframe_size       = "2048 bytes"
    node_name           = "0x500507680b0081fa"
    port_id             = "0x242200"
    port_name           = "0x500507680b2481fa"
    port_state          = "Blocked"
    roles               = "FCP Target"
    scsi_target_id      = "2"
    supported_classes   = "Class 2, Class 3"

$ lszfcp -HPDeam
0.0.1900 host0
Bus = "css"
    chpids              = "60 00 00 00 00 00 00 00"
    modalias            = "css:t0"
    pimpampom           = "80 80 ff"
    type                = "0"
    uevent              = "DRIVER=io_subchannel"
    vpm                 = "80"
Bus = "ccw"
    availability        = "good"
    ...
    failed              = "0"
    in_recovery         = "0"
    online              = "1"
    status              = "0x5400040b"
    ...
Class = "fc_host"
    ...
    port_state          = "Online"
    port_type           = "NPIV VPORT"
    ...
Class = "scsi_host"
    ...
    state               = "running"
    ...

0.0.1940 host8 offline
Bus = "css"
    chpids              = "61 00 00 00 00 00 00 00"
    modalias            = "css:t0"
    pimpampom           = "80 80 ff"
    type                = "0"
    uevent              = "DRIVER=io_subchannel"
    vpm                 = "80"
Bus = "ccw"
    availability        = "good"
    ...
    failed              = "0"
    in_recovery         = "0"
    online              = "0"
    status              = "0x00000401"
    ...
Class = "fc_host"
    ...
    port_state          = "Unknown"
    port_type           = "NPIV VPORT"
    ...
Class = "scsi_host"
    ...
    state               = "running"
    ...

0.0.5000 host1 offline
Bus = "css"
    chpids              = "67 00 00 00 00 00 00 00"
    modalias            = "css:t0"
    pimpampom           = "80 80 ff"
    type                = "0"
    uevent              = "DRIVER=io_subchannel"
    vpm                 = "80"
Bus = "ccw"
    availability        = "good"
    ...
    failed              = "0"
    in_recovery         = "0"
    online              = "0"
    status              = "0x00000401"
    uevent              = "DRIVER=zfcp"
    ...
Class = "fc_host"
    ...
    port_state          = "Unknown"
    port_type           = "NPort (fabric via point-to-point)"
    ...
Class = "scsi_host"
    ...
    state               = "running"
    ...

0.0.3c40 host7 defunct
Bus = "css"
    defunct
Bus = "ccw"
    availability        = "no device"
    ...
    failed              = "0"
    in_recovery         = "0"
    online              = "1"
    status              = "0x00000401"
    ...
Class = "fc_host"
    ...
    port_state          = "Unknown"
    port_type           = "NPIV VPORT"
    ...
Class = "scsi_host"
    ...
    state               = "running"
    ...

0.0.1880 - offline
Bus = "css"
    chpids              = "5a 00 00 00 00 00 00 00"
    modalias            = "css:t0"
    pimpampom           = "80 80 ff"
    type                = "0"
    uevent              = "DRIVER=io_subchannel"
    vpm                 = "00"
Bus = "ccw"
    availability        = "good"
    cmb_enable          = "0"
    cutype              = "1731/03"
    devtype             = "1732/03"
    modalias            = "ccw:t1731m03dt1732dm03"
    online              = "0"
    uevent              = "DRIVER=zfcp"

0.0.1900/0x500507630708c5e3 rport-0:0-0
Class = "zfcp_port"
    access_denied       = "0"
    failed              = "0"
    in_recovery         = "0"
    status              = "0x54000001"
Class = "fc_remote_ports"
    dev_loss_tmo        = "2147483647"
    fast_io_fail_tmo    = "5"
    maxframe_size       = "2112 bytes"
    node_name           = "0x5005076307ffc5e3"
    port_id             = "0x675c00"
    port_name           = "0x500507630708c5e3"
    port_state          = "Online"
    roles               = "FCP Target"
    scsi_target_id      = "0"
    supported_classes   = "Class 2, Class 3"

0.0.5000/0x500507680b2381fb rport-1:0-0 NotOnline
Class = "zfcp_port"
    access_denied       = "0"
    failed              = "0"
    in_recovery         = "0"
    status              = "0x00000001"
Class = "fc_remote_ports"
    dev_loss_tmo        = "2147483647"
    fast_io_fail_tmo    = "5"
    maxframe_size       = "2048 bytes"
    node_name           = "0x500507680b0081fb"
    port_id             = "0x24e200"
    port_name           = "0x500507680b2381fb"
    port_state          = "Blocked"
    roles               = "FCP Target"
    scsi_target_id      = "0"
    supported_classes   = "Class 2, Class 3"

0.0.5040/0x500507680b2281fa rport-2:0-0
Class = "zfcp_port"
    access_denied       = "0"
    failed              = "0"
    in_recovery         = "0"
    status              = "0x54000001"
Class = "fc_remote_ports"
    dev_loss_tmo        = "2147483647"
    fast_io_fail_tmo    = "5"
    maxframe_size       = "2048 bytes"
    node_name           = "0x500507680b0081fa"
    port_id             = "0x24a300"
    port_name           = "0x500507680b2281fa"
    port_state          = "Online"
    roles               = "FCP Target"
    scsi_target_id      = "0"
    supported_classes   = "Class 2, Class 3"

0.0.1940/0x500507630718c5e3 rport-8:0-0 NotOnline
Class = "zfcp_port"
    access_denied       = "0"
    failed              = "0"
    in_recovery         = "0"
    status              = "0x00000001"
Class = "fc_remote_ports"
    dev_loss_tmo        = "2147483647"
    fast_io_fail_tmo    = "5"
    maxframe_size       = "2112 bytes"
    node_name           = "0x5005076307ffc5e3"
    port_id             = "0x675e00"
    port_name           = "0x500507630718c5e3"
    port_state          = "Blocked"
    roles               = "FCP Target"
    scsi_target_id      = "0"
    supported_classes   = "Class 2, Class 3"

0.0.1900/0x500507630708c5e3/0x4000408600000000 0:0:0:1082540032 auto
Class = "scsi_device"
    ...
    state               = "running"
    ...
    zfcp_access_denied  = "0"
    zfcp_failed         = "0"
    zfcp_in_recovery    = "0"
    zfcp_status         = "0x54000000"

0.0.1940/0x500507630718c5e3/0x4000408600000000 8:0:0:1082540032 auto NotRunning
Class = "scsi_device"
    ...
    state               = "transport-offline"
    ...
    zfcp_access_denied  = "0"
    zfcp_failed         = "0"
    zfcp_in_recovery    = "0"
    zfcp_status         = "0x00000000"

0.0.5000/0x500507680b2381fb/0x0256000000000000 1:0:0:598 NotRunning
Class = "zfcp_unit"
    access_denied       = "0"
    access_readonly     = "0"
    access_shared       = "0"
    failed              = "0"
    in_recovery         = "0"
    status              = "0x00000000"
Class = "scsi_device"
    ...
    state               = "transport-offline"
    ...
    zfcp_access_denied  = "0"
    zfcp_failed         = "0"
    zfcp_in_recovery    = "0"
    zfcp_status         = "0x00000000"

0.0.5040/0x500507680b2281fa/0x0256000000000000 2:0:0:598
Class = "zfcp_unit"
    access_denied       = "0"
    access_readonly     = "0"
    access_shared       = "0"
    failed              = "0"
    in_recovery         = "0"
    status              = "0x54000000"
Class = "scsi_device"
    ...
    state               = "running"
    ...
    zfcp_access_denied  = "0"
    zfcp_failed         = "0"
    zfcp_in_recovery    = "0"
    zfcp_status         = "0x54000000"

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Steffen Maier
0c78add815 lszfcp: add new output marker for non-good SCSI devices (luns)
Shows potential issues with zfcp-attached SCSI devices at one glance.

Example:

$ lszfcp -De
0.0.5000/0x500507680b2181fa/0x027d000000000000 1:0:1:637 NotRunning

$ lszfcp -DeV
/sys/devices/css0/0.0.0223/0.0.5000/0x500507680b2181fa/0x027d000000000000
/sys/bus/ccw/drivers/zfcp/0.0.5000/host1/rport-1:0-1/target1:0:1/1:0:1:637 NotRunning
/sys/block/sdm /sys/class/scsi_generic/sg12

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Fedor Loshakov <loshakov@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Steffen Maier
94b7a8f68d lszfcp: allow to also enumerate FCP device that have never been online
Since zfcp lazily allocates Scsi_Host et al. on setting an FCP device
online for the first time since the last driver core bind to zfcp
(such as zfcp kernel module load),
lszfcp has only been showing FCP devices (vHBAs) that have been online
at least once including those that have been set offline again.
This is somewhat confusing.
Also it would be nice if lszfcp could be an easier to type replacement for
"lscss -t 17032/03" to simply show all devices bound to the zfcp device
driver.
Of course those FCP devices that have never been online, won't have any
zfcp-specific attribute details, only CIO attributes from the CCW bus.
They also do not have a Scsi_Host nor fc_host.

In order not to break any scripting or expectations around lszfcp,
make the new feature depend on the extended output command line option.

Example:

$ lszfcp -He
0.0.1880 - offline

$ lszfcp -HeV
/sys/devices/css0/0.0.010b/0.0.1880 offline
-
-

$ lszfcp -Hea
0.0.1880 - offline
Bus = "ccw"
    availability        = "good"
    cmb_enable          = "0"
    cutype              = "1731/03"
    devtype             = "1732/03"
    modalias            = "ccw:t1731m03dt1732dm03"
    online              = "0"
    uevent              = "DRIVER=zfcp"

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Fedor Loshakov <loshakov@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Steffen Maier
4036e80b26 lszfcp: add new output marker for non-good FCP devices (hosts)
Shows potential issues with FCP devices at one glance.

Examples:

$ lszfcp -He
0.0.5000 host1 offline
0.0.50c0 host6 failed
0.0.3c40 host7 defunct

$ lszfcp -HeV
/sys/devices/css0/0.0.0223/0.0.5000 offline
/sys/class/fc_host/host1
/sys/class/scsi_host/host1
/sys/devices/css0/0.0.0226/0.0.50c0 failed
/sys/class/fc_host/host6
/sys/class/scsi_host/host6
/sys/devices/css0/defunct/0.0.3c40 defunct
/sys/class/fc_host/host7
/sys/class/scsi_host/host7

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Steffen Maier
a236180ad8 lszfcp: add new output marker for non-good fc_rports
$ lszfcp -Pe
0.0.50c0/0x500507680b2481fa rport-6:0-2 NotOnline
$ lszfcp -PeV
- (NoMoreZfcpPort:0.0.50c0/0x500507680b2481fa)
/sys/class/fc_remote_ports/rport-6:0-2 NotOnline

$ lszfcp -Pe
0.0.3c40/0x500507680b2181fb rport-7:0-4 NotOnline
$ lszfcp -PeV
/sys/devices/css0/defunct/0.0.3c40/0x500507680b2181fb
/sys/class/fc_remote_ports/rport-7:0-4 NotOnline

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:46 +01:00
Steffen Maier
a9684b9154 lszfcp: fix error message if no zfcp-attached SCSI device found
s390-tools-1.8.1 introduced a new error message.
It gave the same and thus misleading error message as if no FCP device
(vHBA) found.
In order not to break any scripting built around lszfcp output,
only print the fixed error message depending on the extended output
command line option.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:14:40 +01:00
Steffen Maier
6d31760872 lszfcp: fix to show defunct FCP devices again
s390-tools-1.8.0 introduced a regression skipping all FCP devices
that are currently "defunct".

Changing
$SYSFS/devices/css0/*/*/host*
to
$SYSFS/devices/css0/[0-9]*/[0-9]*/host*
was too strict as it won't match
$SYSFS/devices/css0/defunct/[0-9]*/host*
anymore.

Fix:
$SYSFS/devices/css0/[0-9d]*/[0-9]*/host*

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:12:07 +01:00
Steffen Maier
b0dcc61ed5 lszfcp: fix to show non-good target ports again
s390-tools-1.8.1 introduced a regression skipping all fc_rports
with port_state != Online. While we need to skip some output parts
for a zfcp_port which does not exist anymore due to port_remove,
there are other cases with port_state != Online for which we should
not skip an fc_rport.

Such as port_state "Blocked" after a cable pull beyond host-adjacent switch
or port_state "Not Present" after dev_loss_tmo ran out.
This way the user can see the previously discovered ports,
even if they might currently not be usable for traffic.
Non-good ports are marked in the short output with suffix "NotOnline".
In order not to break scripting or expectations around lszfcp, make the new
feature depend on the extended output command line option.

Sysfs path globbing does not work for a removed zfcp_port
to obtain the FCP device bus-ID. Instead, properly walk the sysfs.

Examples with a removed zfcp_port:
$ lszfcp -Pe
0.0.50c0/0x500507680b2481fa rport-6:0-2
$ lszfcp -PeV
- (NoMoreZfcpPort:0.0.50c0/0x500507680b2481fa)
/sys/class/fc_remote_ports/rport-6:0-2

Examples with an existing zfcp_port but pulled fibre:
$ lszfcp -Pe
0.0.3c40/0x500507680b2181fb rport-7:0-4
$ lszfcp -PeV
/sys/devices/css0/defunct/0.0.3c40/0x500507680b2181fb
/sys/class/fc_remote_ports/rport-7:0-4

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:12:07 +01:00
Steffen Maier
a3e37953fe lszfcp: fix missing block & sg device output without CONFIG_SYSFS_DEPRECATED
lszfcp -DVe was missing a 3rd SCSI device header line like:

/sys/devices/css0/0.0.0019/0.0.1880/0x50050763031bd327/0x4045400000000000
/sys/bus/ccw/drivers/zfcp/0.0.1880/host0/rport-0:0-0/target0:0:0/0:0:0:1073758277
/sys/block/sda /sys/class/scsi_generic/sg0

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:12:07 +01:00
Steffen Maier
abf18cb711 lszfcp: new command line option for extended output format
Used in subsequent patches to guard their changes in order not to break
any scripting or expectations around the lszfcp output format.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:12:07 +01:00
Steffen Maier
22a4d45e3b lszfcp: clean up whitespace (mixed indentation, trailing)
Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-26 17:12:07 +01:00
Ingo Franzki
e693173eef zkey: Add batch-mode option to zkey-cryptsetup tool
When re-enciphering or setting LUKS2 volume keys using zkey-cryptsetup,
allow to specify the --batch-mode|-q option to suppress confirmation
questions.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-21 12:19:12 +01:00
Ingo Franzki
11bfa1d3c8 zkey: Add open and format options to the cryptsetup command
For LUKS2 volumes the cryptsetup command currently generates
'cryptsetup luksFormat' commands, but for plain mode volumes it
generates 'cryptsetup plainOpen' commands.

With the --open option it can now also generate 'cryptsetup luksOpen'
commands for opening LUKS2 volumes. With the --format option you can
limit the generated commands to only generate 'cryptsetup luksFormat'
commands for LUKS2 volumes, and skip plain mode volumes.
The default behavior (i.e. if none of the two options specified),
remains the same as before.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-21 12:19:12 +01:00
Ingo Franzki
3ed8ab4e2a zkey: Add common passphrase options for crypttab command
When generating crypttab entries for LUKS2 volumes, allow to
specify common passphrase options like --key-file, --keyfile-offset,
--keyfile-size and --tries and pass those to the generated crypttab
entries.

Note that not all distributions support the keyfile-offset and
keyfile-size options in crypttab entries.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-21 12:19:12 +01:00
Ingo Franzki
5a0c93443c zkey: Add batch-mode option to cryptsetup command
When generating cryptsetup commands, allow to specify the
--batch-mode|-q option and pass it to the generated commands.

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/59
Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/58

Suggested-by: Dimitri John Ledkov <xnox@ubuntu.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-21 12:19:12 +01:00
Ingo Franzki
b0c7965234 zkey: Add common passphrase options for cryptsetup command
When generating 'cryptsetup luksFormat' or 'zkey-cryptsetup setvp'
commands for LUKS2 volumes, allow to specify common passphrase options
like --key-file, --keyfile-offset, --keyfile-size and --tries and
pass those to the generated commands.

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/59
Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/58

Suggested-by: Dimitri John Ledkov <xnox@ubuntu.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-21 12:19:12 +01:00
Dan Horák
cdb23f8d22 zipl: copy new section introduced by GCC 9
GCC 9 is using a new section called .rodata.cst8 for some literals and
it must be included when copying the bootloaders to the bin images.

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/60
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>
2019-03-21 12:19:12 +01:00
Sa Liu
60bda7ed0d dbginfo: Added commmands blockdev and lvdisplay
Signed-off-by: Sa Liu <saliu@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-21 12:19:12 +01:00
Peter Oberparleiter
4ff6519961 zdev: Do not export inacceptable attribute values
For some device driver SysFS attributes, values read may not be
acceptable input values for that attribute.

An example would be the group of qeth VNICC attributes that return "n/a"
when VNICC setup is not supported, but only accept "0" and "1" as valid
values that can be written to it.

This leads to errors such as the following when data for such attributes
is imported:

  # chzdev f500 --import test.conf
  Importing configuration data from test.conf
  QETH device 0.0.f500:0.0.f501:0.0.f502 configure failed
      Error: Invalid value for qeth attribute: vnicc/flooding=n/a (*)
      Acceptable values:
      - Integers in the range 0 - 1
      Use 'chzdev qeth --help-attribute vnicc/flooding' for more information
  Note: You can use --force to override safety checks (*)

To fix this, change chzdev's --export function to skip any attribute
value that is not acceptable for that attribute.

Fixes: e831269e74 ("zdev: Add support for VNIC Characteristics")
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-21 12:19:12 +01:00
Ingo Franzki
90dc65659f zkey: Correct crypttab entry generation
Remove 'hash=plain' option for plain type entries, add 'none luks'
for LUKS type entries.

Note that the format of a crypttab entry is distribution specific.
On some distributions only the first 2 fields are required, the
remaining are optional, on other distributions all 4 fields are
required. With this patch correct crypttab entries are generated
for all distributions.

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/55
Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/57
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-07 14:02:01 +01:00
Ingo Franzki
ec9c67189e zkey-cryptsetup: Support debug level CRYPT_DEBUG_JSON
With libcryptsetup version 2.1 a new debug level was introduced
to log the JSON structures when adding key slots, digests, etc
into the LUKS2 header.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-07 13:54:43 +01:00
Ingo Franzki
951bd1ae54 zkey-cryptsetup: Fix logging of libcryptsetup debug messages
Messages from libcryptsetup for logging level CRYPT_LOG_DEBUG
do not include an EOL.

Prior to libcryptsetup version 2.1 debug messages were not printed
through the log callback, but using printf directly within
libcryptsetup. Now they are also printed through the log callback,
but without an EOL terminating the text.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-07 13:54:43 +01:00
Ingo Franzki
ed6e3b7270 zkey-cryptsetup: Obtain PBKDF from existing key-slot
For zkey-cryptsetup commands reencipher and setkey, use the
same password-based key derivation function (PBKDF) when
creating unbound key-sots that the key slot uses, which was
unlocked through the specified passphrase. That way the
unlocked key slots created by these commands inherit the
PBKDF from the existing key slot.

This feature requires libcryptsetup version 2.1 or later.
If an older libcryptsetup version is available at compile
time, then PBKDF2 is used for newly created unbound key slots.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-07 13:54:43 +01:00
Ingo Franzki
79ce120553 zkey: Minor correction in man page
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-07 13:54:43 +01:00
Jan Höppner
b45b564681 Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-03-07 13:54:43 +01:00
Jan Höppner
c8d0fca36c New release s390-tools-2.8.0
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-02-15 16:35:47 +01:00
Sa Liu
bbd88f26c9 dbginfo: Redirect output of lsof to a separate file open_files.out
The output of lsof command is sometimes too long and makes it difficult
to search in runtime.out. Move the output to a separate file.

Signed-off-by: Sa Liu <saliu@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-02-15 16:35:47 +01:00
Sa Liu
79bfa818ed dbginfo: Collect traces under /var/log/opencryptoki
Signed-off-by: Sa Liu <saliu@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-02-11 12:33:56 +01:00
Hendrik Brueckner
299144264d cpumf/cpumf_helper: always return list reference for --sfb-size
Running lscpumf -i as regular user causes a warning when trying to
disply sampling buffer sizes.  The root cause is in the cpumf_helper
that returns "0,0" instead of a list reference "[0,0]".

This happened when running as regular user because the sampling buffer
size sysfs attribute is not readable for them.

Remove the shortcut and always return a list reference.

Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-02-11 12:33:56 +01:00
Ingo Franzki
a69470d7e0 zkey-cryptsetup: Use PBKDF2 as default PBKDF for new key slots
LUKS2 encrypted volumes use Argon2i as default password based key
derivation function (PBKDF). Argon2i is a so-called memory-hard
function. It requires a certain amount of physical memory to make
dictionary attacks more costly.

Unfortunately, when multiple encrypted volumes are unlocked
automatically during system startup via /etc/crypttab, the use of
Argon2i will most likely cause an out-of-memory error in systemd.

To avoid the out-of-memory error, use PBKDF2 instead. Because PAES
uses secure keys as volume keys, the security of the key derivation
function used to derive the key to encrypt the volume key in the LUKS
key slots is of less relevance. Thus it is safe to use a weaker key
derivation function.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-02-11 12:33:56 +01:00
Ingo Franzki
b26dbfe832 zkey: Add --pbkdf pbkdf2 to generated crptsetup luksFormat command
LUKS2 encrypted volumes use Argon2i as default password based key
derivation function (PBKDF). Argon2i is a so-called memory-hard
function. It requires a certain amount of physical memory to make
dictionary attacks more costly.

Unfortunately, when multiple encrypted volumes are unlocked
automatically during system startup via /etc/crypttab, the use of
Argon2i will most likely cause an out-of-memory error in systemd.

To avoid the out-of-memory error, use PBKDF2 instead. Because PAES
uses secure keys as volume keys, the security of the key derivation
function used to derive the key to encrypt the volume key in the LUKS
key slots is of less relevance. Thus it is safe to use a weaker key
derivation function.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-02-11 12:33:56 +01:00
Ingo Franzki
d95dc6d698 zkey: Avoid EPERM on key change if user is not owner of key file
When a user that is in the zkeyadm group, but is not the owner
of the key file changes a key in the zkey repository, then
error "Operation not permitted" occurs. This is due to a superfluous
call to chmod on the key file. When key files are changed then the
permissions of that file are retained anyway.

Also fix a typo in the error message when chmod fails.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-02-11 12:33:56 +01:00
Dan Horák
847f16f632 Switch to using /run directory instead of the legacy /var/run
Closes: https://github.com/ibm-s390-tools/s390-tools/pull/53
Signed-off-by: Dan Horák <dan@danny.cz>
Acked-by: Sa Liu <saliu@de.ibm.com>
Acked-by: Harald Freudenberger <freude@linux.ibm.com>
Acked-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-02-11 12:33:56 +01:00
Stefan Haberland
bc053a975a zdsfs: add online vtoc refresh
Enable zdsfs to access datasets that were created after zdsfs was
mounted without the need to remount zdsfs.
This is done by re-reading the VTOC with every readdir system call.
To ensure a consistent VTOC state the DASD device is reserved for
every VTOC read and released afterwards.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-01-30 13:35:43 +01:00
Harald Freudenberger
e9c030f202 zcrypt: refine lszcrypt man page
Added some explanations about the columns shown with the
lszcrypt verbose output.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-01-24 12:42:35 +01:00
Dan Horák
dffd41943e pkey: Support autoloading kernel pkey module
The module is loaded automatically based on CPU features, but it's still
too late in some use cases. Thus allow distros to use explicit loading.

See also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=63c19be095d0f8eb8992674991e44b4228bd4179

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/51
Signed-off-by: Dan Horák <dan@danny.cz>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-01-10 12:42:47 +01:00
Ingo Franzki
58189b8786 libutil: Add indention and separator to util_rec_example.c
Show how to use util_rec_set_indent() and util_rec_print_separator()
in util_rec_example.c

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-01-10 12:42:47 +01:00
Ingo Franzki
b165500b69 libutil: Add function to print separator line
In wide format the header is separated from the rest of the
records by a separator line. Add support to print such a
separator line also between some records.

Add function util_rec_print_separator() that prints the
separator line for wide format only. For other formats this
is a NOP.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Acked-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-01-10 12:42:47 +01:00
Ingo Franzki
5f2ddad6a8 libutil: Add support for indenting records
Functions rec_print_xxx allows to print records in
different formats. Add support to optionally indent
the output by a specific number of characters.

The indention is set using a new function util_rec_set_indent().
The default indention is zero, thus existing applications
will behave the same as before.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Acked-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-01-10 12:42:47 +01:00
Jan Höppner
28deb03178 Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-01-10 12:42:47 +01:00
Jan Höppner
8f1fa2a83c New release s390-tools-2.7.1
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-13 15:57:25 +01:00
Martin Schwidefsky
7677d3c0b4 cmsfs-fuse: write more than a single line in linefeed mode
The cmsfs_write function only writes a single record in line mode
and returns the number of bytes it consumed from the input buffer.
This is valid behaviour as the write system call can always return
with a partial write. But there are tools that ignore the return
value of the write and just assume that a single write call is
sufficient to write many lines aka records on the cmsfs filesystem.

Enhance the cmsfs_write function to loop until all lines from the
input buffer have been consumed.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-13 15:57:25 +01:00
Gerald Schaefer
6f7cb68dcf cmsfs-fuse: Fix iconv buffer aliasing
GCC8 shows the following compile warning:

cmsfs-fuse.c: In function ‘convert_text’:
cmsfs-fuse.c:2558:19: warning: passing argument 2 to restrict-qualified
parameter aliases with argument 4 [-Wrestrict]
  rc = iconv(conv, &data_ptr, &in_count, &data_ptr, &out_count);
                   ^~~~~~~~~             ~~~~~~~~~

Fix this by using a separate buffer for iconv. The buffer size depends on
the record format: variable-length records have a maximum length of
MAX_RECORD_LEN (plus 1 byte for linefeed), while fixed-length records
could be larger in theory. This patch takes that into account for the iconv
buffer, but the rest of the code currently cannot handle fixed-length records
larger than MAX_RECORD_LEN.

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-13 15:57:25 +01:00
Jan Höppner
4d008849f7 libu2s: Remove library dependency
Commit aefc8cd3ff ("libutil/libu2s: Move strlcpy() implementation to
libutils") added a dependency to libutil. This is not necessary and
could potentially lead to parallel build errors. Remove the dependency.

Fixes: aefc8cd3ff ("libutil/libu2s: Move strlcpy() implementation to libutils")
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-13 15:57:25 +01:00
Jan Höppner
d921c230ab libdasd: Remove useless build dependency
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-13 15:57:25 +01:00
Jan Höppner
6151889dcd zpcictl: Add warning for unsupported operations
There are several reasons why an operation might fail. Either the
running kernel, the PCI function itself, or the hypervisor lacks support
for a certain operation. In such cases the kernel returns either with
EIO or EOPNOTSUPP.
The corresponding warning, however, just says the file couldn't be
closed. Display a warning for EIO and EOPNOTSUPP to tell the user about
the missing support.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-13 15:57:25 +01:00
Jan Höppner
224dc2e414 Fix spelling typos and grammar mistakes.
Closes: https://github.com/ibm-s390-tools/s390-tools/pull/39
Suggested-by: Dimitri John Ledkov <xnox@ubuntu.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-11 15:52:07 +01:00
Ingo Franzki
5a10aa73a9 zkey: Enhance error message about missing CCA library
Make the error message when the CCA library is missing more
user friendly. Also display an URL where the CCA package
can be downloaded.

The CCA library is used for the REENCIPHER commands of
zkey and zkey-cryptsetup and must be installed separately
as part of the IBM CCA Host Libraries and Tools package.
This packages is not provided by the distributors, but must
be downloaded from an IBM web page and installed separately.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-11 15:52:07 +01:00
Jan Höppner
428d41034e libvmdump: Fix -Wrestrict warning
Get rid of the following GCC8 compile warning by using different buffers
for input/output:

In file included from vmdump_convert.cpp:13:
vm_dump.h: In member function ‘void VMDump::ebcAsc(char*, size_t)
const’:
vm_dump.h:145:26: warning: passing argument 2 to restrict-qualified
parameter aliases with argument 4 [-Wrestrict]
   iconv(ebcdicAsciiConv, &inout, &len, &inout, &len);
                          ^~~~~~        ~~~~~~
vm_dump.h:145:34: warning: passing argument 3 to restrict-qualified
parameter aliases with argument 5 [-Wrestrict]
   iconv(ebcdicAsciiConv, &inout, &len, &inout, &len);
                                  ^~~~          ~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-11 15:52:07 +01:00
Jan Höppner
cf265cc46a qethqoat: Fix -Wrestrict warning
Get rid of the following GCC8 compile warning by using different buffers
for input/output:

qethqoat.c: In function ‘ebctoasc’:
qethqoat.c:51:30: warning: passing argument 2 to restrict-qualified
parameter aliases with argument 4 [-Wrestrict]
  iconv(l_iconv_ebcdic_ascii, &inout, &len, &inout, &len);
                              ^~~~~~        ~~~~~~
qethqoat.c:51:38: warning: passing argument 3 to restrict-qualified
parameter aliases with argument 5 [-Wrestrict]
  iconv(l_iconv_ebcdic_ascii, &inout, &len, &inout, &len);
                                      ^~~~          ~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-11 15:52:07 +01:00
Jan Höppner
84623f39dc hyptop: Fix -Wrestrict warning
Make sure there are two different buffers passed to iconv() to get rid
of the following GCC8 compile warning:

helper.c: In function ‘ht_ebcdic_to_ascii’:
helper.c:103:30: warning: passing argument 2 to restrict-qualified
parameter aliases with argument 4 [-Wrestrict]
  iconv(l_iconv_ebcdic_ascii, &inout, &len, &inout, &len);
                              ^~~~~~        ~~~~~~
helper.c:103:38: warning: passing argument 3 to restrict-qualified
parameter aliases with argument 5 [-Wrestrict]
  iconv(l_iconv_ebcdic_ascii, &inout, &len, &inout, &len);
                                      ^~~~          ~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-11 15:52:07 +01:00
Michael Holzheu
8cbdfebc4f Makefile: Fix parallel build (2nd try)
Commit 851f685993 ("Makefile: Add dependency between libvmcp and
libutil to fix -j builds") introduced the following regression

  $ make clean
  CLEAN   /home2/holzheu/src/s390-tools
  ...
  CLEAN   libccw
  CC      libutil/util_base.o
  CC      libutil/util_path.o

For the "clean" target the new library dependency triggers a build
of libutil.

So remove the dependency again.

To fix the parallel build issue, no longer build the examples with
"make all" and add a new target "examples" that can now be used for building
the example programs.

Fixes: 851f685993 ("Makefile: Add dependency between libvmcp and libutil to fix -j builds")
Signed-off-by: Michael Holzheu <holzheu@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-11 15:52:07 +01:00
Javier Martinez Canillas
4951044213 zipl: use the BLS "title" field as the IPL section name
Most bootloaders use the BootLoaderSpec "title" field to name the entries
in their boot menu. The zipl bootloader used the "version" field instead,
since it was wrongly assumed that the zipl boot menu didn't support names
that contained spaces, which are usually present in a BLS "title" field.

But this is not the case, names with space characters are supported by the
IPL and is just a constraint of the section heading in the zipl.conf file.

So to be consistent with all the other bootloaders, use the "title" field
also on zipl when populating the boot menu entries from BLS files.

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/47
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Stefan Haberland sth@linux.ibm.com
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:46:51 +01:00
Jan Höppner
667516681e zpcictl: Change service element to Support Element
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
10ce432196 zpcictl: Replace strncpy() with util_strlcpy()
Use util_strlcpy() to copy log data correctly and get rid of the
following GCC8 compile warning:

zpcictl.c: In function ‘sclp_issue_action’:
zpcictl.c:312:3: warning: ‘strncpy’ specified bound 4054 equals
destination size [-Wstringop-truncation]
   strncpy(report.data.log_data, sdata, sizeof(report.data.log_data));
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
320a49fc1a hmcdrvfs: Replace strncpy() with util_strlcpy()
Use util_strlcpy() to copy strings correctly and get rid of the
following GCC8 compile warning:

In function ‘hmcdrv_parse_line’,
    inlined from ‘hmcdrv_cache_dir’ at hmcdrvfs.c:981:11:
hmcdrvfs.c:862:4: warning: ‘strncpy’ specified bound 192 equals
destination size [-Wstringop-truncation]
    strncpy(symlink, arrow + 4, HMCDRV_FUSE_MAXPATH);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
f0d18ddf2b zdsfs: Use util_strlcpy() to copy strings
By using util_strlcpy() and correctly copying strings we can get rid of
the following GCC8 compile warnings:

In function ‘path_to_ds_name.constprop’,
    inlined from ‘zdsfs_readdir’ at zdsfs.c:282:2:
zdsfs.c:78:2: warning: ‘strncpy’ specified bound 45 equals destination
size [-Wstringop-truncation]
  strncpy(normds, path, size);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘path_to_ds_name.constprop’,
    inlined from ‘zdsfs_open’ at zdsfs.c:339:2:
zdsfs.c:78:2: warning: ‘strncpy’ specified bound 45 equals destination
size [-Wstringop-truncation]
  strncpy(normds, path, size);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘path_to_member_name.constprop’,
    inlined from ‘zdsfs_open’ at zdsfs.c:372:3:
zdsfs.c:94:3: warning: ‘strncpy’ specified bound 45 equals destination
size [-Wstringop-truncation]
   strncpy(normds, path, size);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘path_to_ds_name.constprop’,
    inlined from ‘zdsfs_getxattr’ at zdsfs.c:527:2:
zdsfs.c:78:2: warning: ‘strncpy’ specified bound 45 equals destination
size [-Wstringop-truncation]
  strncpy(normds, path, size);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘path_to_member_name.constprop’,
    inlined from ‘zdsfs_getxattr’ at zdsfs.c:547:4:
zdsfs.c:94:3: warning: ‘strncpy’ specified bound 45 equals destination
size [-Wstringop-truncation]
   strncpy(normds, path, size);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘path_to_ds_name.constprop’,
    inlined from ‘zdsfs_getattr.part.1’ at zdsfs.c:134:2,
    inlined from ‘zdsfs_getattr’:
zdsfs.c:78:2: warning: ‘strncpy’ specified bound 45 equals destination
size [-Wstringop-truncation]
  strncpy(normds, path, size);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘path_to_member_name.constprop’,
    inlined from ‘zdsfs_getattr.part.1’ at zdsfs.c:164:3,
    inlined from ‘zdsfs_getattr’:
zdsfs.c:94:3: warning: ‘strncpy’ specified bound 45 equals destination
size [-Wstringop-truncation]
   strncpy(normds, path, size);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
2962248e7b qethqoat: Use util_strlcpy() to copy strings
Use the more robust util_strlcpy() to copy strings instead of strncpy().

This fixes the following GCC8 compile warnings:

qethqoat.c: In function ‘main’:
qethqoat.c:616:2: warning: ‘strncpy’ specified bound 16 equals
destination size [-Wstringop-truncation]
  strncpy(ifr.ifr_name, opts.ifname, IFNAMSIZ);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
773c8672ac cmsfs-fuse: Copy strings correctly using util_strlcpy()
Use util_strlcpy() instead of strncpy() to correctly copy strings.

This fixes the following GCC8 compile warnings:

cmsfs-fuse.c: In function ‘file_open’:
cmsfs-fuse.c:604:2: warning: ‘strncpy’ specified bound 18 equals
destination size [-Wstringop-truncation]
  strncpy(uc_name, name, MAX_FNAME);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmsfs-fuse.c: In function ‘lookup_file’:
cmsfs-fuse.c:1570:2: warning: ‘strncpy’ specified bound 18 equals
destination size [-Wstringop-truncation]
  strncpy(uc_name, name, MAX_FNAME);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmsfs-fuse.c: In function ‘cmsfs_open’:
cmsfs-fuse.c:1854:3: warning: ‘strncpy’ specified bound 19 equals
destination size [-Wstringop-truncation]
   strncpy(f->path, path, MAX_FNAME + 1);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmsfs-fuse.c: In function ‘delete_file’:
cmsfs-fuse.c:2760:2: warning: ‘strncpy’ specified bound 18 equals
destination size [-Wstringop-truncation]
  strncpy(file, path + 1, MAX_FNAME);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmsfs-fuse.c: In function ‘cmsfs_rename’:
cmsfs-fuse.c:2850:2: warning: ‘strncpy’ specified bound 18 equals
destination size [-Wstringop-truncation]
  strncpy(uc_old_name, path + 1, MAX_FNAME);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmsfs-fuse.c:2857:3: warning: ‘strncpy’ specified bound 19 equals
destination size [-Wstringop-truncation]
   strncpy(f->path, new_path, MAX_FNAME + 1);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmsfs-fuse.c: In function ‘cmsfs_create’:
cmsfs-fuse.c:2111:2: warning: ‘strncpy’ specified bound 18 equals
destination size [-Wstringop-truncation]
  strncpy(uc_name, path + 1, MAX_FNAME);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

config.c:68:2: warning: ‘strncpy’ specified bound 9 equals destination
size [-Wstringop-truncation]
  strncpy(entry->name, name, MAX_TYPE_LEN);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
637750f299 hyptop: Replace strncpy() with util_strlcpy()
Ensure that strings are copied correctly by using util_strlcpy() rather
than strncpy().

This fixes the following GCC8 compile warnings:

sd_core.c: In function ‘sd_cpu_new’:
sd_core.c:222:2: warning: ‘strncpy’ specified bound 9 equals destination
size [-Wstringop-truncation]
  strncpy(cpu->id, id, sizeof(cpu->id));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sd_core.c: In function ‘sd_sys_new’:
sd_core.c:254:2: warning: ‘strncpy’ specified bound 9 equals destination
size [-Wstringop-truncation]
  strncpy(sys_new->id, id, sizeof(sys_new->id));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tbox.c:160:2: warning: ‘strncpy’ specified bound 121 equals destination
size [-Wstringop-truncation]
  strncpy(line_cpy, line, sizeof(line_cpy));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

win_sys.c: In function ‘win_sys_set’:
win_sys.c:329:2: warning: ‘strncpy’ specified bound 9 equals destination
size [-Wstringop-truncation]
  strncpy(l_sys_id, sys_id, sizeof(l_sys_id));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
a17b52a043 hyptop: Remove unused function sd_cpu_real_type_set()
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
d14051e309 zdev: Copy strings correctly using util_strlcpy()
Make sure strings are copied correctly by using util_strlcpy().

Also, rename the NIC_{OWNER,NAME}_LEN definitions to *_SIZE to make it
more clear that the terminating null byte ('\0') is included in this
buffer size. Using *_LEN would mean only the number of characters in the
string fit in.
Furthermore, use these definitions rather than sizeof().

This fixes the following GCC8 compile warning:

nic.c: In function ‘nic_data_get’:
nic.c:58:2: warning: ‘strncpy’ specified bound 9 equals destination size
[-Wstringop-truncation]
  strncpy(data.owner, argv[11], sizeof(data.owner));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nic.c:59:2: warning: ‘strncpy’ specified bound 9 equals destination size
[-Wstringop-truncation]
  strncpy(data.name, argv[12], sizeof(data.name));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
d85cf20981 dump2tar: Change SET_STR_FIELD to copy strings correctly
Make sure strings are properly copied in the SET_STR_FIELD
macro by using util_strlcpy().

This gets rid of the following GCC8 compile warnings:

In function ‘init_header’,
    inlined from ‘emit_header’ at tar.c:189:2:
tar.c:81:2: warning: ‘strncpy’ specified bound 100 equals destination
size [-Wstringop-truncation]
  strncpy((obj)->name, (value), sizeof((obj)->name))
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tar.c:94:2: note: in expansion of macro ‘SET_STR_FIELD’
  SET_STR_FIELD(header, name, filename);
  ^~~~~~~~~~~~~
tar.c:81:2: warning: ‘strncpy’ specified bound 100 equals destination
size [-Wstringop-truncation]
  strncpy((obj)->name, (value), sizeof((obj)->name))
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tar.c:94:2: note: in expansion of macro ‘SET_STR_FIELD’
  SET_STR_FIELD(header, name, filename);
  ^~~~~~~~~~~~~
tar.c:81:2: warning: ‘strncpy’ specified bound 100 equals destination
size [-Wstringop-truncation]
  strncpy((obj)->name, (value), sizeof((obj)->name))
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tar.c:96:3: note: in expansion of macro ‘SET_STR_FIELD’
   SET_STR_FIELD(header, linkname, link);
   ^~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
7df8edd88a ipl_tools: Change buffer size and copy strings correctly
Change the buffer size to what we actually need and use util_strlcpy()
to correctly copy strings.

This gets rid of the following GCC8 compile warnings:

fcp.c: In function ‘fcp_wwpn_get’:
fcp.c:44:2: warning: ‘strncpy’ output may be truncated copying 20 bytes
from a string of length 4095 [-Wstringop-truncation]
  strncpy(wwpn, buf, 20);
  ^~~~~~~~~~~~~~~~~~~~~~
fcp.c: In function ‘fcp_lun_get’:
fcp.c:65:2: warning: ‘strncpy’ output may be truncated copying 20 bytes
from a string of length 4095 [-Wstringop-truncation]
  strncpy(lun, buf, 20);
  ^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
6d382d30d9 ipl_tools: Allocate string buffer dynamically
Use util_asprintf() to allocate memory for the string buffers
dynamically and get rid of the following GCC8 compile warnings:

system.c: In function ‘print_fw_str’:
system.c:86:46: warning: ‘%s’ directive output may be truncated writing
up to 4095 bytes into a region of size 4082 [-Wformat-truncation=]
  snprintf(path, sizeof(path), "/sys/firmware/%s", file);
                                              ^~
system.c:98:19:
  read_fw_str(str, path, sizeof(str));
                   ~~~~
system.c:86:2: note: ‘snprintf’ output between 15 and 4110 bytes into a
destination of size 4096
  snprintf(path, sizeof(path), "/sys/firmware/%s", file);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cmd_chreipl.c: In function ‘set_reipl_type_helper’:
cmd_chreipl.c:316:19: warning: ‘%d’ directive writing between 1 and 11
bytes into a region of size between 0 and 4095 [-Wformat-overflow=]
  sprintf(cmd, "%s %d:%d", chreipl_helper, major(dev), minor(dev));
                   ^~
cmd_chreipl.c:316:15: note: using the range [-2147483648, 2147483647]
for directive argument
  sprintf(cmd, "%s %d:%d", chreipl_helper, major(dev), minor(dev));
               ^~~~~~~~~~
cmd_chreipl.c:316:15: note: using the range [-2147483648, 2147483647]
for directive argument
cmd_chreipl.c:316:2: note: ‘sprintf’ output between 5 and 4120 bytes
into a destination of size 4096
  sprintf(cmd, "%s %d:%d", chreipl_helper, major(dev), minor(dev));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:19:48 +01:00
Jan Höppner
9f8d245f92 ipl_tools: Copy strings correctly
Use util_strlcpy() to copy strings correctly and get rid of the
following GCC8 compile warnings:

main.c: In function ‘main’:
main.c:34:2: warning: ‘strncpy’ specified bound 256 equals destination
size [-Wstringop-truncation]
  strncpy(g.prog_name, argv[0], sizeof(g.prog_name));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In function ‘set_bootprog’,
    inlined from ‘parse_chreipl_options’ at cmd_chreipl.c:510:4:
cmd_chreipl.c:185:2: warning: ‘strncpy’ specified bound 11 equals
destination size [-Wstringop-truncation]
  strncpy(l.bootprog, bootprog, sizeof(l.bootprog));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cmd_chreipl.c: In function ‘set_reipl_type’:
cmd_chreipl.c:297:2: warning: ‘strncpy’ specified bound 15 equals
destination size [-Wstringop-tr uncation]
  strncpy(l.dev, dev_name, sizeof(l.dev));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:03:02 +01:00
Jan Höppner
cf39f26dee dasdinfo: Replace strncpy() with util_strlcpy()
Copy strings correctly by using util_strlcpy() over strncpy() and get
rid of the following GCC8 compile warning:

In function ‘dinfo_extract_dev’,
    inlined from ‘dinfo_get_dev_from_blockdev’ at dasdinfo.c:365:6:
dasdinfo.c:337:2: warning: ‘strncpy’ specified bound 80 equals
destination size [-Wstringop-trunc ation]
  strncpy(tmp, str, RD_BUFFER_SIZE);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jan Höppner
83106991ab lsqeth: Copy interface name correctly
IFNAMSIZ is the maximum buffer size for an interface name, including its
terminating zero byte. [1] strncpy() should therefore only copy a size
of 'IFNAMSIZ - 1' and the destination string should then be
null-terminated properly.

Use util_strlcpy() to correctly copy the string and get rid of the
followin GCC8 compile warning:

In function ‘ethtool_checksumming’,
    inlined from ‘process_sysfs_attribute’ at lsqeth.c:333:5,
    inlined from ‘print_device’ at lsqeth.c:468:3:
lsqeth.c:171:2: warning: ‘strncpy’ specified bound 16 equals destination
size [-Wstringop-truncat ion]
  strncpy(ifr.ifr_name, if_name, IFNAMSIZ);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[1]: https://www.gnu.org/software/libc/manual/html_node/Interface-Naming.html

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jan Höppner
b631c74df5 lszcrypt: Replace sprintf() with util_asprintf()
Get rid of fixed buffers and avoid the following GCC8 compile warnings:

lszcrypt.c: In function ‘main’:
lszcrypt.c:642:28: warning: ‘%04x’ directive writing between 4 and 8
bytes into a region of size between 7 and 13 [-Wformat-overflow=]
     sprintf(sub_dev, "%02x.%04x", id, dom);
                            ^~~~
lszcrypt.c:642:22: note: directive argument in the range [0, 2147483647]
     sprintf(sub_dev, "%02x.%04x", id, dom);
                      ^~~~~~~~~~~
lszcrypt.c:642:5: note: ‘sprintf’ output between 8 and 18 bytes into a
destination of size 16
     sprintf(sub_dev, "%02x.%04x", id, dom);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jan Höppner
c675096899 ip_watcher: Copy device name correctly
DEV_NAME_SIZE is defined as IFNAMSIZ. IFNAMSIZ is the maximum buffer size
for an interface name, including its terminating null byte. [1] The
buffers dev_name and ifr_name are both defined with a size of
DEV_NAME_SIZE and IFNAMSIZ respectively.
Given these facts, only a size of 'IFNAMSIZ - 1' should be copied and
the destination string should then be null-terminated properly.

Use util_strlcpy() to correctly copy the strings and rid of the followin
GCC8 compile warnings:

xcec-bridge.c: In function ‘open_incoming_socket’:
xcec-bridge.c:94:2: warning: ‘strncpy’ specified bound 16 equals
destination size [-Wstringop-tru ncation]
..strncpy(if_req.ifr_name,dev_name,DEV_NAME_LEN);
..^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xcec-bridge.c: In function ‘read_sys’:
xcec-bridge.c:284:4: warning: ‘strncpy’ output may be truncated copying
16 bytes from a string of length 255 [-Wstringop-truncation]
....strncpy(is->dev_name, if_name, DEV_NAME_LEN);
....^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[1]: https://www.gnu.org/software/libc/manual/html_node/Interface-Naming.html

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jan Höppner
5a9e93fb5b ip_watcher: Rename DEV_NAME_LEN definition
The term 'len' only represents the number of characters in a string,
as opposed to 'size' which means the number of bytes including the
terminating null byte ('\0').
DEV_NAME_LEN is defined as IFNAMSIZ, so we are clearly interested in the
size. Rename to DEV_NAME_SIZE to make this more clear.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jan Höppner
aefc8cd3ff libutil/libu2s: Move strlcpy() implementation to libutils
The strlcpy() implementation in libu2s is beneficial for other tools as
well. Move the implementation to libutils and replace misc_strlcpy() in
libu2s accordingly.

Change the link order in zipl to make it build again.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jan Höppner
a208463e49 dasdview: Replace strncpy() with memcpy()
Safely replace strncpy() with memcpy() as we don't want the terminating
null byte anyway. Get rid of the following warning:

dasdview.c: In function ‘dasdview_print_volser’:
dasdview.c:621:3: warning: ‘strncpy’ output truncated before terminating
nul copying 6 bytes from a string of the same length
[-Wstringop-truncation]
   strncpy(volser, "      ", 6);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jan Höppner
a931428908 fdasd: Replace strncpy() with memcpy()
While assembling the volume label, strncpy() is used. As we don't care
about NUL termination of the strings here, safely replace strncpy() with
memcpy() and get rid of the following compile warnings:

fdasd.c: In function ‘fdasd_write_vtoc_labels’:
fdasd.c:1324:4: warning: ‘strncpy’ output truncated before terminating
nul copying 44 bytes from a string of the same length
[-Wstringop-truncation]
    strncpy(ch, "LINUX.V               "
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     "                      ", 44);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fdasd.c:1332:4: warning: ‘strncpy’ output truncated before terminating
nul copying 5 bytes from a string of the same length
[-Wstringop-truncation]
    strncpy(c1, ".PART", 5);
    ^~~~~~~~~~~~~~~~~~~~~~~
In function ‘fdasd_write_vtoc_labels’,
    inlined from ‘fdasd_write_labels’ at fdasd.c:1399:3:
fdasd.c:1329:4: warning: ‘strncpy’ output may be truncated copying 6
bytes from a string of length 6 [-Wstringop-truncation]
    strncpy(c1, volser, VOLSER_LENGTH);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fdasd.c:1336:4: warning: ‘strncpy’ output may be truncated copying 5
bytes from a string of length 5 [-Wstringop-truncation]
    strncpy(c1, dsno, 5);
    ^~~~~~~~~~~~~~~~~~~~
fdasd.c:1340:4: warning: ‘strncpy’ output truncated before terminating
nul copying as many bytes from a string as its length
[-Wstringop-truncation]
    strncpy(c1, dsname, strlen(dsname)); /* We don't want \0 */
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fdasd.c:1313:4: warning: ‘strncpy’ output may be truncated copying 31
bytes from a string of length 44 [-Wstringop-truncation]
    strncpy(c1, s2, 31);
    ^~~~~~~~~~~~~~~~~~~
In function ‘fdasd_change_part_type’,
    inlined from ‘main’ at fdasd.c:3000:4:
fdasd.c:1639:3: warning: ‘strncpy’ output may be truncated copying 6
bytes from a string of length 19 [-Wstringop-truncation]
   strncpy(ch, str, 6);
   ^~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jan Höppner
c2297a0a7e zgetdump: Replace strncpy() with memcpy()
We can safely replace strncpy() with memcpy() here and get rid of the
following compile warnings:

dfi_s390mv.c: In function ‘set_magic_numbers’:
dfi_s390mv.c:570:3: warning: ‘strncpy’ output truncated before
terminating nul copying 7 bytes fr om a string of the same length
[-Wstringop-truncation]
   strncpy(l.dumper_magic, DF_S390_DUMPER_MAGIC_MV_EXT, 7);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dfi_s390mv.c:573:3: warning: ‘strncpy’ output truncated before
terminating nul copying 7 bytes fr om a string of the same length
[-Wstringop-truncation]
   strncpy(l.dumper_magic, DF_S390_DUMPER_MAGIC_MV, 7);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jan Höppner
70a79fab3c zgetdump: Avoid using PATH_MAX
Using inappropriate sizes for snprintf() leads to the following compile
warnings:

dfi_s390mv.c: In function ‘dev_from_busid’:
dfi_s390mv.c:116:34: warning: ‘/online’ directive output may be
truncated writing 7 bytes into a region of size between 1 and 4096
[-Wformat-truncation=]
  snprintf(tmp_file, PATH_MAX, "%s/online", dev_file);
                                  ^~~~~~~
dfi_s390mv.c:116:2: note: ‘snprintf’ output between 8 and 4103 bytes
into a destination of size 4096
  snprintf(tmp_file, PATH_MAX, "%s/online", dev_file);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dfi_s390mv.c:143:35: warning: ‘%s’ directive output may be truncated
writing up to 255 bytes into a region of size between 0 and 4095
[-Wformat-truncation=]
  snprintf(tmp_file, PATH_MAX, "%s/%s/dev", dev_file, direntp->d_name);
                                   ^~
dfi_s390mv.c:143:2: note: ‘snprintf’ output between 6 and 4356 bytes
into a destination of size 4096
  snprintf(tmp_file, PATH_MAX, "%s/%s/dev", dev_file, direntp->d_name);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A simple fix would be to use different suitable fixed sizes for tmp_file
and dev_file. However, the code can be improved here a little.

Use the libutil function util_path_sysfs() to build the sysfs path
string. This is more robust, as the function will figure out the correct
mount point of the sysfs. util_path_sysfs() will also terminate
execution, if no sysfs mount point could be found. That means, we can
get rid of check_sysfs().
Furthermore, the two variables (tmp_file, dev_file) can be combined to
one. Also, check the return value of open() and act accordingly.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jan Höppner
b5a7b13e71 zipl: Replace strcpy() and strcat()
Use misc_asprintf() for concatenating strings and get rid of the
following GCC8 compile warnings:

disk.c: In function ‘disk_get_info’:
disk.c:247:43: warning: ‘%d’ directive output may be truncated writing
between 1 and 11 bytes int o a region of size between 0 and 79
[-Wformat-truncation=]
    snprintf(ppn_cmd, sizeof(ppn_cmd), "%s %d:%d",
                                           ^~
disk.c:247:39: note: using the range [-2147483648, 2147483647] for
directive argument
    snprintf(ppn_cmd, sizeof(ppn_cmd), "%s %d:%d",
                                       ^~~~~~~~~~
disk.c:247:39: note: using the range [-2147483648, 2147483647] for
directive argument
disk.c:247:4: note: ‘snprintf’ output between 5 and 104 bytes into a
destination of size 80
    snprintf(ppn_cmd, sizeof(ppn_cmd), "%s %d:%d",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      script_file, major(stats.st_rdev),
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      minor(stats.st_rdev));
      ~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jan Höppner
52b2cb8424 zipl: Replace sizeof() with DATA_SIZE() macro
Using the DATA_SIZE() macro gets rid of the following GCC8 compile
warning:

boot.c: In function ‘boot_init_fba_stage0’:
boot.c:120:2: warning: ‘memcpy’ forming offset [2, 152] is out of the
bounds [0, 1] of object ‘_binary_fba0_bin_start’ with type ‘char’
[-Warray-bounds]
  memcpy(stage0, DATA_ADDR(fba0), sizeof(*stage0));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from boot.c:18:
../boot/data.h:24:13: note: ‘_binary_fba0_bin_start’ declared here
 extern char _binary_fba0_bin_start;
             ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jan Höppner
03b2bf028b zipl: Align struct lowcore to double page size
With GCC8 the following warning is displayed:

In file included from cio.h:15,
                 from stage2.h:15,
                 from menu.h:15,
                 from stage2.c:14:
s390.h:193:1: warning: alignment 1 of ‘struct _lowcore’ is less than 8
[-Wpacked-not-aligned]
 } __packed;
 ^

Fix by aligning struct _lowcore to double page size.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jan Höppner
81f9a67d6f libvmdump: Increase message buffer size
The message buffer of DumpException doesn't account for additional
strings such as strerror(), device nodes, or filenames. Make it a bit
larger to be safe.

This fixes the following GCC8 compile warnings:

In file included from vm_dump.h:62,
                 from vm_dump.cpp:17:
dump.h: In static member function ‘static Dump::DumpType
VMDump::getDumpType(const char*)’:
dump.h:46:16: warning: ‘ (’ directive writing 2 bytes into a region of size
between 1 and 200 [-W format-overflow=]
   sprintf(msg, "%s (%s)", m, strerror(errno));
                ^~~~~~~~~
dump.h:46:10: note: ‘sprintf’ output 4 or more bytes (assuming 203) into a
destination of size 200
   sprintf(msg, "%s (%s)", m, strerror(errno));
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dump.h:46:16: warning: ‘ (’ directive writing 2 bytes into a region of size
between 1 and 200 [-W format-overflow=]
   sprintf(msg, "%s (%s)", m, strerror(errno));
                ^~~~~~~~~
dump.h:46:10: note: ‘sprintf’ output 4 or more bytes (assuming 203) into a
destination of size 200
   sprintf(msg, "%s (%s)", m, strerror(errno));
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dump.h:46:16: warning: ‘ (’ directive writing 2 bytes into a region of size
between 1 and 200 [-W format-overflow=]
   sprintf(msg, "%s (%s)", m, strerror(errno));
                ^~~~~~~~~
dump.h:46:10: note: ‘sprintf’ output 4 or more bytes (assuming 203) into a
destination of size 200
   sprintf(msg, "%s (%s)", m, strerror(errno));
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jan Höppner
c15f481181 libvtoc: Replace strncpy() with memcpy()
To assemble things like the volume id or fields of the format1 label
struct, strncpy() is used. Data copied here is later written to disk and
we don't want any terminating null byte ('\0') there. Therefore, we can
simply use memcpy() instead and get rid of the following GCC8 compile
warnings:

vtoc.c: In function ‘vtoc_init_format_1_8_label’:
vtoc.c:747:2: warning: ‘strncpy’ output truncated before terminating nul
copying 6 bytes from a s tring of the same length [-Wstringop-truncation]
  strncpy((char *) f1->DS1DSSN, "      ", 6);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vtoc.c:746:2: warning: ‘strncpy’ output may be truncated copying 44 bytes from
a string of length 79 [-Wstringop-truncation]
  strncpy(f1->DS1DSNAM, str, 44);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vtoc.c:761:2: warning: ‘strncpy’ output may be truncated copying 13 bytes from
a string of length 79 [-Wstringop-truncation]
  strncpy((char *)f1->DS1SYSCD, str, 13);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vtoc.c: In function ‘vtoc_volume_label_set_volser’:
vtoc.c:401:2: warning: ‘strncpy’ output may be truncated copying 6 bytes from a
string of length 6 [-Wstringop-truncation]
  strncpy(vlabel->volid, s, VOLSER_LENGTH);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
4170cceb52 cpuplugd: close config file after use in parse_configfile()
Resolves Cppcheck error:
[cpuplugd/config.c:204]: (error) Resource leak: filp

Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
a648dbb014 zkey: enhance file read/write error handling
fread()/fwrite() return the unsigned count of elements read/written or a
short count or zero in case of an error. Check if the number of elements
read/written matches the expectation. In case of fread(), if it does not
match, check if an error occurred and otherwise assume the file to be too
small. In case of fwrite(), if it does not match, assume an error.

Resolves Cppcheck style warnings:
[zkey/pkey.c:161]: (style) Checking if unsigned variable 'count' is less than zero.
[zkey/pkey.c:209]: (style) Checking if unsigned variable 'count' is less than zero.
[zkey/pkey.c:299]: (style) Checking if unsigned variable 'count' is less than zero.

Cc: Ingo Franzki <ifranzki@de.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
322d51e5e4 zipl: remove redundant duplicate expression
Resolves Cppcheck style warning:
[zipl/boot/stage3.c:260]: (style) Same expression on both sides of '&&'.

Cc: Stefan Haberland <stefan.haberland@de.ibm.com>
Cc: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
a1db08160d zipl: check array limits before indexing
Resolves Cppcheck warning:
[zipl/boot/menu.c:126]: (style) Array index 'i' is used before limits check.

Cc: Stefan Haberland <stefan.haberland@de.ibm.com>
Cc: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
31b77e1646 zdev: fix memory leak in misc_readlink()
When realloc() fails to allocate memory it returns NULL and the original
block is left untouched. In that case return the potentially larger
original block.

Found using Cppcheck:
[zdev/src/misc.c:1106]: (error) Memory leak: name

Cc: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
a4acf7c991 zdev: fix copying of modified flag
The modified flag was actually never copied during merge of setting lists.
Copy the modified flag if requested.

Found using Cppcheck:
[zdev/src/setting.c:553]: (warning) Redundant assignment of 'n->modified' to itself.

Cc: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
17cade6e7f fdasd: fix resource leak in fdasd_parse_conffile()
Deallocate the file descriptor.

Found with Cppcheck:
[fdasd/fdasd.c:731]: (error) Resource leak: fd

Cc: Stefan Haberland <sth@linux.ibm.com>
Cc: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
90ea5d9e5d fdasd: check array limits before indexing
Found using Cppcheck:
[fdasd/fdasd.c:261]: (style) Array index 'from' is used before limits check.

Cc: Stefan Haberland <sth@linux.ibm.com>
Cc: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
6accffd583 fdasd: fix possible integer overflow
The computation of blk in functions fdasd_check_volume() and
fdasd_write_vtoc_labels() contained the possibility for an undetected
unsigned integer overflow. Unconditionally subtracting one from the
return value of function cchhb2blk() may cause an unsigned integer
overflow, as cchhb2blk() may return zero if cc, hh, and b are all zero.

Resolves Cppcheck style warning:
[fdasd/fdasd.c:1260]: (style) Checking if unsigned variable 'blk' is less than zero.

Cc: Stefan Haberland <sth@linux.ibm.com>
Cc: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
4e5afb9b71 cmsfs-fuse: do not check if unsigned is less than zero
Only check if size is zero and not if equal or less than zero. This is
safe, as size is only decremented by rlen, which is either less than or
equal to size. So size may never overflow.

Resolves Cppcheck style warning:
[cmsfs-fuse/cmsfs-fuse.c:3746]: (style) Checking if unsigned variable 'size' is less than zero.

Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
9f247795f3 cmsfs-fuse: remove unused variable in add_record_ext()
Resolves Cppcheck style warning:
[cmsfs-fuse/cmsfs-fuse.c:936]: (style) Variable 'i' is modified but its new value is never used.

Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
71976f8e4b cmsfs-fuse: fix memory leak in cmsfs_rename()
Free the string uc_new_name that gets allocated using strdup().

Found with Cppcheck:
[cmsfs-fuse/cmsfs-fuse.c:2865]: (error) Memory leak: uc_new_name

Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Michael Holzheu
851f685993 Makefile: Add dependency between libvmcp and libutil to fix -j builds
For linking the "libvmcp" example program the "libutil" is required.
Therefore when the "libvmcp" directory is entered in a parallel build
and the "libutil.a" file has not yet been created, a second "libutil"
build is triggered which can then lead to build errors like the following:

 ar: libutil.a: File format not recognized
 ar: libutil.a: No such file or directory
 make[2]: Leaving directory '/builddir/build/BUILD/s390-tools-2.6.0/libutil'
 make[2]: *** [../common.mak:246: libutil.a] Error 1
 make[1]: *** [../common.mak:246: libutil.a] Error 1
 make[1]: *** Waiting for unfinished jobs....
 make[1]: *** [../common.mak:315: ..//libutil/libutil.a] Error 2
 make[1]: Leaving directory '/builddir/build/BUILD/s390-tools-2.6.0/libvmcp'
 make: *** [Makefile:57: libvmcp] Error 2
 make: *** Waiting for unfinished jobs....
ving directory '/builddir/build/BUILD/s390-tools-2.6.0/libutil'
 make: *** [Makefile:57: libutil] Error 2
 error: Bad exit status from /var/tmp/rpm-tmp.wCulxB (%build)

So fix this and add a dependency between libvmcp and libutil.

Signed-off-by: Michael Holzheu <holzheu@linux.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Ingo Franzki
9100327092 zkey: Include /sbin into PATH when executing commands
When using 'zkey cryptsetup' with the '--run' option,
it might not find the executable to execute when those
are in /sbin.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jan Höppner
e2d433bb10 dasdinfo: Display error messages on stderr output
Change all error messages from printf() to warnx().

While at it, remove the punctuation mark for some of the error messages.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jan Höppner
d6925a30da New release s390-tools-2.7.0
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-31 11:44:17 +01:00
Ingo Franzki
fe4cc7c479 zkey: add generated files to .gitignore
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-31 11:44:17 +01:00
Ingo Franzki
fa3cabc8af zkey: Makefile: Don't rebuild .o.d files on 'make install'
The .o.d make targets in common.mak do not expect that
header files are generated by a make target. When a new header
file is generated, the .o.d targets will be rebuilt on the
next make invocation, because that new header file is then
detected, and is then treated as a new dependency of all .o.d
targets.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-31 11:44:17 +01:00
Jan Höppner
5a9b56f814 lscss: Fix email address
The linux.vnet.ibm.com addresses will be become disfunct by eoy.

Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-31 11:44:17 +01:00
Julian Wiedmann
20145b6d06 qethqoat: add OSA-Express7S support
Add the missing identifiers to report the card name and link speed.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-25 13:42:12 +02:00
Ingo Franzki
9561a0b983 zkey: Enhance error message on key store open
Print a meaningful reason when the keystore can not be
accessed, e.g. because the user is not allowed to access
the keystore directory.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-25 11:00:52 +02:00
Philipp Rudo
97fa88299f zfcpdump: Remove unneeded include <zlib.h>
Dump compression was a feature of the file system dumper which was removed
several years ago. This include is a leftover. Remove it.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Acked-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-25 11:00:52 +02:00
Jan Höppner
aaaebb2030 zpcictl: Change wording of man-page and help output
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-25 11:00:52 +02:00
Karsten Graul
ff2a403bd2 osasnmpd: remove unused code, improve readability
Remove unused code because query_OSA_EXP does actually never return -1.
So make its return value unsigned and remove all checks for negative
return values.

Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-25 11:00:52 +02:00
Karsten Graul
66ed1727f9 osasnmpd: start without real OSA devices
Osasnmpd would start without any devices, but refuses to start when all
devices are no real OSA devices.
Start osasnmpd in this case because it re-scans via update_mib_info
whenever the interface data changes.

Reviewed-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-25 11:00:52 +02:00
Ingo Franzki
c33cc5a619 zkey: Makefile: Avoid relink of modules during 'make install'
Because targets check-dep-zkey and check-dep-zkey-cryptsetup
do not produce any file, any targets that have a pre-req on those
targets are rebuilt during 'make install'.

Also correct .PHONY targets.

Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/46
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-22 14:02:35 +02:00
Karsten Graul
cd46297d7c s390-tools/utils: handle util_scandir errors correctly
The util_scandir_* functions may return 0 or -1, in which case no vector
is allocated in libutil/util_scandir.c. util_ptr_vec_free, called by
util_scandir_free or directly from lschp.c and lsscm.c, does always
call free for the vector which might be not initialized.

Fix this by always initializing the vector with NULL in __scandir and
add some api hardening by checking the vector and count in
util_ptr_vec_free before iterating over the vector.
And update the comment for util_scandir to indicate that -1 may be
returned in error cases plus that the vector is initialized with NULL.

Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/43
Reported-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-19 15:32:53 +02:00
Dimitri John Ledkov
07b11982e3 zdev: Trigger generic_ccw devices on any kernel module loads.
Generic CCW device can use any driver, and the value of the driver is
not known ahead of time. To avoid the race between loading and binding
a kernel module, and devices added - retrigger generic-ccw devices on
any kernel module load.

Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/37
Link: https://bugs.launchpad.net/ubuntu-z-systems/+bug/1794308
Closes: https://github.com/ibm-s390-tools/s390-tools/pull/45

Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-19 15:32:40 +02:00
Dimitri John Ledkov
35348c302b zdev/initramfs: add s390-tools- prefix to hook, due to conflicts.
Unfortunately zdev hook already exists in Ubuntu, from an unrelated
project. ZFS uses zdev/zpool names, and ships a zdev hook to do ZFS
specific initialisation. It is available on s390x and thus results in
file-conflict upon installing both. Thus renaming this zdev hook to
s390-tools-zdev.

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/41
Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-19 15:31:54 +02:00
Dimitri John Ledkov
35312d0c47 cpacfstatsd.service: only run on LPARs.
Add ConditionVirtualization=no to the service file such that it is
only started on LPARs. This service cannot run on z/VM nor KVM, and
fails resulting in a degraded boot.

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/38
Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Acked-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-19 15:31:40 +02:00
Jan Höppner
342c6a3707 zpcictl: Make device node for NVMe optional
At the moment, if we specify the slot address of an NVMe device but
can't find the corresponding device node, the execution is terminated.

This is a bit harsh as the device node is rather optional and only
necessary to collect S.M.A.R.T. data. We should still be able to issue
the error reporting, even if we couldn't determine the device node.

Therefore, make sure the device node for NVMe devices is optional by
changing various error messages to warnings.
Change sysfs_get_slot_addr() to have a return value and work with that
accordingly.
Also make sure, that execution is terminated when a valid device node
was specified but no matching slot address was determined. The slot
address is necessary to issue the error reporting commands.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-11 14:41:32 +02:00
Jan Höppner
e2a8d85916 zpcictl: Read device link to obtain device address
The address sysfs attribute might not be present on some older kernel
levels. Read the device link instead using readlink() to obtain the
address.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-11 14:41:32 +02:00
Jan Höppner
8f0496b26a zpcictl: Use fopen() instead of open() for writes
Be consistent with the rest of the code and use fopen() rather than
open().

Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-11 14:41:32 +02:00
Jan Höppner
d03be73536 zpcictl: Rephrase man page entries and tool output
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-11 14:41:32 +02:00
Michael Holzheu
a87268d62e util_path_example: Fix usage message
Document that for the "sysfs" invocation the mount point is optional.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-11 14:41:32 +02:00
Michael Holzheu
9cc06a0529 util_proc: Fix typos in description of util_proc_mnt_get_entry()
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-11 14:41:32 +02:00
Michael Holzheu
3b1ccce515 util_proc: Fix return code handling for util_proc_mnt_get_entry()
Correctly return -1 if the requested file system is not mounted.

Reported-by: Peter Morjan <peter.morjan@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-11 14:41:32 +02:00
Hans Wippel
ffe91d1b30 zdev: fix qeth BridgePort and VNICC conflict checking
This patch fixes false positives when attributes are checked for
conflicts between BridgePort and VNICC.

Signed-off-by: Hans Wippel <hwippel@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-11 14:41:32 +02:00
Hendrik Brueckner
f35c5d01fd zpcictl: include sys/sysmacros.h to avoid minor/major glibc warnings
The minor()/major() function definitions are moved to sys/sysmacros.h
and will be removed from sys/types.h.  To correct below warning, simply
include sys/sysmacros.h.

  zpcictl.c: In function ‘sysfs_get_slot_addr’:
  zpcictl.c:184:13: warning: In the GNU C Library, "major" is defined
   by <sys/sysmacros.h>. For historical compatibility, it is
   currently defined by <sys/types.h> as well, but we plan to
   remove this soon. To use "major", include <sys/sysmacros.h>
   directly. If you did not intend to use a system-defined macro
   "major", you should undefine it after including <sys/types.h>.
    major = major(dev_stat.st_rdev);
               ^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
2018-10-02 09:55:27 +02:00
Jan Höppner
b23c35c390 zcryptctl: Add binary to .gitignore
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-29 12:41:54 +02:00
Jan Höppner
177cf8cfeb zpcictl: Introduce new tool zpcictl
zpcictl is used to manage PCI devices on z Systems. In this first
version it is mainly used to handle erroneous PCI devices by changing
their state and make those changes known to the SE. Log data, such as
S.M.A.R.T. data for NVMe devices, is sent alongside those state changes.

The state change is issued by sending data via the PCI 'report_error'
sysfs attribute. It's a binary attribute which will cause the host to
send an Adapter Notification Event.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-29 12:41:44 +02:00
Harald Freudenberger
f05f7d656b zcryptctl: new tool zcryptctl for multiple zcrypt node management
With the latest kernel comes an extension for the zcrypt
device driver to support multiple zcrypt device nodes.

Here is the userspace part of this which adds a new
application zcryptctl for user friendly management of
this feature.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-29 12:41:31 +02:00
Dan Horák
0bf4f1b957 zkey: Be explicit about linking the tools
I've met cases when the make's default rule for linking was used instead
omitting the ALL_LDFLAGS variable. The linking rule from common.mak is
defined for linking *.o files only, here we have libutil.a too.

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/35
Signed-off-by: Dan Horák <dan@danny.cz>
Acked-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-29 12:41:28 +02:00
Dan Horák
cd38119888 zkey: Be consistent when referring to libutil.a
Link: https://github.com/ibm-s390-tools/s390-tools/pull/35
Signed-off-by: Dan Horák <dan@danny.cz>
Acked-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-29 12:41:21 +02:00
Dan Horák
cadef5c0ff zkey: Drop redundant include
Link: https://github.com/ibm-s390-tools/s390-tools/pull/35
Signed-off-by: Dan Horák <dan@danny.cz>
Acked-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-29 12:41:15 +02:00
Dan Horák
02e1c783f6 Makefile: drop LOADLIBES variable
Remove deprecated LOADLIBES variable from the Makefile rules, LDLIBS
serves the same purpose these days.

Link: https://github.com/ibm-s390-tools/s390-tools/pull/35
Signed-off-by: Dan Horák <dan@danny.cz>
Acked-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-29 12:41:08 +02:00
Eric Sandeen
07e30951f8 zipl: use FIEMAP mapping ioctl if it exists
zipl currently uses the FIBMAP ioctl to map blocks for the bootloader;
on XFS, if FIBMAP is requested on a reflinked file, it will fail -
and FIBMAP returns 0 in this case, which is indistinguishable from a
hole.  This causes boot to fail because the file is not mapped.

We can use the FIEMAP ioctl instead, which is able to map reflinked
files.  While FIEMAP is able to map entire extents at once, here we
simply use it to obtain the mapping block-by-block so that it fits
in with the current FIBMAP calls.

Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/34
Closes: https://github.com/ibm-s390-tools/s390-tools/pull/36
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Tested-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-17 14:28:18 +02:00
Harald Freudenberger
0a0b4c3826 lszcrypt: support for alternate zcrypt device drivers
With kernel 4.19 there comes an extension to the existing
AP bus which supports alternate zcrypt drivers. For details
about this see kernel patch "s390/zcrypt: AP bus support for
alternate driver(s)". So now lszcrypt displays the driver
name in verbose mode. As some of the information displayed
by lszcrypt was based on sysfs attributes, which are only
available when the default zcrypt driver is bound to the
device, this also needed some rework. If a sysfs attribute
is not available because of an alternate driver binding
(or no driver) a question mark is printed into the field.

Together with this a slight rework of the displayed information
has been done. The two columns for pending requests and pending
replies has been merged to one pending column and the column
sizes have been adjusted.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-17 14:26:29 +02:00
Peter Oberparleiter
eade995185 zdsfs: Direct --help and --version output to stdout
zdsfs writes output for --help and --version to stderr. This is
likely because zdsfs calls into a FUSE function for additional
usage output that also writes to stderr (prior to FUSE 3.0.0).

To be consistent with other s390-tools and GNU coding guide lines,
fix this by using stdout for zdsfs generated output, and by
redirecting stderr to stdout before calling the FUSE function.

Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-17 14:23:47 +02:00
Peter Oberparleiter
0eba8d11df tape390_display: Direct --help output to stdout
tape390_display writes output for --help to stderr. To be consistent
with other s390-tools and GNU coding guide lines, fix this by using
stdout for tool-generated usage help.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-17 14:23:47 +02:00
Peter Oberparleiter
257490366b util_prg_example: Add --help and --version options
Add missing long options for --help and --version in util_prg_example.

Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-17 14:23:47 +02:00
Peter Oberparleiter
5ef1320a7b iucvconn/iucvtty: Direct --help output to stdout
Both iucvconn and iucvtty write output for --help to stderr. To be
consistent with other s390-tools and GNU coding guide lines,
fix this by using stdout for tool-generated usage help.

Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-17 14:23:47 +02:00
Peter Oberparleiter
f2f572fa70 hmcdrvfs: Direct --help and --version output to stdout
hmcdrvfs writes output for --help and --version to stderr. This is
likely because hmcdrvfs calls into a FUSE function for additional
usage output that also writes to stderr (prior to FUSE 3.0.0).

To be consistent with other s390-tools and GNU coding guide lines,
fix this by using stdout for hmcdrvfs generated output, and by
redirecting stderr to stdout before calling the FUSE function.

Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-17 14:23:47 +02:00
Peter Oberparleiter
e655f0cd7b cmsfs-fuse: Direct --help and --version output to stdout
cmsfs-fuse writes output for --help and --version to stderr. This is
likely because cmsfs-fuse calls into a FUSE function for additional
usage output that also writes to stderr (prior to FUSE 3.0.0).

To be consistent with other s390-tools and GNU coding guide lines,
fix this by using stdout for cmsfs-fuse generated output, and by
redirecting stderr to stdout before calling the FUSE function.

Also remove an inactive call to add FUSE version output on --version to
be consistent with other FUSE-based s390-tools.

Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-17 14:23:47 +02:00
Peter Oberparleiter
68b46eea7a zipl: Add missing build dependency
Building zipl from outside the zipl/ sub-directory fails due to a
missing dependency:

  # cd s390-tools
  # make -C zipl/src/ zipl
  boot.c:18:10: fatal error: ../boot/data.h: No such file or directory
   #include "../boot/data.h"

This is because boot/data.h needs to be generated before src/boot.c can
be compiled. Fix this by adding the missing dependency to the zipl
Makefile.

Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Ingo Franzki
9894e391ef zkey: Man page correction
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Steffen Maier
5982fd98bf CHANGELOG: lstape, lsluns: handle non-zfcp; lin_tape multiple paths
Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Steffen Maier
d5291eed1c lstape: fix SCSI HBA CCW device bus-ID e.g. for virtio-scsi-ccw
Get the SCSI HBA device bus-ID in general for HBAs on the CCW bus.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Fedor Loshakov <loshakov@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Steffen Maier
34260f1736 lstape: fix SCSI output description in man page
Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Steffen Maier
b9b3d2d230 lstape: fix description of --type and <devbusid> filter for channel tapes
Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Steffen Maier
4cf8f5f46c lstape: fix to prevent error messages if there are non-zfcp SCSI devices
Assume "N/A" for non-zfcp SCSI devices, such as iSCSI or virtio-scsi-ccw,
to not erroneously access absent zfcp-specific sysfs attributes.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Steffen Maier
eba744a25e lsluns: fix to prevent error messages if there are non-zfcp SCSI devices
Simply skip non-zfcp SCSI devices, such as iSCSI or virtio-scsi-ccw,
to not erroneously access absent zfcp-specific sysfs attributes.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Steffen Maier
80e0c41b89 lstape: fix output without SCSI generic (sg)
The default bash setting have nullglob disabled so if
$SCSI_DEV/scsi_generic*
aka
/sys/bus/scsi/devices/*:*:*:*/scsi_generic*
does not match anything, it leaves the glob pattern unmodified and
SG_DEV=$(basename $SG_DEV/*)
results in the literal:
*
If $SG_INQ exists, it invoked sg_inq with more than the one allowed
positional argument for a SCSI generic device node:
sg_inq /dev/*
Causing error messages and the usage of sg_inq to land in $TAPE_SERIAL.

To not have to rely on the nullglob setting, explicitly check for the
existence of $SCSI_DEV/scsi_generic before evaluating
SG_DEV=$(basename $SG_DEV/*).

Also handle availability of sg_inq but absence of scsi_generic
individually to provide the user with a hint if only sg is missing.

Suggested-by: Eric Farman <farman@linux.vnet.ibm.com>
Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Cc: Eric Farman <farman@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Steffen Maier
cdc787db1b lstape: fix to prefer sysfs to find lin_tape device name for SCSI device
This should be more stable than parsing the IBM lin_tape proc-fs output.
If sysfs is not available or provides no match, fall back to proc-fs.

An alternative to "ls -1d ... | head -n1" would have been to use
"shopt -s extglob; ls -d $SCSI_DEV/lin_tape/$DEV_NAME+([0-9])"
but I did not want to have to rely on extglob potentially influencing
other old code of lstape.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Steffen Maier
ef4dc7a45b lstape: fix output with SCSI lin_tape and multiple paths to same tape/changer
https://www.ibm.com/developerworks/linux/linux390/s390-tools-1.8.0.html
before the first upstream commit b627b8d8e1 ("Initial s390-tools-2.0.0
import") introduced SCSI tape/changer output for lstape. It used the SCSI
device serial number as lookup key to find a match in IBM lin_tape device
driver proc-fs output for a given SCSI device name. Since multiple paths
to the same tape/changer have the same serial number, multiple matches can
occur and distort the output:

% lstape
...
SCSI tape devices (found 12):
...
Generic Device        Target       Vendor   Model            Type     State
sg0     IBMtape0      3            0:0:0:0  IBM              ULT3580-TD6 tapedrv
running
sg1     IBMchanger0   1            2        3                0:0:0:1  IBM
3573-TL changer       running
...

There are unexpected additional Device suffix numbers for each additional
path of the same tape/changer (independent of actual path failover
enablement in lin_tape). The multiple matches above cause excess arguments
to printf. Explaining the resulting output, the bash man page says:
"The format is reused as necessary to consume all of the arguments."
This also causes a wrong number of found devices.

Current lin_tape (v3.0.31) uses the printf format string
"%-8d%-12s%-25s%-16s%-16s%-10s" for fixed column proc-fs output.
This causes the following example input to lstape:

==> /proc/scsi/IBMchanger <==
lin_tape version: 3.0.31
lin_tape major number: 251
Attached Changer Devices:
Number  model       SN                       HBA             SCSI            FO Path
0       3573-TL     00L4U78W6497_LL0         Virtio SCSI HBA 0:0:0:1         Primary
1       3573-TL     00L4U78W6497_LL0         Virtio SCSI HBA 0:0:1:1         Alternate
2       3573-TL     00L4U78W6497_LL0         Virtio SCSI HBA 1:0:1:1         Alternate
3       3573-TL     00L4U78W6497_LL0         Virtio SCSI HBA 1:0:0:1         Alternate

==> /proc/scsi/IBMtape <==
lin_tape version: 3.0.31
lin_tape major number: 251
Attached Tape Devices:
Number  model       SN                       HBA             SCSI            FO Path
0       ULT3580-TD6 10WT037733               Virtio SCSI HBA 0:0:0:0         Primary
1       ULT3580-TD6 10WT037701               Virtio SCSI HBA 0:0:1:0         Primary
2       ULT3580-TD6 10WT037701               Virtio SCSI HBA 1:0:1:0         Alternate
3       ULT3580-TD6 10WT037733               Virtio SCSI HBA 1:0:0:0         Alternate

If that was reliable and stable, we could use fixed column parsing:
			IBM_IDX=$(
				awk 'BEGIN {
					FIELDWIDTHS="8 12 25 16 16 10"
				}
				gensub(" ","","g",$5) == "'$SCSI_ID'"{
					print gensub(" ","","g",$1)
				}' /proc/scsi/$DEV_NAME
			)
However, we can hardly guarantee a field value always fits into the left-
adjusted columns (printf won't cap to field width!). Also, the fixed column
format changed between lin_tape v3.0.20 and v3.0.18 from
"%-8d%-12s%-18s%-16s%-16s%-10s" with less width for the 'SN' field.
The column format also changed between v2.2.0 and v1.37.0 from
"%-8d%-12s%-18s%-32s%-10s" where the 'SCSI' field did not even exist.
Likely that was the reason for the original Serial lookup in lstape.

As can be seen in the example, at least the HBA device driver string can
contain whitespace and breaks the field numbers with tokenized parsing.
We want to match column 5 (SCSI) but above we would match against the
string 'SCSI' as part of "Virtio SCSI HBA" instead of e.g. '0:0:0:0'.

The following works currently knowing that the last two columns do not
contain white space. But it can also fail if the value of field
'HBA' does not fit into the left-adjusted columns so there is no white
space between columns 'HBA' and 'SCSI' making them collapse:
awk '$(NF-1) == "'$SCSI_ID'" { print $1 }' /proc/scsi/$DEV_NAME

Grep for the SCSI device name as word (to skip names with same substring,
such as 0:0:1:1 also matching 0:0:1:10) and cut the first field 'Number'.
If there is no SCSI column at all (and no SCSI LLDD or other column with a
name accidentally matching an existing SCSI device name), we get no match
and better bail out with the initialized "N/A" for the lstape column
"Device". If the SCSI column exists, the SCSI device names are unique and
we always get at most one match.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Philipp Rudo
cb3e949772 zfcpdump: Fix incompatible cast compile warning
When zfcpdump is built you get a compile warning

zfcpdump.c: In function ‘init_sig’:
zfcpdump.c:307:24: warning: cast between incompatible function types from ‘void (* (*)(int,  siginfo_t *, void *))(int)’ {aka ‘void (* (*)(int,  struct <anonymous> *, void *))(int)’} to ‘void (*)(int)’ [-Wcast-function-type]
  g.sigact.sa_handler = (__sighandler_t)dump_sig_handler;

Furthermore the man pages for sigaction says

$man 2 sigaction
[...]
       If SA_SIGINFO is specified in sa_flags, then sa_sigaction (instead
       of sa_handler) specifies the signal-handling function for signum.
       This function receives three arguments, as described below.
[...]

Because SA_SIGINFO is set, using sa_handler at all is wrong in this case.

Fix this by giving dump_sig_handler the correct return type and assign it
to sa_sigaction.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Philipp Rudo
f02de298c1 zfcpdump: Remove module load
The zfcpdump kernel is built without module support. Furthermore the initrd
doesn't contain modprobe. So trying to load modules using modprobe in
zfcpdump userspace doesn't really make sense.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Philipp Rudo
eb0dc13c88 zfcpdump: Add install script for zfcpdump
Since version 198 (Feb 2013) systemd contains kernel-install, a script
managing kernel installs. This script allows execution of drop-in scripts
for customization. Add such a drop-in script to s390-tools to handle the
installation of zfcpdump kernels.

It's main purpose is to manage a link to the latest installed zfcpudump
kernel at ZFCPDUMP_IMAGE, where zipl expects to find the image to install
for a SCSI dumper.

The script supports two installation modes. One recommended by the
BootLoaderSpecs [1] to /boot/<machine-id>/<kernel-version> directories and
one directly to /boot. In the second case files are renamed during
installation to <original-name>-<kernel-version> to guarantee unique names.

Because the zfcpdump kernel is so special make the script stand-alone and
prevent any other script from being executed (exit 77) when a zfcpdump is
installed. Especially avoid functionality like creating an initrd (already
provided by s390-tools) or creating a boot entry (the zfcpdump kernel
should not be used for any other purpose than dumping).

The script requires systemd >= 203.

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

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Philipp Rudo
d08bd23c1e zipl: Move macro definition to Makefile
In the zipl Makefile macros are defined with the sole purpose to define
other macros in zipl.h. Remove this unnecessary indirection.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Philipp Rudo
724f1fea2c Makefile: Rename ZFCPDUMP_PART_* macros
The file system dumper no longer exists. So there is no need in keeping
'PART' to distinguish between the file system and the partition dumper.
Adjust the macro name to the usage in zipl by removing 'PART'.

While at it also adjust the file names the macros stand for.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Philipp Rudo
dcc63e6dfc zipl: Rename FSDUMP_PART_* macros
The macro names are a mixture of the original file system dumper (FSDUMP)
and its extension to cut the file system and write directly to a partition
(PART). The original dumper no longer exists and today the feature is
called zfcpdump. Prevent confusion by renaming the macros to fit todays
usage.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Philipp Rudo
576034e94a zfcpdump: Remove unused macros
There are no more users for these macros. Remove them.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Jan Höppner
3ec49ba7bd Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-04 14:09:24 +02:00
Jan Höppner
60c687238d New release s390-tools-2.6.0
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-08-10 12:41:17 +02:00
Sebastian Ott
57b992ffa1 lscss: document behavior of subchannels bound to alternate drivers
Provide information on how subchannels bound to vfio_ccw are displayed.

Reported-by: Cornelia Huck <cohuck@redhat.com>
Link: https://github.com/ibm-s390-tools/s390-tools/issues/32
Fixes: #32
Signed-off-by: Sebastian Ott <sebott@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-08-10 12:41:17 +02:00
Ingo Franzki
1f07a41d5a zkey: Add volume-type property to support LUKS2 volumes
Allow to specify a volume-type for a key. This applies to all
associated volumes. The volume type can be either 'plain' or
'luks2'. New keys created will default to 'luks2', but existing
keys that do not have a volume-type property default to 'plain'
for compatibility reasons.

The volume type 'luks2' is only available when the define
HAVE_LUKS2_SUPPORT is set in the makefile. This is set only
when libcryptsetup version 2.0.3 or newer is available
at build time. If the define is not set, the volume-type
option is not available to the user, and the volume-type of
a key defaults to 'plain'.

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-08-10 12:41:12 +02:00
Ingo Franzki
512b47c004 zkey: Add key verification pattern property
Store a verification pattern in the properties file along
with the secure key. The verification pattern allows to identify
the inner key even when the secure key is no longer valid.

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-08-10 10:42:18 +02:00
Ingo Franzki
818ffbc4b0 zkey: Add build dependency for libcryptsetup and json-c
The zkey-cryptsetup tool has a build dependency to
libcryptsetup version 2.0.3 or later, and json-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-08-10 10:42:18 +02:00
Ingo Franzki
5e65df7375 zkey: Add man page for zkey-cryptsetup
Add documentation for the new zkey-cryptsetup tool

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-08-10 10:42:18 +02:00
Ingo Franzki
4eb80d14a0 zkey: Add zkey-cryptsetup tool
The zkey-cryptsetup tool is used to validate and re-encipher
secure AES volume keys of volumes encrypted with LUKS2 and
the paes cipher.

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-08-10 10:42:18 +02:00
Viktor Mihajlovski
7247a61e0b netboot: add BOOTIF support
The IPAPPEND option in the pxelinux config file can be used
to pass information about the boot interface to the booted
Linux kernel.

The support for this option was missing and could lead to
installation failures, e.g. using kickstart.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-08-10 10:42:18 +02:00
Viktor Mihajlovski
c856f28e11 netboot: Send client architecture and handle path prefix
Client architecture aware DHCP configurations may send a
bootfile for the wrong architecture, if the DHCP request
doesn't include the client architecture identifier 0x001f.

Further, the DHCP reply may include the pxepathprefix option,
which points to the base directory to use for TFT requests.
If the value is not honored by the client, the wrong
configuration file, kernel, etc. could be loaded.

Both issues are fixed by this commit.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-08-10 10:42:18 +02:00
Viktor Mihajlovski
ca30cfd341 netboot: Include compressed kernel modules in initramfs
Compressed kernel modules (filename *.ko.xz) would not be included
since the script was looking for files with .ko suffix only.

This can result in a pxelinux.0 image that can't access the
network, which is not good for a network boot loader...

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-08-10 10:42:18 +02:00
Gerald Schaefer
58ecf1f363 mon_procd: fix parsing of /proc/<pid>/stat
The output of /proc/<pid>/stat will show the process name in parentheses.
The parsing code in read_stat() tries to filter out the parentheses, which
will go wrong when the process name itself also contains parentheses, e.g.
in an output like this: "2421 ((sd-pam)) S 2420 2420 2420 ..."

In this case, the first closing parentheses will be taken as end marker,
and the sscanf() on the remaining string will silently fail, leaving its
values in uninitialized state and producing wrong data.

Fix this by using strrchr() instead of strchr() to find the last closing
parentheses. Also add return value checking for sscanf() and initialize the
values to 0.

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-07-04 13:10:20 +02:00
Sa Liu
d36ff82999 dbginfo: Add VM command query time. Corrected error messages.
Signed-off-by: Sa Liu <saliu@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-07-04 13:09:58 +02:00
Dimitri John Ledkov
d4398aea89 zdev: Adjust zdev modprobe path to be compatible with split-usr systems.
mk-pxelinux-ramfs, mod_fsstatd|procd.service, zfcpdump all use
/sbin/modprobe path. Adjust zdev to use that path as well. This works
universally on both usr-merge systems (e.g. Debian/Ubuntu with
usrmerge package installed), and split-usr systems alike
(Debian/Ubuntu current stable releases default).

Closes: #31
Link: https://bugs.launchpad.net/ubuntu/+source/s390-tools/+bug/1777600
Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-22 17:25:06 +02:00
Ingo Franzki
672548ce30 zkey: Fix generate and import leaving key in an inconsistent state
When a volume or APQN association is made while generating or
importing a key, and a duplicate association is detected, then
this may leave the key in an inconsistent state.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-22 17:25:06 +02:00
Ingo Franzki
344965bd29 zkey: Fix APQN validation routine
When a zkey generate or change command is used to associate one
or multiple APQNs the command succeeds, but no key is generated
and no APQNs are associated, because the return code returned by
_keystore_apqn_check() is wrong.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-22 17:25:06 +02:00
Ingo Franzki
d6a96f07c1 zkey: Fix memory leak
The APQN check routine as well as the properties helper functions
do not free all memory that they allocated.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-22 17:25:06 +02:00
Jan Höppner
6a99d95d4f Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-06-22 17:25:06 +02:00
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
341 changed files with 28356 additions and 6619 deletions

14
.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
@@ -67,6 +68,8 @@ zconf/qeth/lsqeth
zconf/scm/lsscm
zconf/zcrypt/chzcrypt
zconf/zcrypt/lszcrypt
zconf/zcrypt/zcryptctl
zconf/zcrypt/zcryptstats
zdev/src/chzdev
zdev/src/chzdev_usage.c
zdev/src/lszdev
@@ -75,7 +78,8 @@ zdsfs/zdsfs
zdump/zgetdump
zfcpdump/cpioinit
zfcpdump/zfcpdump_part
zfcpdump/zfcpdump_part.rd
zfcpdump/zfcpdump-initrd
zfcpdump/10-zfcpdump.install
ziomon/ziomon_mgr
ziomon/ziomon_util
ziomon/ziomon_zfcpdd
@@ -86,4 +90,10 @@ zipl/boot/*.exec
zipl/boot/data.h
zipl/src/chreipl_helper.device-mapper
zipl/src/zipl
zipl/src/zipl_helper.device-mapper
zkey/zkey
zkey/zkey-cryptsetup
zkey/check-dep-zkey
zkey/check-dep-zkey-cryptsetup
zkey/detect-libcryptsetup.dep
zpcictl/zpcictl

View File

@@ -10,15 +10,21 @@ 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
- Dimitri John Ledkov
- Eberhard Pasch
- Einar Lueck
- Eric Sandeen
- Erwin Vicari
- Eugene Dvurechenski
- Eugene Crosser
- Eugene Dvurechenski
- Farhan Ali
- Fedor Loshakov
- Felix Beck
- Frank Blaschka
- Frank Munzert
@@ -26,8 +32,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 +47,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 +70,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 +99,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,220 @@
Release history for s390-tools (MIT version)
--------------------------------------------
* __v2.9.0 (2019-05-21)__
For Linux kernel version: 5.0 / 5.1
Add new tool:
- zcryptstats: Add zcryptstats to display usage statistics of
IBM Crypto Express adapters
Changes of existing tools:
- lszfcp: New command line option to show module parameters
- lszfcp: Sdev attributes for scsi_disk, block, integrity, queue, iosched
- lszfcp: Add new output marker for non-good SCSI devices (luns)
- lszfcp: Add new output marker for non-good fc_rports
- lszfcp: Clean up whitespace (mixed indentation, trailing)
- lschp: Add support for specifying a CHPID
- zipl: Add secure boot capabilities
- zkey: Add common passphrase options for cryptsetup and crypttab
- zkey: Add batch-mode option to cryptsetup and zkey-cryptsetup
- libu2s: Remove the entire library and provide more robust functionality
in libdasd and libutil instead
Bug Fixes:
- lszfcp: Allow to show zfcp_units without associated SCSI device
- lszfcp: Attribute details for: css, zfcp_port, zfcp_unit
- lszfcp: Allow to also enumerate FCP device that have never been online
- lszfcp: Fix error message if no zfcp-attached SCSI device found
- lszfcp: Fix to show defunct FCP devices again
- lszfcp: Fix to show non-good target ports again
- lszfcp: Fix missing block & sg device output without CONFIG_SYSFS_DEPRECATED
- lszfcp: New command line option for extended output format
- zfcpdbf: Warn about ambiguous payload records with dup reqid & payarea
- zpcictl: Check for regular directory to prevent possible buffer overflow
* __v2.8.0 (2019-02-15)__
For Linux kernel version: 4.20
Changes of existing tools:
- Switch to using /run directory instead of the legacy /var/run
- zkey: Add --pbkdf pbkdf2 to generated cryptsetup luksFormat command
- zdsfs: Add online VTOC refresh
- pkey: Support autoloading kernel pkey module
Bug Fixes:
- zkey: Avoid EPERM on key change if user is not owner of key file
- cpumf/cpumf_helper: Always return list reference for --sfb-size
* __v2.7.1 (2018-12-13)__
For Linux kernel version: 4.19
Changes of existing tools:
- zkey: Enhance file read/write error handling
- cmsfs-fuse: Write more than a single line in linefeed mode
- zpcictl: Add warning for unsupported operations
- zipl: Use the BLS "title" field as the IPL section name
Bug Fixes:
- cmsfs-fuse: Fix iconv buffer aliasing
- cmsfs-fuse: Fix memory leak in cmsfs_rename()
- fdasd: Fix possible integer overflow
- fdasd: Fix resource leak in fdasd_parse_conffile()
- zdev: Fix memory leak in misc_readlink()
- dasdinfo: Display error messages on stderr
- zkey: Include /sbin into PATH when executing commands
- Makefile: Fix parallel build
- GCC8 warning fixes across the board for:
cmsfs-fuse, dasdinfo, dasdview, dump2tar, fdasd, hmcdrvfs, hyptop,
ip_watcher, libvmdump, libvtoc, lsqeth, lszcrypt, qethqoat, zdev, zdsfs,
zgetdump, zipl, zpcictl
* __v2.7.0 (2018-10-31)__
For Linux kernel version: 4.19
Add new tool:
- zcryptctl: Add zcryptctl for multiple zcrypt node management
- zpcictl: Add zpcictl for reporting defective PCI devices
Changes of existing tools:
- qethqoat: Add OSA-Express7S support
- lszcrypt: Add support for alternative zcrypt device drivers
- zfcpdump: Add install script for zfcpdump
- zipl: Make zipl work with XFS by using the FIEMAP mapping ioctl
Bug Fixes:
- lstape: Fix output with SCSI lin_tape and multiple paths to same unit
- lstape: Fix output without SCSI generic (sg)
- lsluns: Fix to prevent error messages if there are non-zfcp SCSI devices
- lstape: Fix to prevent error messages if there are non-zfcp SCSI devices
- lstape: Fix description of --type and <devbusid> filter for channel tapes
- lstape: Fix SCSI output description in man page
- lstape: Fix SCSI HBA CCW device bus-ID e.g. for virtio-scsi-ccw
- Direct --help and --version output to stdout for several tools
- osasnmpd: Start without real OSA devices
* __v2.6.0 (2018-08-10)__
For Linux kernel version: 4.18
Add new tool:
- zkey: Add zkey-cryptsetup tool
Changes of existing tools:
- netboot: add BOOTIF support
Bug Fixes:
- mon_procd: fix parsing of /proc/<pid>/stat
- netboot: Include compressed kernel modules in initramfs
- netboot: Send client architecture and handle path prefix
* __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 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 zpcictl
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,14 @@ 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.
- zcryptstats: Display usage statistics of IBM Crypto Express adapters.
- 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 +237,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 +257,24 @@ 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 |
| cryptsetup | `HAVE_CRYPTSETUP2` | zkey-cryptsetup |
| json-c | `HAVE_JSONC` | zkey-cryptsetup |
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.
@@ -273,6 +285,9 @@ Build and runtime requirements for specific tools
In the following more details on the build an runtime requirements of
the different tools are provided:
* dbginfo.sh:
The tar package is required to archive collected data.
* osasnmpd:
You need at least the NET-SNMP 5.1.x package (net-snmp-devel.rpm)
installed, before building the osasnmpd subagent.
@@ -280,9 +295,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 +374,15 @@ 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). Also required are cryptsetup version 2.0.3 or newer
(cryptsetup-devel.rpm), and json-c version 0.12 or newer (json-c-devel.rpm).
Tip: you may skip the zkey build by adding `HAVE_OPENSSL=0`, and you may
may skip the zkey-cryptsetup build by adding `HAVE_CRYPTSETUP2=0`, or
`HAVE_JSONC=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

@@ -165,7 +165,7 @@ cmsfs-fuse uses a configuration file for automatic translation based on the file
Upon startup, cmsfs-fuse evaluates the file .cmsfs-fuse/filetypes.conf in the user's home directory. If the file does not
exist cmsfs-fuse evaluates the file /etc/cmsfs-fuse/filetypes.conf.
The filetypes.conf file contains the CMS file types that are automaticaly translated to ASCII if cmsfs-fuse is started
The filetypes.conf file contains the CMS file types that are automatically translated to ASCII if cmsfs-fuse is started
with the -t option. The syntax of the configuration file is one file type per line. Lines that start with a # followed by a space are treated as
comments and are ignored. The file type is 8 characters long and must consist of valid CMS file name characters only.

View File

@@ -3,7 +3,7 @@
*
* Main function
*
* Copyright IBM Corp. 2010, 2017
* Copyright IBM Corp. 2010, 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.
@@ -17,6 +17,7 @@
#include <fuse.h>
#include <fuse_opt.h>
#include <iconv.h>
#include <limits.h>
#include <linux/fs.h>
#ifdef HAVE_SETXATTR
#include <linux/xattr.h>
@@ -36,6 +37,7 @@
#include <unistd.h>
#include "lib/util_base.h"
#include "lib/util_libc.h"
#include "lib/util_list.h"
#include "lib/zt_common.h"
@@ -76,7 +78,7 @@ static const struct fuse_opt cmsfs_opts[] = {
static void usage(const char *progname)
{
fprintf(stderr,
fprintf(stdout,
"Usage: %s DEVICE MOUNTPOINT [OPTIONS]\n"
"\n"
"Use the cmsfs-fuse command to read and write files stored on a z/VM CMS disk.\n"
@@ -232,6 +234,8 @@ struct file {
int null_records;
/* write cache for text mode */
char *wcache;
/* buffer for iconv */
char *iconv_buf;
/* used bytes in write cache */
int wcache_used;
/* committed written bytes to FUSE */
@@ -601,7 +605,7 @@ static struct file *file_open(const char *name)
char uc_name[MAX_FNAME];
struct file *f;
strncpy(uc_name, name, MAX_FNAME);
util_strlcpy(uc_name, name, MAX_FNAME);
str_toupper(uc_name);
util_list_iterate(&open_file_list, f)
@@ -923,7 +927,6 @@ static void set_record(struct file *f, int *record, off_t addr, int len,
static void add_record_ext(struct record *rec, struct record_ext *ext)
{
struct record_ext *tmp;
int i = 0;
if (rec->ext == NULL) {
rec->ext = ext;
@@ -931,9 +934,7 @@ static void add_record_ext(struct record *rec, struct record_ext *ext)
ext->next = NULL;
} else {
tmp = rec->ext;
i++;
while (tmp->next != NULL) {
i++;
tmp = tmp->next;
}
tmp->next = ext;
@@ -1567,7 +1568,7 @@ static off_t lookup_file(const char *name, struct fst_entry *fst, int flag)
off_t faddr = 0;
int rc;
strncpy(uc_name, name, MAX_FNAME);
util_strlcpy(uc_name, name, MAX_FNAME);
str_toupper(uc_name);
if (flag == HIDE_UNLINKED && file_unlinked(uc_name))
@@ -1851,7 +1852,26 @@ static int cmsfs_open(const char *path, struct fuse_file_info *fi)
if (f->wcache == NULL)
return -ENOMEM;
strncpy(f->path, path, MAX_FNAME + 1);
/*
* For fixed-length records f->fst->record_len contains
* the fixed record length, which will not change. For
* variable-length records it contains the (current) maximum
* record length, which could be increased later by appending
* new records, so use MAX_RECORD_LEN for the iconv buffer.
* The MAX_RECORD_LEN is not valid for fixed-length records,
* only for variable-length records, so use the actual record
* length (f->fst->record_len) for fixed-length records.
*/
if (f->fst->record_format == RECORD_LEN_FIXED)
f->iconv_buf = malloc(f->fst->record_len + 1);
else
f->iconv_buf = malloc(MAX_RECORD_LEN + 1);
if (f->iconv_buf == NULL) {
destroy_file_object(f);
return -ENOMEM;
}
util_strlcpy(f->path, path, MAX_FNAME + 1);
str_toupper(f->path);
f->use_count = 1;
@@ -2108,7 +2128,7 @@ static int cmsfs_create(const char *path, mode_t mode,
return rc;
/* force uppercase */
strncpy(uc_name, path + 1, MAX_FNAME);
util_strlcpy(uc_name, path + 1, MAX_FNAME);
str_toupper(uc_name);
rc = encode_edf_name(uc_name, fname, ftype);
@@ -2550,14 +2570,13 @@ static void get_block_data_from_record(struct record *rec, off_t offset,
}
}
static int convert_text(iconv_t conv, char *buf, int size)
static int convert_text(iconv_t conv, char *in_buf, char *out_buf, int size)
{
size_t out_count = size;
size_t in_count = size;
char *data_ptr = buf;
int rc;
rc = iconv(conv, &data_ptr, &in_count, &data_ptr, &out_count);
rc = iconv(conv, &in_buf, &in_count, &out_buf, &out_count);
if ((rc == -1) || (in_count != 0)) {
DEBUG("Code page translation EBCDIC-ASCII failed\n");
return -EIO;
@@ -2618,14 +2637,15 @@ static int cmsfs_read(const char *path, char *buf, size_t size, off_t offset,
/* read one record */
if (addr == NULL_BLOCK)
memset(buf, 0, chunk);
else {
rc = _read(buf, chunk, addr);
else if (f->translate) {
rc = _read(f->iconv_buf, chunk, addr);
if (rc < 0)
return rc;
}
if (f->translate) {
rc = convert_text(cmsfs.iconv_from, buf, chunk);
rc = convert_text(cmsfs.iconv_from, f->iconv_buf, buf, chunk);
if (rc < 0)
return rc;
} else {
rc = _read(buf, chunk, addr);
if (rc < 0)
return rc;
}
@@ -2757,7 +2777,7 @@ static int delete_file(const char *path)
fst_last = find_last_fdir_entry(cmsfs.fdir, cmsfs.dir_levels);
/* remove unlinked file from fcache */
strncpy(file, path + 1, MAX_FNAME);
util_strlcpy(file, path + 1, MAX_FNAME);
str_toupper(file);
invalidate_htab_entry(file);
@@ -2841,20 +2861,21 @@ static int cmsfs_rename(const char *path, const char *new_path)
str_toupper(uc_new_name);
rc = encode_edf_name(uc_new_name, fname, ftype);
free(uc_new_name);
if (rc)
return rc;
memcpy(&fst.name[0], fname, 8);
memcpy(&fst.type[0], ftype, 8);
strncpy(uc_old_name, path + 1, MAX_FNAME);
util_strlcpy(uc_old_name, path + 1, MAX_FNAME);
str_toupper(uc_old_name);
invalidate_htab_entry(uc_old_name);
/* update name in file object if the file is opened */
f = file_open(uc_old_name);
if (f != NULL) {
strncpy(f->path, new_path, MAX_FNAME + 1);
util_strlcpy(f->path, new_path, MAX_FNAME + 1);
str_toupper(f->path);
memcpy(f->fst->name, fname, 8);
memcpy(f->fst->type, ftype, 8);
@@ -3743,7 +3764,7 @@ static int extend_block_variable(struct file *f, const char *buf, int len,
}
DEBUG("%s: wrote %d record bytes\n", __func__, rlen);
if (size <= 0)
if (size == 0)
return copied;
}
@@ -4167,22 +4188,13 @@ static ssize_t find_newline(const char *buf, int len)
return pos - buf;
}
static int cmsfs_write(const char *path, const char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
static int cmsfs_write_strings(struct file *f, const char *buf,
size_t size, off_t offset)
{
int scan_len = MIN(size, (size_t)MAX_RECORD_LEN + 1);
int rc, nl_byte = 1, null_record = 0, pad = 0;
struct file *f = get_fobj(fi);
ssize_t rsize;
(void) path;
if (cmsfs.readonly)
return -EROFS;
if (!f->linefeed)
return do_write(f, buf, size, offset);
/* remove already committed bytes */
offset -= f->wcache_commited;
@@ -4222,7 +4234,7 @@ static int cmsfs_write(const char *path, const char *buf, size_t size,
}
/* translate */
rc = convert_text(cmsfs.iconv_to, f->wcache, f->wcache_used);
rc = convert_text(cmsfs.iconv_to, f->wcache, f->iconv_buf, f->wcache_used);
if (rc < 0)
return rc;
@@ -4232,6 +4244,7 @@ static int cmsfs_write(const char *path, const char *buf, size_t size,
*/
if (!f->wcache_used) {
*f->wcache = FILLER_EBCDIC;
*f->iconv_buf = FILLER_EBCDIC;
f->wcache_used = 1;
nl_byte = 0;
null_record = 1;
@@ -4242,7 +4255,7 @@ static int cmsfs_write(const char *path, const char *buf, size_t size,
offset += f->pad_bytes;
BUG(offset < 0);
rc = do_write(f, f->wcache, f->wcache_used, offset);
rc = do_write(f, f->iconv_buf, f->wcache_used, offset);
if (rc < 0)
return rc;
@@ -4257,6 +4270,36 @@ static int cmsfs_write(const char *path, const char *buf, size_t size,
return rc;
}
static int cmsfs_write(const char *path, const char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
{
struct file *f = get_fobj(fi);
int rc, written, nbytes;
(void) path;
if (cmsfs.readonly)
return -EROFS;
if (!f->linefeed)
return do_write(f, buf, size, offset);
/* Limit the size to what we can report back as written */
nbytes = MIN(size, (size_t) INT_MAX);
written = 0;
while (nbytes) {
rc = cmsfs_write_strings(f, buf, nbytes, offset);
if (rc < 0)
return written ? written : rc;
written += rc;
offset += rc;
buf += rc;
nbytes -= rc;
}
return written;
}
static int cmsfs_unlink(const char *path)
{
struct fst_entry fst;
@@ -4284,7 +4327,7 @@ static int flush_wcache(struct file *f)
int rc;
/* translate */
rc = convert_text(cmsfs.iconv_to, f->wcache, f->wcache_used);
rc = convert_text(cmsfs.iconv_to, f->wcache, f->iconv_buf, f->wcache_used);
if (rc < 0)
return rc;
@@ -4292,7 +4335,7 @@ static int flush_wcache(struct file *f)
offset -= (f->fst->nr_records - f->null_records);
BUG(offset < 0);
rc = do_write(f, f->wcache, f->wcache_used, offset);
rc = do_write(f, f->iconv_buf, f->wcache_used, offset);
purge_wcache(f);
f->null_records = 0;
if (rc < 0)
@@ -4415,6 +4458,7 @@ static void destroy_file_object(struct file *f)
struct record *rec;
int i;
free(f->iconv_buf);
free(f->wcache);
free(f->wstate);
@@ -4498,14 +4542,23 @@ static int cmsfs_process_args(void *data, const char *arg, int key,
return 1;
case KEY_HELP:
usage(outargs->argv[0]);
/*
* Usage output needs to go to stdout to be consistent with
* coding guidelines. FUSE versions before 3.0.0 print help
* output to stderr. Redirect stderr to stdout here to enforce
* consistent behavior.
*/
fflush(stderr);
dup2(STDOUT_FILENO, STDERR_FILENO);
fuse_opt_add_arg(outargs, "-ho");
cmsfs_fuse_main(outargs, &cmsfs_oper);
exit(0);
case KEY_VERSION:
fprintf(stderr, COMP "FUSE file system for CMS disks "
fprintf(stdout, COMP "FUSE file system for CMS disks "
"program version %s\n", RELEASE_STRING);
fprintf(stderr, "Copyright IBM Corp. 2010, 2017\n");
fuse_opt_add_arg(outargs, "--version");
fprintf(stdout, "Copyright IBM Corp. 2010, 2017\n");
exit(0);
default:

View File

@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <unistd.h>
#include "lib/util_libc.h"
#include "lib/zt_common.h"
#include "cmsfs-fuse.h"
@@ -65,7 +66,7 @@ static void add_filetype(char *name, struct util_list *list)
entry = malloc(sizeof(*entry));
if (entry == NULL)
DIE_PERROR("malloc failed");
strncpy(entry->name, name, MAX_TYPE_LEN);
util_strlcpy(entry->name, name, MAX_TYPE_LEN);
util_list_add_head(list, entry);
}

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 = 9
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,22 +168,24 @@ 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)
export INSTALLDIR BINDIR LIBDIR MANDIR OWNER GROUP
# Special defines for zfcpdump
ZFCPDUMP_PART_IMAGE = zfcpdump_part.image
ZFCPDUMP_PART_RD = zfcpdump_part.rd
export ZFCPDUMP_DIR ZFCPDUMP_PART_IMAGE ZFCPDUMP_PART_RD
ZFCPDUMP_IMAGE = zfcpdump-image
ZFCPDUMP_INITRD = zfcpdump-initrd
ZFCPDUMP_FLAVOR = zfcpdump
export ZFCPDUMP_DIR ZFCPDUMP_IMAGE ZFCPDUMP_INITRD ZFCPDUMP_FLAVOR
CFLAGS ?= $(DEFAULT_CFLAGS) $(OPT_FLAGS)
HOSTCFLAGS ?= $(DEFAULT_CFLAGS) $(OPT_FLAGS)
@@ -193,12 +196,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,18 +219,28 @@ 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 $@
%: %.o
$(LINK) $(ALL_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@
%.a:
$(AR) rcs $@ $^
@@ -316,14 +331,14 @@ $(rootdir)/libzds/libzds.a: $(rootdir)/libzds
$(MAKE) -C $(rootdir)/libzds/ libzds.a
.PHONY: $(rootdir)/libzds
$(rootdir)/libu2s/libu2s.a: $(rootdir)/libu2s
$(MAKE) -C $(rootdir)/libu2s/ libu2s.a
.PHONY: $(rootdir)/libu2s
$(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

@@ -110,7 +110,7 @@ The default command is --print all.
.
.SH FILES
.nf
/var/run/cpacfstatsd_socket
/run/cpacfstatsd_socket
.fi
.
.SH RETURN VALUE

View File

@@ -78,8 +78,8 @@ struct msg_answer {
#define BACKLOG 10
#define SOCKET_FILE "/var/run/cpacfstatsd_socket"
#define PID_FILE "/var/run/cpacfstatsd.pid"
#define SOCKET_FILE "/run/cpacfstatsd_socket"
#define PID_FILE "/run/cpacfstatsd.pid"
#define CPACFSTATS_GROUP "cpacfstats"

View File

@@ -47,7 +47,7 @@ restart the daemon to ensure correct summing of the per-CPU performance
counters.
The starting daemon first checks for any stale pid file
/var/run/cpacfstatsd.pid. If this file exists, and the process ID in the
/run/cpacfstatsd.pid. If this file exists, and the process ID in the
file belongs to an active process, an error message is printed to the
console and the program terminates.
@@ -81,8 +81,8 @@ daemon startup and initialization failures.
.SH FILES
.nf
/var/run/cpacfstatsd_socket
/var/run/cpacfstatsd.pid
/run/cpacfstatsd_socket
/run/cpacfstatsd.pid
.fi
.SH RETURN VALUE

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

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

@@ -51,10 +51,11 @@ sub cpumf_get_sfb_size()
my $val = "0,0";
my $SFBSIZE;
return $val unless open($SFBSIZE, '<', $CPUM_SFB_SIZE);
$val = <$SFBSIZE>;
chomp($val);
close($SFBSIZE);
if (open($SFBSIZE, '<', $CPUM_SFB_SIZE)) {
$val = <$SFBSIZE>;
chomp($val);
close($SFBSIZE);
}
return [split /,/, $val];
}
@@ -172,7 +173,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 +211,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 +231,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 +261,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 +357,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 +462,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

@@ -7,7 +7,7 @@ LDLIBS += -lm
OBJECTS = daemon.o cpu.o info.o terms.o config.o main.o getopt.o mem.o
cpuplugd: $(OBJECTS)
$(LINK) $(ALL_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@
clean:
rm -f cpuplugd $(OBJECTS)

View File

@@ -3,7 +3,7 @@
*
* Config file parsing
*
* Copyright IBM Corp. 2007, 2017
* Copyright IBM Corp. 2007, 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.
@@ -201,6 +201,7 @@ void parse_configfile(char *file)
linebuffer);
parse_configline(linebuffer);
}
fclose(filp);
}
/*

View File

@@ -161,8 +161,8 @@ int is_online(int cpuid)
retval = 1;
if (state == 0)
retval = 0;
fclose(filp);
}
fclose(filp);
}
return retval;
}
@@ -220,8 +220,8 @@ int cpu_is_configured(int cpuid)
retval = 1;
if (state == 0)
retval = 0;
fclose(filp);
}
fclose(filp);
}
return retval;
}

View File

@@ -27,7 +27,7 @@
#define NAME "cpuplugd"
#define MAX_HISTORY 100
#define PIDFILE "/var/run/cpuplugd.pid"
#define PIDFILE "/run/cpuplugd.pid"
#define LOCKFILE "/var/lock/cpuplugd.lock"
#define PROCINFO_LINE 512
#define CPUSTAT_SIZE 1024
@@ -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

@@ -4,7 +4,6 @@ all: dasdfmt
libs = $(rootdir)/libdasd/libdasd.a \
$(rootdir)/libvtoc/libvtoc.a \
$(rootdir)/libu2s/libu2s.a \
$(rootdir)/libutil/libutil.a
dasdfmt: dasdfmt.o $(libs)

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 = dasd_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,7 @@
include ../common.mak
libs = $(rootdir)/libu2s/libu2s.a \
$(rootdir)/libutil/libutil.a
libs = $(rootdir)/libutil/libutil.a \
$(rootdir)/libdasd/libdasd.a
all: dasdinfo

View File

@@ -34,7 +34,7 @@ Print DASD uid
This option prints the full uid of the DASD. When z/VM provides two
virtual devices that are actually located on the same real device, the
first four tokens of the uid will be identical for both devices. z/VM
may provide an additional token that allows to distinguish between
may provide an additional token that can be used to distinguish between
different minidisks. You need both support in the Linux kernel and
z/VM to receive such an additional token.
@@ -45,7 +45,7 @@ available by applying the PTFs for VM APAR VM64273 on z/VM 5.2.0 and higher.
.BI "-u|--uid"
Print DASD uid without z/VM minidisk token
z/VM may provide an additional token that allows to distinguish
z/VM may provide an additional token that can be used to distinguish
between different minidisks (see --extended-uid option). To remain
compatibile with systems that were installed on older Linux or z/VM
levels, the -u option will print the uid excluding any z/VM-provided

View File

@@ -22,16 +22,15 @@
#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_libc.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 +98,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 +165,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");
if (dasd_get_blocksize(device, &blksize) != 0) {
warnx("Unable to figure out block size");
goto error;
}
if (ioctl(f, BLKSSZGET, &data.blksize) != 0) {
printf("Unable to figure out block size.\n");
if (dasd_get_info(device, &dasd_info) != 0) {
warnx("Unable to figure out DASD information");
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;
}
f = open(device, O_RDONLY);
if (f < 0) {
warnx("Could not open device node");
goto error;
}
vlabel_start = data.dasd_info.label_block * data.blksize;
vlabel_start = dasd_info.label_block * blksize;
if (lseek(f, vlabel_start, SEEK_SET) < 0)
goto error;
goto error_close;
bzero(vlabel, vlsize);
if (read(f, vlabel, vlsize) != vlsize) {
printf("Could not read volume label.\n");
goto error;
warnx("Could not read volume label");
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 +237,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;
}
@@ -338,10 +256,9 @@ static void *dinfo_malloc(size_t size)
void *result;
result = malloc(size);
if (result == NULL) {
printf("Could not allocate %lld bytes of memory",
(unsigned long long) size);
}
if (result == NULL)
warnx("Could not allocate %lu bytes of memory", 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,33 +312,33 @@ 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);
}
}
printf("Error: Unable to create temporary device node");
warnx("Error: Unable to create temporary device node");
return -1;
}
static void dinfo_free_devnode(char *device)
{
if (remove(device)) {
printf("Warning: Could not remove "
"temporary file %s", device);
}
if (remove(device))
warnx("Warning: Could not remove temporary file %s", 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) {
printf("Error: unable to extract major/minor\n");
bzero(tmp, RD_BUFFER_SIZE);
util_strlcpy(tmp, str, RD_BUFFER_SIZE);
p = strchr(tmp, ':');
if (p == NULL) {
warnx("Error: unable to extract major/minor");
return -1;
}
@@ -435,37 +353,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) {
printf("Error: Not enough memory to allocate readbuffer\n");
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
if (!readbuf) {
warnx("Error: Not enough memory to allocate readbuffer");
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 +376,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 +392,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 +408,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,55 +481,49 @@ 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);
warnx("Error: could not stat %s", devnode);
return -1;
}
sprintf(stat_dev, "%d:%d", major(stat_buffer.st_rdev),
minor(stat_buffer.st_rdev));
if ((directory = opendir("/sys/block/")) == NULL) {
printf("Error: could not open directory /sys/block\n");
directory = opendir("/sys/block/");
if (directory == NULL) {
warnx("Error: could not open directory /sys/block");
return -1;
}
if ((readbuf = dinfo_malloc(readbuflen)) == NULL) {
printf("Error: Not enough memory to allocate readbuffer\n");
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
if (!readbuf) {
warnx("Error: Not enough memory to allocate readbuffer");
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 +532,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 +576,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,40 +602,39 @@ 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);
warnx("%s %d.%d is not supported", uname_buf.sysname,
version, release);
exit(1);
}
if (!busid && !blockdev && !devnode) {
printf("Error: please specify a device using either -b, -i "
"or -d\n");
warnx("Error: please specify a device using either -b, -i or -d");
exit(1);
}
if ((busid && blockdev) || (busid && devnode) || (blockdev && devnode)) {
printf("Error: please specify device only once, either -b, -i "
"or -d\n");
warnx("Error: please specify device only once, either -b, -i or -d");
exit(1);
}
if (!print_uid && !print_extended_uid && !print_vlabel) {
printf("Error: no action specified (e.g. -u)\n");
warnx("Error: no action specified (e.g. -u)");
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 +646,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 +654,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,21 +699,22 @@ 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;
}
error:
printf("Error: could not read unique DASD ID\n");
warnx("Error: could not read unique DASD ID");
rc = 1;
out:

View File

@@ -7,7 +7,6 @@ all: dasdview
libs = $(rootdir)/libdasd/libdasd.a \
$(rootdir)/libzds/libzds.a \
$(rootdir)/libvtoc/libvtoc.a \
$(rootdir)/libu2s/libu2s.a \
$(rootdir)/libutil/libutil.a
dasdview: dasdview.o $(libs)

File diff suppressed because it is too large Load Diff

View File

@@ -11,145 +11,11 @@
#define DASDVIEW_H
#include <limits.h>
#include "lib/u2s.h"
/********************************************************************************
* 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 +36,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 +66,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;
@@ -257,7 +108,7 @@ typedef struct dasdview_info
int f8c;
int f9c;
char busid[U2S_BUS_ID_SIZE];
char busid[DASD_BUS_ID_SIZE];
int busid_valid;
int raw_track_access;
struct zdsroot *zdsroot;

View File

@@ -78,7 +78,7 @@ static void set_time(char *dest, size_t len, time_t value)
#define SET_TIME_FIELD(obj, name, value) \
set_time((obj)->name, sizeof((obj)->name), (time_t) (value))
#define SET_STR_FIELD(obj, name, value) \
strncpy((obj)->name, (value), sizeof((obj)->name))
util_strlcpy((obj)->name, (value), sizeof((obj)->name))
/* Initialize the tar file @header with the provided data */
static void init_header(struct tar_header *header, const char *filename,

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

@@ -13,7 +13,7 @@
DAEMON=cpacfstatsd
DAEMON_PATH=/usr/sbin/cpacfstatsd
RUN_PID_FILE=/var/run/cpacfstatsd.pid
RUN_PID_FILE=/run/cpacfstatsd.pid
RETVAL=0
OPTIONS=""

View File

@@ -17,7 +17,7 @@
DAEMON=cpuplugd
DAEMON_PATH=/usr/sbin/cpuplugd
CONFIG_FILE=/etc/cpuplugd.conf
RUN_PID_FILE=/var/run/cpuplugd.pid
RUN_PID_FILE=/run/cpuplugd.pid
RETVAL=0
OPTIONS="-c $CONFIG_FILE"

View File

@@ -22,7 +22,7 @@ DUMP_CONFIG_FILE=/etc/sysconfig/dumpconf
CMDFULL=$0
CMD="dumpconf"
LOCKFILE=/var/lock/$CMD
PIDFILE=/var/run/$CMD.pid
PIDFILE=/run/$CMD.pid
ERRMSG="Check $DUMP_CONFIG_FILE!"
RETVAL=0

View File

@@ -20,8 +20,8 @@ PROCD=mon_procd
FSSTATD_PATH=/usr/sbin/$FSSTATD
PROCD_PATH=/usr/sbin/$PROCD
CONFIG_FILE=/etc/sysconfig/$DAEMON
FSSTATD_PID_FILE=/var/run/$FSSTATD.pid
PROCD_PID_FILE=/var/run/$PROCD.pid
FSSTATD_PID_FILE=/run/$FSSTATD.pid
PROCD_PID_FILE=/run/$PROCD.pid
# source function library
. /lib/lsb/init-functions

View File

@@ -0,0 +1,2 @@
# Load protected key support module on s390 early at boot
pkey

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

@@ -3,7 +3,6 @@ include ../common.mak
libs = $(rootdir)/libvtoc/libvtoc.a \
$(rootdir)/libzds/libzds.a \
$(rootdir)/libdasd/libdasd.a \
$(rootdir)/libu2s/libu2s.a \
$(rootdir)/libutil/libutil.a
all: fdasd

View File

@@ -1,7 +1,7 @@
/*
* fdasd - Create or modify partitions on ECKD DASDs
*
* Copyright IBM Corp. 2001, 2017
* Copyright IBM Corp. 2001, 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.
@@ -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
@@ -259,7 +258,7 @@ static void fdasd_check_volser(char *volser, int devno)
{
int from, to;
for (from = 0, to = 0; volser[from] && from < VOLSER_LENGTH; from++)
for (from = 0, to = 0; from < VOLSER_LENGTH && volser[from]; from++)
if ((volser[from] >= 0x23 &&
volser[from] <= 0x25) || /* # $ % */
(volser[from] >= 0x30 &&
@@ -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);
@@ -728,9 +727,9 @@ static int fdasd_parse_conffile(fdasd_anchor_t *anc,
memset(buffer, 0, sizeof(buffer));
rc = read(fd, buffer, sizeof(buffer) - 1);
close(fd);
if (rc < 0)
return -1;
close(fd);
for (i = 0; i < rc; i++)
buffer[i] = toupper(buffer[i]);
@@ -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);
}
@@ -936,7 +935,7 @@ static void fdasd_verify_device(fdasd_anchor_t *anc, char *name)
fdasd_error(anc, device_verification_failed, err_str);
}
count = u2s_get_host_access_count(name);
count = dasd_get_host_access_count(name);
if (anc->force_host) {
if (count > 1) {
snprintf(err_str, ERROR_STRING_SIZE,
@@ -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);
}
/*
@@ -1273,7 +1257,7 @@ static void fdasd_write_vtoc_labels(fdasd_anchor_t *anc)
printf("DSCBs: ");
blk = (cchhb2blk(&anc->vlabel->vtoc, &geo) - 1) * anc->blksize;
if (blk <= 0)
if (cchhb2blk(&anc->vlabel->vtoc, &geo) == 0 || blk == 0)
fdasd_error(anc, vlabel_corrupted, "");
maxblk = blk + anc->blksize * 9; /* f4+f5+f7+3*f8+3*f9 */
@@ -1326,7 +1310,7 @@ static void fdasd_write_vtoc_labels(fdasd_anchor_t *anc)
volser[VOLSER_LENGTH] = ' ';
strncpy(c1, volser, VOLSER_LENGTH + 1);
c1 = strchr(ch, ' ');
strncpy(c1, s2, 31);
memcpy(c1, s2, 31);
} else {
if (get_part_type_by_dsname(ch, &part_info->type))
part_info->type = PARTITION_NATIVE;
@@ -1335,25 +1319,25 @@ 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 "
memcpy(ch, "LINUX.V "
" ", 44);
strncpy(volser, anc->vlabel->volid, VOLSER_LENGTH);
vtoc_ebcdic_dec(volser, volser, VOLSER_LENGTH);
strncpy(c1, volser, VOLSER_LENGTH);
memcpy(c1, volser, VOLSER_LENGTH);
c1 = strchr(ch, ' ');
strncpy(c1, ".PART", 5);
memcpy(c1, ".PART", 5);
c1 += 5;
sprintf(dsno, "%04d.", k + 1);
strncpy(c1, dsno, 5);
memcpy(c1, dsno, 5);
c1 += 5;
get_part_dsname_by_type(part_info->type, &dsname);
strncpy(c1, dsname, strlen(dsname)); /* We don't want \0 */
memcpy(c1, dsname, strlen(dsname)); /* We don't want \0 */
}
vtoc_ebcdic_enc(ch, ch, 44);
if (anc->verbose)
@@ -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;
}
@@ -1650,7 +1636,7 @@ static void fdasd_change_part_type(fdasd_anchor_t *anc)
ch = strstr(part_info->f1->DS1DSNAM, "PART") + 9;
if (ch != NULL)
strncpy(ch, str, 6);
memcpy(ch, str, 6);
vtoc_ebcdic_enc(part_info->f1->DS1DSNAM, part_info->f1->DS1DSNAM, 44);
anc->vtoc_changed++;
}
@@ -2008,7 +1994,7 @@ static int fdasd_check_volume(fdasd_anchor_t *anc)
printf(" VOL1\n");
blk = (cchhb2blk(&vlabel->vtoc, &geo) - 1) * anc->blksize;
if (blk > 0) {
if (cchhb2blk(&vlabel->vtoc, &geo) > 0 && blk > 0) {
rc = fdasd_valid_vtoc_pointer(anc, blk);
if (anc->print_table && (rc < 0))
@@ -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

@@ -31,12 +31,13 @@ LDLIBS += $(FUSE_LDLIBS) -lpthread -lrt -ldl -lm
OBJECTS = hmcdrvfs.o
libs = $(rootdir)/libutil/libutil.a
all: check_dep hmcdrvfs
$(OBJECTS): Makefile
hmcdrvfs: $(OBJECTS)
hmcdrvfs: $(OBJECTS) $(libs)
install: all install-scripts
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 hmcdrvfs \
@@ -49,7 +50,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

@@ -27,6 +27,7 @@
#include <time.h>
#include <unistd.h>
#include "lib/util_libc.h"
#include "lib/zt_common.h"
#define HMCDRV_FUSE_LOGNAME "hmcdrvfs" /* log prefix */
@@ -276,7 +277,7 @@ static void hmcdrv_cache_symlink(struct hmcdrv_fuse_file *fp,
fp->symlnk = malloc(HMCDRV_FUSE_MAXPATH);
if (fp->symlnk != NULL) {
strncpy(fp->symlnk, symlink, HMCDRV_FUSE_MAXPATH);
util_strlcpy(fp->symlnk, symlink, HMCDRV_FUSE_MAXPATH);
fp->symlnk[HMCDRV_FUSE_MAXPATH - 1] = '\0';
}
}
@@ -483,8 +484,7 @@ static ssize_t hmcdrv_ftp_transfer(struct hmcdrv_fuse_file *fp, char *buf,
}
current_offset += retlen;
strncpy(last_ftpcmd, fp->ftpcmd, HMCDRV_FUSE_MAXCMDLEN);
last_ftpcmd[HMCDRV_FUSE_MAXCMDLEN - 1] = '\0';
util_strlcpy(last_ftpcmd, fp->ftpcmd, HMCDRV_FUSE_MAXCMDLEN);
return retlen;
}
@@ -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 */
@@ -850,13 +853,12 @@ static char *hmcdrv_parse_line(char *line, char *namebuf,
*arrow = '\0';
}
strncpy(namebuf, attr.fname, bufsize);
namebuf[bufsize - 1] = '\0'; /* safety */
util_strlcpy(namebuf, attr.fname, bufsize);
if (arrow == NULL) {
symlink[0] = '\0';
} else {
strncpy(symlink, arrow + 4, HMCDRV_FUSE_MAXPATH);
util_strlcpy(symlink, arrow + 4, HMCDRV_FUSE_MAXPATH);
*arrow = ' '; /* restore */
}
@@ -1145,8 +1147,7 @@ static int hmcdrv_fuse_readlink(const char *path, char *buf, size_t size)
if (!S_ISLNK(fp->st.st_mode)) {
rc = -EINVAL;
} else {
strncpy(buf, fp->symlnk, size);
buf[size - 1] = '\0';
util_strlcpy(buf, fp->symlnk, size);
}
}
}
@@ -1335,7 +1336,7 @@ static int hmcdrv_fuse_main(struct fuse_args *args)
*/
static void hmcdrv_fuse_usage(const char *progname)
{
fprintf(stderr,
fprintf(stdout,
"Usage: %s MOUNTPOINT [OPTIONS]\n\n"
"Use the %s command to read files from a HMC drive DVD.\n"
"\n"
@@ -1447,7 +1448,7 @@ static int hmcdrv_fuse_optproc(void *data, const char *arg,
return 1;
case HMCDRV_FUSE_OPTKEY_VERSION:
fprintf(stderr, HMCDRV_FUSE_LOGHEAD
fprintf(stdout, HMCDRV_FUSE_LOGHEAD
"HMC drive DVD file system, version %s\n"
"Copyright IBM Corp. 2015, 2017\n",
HMCDRV_FUSE_RELEASE);
@@ -1455,6 +1456,16 @@ static int hmcdrv_fuse_optproc(void *data, const char *arg,
case HMCDRV_FUSE_OPTKEY_HELP:
hmcdrv_fuse_usage(outargs->argv[0]);
/*
* Usage output needs to go to stdout to be consistent with
* coding guidelines. FUSE versions before 3.0.0 print help
* output to stderr. Redirect stderr to stdout here to enforce
* consistent behavior.
*/
fflush(stderr);
dup2(STDOUT_FILENO, STDERR_FILENO);
fuse_opt_add_arg(outargs, "-ho");
hmcdrv_fuse_main(outargs);
exit(EXIT_SUCCESS);

View File

@@ -55,8 +55,7 @@ struct l_x_sys_hdr {
static inline void l_sys_hdr__sys_name(struct l_x_sys_hdr *hdr, char *name)
{
memcpy(name, hdr->sys_name, LPAR_NAME_LEN);
ht_ebcdic_to_ascii(name, LPAR_NAME_LEN);
ht_ebcdic_to_ascii(hdr->sys_name, name, LPAR_NAME_LEN);
name[LPAR_NAME_LEN] = 0;
ht_strstrip(name);
}
@@ -176,7 +175,6 @@ static void l_sd_cpu_phys_fill(struct sd_sys *sys,
sd_cpu_state_set(cpu, SD_CPU_STATE_UNKNOWN);
}
sd_cpu_mgm_time_us_set(cpu, cpu_info->mgm_time);
sd_cpu_real_type_set(cpu, cpu_type);
sd_cpu_commit(cpu);
}

View File

@@ -245,8 +245,7 @@ static void l_sd_sys_root_fill(struct sd_sys *sys)
struct sd_sys *guest;
guest_name[NAME_LEN] = 0;
memcpy(guest_name, data->guest_name, NAME_LEN);
ht_ebcdic_to_ascii(guest_name, NAME_LEN);
ht_ebcdic_to_ascii(data->guest_name, guest_name, NAME_LEN);
ht_strstrip(guest_name);
guest = sd_sys_get(sys, guest_name);

View File

@@ -98,9 +98,15 @@ void *ht_realloc(void *old_ptr, size_t size)
/*
* Convert EBCDIC string to ASCII
*/
void ht_ebcdic_to_ascii(char *inout, size_t len)
void ht_ebcdic_to_ascii(char *in, char *out, size_t size)
{
iconv(l_iconv_ebcdic_ascii, &inout, &len, &inout, &len);
size_t size_out = size;
size_t size_in = size;
size_t rc;
rc = iconv(l_iconv_ebcdic_ascii, &in, &size_in, &out, &size_out);
if (rc == (size_t) -1)
ERR_EXIT_ERRNO("Code page translation EBCDIC-ASCII failed");
}
/*

View File

@@ -17,6 +17,7 @@
#include <sys/types.h>
#include "lib/util_base.h"
#include "lib/util_libc.h"
#include "lib/zt_common.h"
#define G0(x) MAX(0, (s64) (x))
@@ -29,7 +30,7 @@ extern char *ht_strstrip(char *str);
extern char *ht_strdup(const char *str);
extern void ht_print_head(const char *sys);
extern void ht_print_help_icon(void);
extern void ht_ebcdic_to_ascii(char *inout, size_t len);
extern void ht_ebcdic_to_ascii(char *in, char *out, size_t len);
extern char *ht_mount_point_get(const char *fs_type);
extern u64 ht_ext_tod_2_us(void *tod_ext);
extern void ht_print_time(void);

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 */

View File

@@ -195,7 +195,6 @@ struct sd_cpu {
struct sd_info i;
char id[9];
struct sd_cpu_type *type;
char real_type[CPU_TYPE_ID_LEN];
struct sd_cpu_info d1;
struct sd_cpu_info d2;
struct sd_cpu_info *d_cur;
@@ -228,11 +227,6 @@ static inline void sd_cpu_state_set(struct sd_cpu *cpu, enum sd_cpu_state state)
cpu->state = state;
}
static inline void sd_cpu_real_type_set(struct sd_cpu *cpu, const char *type)
{
strncpy(cpu->real_type, type, sizeof(cpu->real_type));
}
static inline void sd_cpu_cpu_time_us_set(struct sd_cpu *cpu, u64 value)
{
cpu->d_cur->cpu_time_us = value;

View File

@@ -219,7 +219,7 @@ struct sd_cpu *sd_cpu_new(struct sd_sys *parent, const char *id,
cpu = ht_zalloc(sizeof(*cpu));
cpu->i.parent = parent;
strncpy(cpu->id, id, sizeof(cpu->id));
util_strlcpy(cpu->id, id, sizeof(cpu->id));
cpu->type = l_cpu_type_by_id(type);
cpu->d_cur = &cpu->d1;
cpu->cnt = cnt;
@@ -251,7 +251,7 @@ struct sd_sys *sd_sys_new(struct sd_sys *parent, const char *id)
struct sd_sys *sys_new;
sys_new = ht_zalloc(sizeof(*sys_new));
strncpy(sys_new->id, id, sizeof(sys_new->id));
util_strlcpy(sys_new->id, id, sizeof(sys_new->id));
util_list_init(&sys_new->child_list, struct sd_sys, list);
util_list_init(&sys_new->cpu_list, struct sd_cpu, list);

View File

@@ -47,7 +47,7 @@ static void l_mark_key_add(struct table *t, char *str)
struct table_mark_key *key;
key = ht_zalloc(sizeof(*key));
strncpy(key->str, str, sizeof(key->str));
util_strlcpy(key->str, str, sizeof(key->str));
util_list_add_tail(&t->mark_key_list, key);
}
@@ -617,7 +617,7 @@ void table_row_select_key_get(struct table *t, char str[TABLE_STR_MAX])
struct table_row *row;
row = l_selected_row(t);
strncpy(str, row->entries[0].str, TABLE_STR_MAX);
util_strlcpy(str, row->entries[0].str, TABLE_STR_MAX);
}
/*

View File

@@ -157,7 +157,7 @@ static void l_print_line(const char *line)
char line_cpy[TBOX_MAX_STR + 1];
char *ptr_old, *ptr;
strncpy(line_cpy, line, sizeof(line_cpy));
util_strlcpy(line_cpy, line, sizeof(line_cpy));
ptr_old = ptr = line_cpy;
do {
ptr = strchr(ptr, '\\');

View File

@@ -326,7 +326,7 @@ void win_sys_set(const char *sys_id)
{
if (l_initialized)
table_reset(l_t);
strncpy(l_sys_id, sys_id, sizeof(l_sys_id));
util_strlcpy(l_sys_id, sys_id, sizeof(l_sys_id));
}
/*

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

@@ -0,0 +1,216 @@
/*
* 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>
/* A bus id of a DASD is 8 characters long. E.g. 0.0.4711 */
#define DASD_BUS_ID_SIZE 9
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)
/* Reserve the device for the current LPAR */
#define BIODASDRSRV _IO(DASD_IOCTL_LETTER, 2)
/* Release the device for the current LPAR */
#define BIODASDRLSE _IO(DASD_IOCTL_LETTER, 3)
/* 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);
int dasd_disk_reserve(const char *device);
int dasd_disk_release(const char *device);
#endif /* LIB_DASD_BASE_H */

View File

@@ -13,9 +13,9 @@
#define LIB_DASD_SYS_H
#include <stdio.h>
#include "u2s.h"
int dasd_sys_raw_track_access(char *);
int dasd_reset_chpid(char *, char *);
int dasd_get_host_access_count(char *device);
#endif /* LIB_DASD_SYS_H */

View File

@@ -112,6 +112,8 @@
*/
#define LIB_LIBZDS_H
#include "lib/util_base.h"
#include "lib/util_list.h"
#include "vtoc.h"
@@ -328,11 +330,74 @@ struct pds_member_entry {
*/
struct zdsroot;
/**
* @struct raw_vtoc
* @brief The VTOC is a directory of data sets on one DASD
*
* As the VTOC is the data area on the DASD that describes all data sets,
* this library will often have to refer to the various records in the VTOC.
* To make this more efficient, we will read the whole VTOC once and identify
* all elements (DSCBs). The raw data of the VTOC tracks and the index to the
* DSCBs is stored.
*/
struct raw_vtoc {
/** @brief The raw track data */
char *rawdata;
/** @brief This size of the raw track data in bytes */
unsigned long long rawdatasize;
/** @brief An array with pointers to the various DSCBs in the rawdata */
char **vtocindex;
/** @brief Number of entries in the index */
unsigned int vtocindexcount;
/** @brief Number of records per VTOC track
*
* @note While the DS4DEVDT field in the format 4 DSCB names the number
* if DSCBs per VTOC track, we count the records, which is DS4DEVDT + 1
* for record 0.
*/
unsigned int vtoc_rec_per_track;
/** @brief The track number at which the vtoc begins on the DASD */
unsigned int vtoctrackoffset;
/** @brief Start record of VTOC.
*
* The rawdata contains full tracks. This is the number of the first
* record that actually belongs to the VTOC
*/
unsigned int vtocrecno;
/** @brief The DASD this vtoc was read from */
struct dasd *dasd;
/** @brief Detailed error messages in case of a problem */
struct errorlog *log;
};
/**
* @struct dasd
* @brief Represents one physical device, may have a vtoc
*/
struct dasd;
struct dasd {
/** @brief List head used to store a list of DASDs in struct zdsroot */
struct util_list_node list;
/** @brief Name of the block device, e.g. /dev/dasde */
char *device;
/** @brief File descriptor for the block device.
*
* The device is kept open for as along as the library uses it.
* This lets the system know that the device is still in use.
*/
int inusefd;
/* @brief where to find the volume label */
unsigned int label_block;
/** @brief Device geometry. How many cylinders does the DASD have. */
unsigned int cylinders;
/** @brief Device geometry. How many heads does the DASD have. */
unsigned int heads;
/** @brief The VTOC data that has been read from this device */
struct raw_vtoc *rawvtoc;
/** @brief The volume label that has been read from this device */
volume_label_t *vlabel;
/** @brief Detailed error messages in case of a problem */
struct errorlog *log;
};
/**
* @struct dasditerator
@@ -350,12 +415,6 @@ struct dasditerator;
*/
struct dasdhandle;
/**
* @struct raw_vtoc
* @brief The VTOC is a directory of data sets on one dasd
*/
struct raw_vtoc;
/**
* @struct dscbiterator
* @brief allows to iterate over all DSCBs in a vtoc
@@ -572,7 +631,13 @@ int lzds_dasd_get_vlabel(struct dasd *dasd, struct volume_label **vlabel);
* @brief Read the vtoc data from device. The data as stored as part
* of the struct dasd.
*/
int lzds_dasd_read_rawvtoc(struct dasd *dasd);
int lzds_dasd_read_rawvtoc(struct dasd *dasd, struct raw_vtoc *vtoc);
/**
* @brief Read the vtoc data from device. The data as stored as part
* of the struct dasd.
*/
int lzds_dasd_alloc_rawvtoc(struct dasd *dasd);
/**
* @brief Get the previously read raw_vtoc data.
@@ -787,6 +852,8 @@ int lzds_zdsroot_extract_datasets_from_dasd(struct zdsroot *root,
struct dasd *dasd);
void lzds_dslist_free(struct zdsroot *root);
/** @} */ /* end of group libzds_functions_high */

View File

@@ -1,21 +0,0 @@
/*
*
* Copyright IBM Corp. 2004, 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.
*
* History of changes (starts July 2004)
* 2004-07-02 initial
*/
#ifndef LIB_U2S_H
#define LIB_U2S_H
#define U2S_BUS_ID_SIZE 32
int u2s_getbusid(char *, char *);
int u2s_read_attribute(char *, char *, char *, size_t);
int u2s_get_host_access_count(char *);
#endif /* LIB_U2S_H */

View File

@@ -42,6 +42,9 @@ static inline void util_ptr_vec_free(void **ptr_vec, int count)
{
int i;
if (!ptr_vec || count < 0)
return;
for (i = 0; i < count; i++)
free(ptr_vec[i]);
free(ptr_vec);

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,11 @@ 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);
size_t util_strlcpy(char *dest, const char *src, size_t size);
#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;

View File

@@ -68,5 +68,8 @@ const char *util_rec_get(struct util_rec *rec, const char *key);
void util_rec_print_hdr(struct util_rec *rec);
void util_rec_print(struct util_rec *rec);
void util_rec_print_separator(struct util_rec *rec);
void util_rec_set_indent(struct util_rec *rec, int indent);
#endif /** LIB_UTIL_REC_H @} */

17
include/lib/util_sys.h Normal file
View File

@@ -0,0 +1,17 @@
/*
* @defgroup util_sys_h util_sys: SysFS interface
* @{
* @brief Work with SysFS
*
* Copyright IBM Corp. 2019
*
* 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_UTIL_SYS_H
#define LIB_UTIL_SYS_H
int util_sys_get_dev_addr(const char *dev, char *addr);
#endif /** LIB_UTIL_SYS_H @} */

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

@@ -2,13 +2,15 @@ include ../common.mak
all: xcec-bridge
xcec-bridge: xcec-bridge.o
libs = $(rootdir)/libutil/libutil.a
xcec-bridge: xcec-bridge.o $(libs)
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

@@ -31,6 +31,7 @@
#include <syslog.h>
#include <unistd.h>
#include "lib/util_libc.h"
#include "lib/zt_common.h"
/* a signal causes the interfaces to be re-checked */
@@ -40,7 +41,7 @@
#define UPDATE_SIGNAL SIGUSR1
#define DEV_NAME_LEN IFNAMSIZ
#define DEV_NAME_SIZE IFNAMSIZ
#define BUFFER_LEN 65536
@@ -55,7 +56,7 @@ struct int_sock {
int features;
int i_fd;
int o_fd;
char dev_name[DEV_NAME_LEN];
char dev_name[DEV_NAME_SIZE];
int mtu_warning;
struct int_sock *next;
@@ -91,7 +92,7 @@ int open_incoming_socket(char *dev_name)
return -1;
}
strncpy(if_req.ifr_name,dev_name,DEV_NAME_LEN);
util_strlcpy(if_req.ifr_name, dev_name, DEV_NAME_SIZE);
retval=ioctl(fd,SIOCGIFINDEX,&if_req);
if (retval==-1) {
syslog(LOG_ERR,"can't ioctl on raw packet socket, " \
@@ -192,7 +193,7 @@ int open_outgoing_socket(char *dev_name)
int interface_in_list(struct int_sock *item,struct int_sock *list)
{
for (;list;list=list->next) {
if (!strncmp(item->dev_name,list->dev_name,DEV_NAME_LEN)) {
if (!strncmp(item->dev_name,list->dev_name,DEV_NAME_SIZE)) {
return 1;
}
}
@@ -281,7 +282,7 @@ int read_sys(struct int_sock **nlist)
do_broadcast_bridging=0;
is->mtu_warning=0;
strncpy(is->dev_name, if_name, DEV_NAME_LEN);
util_strlcpy(is->dev_name, if_name, DEV_NAME_SIZE);
if (!strncmp(if_name,"hsi",3)) {
is->features=I_S_FEATURE_PASSTHROUGH;
}
@@ -317,7 +318,7 @@ void update_interfaces()
prev=NULL;
while (j) {
if (!strncmp(j->dev_name,i->dev_name,
DEV_NAME_LEN)) {
DEV_NAME_SIZE)) {
if (!prev) {
select_set.i_s_list=j->next;
} else {
@@ -360,7 +361,7 @@ void update_interfaces()
continue;
}
strncpy(new_int->dev_name,i->dev_name,DEV_NAME_LEN);
util_strlcpy(new_int->dev_name, i->dev_name, DEV_NAME_SIZE);
new_int->i_fd=i_fd;
new_int->o_fd=o_fd;
new_int->features=i->features;

View File

@@ -1,12 +1,16 @@
include ../common.mak
libs = $(rootdir)/libutil/libutil.a
all: chreipl lsreipl chshut lsshut
libs = $(rootdir)/libutil/libutil.a
objects = main.o ccw.o fcp.o system.o shutdown.o \
cmd_lsshut.o cmd_chshut.o cmd_lsreipl.o cmd_chreipl.o proc.o
chreipl: $(objects)
$(LINK) $(ALL_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
chreipl: $(objects) $(libs)
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@
lsreipl:
ln -sf chreipl lsreipl

View File

@@ -13,6 +13,7 @@
#include <ctype.h>
#include <sys/sysmacros.h>
#include "lib/util_libc.h"
#include "lib/zt_common.h"
#include "ipl_tools.h"
@@ -97,7 +98,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);
@@ -182,7 +183,7 @@ static void set_bootprog(const char *bootprog)
ERR_EXIT("Bootprog \"%s\" is not a decimal number", bootprog);
if (bootprog_int > UINT_MAX)
ERR_EXIT("Invalid bootprog specified");
strncpy(l.bootprog, bootprog, sizeof(l.bootprog));
util_strlcpy(l.bootprog, bootprog, sizeof(l.bootprog));
l.bootprog_set = 1;
}
@@ -294,7 +295,7 @@ static int set_reipl_type(const char *dev_name)
else
return -1;
strncpy(l.dev, dev_name, sizeof(l.dev));
util_strlcpy(l.dev, dev_name, sizeof(l.dev));
dev_from_part(l.dev);
l.dev_set = 1;
return 0;
@@ -302,19 +303,21 @@ static int set_reipl_type(const char *dev_name)
static int get_chreipl_helper_cmd(dev_t dev, char cmd[PATH_MAX])
{
char chreipl_helper[PATH_MAX];
char *chreipl_helper;
struct proc_dev_entry pde;
if (proc_dev_get_entry(dev, 1, &pde) != 0)
return -1;
snprintf(chreipl_helper, PATH_MAX,
"%s/%s.%s", TOOLS_LIBDIR, "chreipl_helper", pde.name);
util_asprintf(&chreipl_helper,
"%s/%s.%s", TOOLS_LIBDIR, "chreipl_helper", pde.name);
if (access(chreipl_helper, X_OK) != 0) {
proc_dev_free_entry(&pde);
free(chreipl_helper);
return -1;
}
sprintf(cmd, "%s %d:%d", chreipl_helper, major(dev), minor(dev));
proc_dev_free_entry(&pde);
free(chreipl_helper);
return 0;
}
@@ -445,7 +448,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 +542,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 +595,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 +622,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 +645,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 +653,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

@@ -9,6 +9,7 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
#include "lib/util_libc.h"
#include "ipl_tools.h"
/*
@@ -30,7 +31,7 @@ int fcp_is_device(const char *devno)
*/
void fcp_wwpn_get(const char *device, char *wwpn)
{
char path[PATH_MAX], buf[4096];
char path[PATH_MAX], buf[20];
FILE *fh;
int rc;
@@ -41,7 +42,7 @@ void fcp_wwpn_get(const char *device, char *wwpn)
rc = fscanf(fh, "%s", buf);
if (rc <= 0)
ERR_EXIT("Could not lookup WWPN \"%s\"", path);
strncpy(wwpn, buf, 20);
util_strlcpy(wwpn, buf, 20);
fclose(fh);
}
@@ -51,7 +52,7 @@ void fcp_wwpn_get(const char *device, char *wwpn)
*/
void fcp_lun_get(const char *device, char *lun)
{
char path[PATH_MAX], buf[4096];
char path[PATH_MAX], buf[20];
FILE *fh;
int rc;
@@ -62,7 +63,7 @@ void fcp_lun_get(const char *device, char *lun)
rc = fscanf(fh, "%s", buf);
if (rc <= 0)
ERR_EXIT("Could not lookup LUN \"%s\"", path);
strncpy(lun, buf, 20);
util_strlcpy(lun, buf, 20);
fclose(fh);
}

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

@@ -9,19 +9,21 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
#include "lib/util_libc.h"
#include "lib/zt_common.h"
#include "ipl_tools.h"
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);
@@ -31,7 +33,7 @@ void print_version_exit(void)
int main(int argc, char *argv[])
{
strncpy(g.prog_name, argv[0], sizeof(g.prog_name));
util_strlcpy(g.prog_name, argv[0], sizeof(g.prog_name));
if (strstr(argv[0], "chreipl") != NULL) {
cmd_chreipl(argc, argv);
return 0;

View File

@@ -9,6 +9,7 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
#include "lib/util_libc.h"
#include "ipl_tools.h"
/*
@@ -81,10 +82,11 @@ void read_str(char *string, const char *path, size_t len)
*/
void read_fw_str(char *string, const char *file, size_t len)
{
char path[PATH_MAX];
char *path;
snprintf(path, sizeof(path), "/sys/firmware/%s", file);
return read_str(string, path, len);
util_asprintf(&path, "/sys/firmware/%s", file);
read_str(string, path, len);
free(path);
}
/*
@@ -129,7 +131,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,16 +72,18 @@ 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)
{
FILE *file = is_error ? stderr : stdout;
if (msg != NULL)
fprintf(stderr, _("%s: %s\n"), prg->name, msg);
fprintf(stderr, _(prg->usage), prg->name, prg->name);
fprintf(file, _("%s: %s\n"), prg->name, msg);
fprintf(file, _(prg->usage), prg->name, prg->name);
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,9 +4,9 @@ lib = libdasd.a
all: $(lib)
objects = dasd_sys.o
objects = dasd_sys.o dasd_ioctl.o
$(lib): $(objects) Makefile
$(lib): $(objects)
install: all

302
libdasd/dasd_ioctl.c Normal file
View File

@@ -0,0 +1,302 @@
/*
* 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;
}
/*
* Reserve 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_reserve(const char *device)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BIODASDRSRV, NULL);
dasd_close_device(fd);
return 0;
}
/*
* Release 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_release(const char *device)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BIODASDRLSE, NULL);
dasd_close_device(fd);
return 0;
}

View File

@@ -12,7 +12,11 @@
#include <errno.h>
#include <stdlib.h>
#include "lib/dasd_base.h"
#include "lib/dasd_sys.h"
#include "lib/util_file.h"
#include "lib/util_path.h"
#include "lib/util_sys.h"
/**
* Get raw-track access mode status
@@ -31,22 +35,24 @@
*/
int dasd_sys_raw_track_access(char *devnode)
{
char busid[9];
char path[47];
char busid[DASD_BUS_ID_SIZE];
char *path;
FILE *fp;
int rc;
if (u2s_getbusid(devnode, busid))
if (util_sys_get_dev_addr(devnode, busid) != 0)
return 0;
sprintf(path, "/sys/bus/ccw/devices/%s/raw_track_access", busid);
path = util_path_sysfs("bus/ccw/devices/%s/raw_track_access", busid);
fp = fopen(path, "r");
if (!fp)
if (!fp) {
free(path);
return 0;
}
rc = fgetc(fp) - '0';
fclose(fp);
free(path);
return (rc == 1) ? 1 : 0;
}
@@ -55,15 +61,17 @@ int dasd_sys_raw_track_access(char *devnode)
int dasd_get_pm_from_chpid(char *busid, unsigned int chpid, int *mask)
{
unsigned int val;
char path[40];
int count, i;
char *path;
FILE *fp;
sprintf(path, "/sys/bus/ccw/devices/%s/../chpids", busid);
path = util_path_sysfs("bus/ccw/devices/%s/../chpids", busid);
*mask = 0;
fp = fopen(path, "r");
if (!fp)
if (!fp) {
free(path);
return ENODEV;
}
for (i = 0; i < 8; i++) {
count = fscanf(fp, " %x", &val);
@@ -75,6 +83,7 @@ int dasd_get_pm_from_chpid(char *busid, unsigned int chpid, int *mask)
*mask = 0x80 >> i;
}
fclose(fp);
free(path);
return 0;
}
@@ -102,22 +111,25 @@ int dasd_get_pm_from_chpid(char *busid, unsigned int chpid, int *mask)
int dasd_reset_chpid(char *devnode, char *chpid_char)
{
unsigned int chpid;
char path[41];
char busid[9];
char busid[DASD_BUS_ID_SIZE];
int mask, rc;
char *endptr;
char *path;
FILE *fp;
if (u2s_getbusid(devnode, busid))
if (util_sys_get_dev_addr(devnode, busid) != 0)
return ENODEV;
if (!chpid_char) {
sprintf(path, "/sys/bus/ccw/devices/%s/path_reset", busid);
path = util_path_sysfs("bus/ccw/devices/%s/path_reset", busid);
fp = fopen(path, "w");
if (!fp)
if (!fp) {
free(path);
return ENODEV;
}
fprintf(fp, "%s", "all\n");
fclose(fp);
free(path);
return 0;
}
@@ -132,12 +144,45 @@ int dasd_reset_chpid(char *devnode, char *chpid_char)
if (!mask)
return ENOENT;
sprintf(path, "/sys/bus/ccw/devices/%s/path_reset", busid);
path = util_path_sysfs("bus/ccw/devices/%s/path_reset", busid);
fp = fopen(path, "w");
if (!fp)
if (!fp) {
free(path);
return ENODEV;
}
fprintf(fp, "%02x", mask);
fclose(fp);
free(path);
return 0;
}
/**
* Read amount of host with access to \p device
*
* The \p device can be any valid relative or absolute path to a DASD device
* node, for example:
*
* - /dev/dasda
* - /dev/disk/by-path/ccw-0.0.bf20
*
* @param[in] device Device node of interest
*
* @retval n Number of hosts with access to \p device
* @retval 0 Value could not be determined
*/
int dasd_get_host_access_count(char *device)
{
char busid[9];
char *path;
long value;
if (!util_sys_get_dev_addr(device, busid))
return 0;
path = util_path_sysfs("bus/ccw/devices/%s/host_access_count", busid);
util_file_read_l(&value, 10, path);
free(path);
return value;
}

View File

@@ -1,14 +0,0 @@
include ../common.mak
lib = libu2s.a
all: $(lib)
objects = u2s.o misc.o
$(lib): $(objects)
install: all
clean:
rm -f *.o $(lib)

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