Avoid code duplication and inconsistent error handling by replacing
readlink() with util_readlink(), which is used project-wide to
standardize readlink() usage.
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
When the subchannel type read from sysfs does not match the requested
type, the allocated path is not freed before continuing to the next
loop iteration. This causes a memory leak as reported by valgrind.
Free the path before continuing.
Signed-off-by: Volkan Unal <vunal@linux.ibm.com>
Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
lscss.c: In function 'is_sch_vfio':
lscss.c:392:20: error: implicit declaration of function 'basename' [-Wimplicit-function-declaration]
392 | if (strcmp(basename(driver_path), "vfio_ccw") == 0)
device.c: In function 'device_read_active_attrib':
device.c:426:45: error: implicit declaration of function 'basename'; did you mean 'rename'? [-Wimplicit-function-declaration]
426 | value = misc_strdup(basename(link));
| ^~~~~~~~
| rename
Closes: https://github.com/ibm-s390-linux/s390-tools/pull/192
[hoeppner@linux.ibm.com: Sort includes]
Signed-off-by: L. E. Segovia <amy@amyspark.me>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
lscss shows device number as 'None' if the corresponding device in the
subchannel is non-operational or not connected. Instead, show the
device-no derived from the new dev_busid attribute which provides the
value of device_id irrespective of the device availability.
i.e the current lscss shows
Device Subchan. DevType CU Type Use PIM PAM POM CHPIDs
----------------------------------------------------------------------
0.0.0000 0.0.0000 3390/0c 3990/e9 f0 a0 ff 32333435 00000000
none 0.0.00c7 f0 a0 5f 32333435 00000000
none 0.0.00c8 f0 a0 5f 32333435 00000000
here the subchannels 0.0.00c7 and 0.0.00c8 do not have an operational
device on them. Hence the device is shown as none.
With this patch,
Device Subchan. DevType CU Type Use PIM PAM POM CHPIDs
----------------------------------------------------------------------
0.0.0000 0.0.0000 3390/0c 3990/e9 f0 a0 ff 32333435 00000000
0.0.74c8 0.0.00c7 f0 a0 5f 32333435 00000000
0.0.74c9 0.0.00c8 f0 a0 5f 32333435 00000000
The device-no is shown as 0.0.74c8; Where the DevType field still
indicates that the device is not present.
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>
The linux.vnet.ibm.com addresses will be become disfunct by eoy.
Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
double free or corruption (out)
Program received signal SIGABRT, Aborted.
0x000003fffdd40404 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x000003fffdd40404 in raise () from /lib64/libc.so.6
#1 0x000003fffdd41ec2 in abort () from /lib64/libc.so.6
#2 0x000003fffdd88d8e in __libc_message () from /lib64/libc.so.6
#3 0x000003fffdd905c8 in malloc_printerr () from /lib64/libc.so.6
#4 0x000003fffdd98dfa in free () from /lib64/libc.so.6
#5 0x0000000001005994 in util_ptr_vec_free (count=<optimized out>, ptr_vec=0x101de90) at ../include/lib/util_base.h:46
#6 util_scandir_free (de_vec=0x101de90, count=<optimized out>) at util_scandir.c:174
#7 0x00000000010043ce in print_defunct_devices (rec=rec@entry=0x10114f0,
path=path@entry=0x101cc80 "/sys/devices/css0/defunct") at lscss.c:678
#8 0x0000000001004cfe in print_subchannels_of_type (type_requested=type_requested@entry=SUBCHANNEL_TYPE_IO,
rec=rec@entry=0x10114f0) at lscss.c:726
#9 0x0000000001003888 in cmd_lscss () at lscss.c:761
#10 main (argc=<optimized out>, argv=<optimized out>) at lscss.c:932
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
With gcc 7 we get warnings for code like the following:
44 #define MAX_BUFFER_SIZE_FOR_SUBCHANNEL_ATTRIBUTES 37
406 char buf[MAX_BUFFER_SIZE_FOR_SUBCHANNEL_ATTRIBUTES];
416 device = de_vec[0]->d_name;
417 snprintf(buf, sizeof(buf), "%s", device);
$ grep -r 'd_name\[' /usr/include/
/usr/include/bits/dirent.h: char d_name[256];
The compiler assumes that d_name can be up to 255 characters. Therefore
it produces the following warning:
CC zconf/css/lscss.o
lscss.c: In function 'print_sch_io':
lscss.c:417:31: warning: '%s' directive output may be truncated writing
up to 255 bytes into a region of size 37 [-Wformat-truncation=]
snprintf(buf, sizeof(buf), "%s", device);
^~
In file included from /usr/include/stdio.h:936:0,
from lscss.c:10:
/usr/include/bits/stdio2.h:64:10: note: '__builtin_snprintf' output
between 1 and 256 bytes into a destination of size 37
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this and use larger buffer sizes to keep gcc quiet.
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>