Subject: util_path: add function to check if a path exists From: Jan Hoeppner 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 Acked-by: Michael Holzheu Signed-off-by: Michael Holzheu Signed-off-by: Jan Hoeppner --- 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; +}