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>
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>
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>
chreipl could only be used as root (effective userid 0), which is
explicitly checked upon invocation.
"access" call is a wrong method to check super user read/write access
for sysfs files, because it is simply always returns 0 (success), despite
actual sysfs file permissions or underlying sysfs file callbacks setup.
The only guaranteed way of checking sysfs file super user access is an
actual open call with the corresponding access mode.
The problem is that chreipl always tries to update some sysfs attributes
even through they are not specified as command line arguments. Together
with a broken sysfs file access checks this leads to inability to use
the tool, when some sysfs attributes are read-only (which is the case
on older systems where diag308 set does not work).
$ chreipl ccw -d 0.0.ec5a
chreipl: Could not open "reipl/ccw/parm" (Permission denied)
The change fixes access checks, which are in place to handle "diag308
set does not work" case (presence of read-only sysfs attributes).
Also replaces R_OK with F_OK in "set_target_type_auto" to underline that
only file presence is checked, not an actual read access.
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Make write_str_errno return errno in all error cases, so that it would
be usable in scenarious where open call could fail and we just want to
get an errno, not to exit.
This function is currently only used by chshut in a context where
such a change wouldn't hurt debug ability.
159 if (write_str_errno(argv[2], path))
160 ERR_EXIT_ERRNO("Could not set \"%s\"", path);
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
kdump reipl implementation relies on os_info kernel structure
residing in old memory being dumped. os_info contains reipl block, which
is used (if valid) by the kdump kernel for reipl parameters.
The problem is that the reipl block and its checksum inside
os_info is updated only when /sys/firmware/reipl/reipl_type is
written. This sets an offset of a reipl block for "reipl_type" and
re-calculates reipl block checksum. Any further alteration of values
under /sys/firmware/reipl/{reipl_type}/ without subsequent write to
/sys/firmware/reipl/reipl_type lead to incorrect os_info reipl block
checksum. In such a case kdump kernel ignores it and reboots using
default logic.
This change makes sure that all fcp values are written before
reipl_type, to avoid potential problem with incorrect checksum.
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
With gcc 7 we get warnings like the following:
fdasd.c: In function 'main':
fdasd.c:3055:4: warning: this statement may fall through
[-Wimplicit-fallthrough=]
fdasd_exit(&anchor, 0);
^~~~~~~~~~~~~~~~~~~~~~
fdasd.c:3056:3: note: here
default:
^~~~~~~
Fix this by marking functions with "__noreturn" to help gcc.
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
This commit is based on the s390-tools-1.39.0 version.
Changes on top of s390-tools-1.39.0:
- Add MIT license to all source files
- Add LICENSE file
- Transform REAMDE to README.md (markdown)
- Add AUTHORS.md file
- Add CONTRIBUTING.md file
- Move changelog from README to CHANGELOG.md file
Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>