2009-11-11 Robert Millan <rmh.grub@aybabtu.com>

Large file support for grub-mkisofs.

        * conf/common.rmk (grub_mkisofs_CFLAGS): Add `-D_FILE_OFFSET_BITS=64'.
        * util/mkisofs/mkisofs.c (next_extent, last_extent)
        (session_start): Upgrade type to `uint64_t'.  Update all users.
        * util/mkisofs/mkisofs.h: Include `<stdint.h>'.
        (struct directory_entry): Upgrade type of `starting_block' and
        `size' to `uint64_t'.  Update all users.
        (struct deferred): Remove unused structure.
        (xfwrite): Upgrade type of `count' and `size' to `uint64_t'.
        Update all users.
        * util/mkisofs/tree.c (stat_filter, lstat_filter): Return -1 when
        file is larger than `UINT32_MAX'.
        * util/mkisofs/write.c (xfwrite): Upgrade type of `count' and
        `size' to `uint64_t'.  Update all users.  Fix handling of fwrite()
        return value.
        (struct deferred_write): Upgrade type of `extent' and `size' to
        `uint64_t'.  Update all users.
        (last_extent_written): Upgrade type to `uint64_t'.  Update all
        users.
        (write_one_file): Upgrade type of `count' and `size' to `uint64_t'.
        Update all users.  Upgrade type of `remain' to `int64_t' and
        `use' to `size_t'.  Use error() to handle fread() errors.
        (write_files): Rely on write_one_file() rather than calling
        xfwrite() directly.
This commit is contained in:
Robert Millan 2009-11-11 00:23:29 +00:00
parent 6a9cead5cf
commit 2c55dbc0d5
6 changed files with 76 additions and 48 deletions

View file

@ -1,3 +1,31 @@
2009-11-11 Robert Millan <rmh.grub@aybabtu.com>
Large file support for grub-mkisofs.
* conf/common.rmk (grub_mkisofs_CFLAGS): Add `-D_FILE_OFFSET_BITS=64'.
* util/mkisofs/mkisofs.c (next_extent, last_extent)
(session_start): Upgrade type to `uint64_t'. Update all users.
* util/mkisofs/mkisofs.h: Include `<stdint.h>'.
(struct directory_entry): Upgrade type of `starting_block' and
`size' to `uint64_t'. Update all users.
(struct deferred): Remove unused structure.
(xfwrite): Upgrade type of `count' and `size' to `uint64_t'.
Update all users.
* util/mkisofs/tree.c (stat_filter, lstat_filter): Return -1 when
file is larger than `UINT32_MAX'.
* util/mkisofs/write.c (xfwrite): Upgrade type of `count' and
`size' to `uint64_t'. Update all users. Fix handling of fwrite()
return value.
(struct deferred_write): Upgrade type of `extent' and `size' to
`uint64_t'. Update all users.
(last_extent_written): Upgrade type to `uint64_t'. Update all
users.
(write_one_file): Upgrade type of `count' and `size' to `uint64_t'.
Update all users. Upgrade type of `remain' to `int64_t' and
`use' to `size_t'. Use error() to handle fread() errors.
(write_files): Rely on write_one_file() rather than calling
xfwrite() directly.
2009-11-09 Felix Zielcke <fzielcke@z-51.de> 2009-11-09 Felix Zielcke <fzielcke@z-51.de>
* util/mkisofs/mkisofs.c (ld_options): Fix a spelling mistake. * util/mkisofs/mkisofs.c (ld_options): Fix a spelling mistake.

View file

@ -37,7 +37,9 @@ grub_mkisofs_SOURCES = util/mkisofs/eltorito.c \
util/mkisofs/write.c \ util/mkisofs/write.c \
\ \
gnulib/fnmatch.c gnulib/getopt1.c gnulib/getopt.c gnulib/fnmatch.c gnulib/getopt1.c gnulib/getopt.c
grub_mkisofs_CFLAGS = -I$(srcdir)/util/mkisofs/include -I$(srcdir)/gnulib -Wno-all -Werror grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
-I$(srcdir)/util/mkisofs/include -I$(srcdir)/gnulib \
-Wno-all -Werror
# For grub-fstest. # For grub-fstest.
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h

View file

@ -68,9 +68,9 @@ static char version_string[] = "mkisofs 1.12b5";
char * outfile; char * outfile;
FILE * discimage; FILE * discimage;
unsigned int next_extent = 0; uint64_t next_extent = 0;
unsigned int last_extent = 0; uint64_t last_extent = 0;
unsigned int session_start = 0; uint64_t session_start = 0;
unsigned int path_table_size = 0; unsigned int path_table_size = 0;
unsigned int path_table[4] = {0,}; unsigned int path_table[4] = {0,};
unsigned int path_blocks = 0; unsigned int path_blocks = 0;
@ -1365,7 +1365,7 @@ parse_input_files:
fprintf(stderr,"Max brk space used %x\n", fprintf(stderr,"Max brk space used %x\n",
(unsigned int)(((unsigned long)sbrk(0)) - mem_start)); (unsigned int)(((unsigned long)sbrk(0)) - mem_start));
#endif #endif
fprintf(stderr,"%d extents written (%d Mb)\n", last_extent, last_extent >> 9); fprintf (stderr, "%llu extents written (%llu MiB)\n", last_extent, last_extent >> 9);
} }
#ifdef VMS #ifdef VMS

