diff options
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.patch | 103 |
1 files changed, 0 insertions, 103 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 deleted file mode 100644 index 52dec56d5f..0000000000 --- a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0011-Copy-files-into-the-filesystem-a-piece-at-a-time.patch +++ /dev/null | |||
| @@ -1,103 +0,0 @@ | |||
| 1 | Upstream-Status: inappropriate | ||
| 2 | |||
| 3 | From 0a7d5b11e62e54f88ce3a49d0c2327d537b3f531 Mon Sep 17 00:00:00 2001 | ||
| 4 | From: Corey Minyard <cminyard@mvista.com> | ||
| 5 | Date: Sun, 5 Jun 2011 15:42:24 -0500 | ||
| 6 | Subject: [PATCH 11/19] Copy files into the filesystem a piece at a time | ||
| 7 | |||
| 8 | Instead of malloc-ing and entire files-worth of memory, reading it in, | ||
| 9 | and writing it to the filesystem, do it a piece at a time. This allows | ||
| 10 | very large files to be supported. | ||
| 11 | |||
| 12 | Also, use off_t and make it 64-bits so it supports filesystems and files | ||
| 13 | larger than 2GB. Full support for >2GB files is not quite here, that | ||
| 14 | requires rev 1 filesystem support, which is coming later. | ||
| 15 | --- | ||
| 16 | genext2fs.c | 35 +++++++++++++++++++++++------------ | ||
| 17 | 1 files changed, 23 insertions(+), 12 deletions(-) | ||
| 18 | |||
| 19 | diff --git a/genext2fs.c b/genext2fs.c | ||
| 20 | index f79438d..8a7f589 100644 | ||
| 21 | --- a/genext2fs.c | ||
| 22 | +++ b/genext2fs.c | ||
| 23 | @@ -53,6 +53,12 @@ | ||
| 24 | // along with -q, -P, -U | ||
| 25 | |||
| 26 | |||
| 27 | +/* | ||
| 28 | + * Allow fseeko/off_t to be 64-bit offsets to allow filesystems and | ||
| 29 | + * individual files >2GB. | ||
| 30 | + */ | ||
| 31 | +#define _FILE_OFFSET_BITS 64 | ||
| 32 | + | ||
| 33 | #include <config.h> | ||
| 34 | #include <stdio.h> | ||
| 35 | |||
| 36 | @@ -603,7 +609,6 @@ struct hdlinks_s | ||
| 37 | typedef struct | ||
| 38 | { | ||
| 39 | FILE *f; | ||
| 40 | - uint8 *data; | ||
| 41 | superblock *sb; | ||
| 42 | groupdescriptor *gd; | ||
| 43 | uint32 nheadblocks; | ||
| 44 | @@ -1907,30 +1912,38 @@ mklink_fs(filesystem *fs, uint32 parent_nod, const char *name, size_t size, uint | ||
| 45 | return nod; | ||
| 46 | } | ||
| 47 | |||
| 48 | +#define COPY_BLOCKS 16 | ||
| 49 | +#define CB_SIZE (COPY_BLOCKS * BLOCKSIZE) | ||
| 50 | + | ||
| 51 | // make a file from a FILE* | ||
| 52 | static uint32 | ||
| 53 | -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) | ||
| 54 | +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) | ||
| 55 | { | ||
| 56 | uint8 * b; | ||
| 57 | uint32 nod = mknod_fs(fs, parent_nod, name, mode|FM_IFREG, uid, gid, 0, 0, ctime, mtime); | ||
| 58 | nod_info *ni; | ||
| 59 | inode *node = get_nod(fs, nod, &ni); | ||
| 60 | + size_t readbytes; | ||
| 61 | inode_pos ipos; | ||
| 62 | |||
| 63 | + | ||
| 64 | + b = malloc(CB_SIZE); | ||
| 65 | + if (!b) | ||
| 66 | + error_msg_and_die("mkfile_fs: out of memory"); | ||
| 67 | inode_pos_init(fs, &ipos, nod, INODE_POS_TRUNCATE, NULL); | ||
| 68 | node->i_size = size; | ||
| 69 | - if (size) { | ||
| 70 | - if(!(b = (uint8*)calloc(rndup(size, BLOCKSIZE), 1))) | ||
| 71 | - error_msg_and_die("not enough mem to read file '%s'", name); | ||
| 72 | - if(f) | ||
| 73 | - if (fread(b, size, 1, f) != 1) // FIXME: ugly. use mmap() ... | ||
| 74 | - error_msg_and_die("fread failed"); | ||
| 75 | + while (size) { | ||
| 76 | + readbytes = fread(b, 1, CB_SIZE, f); | ||
| 77 | + if ((size < CB_SIZE && readbytes != size) | ||
| 78 | + || (size >= CB_SIZE && readbytes != CB_SIZE)) | ||
| 79 | + error_msg_and_die("fread failed"); | ||
| 80 | extend_inode_blk(fs, &ipos, b, | ||
| 81 | - rndup(size, BLOCKSIZE) / BLOCKSIZE); | ||
| 82 | - free(b); | ||
| 83 | + rndup(readbytes, BLOCKSIZE) / BLOCKSIZE); | ||
| 84 | + size -= readbytes; | ||
| 85 | } | ||
| 86 | inode_pos_finish(fs, &ipos); | ||
| 87 | put_nod(ni); | ||
| 88 | + free(b); | ||
| 89 | return nod; | ||
| 90 | } | ||
| 91 | |||
| 92 | @@ -2306,8 +2319,6 @@ alloc_fs(int swapit, char *fname, uint32 nbblocks, FILE *srcfile) | ||
| 93 | if (!fs->hdlinks.hdl) | ||
| 94 | error_msg_and_die("Not enough memory"); | ||
| 95 | fs->hdlinks.count = 0 ; | ||
| 96 | - fs->sb = (superblock *) (fs->data + BLOCKSIZE); | ||
| 97 | - fs->gd = (groupdescriptor *) (fs->sb + 1); | ||
| 98 | |||
| 99 | if (strcmp(fname, "-") == 0) | ||
| 100 | fs->f = tmpfile(); | ||
| 101 | -- | ||
| 102 | 1.7.4.1 | ||
| 103 | |||
