Compare commits

..

21 Commits

Author SHA1 Message Date
Jan Höppner
b098990abe New release s390-tools-2.15.1
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 15:31:59 +01:00
Stefan Haberland
6802b86414 libutil: determine base device address in case of given partition
util_sys_get_dev_addr() returns the device address for a given blockdevice.
This does not work for partitions but some tools rely on the ability to get
the device address for partitions.

Add code that first determines the base device for a partition.

Fixes: 6014d07cb1 ("dasdview/libdasd/zipl: Use util_sys_get_dev_addr() instead of u2s_getbusid()")
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 15:08:29 +01:00
Stefan Haberland
aa8c2945cc zipl: make use of util_sys functions to get base device
Remove the implementation in zipl and use the util_sys one.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 15:08:24 +01:00
Stefan Haberland
fa7a4dafa3 libutil: add function to get base device for blockdevice
Some operations are only possible on base devices not on partitions.
Add functions to determine if a given device is a partition or a base
device and to get the base device to a given partition.

Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 15:08:02 +01:00
Jan Höppner
7eb04cdc54 zfcpdump: Fix dump location in README
Commit 724f1fea2c ("Makefile: Rename ZFCPDUMP_PART_* macros") renamed
the zfcpdump image from zfcpdump_part.image to zfcpdump-image. Fix the
image name in the README as well.

Closes: https://github.com/ibm-s390-tools/s390-tools/issues/89
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Jan Höppner
d55b787d05 zgetdump: Fix device node determination via sysfs
When using zgetdump on a multi-volume device dump, the sysfs path to
determine the device node is incomplete, resulting in the following
error:

$ zgetdump -i /dev/dasdb1
zgetdump: Could not open "/sys/bus/ccw/devices/0.0.9300/dasdb/dev" (No
such file or directory)

A simple fix would be to add the missing "block" part in the sysfs path.
However, the logic still assumes sysfs links like "block:" that have
been deprecated a decade ago and are no longer present on modern
systems anyway.
Therefore, the logic can greatly be improved. Create a separate function
to determine whether a device is online, remove the logic for "block:"
entries, and use libutil functions to reduce the complexity even further.

Fixes: 70a79fab3c ("zgetdump: Avoid using PATH_MAX")
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Jan Höppner
da4fdeeb82 dasdfmt: Set prog_name to last component of program name
In the process of switching to glibc defined error functions it becomes
apparent that self-defined error functions that do special things are
not in line with the output of the glibc functions.

To address this, set the prog_name variable to the last component of the
program name (stored in argv[0]) and guarantee a uniform error output.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Jan Höppner
9fe491df27 dasdfmt: Improve error message construction
In check_track_format() the base error message is the same for all cases
but has different additional content depending on which mode dasdfmt is
running.

Currently the message is compiled by using different outputs. To make it
a little bit cleaner and for a better error message handling, construct
the message string completely before passing it to the error() function
for output.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Jan Höppner
732b3dddab dasdfmt: Replace ERRMSG_EXIT macro with an error handling function
The ERRMSG_EXIT macro is a bit clunky in its usage and a change is
necessary in order to free memory in error cases.

Create a new function error() that takes only a format string and adds
all other relevant information by itself. This function frees memory
before terminating the program with the EXIT_FAILURE exit code.

This simplifies the error handling for pretty much all calls and makes
the code a bit cleaner.

While at it, the defines EXIT_MISUSE and EXIT_BUSY don't provide any
value. Neither are they documented nor are these standardized. Also, a
parent process is mostly interessted in success or failure only anyway.
Replace these by using only EXIT_FAILURE in the error() function.

Also, change multiline output to a combination of warnx and error to
have a uniformed output. So this:

WARNING: Device is formatted with a different blocksize (4096).
Use --mode=full to perform a clean format.

becomes this:

dasdfmt: WARNING: Device is formatted with a different blocksize (4096).
dasdfmt: Use --mode=full to perform a clean format.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Jan Höppner
cb76e39cef dasdfmt: Fix bad file descriptor error when running on symlinks
When calling dasdfmt on device node symlinks like
/dev/disk/by-id/ccw-0X9300, dasdfmt fails with "dasdfmt: the ioctl to get
the blocksize of the device failed (Bad file descriptor)"

This is because before the actual formatting process starts, the disk
will be disabled calling the BIODASDDISABLE ioctl, resulting in the
removal of the symlink. Trying to open this file later in the process to
retrieve e.g. blocksize information results in the mentioned error, as
the file doesn't exist any longer.

This incorrect behaviour was introduced with commit 8826028bdc
("dasdfmt: Use libdasd provided ioctl functions") at which the use of a
globally available file descriptor was omitted. Instead, the ioctl
library functions require a device node to be passed as a function
parameter and will open a file descriptor themselves.
So, before that change, the global file descriptor was always valid even
when the file was removed.

In order to fix this without modifying the behaviour of libdasd,
introduce the two global variables dev_node and dev_path. dev_path is
the original device path entered by the user. dev_node on the other hand
is the reliable device node under /dev/block/ using the major and minor
numbers and is determined in get_device_name().
The dev_path is used for message output only and the dev_node variable
is used for the actual disk operations.

As these two variables are global, the device parameters for several
functions are removed to make the code a bit cleaner.

