summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2013-08-22 15:47:23 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-26 11:47:19 +0100
commit1b214059be350a3abfc57140cbad00f5bab437bf (patch)
treedb6ed9da603aa7ce515e353595e78e04a8722190
parent2cece576b351228cb24bf24a53845646a51f7f6b (diff)
downloadpoky-1b214059be350a3abfc57140cbad00f5bab437bf.tar.gz
e2fsprogs: properly set up extent header in do_write
do_write doesn't fully set up the first extent header on a new inode, so if we write a 0-length file, and don't write any data to the new file, we end up creating something that looks corrupt to kernelspace: EXT4-fs error (device loop0): ext4_ext_check_inode:464: inode #12: comm ls: bad header/extent: invalid magic - magic 0, entries 0, max 0(0), depth 0(0) Do something similar to ext4_ext_tree_init() here, and fill out the first extent header upon creation to avoid this. [YOCTO #3848] (From OE-Core rev: 7d1e51681d25f6e6d2c20744825723ad5c83861c) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/debugfs-extent-header.patch47
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.8.bb2
2 files changed, 49 insertions, 0 deletions
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/debugfs-extent-header.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/debugfs-extent-header.patch
new file mode 100644
index 0000000000..ae44730192
--- /dev/null
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/debugfs-extent-header.patch
@@ -0,0 +1,47 @@
1debugfs: properly set up extent header in do_write
2
3do_write doesn't fully set up the first extent header on a new
4inode, so if we write a 0-length file, and don't write any data
5to the new file, we end up creating something that looks corrupt
6to kernelspace:
7
8EXT4-fs error (device loop0): ext4_ext_check_inode:464: inode #12: comm ls: bad header/extent: invalid magic - magic 0, entries 0, max 0(0), depth 0(0)
9
10Do something similar to ext4_ext_tree_init() here, and
11fill out the first extent header upon creation to avoid this.
12
13Upstream-Status: Backport
14
15Reported-by: Robert Yang <liezhi.yang@windriver.com>
16Signed-off-by: Eric Sandeen <sandeen@redhat.com>
17---
18 debugfs/debugfs.c | 13 ++++++++++++-
19 1 file changed, 12 insertions(+), 1 deletion(-)
20
21diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
22--- a/debugfs/debugfs.c
23+++ b/debugfs/debugfs.c
24@@ -1726,8 +1726,19 @@ void do_write(int argc, char *argv[])
25 inode.i_links_count = 1;
26 inode.i_size = statbuf.st_size;
27 if (current_fs->super->s_feature_incompat &
28- EXT3_FEATURE_INCOMPAT_EXTENTS)
29+ EXT3_FEATURE_INCOMPAT_EXTENTS) {
30+ int i;
31+ struct ext3_extent_header *eh;
32+
33+ eh = (struct ext3_extent_header *) &inode.i_block[0];
34+ eh->eh_depth = 0;
35+ eh->eh_entries = 0;
36+ eh->eh_magic = EXT3_EXT_MAGIC;
37+ i = (sizeof(inode.i_block) - sizeof(*eh)) /
38+ sizeof(struct ext3_extent);
39+ eh->eh_max = ext2fs_cpu_to_le16(i);
40 inode.i_flags |= EXT4_EXTENTS_FL;
41+ }
42 if (debugfs_write_new_inode(newfile, &inode, argv[0])) {
43 close(fd);
44 return;
45--
461.8.1.2
47
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.8.bb b/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.8.bb
index 2681f98f00..b54c6a7685 100644
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.8.bb
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.8.bb
@@ -6,6 +6,8 @@ SRC_URI += "file://acinclude.m4 \
6 file://debugfs-too-short.patch \ 6 file://debugfs-too-short.patch \
7 file://debugfs-sparse-copy.patch \ 7 file://debugfs-sparse-copy.patch \
8 file://fix-icache.patch \ 8 file://fix-icache.patch \
9 file://debugfs-extent-header.patch \
10 file://populate-extfs.sh \
9" 11"
10 12
11SRC_URI[md5sum] = "8ef664b6eb698aa6b733df59b17b9ed4" 13SRC_URI[md5sum] = "8ef664b6eb698aa6b733df59b17b9ed4"