@@ -245,6 +245,11 @@ static bool builtin_test_op_file(struct grub2_script *script, char op,
return false;
switch (op) {
+ case 'e':
+ /* -e: for grub, a special case is testing for the device
+ * presence itself (e.g. allows null file). */
+ result = true;
+ break;
case 's':
/* -s: return true if file exists and has non-zero size */
result = !path ? false : statbuf.st_size > 0;
@@ -336,7 +341,7 @@ static bool builtin_test_op(struct grub2_script *script,
return strlen(a1) != 0;
}
- if (!strcmp(op, "-s") || !strcmp(op, "-f")) {
+ if (!strcmp(op, "-s") || !strcmp(op, "-f") || !(strcmp(op, "-e"))) {
*consumed = 2;
return builtin_test_op_file(script, op[1], a1);
}
@@ -19,13 +19,13 @@ void run_test(struct parser_test *test)
check_unresolved_resource(opt->boot_image);
check_unresolved_resource(opt->initrd);
check_name(opt, "Kubuntu GNU/Linux");
- check_args(opt, "root=UUID=29beca39-9181-4780-bbb2-ab5d4be59aaf ro quiet splash ");
+ check_args(opt, "root=UUID=29beca39-9181-4780-bbb2-ab5d4be59aaf ro quiet splash vt.handoff=7");
opt = get_boot_option(ctx, 1);
check_unresolved_resource(opt->boot_image);
check_unresolved_resource(opt->initrd);
check_name(opt, "Kubuntu GNU/Linux, with Linux 3.8.0-19-generic");
- check_args(opt, "root=UUID=29beca39-9181-4780-bbb2-ab5d4be59aaf ro quiet splash ");
+ check_args(opt, "root=UUID=29beca39-9181-4780-bbb2-ab5d4be59aaf ro quiet splash vt.handoff=7");
opt = get_boot_option(ctx, 2);
check_name(opt, "Kubuntu GNU/Linux, with Linux 3.8.0-19-generic (recovery mode)");
Grub2 allows a special-case of file test using the '-e' operator, where the path can be empty, and the device existance is tested. E.g.: if [ -e (md/md-boot) ]; then Add the support for testing this condition. This fixes the following RH CoreOS bug: https://bugzilla.redhat.com/show_bug.cgi?id=1915540 Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com> --- discover/grub2/builtins.c | 7 ++++++- test/parser/test-grub2-ubuntu-13_04-x86.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-)