dcavalca / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0330-verifiers-File-type-for-fine-grained-signature-verif.patch

5975ab
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
5975ab
From: Vladimir Serbinenko <phcoder@gmail.com>
5975ab
Date: Wed, 20 Nov 2013 02:28:29 +0100
5975ab
Subject: [PATCH] verifiers: File type for fine-grained signature-verification
5975ab
 controlling
5975ab
5975ab
Let's provide file type info to the I/O layer. This way verifiers
5975ab
framework and its users will be able to differentiate files and verify
5975ab
only required ones.
5975ab
5975ab
This is preparatory patch.
5975ab
5975ab
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
5975ab
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
5975ab
Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
5975ab
(backported from commit ca0a4f689a02c2c5a5e385f874aaaa38e151564e)
5975ab
Signed-off-by: Daniel Axtens <dja@axtens.net>
5975ab
---
5975ab
 grub-core/commands/acpi.c                    |   2 +-
5975ab
 grub-core/commands/blocklist.c               |   4 +-
5975ab
 grub-core/commands/cat.c                     |   2 +-
5975ab
 grub-core/commands/cmp.c                     |   4 +-
5975ab
 grub-core/commands/efi/loadbios.c            |   4 +-
5975ab
 grub-core/commands/file.c                    |   5 +-
5975ab
 grub-core/commands/hashsum.c                 |  22 ++--
5975ab
 grub-core/commands/hexdump.c                 |   2 +-
5975ab
 grub-core/commands/i386/pc/play.c            |   2 +-
5975ab
 grub-core/commands/keylayouts.c              |   2 +-
5975ab
 grub-core/commands/legacycfg.c               |   2 +-
5975ab
 grub-core/commands/loadenv.c                 |  24 +++--
5975ab
 grub-core/commands/ls.c                      |   8 +-
5975ab
 grub-core/commands/minicmd.c                 |   2 +-
5975ab
 grub-core/commands/nativedisk.c              |   3 +-
5975ab
 grub-core/commands/parttool.c                |   2 +-
5975ab
 grub-core/commands/search.c                  |   4 +-
5975ab
 grub-core/commands/test.c                    |   4 +-
5975ab
 grub-core/commands/testload.c                |   2 +-
5975ab
 grub-core/commands/testspeed.c               |   2 +-
5975ab
 grub-core/commands/verify.c                  |  51 ++++-----
5975ab
 grub-core/disk/loopback.c                    |   3 +-
5975ab
 grub-core/efiemu/main.c                      |   2 +-
5975ab
 grub-core/font/font.c                        |   4 +-
5975ab
 grub-core/fs/zfs/zfscrypt.c                  |   2 +-
5975ab
 grub-core/gettext/gettext.c                  |   2 +-
5975ab
 grub-core/gfxmenu/theme_loader.c             |   2 +-
5975ab
 grub-core/io/bufio.c                         |   4 +-
5975ab
 grub-core/io/gzio.c                          |   5 +-
5975ab
 grub-core/io/lzopio.c                        |   6 +-
5975ab
 grub-core/io/offset.c                        |   7 +-
5975ab
 grub-core/io/xzio.c                          |   6 +-
5975ab
 grub-core/kern/dl.c                          |   2 +-
5975ab
 grub-core/kern/elf.c                         |   4 +-
5975ab
 grub-core/kern/file.c                        |  22 ++--
5975ab
 grub-core/lib/syslinux_parse.c               |   2 +-
5975ab
 grub-core/loader/efi/chainloader.c           |   2 +-
5975ab
 grub-core/loader/i386/bsd.c                  |  16 +--
5975ab
 grub-core/loader/i386/coreboot/chainloader.c |   2 +-
5975ab
 grub-core/loader/i386/linux.c                |   2 +-
5975ab
 grub-core/loader/i386/pc/chainloader.c       |   4 +-
5975ab
 grub-core/loader/i386/pc/freedos.c           |   2 +-
5975ab
 grub-core/loader/i386/pc/linux.c             |   2 +-
5975ab
 grub-core/loader/i386/pc/ntldr.c             |   2 +-
5975ab
 grub-core/loader/i386/pc/plan9.c             |   2 +-
5975ab
 grub-core/loader/i386/pc/pxechainloader.c    |   2 +-
5975ab
 grub-core/loader/i386/pc/truecrypt.c         |   2 +-
5975ab
 grub-core/loader/i386/xen.c                  |   7 +-
5975ab
 grub-core/loader/i386/xen_file.c             |   2 +-
5975ab
 grub-core/loader/i386/xnu.c                  |   2 +-
5975ab
 grub-core/loader/linux.c                     |   6 +-
5975ab
 grub-core/loader/macho.c                     |   4 +-
5975ab
 grub-core/loader/mips/linux.c                |   2 +-
5975ab
 grub-core/loader/multiboot.c                 |   8 +-
5975ab
 grub-core/loader/xnu.c                       |  16 +--
5975ab
 grub-core/loader/xnu_resume.c                |   4 +-
5975ab
 grub-core/normal/autofs.c                    |  11 +-
5975ab
 grub-core/normal/crypto.c                    |   2 +-
5975ab
 grub-core/normal/dyncmd.c                    |   2 +-
5975ab
 grub-core/normal/main.c                      |   2 +-
5975ab
 grub-core/normal/term.c                      |   2 +-
5975ab
 grub-core/video/readers/jpeg.c               |   2 +-
5975ab
 grub-core/video/readers/png.c                |   2 +-
5975ab
 grub-core/video/readers/tga.c                |   2 +-
5975ab
 util/grub-fstest.c                           |   6 +-
5975ab
 util/grub-mount.c                            |   6 +-
5975ab
 include/grub/bufio.h                         |   4 +-
5975ab
 include/grub/elfload.h                       |   2 +-
5975ab
 include/grub/file.h                          | 152 +++++++++++++++++++--------
5975ab
 include/grub/machoload.h                     |   3 +-
5975ab
 70 files changed, 292 insertions(+), 221 deletions(-)
5975ab
5975ab
diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c
5975ab
index 9f02f22019a..5a1499aa0e3 100644
5975ab
--- a/grub-core/commands/acpi.c
5975ab
+++ b/grub-core/commands/acpi.c
5975ab
@@ -635,7 +635,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
5975ab
       grub_size_t size;
5975ab
       char *buf;
5975ab
 
5975ab
-      file = grub_file_open (args[i]);
5975ab
+      file = grub_file_open (args[i], GRUB_FILE_TYPE_ACPI_TABLE);
5975ab
       if (! file)
5975ab
 	{
5975ab
 	  free_tables ();
5975ab
diff --git a/grub-core/commands/blocklist.c b/grub-core/commands/blocklist.c
5975ab
index d1a47b504bf..944449b77d4 100644
5975ab
--- a/grub-core/commands/blocklist.c
5975ab
+++ b/grub-core/commands/blocklist.c
5975ab
@@ -121,8 +121,8 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
5975ab
   if (argc < 1)
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
5975ab
 
5975ab
-  grub_file_filter_disable_compression ();
5975ab
-  file = grub_file_open (args[0]);
5975ab
+  file = grub_file_open (args[0], GRUB_FILE_TYPE_PRINT_BLOCKLIST
5975ab
+			 | GRUB_FILE_TYPE_NO_DECOMPRESS);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/commands/cat.c b/grub-core/commands/cat.c
5975ab
index 88d90443602..ba5f0061aa5 100644
5975ab
--- a/grub-core/commands/cat.c
5975ab
+++ b/grub-core/commands/cat.c
5975ab
@@ -56,7 +56,7 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
5975ab
   if (argc != 1)
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
5975ab
 
5975ab
-  file = grub_file_open (args[0]);
5975ab
+  file = grub_file_open (args[0], GRUB_FILE_TYPE_CAT);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/commands/cmp.c b/grub-core/commands/cmp.c
5975ab
index cc23ee67ea3..e9c3b25d34c 100644
5975ab
--- a/grub-core/commands/cmp.c
5975ab
+++ b/grub-core/commands/cmp.c
5975ab
@@ -45,8 +45,8 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
5975ab
   grub_printf_ (N_("Compare file `%s' with `%s':\n"), args[0],
5975ab
 		args[1]);
5975ab
 
5975ab
-  file1 = grub_file_open (args[0]);
5975ab
-  file2 = grub_file_open (args[1]);
5975ab
+  file1 = grub_file_open (args[0], GRUB_FILE_TYPE_CMP);
5975ab
+  file2 = grub_file_open (args[1], GRUB_FILE_TYPE_CMP);
5975ab
   if (! file1 || ! file2)
5975ab
     goto cleanup;
5975ab
 
5975ab
diff --git a/grub-core/commands/efi/loadbios.c b/grub-core/commands/efi/loadbios.c
5975ab
index 132cadbc764..d41d521a4ae 100644
5975ab
--- a/grub-core/commands/efi/loadbios.c
5975ab
+++ b/grub-core/commands/efi/loadbios.c
5975ab
@@ -169,7 +169,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)),
5975ab
 
5975ab
   if (argc > 1)
5975ab
     {
5975ab
-      file = grub_file_open (argv[1]);
5975ab
+      file = grub_file_open (argv[1], GRUB_FILE_TYPE_VBE_DUMP);
5975ab
       if (! file)
5975ab
 	return grub_errno;
5975ab
 
5975ab
@@ -183,7 +183,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)),
5975ab
 	return grub_errno;
5975ab
     }
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_VBE_DUMP);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
5975ab
index 3ff6d5522d2..4f81aa1f9e1 100644
5975ab
--- a/grub-core/commands/file.c
5975ab
+++ b/grub-core/commands/file.c
5975ab
@@ -165,7 +165,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
5975ab
   if (type == -1)
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "no type specified");
5975ab
 
5975ab
-  file = grub_file_open (args[0]);
5975ab
+  file = grub_file_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL);
5975ab
   if (!file)
5975ab
     return grub_errno;
5975ab
   switch (type)
5975ab
@@ -546,7 +546,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
5975ab
     case IS_XNU64:
5975ab
     case IS_XNU32:
5975ab
       {
5975ab
-	macho = grub_macho_open (args[0], (type == IS_XNU64));
5975ab
+	macho = grub_macho_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL,
5975ab
+				 (type == IS_XNU64));
5975ab
 	if (!macho)
5975ab
 	  break;
5975ab
 	/* FIXME: more checks?  */
5975ab
diff --git a/grub-core/commands/hashsum.c b/grub-core/commands/hashsum.c
5975ab
index d18687351a5..456ba908b6f 100644
5975ab
--- a/grub-core/commands/hashsum.c
5975ab
+++ b/grub-core/commands/hashsum.c
5975ab
@@ -113,7 +113,7 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
5975ab
   if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
5975ab
     return grub_error (GRUB_ERR_BUG, "mdlen is too long");
5975ab
 
5975ab
-  hashlist = grub_file_open (hashfilename);
5975ab
+  hashlist = grub_file_open (hashfilename, GRUB_FILE_TYPE_HASHLIST);
5975ab
   if (!hashlist)
5975ab
     return grub_errno;
