Fix previous commit

- Add missing patch (forgot to add)
- Disable tests on riscv64

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
This commit is contained in:
David Abdurachmanov 2019-10-30 15:31:46 +02:00
parent 42753e7364
commit 947bccf67b
Signed by: davidlt
GPG Key ID: 8B7F1DA0E2C9FDBB
2 changed files with 192 additions and 1 deletions

View File

@ -0,0 +1,191 @@
From 468294997edf8b7ca6a3434d8ea31e10229255e9 Mon Sep 17 00:00:00 2001
From: David Abdurachmanov <david.abdurachmanov@sifive.com>
Date: Wed, 30 Oct 2019 13:02:02 +0000
Subject: [PATCH] riscv: add support for addappend in extlinux
This is experimental only to be used for RISC-V to support multiple
targets with a single images.
addappend does not overwrite existing boot arguments (defined per board)
and instead adds them at the end of existing ones.
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
---
grubby.c | 44 +++++++++++++++++++++++++++-----------------
1 file changed, 27 insertions(+), 17 deletions(-)
diff --git a/grubby.c b/grubby.c
index 5ca6895..60d4723 100644
--- a/grubby.c
+++ b/grubby.c
@@ -101,7 +101,8 @@ enum lineType_e {
LT_KERNEL_16 = 1 << 22,
LT_INITRD_16 = 1 << 23,
LT_DEVTREE = 1 << 24,
- LT_UNKNOWN = 1 << 25,
+ LT_KERNELARGSADD = 1 << 25,
+ LT_UNKNOWN = 1 << 26,
};
struct singleLine {
@@ -589,6 +590,7 @@ struct keywordTypes extlinuxKeywords[] = {
{ "kernel", LT_KERNEL, ' ' },
{ "initrd", LT_INITRD, ' ', ',' },
{ "append", LT_KERNELARGS, ' ' },
+ { "addappend", LT_KERNELARGSADD, ' ' },
{ "prompt", LT_UNKNOWN, ' ' },
{ "fdt", LT_DEVTREE, ' ' },
{ "fdtdir", LT_DEVTREE, ' ' },
@@ -760,6 +762,14 @@ static enum lineType_e preferredLineType(enum lineType_e type,
default:
return type;
}
+#elif defined(__riscv)
+ } else if (cfi == &extlinuxConfigType) {
+ switch (type) {
+ case LT_KERNELARGS:
+ return LT_KERNELARGSADD;
+ default:
+ return type;
+ }
#endif
}
return type;
@@ -945,7 +955,7 @@ static int lineWrite(FILE * out, struct singleLine * line,
continue;
}
- if (i == 1 && line->type == LT_KERNELARGS && cfi->argsInQuotes)
+ if (i == 1 && line->type == preferredLineType(LT_KERNELARGS, cfi) && cfi->argsInQuotes)
if (fputc('"', out) == EOF) return -1;
if (fprintf(out, "%s", line->elements[i].item) == -1) return -1;
@@ -953,7 +963,7 @@ static int lineWrite(FILE * out, struct singleLine * line,
if (fprintf(out, "%s", line->elements[i].indent) == -1) return -1;
}
- if (line->type == LT_KERNELARGS && cfi->argsInQuotes)
+ if (line->type == preferredLineType(LT_KERNELARGS, cfi) && cfi->argsInQuotes)
if (fputc('"', out) == EOF) return -1;
if (fprintf(out, "\n") == -1) return -1;
@@ -1341,7 +1351,7 @@ static struct grubConfig * readConfig(const char * inName,
line->elements[line->numElements - 2].indent;
line->elements[2].item = extras;
line->numElements = 3;
- } else if (line->type == LT_KERNELARGS && cfi->argsInQuotes) {
+ } else if (line->type == preferredLineType(LT_KERNELARGS, cfi) && cfi->argsInQuotes) {
/* Strip off any " which may be present; they'll be put back
on write. This is one of the few (the only?) places that grubby
canonicalizes the output */
@@ -1972,7 +1982,7 @@ static size_t subvolPrefix(const char *str)
}
int suitableImage(struct singleEntry * entry, const char * bootPrefix,
- int skipRemoved, int flags) {
+ int skipRemoved, int flags, struct grubConfig * cfg) {
struct singleLine * line;
char * fullName;
int i;
@@ -2026,7 +2036,7 @@ int suitableImage(struct singleEntry * entry, const char * bootPrefix,
/* didn't succeed in finding a LT_ROOT, let's try LT_KERNELARGS.
* grub+multiboot uses LT_MBMODULE for the args, so check that too.
*/
- line = getLineByType(LT_KERNELARGS|LT_MBMODULE, entry->lines);
+ line = getLineByType(preferredLineType(LT_KERNELARGS, cfg->cfi)|LT_MBMODULE, entry->lines);
/* failed to find one */
if (!line) {
@@ -2266,7 +2276,7 @@ struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix,
} else {
entry = findEntryByTitle(cfg, defTitle, &index);
}
- if (entry && suitableImage(entry, prefix, skipRemoved, flags)) {
+ if (entry && suitableImage(entry, prefix, skipRemoved, flags, cfg)) {
cfg->defaultImage = index;
if (indexPtr)
*indexPtr = index;
@@ -2276,7 +2286,7 @@ struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix,
}
} else if (cfg->defaultImage > -1) {
entry = findEntryByIndex(cfg, cfg->defaultImage);
- if (entry && suitableImage(entry, prefix, skipRemoved, flags)) {
+ if (entry && suitableImage(entry, prefix, skipRemoved, flags, cfg)) {
if (indexPtr) *indexPtr = cfg->defaultImage;
return entry;
}
@@ -2284,7 +2294,7 @@ struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix,
index = 0;
while ((entry = findEntryByIndex(cfg, index))) {
- if (suitableImage(entry, prefix, skipRemoved, flags)) {
+ if (suitableImage(entry, prefix, skipRemoved, flags, cfg)) {
int j;
for (j = 0; j < index; j++) {
entry2 = findEntryByIndex(cfg, j);
@@ -2424,7 +2434,7 @@ void setFallbackImage(struct grubConfig * config, int hasNew) {
}
}
-void displayEntry(struct singleEntry * entry, const char * prefix, int index) {
+void displayEntry(struct singleEntry * entry, const char * prefix, int index, struct grubConfig * cfg) {
struct singleLine * line;
char * root = NULL;
int i;
@@ -2458,7 +2468,7 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) {
}
printf("\"\n");
} else {
- line = getLineByType(LT_KERNELARGS, entry->lines);
+ line = getLineByType(preferredLineType(LT_KERNELARGS, cfg->cfi), entry->lines);
if (line) {
char * s;
@@ -2895,11 +2905,11 @@ int displayInfo(struct grubConfig * config, char * kernel,
if (line) printf("lba\n");
}
- displayEntry(entry, prefix, i);
+ displayEntry(entry, prefix, i, config);
i++;
while ((entry = findEntryByPath(config, kernel, prefix, &i))) {
- displayEntry(entry, prefix, i);
+ displayEntry(entry, prefix, i, config);
i++;
}
@@ -3277,7 +3287,7 @@ int updateActualImage(struct grubConfig * cfg, const char * image,
}
- useKernelArgs = (getKeywordByType(LT_KERNELARGS, cfg->cfi)
+ useKernelArgs = (getKeywordByType(preferredLineType(LT_KERNELARGS, cfg->cfi), cfg->cfi)
&& (!multibootArgs || cfg->cfi->mbConcatArgs));
useRoot = (getKeywordByType(LT_ROOT, cfg->cfi)
@@ -3293,10 +3303,10 @@ int updateActualImage(struct grubConfig * cfg, const char * image,
* LT_HYPER/LT_KERNEL/LT_MBMODULE lines.
*/
if (useKernelArgs) {
- line = getLineByType(LT_KERNELARGS, entry->lines);
+ line = getLineByType(preferredLineType(LT_KERNELARGS, cfg->cfi), entry->lines);
if (!line) {
/* no LT_KERNELARGS, need to add it */
- line = addLine(entry, cfg->cfi, LT_KERNELARGS,
+ line = addLine(entry, cfg->cfi, preferredLineType(LT_KERNELARGS, cfg->cfi),
cfg->secondaryIndent, NULL);
}
firstElement = 1;
@@ -4782,7 +4792,7 @@ int main(int argc, const char ** argv) {
config->defaultImage = 0;
entry = findEntryByIndex(config, config->defaultImage);
if (!entry) return 0;
- if (!suitableImage(entry, bootPrefix, 0, flags)) return 0;
+ if (!suitableImage(entry, bootPrefix, 0, flags, config)) return 0;
line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
if (!line) return 0;
--
2.24.0.rc1

View File

@ -69,7 +69,7 @@ git config --unset user.name
%set_build_flags
make %{?_smp_mflags} LDFLAGS="${LDFLAGS}"
%ifnarch aarch64 %{arm}
%ifnarch aarch64 %{arm} riscv64
%check
make test
%endif