Compare commits

...

267 Commits

Author SHA1 Message Date
Jan Höppner
094905af87 New release s390-tools-2.12.0
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-17 13:51:48 +01:00
Jan Höppner
dcce14923c zipl: Add missing options to help output
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Ingo Franzki
1fd78d9f5e zkey: Fix convert command to use an associated APQN of a key
The zkey convert command must select an CCA adapter out of the
list of associated APQNs (if any) to perform the key conversion.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Marc Hartmayer
9d1baaa594 zipl: stfle: use uint64_t instead of u64
As the definition of `stfle_fac_list` in the lowcore uses uint64_t, we
should also use uint64_t for the `stfle_fac_list` parameter of the
`stfle/__stfle_asm` function.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Marc Hartmayer
efcfbce386 netboot/zipl: use '$(MAKE)' instead of 'make'
Use '$(MAKE)' to pass down the makefile flags.

This fixes the warning:

make[4]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Jan Höppner
3d74c534bf libdasd: Fix flag for opening read-only devices
dasd_is_ro() uses the O_RDWR flag when opening the file descriptor.
However, an attempt to open the file descriptor of a device that is in
read-only state will fail and the BLKROGET ioctl that is used to
actually determine the read-only state can't be issued.
Change the flag to O_RDONLY to fix this.

Fixes: a5c1923d32 ("libdasd: Add common DASD ioctl's to the lib")
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Jan Höppner
ca2ffe9e18 libdasd: Close file descriptor after use
Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/77
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Ingo Franzki
52192908eb zkey: Fix typo in help output
The help output for 'zkey generate' has a typo in the description
of the '-N, --name' option mentioning a non-existing '-M' option.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Ingo Franzki
d4cee7e65a zkey: Fix APQN checking
An invalid APQN like '01.00xx' is not treated as invalid, but results
in APQN '01.0000'. Fix the checking to treat such invalid APQNs as
invalid.

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-12-12 18:04:32 +01:00
Jan Höppner
bfbf456b83 dasdview: Fix exit status in error cases
In error cases, dasdview returns -1 which results in the return value
255. This is due to the fact that only the low-order 8 bits are used for
the status value. See 2.13 Status Information [1] in the POSIX standard
and the exit() POSIX man page [2] for more details.

Instead of returning -1, use the EXIT_FAILURE constant to indicate
unsuccessful termination properly. This change also makes the exit
status consistent for all error cases in dasdview, as some exit() calls
already use EXIT_FAILURE.

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
[2]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/exit.html

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Sa Liu
235e997a77 dbginfo: journalctl from the current system time with more number of lines and precise timestamp
Signed-off-by: Sa Liu <saliu@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Sa Liu
c079e48d7d dbginfo: Collect all files under /usr/lib/systemd/system/
Signed-off-by: Sa Liu <saliu@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
4762e65acb zipl: Consolidate STAGE{2,3} macros
Increase consistency with the other macros by moving and renaming
the STAGE{2,3} macros in zipl.h.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
cb614ed1ee zipl: Consolidate IMAGE macros
Combine the different macros for 0x10000 and use a consistent naming
schema.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
8face3e63e zipl/libc: Use stdint.h instead of self defined macros
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
ea14f5471c zipl: Make address/size/mask macros UL
While at it also fix some white space damages.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
b2ae5a91ac zipl/sclp: Remove duplicate macros
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
edfb6a03d8 zipl/stage3: Mark start_kernel __noreturn
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
5eace91ee7 zipl: Define __noinline macro and make use of it
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
86856f98db zipl: Make use of __noreturn macro
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
154734efc7 zipl: define __section macro and make use of it
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
c7fcb457b0 zfcpdump: Make use of __packed macro
Make use of the pre-defined __packed macro throughout zfcpdump.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
244bf4e550 zdump: Make use of __packed macro
Make use of the pre-defined __packed macro throughout zdump.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
0f7ed7d4fc zipl: Make use of __packed macro
Make use of the pre-defined __packed macro throughout zipl. This
requires adding the global include dir to ALL_CFLAGS.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
121d5d8013 zipl: Fix dependency generation in zipl/boot
When adding new header from zipl/include to a .c file within zipl/boot
a compiler error appears

	stage3.c:16:10: fatal error: zipl.h: No such file or directory
	 #include "zipl.h"
	          ^~~~~~~~
	compilation terminated.
	  CC      zipl/boot/stage3.o

This is because the rule to generate dependencies (*.o.d) does not use
the CFLAGS_BOOT. Thus it cannot find the header and fails. Note this
only applies to the dependency generation, the actual build succeeds.

To fix this rename the CFLAGS_BOOT to ALL_CFLAGS. Using ALL_CFLAGS
instead of e.g. ALL_CPPFLAGS is important to also overwrite flags given
on the commandline via OPT_FLAGS, e.g.

	make V=1 OPT_FLAGS="-D__FOO__"

While at it also remove the unused and wrong '-D__ASSEMBLY__'.

Fixes: 5a6605fe ("zipl: Ensure that boot loader CFLAGS are not overwritten")
Fixes: aa913b1e ("build process: Add automatic dependency generation")
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Philipp Rudo
abe0ba7412 zipl: Fix entry point for stand-alone kdump
Currently zipl doesn't differentiate between the load address and the
entry point of an image, causing stage3 to strip away the entry point at
0x10000 for stand-alone kdump. This breaks the kdump kernel as it jumps
to 0x10000 after the special handling needed for kdump has been
performed.

Fix this by differentiating between the load address and the entry point
of an image.

Fixes: d142fbd5 ("zipl: Do not strip kernel image IPL header")
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Marc Hartmayer
2227bb8330 zipl: remove some useless __packed___ attributes
The __packed__ attribute is not needed for these structures as they
don't need any padding to meet the size and alignment constraints
defined in the Linux for zSeries ABI.

Reported by GCC 9.2.1 when building with '-Waddress-of-packed-member'.