5975ab
   
5975ab
@@ -141,17 +141,15 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
5975ab
 	  filename = grub_xasprintf ("%s/%s", prefix, p);
5975ab
 	  if (!filename)
5975ab
 	    return grub_errno;
5975ab
-	  if (!uncompress)
5975ab
-	    grub_file_filter_disable_compression ();
5975ab
-	  file = grub_file_open (filename);
5975ab
+	  file = grub_file_open (filename, GRUB_FILE_TYPE_TO_HASH
5975ab
+				 | (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
5975ab
+				    : GRUB_FILE_TYPE_NONE));
5975ab
 	  grub_free (filename);
5975ab
 	}
5975ab
       else
5975ab
-	{
5975ab
-	  if (!uncompress)
5975ab
-	    grub_file_filter_disable_compression ();
5975ab
-	  file = grub_file_open (p);
5975ab
-	}
5975ab
+	file = grub_file_open (p, GRUB_FILE_TYPE_TO_HASH
5975ab
+			       | (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
5975ab
+				  : GRUB_FILE_TYPE_NONE));
5975ab
       if (!file)
5975ab
 	{
5975ab
 	  grub_file_close (hashlist);
5975ab
@@ -242,9 +240,9 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
5975ab
       grub_file_t file;
5975ab
       grub_err_t err;
5975ab
       unsigned j;
5975ab
-      if (!uncompress)
5975ab
-	grub_file_filter_disable_compression ();
5975ab
-      file = grub_file_open (args[i]);
5975ab
+      file = grub_file_open (args[i], GRUB_FILE_TYPE_TO_HASH
5975ab
+			     | (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
5975ab
+				: GRUB_FILE_TYPE_NONE));
5975ab
       if (!file)
5975ab
 	{
5975ab
 	  if (!keep)
5975ab
diff --git a/grub-core/commands/hexdump.c b/grub-core/commands/hexdump.c
5975ab
index 4c884b3a19a..eaa12465bb3 100644
5975ab
--- a/grub-core/commands/hexdump.c
5975ab
+++ b/grub-core/commands/hexdump.c
5975ab
@@ -90,7 +90,7 @@ grub_cmd_hexdump (grub_extcmd_context_t ctxt, int argc, char **args)
5975ab
     {
5975ab
       grub_file_t file;
5975ab
 
5975ab
-      file = grub_file_open (args[0]);
5975ab
+      file = grub_file_open (args[0], GRUB_FILE_TYPE_HEXCAT);
5975ab
       if (! file)
5975ab
 	return 0;
5975ab
 
5975ab
diff --git a/grub-core/commands/i386/pc/play.c b/grub-core/commands/i386/pc/play.c
5975ab
index 7712e2a36a1..c8181310515 100644
5975ab
--- a/grub-core/commands/i386/pc/play.c
5975ab
+++ b/grub-core/commands/i386/pc/play.c
5975ab
@@ -93,7 +93,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
5975ab
       grub_uint32_t tempo;
5975ab
       grub_file_t file;
5975ab
 
5975ab
-      file = grub_file_open (args[0]);
5975ab
+      file = grub_file_open (args[0], GRUB_FILE_TYPE_AUDIO);
5975ab
 
5975ab
       if (! file)
5975ab
         return grub_errno;
5975ab
diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c
5975ab
index f35d3a369ba..c05d6128a6d 100644
5975ab
--- a/grub-core/commands/keylayouts.c
5975ab
+++ b/grub-core/commands/keylayouts.c
5975ab
@@ -220,7 +220,7 @@ grub_cmd_keymap (struct grub_command *cmd __attribute__ ((unused)),
5975ab
   else
5975ab
     filename = argv[0];
5975ab
 
5975ab
-  file = grub_file_open (filename);
5975ab
+  file = grub_file_open (filename, GRUB_FILE_TYPE_KEYBOARD_LAYOUT);
5975ab
   if (! file)
5975ab
     goto fail;
5975ab
 
5975ab
diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c
5975ab
index 0de070eacc4..f5696a51a75 100644
5975ab
--- a/grub-core/commands/legacycfg.c
5975ab
+++ b/grub-core/commands/legacycfg.c
5975ab
@@ -56,7 +56,7 @@ legacy_file (const char *filename)
5975ab
   if (!suffix)
5975ab
     return grub_errno;
5975ab
 
5975ab
-  file = grub_file_open (filename);
5975ab
+  file = grub_file_open (filename, GRUB_FILE_TYPE_CONFIG);
5975ab
   if (! file)
5975ab
     {
5975ab
       grub_free (suffix);
5975ab
diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c
5975ab
index 91c99456091..163b9a09042 100644
5975ab
--- a/grub-core/commands/loadenv.c
5975ab
+++ b/grub-core/commands/loadenv.c
5975ab
@@ -46,7 +46,8 @@ static const struct grub_arg_option options[] =
5975ab
    PUBKEY filter (that insists upon properly signed files) as well.  PUBKEY
5975ab
    filter is restored before the function returns. */
5975ab
 static grub_file_t
5975ab
-open_envblk_file (char *filename, int untrusted)
5975ab
+open_envblk_file (char *filename,
5975ab
+		  enum grub_file_type type)
5975ab
 {
5975ab
   grub_file_t file;
5975ab
   char *buf = 0;
5975ab
@@ -74,13 +75,7 @@ open_envblk_file (char *filename, int untrusted)
5975ab
       grub_strcpy (filename + len + 1, GRUB_ENVBLK_DEFCFG);
5975ab
     }
5975ab
 
5975ab
-  /* The filters that are disabled will be re-enabled by the call to
5975ab
-     grub_file_open() after this particular file is opened. */
5975ab
-  grub_file_filter_disable_compression ();
5975ab
-  if (untrusted)
5975ab
-    grub_file_filter_disable_pubkey ();
5975ab
-
5975ab
-  file = grub_file_open (filename);
5975ab
+  file = grub_file_open (filename, type);
5975ab
 
5975ab
   grub_free (buf);
5975ab
   return file;
5975ab
@@ -98,7 +93,10 @@ grub_cmd_load_env (grub_extcmd_context_t ctxt, int argc, char **args)
5975ab
   whitelist.list = args;
5975ab
 
5975ab
   /* state[0] is the -f flag; state[1] is the --skip-sig flag */
5975ab
-  file = open_envblk_file ((state[0].set) ? state[0].arg : 0, state[1].set);
5975ab
+  file = open_envblk_file ((state[0].set) ? state[0].arg : 0,
5975ab
+			   GRUB_FILE_TYPE_LOADENV
5975ab
+			   | (state[1].set
5975ab
+			      ? GRUB_FILE_TYPE_SKIP_SIGNATURE : GRUB_FILE_TYPE_NONE));
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
@@ -133,7 +131,10 @@ grub_cmd_list_env (grub_extcmd_context_t ctxt,
5975ab
   grub_file_t file;
5975ab
   grub_envblk_t envblk;
5975ab
 
5975ab
-  file = open_envblk_file ((state[0].set) ? state[0].arg : 0, 0);
5975ab
+  file = open_envblk_file ((state[0].set) ? state[0].arg : 0,
5975ab
+			   GRUB_FILE_TYPE_LOADENV
5975ab
+			   | (state[1].set
5975ab
+			      ? GRUB_FILE_TYPE_SKIP_SIGNATURE : GRUB_FILE_TYPE_NONE));
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
@@ -317,7 +318,8 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args)
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "no variable is specified");
5975ab
 
5975ab
   file = open_envblk_file ((state[0].set) ? state[0].arg : 0,
5975ab
-                           1 /* allow untrusted */);
5975ab
+			   GRUB_FILE_TYPE_SAVEENV
5975ab
+			   | GRUB_FILE_TYPE_SKIP_SIGNATURE);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
5975ab
index c25161cc4f2..2cdb2acc552 100644
5975ab
--- a/grub-core/commands/ls.c
5975ab
+++ b/grub-core/commands/ls.c
5975ab
@@ -129,8 +129,8 @@ print_files_long (const char *filename, const struct grub_dirhook_info *info,
5975ab
 
5975ab
       /* XXX: For ext2fs symlinks are detected as files while they
5975ab
 	 should be reported as directories.  */
5975ab
-      grub_file_filter_disable_compression ();
5975ab
-      file = grub_file_open (pathname);
5975ab
+      file = grub_file_open (pathname, GRUB_FILE_TYPE_GET_SIZE
5975ab
+			     | GRUB_FILE_TYPE_NO_DECOMPRESS);
5975ab
       if (! file)
5975ab
 	{
5975ab
 	  grub_errno = 0;
5975ab
@@ -234,8 +234,8 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
5975ab
 	  struct grub_dirhook_info info;
5975ab
 	  grub_errno = 0;
5975ab
 
5975ab
-	  grub_file_filter_disable_compression ();
5975ab
-	  file = grub_file_open (dirname);
5975ab
+	  file = grub_file_open (dirname, GRUB_FILE_TYPE_GET_SIZE
5975ab
+				 | GRUB_FILE_TYPE_NO_DECOMPRESS);
5975ab
 	  if (! file)
5975ab
 	    goto fail;
5975ab
 
5975ab
diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c
5975ab
index b25ca4b9f17..46bf135e8f0 100644
5975ab
--- a/grub-core/commands/minicmd.c
5975ab
+++ b/grub-core/commands/minicmd.c
5975ab
@@ -43,7 +43,7 @@ grub_mini_cmd_cat (struct grub_command *cmd __attribute__ ((unused)),
5975ab
   if (argc < 1)
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_CAT);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c
5975ab
index d69214f6de0..f200a5ce092 100644
5975ab
--- a/grub-core/commands/nativedisk.c
5975ab
+++ b/grub-core/commands/nativedisk.c
5975ab
@@ -242,7 +242,8 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
5975ab
       if (! filename)
5975ab
 	goto fail;
5975ab
 
5975ab
-      file = grub_file_open (filename);
5975ab
+      file = grub_file_open (filename,
5975ab
+			     GRUB_FILE_TYPE_GRUB_MODULE);
5975ab
       grub_free (filename);
5975ab
       if (! file)
5975ab
 	goto fail;
5975ab
diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c
5975ab
index 36dadc0b1db..051e31320e9 100644
5975ab
--- a/grub-core/commands/parttool.c
5975ab
+++ b/grub-core/commands/parttool.c
5975ab
@@ -199,7 +199,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
5975ab
 	  {
5975ab
 	    grub_file_t file;
5975ab
 
5975ab
-	    file = grub_file_open (filename);
5975ab
+	    file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
5975ab
 	    if (file)
5975ab
 	      {
5975ab
 		char *buf = 0;
5975ab
diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c
5975ab
index 7dd32e445c9..ddda6e7c590 100644
5975ab
--- a/grub-core/commands/search.c
5975ab
+++ b/grub-core/commands/search.c
5975ab
@@ -81,8 +81,8 @@ iterate_device (const char *name, void *data)
5975ab
       if (! buf)
5975ab
 	return 1;
5975ab
 
5975ab
-      grub_file_filter_disable_compression ();
5975ab
-      file = grub_file_open (buf);
5975ab
+      file = grub_file_open (buf, GRUB_FILE_TYPE_FS_SEARCH
5975ab
+			     | GRUB_FILE_TYPE_NO_DECOMPRESS);
5975ab
       if (file)
5975ab
 	{
5975ab
 	  found = 1;
5975ab
diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c
5975ab
index 5f06642f6c6..13c6ed9534a 100644
5975ab
--- a/grub-core/commands/test.c
5975ab
+++ b/grub-core/commands/test.c
5975ab
@@ -355,8 +355,8 @@ test_parse (char **args, int *argn, int argc)
5975ab
 	  if (grub_strcmp (args[*argn], "-s") == 0)
5975ab
 	    {
5975ab
 	      grub_file_t file;
5975ab
-	      grub_file_filter_disable_compression ();
5975ab
-	      file = grub_file_open (args[*argn + 1]);
5975ab
+	      file = grub_file_open (args[*argn + 1], GRUB_FILE_TYPE_GET_SIZE
5975ab
+				     | GRUB_FILE_TYPE_NO_DECOMPRESS);
5975ab
 	      update_val (file && (grub_file_size (file) != 0), &ctx;;
5975ab
 	      if (file)
5975ab
 		grub_file_close (file);
5975ab
diff --git a/grub-core/commands/testload.c b/grub-core/commands/testload.c
5975ab
index cfab6763dc3..ff01a0516dd 100644
5975ab
--- a/grub-core/commands/testload.c
5975ab
+++ b/grub-core/commands/testload.c
5975ab
@@ -57,7 +57,7 @@ grub_cmd_testload (struct grub_command *cmd __attribute__ ((unused)),
5975ab
   if (argc < 1)
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_TESTLOAD);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/commands/testspeed.c b/grub-core/commands/testspeed.c
5975ab
index 042645f8d26..c13a9b8d8d2 100644
5975ab
--- a/grub-core/commands/testspeed.c
5975ab
+++ b/grub-core/commands/testspeed.c
5975ab
@@ -61,7 +61,7 @@ grub_cmd_testspeed (grub_extcmd_context_t ctxt, int argc, char **args)
5975ab
   if (buffer == NULL)
5975ab
     return grub_errno;
5975ab
 
5975ab
-  file = grub_file_open (args[0]);
5975ab
+  file = grub_file_open (args[0], GRUB_FILE_TYPE_TESTLOAD);
5975ab
   if (file == NULL)
5975ab
     goto quit;
5975ab
 
5975ab
diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c
5975ab
index 67cb1c78509..f0dfeceebd4 100644
5975ab
--- a/grub-core/commands/verify.c
5975ab
+++ b/grub-core/commands/verify.c
5975ab
@@ -680,10 +680,12 @@ grub_cmd_trust (grub_extcmd_context_t ctxt,
5975ab
   if (argc < 1)
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
5975ab
 
5975ab
-  grub_file_filter_disable_compression ();
5975ab
-  if (ctxt->state[OPTION_SKIP_SIG].set)
5975ab
-    grub_file_filter_disable_pubkey ();
5975ab
-  pkf = grub_file_open (args[0]);
5975ab
+  pkf = grub_file_open (args[0],
5975ab
+			GRUB_FILE_TYPE_PUBLIC_KEY_TRUST
5975ab
+			| GRUB_FILE_TYPE_NO_DECOMPRESS
5975ab
+			| (ctxt->state[OPTION_SKIP_SIG].set
5975ab
+			   ? GRUB_FILE_TYPE_SKIP_SIGNATURE
5975ab
+			   : GRUB_FILE_TYPE_NONE));
5975ab
   if (!pkf)
5975ab
     return grub_errno;
5975ab
   pk = grub_load_public_key (pkf);
5975ab
@@ -771,10 +773,12 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
5975ab
   if (argc > 2)
5975ab
     {
5975ab
       grub_file_t pkf;
5975ab
-      grub_file_filter_disable_compression ();
5975ab
-      if (ctxt->state[OPTION_SKIP_SIG].set)
5975ab
-	grub_file_filter_disable_pubkey ();
5975ab
-      pkf = grub_file_open (args[2]);
5975ab
+      pkf = grub_file_open (args[2],
5975ab
+			    GRUB_FILE_TYPE_PUBLIC_KEY
5975ab
+			    | GRUB_FILE_TYPE_NO_DECOMPRESS
5975ab
+			    | (ctxt->state[OPTION_SKIP_SIG].set
5975ab
+			       ? GRUB_FILE_TYPE_SKIP_SIGNATURE
5975ab
+			       : GRUB_FILE_TYPE_NONE));
5975ab
       if (!pkf)
5975ab
 	return grub_errno;
5975ab
       pk = grub_load_public_key (pkf);
5975ab
@@ -786,16 +790,16 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
5975ab
       grub_file_close (pkf);
5975ab
     }
5975ab
 
5975ab
-  grub_file_filter_disable_all ();
5975ab
-  f = grub_file_open (args[0]);
5975ab
+  f = grub_file_open (args[0], GRUB_FILE_TYPE_VERIFY_SIGNATURE);
5975ab
   if (!f)
5975ab
     {
5975ab
       err = grub_errno;
5975ab
       goto fail;
5975ab
     }
5975ab
 
5975ab
-  grub_file_filter_disable_all ();
5975ab
-  sig = grub_file_open (args[1]);
5975ab
+  sig = grub_file_open (args[1],
5975ab
+			GRUB_FILE_TYPE_SIGNATURE
5975ab
+			| GRUB_FILE_TYPE_NO_DECOMPRESS);
5975ab
   if (!sig)
5975ab
     {
5975ab
       err = grub_errno;
5975ab
@@ -858,33 +862,32 @@ struct grub_fs verified_fs =
5975ab
 };
5975ab
 
5975ab
 static grub_file_t
5975ab
-grub_pubkey_open (grub_file_t io, const char *filename)
5975ab
+grub_pubkey_open (grub_file_t io, enum grub_file_type type)
5975ab
 {
5975ab
   grub_file_t sig;
5975ab
   char *fsuf, *ptr;
5975ab
   grub_err_t err;
5975ab
-  grub_file_filter_t curfilt[GRUB_FILE_FILTER_MAX];
5975ab
   grub_file_t ret;
5975ab
   grub_verified_t verified;
5975ab
 
5975ab
+  if ((type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_SIGNATURE
5975ab
+      || (type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_VERIFY_SIGNATURE
5975ab
+      || (type & GRUB_FILE_TYPE_SKIP_SIGNATURE))
5975ab
+    return io;
5975ab
+
5975ab
   if (!sec)
5975ab
     return io;
5975ab
   if (io->device->disk && 
5975ab
       (io->device->disk->dev->id == GRUB_DISK_DEVICE_MEMDISK_ID
5975ab
        || io->device->disk->dev->id == GRUB_DISK_DEVICE_PROCFS_ID))
5975ab
     return io;
5975ab
-  fsuf = grub_malloc (grub_strlen (filename) + sizeof (".sig"));
5975ab
+  fsuf = grub_malloc (grub_strlen (io->name) + sizeof (".sig"));
5975ab
   if (!fsuf)
5975ab
     return NULL;
5975ab
-  ptr = grub_stpcpy (fsuf, filename);
5975ab
+  ptr = grub_stpcpy (fsuf, io->name);
5975ab
   grub_memcpy (ptr, ".sig", sizeof (".sig"));
5975ab
 
5975ab
-  grub_memcpy (curfilt, grub_file_filters_enabled,
5975ab
-	       sizeof (curfilt));
5975ab
-  grub_file_filter_disable_all ();
5975ab
-  sig = grub_file_open (fsuf);
5975ab
-  grub_memcpy (grub_file_filters_enabled, curfilt,
5975ab
-	       sizeof (curfilt));
5975ab
+  sig = grub_file_open (fsuf, GRUB_FILE_TYPE_SIGNATURE);
5975ab
   grub_free (fsuf);
5975ab
   if (!sig)
5975ab
     return NULL;
5975ab
@@ -918,7 +921,7 @@ grub_pubkey_open (grub_file_t io, const char *filename)
5975ab
   if (!verified->buf)
5975ab
     {
5975ab
       grub_file_close (sig);
5975ab
-      grub_free (verified);
5975ab
+      verified_free (verified);
5975ab
       grub_free (ret);
5975ab
       return NULL;
5975ab
     }
5975ab
@@ -926,7 +929,7 @@ grub_pubkey_open (grub_file_t io, const char *filename)
5975ab
     {
5975ab
       if (!grub_errno)
5975ab
 	grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
5975ab
-		    filename);
5975ab
+		    io->name);
5975ab
       grub_file_close (sig);
5975ab
       verified_free (verified);
5975ab
       grub_free (ret);
5975ab
diff --git a/grub-core/disk/loopback.c b/grub-core/disk/loopback.c
5975ab
index 2d8deaeafbd..9406d931cdd 100644
5975ab
--- a/grub-core/disk/loopback.c
5975ab
+++ b/grub-core/disk/loopback.c
5975ab
@@ -92,7 +92,8 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
5975ab
   if (argc < 2)
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
5975ab
 
5975ab
-  file = grub_file_open (args[1]);
5975ab
+  file = grub_file_open (args[1], GRUB_FILE_TYPE_LOOPBACK
5975ab
+			 | GRUB_FILE_TYPE_NO_DECOMPRESS);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c
5975ab
index f6813b1ed15..a81934725be 100644
5975ab
--- a/grub-core/efiemu/main.c
5975ab
+++ b/grub-core/efiemu/main.c
5975ab
@@ -187,7 +187,7 @@ grub_efiemu_load_file (const char *filename)
5975ab
   grub_file_t file;
5975ab
   grub_err_t err;
5975ab
 
5975ab
-  file = grub_file_open (filename);
5975ab
+  file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/font/font.c b/grub-core/font/font.c
5975ab
index b36a099b856..b67507fcc82 100644
5975ab
--- a/grub-core/font/font.c
5975ab
+++ b/grub-core/font/font.c
5975ab
@@ -422,7 +422,7 @@ grub_font_load (const char *filename)
5975ab
 #endif
5975ab
 
5975ab
   if (filename[0] == '(' || filename[0] == '/' || filename[0] == '+')
5975ab
-    file = grub_buffile_open (filename, 1024);
5975ab
+    file = grub_buffile_open (filename, GRUB_FILE_TYPE_FONT, 1024);
5975ab
   else
5975ab
     {
5975ab
       const char *prefix = grub_env_get ("prefix");
5975ab
@@ -442,7 +442,7 @@ grub_font_load (const char *filename)
5975ab
       ptr = grub_stpcpy (ptr, filename);
5975ab
       ptr = grub_stpcpy (ptr, ".pf2");
5975ab
       *ptr = 0;
5975ab
-      file = grub_buffile_open (fullname, 1024);
5975ab
+      file = grub_buffile_open (fullname, GRUB_FILE_TYPE_FONT, 1024);
5975ab
       grub_free (fullname);
5975ab
     }
5975ab
   if (!file)
5975ab
diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c
5975ab
index f8488c35344..de3b015f582 100644
5975ab
--- a/grub-core/fs/zfs/zfscrypt.c
5975ab
+++ b/grub-core/fs/zfs/zfscrypt.c
5975ab
@@ -430,7 +430,7 @@ grub_cmd_zfs_key (grub_extcmd_context_t ctxt, int argc, char **args)
5975ab
   if (argc > 0)
5975ab
     {
5975ab
       grub_file_t file;
5975ab
-      file = grub_file_open (args[0]);
5975ab
+      file = grub_file_open (args[0], GRUB_FILE_TYPE_ZFS_ENCRYPTION_KEY);
5975ab
       if (!file)
5975ab
 	return grub_errno;
5975ab
       real_size = grub_file_read (file, buf, 1024);
5975ab
diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c
5975ab
index b22e1bcc94b..84d520cd494 100644
5975ab
--- a/grub-core/gettext/gettext.c
5975ab
+++ b/grub-core/gettext/gettext.c
5975ab
@@ -291,7 +291,7 @@ grub_mofile_open (struct grub_gettext_context *ctx,
5975ab
   /* Using fd_mo and not another variable because
5975ab
      it's needed for grub_gettext_get_info.  */
5975ab
 
5975ab
-  fd = grub_file_open (filename);
5975ab
+  fd = grub_file_open (filename, GRUB_FILE_TYPE_GETTEXT_CATALOG);
5975ab
 
5975ab
   if (!fd)
5975ab
     return grub_errno;
5975ab
diff --git a/grub-core/gfxmenu/theme_loader.c b/grub-core/gfxmenu/theme_loader.c
5975ab
index 02978392ccc..d6829bb5e90 100644
5975ab
--- a/grub-core/gfxmenu/theme_loader.c
5975ab
+++ b/grub-core/gfxmenu/theme_loader.c
5975ab
@@ -743,7 +743,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
5975ab
   p.view = view;
5975ab
   p.theme_dir = grub_get_dirname (theme_path);
5975ab
 
5975ab
-  file = grub_file_open (theme_path);
5975ab
+  file = grub_file_open (theme_path, GRUB_FILE_TYPE_THEME);
5975ab
   if (! file)
5975ab
     {
5975ab
       grub_free (p.theme_dir);
5975ab
diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c
5975ab
index 2781afe0515..0dbac1b3a1e 100644
5975ab
--- a/grub-core/io/bufio.c
5975ab
+++ b/grub-core/io/bufio.c
5975ab
@@ -88,11 +88,11 @@ grub_bufio_open (grub_file_t io, grub_size_t size)
5975ab
 }
5975ab
 
5975ab
 grub_file_t
5975ab
-grub_buffile_open (const char *name, grub_size_t size)
5975ab
+grub_buffile_open (const char *name, enum grub_file_type type, grub_size_t size)
5975ab
 {
5975ab
   grub_file_t io, file;
5975ab
 
5975ab
-  io = grub_file_open (name);
5975ab
+  io = grub_file_open (name, type);
5975ab
   if (! io)
5975ab
     return 0;
5975ab
 
5975ab
diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c
5975ab
index 7024cda84ea..2ecf076dd5e 100644
5975ab
--- a/grub-core/io/gzio.c
5975ab
+++ b/grub-core/io/gzio.c
5975ab
@@ -1156,11 +1156,14 @@ initialize_tables (grub_gzio_t gzio)
5975ab
    even if IO does not contain data compressed by gzip, return a valid file
5975ab
    object. Note that this function won't close IO, even if an error occurs.  */
5975ab
 static grub_file_t
5975ab
-grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused)))
5975ab
+grub_gzio_open (grub_file_t io, enum grub_file_type type)
5975ab
 {
5975ab
   grub_file_t file;
5975ab
   grub_gzio_t gzio = 0;
5975ab
 
5975ab
+  if (type & GRUB_FILE_TYPE_NO_DECOMPRESS)
5975ab
+    return io;
5975ab
+
5975ab
   file = (grub_file_t) grub_zalloc (sizeof (*file));
5975ab
   if (! file)
5975ab
     return 0;
5975ab
diff --git a/grub-core/io/lzopio.c b/grub-core/io/lzopio.c
5975ab
index 7559c6c9cab..84edf6dd2dc 100644
5975ab
--- a/grub-core/io/lzopio.c
5975ab
+++ b/grub-core/io/lzopio.c
5975ab
@@ -407,12 +407,14 @@ CORRUPTED:
5975ab
 }
5975ab
 
5975ab
 static grub_file_t
5975ab
-grub_lzopio_open (grub_file_t io,
5975ab
-		  const char *name __attribute__ ((unused)))
5975ab
+grub_lzopio_open (grub_file_t io, enum grub_file_type type)
5975ab
 {
5975ab
   grub_file_t file;
5975ab
   grub_lzopio_t lzopio;
5975ab
 
5975ab
+  if (type & GRUB_FILE_TYPE_NO_DECOMPRESS)
5975ab
+    return io;
5975ab
+
5975ab
   file = (grub_file_t) grub_zalloc (sizeof (*file));
5975ab
   if (!file)
5975ab
     return 0;
5975ab
diff --git a/grub-core/io/offset.c b/grub-core/io/offset.c
5975ab
index ebed0ebe63e..ec8e2320871 100644
5975ab
--- a/grub-core/io/offset.c
5975ab
+++ b/grub-core/io/offset.c
5975ab
@@ -69,7 +69,8 @@ grub_file_offset_close (grub_file_t file)
5975ab
 }
5975ab
 
5975ab
 grub_file_t
5975ab
-grub_file_offset_open (grub_file_t parent, grub_off_t start, grub_off_t size)
5975ab
+grub_file_offset_open (grub_file_t parent, enum grub_file_type type,
5975ab
+		       grub_off_t start, grub_off_t size)
5975ab
 {
5975ab
   struct grub_offset_file *off_data;
5975ab
   grub_file_t off_file, last_off_file;
5975ab
@@ -95,10 +96,10 @@ grub_file_offset_open (grub_file_t parent, grub_off_t start, grub_off_t size)
5975ab
   last_off_file = NULL;
5975ab
   for (filter = GRUB_FILE_FILTER_COMPRESSION_FIRST;
5975ab
        off_file && filter <= GRUB_FILE_FILTER_COMPRESSION_LAST; filter++)
5975ab
-    if (grub_file_filters_enabled[filter])
5975ab
+    if (grub_file_filters[filter])
5975ab
       {
5975ab
 	last_off_file = off_file;
5975ab
-	off_file = grub_file_filters_enabled[filter] (off_file, parent->name);
5975ab
+	off_file = grub_file_filters[filter] (off_file, type);
5975ab
       }
5975ab
 
5975ab
   if (!off_file)
5975ab
diff --git a/grub-core/io/xzio.c b/grub-core/io/xzio.c
5975ab
index a3536ad73b1..42afeedcd64 100644
5975ab
--- a/grub-core/io/xzio.c
5975ab
+++ b/grub-core/io/xzio.c
5975ab
@@ -169,12 +169,14 @@ ERROR:
5975ab
 }
5975ab
 
5975ab
 static grub_file_t
5975ab
-grub_xzio_open (grub_file_t io,
5975ab
-		const char *name __attribute__ ((unused)))
5975ab
+grub_xzio_open (grub_file_t io, enum grub_file_type type)
5975ab
 {
5975ab
   grub_file_t file;
5975ab
   grub_xzio_t xzio;
5975ab
 
5975ab
+  if (type & GRUB_FILE_TYPE_NO_DECOMPRESS)
5975ab
+    return io;
5975ab
+
5975ab
   file = (grub_file_t) grub_zalloc (sizeof (*file));
5975ab
   if (!file)
5975ab
     return 0;
5975ab
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
5975ab
index 91105bc4677..d7a7c8f97b0 100644
5975ab
--- a/grub-core/kern/dl.c
5975ab
+++ b/grub-core/kern/dl.c
5975ab
@@ -806,7 +806,7 @@ grub_dl_load_file (const char *filename)
5975ab
 
5975ab
   grub_boot_time ("Loading module %s", filename);
5975ab
 
5975ab
-  file = grub_file_open (filename);
5975ab
+  file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE);
5975ab
   if (! file)
5975ab
     return 0;
5975ab
 
5975ab
diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c
5975ab
index 4f282c9cf43..9d7149b3892 100644
5975ab
--- a/grub-core/kern/elf.c
5975ab
+++ b/grub-core/kern/elf.c
5975ab
@@ -136,12 +136,12 @@ fail:
5975ab
 }
5975ab
 
5975ab
 grub_elf_t
5975ab
-grub_elf_open (const char *name)
5975ab
+grub_elf_open (const char *name, enum grub_file_type type)
5975ab
 {
5975ab
   grub_file_t file;
5975ab
   grub_elf_t elf;
5975ab
 
5975ab
-  file = grub_file_open (name);
5975ab
+  file = grub_file_open (name, type);
5975ab
   if (! file)
5975ab
     return 0;
5975ab
 
5975ab
diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c
5975ab
index c2d9a550007..2efc31da94f 100644
5975ab
--- a/grub-core/kern/file.c
5975ab
+++ b/grub-core/kern/file.c
5975ab
@@ -28,8 +28,7 @@
5975ab
 
5975ab
 void (*EXPORT_VAR (grub_grubnet_fini)) (void);
5975ab
 
5975ab
-grub_file_filter_t grub_file_filters_all[GRUB_FILE_FILTER_MAX];
5975ab
-grub_file_filter_t grub_file_filters_enabled[GRUB_FILE_FILTER_MAX];
5975ab
+grub_file_filter_t grub_file_filters[GRUB_FILE_FILTER_MAX];
5975ab
 
5975ab
 /* Get the device part of the filename NAME. It is enclosed by parentheses.  */
5975ab
 char *
5975ab
@@ -59,7 +58,7 @@ grub_file_get_device_name (const char *name)
5975ab
 }
5975ab
 
5975ab
 grub_file_t
5975ab
-grub_file_open (const char *name)
5975ab
+grub_file_open (const char *name, enum grub_file_type type)
5975ab
 {
5975ab
   grub_device_t device = 0;
5975ab
   grub_file_t file = 0, last_file = 0;
5975ab
@@ -116,18 +115,20 @@ grub_file_open (const char *name)
5975ab
   file->name = grub_strdup (name);
5975ab
   grub_errno = GRUB_ERR_NONE;
5975ab
 
5975ab
-  for (filter = 0; file && filter < ARRAY_SIZE (grub_file_filters_enabled);
5975ab
+  for (filter = 0; file && filter < ARRAY_SIZE (grub_file_filters);
5975ab
        filter++)
5975ab
-    if (grub_file_filters_enabled[filter])
5975ab
+    if (grub_file_filters[filter])
5975ab
       {
5975ab
 	last_file = file;
5975ab
-	file = grub_file_filters_enabled[filter] (file, name);
5975ab
+	file = grub_file_filters[filter] (file, type);
5975ab
+	if (file && file != last_file)
5975ab
+	  {
5975ab
+	    file->name = grub_strdup (name);
5975ab
+	    grub_errno = GRUB_ERR_NONE;
5975ab
+	  }
5975ab
       }
5975ab
   if (!file)
5975ab
     grub_file_close (last_file);
5975ab
-    
5975ab
-  grub_memcpy (grub_file_filters_enabled, grub_file_filters_all,
5975ab
-	       sizeof (grub_file_filters_enabled));
5975ab
 
5975ab
   grub_dprintf ("file", "Opening `%s' succeeded.\n", name);
5975ab
 
5975ab
@@ -141,9 +142,6 @@ grub_file_open (const char *name)
5975ab
 
5975ab
   grub_free (file);
5975ab
 
5975ab
-  grub_memcpy (grub_file_filters_enabled, grub_file_filters_all,
5975ab
-	       sizeof (grub_file_filters_enabled));
5975ab
-
5975ab
   grub_dprintf ("file", "Opening `%s' failed.\n", name);
5975ab
 
5975ab
   return 0;
5975ab
diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c
5975ab
index 21ca040ada7..83e7bdb9161 100644
5975ab
--- a/grub-core/lib/syslinux_parse.c
5975ab
+++ b/grub-core/lib/syslinux_parse.c
5975ab
@@ -696,7 +696,7 @@ syslinux_parse_real (struct syslinux_menu *menu)
5975ab
   char *buf = NULL;
5975ab
   grub_err_t err = GRUB_ERR_NONE;
5975ab
 
5975ab
-  file = grub_file_open (menu->filename);
5975ab
+  file = grub_file_open (menu->filename, GRUB_FILE_TYPE_CONFIG);
5975ab
   if (!file)
5975ab
     return grub_errno;
5975ab
   while ((grub_free (buf), buf = grub_file_getline (file)))
5975ab
diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
5975ab
index a93edc975cd..29663f71801 100644
5975ab
--- a/grub-core/loader/efi/chainloader.c
5975ab
+++ b/grub-core/loader/efi/chainloader.c
5975ab
@@ -941,7 +941,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
5975ab
       *(--p16) = 0;
5975ab
     }
5975ab
 
5975ab
-  file = grub_file_open (filename);
5975ab
+  file = grub_file_open (filename, GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE);
5975ab
   if (! file)
5975ab
     goto fail;
5975ab
 
5975ab
diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c
5975ab
index 0f317632a3b..8306b415abd 100644
5975ab
--- a/grub-core/loader/i386/bsd.c
5975ab
+++ b/grub-core/loader/i386/bsd.c
5975ab
@@ -1464,7 +1464,7 @@ grub_bsd_load (int argc, char *argv[])
5975ab
       goto fail;
5975ab
     }
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL);
5975ab
   if (!file)
5975ab
     goto fail;
5975ab
 
5975ab
@@ -1541,7 +1541,7 @@ grub_cmd_freebsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
5975ab
 	  if (err)
5975ab
 	    return err;
5975ab
 
5975ab
-	  file = grub_file_open (argv[0]);
5975ab
+	  file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL);
5975ab
 	  if (! file)
5975ab
 	    return grub_errno;
5975ab
 
5975ab
@@ -1700,7 +1700,7 @@ grub_cmd_netbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
5975ab
 	{
5975ab
 	  grub_file_t file;
5975ab
 
5975ab
-	  file = grub_file_open (argv[0]);
5975ab
+	  file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL);
5975ab
 	  if (! file)
5975ab
 	    return grub_errno;
5975ab
 
5975ab
@@ -1809,7 +1809,7 @@ grub_cmd_freebsd_loadenv (grub_command_t cmd __attribute__ ((unused)),
5975ab
       goto fail;
5975ab
     }
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_ENV);
5975ab
   if ((!file) || (!file->size))
5975ab
     goto fail;
5975ab
 
5975ab
@@ -1914,7 +1914,7 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)),
5975ab
       return 0;
5975ab
     }
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_MODULE);
5975ab
   if ((!file) || (!file->size))
5975ab
     goto fail;
5975ab
 
5975ab
@@ -1965,7 +1965,7 @@ grub_netbsd_module_load (char *filename, grub_uint32_t type)
5975ab
   void *src;
5975ab
   grub_err_t err;
5975ab
 
5975ab
-  file = grub_file_open (filename);
5975ab
+  file = grub_file_open (filename, GRUB_FILE_TYPE_NETBSD_MODULE);
5975ab
   if ((!file) || (!file->size))
5975ab
     goto fail;
5975ab
 
5975ab
@@ -2055,7 +2055,7 @@ grub_cmd_freebsd_module_elf (grub_command_t cmd __attribute__ ((unused)),
5975ab
       return 0;
5975ab
     }
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_MODULE_ELF);
5975ab
   if (!file)
5975ab
     return grub_errno;
5975ab
   if (!file->size)
5975ab
@@ -2095,7 +2095,7 @@ grub_cmd_openbsd_ramdisk (grub_command_t cmd __attribute__ ((unused)),
5975ab
   if (!openbsd_ramdisk.max_size)
5975ab
     return grub_error (GRUB_ERR_BAD_OS, "your kOpenBSD doesn't support ramdisk");
5975ab
 
5975ab
-  file = grub_file_open (args[0]);
5975ab
+  file = grub_file_open (args[0], GRUB_FILE_TYPE_OPENBSD_RAMDISK);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/loader/i386/coreboot/chainloader.c b/grub-core/loader/i386/coreboot/chainloader.c
5975ab
index 2cb78eee090..0a19ebb9c3e 100644
5975ab
--- a/grub-core/loader/i386/coreboot/chainloader.c
5975ab
+++ b/grub-core/loader/i386/coreboot/chainloader.c
5975ab
@@ -439,7 +439,7 @@ grub_cmd_chain (grub_command_t cmd __attribute__ ((unused)),
5975ab
 
5975ab
   grub_loader_unset ();
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_COREBOOT_CHAINLOADER);
5975ab
   if (!file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
5975ab
index 191f1631e88..aa2cbc4e7eb 100644
5975ab
--- a/grub-core/loader/i386/linux.c
5975ab
+++ b/grub-core/loader/i386/linux.c
5975ab
@@ -709,7 +709,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
5975ab
       goto fail;
5975ab
     }
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
5975ab
   if (! file)
5975ab
     goto fail;
5975ab
 
5975ab
diff --git a/grub-core/loader/i386/pc/chainloader.c b/grub-core/loader/i386/pc/chainloader.c
5975ab
index ef3a322b78c..976fea73ab5 100644
5975ab
--- a/grub-core/loader/i386/pc/chainloader.c
5975ab
+++ b/grub-core/loader/i386/pc/chainloader.c
5975ab
@@ -172,8 +172,8 @@ grub_chainloader_cmd (const char *filename, grub_chainloader_flags_t flags)
5975ab
 
5975ab
   grub_dl_ref (my_mod);
5975ab
 
5975ab
-  grub_file_filter_disable_compression ();
5975ab
-  file = grub_file_open (filename);
5975ab
+  file = grub_file_open (filename, GRUB_FILE_TYPE_PCCHAINLOADER
5975ab
+			 | GRUB_FILE_TYPE_NO_DECOMPRESS);
5975ab
   if (! file)
5975ab
     goto fail;
5975ab
 
5975ab
diff --git a/grub-core/loader/i386/pc/freedos.c b/grub-core/loader/i386/pc/freedos.c
5975ab
index 478f3c5139d..aac6c9715f6 100644
5975ab
--- a/grub-core/loader/i386/pc/freedos.c
5975ab
+++ b/grub-core/loader/i386/pc/freedos.c
5975ab
@@ -110,7 +110,7 @@ grub_cmd_freedos (grub_command_t cmd __attribute__ ((unused)),
5975ab
   if (!rel)
5975ab
     goto fail;
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEDOS);
5975ab
   if (! file)
5975ab
     goto fail;
5975ab
 
5975ab
diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
5975ab
index 63736fae950..b5c28c6580e 100644
5975ab
--- a/grub-core/loader/i386/pc/linux.c
5975ab
+++ b/grub-core/loader/i386/pc/linux.c
5975ab
@@ -142,7 +142,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
5975ab
       goto fail;
5975ab
     }
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
5975ab
   if (! file)
5975ab
     goto fail;
5975ab
 
5975ab
diff --git a/grub-core/loader/i386/pc/ntldr.c b/grub-core/loader/i386/pc/ntldr.c
5975ab
index 1b88f40d871..f0d74145b38 100644
5975ab
--- a/grub-core/loader/i386/pc/ntldr.c
5975ab
+++ b/grub-core/loader/i386/pc/ntldr.c
5975ab
@@ -90,7 +90,7 @@ grub_cmd_ntldr (grub_command_t cmd __attribute__ ((unused)),
5975ab
   if (!rel)
5975ab
     goto fail;
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_NTLDR);
5975ab
   if (! file)
5975ab
     goto fail;
5975ab
 
5975ab
diff --git a/grub-core/loader/i386/pc/plan9.c b/grub-core/loader/i386/pc/plan9.c
5975ab
index 814a49d5071..0351090daf8 100644
5975ab
--- a/grub-core/loader/i386/pc/plan9.c
5975ab
+++ b/grub-core/loader/i386/pc/plan9.c
5975ab
@@ -413,7 +413,7 @@ grub_cmd_plan9 (grub_extcmd_context_t ctxt, int argc, char *argv[])
5975ab
   if (!rel)
5975ab
     goto fail;
5975ab
 
5975ab
-  fill_ctx.file = grub_file_open (argv[0]);
5975ab
+  fill_ctx.file = grub_file_open (argv[0], GRUB_FILE_TYPE_PLAN9_KERNEL);
5975ab
   if (! fill_ctx.file)
5975ab
     goto fail;
5975ab
 
5975ab
diff --git a/grub-core/loader/i386/pc/pxechainloader.c b/grub-core/loader/i386/pc/pxechainloader.c
5975ab
index e60c62b1bad..acb061169b9 100644
5975ab
--- a/grub-core/loader/i386/pc/pxechainloader.c
5975ab
+++ b/grub-core/loader/i386/pc/pxechainloader.c
5975ab
@@ -99,7 +99,7 @@ grub_cmd_pxechain (grub_command_t cmd __attribute__ ((unused)),
5975ab
   if (!rel)
5975ab
     goto fail;
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_PXECHAINLOADER);
5975ab
   if (! file)
5975ab
     goto fail;
5975ab
 
5975ab
diff --git a/grub-core/loader/i386/pc/truecrypt.c b/grub-core/loader/i386/pc/truecrypt.c
5975ab
index 9ea4fde42a5..cbeeec7beae 100644
5975ab
--- a/grub-core/loader/i386/pc/truecrypt.c
5975ab
+++ b/grub-core/loader/i386/pc/truecrypt.c
5975ab
@@ -99,7 +99,7 @@ grub_cmd_truecrypt (grub_command_t cmd __attribute__ ((unused)),
5975ab
 
5975ab
   grub_dl_ref (my_mod);
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_TRUECRYPT);
5975ab
   if (! file)
5975ab
     goto fail;
5975ab
 
5975ab
diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c
5975ab
index 85b93347b25..82350d3a178 100644
5975ab
--- a/grub-core/loader/i386/xen.c
5975ab
+++ b/grub-core/loader/i386/xen.c
5975ab
@@ -650,7 +650,7 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)),
5975ab
 			      (char *) xen_state.next_start.cmd_line,
5975ab
 			      sizeof (xen_state.next_start.cmd_line) - 1);
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
5975ab
   if (!file)
5975ab
     return grub_errno;
5975ab
 
5975ab
@@ -901,9 +901,8 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
5975ab
 
5975ab
   xen_state.max_addr = ALIGN_UP (xen_state.max_addr, PAGE_SIZE);
5975ab
 
5975ab
-  if (nounzip)
5975ab
-    grub_file_filter_disable_compression ();
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_INITRD |
5975ab
+			 (nounzip ? GRUB_FILE_TYPE_NO_DECOMPRESS : GRUB_FILE_TYPE_NONE));
5975ab
   if (!file)