View file

@ -26,6 +26,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <prototyp.h> #include <prototyp.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -159,8 +160,8 @@ struct directory_entry{
struct directory_entry * next; struct directory_entry * next;
struct directory_entry * jnext; struct directory_entry * jnext;
struct iso_directory_record isorec; struct iso_directory_record isorec;
unsigned int starting_block; uint64_t starting_block;
unsigned int size; uint64_t size;
unsigned short priority; unsigned short priority;
unsigned char jreclen; /* Joliet record len */ unsigned char jreclen; /* Joliet record len */
char * name; char * name;
@ -266,21 +267,13 @@ struct directory{
unsigned short dir_nlink; unsigned short dir_nlink;
}; };
struct deferred{
struct deferred * next;
unsigned int starting_block;
char * name;
struct directory * filedir;
unsigned int flags;
};
extern int goof; extern int goof;
extern struct directory * root; extern struct directory * root;
extern struct directory * reloc_dir; extern struct directory * reloc_dir;
extern unsigned int next_extent; extern uint64_t next_extent;
extern unsigned int last_extent; extern uint64_t last_extent;
extern unsigned int last_extent_written; extern uint64_t last_extent_written;
extern unsigned int session_start; extern uint64_t session_start;
extern unsigned int path_table_size; extern unsigned int path_table_size;
extern unsigned int path_table[4]; extern unsigned int path_table[4];
@ -353,7 +346,7 @@ extern void DECL(generate_one_directory,(struct directory *, FILE*));
extern void DECL(memcpy_max, (char *, char *, int)); extern void DECL(memcpy_max, (char *, char *, int));
extern int DECL(oneblock_size, (int starting_extent)); extern int DECL(oneblock_size, (int starting_extent));
extern struct iso_primary_descriptor vol_desc; extern struct iso_primary_descriptor vol_desc;
extern void DECL(xfwrite, (void * buffer, int count, int size, FILE * file)); extern void DECL(xfwrite, (void * buffer, uint64_t count, uint64_t size, FILE * file));
extern void DECL(set_732, (char * pnt, unsigned int i)); extern void DECL(set_732, (char * pnt, unsigned int i));
extern void DECL(set_722, (char * pnt, unsigned int i)); extern void DECL(set_722, (char * pnt, unsigned int i));
extern void DECL(outputlist_insert, (struct output_fragment * frag)); extern void DECL(outputlist_insert, (struct output_fragment * frag));

View file

@ -6,9 +6,11 @@
Copyright 1993 Yggdrasil Computing, Incorporated Copyright 1993 Yggdrasil Computing, Incorporated
Copyright (C) 2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 3, or (at your option)
any later version. any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
@ -17,7 +19,7 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, see <http://www.gnu.org/licenses/>.
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
static char rcsid[] ="$Id: tree.c,v 1.29 1999/03/07 17:41:19 eric Exp $"; static char rcsid[] ="$Id: tree.c,v 1.29 1999/03/07 17:41:19 eric Exp $";
@ -141,6 +143,10 @@ FDECL2(stat_filter, char *, path, struct stat *, st)
int result = stat(path, st); int result = stat(path, st);
if (result >= 0 && rationalize) if (result >= 0 && rationalize)
stat_fix(st); stat_fix(st);
if ((unsigned) st->st_size > UINT32_MAX)
result = -1;
return result; return result;
} }
@ -150,6 +156,10 @@ FDECL2(lstat_filter, char *, path, struct stat *, st)
int result = lstat(path, st); int result = lstat(path, st);
if (result >= 0 && rationalize) if (result >= 0 && rationalize)
stat_fix(st); stat_fix(st);
if ((unsigned) st->st_size > UINT32_MAX)
result = -1;
return result; return result;
} }

View file