stage3.c: In function 'is_verified_address':
stage3.c:241:26: warning: taking address of packed member of 'struct ipl_rb_components' may result in an unaligned pointer value [-Waddress-of-packed-member]
  241 |  for_each_rb_entry(comp, comps) {
      |                          ^~~~~
stage3.c:18:15: note: in definition of macro 'for_each_rb_entry'
   18 |  for (entry = rb->entries; \
      |               ^~
  CC      zipl/boot/kdump3.o
  CC      zipl/boot/sclp_stage3.o
sclp_stage3.c: In function '__sclp_hsa_copy':
sclp_stage3.c:75:34: warning: converting a packed 'struct sdias_sccb' pointer (alignment 1) to a 'struct read_sccb' pointer (alignment 4096) may result in an unaligned pointer value [-Waddress-of-packed-member]
   75 |   if (sclp_hsa_copy_wait((struct read_sccb *)sccb))
      |                                  ^~~~~~~~~
In file included from sclp_stage3.c:13:
sclp_stage3.h:43:8: note: defined here
   43 | struct sdias_sccb {
      |        ^~~~~~~~~~
In file included from sclp_stage3.c:12:
sclp.h:149:8: note: defined here
  149 | struct read_sccb {
      |        ^~~~~~~~~
sclp_stage3.c: In function 'sclp_hsa_get_size':
sclp_stage3.c:126:34: warning: converting a packed 'struct sdias_sccb' pointer (alignment 1) to a 'struct read_sccb' pointer (alignment 4096) may result in an unaligned pointer value [-Waddress-of-packed-member]
  126 |   if (sclp_hsa_copy_wait((struct read_sccb *)sccb))
      |                                  ^~~~~~~~~
In file included from sclp_stage3.c:13:
sclp_stage3.h:43:8: note: defined here
   43 | struct sdias_sccb {
      |        ^~~~~~~~~~
In file included from sclp_stage3.c:12:
sclp.h:149:8: note: defined here
  149 | struct read_sccb {
      |        ^~~~~~~~~

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Marc Hartmayer
aa09b29248 zipl: fix -Waddress-of-packed-member
Reported by GCC 9.2.1 when building with '-Waddress-of-packed-member'.

menu.c: In function 'menu_read':
menu.c:30:22: warning: taking address of packed member of 'struct boot_stage2_params' may result in an unaligned pointer value [-Waddress-of-packed-member]
   30 |  uint16_t *configs = __stage2_params.config;
      |                      ^~~~~~~~~~~~~~~
menu.c: In function 'menu_list':
menu.c:83:22: warning: taking address of packed member of 'struct boot_stage2_params' may result in an unaligned pointer value [-Waddress-of-packed-member]
   83 |  uint16_t *configs = __stage2_params.config;
      |                      ^~~~~~~~~~~~~~~
menu.c: In function 'menu':
menu.c:139:22: warning: taking address of packed member of 'struct boot_stage2_params' may result in an unaligned pointer value [-Waddress-of-packed-member]
  139 |  uint16_t *configs = __stage2_params.config;
      |                      ^~~~~~~~~~~~~~~

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Marc Hartmayer
2790d4faaa zipl: fix -Wmaybe-uninitialized
Reported by GCC 9.2.1 when building with '-Wmaybe-uninitialized'.

job.c: In function 'job_get':
job.c:1817:14: warning: 'filename' may be used uninitialized in this function [-Wmaybe-uninitialized]
 1817 |  scan_size = scan_file(filename, &scan);
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~
job.c:1791:14: note: 'filename' was declared here
 1791 |  const char *filename;
      |              ^~~~~~~~

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Marc Hartmayer
bbc46edaf5 zipl: fix -Wdiscarded-qualifiers
Reported by GCC 9.2.1 when building with '-Wdiscarded-qualifiers'.

job.c: In function 'get_job_from_config_file':
job.c:1810:14: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Jan Höppner
e5c0fb249b ziomon: Move dependency check for blktrace
When calling ziomon --version (or --help) the tool already checks
whether blktrace is present and prevents any output for those command
options when it isn't. This is unnecessary as no actual command is
issued during the parameter check and all other dependencies are checked
at a later point as well.

Move the dependency check to ensure a working --version and --help
option at any time.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Jan Höppner
b6d8e5833c libdasd: Use DASD_BUS_ID_SIZE
Use the define instead of an hardcoded number.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-12-12 18:04:32 +01:00
Tuan Hoang
d71628326d zipl: add value of target= as search path for BLS case
In the BLS files, the 'linux' and 'initrd' fields are relative to the
$BOOT directory. If $BOOT is a mount point of boot partition, 'linux'
and 'initrd' fields are relative to boot partition. If not, the paths
are relative to $BOOT directory of root partition.

zipl always starts searching at / regardless of partitions and mount
points.

This commit extends the semantics of target= field in zipl.conf to make
it as a second search path, besides /, for those 2 BLS fields.

See issues #69 for more details.

Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/69
Closes: https://github.com/ibm-s390-tools/s390-tools/pull/74
Signed-off-by: Tuan Hoang <tmhoang@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-10-17 16:35:01 +02:00
Javier Martinez Canillas
8bfe18e674 zipl: fix the scanned tokens array size calculation
The zipl config file (zipl.conf) and the BootLoaderSpec (BLS) fragments
in /boot/loader/entries define a set of tokens that are parsed by zipl.

These are stored in an array of tokens whose size is calculated to make
sure that there is enough memory allocated for all the scanned tokens.

But the size calculation logic was wrong, since it was checking if the
current size was enough to store a single token per BLS fragment, while
up to 4 tokens can be defined in a BLS file: a section heading and the
image, ramdisk and parameter keywords.

This led to zipl being killed by a SIGABRT signal when trying to parse
more tokens than the ones that could fit in the scanned tokens array:

Using config file '/etc/zipl.conf'
Using BLS config file '/boot/loader/entries/vmlinuz-9.conf'
Using BLS config file '/boot/loader/entries/vmlinuz-8.conf'
Using BLS config file '/boot/loader/entries/vmlinuz-7.conf'
Using BLS config file '/boot/loader/entries/vmlinuz-6.conf'
Using BLS config file '/boot/loader/entries/vmlinuz-5.conf'
Using BLS config file '/boot/loader/entries/vmlinuz-4.conf'
Using BLS config file '/boot/loader/entries/vmlinuz-3.conf'
Using BLS config file '/boot/loader/entries/vmlinuz-2.conf'
Using BLS config file '/boot/loader/entries/vmlinuz-1.conf'
Using BLS config file '/boot/loader/entries/vmlinuz-0.conf'
double free or corruption (out)
Aborted (core dumped)

Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/68
Closes: https://github.com/ibm-s390-tools/s390-tools/pull/73
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-10-17 16:35:01 +02:00
Tuan Hoang
275105fe3d zipl: allow check for other locations of zipl.conf
Allow zipl to find zipl.conf in following order:
/run/zipl/zipl.conf
/etc/zipl.conf
/lib/s390-tools/zipl.conf

Whichever is found first will be used.

Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/70
Closes: https://github.com/ibm-s390-tools/s390-tools/pull/71
Signed-off-by: Tuan Hoang <tmhoang@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-10-17 16:35:01 +02:00
Tuan Hoang
19259aeb65 zipl: ship a minimal zipl.conf
Ship a minimal zipl configuration file at /lib/s390-tools/zipl.conf by
default which would help systems using BLS files, without having to
create the traditional /etc/zipl.conf file.

GitHub-ID: https://github.com/ibm-s390-tools/s390-tools/issues/70
GitHub-ID: https://github.com/ibm-s390-tools/s390-tools/pull/71
Signed-off-by: Tuan Hoang <tmhoang@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-10-17 16:35:01 +02:00
Julian Wiedmann
125df52887 dbginfo: collect qdisc statistics
This can be helpful in diagnosing network-related issues.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-10-17 16:35:01 +02:00
Julian Wiedmann
852fb9dfb8 dbginfo: collect extended network interface statistics
The basic statistics are already collected via ifconfig. But that tool
is deprecated, and provides no way of collecting the extended stats.
So also gather data from 'ip link'.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-10-17 16:35:01 +02:00
Jens Remus
b0fe75b92f zipl: remove duplicate statement
The duplicate statement does not have any effect. Therefore remove it.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-10-17 16:35:01 +02:00
Ingo Franzki
bc987c8d18 zkey: Allow 'zkey-cryptsetup setkey' to set different key types
When a secure key has been converted from type CCA-AESDATA to type
CCA-AESCIPHER, the secure key stored in the LUKS2 header of a volume
encrypted with that key should also changed.

Command 'zkey-cryptsetup setkey' allows to set (replace) the volume
key in the LUKS2 header. It now accepts keys to be set that have
a different size of the original volume keys. CCA-AESCIPHER keys
are larger than CCA-AESDATA keys.

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-09-18 12:55:17 +02:00
Ingo Franzki
a86e41a518 zkey: Add 'convert' command to convert keys from one type to another
Add a new 'convert' command. It allows to convert a secure key from
one key type to another. Currently only keys of type CCA-AESDATA can be
converted to CCA-AESCIPHER.

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-09-18 12:55:17 +02:00
Ingo Franzki
0d9e42264d zkey: Add key checks when importing a CCA-AESCIPHER key
Perform extended checks on a secure key that is imported into
the key repository. Warn the user if the imported key is by
any means insecure, e.g. has been originally created in an
insecure way. Prompt the user to continue the import if a
potential insecurity is detected.

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-09-18 12:55:17 +02:00
Ingo Franzki
7fede7021e zkey: Add helper function to check an AES CIPHER key
The helper function performs a deep check of the AES CIPHER key
token and checks for any potentially insecure attributes.

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-09-18 12:55:17 +02:00
Ingo Franzki
e7d79d5c5c zkey: Add helper function to restrict export of secure keys
Secure keys of type CCA-AESCIPHER can be export restricted, so that
these keys can not be exported by another key.

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-09-18 12:55:17 +02:00
Ingo Franzki
7d4b1e18b6 zkey: Add helper function to convert secure keys between key types
Add a helper function to convert a secure key from key type
CCA-AESDATA to CCA-AESCIPHER.

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-09-18 12:55:17 +02:00
Ingo Franzki
b0cc0e4737 zkey: Add helper function to query the CCA firmware version
Some future functions are dependent on the firmware version of the
CCA crypto adapter. This helper function allows to query the version
of the currently selected CCA adapter.

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-09-18 12:55:17 +02:00
Ingo Franzki
b7bb90c552 zkey: Check crypto card level during APQN cross checking
Secure keys of type CCA-AESCIPHER require a CEX6C or newer crypto
card. Also check for the minimum required card level during cross
checking of APQNs. Also display the card level in the APQN report.

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-09-18 12:55:17 +02:00
Ingo Franzki
560b672bfa zkey: Add support for re-enciphering AES CIPHER keys
For secure keys of type CCA-AESCIPHER the CCA verb CSNBKTC2
(Key Token Change2) is used. CCA-AESDATA keys will continue
to use CCA verb CSNBKTC (Key Token Change).

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-09-18 12:55:17 +02:00
Ingo Franzki
0fab6bdf2a zkey: Add support for validating AES CIPHER keys
Add support for validating secure keys using the new pkey
IOCTLs. This allows to validate secure keys of type CCA-AESDATA
as well as CCA-AESCIPHER.

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-09-18 12:55:17 +02:00
Ingo Franzki
b56c74fe7b zkey: Add support for generating AES CIPHER keys
Add support for generating secure keys using the new pkey
IOCTLs. This allows to generate secure keys of type CCA-AESDATA
as well as CCA-AESCIPHER, either by random inside the crypto
card, or from a given clear key.

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-09-18 12:55:17 +02:00
Ingo Franzki
663d362ff3 zkey: Add helper functions to build lists of APQNs
The new IOCTLs are based on list of APQNs that they try to send
the request to. Add some helper functions to build such lists
of APQNs based on the key type, and optionally a given mkvp.

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-09-18 12:55:17 +02:00
Ingo Franzki
d4027e6506 zkey: Add wrappers for the new IOCTLs with fallback to the old once
By default the new pkey IOCTL are used. In case the pkey device does not
support the new IOCTLs (i.e. errno ENOTTY is returned), then the wrapper
falls back to the old IOCTLs. The old IOCTLs only support secure keys of
type CCA-AESDATA.

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-09-18 12:55:17 +02:00
Ingo Franzki
ddde3f354f zkey: Introduce the CCA-AESCIPHER key type
Add definitions and helper functions to support the new
CCA-AESCIPHER key type. Also enhance existing helper functions
to support CCA-AESCIPHER keys.

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-09-18 12:55:17 +02:00
Ingo Franzki
298fab68fe zkey: Preparations for introducing a new key type
Introduce helper functions and definitions to allow key type
independent code in the keystore implementation

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-09-18 12:55:17 +02:00
Ingo Franzki
b47007b8ac zkey: Allow to specify the key type with the generate command
The zkey generate command allows to specify the --key-type|-K
option to specify the key type. If not specified, then the
default is CCA-AESDATA.

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-09-18 12:55:17 +02:00
Ingo Franzki
91c35543ca zkey: Allow to filter list output by key type
The zkey list command now accepts option --key-type|-K type
to filter the displayed keys by key type. If not specified,
then all key types are displayed.

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-09-18 12:55:17 +02:00
Ingo Franzki
9de85f4295 zkey: Display key type with list and validate commands
For the 'zkey list', 'zkey validate' and 'zkey-cryptsetup validate'
commands, display the key type.

As of today there is only one possible key type (CCA-AESDATA),
but in the future there might be additional key types.

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-09-18 12:55:17 +02:00
Ingo Franzki
e15e8a1bfa zcryptstats: Add support for CEX7
Add the CEX7 crypto card to the list of known crypto cards.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-18 12:55:17 +02:00
Harald Freudenberger
4fc0c3cfef zcrypt: CEX7S exploitation support
This patch adds CEX7S exploitation support to lszcrypt and chzcrypt.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-18 12:55:17 +02:00
Ingo Franzki
a0ed6709cf zkey-cryptsetup: Add --to-new and --from-old options
To allow better control about the secure AES volume key re-enciphering
with 'zkey-cryptsetup reencipher', add options '--to-new' and '--from-old'
to specify if a re-enciphering from CURRENT to NEW, or OLD to CURRENT master
key registers is to be performed. If these options are not specified, then
it is auto-detected, based on the master key that the secure key is currently
re-enciphered with.

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-09-18 12:55:17 +02:00
Ingo Franzki
552a915465 zkey: Select CCA adapter when re-enciphering
When re-enciphering secure AES keys, select the correct APQN for used
with the CCA host library. Re-enciphering a secure key requires the use
of the CCA host library. The APQN is selected based on the master key
verification pattern obtained from the secure key to re-encipher.

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-09-18 12:55:17 +02:00
Ingo Franzki
1091b0bf65 zkey: Add function to select a CCA adapter by mkvp
Add a utility function to select an APQN that is set up with
a specific master key for use with the CCA host library. The
selection is based on the master key verification pattern, which
is typically obtained from an existing secure AES key.

The function iterates over a set of APQNs to find one that is setup
with the desired master key in the CURRENT or OLD master key register,
and optionally has a new master key loaded. It then selects the found
APQN for use with the CCA host library.

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-09-18 12:55:17 +02:00
Ingo Franzki
016a0a56fc zkey: Add function to select a specific CCA adapter
Some operations require the CCA host library to be used, such as
re-enciphering a secure key. The CCA host library uses a different
approach to select the APQN it operates with. To ensure that the
desired APQN is used for an operation, a utility function is added
to select a specific APQN for usage with the CCA host library.

The CCA host library allows to set environment variables to override
the default CCA APQN selection. The environment variables are inspected
during CCA host library initialization only. To select a specific
domain for CCA, the CSU_DEFAULT_DOMAIN environment variable is set,
and then the CCA host library is un-loaded and re-loaded again.
Furthermore, the 'Cryptographic Resource Allocate' verb of the CCA
host library is used together with the 'Cryptographic Facility Query
function' verb to iterate over the crypto cards known by the CCA host
library, and to identify the desired crypto card based on its serial
number. That way, a specific APQN can be selected for use with
subsequent CCA verbs.

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-09-18 12:55:17 +02:00
Ingo Franzki
0b4cbf0041 zkey: Cross check APQNs when changing APQN associations
Perform a cross check of the APQNs when the APQN association of a
secure AES key in the key repository is changed. When adding new APQNs,
or associating a new set of APQNs to a secure key, then the APQNs are
cross checked. If all associated APQNs are removed, then all currently
available APQNs are cross checked. If a master key mismatch is detected,
then the change is rejected.

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-09-18 12:55:17 +02:00
Ingo Franzki
d854aed4b8 zkey: Cross check APQNs when importing secure keys
Perform a cross check of the APQNs when an existing secure AES key is
imported into the key repository. When a set of APQNs are associated to
the imported secure key, these APQNs are cross checked. If no APQNs are
associated to imported secure key, then all currently available
APQNs are cross checked. If a master key mismatch is detected, then
the key import is rejected.

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-09-18 12:55:17 +02:00
Ingo Franzki
7f8e31e861 zkey: Cross check APQNs when validating secure keys
Perform a cross check of the APQNs when a secure AES key is validated.
When a set of APQNs are associated to a secure key, these APQNs are
cross checked. If a secure key is validated outside of the key repository,
or no APQNs are associated to a secure key inside the key repository,
then all currently available APQNs are cross checked. If a master key
mismatch is detected, then an error message is issued.

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-09-18 12:55:17 +02:00
Ingo Franzki
a5b58038a0 zkey: Cross check APQNs when generating secure keys
Perform a cross check of the APQNs when a new secure AES key is
generated. When a set of APQNs are associated to a new secure key,
these APQNs are cross checked. If a new secure key is generated
outside of the key repository, or no APQNs are associated to a secure
key generated inside the key repository, then all currently available
APQNs are cross checked. If a master key mismatch is detected, then
the key generation is rejected.

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-09-18 12:55:17 +02:00
Ingo Franzki
c2244a5795 zkey: Display MKVP when validating a secure key
Display the master key verification pattern of a secure key while
'zkey validate' and 'zkey-cryptsetup validate'

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-09-18 12:55:17 +02:00
Ingo Franzki
ea7cc9ea60 zkey: Add function to obtain the mkvp of a secure key
A secure AES key token contains the master key verification pattern
of the master key it is encrypted with. Add a function to obtain the
master key verification pattern of a secure key token.

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-09-18 12:55:17 +02:00
Ingo Franzki
b32c031474 zkey: Add function to cross check APQNs for valid master keys
Add a utility function to cross check the master keys of a set of
APQNs. It checks for valid master keys in the CURRENT and OLD
master key registers, as well as newly loaded master keys in the NEW
register. It issues information and warning messages for various
findings and also indicates improper master key setup to the caller.

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-09-18 12:55:17 +02:00
Ingo Franzki
bfc3dd018c zkey: Add function to print the MKVPs of APQNs
Add a utility function to print the master key verification patterns
of a set of APQNs. This allows the user to visually check which
master keys are set on which APQNs.

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-09-18 12:55:17 +02:00
Ingo Franzki
625b81130a zkey: add function to iterate over all available CCA APQNs
Add a utility function to iterate over all available APQNs of
type CCA-Coprocessor. This function is required for various
future enhancements.

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-09-18 12:55:17 +02:00
Ingo Franzki
bf8872e94a zkey: Add utility function to get the mkvp of a crypto card
With recent changes in the zcrypt device driver, the master key verifi-
cation patterns of the AES master key of am APQN can be obtained by
reading the sysfs attribute 'mkvps' of an APQN device of type CCA-
Coprocessor. The sysfs attribute can be found under
'/sys/devices/ap/cardnn/nn.mmmm/', where nn specifies the card number
in hex, and mmmm specifies the domain number on hex.

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-09-18 12:55:17 +02:00
Ingo Franzki
a84d1c5d58 zkey: Add utility function to get the serial number of a crypto card
With recent changes in the zcrypt device driver, the serial number of
a crypto card can be obtained by reading the sysfs attribute 'serialnr'
of a crypto card device of type CCA-Coprocessor. The sysfs attribute
can be found under '/sys/devices/ap/cardnn/', where nn specifies the
card number in hex.

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-09-18 12:55:17 +02:00
Ingo Franzki
696e8458f0 zkey: Move utility functions into separate source file
As preparation for future changes, move a sysfs specific functions
into a separate source file (utils.c).

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-09-18 12:55:17 +02:00
Ingo Franzki
95c7258ea7 zkey: Separate and rework CCA host library loading
As preparation for future changes, rework the loading of the
CCA host library so that the exported symbols are not passed
individually to the functions that use it. Pass a structure
that contains all entry points of all loaded CCA functions
instead. This will make it easier to add further CCA functions
at a later time.

Also add a version query for the CCA host library since some
future functions might be dependent on the library version.

While at it, separate the CCA related functions and definitions,
and move them into a separate source file (cca.h/cca.h).

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-09-18 12:55:17 +02:00
Thomas Richter
21de913a5e cpumf/bin/cpumf_helper.in: Add IBM z15 machine name
Add IBM z15 as official machine name to lscpumf command
output.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-18 12:55:17 +02:00
Sa Liu
7a2a96e8a3 dbginfo: add hyptop output for z/VM and LPAR.
Signed-off-by: Sa Liu <saliu@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-18 12:55:17 +02:00
Jan Höppner
7a569c7e33 Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-06 14:13:49 +02:00
Jan Höppner
dc2ac0c916 New release s390-tools-2.11.0
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-06 14:13:09 +02:00
Stefan Haberland
367598b187 zipl: set correct secure IPL default value
Set secure IPL to auto as default value to match documented behavior.

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-09-06 12:44:34 +02:00
Marc Hartmayer
c01bcfa73a Use TOOLS_SYSCONFDIR for the default zipl.conf path
Use the configurable sysconf path instead of a hard-coded path for the
default zipl location.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-06 12:44:34 +02:00
Marc Hartmayer
fe457e2082 zipl: don't leak @script_file
...
==9448== 32 bytes in 1 blocks are definitely lost in loss record 1 of 3
==9448==    at 0x4831010: malloc (vg_replace_malloc.c:309)
==9448==    by 0x48E2205: __vasprintf_internal (vasprintf.c:71)
==9448==    by 0x1005061: misc_asprintf (misc.c:48)
==9448==    by 0x10131F3: disk_get_info (disk.c:239)
==9448==    by 0x1013C41: disk_get_info_from_file (disk.c:517)
==9448==    by 0x1011C87: bootmap_create (bootmap.c:1127)
==9448==    by 0x1004C73: main (zipl.c:192)
...

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-06 12:44:34 +02:00
Philipp Rudo
1d25112589 zipl: Fix error message printed with --dumptofs
The option --dump does not exist. Adjust it to --dumpto.

Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-06 12:44:34 +02:00
Marc Hartmayer
27a8c4434c zipl: fix freeing of uninitialized pointer
Not in every case ppn_cmd is initialized. Therefore, set it explicitly
to NULL.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-06 12:44:34 +02:00
Ursula Braun
e6a3b18104 dbginfo.sh: add ethtool output
This patch adds ethtool commands for network interfaces.
Especially the offload settings are important.

Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-06 12:44:34 +02:00
Ursula Braun
36292cb166 dbginfo.sh: add lspci and smc output
This patch adds the base lspci command to list pci devices
and the smc_dbg command from the smc-tools package to show
SMC socket related information.

Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-06 12:44:34 +02:00
Peter Oberparleiter
49da03e2e7 zdev: Fix broken zfcp-lun udev rule check
zdev incorrectly reports an invalid udev rule for zfcp-lun type rules.
This is caused by a faulty check for an empty udev rule file. This
commit fixes the check to only report invalid rules when there was no
valid configuration directive found in a zfcp-lun type udev rule.

Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reported-by: Steffen Maier <maier@linux.ibm.com>
Reported-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-06 12:44:34 +02:00
Ingo Franzki
139dff3525 zkey: Make confirmation prompts more user friendly
Show '[y/N]' on all user confirmation prompts to give the user a
hint what to reply. Also indicate that the operation was aborted
on a negative confirmation.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-06 12:44:34 +02:00
Ingo Franzki
94227b44d5 zkey: Store volume type property all uppercase
The volume type of a secure key is not really case sensitive,
but for better usability store and display it in uppercase always,
regardless in whatever case it was specified.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-06 12:44:34 +02:00
Stefan Haberland
a9f4ae2db3 zipl: fix zfcp dump image location
The zfcp dumper fails with the following error:

MLOPDM003I: Machine loader finished, moving data to final storage
	    location.

	    uncompression error
--- System halted

HCPGIR450W CP entered; disabled wait
PSW 00020001 80000000 00000000 DEADBEEF

The zipl command shows overlapping components when installing the dumper
to a zfcp disk:

zipl -d /dev/sda1
Building bootmap directly on partition '/dev/sda1'
Adding dump section
  kernel image......: /lib/s390-tools/zfcpdump/zfcpdump-image
  kernel parmline...: 'root=/dev/ram0 dump_mem=1 possible_cpus=1
  	 	      cgroup_disable=memory '
  component address:
    heap area.......: 0x00002000-0x00005fff
    stack area......: 0x0000f000-0x0000ffff
    internal loader.: 0x0000a000-0x0000dfff
    parameters......: 0x00009000-0x000091ff
    kernel image....: 0x00010000-0x005761ff
				     ^^^^^^
    parmline........: 0x00567000-0x005671ff
			  ^^^^^^
Preparing boot device: sda.
Done.

With the secure IPL patchset the offset of the kernel image has been
removed for the normal IPL case but it has not been removed for the dump
image which leads to the overlap of 0x10000.

Fix by removing the offset for the dump case.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewd-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Tested-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-08-08 15:27:27 +02:00
Jan Höppner
15b7f9d83f lsdasd: Add support for thin-provisioned volumes
Make lsdasd aware of thinly provisioned (Extent Space Efficient (ESE))
DASD volumes.

The ESE information is added to the discipline output and the extended
output additionally lists information about logical capacity, allocated
space, and the extent size.

Output before:

Bus-ID     Status      Name      Device  Type  BlkSz  Size      Blocks
==============================================================================
0.0.95e0   alias                         ECKD
0.0.7eb4   active      dasda     94:0    ECKD  4096   7043MB    1803060
0.0.7eb7   active      dasdb     94:4    ECKD  4096   7043MB    1803060
0.0.95d0   active      dasdc     94:8    ECKD  4096   42259MB   10818360
0.0.95d1   n/f         dasdd     94:12   ECKD
0.0.95d4   n/f         dasde     94:16   ECKD
0.0.95d5   active      dasdh     94:28   ECKD  4096   831097MB  212761080

Output after:

Bus-ID    Status    Name      Device  Type         BlkSz  Size      Blocks
================================================================================
0.0.95e0  alias                       ECKD
0.0.7eb4  active    dasda     94:0    ECKD         4096   7043MB    1803060
0.0.7eb7  active    dasdb     94:4    ECKD         4096   7043MB    1803060
0.0.95d0  active    dasdc     94:8    ECKD (ESE)   4096   42259MB   10818360
0.0.95d1  n/f       dasdd     94:12   ECKD (ESE)
0.0.95d4  n/f       dasde     94:16   ECKD (ESE)
0.0.95d5  active    dasdh     94:28   ECKD (ESE)   4096   831097MB  212761080

Extended output before:

0.0.95d0/dasdc/94:8
  status:                               active
  type:                                 ECKD
  blksz:                                4096
  size:                                 42259MB
  blocks:                               10818360
  use_diag:                             0
  readonly:                             0
  eer_enabled:                          0
  erplog:                               0
  hpf:                                  1
  uid:                                  IBM.750000000ABT31.9500.d0
  paths_installed:                      38 39 3a 3b
  paths_in_use:                         38 39 3a 3b
  paths_non_preferred:
  paths_invalid_cabling:
  paths_cuir_quiesced:
  paths_invalid_hpf_characteristics:
  paths_error_threshold_exceeded:

Extended output after:

0.0.95d0/dasdc/94:8
  status:                               active
  type:                                 ECKD (ESE)
  blksz:                                4096
  size:                                 42259MB
  blocks:                               10818360
  extent_size:                          1113
  logical_capacity:                     60102
  space_allocated:                      18921
  use_diag:                             0
  readonly:                             0
  eer_enabled:                          0
  erplog:                               0
  hpf:                                  1
  uid:                                  IBM.750000000ABT31.9500.d0
  paths_installed:                      38 39 3a 3b
  paths_in_use:                         38 39 3a 3b
  paths_non_preferred:
  paths_invalid_cabling:
  paths_cuir_quiesced:
  paths_invalid_hpf_characteristics:
  paths_error_threshold_exceeded:

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-08-08 15:27:21 +02:00
Jan Höppner
214580a704 dasdfmt: Add support for thin-provisioned volumes
Make dasdfmt aware of thinly provisioned (Extent Space Efficient (ESE))
DASD volumes.
If an ESE volume is recognised a QUICK format is performed, formatting
only the first two tracks. The mode can always be overwritten by --mode.

Previously allocated space is always released before formatting, if not
specified otherwise. The option --no-discard (-D) is provided to omit
the space release.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-08-08 15:27:16 +02:00
Jan Höppner
96f13ead2b libdasd: Provide function to utilise release space ioctl
The BIODASDRAS (Release Allocated Space) ioctl allows to release
track-wise or full space of an Extent Space Efficient DASD volume.

Provide a library function to utilise this functionality.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-08-08 15:27:09 +02:00
Jan Höppner
8023a72b11 libdasd: Provide function to read ese sysfs attribute
Provide a function to determine whether a DASD is an Extent Space
Efficient (ESE) volume.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-08-08 15:27:03 +02:00
Jan Höppner
abc1875300 libdasd/dasdfmt: Move definitions to libdasd
Move definitions mostly used by IOCTLs to libdasd. Clean up unused and
old definitions while at it as well.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-08-08 15:26:56 +02:00
Ingo Franzki
7d4c8c2781 zkey: Missing blank in command description
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-08-08 15:25:25 +02:00
Jan Höppner
f0afc6c89a Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-08-08 15:25:25 +02:00
Jan Höppner
8565e591bd New release s390-tools-2.10.0
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-31 16:26:57 +02:00
Jan Höppner
80443ab629 fdasd: Fix exit status in error cases
In error cases, fdasd returns -1 which results in the return value 255.
This is due to the fact that only the low-order 8 bits are used for the
status value. See 2.13 Status Information [1] in the POSIX standard and
the exit() POSIX man page [2] for more details.

Instead of returning -1, use the EXIT_FAILURE constant to indicate
unsuccessful termination properly.

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
[2]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/exit.html

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-31 16:00:40 +02:00
Peter Oberparleiter
8b3cc6e4c1 zdev: Improve handling of invalid udev rules
Add basic checking when reading udev rules and print a warning when an
invalid udev rule file is found. This addresses the current inconsistent
behavior:

  - CCW devices: invalid udev rules are considered valid
  - CCW group devices: invalid udev rules are silently ignored
  - zFCP LUNs: invalid rules cause chzdev/lszdev to silently terminate
    with non-zero exit code

Checks include a test for empty or truncated rule files that might be
the result of an interrupted chzdev operation, or a file system or I/O
error.

Note: The recommended way to correct invalid udev rules is to either
remove the offending rules file, or to repeat the associated persistent
configuration step.

Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reported-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-31 16:00:40 +02:00
Peter Oberparleiter
5693c16894 zdev: Add helper to report warnings only once
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-31 16:00:40 +02:00
Stefan Haberland
8bf5f8d0e2 zipl: do not overwrite BOOT_IMAGE entry
The zipl internal loader adds a variable BOOT_IMAGE= to the commandline
so that it is visible in the operating system which menu entry has been
chosen.

This entry was overwritten by the stage3 parameter page.

Fix by re-arranging the internal memory layout and putting the command
line extra param, which contains the BOOT_IMAGE entry, at 0xe000.
This location is available because less than  one page is used for the
stack.

Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/67
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-31 15:59:50 +02:00
Ingo Franzki
99ab2db6ad zkey: Fix auto-detection of clear key bitsize for XTS keys
When 'zkey generate' is used with options '--clearkey <file>' and
'--xts', but without the '--keybits <bitsize>' option, then the
auto-detection of the bitsize of the specified clear key fails.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-31 15:59:50 +02:00
Ingo Franzki
784ac7d190 zcryptstats: Add note about loading kernel module chsc_sch
Dependent on kernel config option CHSC_SCH the device node /dev/chsc may
exist per default or not. In case the kernel is built with CHSC_SCH=M,
then the device driver is built as separate kernel module, and must
therefore be loaded using modprobe chsc_sch to make device node /dev/chsc
available.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-31 15:59:50 +02:00
Javier Martinez Canillas
53f166673d zipl: remove trailing spaces from the fields defined in BLS files
Currently the zipl tool doesn't remove trailing spaces from the BLS field
values. So for example if a 'title' field has trailing spaces and is used
as the default, zipl will complain that there's no section with that name:

Using config file '/etc/zipl.conf'
Using BLS config file '/boot/loader/entries/f871a0cf218348c5ba921f61c92b7eac-4.18.0-80.20.el8.s390x.conf'
Using BLS config file '/boot/loader/entries/f871a0cf218348c5ba921f61c92b7eac-0-rescue.conf'
Error: Config file '/etc/zipl.conf': Line 6: no such section 'Red Hat Enterprise Linux (4.18.0-80.20.el8.s390x) 8.1 (Ootpa)'

Since the trailing spaces are also removed from the fields defined in the
zipl.conf file, do the same for the ones that are defined in the BLS file.

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/62
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Acked-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-18 16:21:17 +02:00
Dimitri John Ledkov
d4ea321a97 zipl/boot/Makefile: fix failure to build, do not specify .lds twice.
Whilst stage3.lds is a dependency, it is specified via SFLAGS and must
not be repeated again along all the .o files. Filter anything but .o
files.

Fixes failure to build from source on Ubuntu 19.10.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/s390-tools/+bug/1833238
Closes: https://github.com/ibm-s390-tools/s390-tools/pull/63
Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Acked-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-18 15:02:06 +02:00
Dimitri John Ledkov
1a63894487 zipl/boot/Makefile: do not suppress echo in verbose builds.
By default, non-verbose builds don't echo the full command anyway. And
supressed echos in verbose builds make it harder to debug the build
failure.

GitHub-ID: https://github.com/ibm-s390-tools/s390-tools/pull/63
Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Acked-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-18 15:02:06 +02:00
Stefan Haberland
e3fc9478bf zipl: secure IPL man page update
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-15 16:06:53 +02:00
Thomas Richter
f110a77b68 cpumf: Add support for CPU-Measurement Facility counters SVN 6
Add support for CPU-Measurement facility counter second version
number 6. This adds some more counters to the crypto counter set.
Extended counter set is the same as for z14.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-15 16:06:53 +02:00
Ingo Franzki
712433d7f9 util_opt: Correct util_opt_example to handle all possible options
The util_opt_example allows to specify '-l' and '-m, --manual' options,
but does not handle them. This leads to error message 'PANIC: The
application terminated due to an unrecoverable error' with 'Option 'l'
should not be handled here' and the program is aborted.

Add the required case statements in the switch to handle those options.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-15 16:06:53 +02:00
Fedor Loshakov
2c4c210ca8 zdev: add zfcp dix parameter handling
The zfcp kernel module was changed to introduce separate parameters for
selecting DIF and DIF&DIX. This commit implements the corresponding
changes in chzdev and lszdev.

Signed-off-by: Fedor Loshakov <loshakov@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Karsten Graul
58e2135d87 znetconf: show help and version without ccwgroup driver loaded
When directory $SYSFSDIR/bus/ccwgroup does not exist znetconf issues an
error message and terminates. Its not even possible to get the output of
--help or --version. Fix that by moving the responsible check behind the
parameter evaluation.

Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Ingo Franzki
5dbe73403f zkey: Fix option check for validate command
The validate command should allow to specify the --no-apqn-check
option even when --apqns is not specified.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Ingo Franzki
819513ab38 zkey: Fix misspelled option name in error messages
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Ingo Franzki
7e6d782699 zkey: Fix typo in function name
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Heiko Carstens
cc82be3135 zipl: add missing inline
please merge with previous commit.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Heiko Carstens
1b318fe114 zipl: fix stfle zero padding
The stfle inline assembly returns the number of double words written
(condition code 0) or the double words it would have written
(condition code 3), if the memory array it got as parameter would have
been large enough.

The current stfle implementation assumes that the array is always
large enough and clears those parts of the array that have not been
written to with a subsequent memset call.

If however the array is not large enough memset will get a negative
length parameter, which means that memset clears memory until it gets
an exception and the system crashes.

To fix this simply limit the maximum length. Move also the inline
assembly to an extra function to avoid clobbering of register 0, which
might happen because of the added MIN invocation together with code
instrumentation.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Jens Remus
87f47f60e4 zdev: Add comment that zfcp LUNs do not support ranges
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>
2019-07-09 16:24:17 +02:00
Jens Remus
0f55dab2de zdev: Add missing includes
The header exit_code.h is required for the exit_code_t type and
the header misc.h for the err_t type.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Jens Remus
b58adc26f4 zdev: Cleanup zfcp attribute help
Add missing punctuation, remove duplicate newline, and add missing
spacing.

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>
2019-07-09 16:24:17 +02:00
Jens Remus
91509973fe zdev: Do not pass user input as format string
The function util_path_exists() consumes its first parameter as format
string. Passing the user input specified to the chzdev option --export
as-is to the function opens up the possibility for a format string
injection.

Fixes: d542138868 ("zdev: use libutil provided path functions")
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>
2019-07-09 16:24:17 +02:00
Jens Remus
39520546c5 chcp: Use macro S_ISDIR() to test type of file
Testing whether a file is a directory by comparing the struct stat
field st_mode against S_IFDIR is wrong. If st_mode has any access
permission bits set along with the file type code the test will always
fail.

The file type encoded in the struct stat field st_mode is actually an
enumeration. To test whether a file is a directory either extract the
file type from st_mode using the mask S_IFMT and compare it against
S_IFDIR or simply use the macro S_ISDIR().

Fixes: b627b8d8e1 ("Initial s390-tools-2.0.0 import")
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>
2019-07-09 16:24:17 +02:00
Jens Remus
8d1a7fecd0 zkey: Use libutil provided path functions
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Acked-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Jens Remus
a6507b330d zkey: Use macro S_ISDIR() to test type of file
Testing whether a file is a directory by masking the struct stat field
st_mode with S_IFDIR is wrong. Depending on the values of the macros
S_IF* block special devices might be considered as directories.

The file type encoded in the struct stat field st_mode is actually an
enumeration. To test whether a file is a directory either extract the
file type from st_mode using the mask S_IFMT and compare it against
S_IFDIR or simply use the macro S_ISDIR().

Fixes: c944f23d7e ("zkey: Add keystore implementation")
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Acked-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Jens Remus
d37dc68693 util_path: Get rid of "? true : false"
The functions use the C99 _Bool type in form of the alias bool from
stdbool.h as return type. Scalars are implicitly converted to _Bool.
Values equal to zero to 0 (false). Nonzero values to 1 (true).
Therefore the explicit conversion using the ternary operator ?: with
true and false is not required.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Jens Remus
b0007fea98 util_path: Simplify logic and get rid of goto
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Jens Remus
1e248abd53 util_path: Use S_IS*() macros to test type of file
Testing whether a file is a directory or a regular file by masking the
struct stat field st_mode with S_IFDIR or S_IFREG is wrong. Depending
on the values of the macros S_IF* sockets and symbolic links might
erroneously be considered as regular files and block special files as
directories.

The file type encoded in the struct stat field st_mode is actually an
enumeration. To test whether a file is a directory or a regular file
either extract the file type from st_mode using the mask S_IFMT and
compare it against S_IFDIR or S_IFREG or simply use the macros S_ISDIR()
and S_ISREG().

Fixes: b627b8d8e1 ("Initial s390-tools-2.0.0 import")
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Jens Remus
61baa23e48 zdev: Fix reporting of read-only sysfs attributes
Since commit d542138868 ("zdev: use libutil provided path functions")
lszdev fails to correctly report most read-only sysfs attributes as such
in its detailed information output (options -i or -ii). This is because
the libutil function util_path_is_writable() is not equivalent to the
former function file_writable().
util_path_is_writable() always returns true (the underlying function
access() indicates the file is writable), if the path exists and the user
is root, regardless of the path's effective access permissions. This is
correct for most use cases, as root can effectively read/write any path
regardless of its effective access permissions). util_path_is_writable()
behaves exactly like Bash -w in this regard.
The former function file_writable() examined the file's access permissions
to check if one or more of user, group, and other have write permission.

For lszdev it is irrelevant whether a file is effectively writable by
the current user. Instead it needs to determine whether sysfs attributes
access permissions contain write access in any form. If not it lists
those sysfs attributes in a separate read-only section.

Use the new function util_path_is_readonly_file(), which does explicitly
check the file's effective read and write access permissions. It behaves
similar to the former function file_writable(), except that it does test
whether any of user, group, and other have read permission.

Fixes: d542138868 ("zdev: use libutil provided path functions")
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>
2019-07-09 16:24:17 +02:00
Jens Remus
261763f133 util_path_example: Add example for util_path_is_{read|write}only_file() functions
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Jens Remus
f4b2da6c9d util_path: Add functions to test path is read/write-only
For root the functions util_path_is_readable() and util_path_is_writable()
do not take the path's permissions into account. The function access()
succeeds as root is allowed to read/write any file regardless of its
permissions.

Introduce the functions util_path_is_readonly_file() and
util_path_is_writeonly_file() to test whether a path is a regular file and
is either read-only (neither user, group, nor other have write permission,
but one or more of user, group, and other have read permission) or
write-only (neither user, group, nor other have read permission, but one
or more of user, group, and other have write permission).

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
Jan Höppner
1f607fed3d Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-09 16:24:17 +02:00
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
208 changed files with 11692 additions and 2373 deletions

1
.gitignore vendored
View File

@@ -69,6 +69,7 @@ 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

View File

@@ -56,6 +56,7 @@ List of all individuals having contributed content to s390-tools
- Kittipon Meesompop
- Klaus-Dieter Wacker
- Lakhvich Dmitriy
- Marc Hartmayer
- Mark Dettinger
- Martin Kammerer
- Martin Peschke
@@ -97,6 +98,7 @@ List of all individuals having contributed content to s390-tools
- Thomas Richter
- Thomas Spatzier
- Thomas Weber
- Tuan Hoang
- Ursula Braun
- Utz Bacher
- Vasily Gorbik

View File

@@ -1,5 +1,138 @@
Release history for s390-tools (MIT version)
--------------------------------------------
* __v2.12.0 (2019-12-17)__
For Linux kernel version: 5.4
Changes of existing tools:
- dbginfo: Gather qdisc related data (using 'tc')
- dbginfo: Gather extended network statistics (using 'ip link')
- dbginfo: Collect all files under /usr/lib/systemd/system/
- cpumf/cpumf_helper: Add IBM z15 machine name
- zkey: Display MKVP when validating a secure key
- zkey: Cross check APQNs when generating, validating, or importing secure keys,
and when changing APQN associations
- zkey: Check crypto card level during APQN cross checking
- zkey: Add support for generating, validating, and re-enciphering AES CIPHER keys
- zkey-cryptsetup: Add --to-new and --from-old options
- zkey-cryptsetup: Allow setkey to set different key types
- lszcrypt/chzcrypt: CEX7S exploitation support
- zcryptstats: Add support for CEX7 crypto card
- zipl: Ship a minimal zipl.conf
- zipl: Add value of target= as search path for BLS case
Bug Fixes:
- dasdview: Fix exit status in error cases
- zipl: Fix various compile warnings
- zipl: Fix dependency generation in zipl/boot
- zipl: Fix entry point for stand-alone kdump
- zipl: Add missing options to help output
* __v2.11.0 (2019-09-06)__
For Linux kernel version: 5.3
Changes of existing tools:
- dasdfmt: Add support for thin-provisioned volumes
- lsdasd: Add support for thin-provisioned volumes
- libdasd: Provide function to utilise release space ioctl
- libdasd: Provide function to read ese sysfs attribute
- dbginfo: Add lspci (PCI devices) and smc_dbg (SMC sockets)
- dbginfo: Gather ethtool related data
Bug Fixes:
- zipl: Fix freeing of uninitialized pointer
- zipl: Set correct secure IPL default value
* __v2.10.0 (2019-07-31)__
For Linux kernel version: 5.2
Changes of existing tools:
- zdev: Add zfcp dix parameter handling
- cpumf: Add support for CPU-Measurement Facility counters SVN 6
Bug Fixes:
- libutil: Add functions to test path is read/write-only
- zdev: Fix reporting of read-only sysfs attributes
- zdev: Improve handling of invalid udev rules
- zipl: Fix stfle zero padding
- zipl: Fix build issues
- zipl: Remove trailing spaces from the fields defined in BLS files
- zipl: Do not overwrite BOOT_IMAGE entry
- zkey: Fix auto-detection of clear key bitsize for XTS keys
* __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

View File

@@ -3,7 +3,7 @@ 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 libvmcp
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 \

View File

@@ -129,6 +129,7 @@ Package contents
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.
@@ -284,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.

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"
@@ -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);

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 = 7
RELEASE = 12
PATCHLEVEL = 0
DISTRELEASE = build-$(shell date +%Y%m%d)
S390_TOOLS_RELEASE = $(VERSION).$(RELEASE).$(PATCHLEVEL)-$(DISTRELEASE)
@@ -331,10 +331,6 @@ $(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

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

@@ -6,7 +6,7 @@ include ../common.mak
CPUMF_DATADIR = $(TOOLS_DATADIR)/cpumf
DATA_FILES = cpum-cf-hw-counter.map \
cpum-cf-cfvn-1.ctr cpum-cf-cfvn-3.ctr \
cpum-cf-csvn-generic.ctr \
cpum-cf-csvn-12345.ctr cpum-cf-csvn-6.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-z14.ctr

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];
}
@@ -212,6 +213,7 @@ my $system_z_hwtype_map = {
2965 => 'IBM z13s',
3906 => 'IBM z14',
3907 => 'IBM z14 ZR1',
8561 => 'IBM z15',
};
sub get_hardware_type()
@@ -266,7 +268,12 @@ sub cpumf_load_ctrdef($;$)
# List of "generic" counter sets
my @def = ();
push @def, "cfvn-" . $version->{cfvn};
push @def, "csvn-generic";
if ($version->{csvn} >= 1 && $version->{csvn} <= 6) {
push @def, "csvn-12345";
}
if ($version->{csvn} == 6) {
push @def, "csvn-6";
}
my $h = {};
# Load counter set definition

View File

@@ -0,0 +1,33 @@
Counter: 80 Name:ECC_FUNCTION_COUNT
Short-Description:ECC Function Count
Description:
This counter counts the
total number of the elliptic-curve cryptography (ECC)
functions issued by the CPU.
.
Counter: 81 Name:ECC_CYCLES_COUNT
Short-Description:ECC Cycles Count
Description:
This counter counts the total
number of CPU cycles when the ECC coprocessor is
busy performing the elliptic-curve cryptography
(ECC) functions issued by the CPU.
.
Counter: 82 Name:ECC_BLOCKED_FUNCTION_COUNT
Short-Description:Ecc Blocked Function Count
Description:
This counter
counts the total number of the elliptic-curve
cryptography (ECC) functions that are issued by the CPU
and are blocked because the ECC coprocessor is
busy performing a function issued by another CPU.
.
Counter: 83 Name:ECC_BLOCKED_CYCLES_COUNT
Short-Description:ECC Blocked Cycles Count
Description:
This counter counts
the total number of CPU cycles blocked for the elliptic-curve
cryptography (ECC) functions issued by the
CPU because the ECC coprocessor is busy perform-
ing a function issued by another CPU.
.

View File

@@ -14,7 +14,8 @@
'cfvn-3' => 'cpum-cf-cfvn-3.ctr',
# CSVN
'csvn-generic' => 'cpum-cf-csvn-generic.ctr',
'csvn-12345' => 'cpum-cf-csvn-12345.ctr',
'csvn-6' => 'cpum-cf-csvn-6.ctr',
# Extended counters
2097 => 'cpum-cf-extended-z10.ctr',
@@ -27,4 +28,7 @@
2965 => 'cpum-cf-extended-z13.ctr',
3906 => 'cpum-cf-extended-z14.ctr',
3907 => 'cpum-cf-extended-z14.ctr',
# Identical with z14
8561 => 'cpum-cf-extended-z14.ctr',
8562 => 'cpum-cf-extended-z14.ctr',
};

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

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

@@ -122,6 +122,8 @@ Format the first two tracks and write label and partition information. Only use
this option if you are sure that the target DASD already contains a regular
format with the specified blocksize. A blocksize can optionally be specified
using \fB-b\fR (\fB--blocksize\fR).
.br
For thin-provisioned DASD ESE volumes this is the default mode.
.IP expand
Format all unformatted tracks at the end of the target DASD. This mode assumes
that tracks at the beginning of the DASD volume have already been correctly
@@ -136,6 +138,10 @@ using \fB-b\fR (\fB--blocksize\fR).
Perform a complete format check on a DASD volume. A blocksize can be specified
with \fB-b\fR (\fB--blocksize\fR).
.TP
\fB--no-discard\fR
Omit a full space release when formatting a thin-provisioned DASD ESE volume.
.TP
\fB-r\fR \fIcylindercount\fR or \fB--requestsize\fR=\fIcylindercount\fR
Number of cylinders to be processed in one formatting step.

View File

@@ -53,6 +53,7 @@ static const struct util_prg prg = {
/* Defines for options with no short command */
#define OPT_CHECK 128
#define OPT_NOZERO 129
#define OPT_NODISCARD 130
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("FORMAT ACTIONS"),
@@ -105,6 +106,11 @@ static struct util_opt opt_vec[] = {
.desc = "Prevent storage server from modifying record 0",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { "no-discard", no_argument, NULL, OPT_NODISCARD },
.desc = "Do not discard space before formatting",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { NULL, no_argument, NULL, 'y' },
.desc = "Start formatting without further user-confirmation",
@@ -921,6 +927,8 @@ static void dasdfmt_print_info(dasdfmt_info_t *info, char *devname,
printf("Drive Geometry: %d Cylinders * %d Heads = %d Tracks\n",
cylinders, heads, (cylinders * heads));
printf("Device Type: %s Provisioned\n",
info->ese ? "Thinly" : "Fully");
printf("\nI am going to format the device ");
printf("%s in the following way:\n", devname);
printf(" Device number of device : 0x%x\n", info->dasd_info.devno);
@@ -939,7 +947,10 @@ static void dasdfmt_print_info(dasdfmt_info_t *info, char *devname,
(p->intensity & DASD_FMT_INT_COMPAT) ? "yes" : "no");
printf(" Blocksize : %d\n", p->blksize);
printf(" Mode : %s\n", mode_str[mode]);
if (info->ese) {
printf(" Full Space Release : %s\n",
(info->no_discard || mode == FULL) ? "no" : "yes");
}
if (info->testmode)
printf("Test mode active, omitting ioctl.\n");
}
@@ -1234,6 +1245,26 @@ static void dasdfmt_format(dasdfmt_info_t *info, unsigned int cylinders,
process_tracks(info, cylinders, heads, format_params);
}
static void dasdfmt_release_space(dasdfmt_info_t *info)
{
format_data_t r = {
.start_unit = 0,
.stop_unit = 0,
.intensity = DASD_FMT_INT_ESE_FULL,
};
int err = 0;
if (!info->ese || info->no_discard)
return;
printf("Releasing space for the entire device...\n");
err = dasd_release_space(dev_filename, &r);
if (err) {
ERRMSG_EXIT(EXIT_FAILURE, "%s: Could not release space (%s)\n",
prog_name, strerror(err));
}
}
static void dasdfmt_prepare_and_format(dasdfmt_info_t *info,
unsigned int cylinders,
unsigned int heads, format_data_t *p)
@@ -1329,6 +1360,8 @@ static void dasdfmt_quick_format(dasdfmt_info_t *info, unsigned int cylinders,
if (info->force) {
printf("Skipping format check due to --force.\n");
} else if (info->ese) {
printf("Skipping format check due to thin-provisioned device.\n");
} else {
check_blocksize(info, p->blksize);
@@ -1394,7 +1427,7 @@ static void do_format_dasd(dasdfmt_info_t *info, char *devname,
if ((info->verbosity > 0) || !info->withoutprompt || info->testmode)
dasdfmt_print_info(info, devname, vlabel, cylinders, heads, p);
count = u2s_get_host_access_count(devname);
count = dasd_get_host_access_count(devname);
if (info->force_host) {
if (count > 1) {
ERRMSG_EXIT(EXIT_FAILURE,
@@ -1438,6 +1471,7 @@ static void do_format_dasd(dasdfmt_info_t *info, char *devname,
dasdfmt_prepare_and_format(info, cylinders, heads, p);
break;
case QUICK:
dasdfmt_release_space(info);
dasdfmt_quick_format(info, cylinders, heads, p);
break;
case EXPAND:
@@ -1461,6 +1495,19 @@ static void do_format_dasd(dasdfmt_info_t *info, char *devname,
}
}
static void eval_format_mode(dasdfmt_info_t *info)
{
if (!info->force && info->mode_specified && info->ese && mode == EXPAND) {
ERRMSG_EXIT(EXIT_FAILURE,
"WARNING: The specified device is thin-provisioned\n"
"Format mode 'expand' is not feasible.\n"
"Use --mode=full or --mode=quick to perform a clean format\n");
}
if (!info->mode_specified)
mode = info->ese ? QUICK : FULL;
}
int main(int argc, char *argv[])
{
dasdfmt_info_t info = {
@@ -1496,8 +1543,6 @@ int main(int argc, char *argv[])
format_params.blksize = DEFAULT_BLOCKSIZE;
format_params.intensity = DASD_FMT_INT_COMPAT;
mode = FULL;
/*************** parse parameters **********************/
while (1) {
@@ -1601,6 +1646,10 @@ int main(int argc, char *argv[])
"invalid. Consult the man page for "
"more information.\n",
prog_name, optarg);
info.mode_specified = 1;
break;
case OPT_NODISCARD:
info.no_discard = 1;
break;
case OPT_CHECK:
info.check = 1;
@@ -1645,6 +1694,9 @@ int main(int argc, char *argv[])
"device information failed (%s).\n",
prog_name, strerror(rc));
info.ese = dasd_sys_ese(dev_filename);
eval_format_mode(&info);
/* Either let the user specify the blksize or get it from the kernel */
if (!info.blksize_specified) {
if (!(mode == FULL ||

View File

@@ -27,10 +27,6 @@
#include <sys/types.h>
#include <unistd.h>
/****************************************************************************
* SECTION: Definition needed for DASD-API (see dasd.h) *
****************************************************************************/
/*
* Represents possible format modes that can be specified when formatting
* a DASD.
@@ -45,57 +41,16 @@ static const char mode_str[3][10] = {
"Full", "Quick", "Expand"
};
/*
* values to be used for format_data_t.intensity
* 0/8: normal format
* 1/9: also write record zero
* 3/11: also write home address
* 4/12: invalidate track
*/
#define DASD_FMT_INT_FMT_R0 1 /* write record zero */
#define DASD_FMT_INT_FMT_HA 2 /* write home address, also set FMT_R0 ! */
#define DASD_FMT_INT_INVAL 4 /* invalidate tracks */
#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 */
/*
* values to be used in format_check_t for indicating
* possible format errors
*/
#define DASD_FMT_ERR_TOO_FEW_RECORDS 1
#define DASD_FMT_ERR_TOO_MANY_RECORDS 2
#define DASD_FMT_ERR_BLKSIZE 3
#define DASD_FMT_ERR_RECORD_ID 4
#define DASD_FMT_ERR_KEY_LENGTH 5
/*
* values to be used for dasd_information2_t.format
* 0x00: NOT formatted
* 0x01: Linux disc layout
* 0x02: Common disc layout
*/
#define DASD_FORMAT_NONE 0
#define DASD_FORMAT_LDL 1
#define DASD_FORMAT_CDL 2
/****************************************************************************
* SECTION: DASDFMT internal types *
****************************************************************************/
#define DASD_PARTN_BITS 2
#define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
#define EXIT_MISUSE 1
#define EXIT_BUSY 2
#define LABEL_LENGTH 14
#define VLABEL_CHARS 84
#define LINE_LENGTH 80
#define ERR_LENGTH 90
#define DEFAULT_BLOCKSIZE 4096
/* requestsize - number of cylinders in one format step */
#define DEFAULT_REQUESTSIZE 10
#define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
#define ERRMSG(x...) {fflush(stdout);fprintf(stderr,x);}
#define ERRMSG_EXIT(ec,x...) {fflush(stdout);fprintf(stderr,x);exit(ec);}
@@ -137,6 +92,9 @@ typedef struct dasdfmt_info {
int force_host;
int layout_specified;
int check;
int mode_specified;
int ese;
int no_discard;
} dasdfmt_info_t;

View File

@@ -1,7 +1,6 @@
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

@@ -25,6 +25,7 @@
#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"
@@ -192,18 +193,18 @@ static int dinfo_read_dasd_vlabel(char *device, struct volume_label *vlabel,
char *space;
if (dasd_get_blocksize(device, &blksize) != 0) {
printf("Unable to figure out block size.\n");
warnx("Unable to figure out block size");
goto error;
}
if (dasd_get_info(device, &dasd_info) != 0) {
printf("Unable to figure out DASD informations.\n");
warnx("Unable to figure out DASD information");
goto error;
}
f = open(device, O_RDONLY);
if (f < 0) {
printf("Could not open device node.\n");
warnx("Could not open device node");
goto error;
}
@@ -214,7 +215,7 @@ static int dinfo_read_dasd_vlabel(char *device, struct volume_label *vlabel,
bzero(vlabel, vlsize);
if (read(f, vlabel, vlsize) != vlsize) {
printf("Could not read volume label.\n");
warnx("Could not read volume label");
goto error_close;
}
@@ -255,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;
}
@@ -318,16 +318,14 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
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)
@@ -337,10 +335,10 @@ static int dinfo_extract_dev(dev_t *dev, char *str)
int ma, mi;
bzero(tmp, RD_BUFFER_SIZE);
strncpy(tmp, str, RD_BUFFER_SIZE);
util_strlcpy(tmp, str, RD_BUFFER_SIZE);
p = strchr(tmp, ':');
if (p == NULL) {
printf("Error: unable to extract major/minor\n");
warnx("Error: unable to extract major/minor");
return -1;
}
@@ -359,7 +357,7 @@ static int dinfo_get_dev_from_blockdev(char *blockdev, dev_t *dev)
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
if (!readbuf) {
printf("Error: Not enough memory to allocate readbuffer\n");
warnx("Error: Not enough memory to allocate readbuffer");
return -1;
}
if (util_file_read_line(readbuf, RD_BUFFER_SIZE,
@@ -490,7 +488,7 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
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;
}
@@ -499,13 +497,13 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
directory = opendir("/sys/block/");
if (directory == NULL) {
printf("Error: could not open directory /sys/block\n");
warnx("Error: could not open directory /sys/block");
return -1;
}
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
if (!readbuf) {
printf("Error: Not enough memory to allocate readbuffer\n");
warnx("Error: Not enough memory to allocate readbuffer");
return -1;
}
@@ -607,25 +605,23 @@ int main(int argc, char *argv[])
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);
}
@@ -718,7 +714,7 @@ int main(int argc, char *argv[])
}
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)

View File

@@ -28,10 +28,10 @@
#include "lib/dasd_base.h"
#include "lib/dasd_sys.h"
#include "lib/libzds.h"
#include "lib/u2s.h"
#include "lib/util_base.h"
#include "lib/util_opt.h"
#include "lib/util_prg.h"
#include "lib/util_sys.h"
#include "lib/vtoc.h"
#include "lib/zt_common.h"
@@ -160,19 +160,19 @@ dasdview_get_info(dasdview_info_t *info)
if (err != EBADF)
zt_error_print("dasdview: "
"Could not retrieve geo information!\n");
exit(-1);
exit(EXIT_FAILURE);
}
if (dasd_get_blocksize(info->device, &info->blksize) != 0) {
zt_error_print("dasdview: "
"Could not retrieve blocksize information!\n");
exit(-1);
exit(EXIT_FAILURE);
}
if (dasd_get_info(info->device, &info->dasd_info) != 0) {
zt_error_print("dasdview: "
"Could not retrieve disk information!\n");
exit(-1);
exit(EXIT_FAILURE);
}
characteristics = (struct dasd_eckd_characteristics *)
@@ -183,7 +183,7 @@ dasdview_get_info(dasdview_info_t *info)
else
info->hw_cylinders = characteristics->no_cyl;
if (u2s_getbusid(info->device, info->busid) == -1)
if (util_sys_get_dev_addr(info->device, info->busid) != 0)
info->busid_valid = 0;
else
info->busid_valid = 1;
@@ -261,7 +261,7 @@ dasdview_parse_input(unsigned long long *p, dasdview_info_t *info, char *s)
error:
zt_error_print("dasdview: usage error\n"
"%s is not a valid begin/size value!", s);
exit(-1);
exit(EXIT_FAILURE);
}
/*
@@ -454,7 +454,7 @@ dasdview_print_vlabel(dasdview_info_t *info)
if (rc) {
zt_error_print("error when reading label from device:"
" rc=%d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
lzds_dasd_get_vlabel(info->dasd, &tmpvlabel);
memcpy(&vlabel, tmpvlabel, sizeof(vlabel));
@@ -600,7 +600,7 @@ dasdview_print_volser(dasdview_info_t *info)
if (rc) {
zt_error_print("error when reading label from device:"
" rc=%d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
lzds_dasd_get_vlabel(info->dasd, &tmpvlabel);
memcpy(&vlabel, tmpvlabel, sizeof(vlabel));
@@ -618,7 +618,7 @@ dasdview_print_volser(dasdview_info_t *info)
strncpy(volser, vlabel.volid, 6);
vtoc_ebcdic_dec(volser, volser, 6);
} else {
strncpy(volser, " ", 6);
memcpy(volser, " ", 6);
}
printf("%6.6s\n", volser);
@@ -644,7 +644,7 @@ dasdview_read_vtoc(dasdview_info_t *info)
zt_error_print("dasdview: disk layout error\n"
"%s is not formatted with the z/OS "
"compatible disk layout!\n", info->device);
exit(-1);
exit(EXIT_FAILURE);
}
vtocblk = (u_int64_t)vtoc_get_cyl_from_cchhb(&vlabel.vtoc) *
@@ -664,7 +664,7 @@ dasdview_read_vtoc(dasdview_info_t *info)
if ((vtocblk <= 0) || (vtocblk > maxblk)) {
zt_error_print("dasdview: VTOC error\n"
"Volume label VTOC pointer is not valid!\n");
exit(-1);
exit(EXIT_FAILURE);
}
vtoc_read_label(info->device, (vtocblk - 1) * info->blksize,
@@ -676,7 +676,7 @@ dasdview_read_vtoc(dasdview_info_t *info)
/* format4 DSCB is invalid */
zt_error_print("dasdview: VTOC error\n"
"Format 4 DSCB is invalid!\n");
exit(-1);
exit(EXIT_FAILURE);
}
info->f4c++;
@@ -724,19 +724,19 @@ dasdview_read_vtoc(dasdview_info_t *info)
if (info->f4c > 1) {
zt_error_print("dasdview: VTOC error\n"
"More than one FMT4 DSCB!\n");
exit(-1);
exit(EXIT_FAILURE);
}
if (info->f5c > 1) {
zt_error_print("dasdview: VTOC error\n"
"More than one FMT5 DSCB!\n");
exit(-1);
exit(EXIT_FAILURE);
}
if (info->f7c > 1) {
zt_error_print("dasdview: VTOC error\n"
"More than one FMT7 DSCB!\n");
exit(-1);
exit(EXIT_FAILURE);
}
}
@@ -975,7 +975,7 @@ static void dasdview_print_format1_8_short_info_raw(format1_label_t *f1,
}
if (rc) {
zt_error_print("dasdview: Broken format 3 DSCB chain \n");
exit(-1);
exit(EXIT_FAILURE);
}
f3 = (dscb && dscb->fmtid == 0xf3) ? (format3_label_t *)dscb : NULL;
@@ -990,7 +990,7 @@ static void dasdview_print_format1_8_short_info_raw(format1_label_t *f1,
if (f3->DS3FMTID != 0xf3) {
zt_error_print("dasdview: Broken format 3 DSCB"
" chain \n");
exit(-1);
exit(EXIT_FAILURE);
}
for (j = 0; j < 4; ++j)
dasdview_print_short_info_extent_raw(&f3->DS3EXTNT[j]);
@@ -1002,7 +1002,7 @@ static void dasdview_print_format1_8_short_info_raw(format1_label_t *f1,
if (rc) {
zt_error_print("dasdview: Broken format 3 DSCB"
" chain \n");
exit(-1);
exit(EXIT_FAILURE);
}
}
printf("\n");
@@ -1025,7 +1025,7 @@ static void dasdview_print_vtoc_info_raw(dasdview_info_t *info)
rc = lzds_raw_vtoc_alloc_dscbiterator(info->rawvtoc, &it);
if (rc) {
zt_error_print("dasdview: could not allocate DSCB iterator \n");
exit(-1);
exit(EXIT_FAILURE);
}
while (!lzds_dscbiterator_get_next_dscb(it, &dscb)) {
if (dscb->fmtid == 0xf1)
@@ -1058,7 +1058,7 @@ static void dasdview_print_vtoc_info_raw(dasdview_info_t *info)
rc = lzds_raw_vtoc_alloc_dscbiterator(info->rawvtoc, &it);
if (rc) {
zt_error_print("dasdview: could not allocate DSCB iterator \n");
exit(-1);
exit(EXIT_FAILURE);
}
while (!lzds_dscbiterator_get_next_dscb(it, &dscb)) {
if (dscb->fmtid == 0xf1 || dscb->fmtid == 0xf8)
@@ -1739,23 +1739,23 @@ static void dasdview_print_vtoc_raw(dasdview_info_t *info)
if (rc) {
zt_error_print("error when reading label from device:"
" rc=%d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
rc = lzds_dasd_read_rawvtoc(info->dasd);
rc = lzds_dasd_alloc_rawvtoc(info->dasd);
if (rc == EINVAL) {
zt_error_print("dasdview: Cannot read VTOC because disk does"
" not contain valid VOL1 label.\n",
info->device);
exit(-1);
exit(EXIT_FAILURE);
} else if (rc) {
zt_error_print("error when reading vtoc from device:"
" rc=%d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
rc = lzds_dasd_get_rawvtoc(info->dasd, &info->rawvtoc);
if (rc || !info->rawvtoc) {
zt_error_print("dasdview: libvtoc could not read vtoc\n");
exit(-1);
exit(EXIT_FAILURE);
}
if (info->vtoc_info || info->vtoc_all)
@@ -1764,7 +1764,7 @@ static void dasdview_print_vtoc_raw(dasdview_info_t *info)
rc = lzds_raw_vtoc_alloc_dscbiterator(info->rawvtoc, &it);
if (rc) {
zt_error_print("dasdview: could not allocate DSCB iterator\n");
exit(-1);
exit(EXIT_FAILURE);
}
while (!lzds_dscbiterator_get_next_dscb(it, &record))
dasdview_print_vtoc_dscb(info, record);
@@ -1858,7 +1858,7 @@ static void dasdview_view_standard(dasdview_info_t *info)
zt_error_print("dasdview: open error\n"
"Unable to open device %s in read-only mode!\n",
info->device);
exit(-1);
exit(EXIT_FAILURE);
}
j = (info->begin / SEEK_STEP);
@@ -1877,7 +1877,7 @@ static void dasdview_view_standard(dasdview_info_t *info)
zt_error_print("dasdview: seek error\n"
"Unable to seek in device %s!\n",
info->device);
exit(-1);
exit(EXIT_FAILURE);
}
b++;
a += SEEK_STEP;
@@ -1890,7 +1890,7 @@ static void dasdview_view_standard(dasdview_info_t *info)
zt_error_print("dasdview: seek error\n"
"Unable to seek in device %s!\n",
info->device);
exit(-1);
exit(EXIT_FAILURE);
}
}
@@ -1926,7 +1926,7 @@ static void dasdview_view_standard(dasdview_info_t *info)
zt_error_print("dasdview: read error\n"
"Unable to read from device %s!\n",
info->device);
exit(-1);
exit(EXIT_FAILURE);
}
if (info->format1)
@@ -1945,7 +1945,7 @@ static void dasdview_view_standard(dasdview_info_t *info)
zt_error_print("dasdview: read error\n"
"Unable to read from device %s!\n",
info->device);
exit(-1);
exit(EXIT_FAILURE);
}
if (info->format1)
@@ -2112,18 +2112,18 @@ static void dasdview_view_raw(dasdview_info_t *info)
trackdata = memalign(4096, trckbuffsize * RAWTRACKSIZE);
if (!trackdata) {
zt_error_print("failed to allocate memory\n");
exit(-1);
exit(EXIT_FAILURE);
}
rc = lzds_dasd_alloc_dasdhandle(info->dasd, &dasdh);
if (rc) {
zt_error_print("failed to allocate memory\n");
exit(-1);
exit(EXIT_FAILURE);
}
rc = lzds_dasdhandle_open(dasdh);
if (rc) {
lzds_dasdhandle_free(dasdh);
zt_error_print("failed to open device\n");
exit(-1);
exit(EXIT_FAILURE);
}
/* residual is the number of tracks we still have to read */
residual = tracks_to_read;
@@ -2135,7 +2135,7 @@ static void dasdview_view_raw(dasdview_info_t *info)
trckend, trackdata);
if (rc) {
perror("Error on read");
exit(-1);
exit(EXIT_FAILURE);
}
data = trackdata;
for (i = 0; i < trckcount; ++i) {
@@ -2153,7 +2153,7 @@ static void dasdview_view_raw(dasdview_info_t *info)
lzds_dasdhandle_free(dasdh);
if (rc < 0) {
perror("Error on closing file");
exit(-1);
exit(EXIT_FAILURE);
}
}
@@ -2253,7 +2253,7 @@ int main(int argc, char *argv[])
zt_error_print("dasdview: usage error\n"
"%s is no valid argument for"
" option -t/--vtoc\n", optarg);
exit(-1);
exit(EXIT_FAILURE);
}
info.vtoc = 1;
info.action_specified = 1;
@@ -2301,13 +2301,13 @@ int main(int argc, char *argv[])
rc = lzds_zdsroot_alloc(&info.zdsroot);
if (rc) {
zt_error_print("Could not allocate index\n");
exit(-1);
exit(EXIT_FAILURE);
}
rc = lzds_zdsroot_add_device(info.zdsroot, info.device,
&info.dasd);
if (rc) {
zt_error_print("Could not add device to index\n");
exit(-1);
exit(EXIT_FAILURE);
}
}
@@ -2328,7 +2328,7 @@ int main(int argc, char *argv[])
if (info.begin > max) {
zt_error_print("dasdview: usage error\n"
"'begin' value is not within disk range!");
exit(-1);
exit(EXIT_FAILURE);
}
if (info.size_specified)
@@ -2343,7 +2343,7 @@ int main(int argc, char *argv[])
zt_error_print("dasdview: usage error\n"
"'begin' + 'size' is not within "
"disk range!");
exit(-1);
exit(EXIT_FAILURE);
}
if ((info.begin_specified || info.size_specified) &&
@@ -2355,7 +2355,7 @@ int main(int argc, char *argv[])
zt_error_print("dasdview: usage error\n"
"Options -1 or -2 make only sense with "
"options -b or -s!");
exit(-1);
exit(EXIT_FAILURE);
}
/* do the output */

View File

@@ -11,7 +11,6 @@
#define DASDVIEW_H
#include <limits.h>
#include "lib/u2s.h"
/********************************************************************************
* SECTION: Definitions needed for DASD-API (see dasd.h)
@@ -109,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,

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

@@ -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.
@@ -258,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 &&
@@ -397,7 +397,7 @@ static void fdasd_error(fdasd_anchor_t *anc, enum fdasd_failure why, char *str)
fputc('\n', stderr);
fputs(err_str, stderr);
fdasd_exit(anc, -1);
fdasd_exit(anc, EXIT_FAILURE);
}
/*
@@ -727,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]);
@@ -935,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,
@@ -1257,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 */
@@ -1310,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;
@@ -1321,23 +1321,23 @@ static void fdasd_write_vtoc_labels(fdasd_anchor_t *anc)
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)
@@ -1636,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++;
}
@@ -1994,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))
@@ -3040,5 +3040,5 @@ int main(int argc, char *argv[])
}
}
return -1;
return EXIT_FAILURE;
}

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 \

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;
}
@@ -853,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 */
}
@@ -1148,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);
}
}
}

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

