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

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