Gentoo Archives: gentoo-commits

From: Florian Schmaus <flow@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/erofs-utils/files/, sys-fs/erofs-utils/
Date: Tue, 18 Jan 2022 07:58:56
Message-Id: 1642492720.471be79f45484e8f2f1fe7b7e769ad7f8e414659.flow@gentoo
1 commit: 471be79f45484e8f2f1fe7b7e769ad7f8e414659
2 Author: WANG Xuerui <git <AT> xen0n <DOT> name>
3 AuthorDate: Tue Jan 18 06:52:51 2022 +0000
4 Commit: Florian Schmaus <flow <AT> gentoo <DOT> org>
5 CommitDate: Tue Jan 18 07:58:40 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=471be79f
7
8 sys-fs/erofs-utils: fix build on ppc64le
9
10 Tested with a fresh ppc64le chroot and qemu.
11
12 Package-Manager: Portage-3.0.30, Repoman-3.0.3
13 Signed-off-by: WANG Xuerui <git <AT> xen0n.name>
14 Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
15
16 sys-fs/erofs-utils/erofs-utils-1.4.ebuild | 4 +
17 .../files/1.4-dump-fix-de-nid-issues.patch | 134 +++++++++++++++++++++
18 2 files changed, 138 insertions(+)
19
20 diff --git a/sys-fs/erofs-utils/erofs-utils-1.4.ebuild b/sys-fs/erofs-utils/erofs-utils-1.4.ebuild
21 index 1682bcdfb6d0..be9b257859bf 100644
22 --- a/sys-fs/erofs-utils/erofs-utils-1.4.ebuild
23 +++ b/sys-fs/erofs-utils/erofs-utils-1.4.ebuild
24 @@ -24,6 +24,10 @@ RDEPEND="
25 DEPEND="${RDEPEND}"
26 BDEPEND="virtual/pkgconfig"
27
28 +PATCHES=(
29 + "${FILESDIR}/${PV}-dump-fix-de-nid-issues.patch"
30 +)
31 +
32 src_prepare() {
33 default
34 eautoreconf
35
36 diff --git a/sys-fs/erofs-utils/files/1.4-dump-fix-de-nid-issues.patch b/sys-fs/erofs-utils/files/1.4-dump-fix-de-nid-issues.patch
37 new file mode 100644
38 index 000000000000..4c833d737fa2
39 --- /dev/null
40 +++ b/sys-fs/erofs-utils/files/1.4-dump-fix-de-nid-issues.patch
41 @@ -0,0 +1,134 @@
42 +From 35b15cc9c75cc2d7782f36433bad90326e9cb060 Mon Sep 17 00:00:00 2001
43 +From: Gao Xiang <xiang@××××××.org>
44 +Date: Mon, 22 Nov 2021 07:48:48 +0800
45 +Subject: [PATCH 1/2] erofs-utils: dump: fix de->nid issues
46 +
47 +As David Michael reported, "
48 + In file included from main.c:11:
49 + main.c: In function 'erofs_checkdirent':
50 + ../include/erofs/print.h:68:25: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type '__le64' {aka 'long unsigned int'} [-Werror=format=]
51 + 68 | "<E> " PR_FMT_FUNC_LINE(fmt), \
52 + | ^~~~~~
53 + main.c:264:17: note: in expansion of macro 'erofs_err'
54 + 264 | erofs_err("invalid file type %llu", de->nid);
55 + | ^~~~~~~~~
56 + main.c: In function 'erofs_read_dirent':
57 + ../include/erofs/print.h:68:25: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type '__le64' {aka 'long unsigned int'} [-Werror=format=]
58 + 68 | "<E> " PR_FMT_FUNC_LINE(fmt), \
59 + | ^~~~~~
60 + main.c:303:25: note: in expansion of macro 'erofs_err'
61 + 303 | erofs_err("parse dir nid %llu error occurred\n",
62 + | ^~~~~~~~~
63 + cc1: all warnings being treated as errors
64 +"
65 +
66 +Also there are many de->nid lacking of endianness handling.
67 +Should fix them together.
68 +
69 +Link: https://lore.kernel.org/r/20211121234848.12663-1-xiang@××××××.org
70 +Fixes: cf8be8a4352a ("erofs-utils: dump: add feature for collecting filesystem statistics")
71 +Cc: Wang Qi <mpiglet@×××××××.com>
72 +Cc: Guo Xuenan <guoxuenan@××××××.com>
73 +Reported-by: David Michael <fedora.dm0@×××××.com>
74 +Signed-off-by: Gao Xiang <xiang@××××××.org>
75 +---
76 + dump/main.c | 31 ++++++++++++++++---------------
77 + 1 file changed, 16 insertions(+), 15 deletions(-)
78 +
79 +diff --git a/dump/main.c b/dump/main.c
80 +index b7560ec..f85903b 100644
81 +--- a/dump/main.c
82 ++++ b/dump/main.c
83 +@@ -242,11 +242,12 @@ static inline int erofs_checkdirent(struct erofs_dirent *de,
84 + {
85 + int dname_len;
86 + unsigned int nameoff = le16_to_cpu(de->nameoff);
87 ++ erofs_nid_t nid = le64_to_cpu(de->nid);
88 +
89 + if (nameoff < sizeof(struct erofs_dirent) ||
90 + nameoff >= PAGE_SIZE) {
91 + erofs_err("invalid de[0].nameoff %u @ nid %llu",
92 +- nameoff, de->nid | 0ULL);
93 ++ nameoff, nid | 0ULL);
94 + return -EFSCORRUPTED;
95 + }
96 +
97 +@@ -255,13 +256,12 @@ static inline int erofs_checkdirent(struct erofs_dirent *de,
98 + /* a corrupted entry is found */
99 + if (nameoff + dname_len > maxsize ||
100 + dname_len > EROFS_NAME_LEN) {
101 +- erofs_err("bogus dirent @ nid %llu",
102 +- le64_to_cpu(de->nid) | 0ULL);
103 ++ erofs_err("bogus dirent @ nid %llu", nid | 0ULL);
104 + DBG_BUGON(1);
105 + return -EFSCORRUPTED;
106 + }
107 + if (de->file_type >= EROFS_FT_MAX) {
108 +- erofs_err("invalid file type %llu", de->nid);
109 ++ erofs_err("invalid file type %llu", nid | 0ULL);
110 + return -EFSCORRUPTED;
111 + }
112 + return dname_len;
113 +@@ -273,7 +273,7 @@ static int erofs_read_dirent(struct erofs_dirent *de,
114 + {
115 + int err;
116 + erofs_off_t occupied_size = 0;
117 +- struct erofs_inode inode = { .nid = de->nid };
118 ++ struct erofs_inode inode = { .nid = le64_to_cpu(de->nid) };
119 +
120 + stats.files++;
121 + stats.file_category_stat[de->file_type]++;
122 +@@ -296,12 +296,12 @@ static int erofs_read_dirent(struct erofs_dirent *de,
123 + update_file_size_statatics(occupied_size, inode.i_size);
124 + }
125 +
126 +- if ((de->file_type == EROFS_FT_DIR)
127 +- && de->nid != nid && de->nid != parent_nid) {
128 +- err = erofs_read_dir(de->nid, nid);
129 ++ if (de->file_type == EROFS_FT_DIR && inode.nid != nid &&
130 ++ inode.nid != parent_nid) {
131 ++ err = erofs_read_dir(inode.nid, nid);
132 + if (err) {
133 + erofs_err("parse dir nid %llu error occurred\n",
134 +- de->nid);
135 ++ inode.nid | 0ULL);
136 + return err;
137 + }
138 + }
139 +@@ -338,7 +338,8 @@ static int erofs_read_dir(erofs_nid_t nid, erofs_nid_t parent_nid)
140 + int ret;
141 +
142 + /* skip "." and ".." dentry */
143 +- if (de->nid == nid || de->nid == parent_nid) {
144 ++ if (le64_to_cpu(de->nid) == nid ||
145 ++ le64_to_cpu(de->nid) == parent_nid) {
146 + de++;
147 + continue;
148 + }
149 +@@ -399,18 +400,18 @@ static int erofs_get_pathname(erofs_nid_t nid, erofs_nid_t parent_nid,
150 + if (len < 0)
151 + return len;
152 +
153 +- if (de->nid == target) {
154 ++ if (le64_to_cpu(de->nid) == target) {
155 + memcpy(path + pos, dname, len);
156 + path[pos + len] = '\0';
157 + return 0;
158 + }
159 +
160 + if (de->file_type == EROFS_FT_DIR &&
161 +- de->nid != parent_nid &&
162 +- de->nid != nid) {
163 ++ le64_to_cpu(de->nid) != parent_nid &&
164 ++ le64_to_cpu(de->nid) != nid) {
165 + memcpy(path + pos, dname, len);
166 +- err = erofs_get_pathname(de->nid, nid,
167 +- target, path, pos + len);
168 ++ err = erofs_get_pathname(le64_to_cpu(de->nid),
169 ++ nid, target, path, pos + len);
170 + if (!err)
171 + return 0;
172 + memset(path + pos, 0, len);
173 +--
174 +2.34.1
175 +