]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* include/grub/file.h (grub_file): New member not_easly_seekable.
authorSzymon Janc <szymon@janc.net.pl>
Sat, 4 Sep 2010 16:28:42 +0000 (18:28 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 4 Sep 2010 16:28:42 +0000 (18:28 +0200)
(grub_file_seekable): New inline function.
* grub-core/io/gzio.c (test_header): Don't test end magic if file isn't
easily seekable.
(grub_gzio_open): Set not_easly_seekable.
* grub-core/fs/i386/pc/pxe.c (grub_pxefs_open): Set not_easily_seekable.
* grub-core/io/bufio.c (grub_bufio_open): Propagate not_easily_seekable.

ChangeLog
grub-core/fs/i386/pc/pxe.c
grub-core/io/bufio.c
grub-core/io/gzio.c
include/grub/file.h

index a155853d9e29652aa798c0972bf83a624ee9cafc..fee9529969e88fb512b5539dbec268620e80fb40 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-09-04  Szymon Janc <szymon@janc.net.pl>
+
+       * include/grub/file.h (grub_file): New member not_easly_seekable.
+       (grub_file_seekable): New inline function.
+       * grub-core/io/gzio.c (test_header): Don't test end magic if file isn't
+       easily seekable.
+       (grub_gzio_open): Set not_easly_seekable.
+       * grub-core/fs/i386/pc/pxe.c (grub_pxefs_open): Set not_easily_seekable.
+       * grub-core/io/bufio.c (grub_bufio_open): Propagate not_easily_seekable.
+
 2010-09-04  BVK Chaitanya  <bvk.groups@gmail.com>
 
        Support for options to appear multiple times on cmdline.
index 90dfd5067e4f0542f4ef8e612ee8a1efe3172a60..baaff0ffc0e792d6fd0fbb68789ce1093354c8dc 100644 (file)
@@ -282,6 +282,7 @@ grub_pxefs_open (struct grub_file *file, const char *name)
     }
 
   file->data = data;
+  file->not_easly_seekable = 1;
   grub_memcpy (file_int, file, sizeof (struct grub_file));
   curr_file = file_int;
 
index 92f29279e360fd437cb88f6c3dd38fb4cb9c5ed4..8a72ecd79ba545646b12aebf4f76b6868c3022f6 100644 (file)
@@ -74,6 +74,7 @@ grub_bufio_open (grub_file_t io, int size)
   file->data = bufio;
   file->read_hook = 0;
   file->fs = &grub_bufio_fs;
+  file->not_easly_seekable = io->not_easly_seekable;
 
   return file;
 }
index 9bf609105af502e3857ec91abe956a92af8a1001..0545e32bde074134e508ee5b0914d1fe8a39858f 100644 (file)
@@ -214,12 +214,14 @@ test_header (grub_file_t file)
 
   grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4);
 
-  if (grub_file_read (gzio->file, &orig_len, 4) != 4)
+  if (grub_file_seekable (gzio->file))
     {
-      grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
-      return 0;
+      if (grub_file_read (gzio->file, &orig_len, 4) != 4)
+       {
+         grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
+         return 0;
+       }
     }
-
   /* FIXME: this does not handle files whose original size is over 4GB.
      But how can we know the real original size?  */
   file->size = grub_le_to_cpu32 (orig_len);
@@ -1135,6 +1137,7 @@ grub_gzio_open (grub_file_t io, int transparent)
   file->data = gzio;
   file->read_hook = 0;
   file->fs = &grub_gzio_fs;
+  file->not_easly_seekable = 1;
 
   if (! test_header (file))
     {
index 2aacf936f9fa3e8b1f15b91ad007c4b20c05e037..05c9907d51e0365bbd6b5118eb93938cfdd06759 100644 (file)
@@ -39,6 +39,9 @@ struct grub_file
   /* The file size.  */
   grub_off_t size;
 
+  /* If file is not easly seekable. Should be set by underlying layer.  */
+  int not_easly_seekable;
+
   /* Filesystem-specific data.  */
   void *data;
 
@@ -69,4 +72,10 @@ grub_file_tell (const grub_file_t file)
   return file->offset;
 }
 
+static inline int
+grub_file_seekable (const grub_file_t file)
+{
+  return !file->not_easly_seekable;
+}
+
 #endif /* ! GRUB_FILE_HEADER */