Fixes: 8826028bdc ("dasdfmt: Use libdasd provided ioctl functions")
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Jan Höppner
09be935c54 dasdfmt: Make program relevant information global
The global program options (and other actually globally used
information) are currently passed through via function parameter
whenever this information is needed. However, in reality, this
information is used almost everywhere across the program.

Make this information globally available and get rid of all the
unnecessary function parameters for dasdfmt_info_t. This makes the code
a little bit cleaner and more readable. Also, rename the global struct
to a more suitable name.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Jan Höppner
65e18bff67 dasdfmt: Remove function dasdfmt_format
dasdfmt_format() does nothing but calling process_tracks() with the same
parameters. Get rid of it, call process_tracks() directly, and avoid
confusion.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Jan Höppner
07ab32fa8b dasdfmt: Fix whitespace
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Jan Höppner
353403824b libdasd: Fix dasd_get_host_access_count()
Since commit 75e3afb6a0 ("libdasd: Move get_host_access_count() to
libdasd") dasd_get_host_access_count() reports always 0 as the check for
unsuccessful execution of util_sys_get_dev_addr() is incorrect.
Fix the behaviour by turning the check around.

Fixes: 75e3afb6a0 ("libdasd: Move get_host_access_count() to libdasd")
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Ingo Franzki
8a58389e2f zkey: Add library versioning for libekmfweb and zkey-ekmfweb
Closes: https://github.com/ibm-s390-tools/s390-tools/issues/93

Signed-off-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>
2020-10-28 13:22:45 +01:00
Alexander Egorenkov
f2cc871b02 genprotimg/boot: disable SSP
SSP cannot work with boot loaders because it requires libc.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Alexander Egorenkov
4dbdc8dfab zipl/boot: disable SSP
SSP cannot work with boot loaders because it requires libc.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Ingo Franzki
60900de5e9 zkey: Skip build of zkey-ekmfweb.so if libekmfweb dependencies are missing
zkey-ekmfweb.so requires libekmfweb.so. If libekmfweb.so can not be built
due to missing build requirements, then zkey-ekmfweb.so can't be built
either.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Sven Schnelle
2bba362e9a lsstp: Improve wording and fix typos in man page
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:45 +01:00
Ingo Franzki
76044be98d zkey: Ensure zkey and friends are skipped with HAVE_OPENSSL=0
Building zkey-ekmfweb.so will also trigger to build libekmfweb.so,
which requires OpenSSL. So, skip zkey-ekmfweb.so if HAVE_OPENSSL=0.

zkey-cryptsetup also has a dependency on OpenSSL, so skip it also
if HAVE_OPENSSL=0

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-28 13:22:29 +01:00
Jan Höppner
885ff0a03f Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-15 15:56:15 +02:00
18 changed files with 650 additions and 627 deletions

3
.gitignore vendored
View File

@@ -37,6 +37,8 @@ iucvterm/test/test_afiucv
libekmfweb/check-dep-libekmfweb
libekmfweb/detect-openssl-version.dep
libekmfweb/libekmfweb.so
libekmfweb/libekmfweb.so.1
libekmfweb/libekmfweb.so.1.0
libutil/util_base_example
libutil/util_file_example
libutil/util_libc_example
@@ -97,6 +99,7 @@ zipl/src/zipl_helper.device-mapper
zkey/check-dep-zkey
zkey/check-dep-zkey-cryptsetup
zkey/detect-libcryptsetup.dep
zkey/ekmfweb/libekmfweb.dep
zkey/ekmfweb/zkey-ekmfweb.so
zkey/zkey
zkey/zkey-cryptsetup

View File

@@ -1,5 +1,23 @@
Release history for s390-tools (MIT version)
--------------------------------------------
* __v2.15.1 (2020-10-28)__
For Linux kernel version: 5.9
Changes of existing tools:
- lsstp: Improve wording and fix typos in man page
- zkey: Ensure zkey and friends are skipped with HAVE_OPENSSL=0
- zkey: Add library versioning for libekmfweb and zkey-ekmfweb
- libutil: Add function to determine base device of a partition block device
Bug Fixes:
- dasdfmt: Fix bad file descriptor error when running on symlinks
- libdasd: Fix dasd_get_host_access_count()
- zipl: Fix multivolume dump
- zgetdump: Fix device node determination via sysfs to work with multivolume again
- genprotimg/boot: Fix build by disabling SSP
- zipl/boot: Fix build by disabling SSP
* __v2.15.0 (2020-10-15)__
For Linux kernel version: 5.9

View File

@@ -6,7 +6,7 @@ COMMON_INCLUDED = true
# "make DISTRELEASE=%{release}" and "make install DISTRELEASE=%{release}"
VERSION = 2
RELEASE = 15
PATCHLEVEL = 0
PATCHLEVEL = 1
DISTRELEASE = build-$(shell date +%Y%m%d)
S390_TOOLS_RELEASE = $(VERSION).$(RELEASE).$(PATCHLEVEL)-$(DISTRELEASE)
export S390_TOOLS_RELEASE
@@ -163,7 +163,7 @@ USRSBINDIR = $(INSTALLDIR)/usr/sbin
USRBINDIR = $(INSTALLDIR)/usr/bin
BINDIR = $(INSTALLDIR)/sbin
LIBDIR = $(INSTALLDIR)/lib
LIB64DIR = $(INSTALLDIR)/lib64
USRLIB64DIR = $(INSTALLDIR)/usr/lib64
SYSCONFDIR = $(INSTALLDIR)/etc
MANDIR = $(INSTALLDIR)/usr/share/man
VARDIR = $(INSTALLDIR)/var
@@ -179,10 +179,10 @@ INSTDIRS = $(USRSBINDIR) $(USRBINDIR) $(BINDIR) $(LIBDIR) $(MANDIR) \
$(SYSCONFDIR) $(SYSCONFDIR)/sysconfig \
$(TOOLS_LIBDIR) $(TOOLS_DATADIR) \
$(ZFCPDUMP_DIR) $(SYSTEMDSYSTEMUNITDIR) \
$(LIB64DIR) $(USRINCLUDEDIR)
$(USRLIB64DIR) $(USRINCLUDEDIR)
OWNER = $(shell id -un)
GROUP = $(shell id -gn)
export INSTALLDIR BINDIR LIBDIR LIB64DIR MANDIR OWNER GROUP
export INSTALLDIR BINDIR LIBDIR USRLIB64DIR MANDIR OWNER GROUP
# Special defines for zfcpdump
ZFCPDUMP_IMAGE = zfcpdump-image

File diff suppressed because it is too large Load Diff

View File

@@ -65,47 +65,24 @@ static const char mode_str[3][10] = {
"is in invalid format\n",prog_name);}
typedef struct bootstrap1 {
u_int32_t key;
u_int32_t data[6];
u_int32_t key;
u_int32_t data[6];
} __attribute__ ((packed)) bootstrap1_t;
typedef struct bootstrap2 {
u_int32_t key;
u_int32_t data[36];
u_int32_t key;
u_int32_t data[36];
} __attribute__ ((packed)) bootstrap2_t;
typedef struct dasdfmt_info {
dasd_information2_t dasd_info;
int verbosity;
int testmode;
int withoutprompt;
int print_progressbar;
int print_hashmarks, hashstep;
int print_percentage;
int force;
int writenolabel;
int labelspec;
int cdl_format;
int blksize_specified;
int reqsize_specified;
int keep_volser;
int force_host;
int layout_specified;
int check;
int mode_specified;
int ese;
int no_discard;
} dasdfmt_info_t;
/*
C9D7D3F1 000A0000 0000000F 03000000 00000001 00000000 00000000
*/
static bootstrap1_t ipl1 = {
0xC9D7D3F1, {
0x000A0000, 0x0000000F, 0x03000000,
0x00000001, 0x00000000, 0x00000000
}
0xC9D7D3F1, {
0x000A0000, 0x0000000F, 0x03000000,
0x00000001, 0x00000000, 0x00000000
}
};
/*
@@ -116,21 +93,20 @@ C9D7D3F2 07003AB8 40000006 31003ABE 40000005 08003AA0 00000000 06000000
00000000 00000000 00000000 00000000 00000000
*/
static bootstrap2_t ipl2 = {
0xC9D7D3F2, {
0x07003AB8, 0x40000006, 0x31003ABE,
0x40000005, 0x08003AA0, 0x00000000,
0x06000000, 0x20000000, 0x00000000,
0x00000000, 0x00000400, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000
}
0xC9D7D3F2, {
0x07003AB8, 0x40000006, 0x31003ABE,
0x40000005, 0x08003AA0, 0x00000000,
0x06000000, 0x20000000, 0x00000000,
0x00000000, 0x00000400, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000
}
};
#endif /* DASDFMT_H */

