|
| 1 | +From 8a83b306db64d6f60186d4396b0b770163b85b6e Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ross Burton < [email protected]> |
| 3 | +Date: Wed, 26 Feb 2025 18:24:00 +0000 |
| 4 | +Subject: [PATCH 1/7] ubifs-utils: link libmissing.a in case execinfo.h isn't |
| 5 | + present |
| 6 | + |
| 7 | +On musl execinfo.h doesn't exist, but ubifs-utils uses backtrace() when |
| 8 | +reporting errors. This results in build failures under musl. |
| 9 | + |
| 10 | +Handily, libmissing.a already exists with a stub implementation of |
| 11 | +backtrace(). |
| 12 | + |
| 13 | +Guard the execinfo.h include and if it isn't available instead include |
| 14 | +libmissing.h, and link to libmissing.a to provide backtrace() if needed. |
| 15 | + |
| 16 | +Signed-off-by: Ross Burton < [email protected]> |
| 17 | +Reviewed-by: Zhihao Cheng < [email protected]> |
| 18 | +Signed-off-by: David Oberhollenzer < [email protected]> |
| 19 | +--- |
| 20 | + ubifs-utils/Makemodule.am | 4 ++-- |
| 21 | + ubifs-utils/common/defs.h | 5 ++++- |
| 22 | + 2 files changed, 6 insertions(+), 3 deletions(-) |
| 23 | + |
| 24 | +diff --git a/ubifs-utils/Makemodule.am b/ubifs-utils/Makemodule.am |
| 25 | +index 21ba059..f84569a 100644 |
| 26 | +--- a/ubifs-utils/Makemodule.am |
| 27 | ++++ b/ubifs-utils/Makemodule.am |
| 28 | +@@ -72,7 +72,7 @@ mkfs_ubifs_SOURCES = \ |
| 29 | + ubifs-utils/mkfs.ubifs/mkfs.ubifs.c |
| 30 | + |
| 31 | + mkfs_ubifs_LDADD = libmtd.a libubi.a $(ZLIB_LIBS) $(LZO_LIBS) $(ZSTD_LIBS) $(UUID_LIBS) $(LIBSELINUX_LIBS) $(OPENSSL_LIBS) \ |
| 32 | +- $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread |
| 33 | ++ $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread libmissing.a |
| 34 | + mkfs_ubifs_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) $(ZSTD_CFLAGS) $(UUID_CFLAGS) $(LIBSELINUX_CFLAGS) \ |
| 35 | + -I$(top_srcdir)/ubi-utils/include -I$(top_srcdir)/ubifs-utils/common -I $(top_srcdir)/ubifs-utils/libubifs |
| 36 | + |
| 37 | +@@ -90,7 +90,7 @@ fsck_ubifs_SOURCES = \ |
| 38 | + ubifs-utils/fsck.ubifs/handle_disconnected.c |
| 39 | + |
| 40 | + fsck_ubifs_LDADD = libmtd.a libubi.a $(ZLIB_LIBS) $(LZO_LIBS) $(ZSTD_LIBS) $(UUID_LIBS) $(LIBSELINUX_LIBS) $(OPENSSL_LIBS) \ |
| 41 | +- $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread |
| 42 | ++ $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread libmissing.a |
| 43 | + fsck_ubifs_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) $(ZSTD_CFLAGS) $(UUID_CFLAGS) $(LIBSELINUX_CFLAGS) \ |
| 44 | + -I$(top_srcdir)/ubi-utils/include -I$(top_srcdir)/ubifs-utils/common -I $(top_srcdir)/ubifs-utils/libubifs \ |
| 45 | + -I$(top_srcdir)/ubifs-utils/fsck.ubifs |
| 46 | +diff --git a/ubifs-utils/common/defs.h b/ubifs-utils/common/defs.h |
| 47 | +index 7ff1771..d5edbf6 100644 |
| 48 | +--- a/ubifs-utils/common/defs.h |
| 49 | ++++ b/ubifs-utils/common/defs.h |
| 50 | +@@ -13,8 +13,11 @@ |
| 51 | + #include <errno.h> |
| 52 | + #include <time.h> |
| 53 | + #include <assert.h> |
| 54 | ++#if HAVE_EXECINFO_H |
| 55 | + #include <execinfo.h> |
| 56 | +- |
| 57 | ++#else |
| 58 | ++#include "libmissing.h" |
| 59 | ++#endif |
| 60 | + #include "ubifs.h" |
| 61 | + |
| 62 | + /* common.h requires the PROGRAM_NAME macro */ |
| 63 | +-- |
| 64 | +2.50.0 |
| 65 | + |
| 66 | + |
| 67 | +From 2669111e3c60b8e146c174db5d2e7e9991f3dd87 Mon Sep 17 00:00:00 2001 |
| 68 | +From: AntonMoryakov < [email protected]> |
| 69 | +Date: Thu, 24 Apr 2025 21:19:22 +0300 |
| 70 | +Subject: [PATCH 2/7] ubifs-utils: common: fix memory leak in devtable.c |
| 71 | + |
| 72 | +Report of the static analyzer: |
| 73 | +Dynamic memory, referenced by 'line', is allocated at devtable.c:356 |
| 74 | +by calling function 'getline' and lost at devtable.c:388. |
| 75 | +(line: while (getline(&line, &len, f) != -1) {) |
| 76 | + |
| 77 | +Correct explained: |
| 78 | +Now line is freed in any exit scenario via out_close which eliminates this error. |
| 79 | + |
| 80 | +Triggers found by static analyzer Svace. |
| 81 | + |
| 82 | +Signed-off-by: Anton Moryakov < [email protected] |
| 83 | +Reviewed-by: Zhihao Cheng < [email protected]> |
| 84 | +Signed-off-by: David Oberhollenzer < [email protected]> |
| 85 | +--- |
| 86 | + ubifs-utils/common/devtable.c | 1 + |
| 87 | + 1 file changed, 1 insertion(+) |
| 88 | + |
| 89 | +diff --git a/ubifs-utils/common/devtable.c b/ubifs-utils/common/devtable.c |
| 90 | +index 7347f09..2e581ff 100644 |
| 91 | +--- a/ubifs-utils/common/devtable.c |
| 92 | ++++ b/ubifs-utils/common/devtable.c |
| 93 | +@@ -392,6 +392,7 @@ int parse_devtable(const char *tbl_file) |
| 94 | + |
| 95 | + out_close: |
| 96 | + fclose(f); |
| 97 | ++ free(line); |
| 98 | + free_devtable_info(); |
| 99 | + return -1; |
| 100 | + } |
| 101 | +-- |
| 102 | +2.50.0 |
| 103 | + |
| 104 | + |
| 105 | +From 2ff8105b3bb2d8eff682bbbfdca1a7843c7bd524 Mon Sep 17 00:00:00 2001 |
| 106 | +From: Konstantin Menyaev < [email protected]> |
| 107 | +Date: Sat, 24 May 2025 20:26:39 +0300 |
| 108 | +Subject: [PATCH 3/7] ubi-utils: ubirsvol: resize volume using all available |
| 109 | + free space |
| 110 | + |
| 111 | +useful in resizing last ubi volume, |
| 112 | +some kind of auto-resize ubinize option. |
| 113 | + |
| 114 | +Signed-off-by: Konstantin Menyaev < [email protected]> |
| 115 | +Reviewed-by: Zhihao Cheng < [email protected]> |
| 116 | +Signed-off-by: David Oberhollenzer < [email protected]> |
| 117 | +--- |
| 118 | + ubi-utils/ubirsvol.c | 9 +++++++-- |
| 119 | + 1 file changed, 7 insertions(+), 2 deletions(-) |
| 120 | + |
| 121 | +diff --git a/ubi-utils/ubirsvol.c b/ubi-utils/ubirsvol.c |
| 122 | +index 73d2f68..55f6794 100644 |
| 123 | +--- a/ubi-utils/ubirsvol.c |
| 124 | ++++ b/ubi-utils/ubirsvol.c |
| 125 | +@@ -57,8 +57,10 @@ static const char optionsstr[] = |
| 126 | + "-N, --name=<volume name> volume name to resize\n" |
| 127 | + "-s, --size=<bytes> volume size volume size in bytes, kilobytes (KiB)\n" |
| 128 | + " or megabytes (MiB)\n" |
| 129 | ++" zero size means use all available free bytes\n" |
| 130 | + "-S, --lebs=<LEBs count> alternative way to give volume size in logical\n" |
| 131 | + " eraseblocks\n" |
| 132 | ++" zero size means use all available free LEBs\n" |
| 133 | + "-h, -?, --help print help message\n" |
| 134 | + "-V, --version print program version"; |
| 135 | + |
| 136 | +@@ -114,13 +116,13 @@ static int parse_opt(int argc, char * const argv[]) |
| 137 | + switch (key) { |
| 138 | + case 's': |
| 139 | + args.bytes = util_get_bytes(optarg); |
| 140 | +- if (args.bytes <= 0) |
| 141 | ++ if (args.bytes < 0) |
| 142 | + return errmsg("bad volume size: \"%s\"", optarg); |
| 143 | + break; |
| 144 | + |
| 145 | + case 'S': |
| 146 | + args.lebs = simple_strtoull(optarg, &error); |
| 147 | +- if (error || args.lebs <= 0) |
| 148 | ++ if (error || args.lebs < 0) |
| 149 | + return errmsg("bad LEB count: \"%s\"", optarg); |
| 150 | + break; |
| 151 | + |
| 152 | +@@ -233,6 +235,9 @@ int main(int argc, char * const argv[]) |
| 153 | + if (args.lebs != -1) |
| 154 | + args.bytes = (long long)vol_info.leb_size * args.lebs; |
| 155 | + |
| 156 | ++ if (args.lebs == 0 || args.bytes == 0) |
| 157 | ++ args.bytes = vol_info.rsvd_bytes + dev_info.avail_bytes; |
| 158 | ++ |
| 159 | + err = ubi_rsvol(libubi, args.node, args.vol_id, args.bytes); |
| 160 | + if (err) { |
| 161 | + sys_errmsg("cannot UBI resize volume"); |
| 162 | +-- |
| 163 | +2.50.0 |
| 164 | + |
| 165 | + |
| 166 | +From ac0ab65ebcd7b11739986b81343457469fbb43b0 Mon Sep 17 00:00:00 2001 |
| 167 | +From: Khem Raj < [email protected]> |
| 168 | +Date: Sat, 22 Mar 2025 21:01:32 -0700 |
| 169 | +Subject: [PATCH 4/7] Improve check for GCC compiler version |
| 170 | + |
| 171 | +When using unreleased compiler has version like |
| 172 | +15.0.1 and that test fails because __GNUC_MINOR__ < 1 |
| 173 | +becomes true, therefore check for full version string |
| 174 | +which is more rubust. |
| 175 | + |
| 176 | +Signed-off-by: Khem Raj < [email protected]> |
| 177 | +Signed-off-by: David Oberhollenzer < [email protected]> |
| 178 | +--- |
| 179 | + ubifs-utils/common/atomic.h | 6 +++++- |
| 180 | + 1 file changed, 5 insertions(+), 1 deletion(-) |
| 181 | + |
| 182 | +diff --git a/ubifs-utils/common/atomic.h b/ubifs-utils/common/atomic.h |
| 183 | +index f287d43..95754b2 100644 |
| 184 | +--- a/ubifs-utils/common/atomic.h |
| 185 | ++++ b/ubifs-utils/common/atomic.h |
| 186 | +@@ -2,8 +2,12 @@ |
| 187 | + #ifndef __ATOMIC_H__ |
| 188 | + #define __ATOMIC_H__ |
| 189 | + |
| 190 | ++#define GCC_VERSION (__GNUC__ * 10000 \ |
| 191 | ++ + __GNUC_MINOR__ * 100 \ |
| 192 | ++ + __GNUC_PATCHLEVEL__) |
| 193 | ++ |
| 194 | + /* Check GCC version, just to be safe */ |
| 195 | +-#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC_MINOR__ < 1) |
| 196 | ++#if GCC_VERSION < 40100 |
| 197 | + # error atomic.h works only with GCC newer than version 4.1 |
| 198 | + #endif /* GNUC >= 4.1 */ |
| 199 | + |
| 200 | +-- |
| 201 | +2.50.0 |
| 202 | + |
| 203 | + |
| 204 | +From 12bc9ad824bd8f18a5ec9c7154ad2374cf8c7ae3 Mon Sep 17 00:00:00 2001 |
| 205 | +From: Fabio Estevam < [email protected]> |
| 206 | +Date: Wed, 19 Feb 2025 10:02:41 -0300 |
| 207 | +Subject: [PATCH 5/7] ubifs-utils: ubifs.h: Include <fcntl.h> |
| 208 | + |
| 209 | +Include the <fcntl.h> header file to fix the following error |
| 210 | +when building with musl: |
| 211 | + |
| 212 | +| In file included from ../git/ubifs-utils/common/compr.c:42: |
| 213 | +| ../git/ubifs-utils/libubifs/ubifs.h:313:9: error: unknown type name 'loff_t'; did you mean 'off_t'? |
| 214 | +| 313 | loff_t ui_size; |
| 215 | +| | ^~~~~~ |
| 216 | +| | off_t |
| 217 | +| ../git/ubifs-utils/libubifs/ubifs.h:1341:9: error: unknown type name 'loff_t'; did you mean 'off_t'? |
| 218 | +| 1341 | loff_t i_size; |
| 219 | +| | ^~~~~~ |
| 220 | +| | off_t |
| 221 | +| ../git/ubifs-utils/libubifs/ubifs.h:1342:9: error: unknown type name 'loff_t'; did you mean 'off_t'? |
| 222 | +| 1342 | loff_t d_size; |
| 223 | +| | ^~~~~~ |
| 224 | +| | off_t |
| 225 | +| ../git/ubifs-utils/libubifs/ubifs.h:1899:44: error: unknown type name 'loff_t'; did you mean 'off_t'? |
| 226 | +| 1899 | int deletion, loff_t new_size); |
| 227 | +| | ^~~~~~ |
| 228 | +| | off_t |
| 229 | +| make: *** [Makefile:4878: ubifs-utils/common/mkfs_ubifs-compr.o] Error 1 |
| 230 | + |
| 231 | +Signed-off-by: Fabio Estevam < [email protected]> |
| 232 | +Reviewed-by: Zhihao Cheng < [email protected]> |
| 233 | +Reviewed-by: Khem Raj < [email protected]> |
| 234 | +Signed-off-by: David Oberhollenzer < [email protected]> |
| 235 | +--- |
| 236 | + ubifs-utils/libubifs/ubifs.h | 1 + |
| 237 | + 1 file changed, 1 insertion(+) |
| 238 | + |
| 239 | +diff --git a/ubifs-utils/libubifs/ubifs.h b/ubifs-utils/libubifs/ubifs.h |
| 240 | +index 0908a22..1c7bc7b 100644 |
| 241 | +--- a/ubifs-utils/libubifs/ubifs.h |
| 242 | ++++ b/ubifs-utils/libubifs/ubifs.h |
| 243 | +@@ -11,6 +11,7 @@ |
| 244 | + #ifndef __UBIFS_H__ |
| 245 | + #define __UBIFS_H__ |
| 246 | + |
| 247 | ++#include <fcntl.h> |
| 248 | + #include <string.h> |
| 249 | + |
| 250 | + #include "linux_types.h" |
| 251 | +-- |
| 252 | +2.50.0 |
| 253 | + |
| 254 | + |
| 255 | +From 173f9714c8da1d685bfa951d43b9310d16bbab3c Mon Sep 17 00:00:00 2001 |
| 256 | +From: Fabio Estevam < [email protected]> |
| 257 | +Date: Wed, 19 Feb 2025 10:02:42 -0300 |
| 258 | +Subject: [PATCH 6/7] ubifs-utils: journal: Include <sys/stat.h> |
| 259 | + |
| 260 | +Include the <sys/stat.h> header file to fix the following error |
| 261 | +when building with musl: |
| 262 | + |
| 263 | +| ../git/ubifs-utils/libubifs/journal.c: In function 'ubifs_get_dent_type': |
| 264 | +| ../git/ubifs-utils/libubifs/journal.c:414:24: error: 'S_IFMT' undeclared (first use in this function) |
| 265 | +| 414 | switch (mode & S_IFMT) { |
| 266 | +| | ^~~~~~ |
| 267 | +| ../git/ubifs-utils/libubifs/journal.c:414:24: note: each undeclared identifier is reported only once for each function it appears in |
| 268 | +| ../git/ubifs-utils/libubifs/journal.c:415:14: error: 'S_IFREG' undeclared (first use in this function) |
| 269 | +| 415 | case S_IFREG: |
| 270 | + |
| 271 | +Signed-off-by: Fabio Estevam < [email protected]> |
| 272 | +Reviewed-by: Zhihao Cheng < [email protected]> |
| 273 | +Signed-off-by: David Oberhollenzer < [email protected]> |
| 274 | +--- |
| 275 | + ubifs-utils/libubifs/journal.c | 1 + |
| 276 | + 1 file changed, 1 insertion(+) |
| 277 | + |
| 278 | +diff --git a/ubifs-utils/libubifs/journal.c b/ubifs-utils/libubifs/journal.c |
| 279 | +index e78ea14..45d82fd 100644 |
| 280 | +--- a/ubifs-utils/libubifs/journal.c |
| 281 | ++++ b/ubifs-utils/libubifs/journal.c |
| 282 | +@@ -46,6 +46,7 @@ |
| 283 | + * all the nodes. |
| 284 | + */ |
| 285 | + |
| 286 | ++#include <sys/stat.h> |
| 287 | + #include "bitops.h" |
| 288 | + #include "kmem.h" |
| 289 | + #include "ubifs.h" |
| 290 | +-- |
| 291 | +2.50.0 |
| 292 | + |
| 293 | + |
| 294 | +From 77981a2888c711268b0e7f32af6af159c2288e23 Mon Sep 17 00:00:00 2001 |
| 295 | +From: Fabio Estevam < [email protected]> |
| 296 | +Date: Wed, 19 Feb 2025 10:02:44 -0300 |
| 297 | +Subject: [PATCH 7/7] ubifs-utils: extract_files: Include <linux/limits.h> |
| 298 | + |
| 299 | +Include <linux/limits.h> to fix the following build error when building |
| 300 | +with musl: |
| 301 | + |
| 302 | +| ../git/ubifs-utils/fsck.ubifs/extract_files.c: In function 'parse_ino_node': |
| 303 | +| ../git/ubifs-utils/fsck.ubifs/extract_files.c:144:47: error: 'XATTR_LIST_MAX' undeclared (first use in this function) |
| 304 | +| 144 | if (ino_node->xnms + ino_node->xcnt > XATTR_LIST_MAX) { |
| 305 | +| | ^~~~~~~~~~~~~~ |
| 306 | +| ../git/ubifs-utils/fsck.ubifs/extract_files.c:144:47: note: each undeclared identifier is reported only once for each function it appears in |
| 307 | +| make: *** [Makefile:4374: ubifs-utils/fsck.ubifs/fsck_ubifs-extract_files.o] Error 1 |
| 308 | + |
| 309 | +Signed-off-by: Fabio Estevam < [email protected]> |
| 310 | +Reviewed-by: Zhihao Cheng < [email protected]> |
| 311 | +Signed-off-by: David Oberhollenzer < [email protected]> |
| 312 | +--- |
| 313 | + ubifs-utils/fsck.ubifs/extract_files.c | 2 ++ |
| 314 | + 1 file changed, 2 insertions(+) |
| 315 | + |
| 316 | +diff --git a/ubifs-utils/fsck.ubifs/extract_files.c b/ubifs-utils/fsck.ubifs/extract_files.c |
| 317 | +index c83d377..000ef5d 100644 |
| 318 | +--- a/ubifs-utils/fsck.ubifs/extract_files.c |
| 319 | ++++ b/ubifs-utils/fsck.ubifs/extract_files.c |
| 320 | +@@ -10,6 +10,8 @@ |
| 321 | + #include <getopt.h> |
| 322 | + #include <sys/stat.h> |
| 323 | + |
| 324 | ++#include <linux/limits.h> |
| 325 | ++ |
| 326 | + #include "linux_err.h" |
| 327 | + #include "bitops.h" |
| 328 | + #include "kmem.h" |
| 329 | +-- |
| 330 | +2.50.0 |
| 331 | + |
0 commit comments