Blob Blame History Raw
From 221f6e1ac22f66881276d4cb012d588ecfb17e47 Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phcoder@gmail.com>
Date: Sat, 18 Jan 2014 19:54:09 +0100
Subject: [PATCH 032/143] 	* grub-core/normal/main.c (read_config_file):
 Buffer config file. 	Reduces boot time.

---
 ChangeLog               |  5 +++++
 grub-core/normal/main.c | 14 +++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c3bfa9f..c84f7e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-18  Vladimir Serbinenko  <phcoder@gmail.com>
+
+	* grub-core/normal/main.c (read_config_file): Buffer config file.
+	Reduces boot time.
+
 2014-01-18  Andrey Borzenkov <arvidjaar@gmail.com>
 
 	* acinclude.m4 (grub_CHECK_LINK_DIR): Check that we can also remove
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index c36663f..3a926fc 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -32,6 +32,7 @@
 #include <grub/i18n.h>
 #include <grub/charset.h>
 #include <grub/script_sh.h>
+#include <grub/bufio.h>
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
@@ -104,7 +105,7 @@ read_config_file_getline (char **line, int cont __attribute__ ((unused)),
 static grub_menu_t
 read_config_file (const char *config)
 {
-  grub_file_t file;
+  grub_file_t rawfile, file;
   char *old_file = 0, *old_dir = 0;
   char *config_dir, *ptr = 0;
   const char *ctmp;
@@ -122,10 +123,17 @@ read_config_file (const char *config)
     }
 
   /* Try to open the config file.  */
-  file = grub_file_open (config);
-  if (! file)
+  rawfile = grub_file_open (config);
+  if (! rawfile)
     return 0;
 
+  file = grub_bufio_open (rawfile, 0);
+  if (! file)
+    {
+      grub_file_close (file);
+      return 0;
+    }
+
   ctmp = grub_env_get ("config_file");
   if (ctmp)
     old_file = grub_strdup (ctmp);
-- 
1.9.3