Skip to contentSkip to conversation

Large image file support for grub-fstest

PATCH In review Christian Franke 2 participants 2 messages Feb 7, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Large image file support for grub-fstest

The new command "grub-fstest" may not work for large image files or /dev/sdX devices on 32-bit platforms.

Legacy C89 functions fseek() and ftell() always use "long" as offset type. The attached patch changes this to fseeko() and ftello() which use off_t. These are part of POSIX, so new ./configure stuff should be not necessary.

Christian

2008-02-07 Christian Franke <[email protected]>

* util/hostfs.c (grub_hostfs_open): Use fseeko and ftello instead of fseek and ftell to support large files. (grub_hostfs_read): Likewise.

util/hostfs.c +4 -4
@@ -100,9 +100,9 @@ grub_hostfs_open (struct grub_file *file
 		       "can't open `%s'", name);
   file->data = f;
 
-  fseek (f, 0, SEEK_END);
-  file->size = ftell (f);
-  fseek (f, 0, SEEK_SET);
+  fseeko (f, 0, SEEK_END);
+  file->size = ftello (f);
+  fseeko (f, 0, SEEK_SET);
 
   return GRUB_ERR_NONE;
 }
@@ -113,7 +113,7 @@ grub_hostfs_read (grub_file_t file, char
   FILE *f;
 
   f = (FILE *) file->data;
-  fseek (f, file->offset, SEEK_SET);
+  fseeko (f, file->offset, SEEK_SET);
   int s = fread (buf, 1, len, f);
 
   return s;
#1 lore raw
Quoted 8 lines · Christian Franke

The new command "grub-fstest" may not work for large image files or /dev/sdX devices on 32-bit platforms.

Legacy C89 functions fseek() and ftell() always use "long" as offset type. The attached patch changes this to fseeko() and ftello() which use off_t. These are part of POSIX, so new ./configure stuff should be not necessary.

Quoted 7 lines

Christian

2008-02-07 Christian Franke <[email protected]>

* util/hostfs.c (grub_hostfs_open): Use fseeko and ftello instead of fseek and ftell to support large files. (grub_hostfs_read): Likewise.

Committed, thanks.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)