summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0018-Handle-files-changing-while-we-are-working.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:31:48 +0100
commit79c806cb404c2d85aeec45b40ea6adbeae9f6346 (patch)
tree5627bb72a24373b931e6a3d4190335bc904cfd88 /meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0018-Handle-files-changing-while-we-are-working.patch
parent84b7541abc2d7e59c22891219fce97d320d3bb33 (diff)
downloadpoky-79c806cb404c2d85aeec45b40ea6adbeae9f6346.tar.gz
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 (From OE-Core rev: 8f17e499cf91191727c8767e839738cb39c21655) Signed-off-by: Dexuan Cui <dexuan.cui@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0018-Handle-files-changing-while-we-are-working.patch')
-rw-r--r--meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0018-Handle-files-changing-while-we-are-working.patch89
1 files changed, 89 insertions, 0 deletions
diff --git a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0018-Handle-files-changing-while-we-are-working.patch b/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0018-Handle-files-changing-while-we-are-working.patch
new file mode 100644
index 0000000000..3ea877c4d4
--- /dev/null
+++ b/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/0018-Handle-files-changing-while-we-are-working.patch
@@ -0,0 +1,89 @@
1Upstream-Status: inappropriate
2
3From fd1f52c435099eab199f2b06eb411aab337d7f47 Mon Sep 17 00:00:00 2001
4From: Corey Minyard <cminyard@mvista.com>
5Date: Tue, 7 Jun 2011 07:29:53 -0500
6Subject: [PATCH 18/19] Handle files changing while we are working
7
8Files may change or be deleted between the lstat and the actual
9operation to read them and put them into the target filesystem.
10Handle this more gracefully. Warn on file deletions, and handle
11whatever size is read, not whatever size happens to be in the
12inode when we stat-ed it.
13
14Also clear the data to the end of an file's last block, to keep
15things clean.
16---
17 genext2fs.c | 30 ++++++++++++++++++------------
18 1 files changed, 18 insertions(+), 12 deletions(-)
19
20diff --git a/genext2fs.c b/genext2fs.c
21index 485393c..28ba94f 100644
22--- a/genext2fs.c
23+++ b/genext2fs.c
24@@ -1942,19 +1942,30 @@ fs_upgrade_rev1_largefile(filesystem *fs)
25
26 // make a file from a FILE*
27 static uint32
28-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)
29+mkfile_fs(filesystem *fs, uint32 parent_nod, const char *name, uint32 mode, FILE *f, uid_t uid, gid_t gid, uint32 ctime, uint32 mtime)
30 {
31 uint8 * b;
32 uint32 nod = mknod_fs(fs, parent_nod, name, mode|FM_IFREG, uid, gid, 0, 0, ctime, mtime);
33 nod_info *ni;
34 inode *node = get_nod(fs, nod, &ni);
35+ off_t size = 0;
36 size_t readbytes;
37 inode_pos ipos;
38+ int fullsize;
39
40 b = malloc(CB_SIZE);
41 if (!b)
42 error_msg_and_die("mkfile_fs: out of memory");
43 inode_pos_init(fs, &ipos, nod, INODE_POS_TRUNCATE, NULL);
44+ readbytes = fread(b, 1, CB_SIZE, f);
45+ while (readbytes) {
46+ fullsize = rndup(readbytes, BLOCKSIZE);
47+ // Fill to end of block with zeros.
48+ memset(b + readbytes, 0, fullsize - readbytes);
49+ extend_inode_blk(fs, &ipos, b, fullsize / BLOCKSIZE);
50+ size += readbytes;
51+ readbytes = fread(b, 1, CB_SIZE, f);
52+ }
53 if (size > 0x7fffffff) {
54 if (fs->sb->s_rev_level < 1)
55 fs_upgrade_rev1_largefile(fs);
56@@ -1962,15 +1973,6 @@ mkfile_fs(filesystem *fs, uint32 parent_nod, const char *name, uint32 mode, off_
57 }
58 node->i_dir_acl = size >> 32;
59 node->i_size = size;
60- while (size) {
61- readbytes = fread(b, 1, CB_SIZE, f);
62- if ((size < CB_SIZE && readbytes != size)
63- || (size >= CB_SIZE && readbytes != CB_SIZE))
64- error_msg_and_die("fread failed");
65- extend_inode_blk(fs, &ipos, b,
66- rndup(readbytes, BLOCKSIZE) / BLOCKSIZE);
67- size -= readbytes;
68- }
69 inode_pos_finish(fs, &ipos);
70 put_nod(ni);
71 free(b);
72@@ -2256,8 +2258,12 @@ add2fs_from_dir(filesystem *fs, uint32 this_nod, int squash_uids, int squash_per
73 free(lnk);
74 break;
75 case S_IFREG:
76- fh = xfopen(dent->d_name, "rb");
77- nod = mkfile_fs(fs, this_nod, name, mode, st.st_size, fh, uid, gid, ctime, mtime);
78+ fh = fopen(dent->d_name, "rb");
79+ if (!fh) {
80+ error_msg("Unable to open file %s", dent->d_name);
81+ break;
82+ }
83+ nod = mkfile_fs(fs, this_nod, name, mode, fh, uid, gid, ctime, mtime);
84 fclose(fh);
85 break;
86 case S_IFDIR:
87--
881.7.4.1
89