summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2020-07-20 19:16:01 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-07-22 12:45:56 +0100
commitd128ded2d16f9163d225397a28132fabdd960fc2 (patch)
tree14edb00a1861c32547fc7c9870a0d503ad907e07
parentba11042bbd098d1224bfe84ef3818dd3a08a5d8a (diff)
downloadpoky-d128ded2d16f9163d225397a28132fabdd960fc2.tar.gz
e2fsprogs: fix up check for hardlinks always false if inode > 0xFFFFFFFF
While file has a large inode number (> 0xFFFFFFFF), mkfs.ext4 could not parse hardlink correctly. Prepare three hardlink files for mkfs.ext4 $ ls -il rootfs_ota/a rootfs_ota/boot/b rootfs_ota/boot/c 11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/a 11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/boot/b 11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/boot/c $ truncate -s 1M rootfs_ota.ext4 $ mkfs.ext4 -F -i 8192 rootfs_ota.ext4 -L otaroot -U fd5f8768-c779-4dc9-adde-165a3d863349 -d rootfs_ota $ mkdir mnt && sudo mount rootfs_ota.ext4 mnt $ ls -il mnt/rootfs_ota/a mnt/rootfs_ota/boot/b 12 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/a 14 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/boot/b 15 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/boot/c After applying this fix $ ls -il mnt/rootfs_ota/a mnt/rootfs_ota/boot/b 12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/a 12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/boot/b 12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/boot/c (From OE-Core rev: 3b2c7350a7f3fb20f2b61ddb41f81959a54bc873) Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-fix-up-check-for-hardlinks-always-false-if-inode-0xF.patch55
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs_1.45.6.bb1
2 files changed, 56 insertions, 0 deletions
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-fix-up-check-for-hardlinks-always-false-if-inode-0xF.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-fix-up-check-for-hardlinks-always-false-if-inode-0xF.patch
new file mode 100644
index 0000000000..0e8cbad25a
--- /dev/null
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-fix-up-check-for-hardlinks-always-false-if-inode-0xF.patch
@@ -0,0 +1,55 @@
1From dcb36fd007ddb32d8c5cfcf5e9ddb3d713d65396 Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Tue, 21 Jul 2020 09:43:03 +0800
4Subject: [PATCH] fix up check for hardlinks always false if inode > 0xFFFFFFFF
5
6Since commit [382ed4a1 e2fsck: use proper types for variables][1]
7applied, it used ext2_ino_t instead of ino_t for referencing inode
8numbers, but the type of is_hardlink's `ino' should not be instead,
9The ext2_ino_t is 32bit, if inode > 0xFFFFFFFF, its value will be
10truncated.
11
12Add a debug printf to show the value of inode, when it check for hardlink
13files, it will always return false if inode > 0xFFFFFFFF
14|--- a/misc/create_inode.c
15|+++ b/misc/create_inode.c
16|@@ -605,6 +605,7 @@ static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ext2_ino_t ino)
17| {
18| int i;
19|
20|+ printf("%s %d, %lX, %lX\n", __FUNCTION__, __LINE__, hdlinks->hdl[i].src_ino, ino);
21| for (i = 0; i < hdlinks->count; i++) {
22| if (hdlinks->hdl[i].src_dev == dev &&
23| hdlinks->hdl[i].src_ino == ino)
24
25Here is debug message:
26is_hardlink 608, 2913DB886, 913DB886
27
28The length of ext2_ino_t is 32bit (typedef __u32 __bitwise ext2_ino_t;),
29and ino_t is 64bit on 64bit system (such as x86-64), recover `ino' to ino_t.
30
31[1] https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit/?id=382ed4a1c2b60acb9db7631e86dda207bde6076e
32
33Upstream-Status: Submitted [https://github.com/tytso/e2fsprogs/pull/48]
34
35Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
36---
37 misc/create_inode.c | 2 +-
38 1 file changed, 1 insertion(+), 1 deletion(-)
39
40diff --git a/misc/create_inode.c b/misc/create_inode.c
41index e8d1df6b..837f3875 100644
42--- a/misc/create_inode.c
43+++ b/misc/create_inode.c
44@@ -601,7 +601,7 @@ out:
45 return err;
46 }
47
48-static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ext2_ino_t ino)
49+static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ino_t ino)
50 {
51 int i;
52
53--
542.18.2
55
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.45.6.bb b/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.45.6.bb
index 4ad5b03cac..15054768dd 100644
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.45.6.bb
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.45.6.bb
@@ -6,6 +6,7 @@ SRC_URI += "file://remove.ldconfig.call.patch \
6 file://mkdir_p.patch \ 6 file://mkdir_p.patch \
7 file://0001-configure.ac-correct-AM_GNU_GETTEXT.patch \ 7 file://0001-configure.ac-correct-AM_GNU_GETTEXT.patch \
8 file://0001-intl-do-not-try-to-use-gettext-defines-that-no-longe.patch \ 8 file://0001-intl-do-not-try-to-use-gettext-defines-that-no-longe.patch \
9 file://0001-fix-up-check-for-hardlinks-always-false-if-inode-0xF.patch \
9 " 10 "
10 11
11SRC_URI_append_class-native = " file://e2fsprogs-fix-missing-check-for-permission-denied.patch \ 12SRC_URI_append_class-native = " file://e2fsprogs-fix-missing-check-for-permission-denied.patch \