@@ -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));
}
/*

View File

@@ -20,6 +20,9 @@
#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 */
@@ -51,6 +54,16 @@ typedef struct dasd_information2_t {
unsigned int reserved7; /* reserved for further use ,... */
} dasd_information2_t;
/*
* values to be used for dasd_information2_t.format
* 0x00: NOT formatted
* 0x01: Linux disc layout
* 0x02: Common disc layout
*/
#define DASD_FORMAT_NONE 0
#define DASD_FORMAT_LDL 1
#define DASD_FORMAT_CDL 2
struct dasd_eckd_characteristics {
unsigned short cu_type;
struct {
@@ -136,6 +149,16 @@ typedef struct format_data_t {
unsigned int intensity;
} format_data_t;
/*
* values to be used for format_data_t.intensity
*/
#define DASD_FMT_INT_FMT_R0 1 /* write record zero */
#define DASD_FMT_INT_FMT_HA 2 /* write home address, also set FMT_R0 ! */
#define DASD_FMT_INT_INVAL 4 /* invalidate tracks */
#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 */
#define DASD_FMT_INT_ESE_FULL 32 /* release space for entire volume */
/*
* struct format_check_t
* represents all data necessary to evaluate the format of
@@ -154,6 +177,16 @@ typedef struct format_check_t {
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
*/
#define DASD_FMT_ERR_TOO_FEW_RECORDS 1
#define DASD_FMT_ERR_TOO_MANY_RECORDS 2
#define DASD_FMT_ERR_BLKSIZE 3
#define DASD_FMT_ERR_RECORD_ID 4
#define DASD_FMT_ERR_KEY_LENGTH 5
#ifndef __linux__
/* definition from hdreg.h */
struct hd_geometry {
@@ -170,10 +203,16 @@ struct hd_geometry {
#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)
/* Release Allocated Space */
#define BIODASDRAS _IOW(DASD_IOCTL_LETTER, 3, format_data_t)
/* Check device format according to format_data_t */
#define BIODASDCHECKFMT _IOWR(DASD_IOCTL_LETTER, 2, format_check_t)
@@ -197,11 +236,14 @@ 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_release_space(const char *device, format_data_t *r);
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,10 @@
#define LIB_DASD_SYS_H
#include <stdio.h>
#include "u2s.h"
int dasd_sys_raw_track_access(char *);
int dasd_sys_ese(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

@@ -130,6 +130,7 @@ 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
}

View File

@@ -3,7 +3,7 @@
* @{
* @brief Work with paths
*
* Copyright IBM Corp. 2016, 2017
* Copyright IBM Corp. 2016, 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.
@@ -21,5 +21,7 @@ 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, ...);
bool util_path_is_readonly_file(const char *fmt, ...);
bool util_path_is_writeonly_file(const char *fmt, ...);
#endif /** LIB_UTIL_PATH_H @} */

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

View File

@@ -31,6 +31,8 @@
#define __packed __attribute__((packed))
#define __aligned(x) __attribute__((aligned(x)))
#define __may_alias __attribute__((may_alias))
#define __section(x) __attribute__((__section__(#x)))
#define __noinline __attribute__((__noinline__))
typedef unsigned long long u64;
typedef signed long long s64;

View File

@@ -2,7 +2,9 @@ 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

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,11 +1,15 @@
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)
chreipl: $(objects) $(libs)
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@
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"
@@ -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;
}

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

@@ -9,7 +9,9 @@
* 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;
@@ -31,7 +33,7 @@ void __noreturn 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);
}
/*

View File

@@ -6,7 +6,7 @@ all: $(lib)
objects = dasd_sys.o dasd_ioctl.o
$(lib): $(objects) Makefile
$(lib): $(objects)
install: all

View File

@@ -146,9 +146,10 @@ int dasd_is_ro(const char *device, bool *ro)
{
int fd, val;
fd = dasd_open_device(device, O_RDWR);
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BLKROGET, &val);
*ro = (val != 0) ? true : false;
dasd_close_device(fd);
return 0;
}
@@ -228,6 +229,26 @@ int dasd_check_format(const char *device, format_check_t *p)
return 0;
}
/*
* Release Allocated Space
*
* @param[in] fd device node's file descriptor
* @param[in] r format options
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_release_space(const char *device, format_data_t *r)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BIODASDRAS, r);
dasd_close_device(fd);
return 0;
}
/*
* Reread partition table
*
@@ -261,3 +282,42 @@ int dasd_reread_partition_table(const char *device, int ntries)
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,19 +35,59 @@
*/
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;
}
/**
* Is volume extent space efficient a.k.a. thin-provisioned
*
* The "devnode" parameter 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] devnode Device node of interest
*
* @retval 1 Volume is extent space efficient
* @retval 0 Volume is not extent space efficient or
* cannot be determined
*/
int dasd_sys_ese(char *devnode)
{
char busid[DASD_BUS_ID_SIZE];
char *path;
FILE *fp;
int rc;
if (util_sys_get_dev_addr(devnode, busid) != 0)
return 0;
path = util_path_sysfs("bus/ccw/devices/%s/ese", busid);
fp = fopen(path, "r");
if (!fp) {
free(path);
return 0;
}
rc = fgetc(fp) - '0';
fclose(fp);
@@ -51,19 +95,20 @@ int dasd_sys_raw_track_access(char *devnode)
return (rc == 1) ? 1 : 0;
}
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 +120,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 +148,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 +181,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[DASD_BUS_ID_SIZE];
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)