5975ab
     return grub_errno;
5975ab
   size = grub_file_size (file);
5975ab
diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c
5975ab
index 77a93e7b228..9af5d66dfcd 100644
5975ab
--- a/grub-core/loader/i386/xen_file.c
5975ab
+++ b/grub-core/loader/i386/xen_file.c
5975ab
@@ -78,7 +78,7 @@ grub_xen_file (grub_file_t file)
5975ab
      Trim it.  */
5975ab
   if (grub_memcmp (magic, XZ_MAGIC, sizeof (XZ_MAGIC) - 1) == 0)
5975ab
     payload_length -= 4;
5975ab
-  off_file = grub_file_offset_open (file, payload_offset,
5975ab
+  off_file = grub_file_offset_open (file, GRUB_FILE_TYPE_LINUX_KERNEL, payload_offset,
5975ab
 				    payload_length);
5975ab
   if (!off_file)
5975ab
     goto fail;
5975ab
diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c
5975ab
index 44f7ebfa2b6..a7009360732 100644
5975ab
--- a/grub-core/loader/i386/xnu.c
5975ab
+++ b/grub-core/loader/i386/xnu.c
5975ab
@@ -486,7 +486,7 @@ grub_cmd_devprop_load (grub_command_t cmd __attribute__ ((unused)),
5975ab
   if (argc != 1)
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
5975ab
 
5975ab
-  file = grub_file_open (args[0]);
5975ab
+  file = grub_file_open (args[0], GRUB_FILE_XNU_DEVPROP);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
   size = grub_file_size (file);
5975ab
diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
5975ab
index 0953f6d3266..2b2f798e754 100644
5975ab
--- a/grub-core/loader/linux.c
5975ab
+++ b/grub-core/loader/linux.c
5975ab
@@ -183,7 +183,6 @@ grub_initrd_init (int argc, char *argv[],
5975ab
 	  eptr = grub_strchr (ptr, ':');
5975ab
 	  if (eptr)
5975ab
 	    {
5975ab
-	      grub_file_filter_disable_compression ();
5975ab
 	      grub_size_t dir_size, name_len;
5975ab
 
5975ab
 	      initrd_ctx->components[i].newc_name = grub_strndup (ptr, eptr - ptr);
5975ab
@@ -215,8 +214,9 @@ grub_initrd_init (int argc, char *argv[],
5975ab
 	  root = 0;
5975ab
 	  newc = 0;
5975ab
 	}
5975ab
-      grub_file_filter_disable_compression ();
5975ab
-      initrd_ctx->components[i].file = grub_file_open (fname);
5975ab
+      initrd_ctx->components[i].file = grub_file_open (fname,
5975ab
+						       GRUB_FILE_TYPE_LINUX_INITRD
5975ab
+						       | GRUB_FILE_TYPE_NO_DECOMPRESS);
5975ab
       if (!initrd_ctx->components[i].file)
5975ab
 	{
5975ab
 	  grub_initrd_close (initrd_ctx);
5975ab
diff --git a/grub-core/loader/macho.c b/grub-core/loader/macho.c
5975ab
index f61341af515..05710c48e06 100644
5975ab
--- a/grub-core/loader/macho.c
5975ab
+++ b/grub-core/loader/macho.c
5975ab
@@ -188,12 +188,12 @@ fail:
5975ab
 }
5975ab
 
5975ab
 grub_macho_t
5975ab
-grub_macho_open (const char *name, int is_64bit)
5975ab
+grub_macho_open (const char *name, enum grub_file_type type, int is_64bit)
5975ab
 {
5975ab
   grub_file_t file;
5975ab
   grub_macho_t macho;
5975ab
 
5975ab
-  file = grub_file_open (name);
5975ab
+  file = grub_file_open (name, type);
5975ab
   if (! file)
5975ab
     return 0;
5975ab
 
5975ab
diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c
5975ab
index 27c1db84a44..10358854458 100644
5975ab
--- a/grub-core/loader/mips/linux.c
5975ab
+++ b/grub-core/loader/mips/linux.c
5975ab
@@ -237,7 +237,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
5975ab
   if (argc == 0)
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
5975ab
 
5975ab
-  elf = grub_elf_open (argv[0]);
5975ab
+  elf = grub_elf_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
5975ab
   if (! elf)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c
5975ab
index f455e803910..e8963d7cdb3 100644
5975ab
--- a/grub-core/loader/multiboot.c
5975ab
+++ b/grub-core/loader/multiboot.c
5975ab
@@ -323,7 +323,7 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)),
5975ab
   if (argc == 0)
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
5975ab
 
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_MULTIBOOT_KERNEL);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
@@ -389,10 +389,8 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
5975ab
     return grub_error (GRUB_ERR_BAD_ARGUMENT,
5975ab
 		       N_("you need to load the kernel first"));
5975ab
 
5975ab
-  if (nounzip)
5975ab
-    grub_file_filter_disable_compression ();
5975ab
-
5975ab
-  file = grub_file_open (argv[0]);
5975ab
+  file = grub_file_open (argv[0], GRUB_FILE_TYPE_MULTIBOOT_MODULE
5975ab
+			 | (nounzip ? GRUB_FILE_TYPE_NO_DECOMPRESS : GRUB_FILE_TYPE_NONE));
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
5975ab
index 2bf02489bad..9f78abb05f9 100644
5975ab
--- a/grub-core/loader/xnu.c
5975ab
+++ b/grub-core/loader/xnu.c
5975ab
@@ -355,7 +355,7 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)),
5975ab
 
