From: Jeremy Kerr Date: Thu, 27 Feb 2014 03:39:41 +0000 (+0800) Subject: discover/pxe: Fix prefix autodetection when bootfile is in the root dir X-Git-Tag: v1.0.0~227 X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=commitdiff_plain;h=922756a3aefd8ba5c5675efd37df9f43938cf432 discover/pxe: Fix prefix autodetection when bootfile is in the root dir Currently, if the bootfile doesn't contain a directory, the path we use for config file resolution will use the bootfile as the first component of path. For example, if bootfile is: pxelinux.0 the config files requested will be: pxelinux.0/ pxelinux.0/ pxelinux.0/default For cases where bootfile is a single file, we need to use a blank prefix. Signed-off-by: Jeremy Kerr --- diff --git a/discover/user-event.c b/discover/user-event.c index 1e366ee..cf7f20c 100644 --- a/discover/user-event.c +++ b/discover/user-event.c @@ -290,8 +290,9 @@ struct pb_url *user_event_parse_conf_url(struct discover_context *ctx, /* strip filename from the bootfile path, leaving only a * directory */ p = strrchr(basedir, '/'); - if (p) - *p = '\0'; + if (!p) + p = basedir; + *p = '\0'; if (strlen(basedir)) url_str = talloc_asprintf_append(url_str, "%s/",