diff options
-rw-r--r-- | CHANGELOG.md | 7 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | ubi-utils/ubirsvol.c | 9 | ||||
-rw-r--r-- | ubifs-utils/Makemodule.am | 4 | ||||
-rw-r--r-- | ubifs-utils/common/atomic.h | 6 | ||||
-rw-r--r-- | ubifs-utils/common/defs.h | 5 | ||||
-rw-r--r-- | ubifs-utils/common/devtable.c | 1 | ||||
-rw-r--r-- | ubifs-utils/fsck.ubifs/extract_files.c | 2 | ||||
-rw-r--r-- | ubifs-utils/libubifs/README | 2 | ||||
-rw-r--r-- | ubifs-utils/libubifs/find.c | 40 | ||||
-rw-r--r-- | ubifs-utils/libubifs/journal.c | 1 | ||||
-rw-r--r-- | ubifs-utils/libubifs/lpt.c | 1 | ||||
-rw-r--r-- | ubifs-utils/libubifs/lpt_commit.c | 4 | ||||
-rw-r--r-- | ubifs-utils/libubifs/replay.c | 1 | ||||
-rw-r--r-- | ubifs-utils/libubifs/tnc_commit.c | 2 | ||||
-rw-r--r-- | ubifs-utils/libubifs/ubifs.h | 1 |
16 files changed, 57 insertions, 31 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 57afc62..204ee0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). -## [Unreleased] +## [2.3.0] - 2025-02-15 ### Added - fsck.ubifs: Add fsck utility for ubifs - ubifs-utils: Support Address-Sanitizier debug @@ -17,6 +17,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - mkfs.jffs2: fix segfault when parsing dev table - nand-utils: nanddump: Explicitely use the page size when relevant - misc-utils: add missing error handling for 'bam' allocation in ftl_check.c + - mtdinfo: type mis-match in printf format string + - nanddump: const cast warning + - flashcp: uninitialized variable + - jffs2reader: potential null pointer dereference + - tests: checkfs: Add previous prototype for do_pwr_dn() ### Changed - mkfs.ubifs: re-sync with the kernel code diff --git a/configure.ac b/configure.ac index b160c03..2a79ba8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.60]) -m4_define([RELEASE], 2.2.1) +m4_define([RELEASE], 2.3.0) AC_INIT([mtd-utils], [RELEASE], [linux-mtd@lists.infradead.org], mtd-utils) diff --git a/ubi-utils/ubirsvol.c b/ubi-utils/ubirsvol.c index 73d2f68..55f6794 100644 --- a/ubi-utils/ubirsvol.c +++ b/ubi-utils/ubirsvol.c @@ -57,8 +57,10 @@ static const char optionsstr[] = "-N, --name=<volume name> volume name to resize\n" "-s, --size=<bytes> volume size volume size in bytes, kilobytes (KiB)\n" " or megabytes (MiB)\n" +" zero size means use all available free bytes\n" "-S, --lebs=<LEBs count> alternative way to give volume size in logical\n" " eraseblocks\n" +" zero size means use all available free LEBs\n" "-h, -?, --help print help message\n" "-V, --version print program version"; @@ -114,13 +116,13 @@ static int parse_opt(int argc, char * const argv[]) switch (key) { case 's': args.bytes = util_get_bytes(optarg); - if (args.bytes <= 0) + if (args.bytes < 0) return errmsg("bad volume size: \"%s\"", optarg); break; case 'S': args.lebs = simple_strtoull(optarg, &error); - if (error || args.lebs <= 0) + if (error || args.lebs < 0) return errmsg("bad LEB count: \"%s\"", optarg); break; @@ -233,6 +235,9 @@ int main(int argc, char * const argv[]) if (args.lebs != -1) args.bytes = (long long)vol_info.leb_size * args.lebs; + if (args.lebs == 0 || args.bytes == 0) + args.bytes = vol_info.rsvd_bytes + dev_info.avail_bytes; + err = ubi_rsvol(libubi, args.node, args.vol_id, args.bytes); if (err) { sys_errmsg("cannot UBI resize volume"); diff --git a/ubifs-utils/Makemodule.am b/ubifs-utils/Makemodule.am index 21ba059..f84569a 100644 --- a/ubifs-utils/Makemodule.am +++ b/ubifs-utils/Makemodule.am @@ -72,7 +72,7 @@ mkfs_ubifs_SOURCES = \ ubifs-utils/mkfs.ubifs/mkfs.ubifs.c mkfs_ubifs_LDADD = libmtd.a libubi.a $(ZLIB_LIBS) $(LZO_LIBS) $(ZSTD_LIBS) $(UUID_LIBS) $(LIBSELINUX_LIBS) $(OPENSSL_LIBS) \ - $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread + $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread libmissing.a mkfs_ubifs_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) $(ZSTD_CFLAGS) $(UUID_CFLAGS) $(LIBSELINUX_CFLAGS) \ -I$(top_srcdir)/ubi-utils/include -I$(top_srcdir)/ubifs-utils/common -I $(top_srcdir)/ubifs-utils/libubifs @@ -90,7 +90,7 @@ fsck_ubifs_SOURCES = \ ubifs-utils/fsck.ubifs/handle_disconnected.c fsck_ubifs_LDADD = libmtd.a libubi.a $(ZLIB_LIBS) $(LZO_LIBS) $(ZSTD_LIBS) $(UUID_LIBS) $(LIBSELINUX_LIBS) $(OPENSSL_LIBS) \ - $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread + $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread libmissing.a fsck_ubifs_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) $(ZSTD_CFLAGS) $(UUID_CFLAGS) $(LIBSELINUX_CFLAGS) \ -I$(top_srcdir)/ubi-utils/include -I$(top_srcdir)/ubifs-utils/common -I $(top_srcdir)/ubifs-utils/libubifs \ -I$(top_srcdir)/ubifs-utils/fsck.ubifs diff --git a/ubifs-utils/common/atomic.h b/ubifs-utils/common/atomic.h index f287d43..95754b2 100644 --- a/ubifs-utils/common/atomic.h +++ b/ubifs-utils/common/atomic.h @@ -2,8 +2,12 @@ #ifndef __ATOMIC_H__ #define __ATOMIC_H__ +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + /* Check GCC version, just to be safe */ -#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC_MINOR__ < 1) +#if GCC_VERSION < 40100 # error atomic.h works only with GCC newer than version 4.1 #endif /* GNUC >= 4.1 */ diff --git a/ubifs-utils/common/defs.h b/ubifs-utils/common/defs.h index 7ff1771..d5edbf6 100644 --- a/ubifs-utils/common/defs.h +++ b/ubifs-utils/common/defs.h @@ -13,8 +13,11 @@ #include <errno.h> #include <time.h> #include <assert.h> +#if HAVE_EXECINFO_H #include <execinfo.h> - +#else +#include "libmissing.h" +#endif #include "ubifs.h" /* common.h requires the PROGRAM_NAME macro */ diff --git a/ubifs-utils/common/devtable.c b/ubifs-utils/common/devtable.c index 7347f09..2e581ff 100644 --- a/ubifs-utils/common/devtable.c +++ b/ubifs-utils/common/devtable.c @@ -392,6 +392,7 @@ int parse_devtable(const char *tbl_file) out_close: fclose(f); + free(line); free_devtable_info(); return -1; } diff --git a/ubifs-utils/fsck.ubifs/extract_files.c b/ubifs-utils/fsck.ubifs/extract_files.c index c83d377..000ef5d 100644 --- a/ubifs-utils/fsck.ubifs/extract_files.c +++ b/ubifs-utils/fsck.ubifs/extract_files.c @@ -10,6 +10,8 @@ #include <getopt.h> #include <sys/stat.h> +#include <linux/limits.h> + #include "linux_err.h" #include "bitops.h" #include "kmem.h" diff --git a/ubifs-utils/libubifs/README b/ubifs-utils/libubifs/README index 551ed8e..dd9322a 100644 --- a/ubifs-utils/libubifs/README +++ b/ubifs-utils/libubifs/README @@ -1,4 +1,4 @@ -UBIFS Library (Imported from linux kernel 6.8-rc2 41bccc98fb7931d63) +UBIFS Library (Imported from linux kernel 6.13-rc7 aa22f4da2a46) * ubifs.h is a selection of definitions from fs/ubifs/ubifs.h from the linux kernel. * key.h is copied from fs/ubifs/key.h from the linux kernel. diff --git a/ubifs-utils/libubifs/find.c b/ubifs-utils/libubifs/find.c index ecf689c..364252e 100644 --- a/ubifs-utils/libubifs/find.c +++ b/ubifs-utils/libubifs/find.c @@ -80,7 +80,7 @@ static int valuable(struct ubifs_info *c, const struct ubifs_lprops *lprops) * @c: the UBIFS file-system description object * @lprops: LEB properties to scan * @in_tree: whether the LEB properties are in main memory - * @data: information passed to and from the caller of the scan + * @arg: information passed to and from the caller of the scan * * This function returns a code that indicates whether the scan should continue * (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree @@ -89,8 +89,9 @@ static int valuable(struct ubifs_info *c, const struct ubifs_lprops *lprops) */ static int scan_for_dirty_cb(struct ubifs_info *c, const struct ubifs_lprops *lprops, int in_tree, - struct scan_data *data) + void *arg) { + struct scan_data *data = arg; int ret = LPT_SCAN_CONTINUE; /* Exclude LEBs that are currently in use */ @@ -173,8 +174,7 @@ static const struct ubifs_lprops *scan_for_dirty(struct ubifs_info *c, data.pick_free = pick_free; data.lnum = -1; data.exclude_index = exclude_index; - err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, - (ubifs_lpt_scan_callback)scan_for_dirty_cb, + err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, scan_for_dirty_cb, &data); if (err) return ERR_PTR(err); @@ -347,7 +347,7 @@ out: * @c: the UBIFS file-system description object * @lprops: LEB properties to scan * @in_tree: whether the LEB properties are in main memory - * @data: information passed to and from the caller of the scan + * @arg: information passed to and from the caller of the scan * * This function returns a code that indicates whether the scan should continue * (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree @@ -356,8 +356,9 @@ out: */ static int scan_for_free_cb(struct ubifs_info *c, const struct ubifs_lprops *lprops, int in_tree, - struct scan_data *data) + void *arg) { + struct scan_data *data = arg; int ret = LPT_SCAN_CONTINUE; /* Exclude LEBs that are currently in use */ @@ -453,7 +454,7 @@ const struct ubifs_lprops *do_find_free_space(struct ubifs_info *c, data.pick_free = pick_free; data.lnum = -1; err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, - (ubifs_lpt_scan_callback)scan_for_free_cb, + scan_for_free_cb, &data); if (err) return ERR_PTR(err); @@ -587,7 +588,7 @@ out: * @c: the UBIFS file-system description object * @lprops: LEB properties to scan * @in_tree: whether the LEB properties are in main memory - * @data: information passed to and from the caller of the scan + * @arg: information passed to and from the caller of the scan * * This function returns a code that indicates whether the scan should continue * (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree @@ -596,8 +597,9 @@ out: */ static int scan_for_idx_cb(struct ubifs_info *c, const struct ubifs_lprops *lprops, int in_tree, - struct scan_data *data) + void *arg) { + struct scan_data *data = arg; int ret = LPT_SCAN_CONTINUE; /* Exclude LEBs that are currently in use */ @@ -632,8 +634,7 @@ static const struct ubifs_lprops *scan_for_leb_for_idx(struct ubifs_info *c) int err; data.lnum = -1; - err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, - (ubifs_lpt_scan_callback)scan_for_idx_cb, + err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, scan_for_idx_cb, &data); if (err) return ERR_PTR(err); @@ -733,11 +734,10 @@ out: return err; } -static int cmp_dirty_idx(const struct ubifs_lprops **a, - const struct ubifs_lprops **b) +static int cmp_dirty_idx(const void *a, const void *b) { - const struct ubifs_lprops *lpa = *a; - const struct ubifs_lprops *lpb = *b; + const struct ubifs_lprops *lpa = *(const struct ubifs_lprops **)a; + const struct ubifs_lprops *lpb = *(const struct ubifs_lprops **)b; return lpa->dirty + lpa->free - lpb->dirty - lpb->free; } @@ -761,7 +761,7 @@ int ubifs_save_dirty_idx_lnums(struct ubifs_info *c) sizeof(void *) * c->dirty_idx.cnt); /* Sort it so that the dirtiest is now at the end */ sort(c->dirty_idx.arr, c->dirty_idx.cnt, sizeof(void *), - (int (*)(const void *, const void *))cmp_dirty_idx, NULL); + cmp_dirty_idx, NULL); dbg_find("found %d dirty index LEBs", c->dirty_idx.cnt); if (c->dirty_idx.cnt) dbg_find("dirtiest index LEB is %d with dirty %d and free %d", @@ -780,7 +780,7 @@ int ubifs_save_dirty_idx_lnums(struct ubifs_info *c) * @c: the UBIFS file-system description object * @lprops: LEB properties to scan * @in_tree: whether the LEB properties are in main memory - * @data: information passed to and from the caller of the scan + * @arg: information passed to and from the caller of the scan * * This function returns a code that indicates whether the scan should continue * (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree @@ -789,8 +789,9 @@ int ubifs_save_dirty_idx_lnums(struct ubifs_info *c) */ static int scan_dirty_idx_cb(struct ubifs_info *c, const struct ubifs_lprops *lprops, int in_tree, - struct scan_data *data) + void *arg) { + struct scan_data *data = arg; int ret = LPT_SCAN_CONTINUE; /* Exclude LEBs that are currently in use */ @@ -849,8 +850,7 @@ static int find_dirty_idx_leb(struct ubifs_info *c) if (c->pnodes_have >= c->pnode_cnt) /* All pnodes are in memory, so skip scan */ return -ENOSPC; - err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, - (ubifs_lpt_scan_callback)scan_dirty_idx_cb, + err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, scan_dirty_idx_cb, &data); if (err) return err; diff --git a/ubifs-utils/libubifs/journal.c b/ubifs-utils/libubifs/journal.c index e78ea14..45d82fd 100644 --- a/ubifs-utils/libubifs/journal.c +++ b/ubifs-utils/libubifs/journal.c @@ -46,6 +46,7 @@ * all the nodes. */ +#include <sys/stat.h> #include "bitops.h" #include "kmem.h" #include "ubifs.h" diff --git a/ubifs-utils/libubifs/lpt.c b/ubifs-utils/libubifs/lpt.c index 8e20a17..f2f2727 100644 --- a/ubifs-utils/libubifs/lpt.c +++ b/ubifs-utils/libubifs/lpt.c @@ -2009,6 +2009,7 @@ out_err: * @pnode: where to keep a pnode * @cnode: where to keep a cnode * @in_tree: is the node in the tree in memory + * @ptr: union of node pointers * @ptr.nnode: pointer to the nnode (if it is an nnode) which may be here or in * the tree * @ptr.pnode: ditto for pnode diff --git a/ubifs-utils/libubifs/lpt_commit.c b/ubifs-utils/libubifs/lpt_commit.c index ee84f80..79f7b14 100644 --- a/ubifs-utils/libubifs/lpt_commit.c +++ b/ubifs-utils/libubifs/lpt_commit.c @@ -580,7 +580,7 @@ struct ubifs_pnode *ubifs_find_next_pnode(struct ubifs_info *c, /* Go right */ nnode = ubifs_get_nnode(c, nnode, iip); if (IS_ERR(nnode)) - return (void *)nnode; + return ERR_CAST(nnode); /* Go down to level 1 */ while (nnode->level > 1) { @@ -597,7 +597,7 @@ struct ubifs_pnode *ubifs_find_next_pnode(struct ubifs_info *c, } nnode = ubifs_get_nnode(c, nnode, iip); if (IS_ERR(nnode)) - return (void *)nnode; + return ERR_CAST(nnode); } for (iip = 0; iip < UBIFS_LPT_FANOUT; iip++) diff --git a/ubifs-utils/libubifs/replay.c b/ubifs-utils/libubifs/replay.c index 3943b32..9d61133 100644 --- a/ubifs-utils/libubifs/replay.c +++ b/ubifs-utils/libubifs/replay.c @@ -34,6 +34,7 @@ * @lnum: logical eraseblock number of the node * @offs: node offset * @len: node length + * @hash: node hash * @deletion: non-zero if this entry corresponds to a node deletion * @sqnum: node sequence number * @list: links the replay list diff --git a/ubifs-utils/libubifs/tnc_commit.c b/ubifs-utils/libubifs/tnc_commit.c index d797006..66922d4 100644 --- a/ubifs-utils/libubifs/tnc_commit.c +++ b/ubifs-utils/libubifs/tnc_commit.c @@ -663,6 +663,8 @@ static int get_znodes_to_commit(struct ubifs_info *c) znode->alt = 0; cnext = find_next_dirty(znode); if (!cnext) { + ubifs_assert(c, !znode->parent); + znode->cparent = NULL; znode->cnext = c->cnext; break; } diff --git a/ubifs-utils/libubifs/ubifs.h b/ubifs-utils/libubifs/ubifs.h index 0908a22..1c7bc7b 100644 --- a/ubifs-utils/libubifs/ubifs.h +++ b/ubifs-utils/libubifs/ubifs.h @@ -11,6 +11,7 @@ #ifndef __UBIFS_H__ #define __UBIFS_H__ +#include <fcntl.h> #include <string.h> #include "linux_types.h" |