summaryrefslogtreecommitdiff
path: root/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0011-Copy-files-into-the-filesystem-a-piece-at-a-time.patch
diff options
context:
space:
mode:
authorDexuan Cui <dexuan.cui@intel.com>2012-03-29 00:35:09 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-04-02 04:26:09 +0100
commit8f17e499cf91191727c8767e839738cb39c21655 (patch)
treeff928b8e77c62375328841aaa822a1d95ce5dd04 /meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0011-Copy-files-into-the-filesystem-a-piece-at-a-time.patch
parentb3ccc630e6c12a75111b1f7ca877e17d8d4e1dc7 (diff)
downloadopenembedded-core-8f17e499cf91191727c8767e839738cb39c21655.tar.gz
openembedded-core-8f17e499cf91191727c8767e839738cb39c21655.tar.bz2
openembedded-core-8f17e499cf91191727c8767e839738cb39c21655.tar.xz
openembedded-core-8f17e499cf91191727c8767e839738cb39c21655.zip
genext2fs: support large files and filesystems without using large amounts of memory
update_to_1.95.patch was generated by making a diff bewteen the 1.4.1 release and the latest 1.9.5 version in the cvs repo: http://genext2fs.cvs.sourceforge.net/viewvc/genext2fs/genext2fs/genext2fs.c?revision=1.95 The patches 0001-0019 come from mailing list of genext2fs-devel http://sourceforge.net/mailarchive/forum.php?forum_name=genext2fs-devel&max_rows=100&style=flat&viewmonth=201106 Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
Diffstat (limited to 'meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0011-Copy-files-into-the-filesystem-a-piece-at-a-time.patch')
-rw-r--r--meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0011-Copy-files-into-the-filesystem-a-piece-at-a-time.patch103
1 files changed, 103 insertions, 0 deletions
diff --git a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0011-Copy-files-into-the-filesystem-a-piece-at-a-time.patch b/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0011-Copy-files-into-the-filesystem-a-piece-at-a-time.patch
new file mode 100644
index 000000000..52dec56d5
--- /dev/null
+++ b/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0011-Copy-files-into-the-filesystem-a-piece-at-a-time.patch
@@ -0,0 +1,103 @@
+Upstream-Status: inappropriate
+
+From 0a7d5b11e62e54f88ce3a49d0c2327d537b3f531 Mon Sep 17 00:00:00 2001
+From: Corey Minyard <cminyard@mvista.com>
+Date: Sun, 5 Jun 2011 15:42:24 -0500
+Subject: [PATCH 11/19] Copy files into the filesystem a piece at a time
+
+Instead of malloc-ing and entire files-worth of memory, reading it in,
+and writing it to the filesystem, do it a piece at a time. This allows
+very large files to be supported.
+
+Also, use off_t and make it 64-bits so it supports filesystems and files
+larger than 2GB. Full support for >2GB files is not quite here, that
+requires rev 1 filesystem support, which is coming later.
+---
+ genext2fs.c | 35 +++++++++++++++++++++++------------
+ 1 files changed, 23 insertions(+), 12 deletions(-)
+
+diff --git a/genext2fs.c b/genext2fs.c
+index f79438d..8a7f589 100644
+--- a/genext2fs.c
++++ b/genext2fs.c
+@@ -53,6 +53,12 @@
+ // along with -q, -P, -U
+
+
++/*
++ * Allow fseeko/off_t to be 64-bit offsets to allow filesystems and
++ * individual files >2GB.
++ */
++#define _FILE_OFFSET_BITS 64
++
+ #include <config.h>
+ #include <stdio.h>
+
+@@ -603,7 +609,6 @@ struct hdlinks_s
+ typedef struct
+ {
+ FILE *f;
+- uint8 *data;
+ superblock *sb;
+ groupdescriptor *gd;
+ uint32 nheadblocks;
+@@ -1907,30 +1912,38 @@ mklink_fs(filesystem *fs, uint32 parent_nod, const char *name, size_t size, uint
+ return nod;
+ }
+
++#define COPY_BLOCKS 16
++#define CB_SIZE (COPY_BLOCKS * BLOCKSIZE)
++
+ // make a file from a FILE*
+ static uint32
+-mkfile_fs(filesystem *fs, uint32 parent_nod, const char *name, uint32 mode, size_t size, FILE *f, uid_t uid, gid_t gid, uint32 ctime, uint32 mtime)
++mkfile_fs(filesystem *fs, uint32 parent_nod, const char *name, uint32 mode, off_t size, FILE *f, uid_t uid, gid_t gid, uint32 ctime, uint32 mtime)
+ {
+ uint8 * b;
+ uint32 nod = mknod_fs(fs, parent_nod, name, mode|FM_IFREG, uid, gid, 0, 0, ctime, mtime);
+ nod_info *ni;
+ inode *node = get_nod(fs, nod, &ni);
++ size_t readbytes;
+ inode_pos ipos;
+
++
++ b = malloc(CB_SIZE);
++ if (!b)
++ error_msg_and_die("mkfile_fs: out of memory");
+ inode_pos_init(fs, &ipos, nod, INODE_POS_TRUNCATE, NULL);
+ node->i_size = size;
+- if (size) {
+- if(!(b = (uint8*)calloc(rndup(size, BLOCKSIZE), 1)))
+- error_msg_and_die("not enough mem to read file '%s'", name);
+- if(f)
+- if (fread(b, size, 1, f) != 1) // FIXME: ugly. use mmap() ...
+- error_msg_and_die("fread failed");
++ while (size) {
++ readbytes = fread(b, 1, CB_SIZE, f);
++ if ((size < CB_SIZE && readbytes != size)
++ || (size >= CB_SIZE && readbytes != CB_SIZE))
++ error_msg_and_die("fread failed");
+ extend_inode_blk(fs, &ipos, b,
+- rndup(size, BLOCKSIZE) / BLOCKSIZE);
+- free(b);
++ rndup(readbytes, BLOCKSIZE) / BLOCKSIZE);
++ size -= readbytes;
+ }
+ inode_pos_finish(fs, &ipos);
+ put_nod(ni);
++ free(b);
+ return nod;
+ }
+
+@@ -2306,8 +2319,6 @@ alloc_fs(int swapit, char *fname, uint32 nbblocks, FILE *srcfile)
+ if (!fs->hdlinks.hdl)
+ error_msg_and_die("Not enough memory");
+ fs->hdlinks.count = 0 ;
+- fs->sb = (superblock *) (fs->data + BLOCKSIZE);
+- fs->gd = (groupdescriptor *) (fs->sb + 1);
+
+ if (strcmp(fname, "-") == 0)
+ fs->f = tmpfile();
+--
+1.7.4.1
+