View File

@@ -12,7 +12,7 @@ ALL_CFLAGS := $(NO_PIE_CFLAGS) -Os -g \
-DENABLE_SCLP_ASCII=1 \
-DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
-fno-builtin -ffreestanding -fno-asynchronous-unwind-tables \
-fno-delete-null-pointer-checks \
-fno-delete-null-pointer-checks -fno-stack-protector \
-fexec-charset=IBM1047 -m64 -mpacked-stack \
-mstack-size=4096 -mstack-guard=128 -msoft-float \
-Wall -Wformat-security -Wextra -Werror

View File

@@ -12,6 +12,11 @@
#ifndef LIB_UTIL_SYS_H
#define LIB_UTIL_SYS_H
#include <stdbool.h>
int util_sys_get_dev_addr(const char *dev, char *addr);
bool util_sys_dev_is_partition(dev_t dev);
int util_sys_get_partnum(dev_t dev);
int util_sys_get_base_dev(dev_t dev, dev_t *base_dev);
#endif /** LIB_UTIL_SYS_H @} */

View File

@@ -214,7 +214,7 @@ int dasd_get_host_access_count(char *device)
char *path;
long value;
if (!util_sys_get_dev_addr(device, busid))
if (util_sys_get_dev_addr(device, busid) != 0)
return 0;
path = util_path_sysfs("bus/ccw/devices/%s/host_access_count", busid);

View File

