Add helper macros to easily create, enlarge and append new elements to
dynamic arrays of arbitrary types.
Note: The use of dynamic arrays over lists may be preferable in some
cases to reduce complexity, and they may be required in cases where
elements need to be addressed directly by index.
Usage example:
struct {
int a;
int b;
} *array = NULL, element = { 1, 2 };
unsigned int num = 0;
util_add_array(&array, &num, element);
printf("array[0].a=%d\n", array[0].a); /* array[0].a=1 */
printf("array[0].b=%d\n", array[0].b); /* array[0].b=2 */
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
The current implementation of util_hexdump_grp() enforces a minimum
indentation of 1 space which may not be suitable for all users.
Fix this by allowing a true zero indentation level.
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
The separator line emitted by util_rec functions may not be suitable for
all users. Fix this by making the hdr_sep parameter optional.
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
By default, files opened via fopen are block-buffered. As a result,
I/O errors that occur during file write operations via util_file_write_*
are silently ignored because fputs() only buffers data while actual I/O
occurs during the flush operation that is part of the final fclose()
library call.
Fix this by indicating errors that occur during fclose() via the
util_file_write_* function return code.
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Steps to reproduce: Prepare some target disk for IPL, specifying
its parameters via zipl "target options", and an image IMAGE_NAME
located on another disk. Don't specify "-a" option.
Actual result: Installation succeeded (resulting in unbootable setup)
Expected result: "Error: Could not add image file 'IMAGE_NAME': File
is not on target device"
The problem is in incorrect evaluation of device number(dev_t) where
the image is located by the function add_component_file_range() in
case when target parameters are specified by user.
Fixup: Retrieve info of the underlying disk without any user hints,
passing zeroed structure job_target_data
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This patch fixes a bug in disk_get_info()
Steps to reproduce: Prepare a SCSI disk for IPL, specifying an image
("-i IMAGE_NAME") located on DASD and a target directory ("-t /mnt")
located on SCSI (dm). Don't specify "-a" option.
Actual result: Installation succeeded (resulting in unbootable setup!)
Expected result: "Error: Could not add image file 'IMAGE_NAME':
File is not on target device".
The problem is in incorrect evaluation of device number (dev_t) of
the device, where the image file is located, by the function
add_component_file_range(). To evaluate it, disk_get_info() is called
with the structure job_target_data (passed as the second argument)
previously completed by disk_get_info() called earlier to evaluate
parameters of the specified target device (SCSI dm) by the function
prepare_build_program_table_file(). Since the targetbase is already
set in the passed job_target_data (by the first call), in the second
call the source type is evaluated as "source_user", so the number of
the device where the image is located is calculated by the base SCSI
disk, which is incorrect.
Fixup: Rework disk_get_info(): introduce a dedicated function to
evaluate source type not depending on the job_target_data content.
Implement the core procedure as a switch by the evaluated source
type.
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Use "bootmap_dir" field of struct job_target_data instead,
thus avoid allocation/releasing additional resources.
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This patch fixes a bug in disk_get_info()
Steps to reproduce: Prepare a DASD disk for IPL, specifying an
image ("-i IMAGE_NAME") located on SCSI (dm) and a target directory
("-t /mnt") located on DASD. Don't specify "-a" option.
Actual result: "Run /lib/s390-tools//zipl_helper.device-mapper /mnt
Error: Could not retrieve device-mapper information for device
'dasda1'"
Expected result: "Run /lib/s390-tools//zipl_helper.device-mapper 253:4
Error: Could not add image file 'IMAGE_NAME': File is not on target
device"
The problem is in incorrect calculation by disk_get_info()
parameters for @device associated with the image file. Specifically,
@target->bootmap_dir is passed to the script, which is wrong.
Fixup: Get rid of bogus branching in disk_get_info() in case when
target parameters are evaluated in "source_script" mode. Always pass
major and minor of the @device (whose parameters to be calculated)
to the helper script.
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Hyphens are converted by groff to a different unicode character leading
to failing command execution of copy-pasted options or examples.
Ensure that all hyphens are properly escaped.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Hyphens are converted by groff to a different unicode character leading
to failing command execution of copy-pasted options or examples.
Ensure that all hyphens are properly escaped.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Hyphens are converted by groff to a different unicode character leading
to failing command execution of copy-pasted options or examples.
Ensure that all hyphens are properly escaped.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
The man page title was incorrectly set to "LSDASD". Set the correct name
"DASDSTAT".
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Hyphens are converted by groff to a different unicode character leading
to failing command execution of copy-pasted options or examples.
Ensure that all hyphens are properly escaped.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Hyphens are converted by groff to a different unicode character leading
to failing command execution of copy-pasted options or examples.
Ensure that all hyphens are properly escaped.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Hyphens are converted by groff to a different unicode character leading
to failing command execution of copy-pasted options or examples.
Ensure that all hyphens are properly escaped.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Hyphens are converted by groff to a different unicode character leading
to failing command execution of copy-pasted options or examples.
Ensure that all hyphens are properly escaped. Fix whitespace damage
along the way.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Hyphens are converted by groff to a different unicode character leading
to failing command execution of copy-pasted options or examples.
Ensure that all hyphens are properly escaped.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Hyphens are converted by groff to a different unicode character leading
to failing command execution of copy-pasted options or examples.
Ensure that all hyphens are properly escaped.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Under QEMU user can attach disk with smth like:
```
-device virtio-scsi-ccw,... -device scsi-hd,...
```
So virtio block device appears as '/dev/sda' instead of '/dev/vda'.
chreipl assumes all '/dev/sd*' disks as FCP disks, which is not a
case in such setup.
Closes: https://github.com/ibm-s390-linux/s390-tools/pull/154
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
Acked-by: Marc Hartmayer mhartmay@linux.ibm.com
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Add helper function to get device's real path under SYSFS_ROOT devices
hierarchy.
Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/154
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
[hoeppner@linux.ibm.com: Adapt commit message]
Acked-by: Marc Hartmayer mhartmay@linux.ibm.com
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
If many invocations of mdevctl occur simultaneously (as can happen with
libvirt) then waiting for 5-60 seconds per lock retry is simply too long.
Anticipating this possibility, retry more frequently but also attempt
significantly more retries than before.
Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Tested-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
The default values for repeated attempts at acquiring a file lock created
by util_lockfile are on the order of seconds. Let's leave this the
default, but allow for a caller to specify smaller values by adding
cw (custom_wait) functions and by switching from using sleep to usleep.
Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Ensure that all hyphens in command options and examples are escaped properly.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Ensure that all hyphens in command options and examples are escaped properly.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
When formatting an ESE (thin-provisioned) ECKD DASD, dasdfmt(8)
defaults to the quick-format mode instead of full-format for normal
DASDs. This results in a significant performance impact during first
sequential write to each track, which may be unexpected for users.
To address this, change the default for dasdfmt to always use
full-format mode. Customers that require thin provisioning(*) still
override the default by specifying quick format explicitly using the
"-M" option.
Get rid of the related fallbacks; In case of unsuccessful space
release always fail. The customers that still require quick format can
proceed by specifying "--no-discard" option.
(*) Thin provisioning: while providing a large amount of logical
space, zero amount of actual space is provisioned and then
allocated on an on-demand basis.
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>
Check for vmcore LOAD segment with zero paddr (instead of zero vaddr) to
identify HSA since physical and virtual addresses can be uncoupled on s390.
Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Acked-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
The 'lschp' command's output contains a 'type' identifier column. For
information about each value of this identifier, provide the
reference to the z/OS public documentation in the manpage.
Suggested-by: Mike Storzer <MSTORZER@de.ibm.com>
Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Get rid of all arch barriers in main.rs. cmd.rs handles the arch
barriers for the individual commands. Simplifies main.rs & cmd.rs and
makes it easier to read and understand the code.
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Fix findings from `cargo clippy --all-targets`. `warning: calls to
`push` immediately after creation` The findings were in test code only.
Also, replace a while loop with a function from Vec.
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
They add no value and code outside the crate does not need those constants.
Reduces unnecessary constant duplication. Introduce an error for to
large Add-Secret requests and check for this to render those contsnts
fully unnecessary for the API.
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
The BinGuestSecret type provides no benefits. The public GuestSecret
struct can handle everything. Therefore, move the two functions from bin
to the non-bin variant. While at it, use a struct to define the binary
structure instead of copy numbers to some positions in a Vec. This
simplifies the addition of further secret types.
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This streamlines and unifies the use and (de)serialization of structs
using a secret id. As a bonus, the hidden `for_pv` module is not longer
needed.
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Provides a default for the cmd function for an UvCmd. This is enabled by
requiring an associated constant for the IOCTL nr of the command.
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
The content of `pv/src/uvsecret/uvc.rs` was moved with
9b51b8b882 ("rust/pv: Refactor pv crate") to pv_core.
The content was unused, but the file was not deleted.
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Fix clippy waring `warning: very complex type used.` by introducing a
new struct containing the tuple, that was returned before.
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
During the remove of mockito, lazy_static dependency was accidentally
removed as well.
Fix this by adding lazy-static as dev dependency again.
Fixes: aba8900074 ("rust/pv_core: Remove mockito dependency")
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This adds the counter numbers to the corresponding counter names to the
cpacfstats output. This aims to ease using this tool with other related
tools which may use other names for the counters.
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
All files created by chzdev feature a common header; however, this
header is absent in temporary files. It is necessary to incorporate
the consistent "Generated by chzdev" header into temporary files
generated by chzdev as well, so as to properly identify these files
via option --is-owner.
Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>