Blame SOURCES/0289-efidisk-prevent-errors-from-diskfilter-scan-of-remov.patch

d41074
From 8f4dc1510c0f42a549b91c28eda74fe8a1e2a5d4 Mon Sep 17 00:00:00 2001
d41074
From: Andrei Borzenkov <arvidjaar@gmail.com>
d41074
Date: Fri, 26 Feb 2016 21:44:37 +0300
d41074
Subject: [PATCH] efidisk: prevent errors from diskfilter scan of removable
d41074
 drives
d41074
d41074
Map EFI_NO_MEDIA to GRUB_ERR_OUT_OF_RANGE that is ignored by diskfilter. This
d41074
actually matches pretty close (we obviously attempt to read outside of media)
d41074
and avoids adding more error codes.
d41074
d41074
This affects only internally initiated scans. If read/write from removable is
d41074
explicitly requested, we still return an error and text explanation is more
d41074
clear for user than generic error.
d41074
d41074
Reported and tested by Andreas Loew <Andreas.Loew@gmx.net>
d41074
---
d41074
 grub-core/disk/efi/efidisk.c | 12 ++++++++----
d41074
 1 file changed, 8 insertions(+), 4 deletions(-)
d41074
d41074
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
d41074
index f04f20b84ff..41adc1b0421 100644
d41074
--- a/grub-core/disk/efi/efidisk.c
d41074
+++ b/grub-core/disk/efi/efidisk.c
d41074
@@ -575,9 +575,11 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
d41074
 
d41074
   status = grub_efidisk_readwrite (disk, sector, size, buf, 0);
d41074
 
d41074
-  if (status != GRUB_EFI_SUCCESS)
d41074
+  if (status == GRUB_EFI_NO_MEDIA)
d41074
+    return grub_error (GRUB_ERR_OUT_OF_RANGE, "no media in `%s'", disk->name);
d41074
+  else if (status != GRUB_EFI_SUCCESS)
d41074
     return grub_error (GRUB_ERR_READ_ERROR,
d41074
-		       N_("failure reading sector 0x%llx from `%s'"),
d41074
+		       "failure reading sector 0x%llx from `%s'",
d41074
 		       (unsigned long long) sector,
d41074
 		       disk->name);
d41074
 
d41074
@@ -596,9 +598,11 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,
d41074
 
d41074
   status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1);
d41074
 
d41074
-  if (status != GRUB_EFI_SUCCESS)
d41074
+  if (status == GRUB_EFI_NO_MEDIA)
d41074
+    return grub_error (GRUB_ERR_OUT_OF_RANGE, "no media in `%s'", disk->name);
d41074
+  else if (status != GRUB_EFI_SUCCESS)
d41074
     return grub_error (GRUB_ERR_WRITE_ERROR,
d41074
-		       N_("failure writing sector 0x%llx to `%s'"),
d41074
+		       "failure writing sector 0x%llx to `%s'",
d41074
 		       (unsigned long long) sector, disk->name);
d41074
 
d41074
   return GRUB_ERR_NONE;
d41074
-- 
d41074
2.20.1
d41074