summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-05-27 11:57:42 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-05-28 10:36:09 +0200
commitd2211c83365e5473cede0aa4704294d03270e59c (patch)
tree4fd9c235abc209e312bad4565e17c53a9bb55188
parent799d94daa445173a6da410858e9e0f87ea9e04cb (diff)
downloadbarebox-d2211c83365e5473cede0aa4704294d03270e59c.tar.gz
barebox-d2211c83365e5473cede0aa4704294d03270e59c.tar.xz
scripts: kwbimage: fix build with non-glibc systems
get_current_dir_name is a glibc extension, thus replace it with a call to standard POSIX pathconf/malloc/gecwd. The result slightly differs, because get_current_dir_name consults the $PWD environment variable as as well, but that's ok, as it's just an error message. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--scripts/kwbimage.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index 2a052a7ff3..6ba4abaa30 100644
--- a/scripts/kwbimage.c
+++ b/scripts/kwbimage.c
@@ -860,12 +860,16 @@ static void *image_create_v1(struct image_cfg_element *image_cfg,
ret = stat(binarye->binary.file, &s);
if (ret < 0) {
- char *cwd = get_current_dir_name();
+ char *buf, *cwd = NULL;
+ size_t size = (size_t)pathconf(".", _PC_PATH_MAX);
+ buf = malloc(size);
+ if (buf)
+ cwd = getcwd(buf, size);
fprintf(stderr,
"Didn't find the file '%s' in '%s' which is mandatory to generate the image\n"
"This file generally contains the DDR3 training code, and should be extracted from an existing bootable\n"
"image for your board. See 'kwbimage -x' to extract it from an existing image.\n",
- binarye->binary.file, cwd);
+ binarye->binary.file, cwd ? cwd : "current working directory");
free(cwd);
return NULL;
}