View File

@@ -1,27 +0,0 @@
/*
* Misc - Local helper functions
*
* 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.
*/
#include <string.h>
#include "lib/util_base.h"
/*
* Helper function that copies a string safely
*/
size_t misc_strlcpy(char *dest, const char *src, size_t size)
{
size_t str_len = strlen(src);
size_t len;
if (size) {
len = MIN(size - 1, str_len);
memcpy(dest, src, len);
dest[len] = '\0';
}
return str_len;
}

View File

@@ -1,15 +0,0 @@
/*
* Misc - Local helper functions
*
* 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.
*/
#ifndef MISC_H
#define MISC_H
size_t misc_strlcpy(char *, const char *, size_t);
#endif /* MISC_H */

View File

@@ -1,334 +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.
*
*/
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <unistd.h>
#include <wait.h>
#include "lib/u2s.h"
#include "misc.h"
#define DEV_BUFFER_LENGTH 20
#define PATH_BUFFER_LENGTH 256
#define BUSIDSIZE 9
#define BLOCKPATH "/sys/block/"
#define DEVICE_LINK "device"
#define DEV_ATTRIBUTE "dev"
/*
* Helper function that expects a file name and returns 1 if this
* is a directory or 0 otherwise.
*/
static int isdir(char *name) {
struct stat statbuf;
if (stat(name, &statbuf) < 0)
return 0;
return S_ISDIR(statbuf.st_mode);
}
/*
* Helper function that expects a directory name in sysfs of the form
* /sys/block/<devname>/ or /sys/block/<devname>/<partname>/.
* It will try to read the file "dev" in this directory and compare
* it's contents with the given dev string of the form <major>:<minor>.
* Trailing white space (newline) is ignored.
* The buffer name is expected to be long enough to hold the additional "dev".
* Returns 1 if the directory matches dev, 0 otherwise.
*/
static int check_directory(char *name, char *dev) {
char buffer[DEV_BUFFER_LENGTH];
char *end;
int fd;
ssize_t count;
int dev_attr_len, dev_parm_len;
unsigned int namelen;
namelen = strlen(name);
if ((PATH_BUFFER_LENGTH - namelen) < sizeof(DEV_ATTRIBUTE))
return 0;
end = name + namelen;
strcpy(end, DEV_ATTRIBUTE);
fd = open(name, O_RDONLY);
*end = 0;
if (fd < 0)
return 0;
count = read(fd, buffer, DEV_BUFFER_LENGTH);
close(fd);
if (count < 0)
return 0;
dev_attr_len = strspn(buffer, "1234567890:");
dev_parm_len = strlen(dev);
if (dev_attr_len != dev_parm_len )
return 0;
return (strncmp(dev, buffer, dev_parm_len) == 0);
}
/*
* Helper function that expects a directory name in sysfs of the form
* /sys/block/<devname>/. It will try to read a link "device"
* in this directory and extract the busid, which is the last part
* of that link. The buffer name is expected to be long enough
* to hold the additional "device".
* name: block device path in sysfs.
* busid: buffer in which the busid string will be returned
* returns 0 for successful operation and -1 in case of an error.
*/
static int extract_busid(char *name, char *busid) {
int count;
unsigned int namelen;
char linkbuffer[PATH_BUFFER_LENGTH];
char *start, *end;
size_t len;
namelen = strlen(name);
if ((PATH_BUFFER_LENGTH - namelen) < sizeof(DEVICE_LINK))
return 0;
end = name + namelen;
strcpy(end, DEVICE_LINK);
count = readlink(name, linkbuffer, PATH_BUFFER_LENGTH - 1);
if (count < 0)
return -1;
linkbuffer[count] = 0;
start = strrchr(linkbuffer, '/');
if (!start)
return -1;
start++;
len = misc_strlcpy(busid, start, BUSIDSIZE);
if (len >= BUSIDSIZE)
return -1;
return 0;
};
/*
* Helper function that makes some basic checks on a directory entry.
* The function checks if there is still enough space left in the buffer
* for the new string, excludes '.' and '..', and verifies that the entry
* is actually a directory.
* buffer: the beginning of the name buffer
* oldend: the current end of the string in the name buffer
* dir: the dirent in question
* returns: a pointer to the new end of the string in buffer or NULL if
* one of the checks failed
*/
static char *append_if_directory(char *buffer, char *oldend, struct dirent *dir) {
char *newend;
int oldlength, dirlength;
if (strcmp(dir->d_name, ".") == 0 ||
strcmp(dir->d_name, "..") == 0)
return NULL;
oldlength = strlen(buffer);
dirlength = strlen(dir->d_name);
if (PATH_BUFFER_LENGTH < oldlength + dirlength + 2)
return NULL;
strcpy(oldend, dir->d_name);
if (!isdir(buffer)) {
*oldend = 0;
return NULL;
}
newend = oldend + dirlength;
strcpy(newend, "/");
newend++;
return newend;
}
/*
* helper function that searches for a specific block device and returns
* it's busid
* dev: <major>:<minor> of the device
* busid: buffer in which the busid string will be returned
* returns 0 for successful operation and -1 in case of an error.
*/
static int find_busid_in_sysfs(char *dev, char *busid) {
DIR *blockdir, *diskdir;
struct dirent *blockde, *diskde;
int found = 0;
char namebuffer[PATH_BUFFER_LENGTH];
char *blockend, *diskend = NULL, *partend;
/* everything, including the other helper functions, works on the
* same buffer area 'namebuffer'. The pointers blockend, diskend
* and partend point to the end of the various names.
* Example:
* "/sys/block/dasda/dasda1/"
* ^ blockend
* ^ diskend
* ^ partend
*/
strcpy(namebuffer,BLOCKPATH);
blockdir = opendir(namebuffer);
if (!blockdir)
return -1;
blockend = namebuffer + strlen(namebuffer);
/* check each entry in /sys/block */
while ((blockde = readdir(blockdir))) {
diskend = append_if_directory(namebuffer, blockend, blockde);
if (!diskend)
continue;
found = check_directory(namebuffer, dev);
if (found)
break;
diskdir = opendir(namebuffer);
if (!diskdir)
continue;
/* check each entry in /sys/block/<disk name> */
while ((diskde = readdir(diskdir))) {
partend = append_if_directory(
namebuffer, diskend, diskde);
if (!partend)
continue;
found = check_directory(namebuffer, dev);
if (found)
break;
}
closedir(diskdir);
if (found)
break;
}
closedir(blockdir);
if (found) {
*diskend = 0; /* remove partition directory from name */
return extract_busid(namebuffer, busid);
} else
return -1;
}
/*
* helper function that searches for a specific block device in
* /proc/dasd/devices and returns it's bus-ID
* maja, mina: <major>, <minor> of the device
* busid: buffer in which the bus-ID string will be returned
* returns 0 for successful operation and -1 in case of an error
* e.g. /proc/dasd/devices does not exist.
*
* An entry looks like:
* 0.0.XXXX(DISCIPLINE) at ( MAJ: MIN) is dasdX :
* active at blocksize: BLOCKSIZE, BLOCKS blocks, SIZE MB
*/
static int find_busid_in_proc(int maja, int mina, char *busid)
{
FILE *filp;
char bus[BUSIDSIZE];
int majb, minb, rc;
size_t len;
rc = -1;
filp = fopen("/proc/dasd/devices", "r");
if (!filp)
return rc;
while (fscanf(filp, "%[^(] %*[^)] ) at ( %d : %d %*[^\n]\n",
bus, &majb, &minb) != EOF) {
if ((maja == majb) && (mina == minb)) {
len = misc_strlcpy(busid, bus, BUSIDSIZE);
if (len < BUSIDSIZE)
rc = 0;
break;
}
}
fclose(filp);
return rc;
}
/*
* Return the busid of a given device node.
* Works only for block devices.
* devicenode: path to the device node
* busid: buffer in which the busid string will be returned
* returns 0 for successful operation and -1 in case of an error.
*/
int u2s_getbusid(char *devicenode, char *busid)
{
int maj, min, rc;
struct stat stat_buf;
char dev_string[DEV_BUFFER_LENGTH];
/*
* Get major and minor information of the device special file
* and combine them to a <maj>:<min> string, as returned by
* the dev attributes in sysfs
*/
if (stat(devicenode, &stat_buf))
return -1;
if (!S_ISBLK(stat_buf.st_mode))
return -1;
maj = major(stat_buf.st_rdev);
min = minor(stat_buf.st_rdev);
rc = find_busid_in_proc(maj, min, busid);
if (rc) {
snprintf(dev_string, DEV_BUFFER_LENGTH, "%u:%u", maj, min);
rc = find_busid_in_sysfs(dev_string, busid);
}
return rc;
}
/*
* Attempts to find the sysfs entry for the given busid and reads
* the contents of a specified attribute to the buffer
*/
int u2s_read_attribute(char *busid, char *attribute, char *buffer,
size_t count)
{
char path[100];
int rc, fd;
ssize_t rcount;
rc = 0;
snprintf(path, sizeof(path), "/sys/bus/ccw/devices/%s/%s",
busid, attribute);
fd = open(path, O_RDONLY);
if (fd < 0)
return errno;
rcount = read(fd, buffer, count);
if (rcount < 0)
rc = errno;
close(fd);
return rc;
}
int u2s_get_host_access_count(char *devicenode)
{
char busid[BUSIDSIZE];
unsigned long value;
char buffer[10];
char *endp;
u2s_getbusid(devicenode, busid);
u2s_read_attribute(busid, "host_access_count", buffer, sizeof(buffer));
value = strtoul(buffer, &endp, 0);
if (endp == buffer)
return -EINVAL;
return value;
}