@ -127,7 +127,7 @@ void FDECL2(set_733, char *, pnt, unsigned int, i)
pnt[4] = pnt[3] = (i >> 24) & 0xff; pnt[4] = pnt[3] = (i >> 24) & 0xff;
} }
void FDECL4(xfwrite, void *, buffer, int, count, int, size, FILE *, file) void FDECL4(xfwrite, void *, buffer, uint64_t, count, uint64_t, size, FILE *, file)
{ {
/* /*
* This is a hack that could be made better. XXXIs this the only place? * This is a hack that could be made better. XXXIs this the only place?
@ -156,11 +156,11 @@ void FDECL4(xfwrite, void *, buffer, int, count, int, size, FILE *, file)
} }
while(count) while(count)
{ {
int got = fwrite(buffer,size,count,file); size_t got = fwrite (buffer, size, count, file);
if(got<=0) if (got != count)
{ {
fprintf(stderr,"cannot fwrite %d*%d\n",size,count); fprintf(stderr,"cannot fwrite %llu*%llu\n",size,count);
exit(1); exit(1);
} }
count-=got,*(char**)&buffer+=size*got; count-=got,*(char**)&buffer+=size*got;
@ -171,14 +171,14 @@ struct deferred_write
{ {
struct deferred_write * next; struct deferred_write * next;
char * table; char * table;
unsigned int extent; uint64_t extent;
unsigned int size; uint64_t size;
char * name; char * name;
}; };
static struct deferred_write * dw_head = NULL, * dw_tail = NULL; static struct deferred_write * dw_head = NULL, * dw_tail = NULL;
unsigned int last_extent_written =0; uint64_t last_extent_written = 0;
static unsigned int path_table_index; static unsigned int path_table_index;
static time_t begun; static time_t begun;
@ -235,12 +235,12 @@ static int FDECL1(assign_directory_addresses, struct directory *, node)
} }
static void FDECL3(write_one_file, char *, filename, static void FDECL3(write_one_file, char *, filename,
unsigned int, size, FILE *, outfile) uint64_t, size, FILE *, outfile)
{ {
char buffer[SECTOR_SIZE * NSECT]; char buffer[SECTOR_SIZE * NSECT];
FILE * infile; FILE * infile;
int remain; int64_t remain;
unsigned int use; size_t use;
if ((infile = fopen(filename, "rb")) == NULL) if ((infile = fopen(filename, "rb")) == NULL)
@ -260,10 +260,7 @@ static void FDECL3(write_one_file, char *, filename,
use = ROUND_UP(use); /* Round up to nearest sector boundary */ use = ROUND_UP(use); /* Round up to nearest sector boundary */
memset(buffer, 0, use); memset(buffer, 0, use);
if (fread(buffer, 1, use, infile) == 0) if (fread(buffer, 1, use, infile) == 0)
{ error (1, errno, "cannot read %llu bytes from %s", use, filename);
fprintf(stderr,"cannot read from %s\n",filename);
exit(1);
}
xfwrite(buffer, 1, use, outfile); xfwrite(buffer, 1, use, outfile);
last_extent_written += use/SECTOR_SIZE; last_extent_written += use/SECTOR_SIZE;
#if 0 #if 0
@ -298,12 +295,10 @@ static void FDECL1(write_files, FILE *, outfile)
{ {
if(dwpnt->table) if(dwpnt->table)
{ {
xfwrite(dwpnt->table, 1, ROUND_UP(dwpnt->size), outfile); write_one_file (dwpnt->table, dwpnt->size, outfile);
last_extent_written += ROUND_UP(dwpnt->size) / SECTOR_SIZE; table_size += dwpnt->size;
table_size += dwpnt->size; free (dwpnt->table);
/* fprintf(stderr,"Size %d ", dwpnt->size); */ }
free(dwpnt->table);
}
else else
{ {
@ -673,7 +668,7 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt)
last_extent += ROUND_UP(s_entry->size) >> 11; last_extent += ROUND_UP(s_entry->size) >> 11;
if(verbose > 2) if(verbose > 2)
{ {
fprintf(stderr,"%d %d %s\n", s_entry->starting_block, fprintf(stderr,"%llu %llu %s\n", s_entry->starting_block,
last_extent-1, whole_path); last_extent-1, whole_path);
} }
#ifdef DBG_ISO #ifdef DBG_ISO
@ -1131,17 +1126,17 @@ static int FDECL1(file_write, FILE *, outfile)
if( print_size > 0 ) if( print_size > 0 )
{ {
fprintf(stderr,"Total extents scheduled to be written = %d\n", fprintf(stderr,"Total extents scheduled to be written = %llu\n",
last_extent - session_start); last_extent - session_start);
exit(0); exit(0);
} }
if( verbose > 2 ) if( verbose > 2 )
{ {
#ifdef DBG_ISO #ifdef DBG_ISO
fprintf(stderr,"Total directory extents being written = %d\n", last_extent); fprintf(stderr,"Total directory extents being written = %llu\n", last_extent);
#endif #endif
fprintf(stderr,"Total extents scheduled to be written = %d\n", fprintf(stderr,"Total extents scheduled to be written = %llu\n",
last_extent - session_start); last_extent - session_start);
} }
@ -1158,7 +1153,7 @@ static int FDECL1(file_write, FILE *, outfile)
return 0; return 0;
} }
fprintf(stderr,"Total extents actually written = %d\n", fprintf(stderr,"Total extents actually written = %llu\n",
last_extent_written - session_start); last_extent_written - session_start);
/* /*
@ -1168,7 +1163,7 @@ static int FDECL1(file_write, FILE *, outfile)
if(should_write + session_start != last_extent) if(should_write + session_start != last_extent)
{ {
fprintf(stderr,"Number of extents written not what was predicted. Please fix.\n"); fprintf(stderr,"Number of extents written not what was predicted. Please fix.\n");
fprintf(stderr,"Predicted = %d, written = %d\n", should_write, last_extent); fprintf(stderr,"Predicted = %d, written = %llu\n", should_write, last_extent);
} }
fprintf(stderr,"Total translation table size: %d\n", table_size); fprintf(stderr,"Total translation table size: %d\n", table_size);