]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2009-11-11 Robert Millan <rmh.grub@aybabtu.com>
authorRobert Millan <rmh@aybabtu.com>
Wed, 11 Nov 2009 00:23:29 +0000 (00:23 +0000)
committerRobert Millan <rmh@aybabtu.com>
Wed, 11 Nov 2009 00:23:29 +0000 (00:23 +0000)
        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.

ChangeLog
conf/common.rmk
util/mkisofs/mkisofs.c
util/mkisofs/mkisofs.h
util/mkisofs/tree.c
util/mkisofs/write.c

index 33e154e99972e25d51c87a5402ce9a2aa6237fcd..b27b5e2904361f70f6fa3602e51980c63263bfac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * util/mkisofs/mkisofs.c (ld_options): Fix a spelling mistake.
index 6340373c36d6295b76c73481211a936c5ba7059d..a66bd97fd35afebdf003b14ed2f376ce06b20546 100644 (file)
@@ -37,7 +37,9 @@ grub_mkisofs_SOURCES = util/mkisofs/eltorito.c                                \
        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
index 8e256c00587ba8a43a29fd814a68860e1f1bb11c..8497723e68a161805e1450f91571dc10db5b991a 100644 (file)
@@ -68,9 +68,9 @@ static char version_string[] = "mkisofs 1.12b5";
 
 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;
@@ -1365,7 +1365,7 @@ parse_input_files:
       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
index e32918682ac95e54eb639804a92836784f5fee65..52acc72b5cca8e88d192d85c69c73956709c2a2b 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 #include <stdio.h>
+#include <stdint.h>
 #include <prototyp.h>
 #include <sys/stat.h>
 
@@ -159,8 +160,8 @@ struct directory_entry{
   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;
@@ -266,21 +267,13 @@ struct directory{
   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];
@@ -353,7 +346,7 @@ extern void DECL(generate_one_directory,(struct directory *, FILE*));
 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));
index 9d5418965d1f5974830a034e61215f43816f9527..355dd9873478f1ed864c3eab45a4ed398f940ce4 100644 (file)
@@ -6,9 +6,11 @@
 
    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,
@@ -17,7 +19,7 @@
    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 $";
@@ -141,6 +143,10 @@ FDECL2(stat_filter, char *, path, struct stat *, st)
   int result = stat(path, st);
   if (result >= 0 && rationalize)
     stat_fix(st);
+
+  if ((unsigned) st->st_size > UINT32_MAX)
+    result = -1;
+
   return result;
 }
 
@@ -150,6 +156,10 @@ FDECL2(lstat_filter, char *, path, struct stat *, st)
   int result = lstat(path, st);
   if (result >= 0 && rationalize)
     stat_fix(st);
+
+  if ((unsigned) st->st_size > UINT32_MAX)
+    result = -1;
+
   return result;
 }
 
index 8d46d89c6591e266e2c0f8dccf00b31997b29bca..7c45404928312bf17893e77ea54385b8bb2cb6f8 100644 (file)
@@ -127,7 +127,7 @@ void FDECL2(set_733, char *, pnt, unsigned int, i)
      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?
@@ -156,11 +156,11 @@ void FDECL4(xfwrite, void *, buffer, int, count, int, size, FILE *, file)
        }
      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;
@@ -171,14 +171,14 @@ struct deferred_write
 {
   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;
 
@@ -235,12 +235,12 @@ static int FDECL1(assign_directory_addresses, struct directory *, node)
 }
 
 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) 
@@ -260,10 +260,7 @@ static void FDECL3(write_one_file, char *, filename,
          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
@@ -298,12 +295,10 @@ static void FDECL1(write_files, FILE *, outfile)
      {
          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 
          {
 
@@ -673,7 +668,7 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt)
                    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
@@ -1131,17 +1126,17 @@ static int FDECL1(file_write, FILE *, outfile)
 
   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);
     }
 
@@ -1158,7 +1153,7 @@ static int FDECL1(file_write, FILE *, outfile)
       return 0;
     }
 
-  fprintf(stderr,"Total extents actually written = %d\n", 
+  fprintf(stderr,"Total extents actually written = %llu\n", 
          last_extent_written - session_start);
 
   /* 
@@ -1168,7 +1163,7 @@ static int FDECL1(file_write, FILE *, outfile)
   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);