5975ab
   grub_xnu_unload ();
5975ab
 
5975ab
-  macho = grub_macho_open (args[0], 0);
5975ab
+  macho = grub_macho_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL, 0);
5975ab
   if (! macho)
5975ab
     return grub_errno;
5975ab
 
5975ab
@@ -460,7 +460,7 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)),
5975ab
 
5975ab
   grub_xnu_unload ();
5975ab
 
5975ab
-  macho = grub_macho_open (args[0], 1);
5975ab
+  macho = grub_macho_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL, 1);
5975ab
   if (! macho)
5975ab
     return grub_errno;
5975ab
 
5975ab
@@ -678,7 +678,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
5975ab
     macho = 0;
5975ab
 
5975ab
   if (infoplistname)
5975ab
-    infoplist = grub_file_open (infoplistname);
5975ab
+    infoplist = grub_file_open (infoplistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
5975ab
   else
5975ab
     infoplist = 0;
5975ab
   grub_errno = GRUB_ERR_NONE;
5975ab
@@ -775,7 +775,7 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)),
5975ab
   if (! grub_xnu_heap_size)
5975ab
     return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
5975ab
 
5975ab
-  file = grub_file_open (args[0]);
5975ab
+  file = grub_file_open (args[0], GRUB_FILE_TYPE_XNU_MKEXT);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
@@ -889,7 +889,7 @@ grub_cmd_xnu_ramdisk (grub_command_t cmd __attribute__ ((unused)),
5975ab
   if (! grub_xnu_heap_size)
5975ab
     return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
5975ab
 
5975ab
-  file = grub_file_open (args[0]);
5975ab
+  file = grub_file_open (args[0], GRUB_FILE_TYPE_XNU_RAMDISK);
5975ab
   if (! file)
5975ab
     return grub_errno;
5975ab
 
5975ab
@@ -929,7 +929,7 @@ grub_xnu_check_os_bundle_required (char *plistname,
5975ab
   if (binname)
5975ab
     *binname = 0;
5975ab
 
5975ab
-  file = grub_file_open (plistname);
5975ab
+  file = grub_file_open (plistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
5975ab
   if (! file)
5975ab
     return 0;
5975ab
 
5975ab
@@ -1214,7 +1214,7 @@ grub_xnu_load_kext_from_dir (char *dirname, const char *osbundlerequired,
5975ab
 		grub_strcpy (binname + grub_strlen (binname), "/");
5975ab
 	      grub_strcpy (binname + grub_strlen (binname), binsuffix);
5975ab
 	      grub_dprintf ("xnu", "%s:%s\n", ctx.plistname, binname);
5975ab
-	      binfile = grub_file_open (binname);
5975ab
+	      binfile = grub_file_open (binname, GRUB_FILE_TYPE_XNU_KEXT);
5975ab
 	      if (! binfile)
5975ab
 		grub_errno = GRUB_ERR_NONE;
5975ab
 
5975ab
@@ -1257,7 +1257,7 @@ grub_cmd_xnu_kext (grub_command_t cmd __attribute__ ((unused)),
5975ab
       /* User explicitly specified plist and binary. */
5975ab
       if (grub_strcmp (args[1], "-") != 0)
5975ab
 	{
5975ab
-	  binfile = grub_file_open (args[1]);
5975ab
+	  binfile = grub_file_open (args[1], GRUB_FILE_TYPE_XNU_KEXT);
5975ab
 	  if (! binfile)
5975ab
 	    return grub_errno;
5975ab
 	}
5975ab
diff --git a/grub-core/loader/xnu_resume.c b/grub-core/loader/xnu_resume.c
5975ab
index 99119558d21..d648ef0cd3a 100644
5975ab
--- a/grub-core/loader/xnu_resume.c
5975ab
+++ b/grub-core/loader/xnu_resume.c
5975ab
@@ -53,8 +53,8 @@ grub_xnu_resume (char *imagename)
5975ab
   grub_addr_t target_image;
5975ab
   grub_err_t err;
5975ab
 
5975ab
-  grub_file_filter_disable_compression ();
5975ab
-  file = grub_file_open (imagename);
5975ab
+  file = grub_file_open (imagename, GRUB_FILE_TYPE_XNU_HIBERNATE_IMAGE
5975ab
+			 | GRUB_FILE_TYPE_NO_DECOMPRESS);
5975ab
   if (! file)
5975ab
     return 0;
5975ab
 
5975ab
diff --git a/grub-core/normal/autofs.c b/grub-core/normal/autofs.c
5975ab
index 721b9c3256d..7a7cf2b0f7e 100644
5975ab
--- a/grub-core/normal/autofs.c
5975ab
+++ b/grub-core/normal/autofs.c
5975ab
@@ -33,12 +33,6 @@ autoload_fs_module (void)
5975ab
 {
5975ab
   grub_named_list_t p;
5975ab
   int ret = 0;
5975ab
-  grub_file_filter_t grub_file_filters_was[GRUB_FILE_FILTER_MAX];
5975ab
-
5975ab
-  grub_memcpy (grub_file_filters_was, grub_file_filters_enabled,
5975ab
-	       sizeof (grub_file_filters_enabled));
5975ab
-  grub_memcpy (grub_file_filters_enabled, grub_file_filters_all,
5975ab
-	       sizeof (grub_file_filters_enabled));
5975ab
 
5975ab
   while ((p = fs_module_list) != NULL)
5975ab
     {
5975ab
@@ -56,9 +50,6 @@ autoload_fs_module (void)
5975ab
       grub_free (p);
5975ab
     }
5975ab
 
5975ab
-  grub_memcpy (grub_file_filters_enabled, grub_file_filters_was,
5975ab
-	       sizeof (grub_file_filters_enabled));
5975ab
-
5975ab
   return ret;
5975ab
 }
5975ab
 
5975ab
@@ -82,7 +73,7 @@ read_fs_list (const char *prefix)
5975ab
 	  tmp_autoload_hook = grub_fs_autoload_hook;
5975ab
 	  grub_fs_autoload_hook = NULL;
5975ab
 
5975ab
-	  file = grub_file_open (filename);
5975ab
+	  file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
5975ab
 	  if (file)
5975ab
 	    {
5975ab
 	      /* Override previous fs.lst.  */
5975ab
diff --git a/grub-core/normal/crypto.c b/grub-core/normal/crypto.c
5975ab
index e6d345f3345..d01e6f271e1 100644
5975ab
--- a/grub-core/normal/crypto.c
5975ab
+++ b/grub-core/normal/crypto.c
5975ab
@@ -94,7 +94,7 @@ read_crypto_list (const char *prefix)
5975ab
       return;
5975ab
     }
5975ab
 
5975ab
-  file = grub_file_open (filename);
5975ab
+  file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
5975ab
   grub_free (filename);
5975ab
   if (!file)
5975ab
     {
5975ab
diff --git a/grub-core/normal/dyncmd.c b/grub-core/normal/dyncmd.c
5975ab
index 169c126f508..719ebf477f2 100644
5975ab
--- a/grub-core/normal/dyncmd.c
5975ab
+++ b/grub-core/normal/dyncmd.c
5975ab
@@ -106,7 +106,7 @@ read_command_list (const char *prefix)
5975ab
 	{
5975ab
 	  grub_file_t file;
5975ab
 
5975ab
-	  file = grub_file_open (filename);
5975ab
+	  file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
5975ab
 	  if (file)
5975ab
 	    {
5975ab
 	      char *buf = NULL;
5975ab
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
5975ab
index 59fd54eb0f1..cee71a4c2ab 100644
5975ab
--- a/grub-core/normal/main.c
5975ab
+++ b/grub-core/normal/main.c
5975ab
@@ -127,7 +127,7 @@ read_config_file (const char *config)
5975ab
     }
5975ab
 
5975ab
   /* Try to open the config file.  */
5975ab
-  rawfile = grub_file_open (config);
5975ab
+  rawfile = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
5975ab
   if (! rawfile)
5975ab
     return 0;
5975ab
 
5975ab
diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c
5975ab
index 93a3a0d912e..cc8c173b6e8 100644
5975ab
--- a/grub-core/normal/term.c
5975ab
+++ b/grub-core/normal/term.c
5975ab
@@ -331,7 +331,7 @@ read_terminal_list (const char *prefix)
5975ab
       return;
5975ab
     }
5975ab
 
5975ab
-  file = grub_file_open (filename);
5975ab
+  file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
5975ab
   grub_free (filename);
5975ab
   if (!file)
5975ab
     {
5975ab
diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c
5975ab
index 21b0d9ded67..31359a4c9c8 100644
5975ab
--- a/grub-core/video/readers/jpeg.c
5975ab
+++ b/grub-core/video/readers/jpeg.c
5975ab
@@ -772,7 +772,7 @@ grub_video_reader_jpeg (struct grub_video_bitmap **bitmap,
5975ab
   grub_file_t file;
5975ab
   struct grub_jpeg_data *data;
5975ab
 
5975ab
-  file = grub_buffile_open (filename, 0);
5975ab
+  file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0);
5975ab
   if (!file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c
5975ab
index 719e647e44f..0157ff7420b 100644
5975ab
--- a/grub-core/video/readers/png.c
5975ab
+++ b/grub-core/video/readers/png.c
5975ab
@@ -1095,7 +1095,7 @@ grub_video_reader_png (struct grub_video_bitmap **bitmap,
5975ab
   grub_file_t file;
5975ab
   struct grub_png_data *data;
5975ab
 
5975ab
-  file = grub_buffile_open (filename, 0);
5975ab
+  file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0);
5975ab
   if (!file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/grub-core/video/readers/tga.c b/grub-core/video/readers/tga.c
5975ab
index c7a16fa9cc4..7cb9d1d2a0c 100644
5975ab
--- a/grub-core/video/readers/tga.c
5975ab
+++ b/grub-core/video/readers/tga.c
5975ab
@@ -297,7 +297,7 @@ grub_video_reader_tga (struct grub_video_bitmap **bitmap,
5975ab
 
5975ab
   grub_memset (&data, 0, sizeof (data));
5975ab
 
5975ab
-  data.file = grub_buffile_open (filename, 0);
5975ab
+  data.file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0);
5975ab
   if (! data.file)
5975ab
     return grub_errno;
5975ab
 
5975ab
diff --git a/util/grub-fstest.c b/util/grub-fstest.c
5975ab
index 793aefa02b1..fe5982220d0 100644
5975ab
--- a/util/grub-fstest.c
5975ab
+++ b/util/grub-fstest.c
5975ab
@@ -120,9 +120,9 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len, void
5975ab
       return;
5975ab
     }
5975ab
 
5975ab
-  if (uncompress == 0)
5975ab
-    grub_file_filter_disable_compression ();
5975ab
-  file = grub_file_open (pathname);
5975ab
+  file = grub_file_open (pathname, ((uncompress == 0)
5975ab
+				    ? GRUB_FILE_TYPE_NO_DECOMPRESS : GRUB_FILE_TYPE_NONE)
5975ab
+			 | GRUB_FILE_TYPE_FSTEST);
5975ab
   if (!file)
5975ab
     {
5975ab
       grub_util_error (_("cannot open `%s': %s"), pathname,
5975ab
diff --git a/util/grub-mount.c b/util/grub-mount.c
5975ab
index a25db8a7181..e32b502e7e4 100644
5975ab
--- a/util/grub-mount.c
5975ab
+++ b/util/grub-mount.c
5975ab
@@ -208,7 +208,7 @@ fuse_getattr (const char *path, struct stat *st)
5975ab
   if (!ctx.file_info.dir)
5975ab
     {
5975ab
       grub_file_t file;
5975ab
-      file = grub_file_open (path);
5975ab
+      file = grub_file_open (path, GRUB_FILE_TYPE_GET_SIZE);
5975ab
       if (! file && grub_errno == GRUB_ERR_BAD_FILE_TYPE)
5975ab
 	{
5975ab
 	  grub_errno = GRUB_ERR_NONE;
5975ab
@@ -244,7 +244,7 @@ static int
5975ab
 fuse_open (const char *path, struct fuse_file_info *fi __attribute__ ((unused)))
5975ab
 {
5975ab
   grub_file_t file;
5975ab
-  file = grub_file_open (path);
5975ab
+  file = grub_file_open (path, GRUB_FILE_TYPE_MOUNT);
5975ab
   if (! file)
5975ab
     return translate_error ();
5975ab
   files[first_fd++] = file;
5975ab
@@ -308,7 +308,7 @@ fuse_readdir_call_fill (const char *filename,
5975ab
       grub_file_t file;
5975ab
       char *tmp;
5975ab
       tmp = xasprintf ("%s/%s", ctx->path, filename);
5975ab
-      file = grub_file_open (tmp);
5975ab
+      file = grub_file_open (tmp, GRUB_FILE_TYPE_GET_SIZE);
5975ab
       free (tmp);
5975ab
       /* Symlink to directory.  */
5975ab
       if (! file && grub_errno == GRUB_ERR_BAD_FILE_TYPE)
5975ab
diff --git a/include/grub/bufio.h b/include/grub/bufio.h
5975ab
index 77eb8ee5672..0ff72d1033c 100644
5975ab
--- a/include/grub/bufio.h
5975ab
+++ b/include/grub/bufio.h
5975ab
@@ -23,6 +23,8 @@
5975ab
 #include <grub/file.h>
5975ab
 
5975ab
 grub_file_t EXPORT_FUNC (grub_bufio_open) (grub_file_t io, grub_size_t size);
5975ab
-grub_file_t EXPORT_FUNC (grub_buffile_open) (const char *name, grub_size_t size);
5975ab
+grub_file_t EXPORT_FUNC (grub_buffile_open) (const char *name,
5975ab
+					     enum grub_file_type type,
5975ab
+					     grub_size_t size);
5975ab
 
5975ab
 #endif /* ! GRUB_BUFIO_H */
5975ab
diff --git a/include/grub/elfload.h b/include/grub/elfload.h
5975ab
index 9a7ae4ebb30..dbb609c9b20 100644
5975ab
--- a/include/grub/elfload.h
5975ab
+++ b/include/grub/elfload.h
5975ab
@@ -42,7 +42,7 @@ typedef int (*grub_elf32_phdr_iterate_hook_t)
5975ab
 typedef int (*grub_elf64_phdr_iterate_hook_t)
5975ab
   (grub_elf_t elf, Elf64_Phdr *phdr, void *arg);
5975ab
 
5975ab
-grub_elf_t grub_elf_open (const char *);
5975ab
+grub_elf_t grub_elf_open (const char *, enum grub_file_type type);
5975ab
 grub_elf_t grub_elf_file (grub_file_t file, const char *filename);
5975ab
 grub_err_t grub_elf_close (grub_elf_t);
5975ab
 
5975ab
diff --git a/include/grub/file.h b/include/grub/file.h
5975ab
index 739488cbe59..5b47c5f91f9 100644
5975ab
--- a/include/grub/file.h
5975ab
+++ b/include/grub/file.h
5975ab
@@ -25,6 +25,109 @@
5975ab
 #include <grub/fs.h>
5975ab
 #include <grub/disk.h>
5975ab
 
5975ab
+enum grub_file_type
5975ab
+  {
5975ab
+    GRUB_FILE_TYPE_NONE = 0,
5975ab
+    /* GRUB module to be loaded.  */
5975ab
+    GRUB_FILE_TYPE_GRUB_MODULE,
5975ab
+    /* Loopback file to be represented as disk.  */
5975ab
+    GRUB_FILE_TYPE_LOOPBACK,
5975ab
+    /* Linux kernel to be loaded.  */
5975ab
+    GRUB_FILE_TYPE_LINUX_KERNEL,
5975ab
+    /* Linux initrd.  */
5975ab
+    GRUB_FILE_TYPE_LINUX_INITRD,
5975ab
+
5975ab
+    /* Multiboot kernel.  */
5975ab
+    GRUB_FILE_TYPE_MULTIBOOT_KERNEL,
5975ab
+    /* Multiboot module.  */
5975ab
+    GRUB_FILE_TYPE_MULTIBOOT_MODULE,
5975ab
+
5975ab
+    GRUB_FILE_TYPE_BSD_KERNEL,
5975ab
+    GRUB_FILE_TYPE_FREEBSD_ENV,
5975ab
+    GRUB_FILE_TYPE_FREEBSD_MODULE,
5975ab
+    GRUB_FILE_TYPE_FREEBSD_MODULE_ELF,
5975ab
+    GRUB_FILE_TYPE_NETBSD_MODULE,
5975ab
+    GRUB_FILE_TYPE_OPENBSD_RAMDISK,
5975ab
+
5975ab
+    GRUB_FILE_TYPE_XNU_INFO_PLIST,
5975ab
+    GRUB_FILE_TYPE_XNU_MKEXT,
5975ab
+    GRUB_FILE_TYPE_XNU_KEXT,
5975ab
+    GRUB_FILE_TYPE_XNU_KERNEL,
5975ab
+    GRUB_FILE_TYPE_XNU_RAMDISK,
5975ab
+    GRUB_FILE_TYPE_XNU_HIBERNATE_IMAGE,
5975ab
+    GRUB_FILE_XNU_DEVPROP,
5975ab
+
5975ab
+    GRUB_FILE_TYPE_PLAN9_KERNEL,
5975ab
+
5975ab
+    GRUB_FILE_TYPE_NTLDR,
5975ab
+    GRUB_FILE_TYPE_TRUECRYPT,
5975ab
+    GRUB_FILE_TYPE_FREEDOS,
5975ab
+    GRUB_FILE_TYPE_PXECHAINLOADER,
5975ab
+    GRUB_FILE_TYPE_PCCHAINLOADER,
5975ab
+
5975ab
+    GRUB_FILE_TYPE_COREBOOT_CHAINLOADER,
5975ab
+
5975ab
+    GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE,
5975ab
+
5975ab
+    /* File holding signature.  */
5975ab
+    GRUB_FILE_TYPE_SIGNATURE,
5975ab
+    /* File holding public key to verify signature once.  */
5975ab
+    GRUB_FILE_TYPE_PUBLIC_KEY,
5975ab
+    /* File holding public key to add to trused keys.  */
5975ab
+    GRUB_FILE_TYPE_PUBLIC_KEY_TRUST,
5975ab
+    /* File of which we intend to print a blocklist to the user.  */
5975ab
+    GRUB_FILE_TYPE_PRINT_BLOCKLIST,
5975ab
+    /* File we intend to use for test loading or testing speed.  */
5975ab
+    GRUB_FILE_TYPE_TESTLOAD,
5975ab
+    /* File we open only to get its size. E.g. in ls output.  */
5975ab
+    GRUB_FILE_TYPE_GET_SIZE,
5975ab
+    /* Font file.  */
5975ab
+    GRUB_FILE_TYPE_FONT,
5975ab
+    /* File holding encryption key for encrypted ZFS.  */
5975ab
+    GRUB_FILE_TYPE_ZFS_ENCRYPTION_KEY,
5975ab
+    /* File we open n grub-fstest.  */
5975ab
+    GRUB_FILE_TYPE_FSTEST,
5975ab
+    /* File we open n grub-mount.  */
5975ab
+    GRUB_FILE_TYPE_MOUNT,
5975ab
+    /* File which we attempt to identify the type of.  */
5975ab
+    GRUB_FILE_TYPE_FILE_ID,
5975ab
+    /* File holding ACPI table.  */
5975ab
+    GRUB_FILE_TYPE_ACPI_TABLE,
5975ab
+    /* File we intend show to user.  */
5975ab
+    GRUB_FILE_TYPE_CAT,
5975ab
+    GRUB_FILE_TYPE_HEXCAT,
5975ab
+    /* One of pair of files we intend to compare.  */
5975ab
+    GRUB_FILE_TYPE_CMP,
5975ab
+    /* List of hashes for hashsum.  */
5975ab
+    GRUB_FILE_TYPE_HASHLIST,
5975ab
+    /* File hashed by hashsum.  */
5975ab
+    GRUB_FILE_TYPE_TO_HASH,
5975ab
+    /* Keyboard layout.  */
5975ab
+    GRUB_FILE_TYPE_KEYBOARD_LAYOUT,
5975ab
+    /* Picture file.  */
5975ab
+    GRUB_FILE_TYPE_PIXMAP,
5975ab
+    /* *.lst shipped by GRUB.  */
5975ab
+    GRUB_FILE_TYPE_GRUB_MODULE_LIST,
5975ab
+    /* config file.  */
5975ab
+    GRUB_FILE_TYPE_CONFIG,
5975ab
+    GRUB_FILE_TYPE_THEME,
5975ab
+    GRUB_FILE_TYPE_GETTEXT_CATALOG,
5975ab
+    GRUB_FILE_TYPE_FS_SEARCH,
5975ab
+    GRUB_FILE_TYPE_AUDIO,
5975ab
+    GRUB_FILE_TYPE_VBE_DUMP,
5975ab
+
5975ab
+    GRUB_FILE_TYPE_LOADENV,
5975ab
+    GRUB_FILE_TYPE_SAVEENV,
5975ab
+
5975ab
+    GRUB_FILE_TYPE_VERIFY_SIGNATURE,
5975ab
+
5975ab
+    GRUB_FILE_TYPE_MASK = 0xffff,
5975ab
+
5975ab
+    /* --skip-sig is specified.  */
5975ab
+    GRUB_FILE_TYPE_SKIP_SIGNATURE = 0x10000,
5975ab
+    GRUB_FILE_TYPE_NO_DECOMPRESS = 0x20000
5975ab
+  };
5975ab
+
5975ab
 /* File description.  */
5975ab
 struct grub_file
5975ab
 {
5975ab
@@ -77,61 +180,26 @@ typedef enum grub_file_filter_id
5975ab
     GRUB_FILE_FILTER_COMPRESSION_LAST = GRUB_FILE_FILTER_LZOPIO,
5975ab
   } grub_file_filter_id_t;
5975ab
 
5975ab
-typedef grub_file_t (*grub_file_filter_t) (grub_file_t in, const char *filename);
5975ab
+typedef grub_file_t (*grub_file_filter_t) (grub_file_t in, enum grub_file_type type);
5975ab
 
5975ab
-extern grub_file_filter_t EXPORT_VAR(grub_file_filters_all)[GRUB_FILE_FILTER_MAX];
5975ab
-extern grub_file_filter_t EXPORT_VAR(grub_file_filters_enabled)[GRUB_FILE_FILTER_MAX];
5975ab
+extern grub_file_filter_t EXPORT_VAR(grub_file_filters)[GRUB_FILE_FILTER_MAX];
5975ab
 
5975ab
 static inline void
5975ab
 grub_file_filter_register (grub_file_filter_id_t id, grub_file_filter_t filter)
5975ab
 {
5975ab
-  grub_file_filters_all[id] = filter;
5975ab
-  grub_file_filters_enabled[id] = filter;
5975ab
+  grub_file_filters[id] = filter;
5975ab
 }
5975ab
 
5975ab
 static inline void
5975ab
 grub_file_filter_unregister (grub_file_filter_id_t id)
5975ab
 {
5975ab
-  grub_file_filters_all[id] = 0;
5975ab
-  grub_file_filters_enabled[id] = 0;
5975ab
-}
5975ab
-
5975ab
-static inline void
5975ab
-grub_file_filter_disable (grub_file_filter_id_t id)
5975ab
-{
5975ab
-  grub_file_filters_enabled[id] = 0;
5975ab
-}
5975ab
-
5975ab
-static inline void
5975ab
-grub_file_filter_disable_compression (void)
5975ab
-{
5975ab
-  grub_file_filter_id_t id;
5975ab
-
5975ab
-  for (id = GRUB_FILE_FILTER_COMPRESSION_FIRST;
5975ab
-       id <= GRUB_FILE_FILTER_COMPRESSION_LAST; id++)
5975ab
-    grub_file_filters_enabled[id] = 0;
5975ab
-}
5975ab
-
5975ab
-static inline void
5975ab
-grub_file_filter_disable_all (void)
5975ab
-{
5975ab
-  grub_file_filter_id_t id;
5975ab
-
5975ab
-  for (id = 0;
5975ab
-       id < GRUB_FILE_FILTER_MAX; id++)
5975ab
-    grub_file_filters_enabled[id] = 0;
5975ab
-}
5975ab
-
5975ab
-static inline void
5975ab
-grub_file_filter_disable_pubkey (void)
5975ab
-{
5975ab
-  grub_file_filters_enabled[GRUB_FILE_FILTER_PUBKEY] = 0;
5975ab
+  grub_file_filters[id] = 0;
5975ab
 }
5975ab
 
5975ab
 /* Get a device name from NAME.  */
5975ab
 char *EXPORT_FUNC(grub_file_get_device_name) (const char *name);
5975ab
 
5975ab
-grub_file_t EXPORT_FUNC(grub_file_open) (const char *name);
5975ab
+grub_file_t EXPORT_FUNC(grub_file_open) (const char *name, enum grub_file_type type);
5975ab
 grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, void *buf,
5975ab
 					  grub_size_t len);
5975ab
 grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset);
5975ab
@@ -159,8 +227,8 @@ grub_file_seekable (const grub_file_t file)
5975ab
 }
5975ab
 
5975ab
 grub_file_t
5975ab
-grub_file_offset_open (grub_file_t parent, grub_off_t start,
5975ab
-		       grub_off_t size);
5975ab
+grub_file_offset_open (grub_file_t parent, enum grub_file_type type,
5975ab
+		       grub_off_t start, grub_off_t size);
5975ab
 void
5975ab
 grub_file_offset_close (grub_file_t file);
5975ab
 
5975ab
diff --git a/include/grub/machoload.h b/include/grub/machoload.h
5975ab
index 1eec118f15f..f1157f4105b 100644
5975ab
--- a/include/grub/machoload.h
5975ab
+++ b/include/grub/machoload.h
5975ab
@@ -49,7 +49,8 @@ struct grub_macho_file
5975ab
 };
5975ab
 typedef struct grub_macho_file *grub_macho_t;
5975ab
 
5975ab
-grub_macho_t grub_macho_open (const char *, int is_64bit);
5975ab
+grub_macho_t grub_macho_open (const char *, enum grub_file_type type,
5975ab
+			      int is_64bit);
5975ab
 grub_macho_t grub_macho_file (grub_file_t file, const char *filename,
5975ab
 			      int is_64bit);
5975ab
 grub_err_t grub_macho_close (grub_macho_t);