Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 1 | From 14d4dbd293c75bc81a0dde6e678f9bbefb40b6f1 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 2 | From: Andrea Adami <andrea.adami@gmail.com> |
| 3 | Date: Tue, 17 Apr 2018 13:48:25 +0200 |
| 4 | Subject: [PATCH] fs2dt.c: work around missing getline() |
| 5 | |
| 6 | This simple case can be rewrtten with fgets() |
| 7 | |
| 8 | Fix |
| 9 | |
| 10 | fs2dt.c: In function 'dt_copy_old_root_param': |
| 11 | fs2dt.c:541:6: warning: implicit declaration of function 'getline' |
| 12 | |
| 13 | Upstream-Status: Inappropriate [klibc specific] |
| 14 | Signed-off-by: Andrea Adami <andrea.adami@gmail.com> |
| 15 | |
| 16 | --- |
| 17 | kexec/fs2dt.c | 8 ++++++++ |
| 18 | 1 file changed, 8 insertions(+) |
| 19 | |
| 20 | diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c |
| 21 | index 07a5e2f..d635636 100644 |
| 22 | --- a/kexec/fs2dt.c |
| 23 | +++ b/kexec/fs2dt.c |
| 24 | @@ -531,6 +531,9 @@ static void dt_copy_old_root_param(void) |
| 25 | char *last_cmdline = NULL; |
| 26 | char *p, *old_param; |
| 27 | size_t len = 0; |
| 28 | +#ifdef __KLIBC__ |
| 29 | + char buf[512]; |
| 30 | +#endif |
| 31 | |
| 32 | strcpy(filename, pathname); |
| 33 | strcat(filename, "bootargs"); |
| 34 | @@ -538,8 +541,13 @@ static void dt_copy_old_root_param(void) |
| 35 | if (!fp) |
| 36 | return; |
| 37 | |
| 38 | +#ifndef __KLIBC__ |
| 39 | if (getline(&last_cmdline, &len, fp) == -1) |
| 40 | die("unable to read %s\n", filename); |
| 41 | +#else |
| 42 | + last_cmdline = fgets(buf, 200, fp); |
| 43 | + last_cmdline[strlen(last_cmdline) - 1] = '\0'; |
| 44 | +#endif |
| 45 | |
| 46 | p = strstr(last_cmdline, "root="); |
| 47 | if (p) { |