View File

@@ -13,7 +13,8 @@ examples = util_base_example \
util_prg_example \
util_rec_example
all: $(lib) $(examples)
all: $(lib)
examples: $(lib) $(examples)
objects = util_base.o \
util_path.o \
@@ -26,7 +27,8 @@ objects = util_base.o \
util_part.o \
util_prg.o \
util_proc.o \
util_rec.o
util_rec.o \
util_sys.o
util_base_example: util_base_example.o $(lib)
util_panic_example: util_panic_example.o $(lib)

View File

@@ -228,3 +228,30 @@ char *util_strstrip(char *s)
return s;
}
/**
* Copy \a src to buffer \a dest of size \a size. At most size - 1
* chars will be copied. \a dest will always be NUL terminated.
*
* Note: If the return value is greater than or equal to size truncation
* occurred.
*
* @param[in] dest Destination buffer
* @param[in] src Source string
* @param[in] size Size of destination buffer
*
* @returns strlen Length of \a src string
*/
size_t util_strlcpy(char *dest, const char *src, size_t size)
{
size_t str_len = strlen(src);
size_t len;
if (size) {
len = MIN(size - 1, str_len);
memcpy(dest, src, len);
dest[len] = '\0';
}
return str_len;
}

View File

@@ -112,6 +112,12 @@ int main(int argc, char *argv[])
case OPT_NOSHORT:
printf("Specified: --noshort\n");
break;
case 'l':
printf("Specified: -l\n");
break;
case 'm':
printf("Specified: --manual\n");
break;
default:
util_opt_print_parse_error(c, argv);
return EXIT_FAILURE;

