File s390-tools-sles15sp1-01-util_path-add-function-to-check-if-a-path-exists.patch of Package s390-tools
Subject: util_path: add function to check if a path exists
From: Jan Hoeppner <jan.hoeppner@de.ibm.com>
Summary: zpcictl: Add tool to manage PCI devices
Description: Use the zpcictl tool to manage PCI devices on the IBM Z
platform. Initial functions include generating firmware
error logs, resetting PCI devices, and preparing a device
for further repair actions.
Upstream-ID: df133846b5889a7698ac09f00284c1be54926b59
Problem-ID: RAS1703
Upstream-Description:
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>
Signed-off-by: Jan Hoeppner <jan.hoeppner@de.ibm.com>
---
include/lib/util_path.h | 1 +
libutil/util_path.c | 12 ++++++++++++
2 files changed, 13 insertions(+)
--- a/include/lib/util_path.h
+++ b/include/lib/util_path.h
@@ -20,5 +20,6 @@ bool util_path_is_readable(const char *f
bool util_path_is_writable(const char *fmt, ...);
bool util_path_is_dir(const char *fmt, ...);
bool util_path_is_reg_file(const char *fmt, ...);
+bool util_path_exists(const char *fmt, ...);
#endif /** LIB_UTIL_PATH_H @} */
--- a/libutil/util_path.c
+++ b/libutil/util_path.c
@@ -194,3 +194,15 @@ free_str:
free(path);
return rc;
}
+
+bool util_path_exists(const char *fmt, ...)
+{
+ va_list ap;
+ char *path;
+ bool rc;
+
+ UTIL_VASPRINTF(&path, fmt, ap);
+ rc = access(path, F_OK) == 0;
+ free(path);
+ return rc;
+}