Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | From 800dae0d34f8629a34c638a612166b76dda03e27 Mon Sep 17 00:00:00 2001 |
| 2 | From: Andrea Adami <andrea.adami@gmail.com> |
| 3 | Date: Sat, 2 Aug 2014 01:13:08 +0200 |
| 4 | Subject: [PATCH 3/4] kexecboot: do not hardcode MOUNTPOINT |
| 5 | |
| 6 | Avoid to hardcode it: could be requested as a new configure option. |
| 7 | |
| 8 | Signed-off-by: Andrea Adami <andrea.adami@gmail.com> |
| 9 | --- |
| 10 | cfgparser.c | 6 +++--- |
| 11 | kexecboot.c | 18 ++++++++++-------- |
| 12 | 2 files changed, 13 insertions(+), 11 deletions(-) |
| 13 | |
| 14 | diff --git a/cfgparser.c b/cfgparser.c |
| 15 | index 8f6688c..dec27b1 100644 |
| 16 | --- a/cfgparser.c |
| 17 | +++ b/cfgparser.c |
| 18 | @@ -141,7 +141,7 @@ static int set_kernel(struct cfgdata_t *cfgdata, char *value) |
| 19 | return -1; |
| 20 | } |
| 21 | |
| 22 | - strcpy(sc->kernelpath, "/mnt"); |
| 23 | + strcpy(sc->kernelpath, MOUNTPOINT); |
| 24 | strcat(sc->kernelpath, value); |
| 25 | return 0; |
| 26 | } |
| 27 | @@ -155,7 +155,7 @@ static int set_icon(struct cfgdata_t *cfgdata, char *value) |
| 28 | |
| 29 | dispose(sc->iconpath); |
| 30 | /* Add our mountpoint, since the enduser won't know it */ |
| 31 | - sc->iconpath = malloc(sizeof(MOUNTPOINT)+strlen(value)); |
| 32 | + sc->iconpath = malloc(strlen(MOUNTPOINT)+strlen(value)+1); |
| 33 | if (NULL == sc->iconpath) { |
| 34 | DPRINTF("Can't allocate memory to store iconpath '%s'", value); |
| 35 | return -1; |
| 36 | @@ -194,7 +194,7 @@ static int set_initrd(struct cfgdata_t *cfgdata, char *value) |
| 37 | return -1; |
| 38 | } |
| 39 | |
| 40 | - strcpy(sc->initrd, "/mnt"); |
| 41 | + strcpy(sc->initrd, MOUNTPOINT); |
| 42 | strcat(sc->initrd, value); |
| 43 | return 0; |
| 44 | } |
| 45 | diff --git a/kexecboot.c b/kexecboot.c |
| 46 | index d6657a0..7268d6b 100644 |
| 47 | --- a/kexecboot.c |
| 48 | +++ b/kexecboot.c |
| 49 | @@ -57,20 +57,22 @@ |
| 50 | #endif |
| 51 | |
| 52 | #ifdef USE_MACHINE_KERNEL |
| 53 | -/* Machine-dependent kernel patch */ |
| 54 | +/* Machine-dependent kernel path */ |
| 55 | char *machine_kernel = NULL; |
| 56 | #endif |
| 57 | |
| 58 | +#define PREPEND_MOUNTPATH(string) MOUNTPOINT""string |
| 59 | + |
| 60 | /* NULL-terminated array of kernel search paths |
| 61 | * First item should be filled with machine-dependent path */ |
| 62 | char *default_kernels[] = { |
| 63 | #ifdef USE_ZIMAGE |
| 64 | - "/mnt/boot/zImage", |
| 65 | - "/mnt/zImage", |
| 66 | + PREPEND_MOUNTPATH("/boot/zImage"), |
| 67 | + PREPEND_MOUNTPATH("/zImage"), |
| 68 | #endif |
| 69 | #ifdef USE_UIMAGE |
| 70 | - "/mnt/boot/uImage", |
| 71 | - "/mnt/uImage", |
| 72 | + PREPEND_MOUNTPATH("/boot/uImage"), |
| 73 | + PREPEND_MOUNTPATH("/uImage"), |
| 74 | #endif |
| 75 | NULL |
| 76 | }; |
| 77 | @@ -149,14 +151,14 @@ char *get_machine_kernelpath() { |
| 78 | ++tmp; |
| 79 | } |
| 80 | |
| 81 | - /* Prepend "/mnt/boot/zImage-" to hw */ |
| 82 | - tmp = malloc(strlen(hw) + 17 + 1); /* strlen("/mnt/boot/zImage-") */ |
| 83 | + /* Prepend MOUNTPOINT"/boot/zImage-" to hw */ |
| 84 | + tmp = malloc(strlen(PREPEND_MOUNTPATH("/boot/zImage-")) + strlen(hw) + 1); |
| 85 | if (NULL == tmp) { |
| 86 | DPRINTF("Can't allocate memory for machine-specific kernel path"); |
| 87 | return NULL; |
| 88 | } |
| 89 | |
| 90 | - strcpy(tmp, "/mnt/boot/zImage-"); |
| 91 | + strcpy(tmp, PREPEND_MOUNTPATH("/boot/zImage-")); |
| 92 | strcat(tmp, hw); |
| 93 | |
| 94 | return tmp; |
| 95 | -- |
| 96 | 1.9.1 |
| 97 | |