Blob Blame Raw
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Thu, 20 Jun 2019 13:26:31 +0200
Subject: [PATCH] grub-set-bootflag: Print an error if failing to read from
 grubenv

If the tool fails to read the grubenv file, it prints the following error:

  Error reading from /boot/grub2/grubenv: Success

This is confusing for users, so instead print a proper error message.

Resolves: rhbz#1702354

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
 util/grub-set-bootflag.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c
index 20062fe802b..6a79ee67444 100644
--- a/util/grub-set-bootflag.c
+++ b/util/grub-set-bootflag.c
@@ -27,6 +27,7 @@
 #include <grub/types.h>
 #include <grub/err.h>
 #include <grub/lib/envblk.h> /* For GRUB_ENVBLK_DEFCFG define */
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -87,6 +88,7 @@ int main(int argc, char *argv[])
   fclose (f);
   if (ret != GRUBENV_SIZE)
     {
+      errno = EINVAL;
       perror ("Error reading from " GRUBENV);
       return 1;     
     }