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

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