The kernel already provides the same macro as does the zt_common.h file,
thus check for its availability first.
CC zconf/qeth/lsqeth.o
In file included from ../../include/lib/util_base.h:17,
from lsqeth.c:30:
../../include/lib/zt_common.h:27: warning: "_AC" redefined
27 | #define _AC(X, TYPE) X##TYPE
|
In file included from /usr/include/linux/ethtool.h:17,
from lsqeth.c:12:
/usr/include/linux/const.h:21: note: this is the location of the previous definition
21 | #define _AC(X,Y) __AC(X,Y)
|
GitHub-ID: https://github.com/ibm-s390-linux/s390-tools/pull/137
Signed-off-by: Dan Horák <dan@danny.cz>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Add a check to detect Processor Activity Instrumentation (PAI)
Extension 1 facility unit.
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
zdev uses a particular set of exit codes -- In preparation for sharing
some zdev udev code with other libraries, let's also create a libutil
include to specify reusable exit codes. For now, let's just initialize
it with the codes from zdev we care about.
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Add a check to detect Processor Activity Instrumentation (PAI)
Extension 1 facility unit. This covers the counter set for
Neural Network Processing Assist (NNPA) counters.
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Fix the doxygen comments and add a description on the return values.
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Add a function to detect the existence of the CPU Measurement Sampling
Facility on a system.
Add a function which extracts the CPU Measurement Sampling Facility
characteristics on a system, such as
- minimum sample speed
- maximum sample speed
- current CPU speed
- basic sample size in bytes
- diagnostic sample size in bytes
Add a function to detect the existence of the CPU Measurement Sampling
Facility on a system and return the current sampling buffer management
characteristics, such as:
- minimum supported sampling buffer size
- maximum supported sampling buffer size
Add a function to detect the existence of the CPU Measurement Counting
Facility on a system.
Add a function which extracts the CPU Measurement Counting Facility
characteristics on a system, such as
- counter first version number
- counter second version number
- counter set authorization level
Add a function the returm the PMU type number of a CPU Measurement
Facility device driver. These numbers may vary between boots.
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Add generic functions
util_sysdir();
util_sysdir_path()
and their special cases supplied for users:
util_libdir();
util_libdir_path();
util_datadir();
util_datadir_path()
The function util_sysdir() determines the absolute name of a
s390-tools system directory. It could be data, or library directory.
The function util_sysdir_path() determines the absolute name of a
file installed in the s390-tools system directory.
The function util_libdir() determines the absolute name of a
s390-tools library directory. By default that name is defined
by the compile-time macro TOOLS_LIBDIR (/lib/s390-tools).
Users can specify an override by setting environment variable
S390TOOLS_LIBDIR.
The function util_libdir_path() determines the absolute name of a
file installed in the s390-tools library directory.
The function util_datadir() determines the absolute name of a
s390-tools system data directory. By default the name is defined
by the compile-time macro TOOLS_DATADIR (/usr/share/s390-tools/).
Users can specify an override by setting environment variable
S390TOOLS_DATADIR.
The function util_datadir_path() determines the absolute name of a
file installed in the s390-tools data directory.
The ability to override the setting for TOOLS_LIBDIR and
TOOLS_DATADIR is required for implementing tests on tools that are
not installed in their default system path locations.
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
The util_arch module is supposed to provide general information about
the underlying architecture of the machine in use.
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
The only user of util_proc_mnt_get_entry() so far was util_path_sysfs().
With the simplified version there is no user left. Remove
util_proc_mnt_get_entry() and related code.
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
The goal of util_log is to provide a facility for a multi-level message
logging on stderr. This allows to selectively enable/disable log messages
via a log level which can be adjusted at runtime.
Signed-off-by: Alexander Egorenkov <egorenar@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>
Add codepage conversion capabilities to libzds.
Whenever a dataset is read and an appropriate iconv handle is set for the
dataset the conversion is automatically performed.
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
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>
For data consistency it is essential that datasets are not modified by
z/OS applications during zdsfs access. This is currently ensured by
manually setting the device offline in z/OS before mounting it in Linux.
This patch improves the usability and data security by making this manual
step obsolete.
Before opening a dataset zdsfs will obtain an ENQ to mark it as in use for
z/OS and release the ENQ when closing the dataset.
A timer is set up that pings the z/OSMF REST services with the ENQ to
prevent it from a timeout after 10 minutes.
The behavior of zdsfs can be configured in a new config file or with new
command line options.
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Add library functions that allow to communicate with z/OSMF REST services
using libcurl.
Following three functions are added:
lzds_rest_get_enq()
to obtain an ENQ that will mark a dataset as in use to z/OS until
it is released again
lzds_rest_release_enq()
to release an ENQ and mark a dataset as no longer in use to z/OS
lzds_rest_ping()
to ping a z/OSMF REST server to check if it accessible
or to refresh an ENQ and prevent it from a timeout after 10 minutes
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Consolidate `ALIGN, __ALIGN_MASK, ARRAY_SIZE` macros and add them to
lib/zt_common.h. While at it, adapt coding style.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Support `lib/zt_common.h` to be used in assembler files. In addition,
add the macro `_AC` that can be used to make constant macros usable in
both assembler and C code.
Suggested-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
The util_scandir_* functions may return 0 or -1, in which case no vector
is allocated in libutil/util_scandir.c. util_ptr_vec_free, called by
util_scandir_free or directly from lschp.c and lsscm.c, does always
call free for the vector which might be not initialized.
Fix this by always initializing the vector with NULL in __scandir and
add some api hardening by checking the vector and count in
util_ptr_vec_free before iterating over the vector.
And update the comment for util_scandir to indicate that -1 may be
returned in error cases plus that the vector is initialized with NULL.
Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/43
Reported-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This patch prevents code duplication in vmcp related programs.
Some applications such as vmur, vmcp, and lsqeth
use z/VM CP commands to query information. Each program
uses its own defines and code.
Supply a library and common header file to use common code.
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This patch
- moves function util_strstrip to libutil/util_libc.c and deletes the
extra files util_strstip.[ch]
- adds doxygen comments for util_strstrip()
- provides an example on how to use util_strstrip().
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Function strstrip strips leading and trailung
spaces from a given string.
During review it was decided to move this function
to the libutil library to make it available for other tools.
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>