View File

@@ -15,10 +15,10 @@
#include <sys/resource.h>
#include <sys/time.h>
#include "lib/zt_common.h"
#include "lib/util_panic.h"
/* Make functions noinline to have a nice backtrace */
#define __noinline __attribute__((noinline))
/*
* Test util_panic()

View File

@@ -3,7 +3,7 @@
*
* Work with paths
*
* Copyright IBM Corp. 2016, 2017
* Copyright IBM Corp. 2016, 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.
@@ -107,7 +107,7 @@ bool util_path_is_readable(const char *fmt, ...)
bool rc;
UTIL_VASPRINTF(&path, fmt, ap);
rc = access(path, R_OK) == 0 ? true : false;
rc = access(path, R_OK) == 0;
free(path);
return rc;
@@ -131,7 +131,7 @@ bool util_path_is_writable(const char *fmt, ...)
bool rc;
UTIL_VASPRINTF(&path, fmt, ap);
rc = access(path, W_OK) == 0 ? true : false;
rc = access(path, W_OK) == 0;
free(path);
return rc;
@@ -150,18 +150,14 @@ bool util_path_is_writable(const char *fmt, ...)
*/
bool util_path_is_reg_file(const char *fmt, ...)
{
bool rc = false;
struct stat sb;
va_list ap;
char *path;
bool rc;
UTIL_VASPRINTF(&path, fmt, ap);
if (stat(path, &sb)) {
rc = false;
goto free_str;
}
rc = (sb.st_mode & S_IFREG) ? true : false;
free_str:
if (stat(path, &sb) == 0)
rc = S_ISREG(sb.st_mode);
free(path);
return rc;
}
@@ -179,18 +175,14 @@ free_str:
*/
bool util_path_is_dir(const char *fmt, ...)
{
bool rc = false;
struct stat sb;
va_list ap;
char *path;
bool rc;
UTIL_VASPRINTF(&path, fmt, ap);
if (stat(path, &sb)) {
rc = false;
goto free_str;
}
rc = (sb.st_mode & S_IFDIR) ? true : false;
free_str:
if (stat(path, &sb) == 0)
rc = S_ISDIR(sb.st_mode);
free(path);
return rc;
}
@@ -213,7 +205,62 @@ bool util_path_exists(const char *fmt, ...)
bool rc;
UTIL_VASPRINTF(&path, fmt, ap);
rc = access(path, F_OK) == 0 ? true : false;
rc = access(path, F_OK) == 0;
free(path);
return rc;
}
/**
* Test if path exists, is a regular file, and permission is read-only
*
* @param[in] fmt Format string for path to test
* @param[in] ... Variable arguments for format string
*
* @returns true Path exists, is a regular file, and permission does
* not allow any write but allows read
* false Otherwise
*/
bool util_path_is_readonly_file(const char *fmt, ...)
{
bool rc = false;
struct stat sb;
va_list ap;
char *path;
UTIL_VASPRINTF(&path, fmt, ap);
if (stat(path, &sb) == 0) {
rc = S_ISREG(sb.st_mode) &&
(sb.st_mode & 0222) == 0 &&
(sb.st_mode & 0444) != 0;
}
free(path);
return rc;
}
/**
* Test if path exists, is a regular file, and permission is write-only
*
* @param[in] fmt Format string for path to test
* @param[in] ... Variable arguments for format string
*
* @returns true Path exists, is a regular file, and permission does
* not allow any read but allows write
* false Otherwise
*/
bool util_path_is_writeonly_file(const char *fmt, ...)
{
bool rc = false;
struct stat sb;
va_list ap;
char *path;
UTIL_VASPRINTF(&path, fmt, ap);
if (stat(path, &sb) == 0) {
rc = S_ISREG(sb.st_mode) &&
(sb.st_mode & 0222) != 0 &&
(sb.st_mode & 0444) == 0;
}
free(path);
return rc;
}

View File

@@ -1,7 +1,7 @@
/**
* util_path_example - Example program for util_path
*
* Copyright IBM Corp. 2016, 2017
* Copyright IBM Corp. 2016, 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.
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "lib/util_path.h"
#include "lib/util_prg.h"
@@ -26,7 +27,7 @@ const struct util_prg prg = {
{
.owner = "IBM Corp.",
.pub_first = 2001,
.pub_last = 2017,
.pub_last = 2019,
},
UTIL_PRG_COPYRIGHT_END
}
@@ -72,9 +73,17 @@ static void test_path(const char *path)
else
printf("reg_file=no ");
if (util_path_is_dir(path))
printf("dir=yes");
printf("dir=yes ");
else
printf("dir=no ");
printf("dir=no ");
if (util_path_is_readonly_file(path))
printf("read-only_file=yes ");
else
printf("read-only_file=no ");
if (util_path_is_writeonly_file(path))
printf("write-only_file=yes");
else
printf("write-only_file=no ");
printf("\n");
}

View File

@@ -64,6 +64,7 @@ struct rec_fmt {
int argz_sep;
} csv_p;
} d;
int indent;
};
/*
@@ -122,9 +123,50 @@ struct util_rec *util_rec_new_wide(const char *hdr_sep)
rec->fmt.type = REC_FMT_WIDE;
rec->fmt.d.wide_p.hdr_sep = util_strdup(hdr_sep);
rec->fmt.d.wide_p.argz_sep = ',';
rec->fmt.indent = 0;
return rec;
}
/*
* Print the indentation characters
*/
static inline void rec_print_indention(int indent)
{
if (indent <= 0)
return;
printf("%*s", indent, "");
}
/*
* Print record separator in "wide" output format
*/
static void rec_print_wide_separator(struct util_rec *rec)
{
const char *hdr_sep = rec->fmt.d.wide_p.hdr_sep;
int size = 0, field_count = 0;
struct util_rec_fld *fld;
char *buf;
if (!hdr_sep)
return;
util_list_iterate(rec->list, fld) {
if (fld->hdr) {
size += fld->width;
field_count++;
}
}
size += field_count - 1;
buf = util_malloc(size + 1);
memset(buf, (int)hdr_sep[0], size);
buf[size] = 0;
rec_print_indention(rec->fmt.indent);
printf("%s\n", buf);
free(buf);
}
/*
* Print record header in "wide" output format
*/
@@ -135,6 +177,7 @@ static void rec_print_wide_hdr(struct util_rec *rec)
struct util_rec_fld *fld;
char *buf;
rec_print_indention(rec->fmt.indent);
util_list_iterate(rec->list, fld) {
if (col_nr)
printf(" ");
@@ -156,6 +199,7 @@ static void rec_print_wide_hdr(struct util_rec *rec)
buf = util_malloc(size + 1);
memset(buf, (int)hdr_sep[0], size);
buf[size] = 0;
rec_print_indention(rec->fmt.indent);
printf("%s\n", buf);
free(buf);
}
@@ -172,6 +216,7 @@ void rec_print_wide(struct util_rec *rec)
int fld_count = 0;
char *entry;
rec_print_indention(rec->fmt.indent);
util_list_iterate(rec->list, fld) {
if (!fld->hdr)
continue;
@@ -225,6 +270,7 @@ struct util_rec *util_rec_new_long(const char *hdr_sep, const char *col_sep,
rec->fmt.d.long_p.key_size = key_size;
rec->fmt.d.long_p.val_size = val_size;
rec->fmt.d.long_p.argz_sep = ' ';
rec->fmt.indent = 0;
return rec;
}
@@ -241,6 +287,7 @@ static void rec_print_long_hdr(struct util_rec *rec)
fld = rec_get_fld(rec, p->key);
util_assert(fld != NULL, "Record not found\n");
util_assert(fld->hdr != NULL, "Header for field not found\n");
rec_print_indention(rec->fmt.indent);
if (p->col_sep) {
printf("%-*s %s %-*s\n", p->key_size, fld->hdr,
p->col_sep, fld->width, fld->val);
@@ -255,6 +302,7 @@ static void rec_print_long_hdr(struct util_rec *rec)
buf = util_malloc(len + 1);
memset(buf, p->hdr_sep[0], len);
buf[len] = 0;
rec_print_indention(rec->fmt.indent);
printf("%s\n", buf);
free(buf);
}
@@ -277,19 +325,24 @@ static void rec_print_long(struct util_rec *rec)
continue;
if (!fld->val)
continue;
rec_print_indention(rec->fmt.indent);
item = argz_next(fld->val, fld->len, item);
if (p->col_sep) {
printf(" %-*s %s %s\n",
p->key_size - 8, fld->hdr, p->col_sep, item);
while ((item = argz_next(fld->val, fld->len, item)))
while ((item = argz_next(fld->val, fld->len, item))) {
rec_print_indention(rec->fmt.indent);
printf(" %-*s %c %s\n",
p->key_size - 8, "", p->argz_sep, item);
}
} else {
printf(" %-*s %s\n",
p->key_size - 8, fld->hdr, fld->val);
while ((item = argz_next(fld->val, fld->len, item)))
while ((item = argz_next(fld->val, fld->len, item))) {
rec_print_indention(rec->fmt.indent);
printf(" %-*s %s\n",
p->key_size - 8, "", item);
}
}
}
printf("\n");
@@ -320,6 +373,7 @@ struct util_rec *util_rec_new_csv(const char *col_sep)
rec->fmt.type = REC_FMT_CSV;
rec->fmt.d.csv_p.col_sep = util_strdup(col_sep);
rec->fmt.d.csv_p.argz_sep = ' ';
rec->fmt.indent = 0;
return rec;
}
@@ -332,6 +386,7 @@ void rec_print_csv_hdr(struct util_rec *rec)
struct util_rec_fld *fld;
int fld_count = 0;
rec_print_indention(rec->fmt.indent);
util_list_iterate(rec->list, fld) {
if (fld_count)
printf("%c", *col_sep);
@@ -354,6 +409,7 @@ void rec_print_csv(struct util_rec *rec)
int fld_count = 0;
char *item = NULL;
rec_print_indention(rec->fmt.indent);
util_list_iterate(rec->list, fld) {
item = argz_next(fld->val, fld->len, item);
if (fld_count)
@@ -470,6 +526,24 @@ void util_rec_print_hdr(struct util_rec *rec)
}
}
/**
* Print record separator according to output format
*
* @param[in] rec Record pointer
*/
void util_rec_print_separator(struct util_rec *rec)
{
switch (rec->fmt.type) {
case REC_FMT_WIDE:
rec_print_wide_separator(rec);
break;
case REC_FMT_LONG:
break;
case REC_FMT_CSV:
break;
}
}
/**
* Set a field value to an argz vector
*
@@ -537,3 +611,14 @@ const char *util_rec_get(struct util_rec *rec, const char *key)
return (fld != NULL) ? fld->val : NULL;
}
/**
* Sets the indentation of the record
*
* @param[in] rec Record pointer
* @param[in] indent Number of characters to indent
*/
void util_rec_set_indent(struct util_rec *rec, int indent)
{
rec->fmt.indent = indent;
}

