Blame SOURCES/e2fsprogs-1.45.6-mke2fs-fix-up-check-for-hardlinks-always-false-if-in.patch

a77133
From d74f2e031418fb877c97c86a9c6b58eb30a4592c Mon Sep 17 00:00:00 2001
a77133
From: Hongxu Jia <hongxu.jia@windriver.com>
a77133
Date: Tue, 21 Jul 2020 18:25:03 -0700
a77133
Subject: [PATCH 10/46] mke2fs: fix up check for hardlinks always false if
a77133
 inode > 0xFFFFFFFF
a77133
Content-Type: text/plain
a77133
a77133
While file has a large inode number (> 0xFFFFFFFF), mkfs.ext4 could
a77133
not parse hardlink correctly.
a77133
a77133
Prepare three hardlink files for mkfs.ext4
a77133
a77133
$ ls -il rootfs_ota/a rootfs_ota/boot/b rootfs_ota/boot/c
a77133
11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/a
a77133
11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/boot/b
a77133
11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/boot/c
a77133
a77133
$ truncate -s 1M rootfs_ota.ext4
a77133
a77133
$ mkfs.ext4 -F -i 8192 rootfs_ota.ext4 -L otaroot -U fd5f8768-c779-4dc9-adde-165a3d863349 -d rootfs_ota
a77133
a77133
$ mkdir mnt && sudo mount rootfs_ota.ext4 mnt
a77133
a77133
$ ls -il mnt/a mnt/boot/b mnt/boot/c
a77133
12 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/a
a77133
14 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/boot/b
a77133
15 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/boot/c
a77133
a77133
After applying this fix
a77133
$ ls -il mnt/a mnt/boot/b mnt/boot/c
a77133
12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/a
a77133
12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/boot/b
a77133
12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/boot/c
a77133
a77133
Since commit [382ed4a1 e2fsck: use proper types for variables][1]
a77133
applied, it used ext2_ino_t instead of ino_t for referencing inode
a77133
numbers, but the type of is_hardlink's `ino' should not be instead,
a77133
The ext2_ino_t is 32bit, if inode > 0xFFFFFFFF, its value will be
a77133
truncated.
a77133
a77133
Add a debug printf to show the value of inode, when it check for hardlink
a77133
files, it will always return false if inode > 0xFFFFFFFF
a77133
|--- a/misc/create_inode.c
a77133
|+++ b/misc/create_inode.c
a77133
|@@ -605,6 +605,7 @@ static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ext2_ino_t ino)
a77133
| {
a77133
|        int i;
a77133
|
a77133
|+       printf("%s %d, %lX, %lX\n", __FUNCTION__, __LINE__, hdlinks->hdl[i].src_ino, ino);
a77133
|        for (i = 0; i < hdlinks->count; i++) {
a77133
|                if (hdlinks->hdl[i].src_dev == dev &&
a77133
|                    hdlinks->hdl[i].src_ino == ino)
a77133
a77133
Here is debug message:
a77133
is_hardlink 608, 2913DB886, 913DB886
a77133
a77133
The length of ext2_ino_t is 32bit (typedef __u32 __bitwise ext2_ino_t;),
a77133
and ino_t is 64bit on 64bit system (such as x86-64), recover `ino' to ino_t.
a77133
a77133
[1] https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit/?id=382ed4a1c2b60acb9db7631e86dda207bde6076e
a77133
a77133
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
a77133
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
a77133
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
a77133
---
a77133
 misc/create_inode.c | 2 +-
a77133
 1 file changed, 1 insertion(+), 1 deletion(-)
a77133
a77133
diff --git a/misc/create_inode.c b/misc/create_inode.c
a77133
index e8d1df6b..837f3875 100644
a77133
--- a/misc/create_inode.c
a77133
+++ b/misc/create_inode.c
a77133
@@ -601,7 +601,7 @@ out:
a77133
 	return err;
a77133
 }
a77133
 
a77133
-static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ext2_ino_t ino)
a77133
+static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ino_t ino)
a77133
 {
a77133
 	int i;
a77133
 
a77133
-- 
a77133
2.35.1
a77133