Large image file support for grub-fstest
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, charFILE *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;
Quoted 8 lines · Christian Franke
The new command "grub-fstest" may not work for large image files or
/dev/sdXdevices on 32-bit platforms.Legacy C89 functions
fseek()andftell()always use "long" as offset type. The attached patch changes this tofseeko()andftello()which useoff_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 /.)