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

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