/* Create an absolute path of given path by prepending the CWD environment variable.  */
static int create_absolute_path(char *dst_p, const char *path_p)
/* Create an absolute path of given path by prepending the CWD environment variable.  */
static int create_absolute_path(char *dst_p, const char *path_p)
{
    ssize_t res;
    const char *cwd_p;
    const char *slash_p;
    cwd_p = "";
    slash_p = "";
    if (path_p[0] != '/') {
        cwd_p = thrd_get_env("CWD");
        if ((cwd_p == NULL) || (cwd_p[0] == '\0')) {
            cwd_p = "/";
        }
        if (cwd_p[strlen(cwd_p) - 1] != '/') {
            slash_p = "/";
        }
    }
    res = std_snprintf(dst_p,
                       CONFIG_FS_PATH_MAX,
                       FSTR("%s%s%s"),
                       cwd_p,
                       slash_p,
                       path_p);
    return (res < 0 ? res : 0);
}