@@ -1,10 +1,13 @@
include ../common.mak
VERSION = 1.0
VERM = $(shell echo $(VERSION) | cut -d '.' -f 1)
ifneq (${HAVE_OPENSSL},0)
ifneq (${HAVE_JSONC},0)
ifneq (${HAVE_LIBCURL},0)
BUILD_TARGETS += libekmfweb.so
INSTALL_TARGETS += install-libekmfweb.so
BUILD_TARGETS += libekmfweb.so.$(VERSION)
INSTALL_TARGETS += install-libekmfweb.so.$(VERSION)
else
BUILD_TARGETS += skip-libekmfweb-curl
INSTALL_TARGETS += skip-libekmfweb-curl
@@ -64,22 +67,26 @@ ekmfweb.o: check-dep-libekmfweb ekmfweb.c utilities.h cca.h $(rootdir)include/ek
utilities.o: check-dep-libekmfweb utilities.c utilities.h $(rootdir)include/ekmfweb/ekmfweb.h
cca.o: check-dep-libekmfweb cca.c cca.h utilities.h $(rootdir)include/ekmfweb/ekmfweb.h
libekmfweb.so: ALL_CFLAGS += -fPIC
libekmfweb.so: LDLIBS = -ljson-c -lcrypto -lssl -lcurl -ldl -shared
libekmfweb.so: LDFLAGS = -shared -Wl,--version-script=libekmfweb.map \
-Wl,-z,defs,-Bsymbolic
libekmfweb.so: ekmfweb.o utilities.o cca.o
libekmfweb.so.$(VERSION): ALL_CFLAGS += -fPIC
libekmfweb.so.$(VERSION): LDLIBS = -ljson-c -lcrypto -lssl -lcurl -ldl
libekmfweb.so.$(VERSION): ALL_LDFLAGS += -shared -Wl,--version-script=libekmfweb.map \
-Wl,-z,defs,-Bsymbolic -Wl,-soname,libekmfweb.so.$(VERM)
libekmfweb.so.$(VERSION): ekmfweb.o utilities.o cca.o
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@
ln -srf libekmfweb.so.$(VERSION) libekmfweb.so.$(VERM)
ln -srf libekmfweb.so.$(VERSION) libekmfweb.so
install-libekmfweb.so: libekmfweb.so
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 -T libekmfweb.so $(DESTDIR)$(LIB64DIR)/libekmfweb.so
install-libekmfweb.so.$(VERSION): libekmfweb.so.$(VERSION)
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 -T libekmfweb.so.$(VERSION) $(DESTDIR)$(USRLIB64DIR)/libekmfweb.so.$(VERSION)
ln -srf $(DESTDIR)$(USRLIB64DIR)/libekmfweb.so.$(VERSION) $(DESTDIR)$(USRLIB64DIR)/libekmfweb.so.$(VERM)
ln -srf $(DESTDIR)$(USRLIB64DIR)/libekmfweb.so.$(VERSION) $(DESTDIR)$(USRLIB64DIR)/libekmfweb.so
$(INSTALL) -d -m 770 $(DESTDIR)$(USRINCLUDEDIR)/ekmfweb
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 $(rootdir)include/ekmfweb/ekmfweb.h $(DESTDIR)$(USRINCLUDEDIR)/ekmfweb
install: all $(INSTALL_TARGETS)
clean:
rm -f *.o libekmfweb.so check-dep-libekmfweb detect-openssl-version.dep
rm -f *.o libekmfweb.so* check-dep-libekmfweb detect-openssl-version.dep
.PHONY: all install clean skip-libekmfweb-openssl skip-libekmfweb-jsonc \
skip-libekmfweb-curl install-libekmfweb.so
skip-libekmfweb-curl install-libekmfweb.so.$(VERSION)

View File

