Commit Graph

18 Commits

Author SHA1 Message Date
Michael Holzheu
8cbdfebc4f Makefile: Fix parallel build (2nd try)
Commit 851f685993 ("Makefile: Add dependency between libvmcp and
libutil to fix -j builds") introduced the following regression

  $ make clean
  CLEAN   /home2/holzheu/src/s390-tools
  ...
  CLEAN   libccw
  CC      libutil/util_base.o
  CC      libutil/util_path.o

For the "clean" target the new library dependency triggers a build
of libutil.

So remove the dependency again.

To fix the parallel build issue, no longer build the examples with
"make all" and add a new target "examples" that can now be used for building
the example programs.

Fixes: 851f685993 ("Makefile: Add dependency between libvmcp and libutil to fix -j builds")
Signed-off-by: Michael Holzheu <holzheu@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-12-11 15:52:07 +01:00
Jan Höppner
aefc8cd3ff libutil/libu2s: Move strlcpy() implementation to libutils
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>
2018-11-16 15:01:42 +01:00
Karsten Graul
cd46297d7c s390-tools/utils: handle util_scandir errors correctly
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>
2018-10-19 15:32:53 +02:00
Michael Holzheu
a87268d62e util_path_example: Fix usage message
Document that for the "sysfs" invocation the mount point is optional.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-11 14:41:32 +02:00
Michael Holzheu
9cc06a0529 util_proc: Fix typos in description of util_proc_mnt_get_entry()
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-11 14:41:32 +02:00
Michael Holzheu
3b1ccce515 util_proc: Fix return code handling for util_proc_mnt_get_entry()
Correctly return -1 if the requested file system is not mounted.

Reported-by: Peter Morjan <peter.morjan@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-10-11 14:41:32 +02:00
Peter Oberparleiter
257490366b util_prg_example: Add --help and --version options
Add missing long options for --help and --version in util_prg_example.

Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-17 14:23:47 +02:00
Thomas Richter
427dff3450 s390-tools: Move function util_strstrip
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>
2018-05-07 13:42:03 +02:00
Thomas Richter
6a1b9cf10a s390-tools: Add function util_strstrip
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>
2018-05-07 13:42:03 +02:00
Michael Holzheu
89ead069f9 util_list: Use util_malloc() for util_list_new()
Since now util_list_new() internally fails for out-of-memory situations,
we can also remove some NULL pointer checks.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2018-01-29 18:15:03 +01:00
Michael Holzheu
e767a2b99d build process: Fix parallel build for libutil
When building libutil in parallel, it can happen that the archive
file is created twice:

 $ cd libutil
 $ make -j
  ...
  CC      libutil/util_rec_example.o
  AR      libutil/libutil.a
  AR      libutil/libutil.a
  LINK    libutil/util_base_example

This can lead to the following build error:

 $ make -j OPT_FLAGS="-pipe"
   ..//libutil/libutil.a(util_path.o): In function `sys_mount_point':
   util_path.c:56: undefined reference to `util_proc_mnt_get_entry'
   util_path.c:60: undefined reference to `util_proc_mnt_free_entry'
   collect2: error: ld returned 1 exit status
   ../common.mak:232: recipe for target 'util_path_example' failed

The problem is that the following rule from common.mak is triggered in
the libutil directory:

 $(rootdir)/libutil/libutil.a: $(rootdir)/libutil
      $(MAKE) -C $(rootdir)/libutil/ libutil.a
 .PHONY: $(rootdir)/libutil

To prevent this rule, use the local "libutil.a" as dependency for the
example binaries.

Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-06 15:59:58 +01:00
Michael Holzheu
75a45158ad util_path_example: Improve output of is_xxx
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:25 +01:00
Michael Holzheu
16c4074e47 util_path_example: Add example for new util_path_exists() function
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:19 +01:00
Michael Holzheu
2b92bc4c08 util_path: Make true/false handling consistent with other functions
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:10 +01:00
Michael Holzheu
d0e2caf0ff util_path: Add description for util_path_exists()
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:05 +01:00
Rafael Fonseca
df133846b5 util_path: add function to check if a path exists
GitHub-ID: #20

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:58:57 +01:00
Michael Holzheu
e0c48d6af8 Fix copyright dates
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-21 12:06:12 +02:00
Michael Holzheu
b627b8d8e1 Initial s390-tools-2.0.0 import
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>
2017-08-21 10:55:40 +02:00