View File

@@ -42,6 +42,8 @@ static void print_records(const char *format, struct util_rec *rec)
/* Print the record */
util_rec_print(rec);
}
/* Print a separator line (is a nop for long and csv format) */
util_rec_print_separator(rec);
printf("\n");
}
@@ -72,6 +74,11 @@ int main(void)
print_records("Wide format", rec);
util_rec_free(rec);
rec = util_rec_new_wide("-");
util_rec_set_indent(rec, 4);
print_records("Wide format with indentation", rec);
util_rec_free(rec);
rec = util_rec_new_long("-", ":", "number", 30, 20);
print_records("Long format", rec);
util_rec_free(rec);

77
libutil/util_sys.c Normal file
View File

@@ -0,0 +1,77 @@
/*
* util - Utility function library
*
* SysFS helper functions
*
* 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.
*/
#include <err.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <unistd.h>
#include "lib/util_path.h"
#include "lib/util_sys.h"
/* lstat() doesn't work for sysfs files, a fixed size is therefore inevitable */
#define READLINK_SIZE 256
/**
* Identify device address
*
* Identifying the device address with this function works for almost any
* character and block device (e.g. NVMe, SCSI, DASD, etc).
* The user must provide a buffer that is large enough for the desired device
* address to be read into \p addr.
*
* @param[in] dev Device node of interest
* @param[out] addr Identified device address
*
* @retval 0 Success
* @retval -1 Error while reading device information or
* constructed path
*/
int util_sys_get_dev_addr(const char *dev, char *addr)
{
char device[READLINK_SIZE], *result;
unsigned int maj, min;
struct stat s;
ssize_t len;
char *path;
if (stat(dev, &s) != 0)
return -1;
maj = major(s.st_rdev);
min = minor(s.st_rdev);
if (S_ISBLK(s.st_mode))
path = util_path_sysfs("dev/block/%u:%u/device", maj, min);
else if (S_ISCHR(s.st_mode))
path = util_path_sysfs("dev/char/%u:%u/device", maj, min);
else
return -1;
len = readlink(path, device, READLINK_SIZE - 1);
free(path);
if (len != -1)
device[len] = '\0';
else
return -1;
result = strrchr(device, '/');
if (result)
result++;
else
result = device;
strcpy(addr, result);
return 0;
}

View File

@@ -4,7 +4,8 @@ lib = libvmcp.a
examples = vmcp_example
all: $(lib) $(examples)
all: $(lib)
examples: $(lib) $(examples)
objects = vmcp.o

View File

@@ -35,7 +35,7 @@ public:
const char *what(void) const { return msg; }
int code(void) const { return errorCode; }
protected:
char msg[200];
char msg[2048];
int errorCode;
};

View File

@@ -98,19 +98,20 @@ VMDump::VMDump(const char *fileName) : Dump(fileName, "rb")
dump_read(&adsrRecord,sizeof(adsrRecord),1,fh);
if(debug) {
char buf_asc[1024];
char buf[1024];
int i;
fprintf(stderr, "off=%d\n", adsrRecord.sec5_offset);
dump_seek(fh, adsrRecord.sec5_offset, SEEK_SET);
dump_read(buf, adsrRecord.sec5_len, 1, fh);
ebcAsc(buf, adsrRecord.sec5_len);
ebcAsc(buf, buf_asc, adsrRecord.sec5_len);
for (i=0; i < adsrRecord.sec5_len; i++) {
if ((buf[i]==0) || iscntrl(buf[i]))
buf[i]=' ';
if ((buf_asc[i]==0) || iscntrl(buf_asc[i]))
buf_asc[i]=' ';
}
buf[adsrRecord.sec5_len] = 0;
printf("symptom string1: %s\n",buf);
buf_asc[adsrRecord.sec5_len] = 0;
printf("symptom string1: %s\n",buf_asc);
}
/* Record 2: fmbk */
@@ -142,7 +143,8 @@ struct timeval VMDump::getDumpTime(void) const
void VMDump::printDebug(void)
{
struct timeval time;
char buf[1024];
char fmbk_id[8];
char albk_id[8];
s390TodToTimeval(adsrRecord.tod, &time);
@@ -165,9 +167,9 @@ void VMDump::printDebug(void)
/* fmbk */
ebcAsc(fmbkRecord.id, sizeof(fmbkRecord.id));
fmbkRecord.id[7] = 0;
printf("id : %s\n", fmbkRecord.id);
ebcAsc(fmbkRecord.id, fmbk_id, sizeof(fmbkRecord.id));
fmbk_id[7] = 0;
printf("id : %s\n", fmbk_id);
printf("fir rec nr: %i\n", fmbkRecord.rec_nr_fir);
printf("vec rec nr: %i\n", fmbkRecord.rec_nr_vector);
printf("access rec nr: %i\n", fmbkRecord.rec_nr_access);
@@ -175,21 +177,9 @@ void VMDump::printDebug(void)
/* albk */
memcpy(buf, albkRecord.id, sizeof(albkRecord.id));
ebcAsc(buf, sizeof(albkRecord.id));
buf[8]=0;
printf("ALBK id : %s\n",buf);
/* asibk */
/*
XXX
memcpy(buf,asibkRecord.id,sizeof(asibkRecord.id));
ebcAsc(buf,sizeof(asibkRecord.id));
asibkRecord.id[8]=0;
printf("ASIBK id : %s\n",buf);
printf("storage : %x\n",asibkRecord.storage_size_2GB);
printf("bitmapsrecs : %i\n",asibkRecord.nr_of_recs_of_first_bit_map);
*/
ebcAsc(albkRecord.id, albk_id, sizeof(albkRecord.id));
albk_id[7]=0;
printf("ALBK id : %s\n",albk_id);
}
void VMDump::printInfo(void)

View File

@@ -140,9 +140,15 @@ protected:
} __packed;
/* Methods */
inline void ebcAsc(char *inout, size_t len) const
inline void ebcAsc(char *in, char *out, size_t size) const
{
iconv(ebcdicAsciiConv, &inout, &len, &inout, &len);
size_t size_out = size;
size_t size_in = size;
size_t rc;
rc = iconv(ebcdicAsciiConv, &in, &size_in, &out, &size_out);
if (rc == (size_t) -1)
throw(DumpException("Code page translation EBCDIC-ASCII failed"));
}
/* Members */

View File