@@ -11,17 +11,114 @@
#include <err.h>
#include <errno.h>
#include <linux/fs.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <unistd.h>
#include "lib/util_file.h"
#include "lib/util_libc.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
#define PAGE_SIZE 4096
/**
* Return the partition number of a given partition.
*
* @param[in] dev Device node of interest
*
* @retval int Partition number of the device
* @retval -1 Error when trying to read the partition number.
*/
int util_sys_get_partnum(dev_t dev)
{
int partnum = -1;
char *path;
path = util_path_sysfs("dev/block/%u:%u/partition",
major(dev), minor(dev));
if (util_file_read_i(&partnum, 10, path)) {
warnx("Could not read from path '%s'", path);
goto out;
}
if (partnum <= 0) {
warnx("Bad partition number in '%s'", path);
partnum = -1;
goto out;
}
out:
free(path);
return partnum;
}
/**
* Determine if the given device is a partition.
*
* @param[in] dev Device node of interest
*
* @retval true Device is partition
* @retval false Device is not a partition
*/
bool util_sys_dev_is_partition(dev_t dev)
{
bool is_part;
char *path;
path = util_path_sysfs("dev/block/%u:%u/partition",
major(dev), minor(dev));
is_part = util_path_exists(path);
free(path);
return is_part;
}
/**
* Determine base device
*
* This function determines the base device \p base_dev of a given
* device \p dev. If \p dev is a base device, \p base_dev becomes \p dev.
*
* @param[in] dev Device node of interest
* @param[out] base_dev Identified base device
*
* @retval 0 Success
* @retval -1 Error while reading device information or
* constructed path
*/
int util_sys_get_base_dev(dev_t dev, dev_t *base_dev)
{
int base_major, base_minor;
char buf[PAGE_SIZE];
char *path;
/* check if the device already is a base device */
if (!util_sys_dev_is_partition(dev)) {
*base_dev = makedev(major(dev), minor(dev));
return 0;
}
path = util_path_sysfs("dev/block/%d:%d/../dev",
major(dev), minor(dev));
if (util_file_read_line(buf, sizeof(buf), path)) {
warnx("Could not read from path '%s'", path);
free(path);
return -1;
}
free(path);
if (sscanf(buf, "%i:%i", &base_major, &base_minor) != 2) {
warn("Could not parse major:minor from string '%s'", buf);
return -1;
}
*base_dev = makedev(base_major, base_minor);
return 0;
}
/**
* Identify device address
@@ -44,13 +141,17 @@ int util_sys_get_dev_addr(const char *dev, char *addr)
unsigned int maj, min;
struct stat s;
ssize_t len;
dev_t base;
char *path;
if (stat(dev, &s) != 0)
return -1;
maj = major(s.st_rdev);
min = minor(s.st_rdev);
if (util_sys_get_base_dev(s.st_rdev, &base))
return -1;
maj = major(base);
min = minor(base);
if (S_ISBLK(s.st_mode))
path = util_path_sysfs("dev/block/%u:%u/device", maj, min);

View File

@@ -5,21 +5,21 @@
.TH LSSTP 8 "Jul 2020" "s390-tools" "Linux Administrator's Manual"
.SH NAME
.B "lsstp "
\- tool to show STP system information
\- Show STP configuration information
.SH SYNOPSIS
.BI "lsstp "
.SH DESCRIPTION
.B lsstp
displays information about the currenta Server Time Protocol (STP) configuration
like Coordianted Timing Network (CTN) ID, Timing state and Leap seconds.
displays information about the current Server Time Protocol (STP) configuration
like coordinated time network (CTN) ID, timing state and leap seconds.
.SH OUTPUT
.TP
.B STP online
Whether the STP subsystem is online
Indication of the online state
.TP
.B CTN ID
The ID of the Coordinated Time Network. If it can be decoded as EBCDIC it will be shown as EBCDIC String, otherwise a hexadecimal representation is shown.
The ID of the coordinated time network. If it can be decoded as EBCDIC it is shown as an EBCDIC string, otherwise a hexadecimal representation is shown.
.TP
.B CTN Type
The type of timing network.
@@ -31,15 +31,15 @@ STP is not configured for attachment to a CTN.
STP is configured and attached to a CTN with only STP nodes.
.IP
.B Mixed
STP is configured and attached to a CTN which contains both STP and External Time Reference (ETR) nodes.
STP is configured and attached to a CTN with both STP and external time reference (ETR) nodes.
.TP
.B Stratum
The Stratum level of the STP clock. This indicates the number of servers in the timing path between the local STP clock and the selected primary time server.
The number of servers in the timing path between the local STP clock and the selected primary time server.
.TP
.B Timing mode
.IP
.B Local
The Time-of-day (TOD) clock is stepped to the local hardware oscillator and is not steered by the STP facility.
The Time-of-day (TOD) clock is stepped by the local hardware oscillator and is not steered by the STP facility.
.IP
.B ETR
The TOD clock is synchronized with an attached 9037 Sysplex Timer.
@@ -51,10 +51,10 @@ The TOD clock is steered by the STP facility to maintain synchronization with a
The TOD clock is not initialized. The STP facility is allowed to perform a step adjustment to the TOD clock for synchronization.
.TP
.B Timing state
The synchronization state of the STP facilty. Can be unsynchronzied, synchronized and stopped.
The synchronization state of the STP facility. Can be unsynchronized, synchronized or stopped.
.TP
.B DST offset
The Daylight savings time offset relative to UTC in minutes.
The daylight savings time offset relative to UTC in minutes.
.TP
.B Timezone offset
The offset of the local time relative to UTC in minutes.
@@ -62,11 +62,11 @@ The offset of the local time relative to UTC in minutes.
.B Time offset
The total time offset at the server. This field is only valid in mixed CTN configurations.
.TP
.B Active Leap seconds
The number of Leap seconds that are currently in effect at the STP facility.
.B Active leap seconds
The number of leap seconds that are currently in effect at the STP facility.
.TP
.B Leap second <insertion|delation> at
If a Leap second insertion or deletetion is scheduled in the STP facility, this field will show the Day and Time of the scheduled change.
.B Leap second <insertion|deletion> at
If a leap second insertion or deletion is scheduled in the STP facility, this field shows the day and time of the scheduled change.
.SH OPTIONS
.TP
.BI "-v|--version"

View File

@@ -21,6 +21,7 @@
#include <time.h>
#include <unistd.h>
#include "lib/util_file.h"
#include "lib/util_path.h"
#include "zgetdump.h"
@@ -98,6 +99,24 @@ static void em_init(struct vol *vol)
l.dump_incomplete = 1;
}
/*
* Check whether a device with a given busid is online
*/
static unsigned int dev_is_online(const char *busid)
{
unsigned int online;
char *path;
path = util_path_sysfs("%s/%s/online", SYSFS_BUSDIR, busid);
if (util_file_read_ui(&online, 10, path) != 0) {
warnx("Could not open \"%s\" (%s)", path, strerror(errno));
free(path);
exit(EXIT_FAILURE);
}
free(path);
return online;
}
/*
* Check sysfs, whether a device specified by its bus ID is defined and online.
@@ -106,67 +125,40 @@ static void em_init(struct vol *vol)
static enum dev_status dev_from_busid(char *bus_id, dev_t *dev)
{
struct dirent *direntp;
int fh, minor, major;
int minor, major;
char buf[10];
DIR *fh_dir;
char *sysfs;
sysfs = util_path_sysfs("%s/%s", SYSFS_BUSDIR, bus_id);
fh_dir = opendir(sysfs);
free(sysfs);
if (!fh_dir)
if (!util_path_is_dir(sysfs)) {
free(sysfs);
return DEV_UNDEFINED;
sysfs = util_path_sysfs("%s/%s/online", SYSFS_BUSDIR, bus_id);
fh = open(sysfs, O_RDONLY);
if (fh == -1) {
warnx("Could not open \"%s\" (%s)", sysfs, strerror(errno));
goto err;
}
free(sysfs);
if (read(fh, buf, 1) == -1)
ERR_EXIT_ERRNO("Could not read online attribute");
close(fh);
if (buf[0] != '1')
if (!dev_is_online(bus_id))
return DEV_OFFLINE;
while ((direntp = readdir(fh_dir)))
if (strncmp(direntp->d_name, "block:", 6) == 0)
break;
closedir(fh_dir);
if (direntp == NULL) {
sysfs = util_path_sysfs("%s/%s/block", SYSFS_BUSDIR, bus_id);
fh_dir = opendir(sysfs);
if (!fh_dir) {
warnx("Could not open \"%s\" (%s) ",
sysfs, strerror(errno));
goto err;
}
while ((direntp = readdir(fh_dir)))
if (strncmp(direntp->d_name, "dasd", 4) == 0)
break;
closedir(fh_dir);
if (direntp == NULL) {
warnx("Problem with contents of \"%s\"", sysfs);
goto err;
}
free(sysfs);
}
sysfs = util_path_sysfs("%s/%s/%s/dev",
SYSFS_BUSDIR, bus_id, direntp->d_name);
fh = open(sysfs, O_RDONLY);
if (fh == -1) {
warnx("Could not open \"%s\" (%s)", sysfs, strerror(errno));
sysfs = util_path_sysfs("%s/%s/block", SYSFS_BUSDIR, bus_id);
fh_dir = opendir(sysfs);
if (!fh_dir) {
warnx("Could not open \"%s\" (%s) ", sysfs, strerror(errno));
goto err;
}
if (read(fh, buf, sizeof(buf)) == -1) {
while ((direntp = readdir(fh_dir)))
if (strncmp(direntp->d_name, "dasd", 4) == 0)
break;
if (direntp == NULL) {
warnx("Problem with contents of \"%s\"", sysfs);
goto err;
}
if (util_file_read_line(buf, sizeof(buf), "%s/%s/dev", sysfs, direntp->d_name)) {
warnx("Could not read dev file (%s)", strerror(errno));
goto err;
}
close(fh);
closedir(fh_dir);
if (sscanf(buf, "%i:%i", &major, &minor) != 2) {
warnx("Malformed content of \"%s\": %s", sysfs, buf);
goto err;
@@ -178,6 +170,8 @@ static enum dev_status dev_from_busid(char *bus_id, dev_t *dev)
return DEV_ONLINE;
err:
if (fh_dir)
closedir(fh_dir);
free(sysfs);
exit(EXIT_FAILURE);
}

View File

@@ -31,7 +31,7 @@ configuration.
* Issue "make bzImage" to build the zfcpdump kernel image.
In a Linux distribution the zfcpdump enabled kernel image must be copied to
/lib/s390-tools/zfcpdump/zfcpdump_part.image, where the s390 zipl tool is
/lib/s390-tools/zfcpdump/zfcpdump-image, where the s390 zipl tool is
looking for the dump kernel when preparing a SCSI dump disk.
Create and install initrd

View File

@@ -7,7 +7,7 @@ INCLUDE_PARMS := $(addprefix -I,$(INCLUDE_PATHS))
ALL_CFLAGS = $(NO_PIE_CFLAGS) -Os -g $(INCLUDE_PARMS) \
-DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
-fno-builtin -ffreestanding -fno-asynchronous-unwind-tables \
-fno-delete-null-pointer-checks \
-fno-delete-null-pointer-checks -fno-stack-protector \
-fexec-charset=IBM1047 -m64 -mpacked-stack \
-mstack-size=4096 -mstack-guard=128 -msoft-float \
-W -Wall -Wformat-security

View File

@@ -25,6 +25,7 @@
#include <linux/fiemap.h>
#include "lib/util_proc.h"
#include "lib/util_sys.h"
#include "disk.h"
#include "error.h"
@@ -89,88 +90,6 @@ disk_determine_dasd_type(struct disk_info *data,
return 0;
}
static int blkext_get_partnum(dev_t dev)
{
char path[PATH_MAX], *buf;
int dev_major, dev_minor, partnum = -1;
dev_major = major(dev);
dev_minor = minor(dev);
snprintf(path, PATH_MAX, "/sys/dev/block/%d:%d/partition",
dev_major, dev_minor);
if (misc_read_special_file(path, &buf, NULL, 1)) {
error_text("Could not read from path '%s'", path);
return -1;
}
partnum = atoi(buf);
free(buf);
if (partnum < 0) {
error_text("Bad partition number in '%s'", path);
return -1;
}
return partnum;
}
static int blkext_is_base_device(dev_t dev)
{
int dev_major, dev_minor;
char path[PATH_MAX];
struct stat stats;
dev_major = major(dev);
dev_minor = minor(dev);
snprintf(path, PATH_MAX, "/sys/dev/block/%d:%d/partition",
dev_major, dev_minor);
return (stat(path, &stats));
}
static int blkext_get_base_dev(dev_t dev, dev_t *base_dev)
{
int base_major, base_minor;
char dev_path[PATH_MAX], base_path[PATH_MAX];
char *temp_path, *buf;
misc_asprintf(&temp_path, "/sys/dev/block/%d:%d", major(dev), minor(dev));
if (!realpath(temp_path, dev_path)) {
error_reason(strerror(errno));
error_text("Could not resolve link %s", temp_path);
free(temp_path);
return -1;
}
free(temp_path);
misc_asprintf(&temp_path, "%s/..", dev_path);
if (!realpath(temp_path, base_path)) {
error_reason(strerror(errno));
error_text("Could not resolve path %s", temp_path);
free(temp_path);
return -1;
}
free(temp_path);
misc_asprintf(&temp_path, "%s/dev", base_path);
if (misc_read_special_file(temp_path, &buf, NULL, 1)) {
error_text("Could not read from path '%s'", temp_path);
free(temp_path);
return -1;
}
free(temp_path);
if (sscanf(buf, "%i:%i", &base_major, &base_minor) != 2) {
error_text("Could not parse major:minor from string '%s'", buf);
free(buf);
return -1;
}
free(buf);
*base_dev = makedev(base_major, base_minor);
return 0;
}
/* Return non-zero for ECKD type. */
int
disk_is_eckd(disk_type_t type)
@@ -492,15 +411,15 @@ disk_get_info(const char* device, struct job_target_data* target,
data->devno = -1;
data->type = disk_type_scsi;
if (blkext_is_base_device(stats.st_rdev)) {
data->device = stats.st_rdev;
data->partnum = 0;
} else {
if (blkext_get_base_dev(stats.st_rdev, &data->device))
if (util_sys_dev_is_partition(stats.st_rdev)) {
if (util_sys_get_base_dev(stats.st_rdev, &data->device))
goto out_close;
data->partnum = blkext_get_partnum(stats.st_rdev);
data->partnum = util_sys_get_partnum(stats.st_rdev);
if (data->partnum == -1)
goto out_close;
} else {
data->device = stats.st_rdev;
data->partnum = 0;
}
} else {
/* Driver name is unknown */

View File

@@ -1,10 +1,13 @@
include ../common.mak
SUB_DIRS = ekmfweb
ifneq (${HAVE_OPENSSL},0)
BUILD_TARGETS += zkey
INSTALL_TARGETS += install-zkey
ifneq (${HAVE_JSONC},0)
ifneq (${HAVE_LIBCURL},0)
SUB_DIRS += ekmfweb
endif
endif
else
BUILD_TARGETS += zkey-skip
INSTALL_TARGETS += zkey-skip
@@ -12,9 +15,14 @@ endif
ifneq (${HAVE_CRYPTSETUP2},0)
ifneq (${HAVE_JSONC},0)
BUILD_TARGETS += zkey-cryptsetup
INSTALL_TARGETS += install-zkey-cryptsetup
CPPFLAGS += -DHAVE_LUKS2_SUPPORT
ifneq (${HAVE_OPENSSL},0)
BUILD_TARGETS += zkey-cryptsetup
INSTALL_TARGETS += install-zkey-cryptsetup
CPPFLAGS += -DHAVE_LUKS2_SUPPORT
else
BUILD_TARGETS += zkey-cryptsetup-skip-openssl
INSTALL_TARGETS += zkey-cryptsetup-skip-openssl
endif
else
BUILD_TARGETS += zkey-cryptsetup-skip-jsonc
INSTALL_TARGETS += zkey-cryptsetup-skip-jsonc
@@ -64,6 +72,9 @@ zkey-cryptsetup-skip-cryptsetup2:
zkey-cryptsetup-skip-jsonc:
echo " SKIP zkey-cryptsetup due to HAVE_JSONC=0"
zkey-cryptsetup-skip-openssl:
echo " SKIP zkey-cryptsetup due to HAVE_OPENSSL=0"
all: $(BUILD_TARGETS) $(SUB_DIRS)
zkey.o: zkey.c pkey.h cca.h ep11.h misc.h

View File

@@ -1,5 +1,8 @@
include ../../common.mak
VERSION = 1.0
VERM = $(shell echo $(VERSION) | cut -d '.' -f 1)
all: zkey-ekmfweb.so
libs = $(rootdir)/libutil/libutil.a
@@ -8,7 +11,7 @@ export LIBRARY_PATH = $(rootdir)/libekmfweb:$LIBRARY_PATH
zkey-ekmfweb.o: zkey-ekmfweb.c zkey-ekmfweb.h ../kms-plugin.h \
../cca.h ../utils.h ../pkey.h ../properties.h \
$(rootdir)include/ekmfweb/ekmfweb.h $(rootdir)/libekmfweb/libekmfweb.so
$(rootdir)include/ekmfweb/ekmfweb.h libekmfweb.dep
properties.o: ../properties.c ../properties.h
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -fPIC -c $< -o $@
@@ -26,9 +29,9 @@ utils.o: ../utils.c ../utils.h ../pkey.h ../cca.h ../ep11.h
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -fPIC -c $< -o $@
zkey-ekmfweb.so: ALL_CFLAGS += -fPIC
zkey-ekmfweb.so: LDLIBS = -lekmfweb -ldl -lcrypto -shared
zkey-ekmfweb.so: LDFLAGS = -shared -Wl,--version-script=zkey-ekmfweb.map \
-Wl,-z,defs,-Bsymbolic
zkey-ekmfweb.so: LDLIBS = -lekmfweb -ldl -lcrypto
zkey-ekmfweb.so: ALL_LDFLAGS += -shared -Wl,--version-script=zkey-ekmfweb.map \
-Wl,-z,defs,-Bsymbolic -Wl,-soname,zkey-ekmfweb.so.$(VERM)
zkey-ekmfweb.so: zkey-ekmfweb.o properties.o pkey.o cca.o ep11.o utils.o $(libs)
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@
@@ -36,13 +39,18 @@ install-libekmfweb.dep:
$(MAKE) -C $(rootdir)/libekmfweb/ TOPDIR=$(TOPDIR) ARCH=$(ARCH) install
touch install-libekmfweb.dep
libekmfweb.dep:
$(MAKE) -C $(rootdir)/libekmfweb/ TOPDIR=$(TOPDIR) ARCH=$(ARCH) all
touch libekmfweb.dep
install: all install-libekmfweb.dep zkey-ekmfweb.so
$(INSTALL) -d -m 755 $(DESTDIR)$(MANDIR)/man1
$(INSTALL) -m 644 -c zkey-ekmfweb.1 $(DESTDIR)$(MANDIR)/man1
$(INSTALL) -d -m 755 $(DESTDIR)$(LIB64DIR)
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 -T zkey-ekmfweb.so $(DESTDIR)$(LIB64DIR)/zkey-ekmfweb.so
$(INSTALL) -d -m 755 $(DESTDIR)$(USRLIB64DIR)
$(INSTALL) -d -m 755 $(DESTDIR)$(USRLIB64DIR)/zkey
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 -T zkey-ekmfweb.so $(DESTDIR)$(USRLIB64DIR)/zkey/zkey-ekmfweb.so
clean:
rm -f *.o zkey-ekmfweb.so install-libekmfweb.dep
rm -f *.o zkey-ekmfweb.so install-libekmfweb.dep libekmfweb.dep
.PHONY: all install clean

View File

@@ -40,6 +40,7 @@
#define ENVVAR_ZKEY_KMS_PLUGINS "ZKEY_KMS_PLUGINS"
#define DEFAULT_KMS_PLUGINS "/etc/zkey/kms-plugins.conf"
#define KMS_PLUGIN_LOCATION "/usr/lib64/zkey"
#define KMS_CONFIG_FILE "kms.conf"
#define KMS_CONFIG_PROP_KMS "kms"
@@ -209,6 +210,7 @@ static int load_kms_plugin(const char *plugin,
void **plugin_lib, char **plugin_name, bool verbose)
{
kms_get_functions_t _kms_get_functions;
char load_so_name[PATH_MAX];
char *so_name = NULL;
FILE *fp = NULL;
char line[4096];
@@ -258,15 +260,26 @@ static int load_kms_plugin(const char *plugin,
goto out;
}
/* Try to load via LD_LIBRARY_PATH first */
snprintf(load_so_name, sizeof(load_so_name), "%s", so_name);
pr_verbose(verbose, "Loading KMS plugin '%s': '%s'", *plugin_name,
so_name);
*plugin_lib = dlopen(so_name, RTLD_GLOBAL | RTLD_NOW);
load_so_name);
*plugin_lib = dlopen(load_so_name, RTLD_GLOBAL | RTLD_NOW);
if (*plugin_lib == NULL) {
pr_verbose(verbose, "%s", dlerror());
warnx("Failed to load KMS plugin '%s': '%s'", *plugin_name,
so_name);
rc = -ELIBACC;
goto out;
/* Try to load from default plugin location */
snprintf(load_so_name, sizeof(load_so_name), "%s/%s",
KMS_PLUGIN_LOCATION, so_name);
pr_verbose(verbose, "Loading KMS plugin '%s': '%s'",
*plugin_name, load_so_name);
*plugin_lib = dlopen(load_so_name, RTLD_GLOBAL | RTLD_NOW);
if (*plugin_lib == NULL) {
pr_verbose(verbose, "%s", dlerror());
warnx("Failed to load KMS plugin '%s': '%s'",
*plugin_name, load_so_name);
rc = -ELIBACC;
goto out;
}
}
_kms_get_functions = (kms_get_functions_t)dlsym(*plugin_lib,
@@ -274,7 +287,7 @@ static int load_kms_plugin(const char *plugin,
if (_kms_get_functions == NULL) {
pr_verbose(verbose, "%s", dlerror());
warnx("Failed to load KMS plugin '%s': '%s'", *plugin_name,
so_name);
load_so_name);
rc = -ELIBACC;
goto out;
}
@@ -283,13 +296,13 @@ static int load_kms_plugin(const char *plugin,
if (*kms_functions == NULL) {
pr_verbose(verbose, "kms_get_functions() reutned NULL");
warnx("Failed to load KMS plugin '%s': '%s'", *plugin_name,
so_name);
load_so_name);
rc = -ELIBACC;
goto out;
}
pr_verbose(verbose, "Successfully loaded KMS plugin '%s': '%s' (API "
"version: %u)", *plugin_name, so_name,
"version: %u)", *plugin_name, load_so_name,
(*kms_functions)->api_version);
out: