util: Add function to normalize paths produced by kernel.core_pattern %E 45/225545/3
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 20 Feb 2020 15:46:03 +0000 (16:46 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 21 Feb 2020 14:21:36 +0000 (15:21 +0100)
Change-Id: I0afbb7d946d16b2fff293c8697ae2e6d7db53e43

src/shared/util.c
src/shared/util.h

index 6afc936..bfea12b 100644 (file)
@@ -578,6 +578,15 @@ bool string_ends_with(const char *string, const char *suffix)
        return (string_len >= suffix_len) && !strcmp(string + string_len - suffix_len, suffix);
 }
 
+/* what for: kernel.core_pattern's %E replaces / with !, this function does opposite process */
+void kernel_exe_path_normalize(char *path)
+{
+       assert(path);
+
+       for (size_t i = 0, len = strlen(path); i < len; i++)
+               path[i] = path[i] == '!' ? '/' : path[i];
+}
+
 bool file_exists(const char *path)
 {
        struct stat buf;
index f820997..ad0bd42 100644 (file)
@@ -68,6 +68,8 @@ char* concatenate(char *const vec[]);
 
 bool string_ends_with(const char *string, const char *suffix);
 
+void kernel_exe_path_normalize(char *path);
+
 bool file_exists(const char *path);
 
 bool file_exists_in_dir(const char *dir_path, const char *file_name);