@@ -398,7 +398,7 @@ void vtoc_volume_label_set_volser (volume_label_t *vlabel, char *volser)
strcpy(s, " ");
vtoc_ebcdic_enc(s, s, VOLSER_LENGTH);
strncpy(vlabel->volid, s, VOLSER_LENGTH);
memcpy(vlabel->volid, s, VOLSER_LENGTH);
if (i > VOLSER_LENGTH) i = VOLSER_LENGTH;
@@ -743,8 +743,8 @@ static void vtoc_init_format_1_8_label (
bzero(f1->DS1DSNAM, sizeof(f1->DS1DSNAM));
sprintf(str, "PART .NEW ");
vtoc_ebcdic_enc(str, str, 44);
strncpy(f1->DS1DSNAM, str, 44);
strncpy((char *) f1->DS1DSSN, " ", 6);
memcpy(f1->DS1DSNAM, str, 44);
memcpy((char *) f1->DS1DSSN, " ", 6);
f1->DS1VOLSQ = 0x0001;
vtoc_set_date(&f1->DS1CREDT,
@@ -758,7 +758,7 @@ static void vtoc_init_format_1_8_label (
f1->DS1NOBDB = 0x00;
f1->DS1FLAG1 = 0x00;
vtoc_ebcdic_enc("IBM LINUX ", str, 13);
strncpy((char *)f1->DS1SYSCD, str, 13);
memcpy((char *)f1->DS1SYSCD, str, 13);
vtoc_set_date(&f1->DS1REFD,
(u_int8_t) creatime->tm_year,
(u_int16_t) creatime->tm_yday);

View File

@@ -20,10 +20,8 @@
#include <stdlib.h>
#include "lib/dasd_base.h"
#include "lib/dasd_sys.h"
#include "lib/libzds.h"
#include "lib/u2s.h"
#include "lib/util_base.h"
#include "lib/util_list.h"
#include "lib/vtoc.h"
/** @cond PRIVATE */
@@ -70,42 +68,6 @@ struct errormsg {
char text[ERRORMSG];
};
/**
* 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 efficiant, 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 in 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 dscbiterator {
/** @brief The raw_vtoc this iterator refers to */
struct raw_vtoc *rawvtoc;
@@ -113,31 +75,6 @@ struct dscbiterator {
unsigned int i;
};
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 dasdhandle {
/** @brief The struct dasd this context relates to */
struct dasd *dasd;
@@ -412,6 +349,29 @@ int lzds_zdsroot_alloc(struct zdsroot **root)
return 0;
}
/**
* It should be noted that this frees all structures that are owned by the
* root structure as well. For example, a pointer to a struct dasd that
* has been returned by lzds_zdsroot_add_device is not valid anymore.
*
* @param[in] root Reference to the zdsroot structure that is to be freed.
*/
void lzds_dslist_free(struct zdsroot *root)
{
struct dataset *ds, *nextds;
int i;
util_list_iterate_safe(root->datasetlist, ds, nextds) {
util_list_remove(root->datasetlist, ds);
dataset_free_memberlist(ds);
for (i = 0; i < MAXVOLUMESPERDS; ++i)
free(ds->dsp[i]);
errorlog_free(ds->log);
free(ds);
}
}
/**
* It should be noted that this frees all structures that are owned by the
* root structure as well. For example, a pointer to a struct dasd that
@@ -422,8 +382,6 @@ int lzds_zdsroot_alloc(struct zdsroot **root)
void lzds_zdsroot_free(struct zdsroot *root)
{
struct dasd *dasd, *nextdasd;
struct dataset *ds, *nextds;
int i;
if (!root)
return;
@@ -433,15 +391,7 @@ void lzds_zdsroot_free(struct zdsroot *root)
dasd_free(dasd);
}
util_list_free(root->dasdlist);
util_list_iterate_safe(root->datasetlist, ds, nextds) {
util_list_remove(root->datasetlist, ds);
dataset_free_memberlist(ds);
for (i = 0; i < MAXVOLUMESPERDS; ++i)
free(ds->dsp[i]);
errorlog_free(ds->log);
free(ds);
}
lzds_dslist_free(root);
util_list_free(root->datasetlist);
errorlog_free(root->log);
free(root);
@@ -1443,7 +1393,7 @@ int lzds_raw_vtoc_get_dscb_from_cchhb(struct raw_vtoc *rv, cchhb_t *p,
* - EPROTO The VTOC data is not in a valid format.
* - EIO Other I/O error
*/
int lzds_dasd_read_rawvtoc(struct dasd *dasd)
int lzds_dasd_read_rawvtoc(struct dasd *dasd, struct raw_vtoc *rawvtoc)
{
unsigned long long vtoctrckno, vtocrecno;
unsigned int vtoctrack_start, vtoctrack_end, vtocindexsize;
@@ -1455,26 +1405,11 @@ int lzds_dasd_read_rawvtoc(struct dasd *dasd)
format4_label_t *f4;
unsigned long long rawvtocsize;
struct raw_vtoc *rawvtoc = NULL;
volume_label_t *vlabel = NULL;
char *trackdata = NULL;
char vol1[] = {0xe5, 0xd6, 0xd3, 0xf1, 0x00}; /* "VOL1" in EBCDIC */
errorlog_clear(dasd->log);
/* cleanup the old rawvtoc structures before we read new ones */
rawvtoc = dasd->rawvtoc;
dasd->rawvtoc = NULL;
if (rawvtoc) {
free(rawvtoc->rawdata);
free(rawvtoc->vtocindex);
free(rawvtoc);
}
rawvtoc = malloc(sizeof(*rawvtoc));
if (!rawvtoc)
return ENOMEM;
memset(rawvtoc, 0, sizeof(*rawvtoc));
rawvtoc->dasd = dasd;
rc = lzds_dasd_get_vlabel(dasd, &vlabel);
if (rc) {
@@ -1611,13 +1546,49 @@ int lzds_dasd_read_rawvtoc(struct dasd *dasd)
++i;
}
dasd->rawvtoc = rawvtoc;
return 0;
cleanup:
free(rawvtoc->vtocindex);
free(trackdata);
free(rawvtoc);
return rc;
}
/**
* @param[in] dasd The struct dasd that represents the device we want to read
* the VTOC from.
* @return 0 on success, otherwise one of the following error codes:
* - ENOMEM Could not allocate internal structure due to lack of memory.
* - EINVAL The volume label has not yet been read or it is not valid.
* - EPROTO The VTOC data is not in a valid format.
* - EIO Other I/O error
*/
int lzds_dasd_alloc_rawvtoc(struct dasd *dasd)
{
struct raw_vtoc *rawvtoc = NULL;
int rc;
/* cleanup the old rawvtoc structures before we read new ones */
rawvtoc = dasd->rawvtoc;
dasd->rawvtoc = NULL;
if (rawvtoc) {
free(rawvtoc->rawdata);
free(rawvtoc->vtocindex);
free(rawvtoc);
}
rawvtoc = malloc(sizeof(*rawvtoc));
if (!rawvtoc)
return ENOMEM;
memset(rawvtoc, 0, sizeof(*rawvtoc));
rawvtoc->dasd = dasd;
rc = lzds_dasd_read_rawvtoc(dasd, rawvtoc);
if (rc) {
free(rawvtoc->vtocindex);
free(rawvtoc);
} else {
dasd->rawvtoc = rawvtoc;
}
return rc;
}
@@ -2261,6 +2232,7 @@ out1:
static int dataset_merge_dataset(struct dataset *baseds, struct dataset *newds)
{
int k, l, dspcount;
for (k = 0; k < MAXVOLUMESPERDS; ++k) {
/* if both datasets have a part in position k,
* then something is wrong */
@@ -2280,18 +2252,20 @@ static int dataset_merge_dataset(struct dataset *baseds, struct dataset *newds)
* Since dsp[0] may not be set yet, we loop over the
* base dsp array until we find an entry.
*/
for (l = 0; l < MAXVOLUMESPERDS; ++l)
if (baseds->dsp[l]) {
if (memcmp(baseds->dsp[l]->f1->DS1DSSN,
newds->dsp[k]->f1->DS1DSSN,
MAXVOLSER))
return errorlog_add_message(
&baseds->log, NULL, EPROTO,
"merge dataset: part %d has incompatible"
" base volume serial\n", k);
else
break;
}
for (l = 0; l < MAXVOLUMESPERDS; ++l) {
if (!baseds->dsp[l])
continue;
if (memcmp(baseds->dsp[l]->f1->DS1DSSN,
newds->dsp[k]->f1->DS1DSSN,
MAXVOLSER))
return errorlog_add_message(
&baseds->log, NULL, EPROTO,
"merge dataset: part %d has incompatible base volume serial\n",
k);
else
break;
}
baseds->dsp[k] = newds->dsp[k];
baseds->dspcount++;
@@ -3727,7 +3701,7 @@ int lzds_analyse_open_count(struct zdsroot *root, int warn)
int rc = 0;
util_list_iterate(root->dasdlist, dasd) {
value = u2s_get_host_access_count(dasd->device);
value = dasd_get_host_access_count(dasd->device);
if (value < 0) {
fprintf(stderr,

View File

@@ -32,7 +32,7 @@ static char small_mon_record[SMALL_MON_RECORD_LEN];
static char large_mon_record[LARGE_MON_RECORD_LEN];
static long sample_interval = 60;
static const char *pid_file = "/var/run/mon_fsstatd.pid";
static const char *pid_file = "/run/mon_fsstatd.pid";
struct mw_name_lens {
__u16 mw_name_len;

View File

@@ -59,7 +59,7 @@ static char buf[BUF_SIZE];
static char mon_record[MAX_REC_LEN];
static long sample_interval = 60;
static const char *pid_file = "/var/run/mon_procd.pid";
static const char *pid_file = "/run/mon_procd.pid";
/*
* Clean up when SIGTERM or SIGINT received

View File

@@ -33,8 +33,8 @@ pxelinux.initramfs: $(BBINSTALL)
$(BUSYBOX)/_install:
wget https://busybox.net/downloads/$(BUSYBOX).tar.bz2
tar xjf $(BUSYBOX).tar.bz2
make -C $(BUSYBOX) defconfig
make -C $(BUSYBOX) install
$(MAKE) -C $(BUSYBOX) defconfig
$(MAKE) -C $(BUSYBOX) install
install:

View File

@@ -58,7 +58,7 @@ e.g. \-xc0a80a26
.TP
\fIMASKBITS\fR
Number of bits set in the network mask.
This allows to specify an address range, e.g. 192.168.10.0/24.
Network masks can be used to specify address ranges, e.g. 192.168.10.0/24.
This subparameter is only valid for function IPA.
.TP
\fIINTERFACE\fR

View File

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

View File

@@ -24,6 +24,7 @@
#include <sys/types.h>
#include <unistd.h>
#include "lib/util_libc.h"
#include "lib/zt_common.h"
#include "qethqoat.h"
@@ -46,9 +47,15 @@ static int mac_is_zero(__u8 *mac)
return !(mac[0] | mac[1] | mac[2] | mac[3] | mac[4] | mac[5]);
}
static void ebctoasc(char *inout, size_t len)
static void ebctoasc(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)
fprintf(stderr, "Code page translation EBCDIC-ASCII failed\n");
}
static void print_version()
@@ -287,6 +294,7 @@ static void print_logical(struct qeth_qoat_logical *lhdr)
char prouter[] = "primary";
char srouter[] = "secondary";
char nrouter[] = "no";
char port_name[8];
char *router;
if (lhdr->ip4_primary_router)
@@ -340,8 +348,8 @@ static void print_logical(struct qeth_qoat_logical *lhdr)
if (lhdr->port_name_f) {
ebctoasc((char *)lhdr->port_name, 8);
printf("Port name: %.8s\n", lhdr->port_name);
ebctoasc((char *)lhdr->port_name, port_name, 8);
printf("Port name: %.8s\n", port_name);
}
printf("IPv4 assists enabled: 0x%08x\n", lhdr->ip4_ass_enabled);
@@ -541,6 +549,7 @@ int main(int argc, char **argv)
opts.raw = 0;
opts.scope = 1;
opts.file = NULL;
opts.ifname = NULL;
while ((c = getopt_long(argc, argv, qethqoat_opts_str, qethqoat_opts,
&index)) != -1) {
@@ -613,7 +622,7 @@ int main(int argc, char **argv)
return 1;
}
strncpy(ifr.ifr_name, opts.ifname, IFNAMSIZ);
util_strlcpy(ifr.ifr_name, opts.ifname, IFNAMSIZ);
oat_data.command = opts.scope;
ifr.ifr_ifru.ifru_data = (void *)&oat_data;

View File

@@ -167,9 +167,18 @@ readonly OUTPUT_FILE_VMCMD="${WORKPATH}zvm_runtime.out"
# File that includes content of files from sysfs
readonly OUTPUT_FILE_SYSFS="${WORKPATH}sysfsfiles.out"
# File that includes the output of lsof
readonly OUTPUT_FILE_LSOF="${WORKPATH}open_files.out"
# File that includes content of OSA OAT
readonly OUTPUT_FILE_OSAOAT="${WORKPATH}osa_oat"
# File that includes content of Ethtool commands
readonly OUTPUT_FILE_ETHTOOL="${WORKPATH}ethtool.out"
# File that includes content of tc commands
readonly OUTPUT_FILE_TC="${WORKPATH}tc.out"
# File that includes the output of journalctl
readonly OUTPUT_FILE_JOURNALCTL="${WORKPATH}journalctl.out"
@@ -189,7 +198,7 @@ readonly OUTPUT_FILE_NVME="${WORKPATH}nvme.out"
readonly MOUNT_POINT_DEBUGFS="/sys/kernel/debug"
# The amount of steps running the whole collections
readonly COLLECTION_COUNT=12
readonly COLLECTION_COUNT=14
# The kernel version (e.g. '2' from 2.6.32 or '3' from 3.2.1)
readonly KERNEL_VERSION=$(uname -r 2>/dev/null | cut -d'.' -f1)
@@ -307,12 +316,13 @@ LOGFILES="\
/var/log/lin_tape.trace\
/var/log/lin_tape.errorlog\
/var/log/messages*\
/var/log/opencryptoki\
/var/log/syslog*\
/var/log/sa\
/var/log/yum.log\
/var/log/openvswitch/ovs-vswitchd.log\
/var/log/openvswitch/ovsdb-server.log\
/var/run/docker/libcontainerd/containerd/events.log\
/run/docker/libcontainerd/containerd/events.log\
/run/containerd/events.log\
"
@@ -367,7 +377,7 @@ CONFIGFILES="\
$(find /lib/modules -name modules.dep 2>/dev/null)\
/etc/docker\
/lib/systemd/system/docker.service\
/usr/lib/systemd/system/docker.service\
/usr/lib/systemd/system\
/etc/apparmor.d\
"
@@ -394,6 +404,7 @@ CMDS="uname -a\
:ip link show\
:ip ntable\
:ip a sh\
:ip -s -s link\
:firewall-cmd --list-all\
:ipcs -a\
:netstat -pantu\
@@ -441,7 +452,8 @@ CMDS="uname -a\
:SPident\
:rpm -qa | sort\
:sysctl -a\
:lsof\
:lsof \
> '${OUTPUT_FILE_LSOF}'\
:mount\
:df -h\
:df -i\
@@ -451,7 +463,7 @@ CMDS="uname -a\
:java -version\
:cat /root/.bash_history\
:env\
:journalctl --all --no-pager --since=$(date -d '5 day ago' +%Y-%m-%d) --until=now --lines=50000 \
:journalctl --all --no-pager --lines=100000 --output=short-precise\
> '${OUTPUT_FILE_JOURNALCTL}'\
:openssl engine\
:systemd-delta\
@@ -465,6 +477,10 @@ CMDS="uname -a\
:docker version\
:docker stats --no-stream\
:systemctl status docker.service\
:blockdev --report\
:lvdisplay\
:lspci -vv\
:smc_dbg\
"
########################################
@@ -549,6 +565,11 @@ collect_cmdsout() {
done
IFS="${ifs_orig}"
if echo "${RUNTIME_ENVIRONMENT}" | grep -qi "z/VM" >/dev/null 2>&1; then
call_run_command "hyptop -b -d 1 -n 5 -f \#,c,m,C:s,M:s,o -S c" "${OUTPUT_FILE_CMD}"
else call_run_command "hyptop -b -d 1 -n 5 -f \#,T,c,e,m,C:s,E:s,M:s,o -S c" "${OUTPUT_FILE_CMD}"
fi
pr_log_stdout " "
}
@@ -743,6 +764,59 @@ collect_osaoat() {
pr_log_stdout " "
}
########################################
collect_ethtool() {
local network_devices
local network_device
network_devices=$(ls /sys/class/net 2>/dev/null)
if which ethtool >/dev/null 2>&1; then
if test -n "${network_devices}"; then
pr_syslog_stdout "8 of ${COLLECTION_COUNT}: Collecting ethtool output"
for network_device in ${network_devices}; do
call_run_command "ethtool ${network_device}" "${OUTPUT_FILE_ETHTOOL}"
call_run_command "ethtool -k ${network_device}" "${OUTPUT_FILE_ETHTOOL}"
call_run_command "ethtool -a ${network_device}" "${OUTPUT_FILE_ETHTOOL}"
call_run_command "ethtool -c ${network_device}" "${OUTPUT_FILE_ETHTOOL}"
call_run_command "ethtool -g ${network_device}" "${OUTPUT_FILE_ETHTOOL}"
call_run_command "ethtool -i ${network_device}" "${OUTPUT_FILE_ETHTOOL}"
call_run_command "ethtool -l ${network_device}" "${OUTPUT_FILE_ETHTOOL}"
call_run_command "ethtool -P ${network_device}" "${OUTPUT_FILE_ETHTOOL}"
call_run_command "ethtool -S ${network_device}" "${OUTPUT_FILE_ETHTOOL}"
call_run_command "ethtool -T ${network_device}" "${OUTPUT_FILE_ETHTOOL}"
done
else
pr_syslog_stdout "8 of ${COLLECTION_COUNT}: Collecting ethtool output skipped - no devices"
fi
else
pr_syslog_stdout "8 of ${COLLECTION_COUNT}: Collecting ethtool output skipped - not available"
fi
pr_log_stdout " "
}
########################################
collect_tc() {
local network_devices
local network_device
network_devices=$(ls /sys/class/net 2>/dev/null)
if which tc >/dev/null 2>&1; then
if test -n "${network_devices}"; then
pr_syslog_stdout "9 of ${COLLECTION_COUNT}: Collecting tc output"
for network_device in ${network_devices}; do
call_run_command "tc -s qdisc show dev ${network_device}" "${OUTPUT_FILE_TC}"
done
else
pr_syslog_stdout "9 of ${COLLECTION_COUNT}: Collecting tc output skipped - no devices"
fi
else
pr_syslog_stdout "9 of ${COLLECTION_COUNT}: Collecting tc output skipped - not available"
fi
pr_log_stdout " "
}
########################################
# OpenVSwitch
collect_ovs() {
@@ -759,7 +833,7 @@ collect_ovs() {
:ovsdb-client dump\
"
if test -n "${br_list}"; then
pr_syslog_stdout "8 of ${COLLECTION_COUNT}: Collecting OpenVSwitch output"
pr_syslog_stdout "10 of ${COLLECTION_COUNT}: Collecting OpenVSwitch output"
IFS=:
for ovscmd in ${ovscmds}; do
IFS=${ifs_orig} call_run_command "${ovscmd}" "${OUTPUT_FILE_OVS}.out"
@@ -778,7 +852,7 @@ collect_ovs() {
IFS="${ifs_orig}"
done
else
pr_syslog_stdout "8 of ${COLLECTION_COUNT}: Collecting OpenVSwitch output skipped"
pr_syslog_stdout "10 of ${COLLECTION_COUNT}: Collecting OpenVSwitch output skipped"
fi
pr_log_stdout " "
@@ -791,12 +865,12 @@ collect_domain_xml() {
domain_list=$(virsh list --all --name)
if test -n "${domain_list}"; then
pr_syslog_stdout "9 of ${COLLECTION_COUNT}: Collecting domain xml files"
pr_syslog_stdout "11 of ${COLLECTION_COUNT}: Collecting domain xml files"
for domain in ${domain_list}; do
call_run_command "virsh dumpxml ${domain}" "${OUTPUT_FILE_XML}_${domain}.xml"
done
else
pr_syslog_stdout "9 of ${COLLECTION_COUNT}: Collecting domain xml files skipped"
pr_syslog_stdout "11 of ${COLLECTION_COUNT}: Collecting domain xml files skipped"
fi
pr_log_stdout " "
@@ -810,23 +884,23 @@ collect_docker() {
# call docker inspect for all containers
item_list=$(docker ps -qa)
if test -n "${item_list}"; then
pr_syslog_stdout "10a of ${COLLECTION_COUNT}: Collecting docker container output"
pr_syslog_stdout "12a of ${COLLECTION_COUNT}: Collecting docker container output"
for item in ${item_list}; do
call_run_command "docker inspect ${item}" "${OUTPUT_FILE_DOCKER}"
done
else
pr_syslog_stdout "10a of ${COLLECTION_COUNT}: Collecting docker container output skipped"
pr_syslog_stdout "12a of ${COLLECTION_COUNT}: Collecting docker container output skipped"
fi
# call docker inspect for all networks
item_list=$(docker network ls -q)
if test -n "${item_list}"; then
pr_syslog_stdout "10b of ${COLLECTION_COUNT}: Collecting docker network output"
pr_syslog_stdout "12b of ${COLLECTION_COUNT}: Collecting docker network output"
for item in ${item_list}; do
call_run_command "docker network inspect ${item}" "${OUTPUT_FILE_DOCKER}"
done
else
pr_syslog_stdout "10b of ${COLLECTION_COUNT}: Collecting docker network output skipped"
pr_syslog_stdout "12b of ${COLLECTION_COUNT}: Collecting docker network output skipped"
fi
pr_log_stdout " "
@@ -836,7 +910,7 @@ collect_docker() {
collect_nvme() {
local NVME
pr_syslog_stdout "11 of ${COLLECTION_COUNT}: Collecting nvme output"
pr_syslog_stdout "13 of ${COLLECTION_COUNT}: Collecting nvme output"
call_run_command "nvme list" "${OUTPUT_FILE_NVME}"
for NVME in /dev/nvme[0-9]*; do
@@ -1143,6 +1217,10 @@ collect_configfiles
collect_osaoat
collect_ethtool
collect_tc
collect_ovs
collect_domain_xml

View File

@@ -52,7 +52,7 @@ Sample invocation:
.br
dbginfo.sh: Debug information script version %S390_TOOLS_VERSION%
.br
Copyright IBM Corp. 2002, 2017
Copyright IBM Corp. 2002, 2019
.PP
Hardware platform = s390x
.br
@@ -60,34 +60,42 @@ Kernel version = <kernel\-version>
.br
Runtime environment = z/VM
.PP
1 of 11: Collecting command output
1 of 14: Collecting command output
.PP
2 of 11: Collecting z/VM command output
2 of 14: Collecting z/VM command output
.PP
3 of 11: Collecting procfs
3 of 14: Collecting procfs
.PP
4 of 11: Collecting sysfs
4 of 14: Collecting sysfs
.PP
5 of 11: Collecting log files
5 of 14: Collecting log files
.PP
6 of 11: Collecting config files
6 of 14: Collecting config files
.PP
7 of 11: Collecting osa oat output skipped \- not available
7 of 14: Collecting osa oat output skipped \- not available
.PP
8 of 11: Collecting OpenVSwitch output
8 of 14: Collecting ethtool output
.PP
9 of 11: Collecting domain xml files
9 of 14: Collecting tc output
.pp
10 of 14: Collecting OpenVSwitch output
.PP
10a of 11: Collecting docker container output
10b of 11: Collecting docker network output
11 of 14: Collecting domain xml files
.PP
11 of 11: Postprocessing
12a of 14: Collecting docker container output
12b of 14: Collecting docker network output
.PP
13 of 14: Collecting nvme output
.PP
14 of 14: Postprocessing
.PP
Finalizing: Creating archive with collected data
.PP
Collected data was saved to:
.br
>> /data\-collection/DBGINFO\-2015\-02\-26\-21\-39\-16\-host\-012345.tgz <<
>> /data\-collection/DBGINFO\-2019\-08\-19\-21\-39\-16\-host\-012345.tgz <<
.br
Review the collected data before sending to your service organization.
.SH HINTS
Run the script with root authority.
.br

View File

@@ -291,6 +291,13 @@ sub get_payload_records
my $area = str_from_hex(substr($record[2], 2, 14));
my $counter = hex(substr($record[2], 0, 2));
my $fsf_req_id = substr($record[2], 16, 16);
# ($counter == 0) is just a simple heuristic which can fail if
# there are missing payload record junks due to PAY area wrap!
if ($counter == 0 &&
defined($PAYLOAD_RECORDS{$fsf_req_id}{$area})) {
print "Warning: Ambiguous PAYload records. reqid:" .
$fsf_req_id . " area:" . $area . "\n";
}
$PAYLOAD_RECORDS{$fsf_req_id}{$area}[$counter] = [@record];
if ($def_error && ($area =~ /def_err/)) {
$def_error{$fsf_req_id}[$counter] = [@record];
@@ -515,11 +522,16 @@ sub print_payload
my $field_name = shift();
my $tmp_str;
if ($payload) {
# workaround to let user determine ambiguous PAYload records
printf "%-14s : %s\n", "Payload time", $payload->[0]->[0];
}
printf "%-14s : ", $field_name;
if (!$payload) {
print "record not available anymore.\n";
return;
}
# TODO: iterate with $counter loop and notify user about missing junks
foreach my $cc (@$payload) {
$tmp_str .= substr($cc->[2], 32);
}

View File

@@ -150,6 +150,7 @@ while IFS='= ' read key val; do
if [ -f "${OUTPUT}" ]; then
print_error "BLS file ${OUTPUT} already exists"
fi
echo "title $section" >> ${OUTPUT}
fi
elif [[ $val ]]; then
val="$(echo $val | sed -e 's/^[ \t"]*//;s/[ \t"]*$//')"

View File

@@ -15,7 +15,7 @@ ConditionVirtualization=no
[Service]
Type=forking
ExecStart=@usrsbin_path@/cpacfstatsd
PIDFile=/var/run/cpacfstatsd.pid
PIDFile=/run/cpacfstatsd.pid
KillMode=process
Restart=no

View File

@@ -17,7 +17,7 @@ ExecStart=@usrsbin_path@/cpuplugd -c @sysconf_path@/cpuplugd.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Type=forking
PIDFile=/var/run/cpuplugd.pid
PIDFile=/run/cpuplugd.pid
[Install]
WantedBy=multi-user.target

View File

@@ -34,7 +34,7 @@ ExecStart=@usrsbin_path@/mon_fsstatd -i $FSSTAT_INTERVAL
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Type=forking
PIDFile=/var/run/mon_fsstatd.pid
PIDFile=/run/mon_fsstatd.pid
[Install]
WantedBy=multi-user.target

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