[PATCH 16/18] scripts: kwbimage: fix build with non-glibc systems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 scripts/kwbimage.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index 2a052a7ff385..6ba4abaa3076 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;
 		}
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux