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-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>
* util/mkisofs/mkisofs.c (ld_options): Fix a spelling mistake.
util/mkisofs/write.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.
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
char * outfile;
FILE * discimage;
-unsigned int next_extent = 0;
-unsigned int last_extent = 0;
-unsigned int session_start = 0;
+uint64_t next_extent = 0;
+uint64_t last_extent = 0;
+uint64_t session_start = 0;
unsigned int path_table_size = 0;
unsigned int path_table[4] = {0,};
unsigned int path_blocks = 0;
fprintf(stderr,"Max brk space used %x\n",
(unsigned int)(((unsigned long)sbrk(0)) - mem_start));
#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
*/
#include <stdio.h>
+#include <stdint.h>
#include <prototyp.h>
#include <sys/stat.h>
struct directory_entry * next;
struct directory_entry * jnext;
struct iso_directory_record isorec;
- unsigned int starting_block;
- unsigned int size;
+ uint64_t starting_block;
+ uint64_t size;
unsigned short priority;
unsigned char jreclen; /* Joliet record len */
char * name;
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 struct directory * root;
extern struct directory * reloc_dir;
-extern unsigned int next_extent;
-extern unsigned int last_extent;
-extern unsigned int last_extent_written;
-extern unsigned int session_start;
+extern uint64_t next_extent;
+extern uint64_t last_extent;
+extern uint64_t last_extent_written;
+extern uint64_t session_start;
extern unsigned int path_table_size;
extern unsigned int path_table[4];
extern void DECL(memcpy_max, (char *, char *, int));
extern int DECL(oneblock_size, (int starting_extent));
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_722, (char * pnt, unsigned int i));
extern void DECL(outputlist_insert, (struct output_fragment * frag));
Copyright 1993 Yggdrasil Computing, Incorporated
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
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
- 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.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
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. */
static char rcsid[] ="$Id: tree.c,v 1.29 1999/03/07 17:41:19 eric Exp $";
int result = stat(path, st);
if (result >= 0 && rationalize)
stat_fix(st);
+
+ if ((unsigned) st->st_size > UINT32_MAX)
+ result = -1;
+
return result;
}
int result = lstat(path, st);
if (result >= 0 && rationalize)
stat_fix(st);
+
+ if ((unsigned) st->st_size > UINT32_MAX)
+ result = -1;
+
return result;
}
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?
}
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);
}
count-=got,*(char**)&buffer+=size*got;
{
struct deferred_write * next;
char * table;
- unsigned int extent;
- unsigned int size;
+ uint64_t extent;
+ uint64_t size;
char * name;
};
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 time_t begun;
}
static void FDECL3(write_one_file, char *, filename,
- unsigned int, size, FILE *, outfile)
+ uint64_t, size, FILE *, outfile)
{
char buffer[SECTOR_SIZE * NSECT];
FILE * infile;
- int remain;
- unsigned int use;
+ int64_t remain;
+ size_t use;
if ((infile = fopen(filename, "rb")) == NULL)
use = ROUND_UP(use); /* Round up to nearest sector boundary */
memset(buffer, 0, use);
if (fread(buffer, 1, use, infile) == 0)
- {
- fprintf(stderr,"cannot read from %s\n",filename);
- exit(1);
- }
+ error (1, errno, "cannot read %llu bytes from %s", use, filename);
xfwrite(buffer, 1, use, outfile);
last_extent_written += use/SECTOR_SIZE;
#if 0
{
if(dwpnt->table)
{
- xfwrite(dwpnt->table, 1, ROUND_UP(dwpnt->size), outfile);
- last_extent_written += ROUND_UP(dwpnt->size) / SECTOR_SIZE;
- table_size += dwpnt->size;
-/* fprintf(stderr,"Size %d ", dwpnt->size); */
- free(dwpnt->table);
- }
+ write_one_file (dwpnt->table, dwpnt->size, outfile);
+ table_size += dwpnt->size;
+ free (dwpnt->table);
+ }
else
{
last_extent += ROUND_UP(s_entry->size) >> 11;
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);
}
#ifdef DBG_ISO
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);
exit(0);
}
if( verbose > 2 )
{
#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
- fprintf(stderr,"Total extents scheduled to be written = %d\n",
+ fprintf(stderr,"Total extents scheduled to be written = %llu\n",
last_extent - session_start);
}
return 0;
}
- fprintf(stderr,"Total extents actually written = %d\n",
+ fprintf(stderr,"Total extents actually written = %llu\n",
last_extent_written - session_start);
/*
if(should_write + session_start != last_extent)
{
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);