diff options
Diffstat (limited to 'ubifs-utils')
| -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/check_files.c | 16 | ||||
| -rw-r--r-- | ubifs-utils/fsck.ubifs/extract_files.c | 97 | ||||
| -rw-r--r-- | ubifs-utils/fsck.ubifs/handle_disconnected.c | 6 | ||||
| -rw-r--r-- | ubifs-utils/fsck.ubifs/problem.c | 20 | ||||
| -rw-r--r-- | ubifs-utils/fsck.ubifs/rebuild_fs.c | 4 | ||||
| -rw-r--r-- | ubifs-utils/libubifs/README | 2 | ||||
| -rw-r--r-- | ubifs-utils/libubifs/dir.c | 4 | ||||
| -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 |
18 files changed, 115 insertions, 100 deletions
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/check_files.c b/ubifs-utils/fsck.ubifs/check_files.c index 1e1a77b..615f6bc 100644 --- a/ubifs-utils/fsck.ubifs/check_files.c +++ b/ubifs-utils/fsck.ubifs/check_files.c @@ -57,12 +57,13 @@ static int construct_file(struct ubifs_info *c, union ubifs_key *key, struct rb_root *tree = &FSCK(c)->scanned_files; struct scanned_node *sn = NULL; struct ubifs_ch *ch = (struct ubifs_ch *)node; + struct scanned_ino_node ino_node; + struct scanned_dent_node dent_node; + struct scanned_data_node data_node; switch (ch->node_type) { case UBIFS_INO_NODE: { - struct scanned_ino_node ino_node; - if (!parse_ino_node(c, lnum, offs, node, key, &ino_node)) { if (fix_problem(c, INVALID_INO_NODE, NULL)) return add_invalid_node(c, key, lnum, offs, iter); @@ -74,8 +75,6 @@ static int construct_file(struct ubifs_info *c, union ubifs_key *key, case UBIFS_DENT_NODE: case UBIFS_XENT_NODE: { - struct scanned_dent_node dent_node; - if (!parse_dent_node(c, lnum, offs, node, key, &dent_node)) { if (fix_problem(c, INVALID_DENT_NODE, NULL)) return add_invalid_node(c, key, lnum, offs, iter); @@ -86,8 +85,6 @@ static int construct_file(struct ubifs_info *c, union ubifs_key *key, } case UBIFS_DATA_NODE: { - struct scanned_data_node data_node; - if (!parse_data_node(c, lnum, offs, node, key, &data_node)) { if (fix_problem(c, INVALID_DATA_NODE, NULL)) return add_invalid_node(c, key, lnum, offs, iter); @@ -101,8 +98,8 @@ static int construct_file(struct ubifs_info *c, union ubifs_key *key, } dbg_fsck("construct file(%lu) for %s node, TNC location %d:%d, in %s", - inum, ubifs_get_key_name(key_type(c, key)), sn->lnum, sn->offs, - c->dev_name); + (unsigned long)inum, ubifs_get_key_name(key_type(c, key)), + sn->lnum, sn->offs, c->dev_name); return insert_or_update_file(c, tree, sn, key_type(c, key), inum); } @@ -344,7 +341,8 @@ void update_files_size(struct ubifs_info *c) if (file && file->ino.header.exist && file->ino.size < e->d_size) { dbg_fsck("update file(%lu) size %llu->%llu, in %s", - e->inum, file->ino.size, + (unsigned long)e->inum, + file->ino.size, (unsigned long long)e->d_size, c->dev_name); file->ino.size = e->d_size; diff --git a/ubifs-utils/fsck.ubifs/extract_files.c b/ubifs-utils/fsck.ubifs/extract_files.c index c83d377..2e47b42 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" @@ -76,21 +78,21 @@ bool parse_ino_node(struct ubifs_info *c, int lnum, int offs, void *node, if (!inum || inum > INUM_WATERMARK) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node(bad inum %lu) at %d:%d, in %s", - inum, lnum, offs, c->dev_name); + (unsigned long)inum, lnum, offs, c->dev_name); else log_out(c, "bad inode node(bad inum %lu) at %d:%d", - inum, lnum, offs); + (unsigned long)inum, lnum, offs); goto out; } if (ch->node_type != key_type(c, key)) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(inconsistent node type %d vs key_type %d) at %d:%d, in %s", - inum, ch->node_type, key_type(c, key), + (unsigned long)inum, ch->node_type, key_type(c, key), lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(inconsistent node type %d vs key_type %d) at %d:%d", - inum, ch->node_type, key_type(c, key), + (unsigned long)inum, ch->node_type, key_type(c, key), lnum, offs); goto out; } @@ -112,43 +114,43 @@ bool parse_ino_node(struct ubifs_info *c, int lnum, int offs, void *node, if (inum == UBIFS_ROOT_INO && !S_ISDIR(ino_node->mode)) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(root inode is not dir, tyoe %u) at %d:%d, in %s", - inum, ino_node->mode & S_IFMT, lnum, offs, + (unsigned long)inum, ino_node->mode & S_IFMT, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(root inode is not dir, tyoe %u) at %d:%d", - inum, ino_node->mode & S_IFMT, lnum, offs); + (unsigned long)inum, ino_node->mode & S_IFMT, lnum, offs); goto out; } if (ino_node->size > c->max_inode_sz) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(size %llu is too large) at %d:%d, in %s", - inum, ino_node->size, lnum, offs, c->dev_name); + (unsigned long)inum, ino_node->size, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(size %llu is too large) at %d:%d", - inum, ino_node->size, lnum, offs); + (unsigned long)inum, ino_node->size, lnum, offs); goto out; } if (le16_to_cpu(ino->compr_type) >= UBIFS_COMPR_TYPES_CNT) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(unknown compression type %d) at %d:%d, in %s", - inum, le16_to_cpu(ino->compr_type), lnum, offs, + (unsigned long)inum, le16_to_cpu(ino->compr_type), lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(unknown compression type %d) at %d:%d", - inum, le16_to_cpu(ino->compr_type), lnum, offs); + (unsigned long)inum, le16_to_cpu(ino->compr_type), lnum, offs); goto out; } if (ino_node->xnms + ino_node->xcnt > XATTR_LIST_MAX) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(too big xnames %u xcount %u) at %d:%d, in %s", - inum, ino_node->xnms, ino_node->xcnt, + (unsigned long)inum, ino_node->xnms, ino_node->xcnt, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(too big xnames %u xcount %u) at %d:%d", - inum, ino_node->xnms, ino_node->xcnt, + (unsigned long)inum, ino_node->xnms, ino_node->xcnt, lnum, offs); goto out; } @@ -156,20 +158,20 @@ bool parse_ino_node(struct ubifs_info *c, int lnum, int offs, void *node, if (data_len < 0 || data_len > UBIFS_MAX_INO_DATA) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(invalid data len %d) at %d:%d, in %s", - inum, data_len, lnum, offs, c->dev_name); + (unsigned long)inum, data_len, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(invalid data len %d) at %d:%d", - inum, data_len, lnum, offs); + (unsigned long)inum, data_len, lnum, offs); goto out; } if (UBIFS_INO_NODE_SZ + data_len != node_len) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(inconsistent data len %d vs node len %d) at %d:%d, in %s", - inum, data_len, node_len, lnum, offs, c->dev_name); + (unsigned long)inum, data_len, node_len, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(inconsistent data len %d vs node len %d) at %d:%d", - inum, data_len, node_len, lnum, offs); + (unsigned long)inum, data_len, node_len, lnum, offs); goto out; } @@ -177,33 +179,33 @@ bool parse_ino_node(struct ubifs_info *c, int lnum, int offs, void *node, if (!S_ISREG(ino_node->mode)) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(bad type %u for xattr) at %d:%d, in %s", - inum, ino_node->mode & S_IFMT, + (unsigned long)inum, ino_node->mode & S_IFMT, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(bad type %u for xattr) at %d:%d", - inum, ino_node->mode & S_IFMT, + (unsigned long)inum, ino_node->mode & S_IFMT, lnum, offs); goto out; } if (data_len != ino_node->size) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(inconsistent data_len %d vs size %llu for xattr) at %d:%d, in %s", - inum, data_len, ino_node->size, + (unsigned long)inum, data_len, ino_node->size, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(inconsistent data_len %d vs size %llu for xattr) at %d:%d", - inum, data_len, ino_node->size, + (unsigned long)inum, data_len, ino_node->size, lnum, offs); goto out; } if (ino_node->xcnt || ino_node->xsz || ino_node->xnms) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(non zero xattr count %u xattr size %u xattr names %u for xattr) at %d:%d, in %s", - inum, ino_node->xcnt, ino_node->xsz, + (unsigned long)inum, ino_node->xcnt, ino_node->xsz, ino_node->xnms, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(non zero xattr count %u xattr size %u xattr names %u for xattr) at %d:%d", - inum, ino_node->xcnt, ino_node->xsz, + (unsigned long)inum, ino_node->xcnt, ino_node->xsz, ino_node->xnms, lnum, offs); goto out; } @@ -214,10 +216,10 @@ bool parse_ino_node(struct ubifs_info *c, int lnum, int offs, void *node, if (!ino_node->is_xattr && data_len != 0) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(bad data len %d for reg file) at %d:%d, in %s", - inum, data_len, lnum, offs, c->dev_name); + (unsigned long)inum, data_len, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(bad data len %d for reg file) at %d:%d", - inum, data_len, lnum, offs); + (unsigned long)inum, data_len, lnum, offs); goto out; } break; @@ -225,10 +227,10 @@ bool parse_ino_node(struct ubifs_info *c, int lnum, int offs, void *node, if (data_len != 0) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(bad data len %d for dir file) at %d:%d, in %s", - inum, data_len, lnum, offs, c->dev_name); + (unsigned long)inum, data_len, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(bad data len %d for dir file) at %d:%d", - inum, data_len, lnum, offs); + (unsigned long)inum, data_len, lnum, offs); goto out; } break; @@ -247,10 +249,10 @@ bool parse_ino_node(struct ubifs_info *c, int lnum, int offs, void *node, */ if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad symlink inode node %lu(bad data len %d) at %d:%d, in %s", - inum, data_len, lnum, offs, c->dev_name); + (unsigned long)inum, data_len, lnum, offs, c->dev_name); else log_out(c, "bad symlink inode node %lu(bad data len %d) at %d:%d", - inum, data_len, lnum, offs); + (unsigned long)inum, data_len, lnum, offs); goto out; } break; @@ -264,11 +266,11 @@ bool parse_ino_node(struct ubifs_info *c, int lnum, int offs, void *node, if (data_len != sz_new && data_len != sz_huge) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(bad data len %d for char/block file, expect %d or %d) at %d:%d, in %s", - inum, data_len, sz_new, sz_huge, lnum, + (unsigned long)inum, data_len, sz_new, sz_huge, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(bad data len %d for char/block file, expect %d or %d) at %d:%d", - inum, data_len, sz_new, sz_huge, lnum, + (unsigned long)inum, data_len, sz_new, sz_huge, lnum, offs); goto out; } @@ -280,10 +282,10 @@ bool parse_ino_node(struct ubifs_info *c, int lnum, int offs, void *node, if (data_len != 0) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(bad data len %d for fifo/sock file) at %d:%d, in %s", - inum, data_len, lnum, offs, c->dev_name); + (unsigned long)inum, data_len, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(bad data len %d for fifo/sock file) at %d:%d", - inum, data_len, lnum, offs); + (unsigned long)inum, data_len, lnum, offs); goto out; } break; @@ -291,21 +293,21 @@ bool parse_ino_node(struct ubifs_info *c, int lnum, int offs, void *node, /* invalid file type. */ if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(unknown type %u) at %d:%d, in %s", - inum, ino_node->mode & S_IFMT, lnum, offs, c->dev_name); + (unsigned long)inum, ino_node->mode & S_IFMT, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(unknown type %u) at %d:%d", - inum, ino_node->mode & S_IFMT, lnum, offs); + (unsigned long)inum, ino_node->mode & S_IFMT, lnum, offs); goto out; } if (ino_node->is_encrypted && !inode_can_be_encrypted(c, ino_node)) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad inode node %lu(encrypted but cannot be encrypted, type %u, is_xattr %d, fs_encrypted %d) at %d:%d, in %s", - inum, ino_node->mode & S_IFMT, ino_node->is_xattr, + (unsigned long)inum, ino_node->mode & S_IFMT, ino_node->is_xattr, c->encrypted, lnum, offs, c->dev_name); else log_out(c, "bad inode node %lu(encrypted but cannot be encrypted, type %u, is_xattr %d, fs_encrypted %d) at %d:%d", - inum, ino_node->mode & S_IFMT, ino_node->is_xattr, + (unsigned long)inum, ino_node->mode & S_IFMT, ino_node->is_xattr, c->encrypted, lnum, offs); goto out; } @@ -355,12 +357,12 @@ bool parse_dent_node(struct ubifs_info *c, int lnum, int offs, void *node, if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad %s node(len %d nlen %d type %d inum %lu key_type %d node_type %d) at %d:%d, in %s", ch->node_type == UBIFS_XENT_NODE ? "xattr entry" : "directory entry", - node_len, nlen, dent->type, inum, key_type, + node_len, nlen, dent->type, (unsigned long)inum, key_type, ch->node_type, lnum, offs, c->dev_name); else log_out(c, "bad %s node(len %d nlen %d type %d inum %lu key_type %d node_type %d) at %d:%d", ch->node_type == UBIFS_XENT_NODE ? "xattr entry" : "directory entry", - node_len, nlen, dent->type, inum, key_type, + node_len, nlen, dent->type, (unsigned long)inum, key_type, ch->node_type, lnum, offs); goto out; } @@ -417,10 +419,10 @@ bool parse_data_node(struct ubifs_info *c, int lnum, int offs, void *node, if (!inum || inum > INUM_WATERMARK) { if (FSCK(c)->mode == REBUILD_MODE) dbg_fsck("bad data node(bad inum %lu) at %d:%d, in %s", - inum, lnum, offs, c->dev_name); + (unsigned long)inum, lnum, offs, c->dev_name); else log_out(c, "bad data node(bad inum %lu) at %d:%d", - inum, lnum, offs); + (unsigned long)inum, lnum, offs); goto out; } @@ -483,7 +485,7 @@ bool parse_trun_node(struct ubifs_info *c, int lnum, int offs, void *node, if (!inum || inum > INUM_WATERMARK) { dbg_fsck("bad truncation node(bad inum %lu) at %d:%d, in %s", - inum, lnum, offs, c->dev_name); + (unsigned long)inum, lnum, offs, c->dev_name); goto out; } @@ -494,8 +496,9 @@ bool parse_trun_node(struct ubifs_info *c, int lnum, int offs, void *node, if (old_size < 0 || old_size > c->max_inode_sz || new_size < 0 || new_size > c->max_inode_sz || old_size <= new_size) { - dbg_fsck("bad truncation node(new size %ld old size %ld inum %lu) at %d:%d, in %s", - new_size, old_size, inum, lnum, offs, c->dev_name); + dbg_fsck("bad truncation node(new size %lld old size %lld inum %lu) at %d:%d, in %s", + (long long)new_size, (long long)old_size, + (unsigned long)inum, lnum, offs, c->dev_name); goto out; } @@ -1005,7 +1008,7 @@ int file_is_valid(struct ubifs_info *c, struct scanned_file *file, struct scanned_data_node *data_node; LIST_HEAD(drop_list); - dbg_fsck("check validation of file %lu, in %s", file->inum, c->dev_name); + dbg_fsck("check validation of file %lu, in %s", (unsigned long)file->inum, c->dev_name); if (!file->ino.header.exist) { handle_invalid_file(c, FILE_HAS_NO_INODE, file, NULL); @@ -1273,12 +1276,12 @@ retry: handle_invalid_file(c, FILE_IS_DISCONNECTED, file, NULL); else handle_invalid_file(c, FILE_HAS_NO_DENT, file, NULL); - dbg_fsck("file %lu is unreachable, in %s", file->inum, c->dev_name); + dbg_fsck("file %lu is unreachable, in %s", (unsigned long)file->inum, c->dev_name); return false; } reachable: - dbg_fsck("file %lu is reachable, in %s", file->inum, c->dev_name); + dbg_fsck("file %lu is reachable, in %s", (unsigned long)file->inum, c->dev_name); return true; } @@ -1496,7 +1499,7 @@ static int correct_file_info(struct ubifs_info *c, struct scanned_file *file) handle_invalid_file(c, FILE_IS_INCONSISTENT, file, NULL); lnum = file->ino.header.lnum; dbg_fsck("correct file(inum:%lu type:%s), nlink %u->%u, xattr cnt %u->%u, xattr size %u->%u, xattr names %u->%u, size %llu->%llu, at %d:%d, in %s", - file->inum, file->ino.is_xattr ? "xattr" : + (unsigned long)file->inum, file->ino.is_xattr ? "xattr" : ubifs_get_type_name(ubifs_get_dent_type(file->ino.mode)), file->ino.nlink, file->calc_nlink, file->ino.xcnt, file->calc_xcnt, diff --git a/ubifs-utils/fsck.ubifs/handle_disconnected.c b/ubifs-utils/fsck.ubifs/handle_disconnected.c index be62522..9e5d925 100644 --- a/ubifs-utils/fsck.ubifs/handle_disconnected.c +++ b/ubifs-utils/fsck.ubifs/handle_disconnected.c @@ -117,7 +117,7 @@ static int handle_disonnected_file(struct ubifs_info *c, struct ubifs_inode *target_ui; err = snprintf(file_name, sizeof(file_name), - "INO_%lu_%u", file->inum, index); + "INO_%lu_%u", (unsigned long)file->inum, index); if (err < 0) goto free_ui; fname_name(&nm) = file_name; @@ -138,7 +138,7 @@ static int handle_disonnected_file(struct ubifs_info *c, kfree(ui); kfree(lost_found_ui); log_out(c, "Too many duplicated names(%u) in lost+found for inum %lu", - index, file->inum); + index, (unsigned long)file->inum); goto delete_file; } @@ -150,7 +150,7 @@ static int handle_disonnected_file(struct ubifs_info *c, goto delete_file; } dbg_fsck("recover disconnected file %lu, in %s", - file->inum, c->dev_name); + (unsigned long)file->inum, c->dev_name); free_ui: kfree(ui); diff --git a/ubifs-utils/fsck.ubifs/problem.c b/ubifs-utils/fsck.ubifs/problem.c index 916c976..edb5f57 100644 --- a/ubifs-utils/fsck.ubifs/problem.c +++ b/ubifs-utils/fsck.ubifs/problem.c @@ -147,7 +147,7 @@ static void print_problem(const struct ubifs_info *c, { const struct invalid_file_problem *ifp = (const struct invalid_file_problem *)priv; - log_out(c, "problem: %s, ino %lu", problem->desc, ifp->file->inum); + log_out(c, "problem: %s, ino %lu", problem->desc, (unsigned long)ifp->file->inum); break; } case FILE_HAS_INCONSIST_TYPE: @@ -156,7 +156,7 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_dent_node *dent_node = (const struct scanned_dent_node *)ifp->priv; log_out(c, "problem: %s, ino %lu, inode type %s%s, dentry %s has type %s%s", - problem->desc, ifp->file->inum, + problem->desc, (unsigned long)ifp->file->inum, ubifs_get_type_name(ubifs_get_dent_type(ifp->file->ino.mode)), ifp->file->ino.is_xattr ? "(xattr)" : "", c->encrypted && !ifp->file->ino.is_xattr ? "<encrypted>" : dent_node->name, @@ -171,7 +171,7 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_dent_node *dent_node = (const struct scanned_dent_node *)ifp->priv; log_out(c, "problem: %s, ino %lu, type %s%s, dentry %s", - problem->desc, ifp->file->inum, + problem->desc, (unsigned long)ifp->file->inum, ubifs_get_type_name(ubifs_get_dent_type(ifp->file->ino.mode)), ifp->file->ino.is_xattr ? "(xattr)" : "", c->encrypted && !ifp->file->ino.is_xattr ? "<encrypted>" : dent_node->name); @@ -183,7 +183,7 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_data_node *data_node = (const struct scanned_data_node *)ifp->priv; log_out(c, "problem: %s, ino %lu, type %s%s, data block %u", - problem->desc, ifp->file->inum, + problem->desc, (unsigned long)ifp->file->inum, ubifs_get_type_name(ubifs_get_dent_type(ifp->file->ino.mode)), ifp->file->ino.is_xattr ? "(xattr)" : "", key_block(c, &data_node->key)); @@ -198,7 +198,7 @@ static void print_problem(const struct ubifs_info *c, const struct invalid_file_problem *ifp = (const struct invalid_file_problem *)priv; log_out(c, "problem: %s, ino %lu type %s%s", problem->desc, - ifp->file->inum, + (unsigned long)ifp->file->inum, ubifs_get_type_name(ubifs_get_dent_type(ifp->file->ino.mode)), ifp->file->ino.is_xattr ? "(xattr)" : ""); break; @@ -209,9 +209,9 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_file *host = (const struct scanned_file *)ifp->priv; log_out(c, "problem: %s, ino %lu type %s%s, host ino %lu type %s%s", - problem->desc, ifp->file->inum, + problem->desc, (unsigned long)ifp->file->inum, ubifs_get_type_name(ubifs_get_dent_type(ifp->file->ino.mode)), - ifp->file->ino.is_xattr ? "(xattr)" : "", host->inum, + ifp->file->ino.is_xattr ? "(xattr)" : "", (unsigned long)host->inum, ubifs_get_type_name(ubifs_get_dent_type(host->ino.mode)), host->ino.is_xattr ? "(xattr)" : ""); break; @@ -222,7 +222,7 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_dent_node *dent_node = (const struct scanned_dent_node *)ifp->priv; log_out(c, "problem: %s, ino %lu, unreachable dentry %s, type %s%s", - problem->desc, ifp->file->inum, + problem->desc, (unsigned long)ifp->file->inum, c->encrypted && !ifp->file->ino.is_xattr ? "<encrypted>" : dent_node->name, ubifs_get_type_name(dent_node->type), key_type(c, &dent_node->key) == UBIFS_XENT_KEY ? "(xattr)" : ""); @@ -235,7 +235,7 @@ static void print_problem(const struct ubifs_info *c, log_out(c, "problem: %s, ino %lu type %s, nlink %u xcnt %u xsz %u xnms %u size %llu, " "should be nlink %u xcnt %u xsz %u xnms %u size %llu", - problem->desc, file->inum, + problem->desc, (unsigned long)file->inum, file->ino.is_xattr ? "xattr" : ubifs_get_type_name(ubifs_get_dent_type(file->ino.mode)), file->ino.nlink, file->ino.xcnt, file->ino.xsz, file->ino.xnms, file->ino.size, @@ -299,7 +299,7 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_file *file = (const struct scanned_file *)priv; log_out(c, "problem: %s, ino %lu, size %llu", problem->desc, - file->inum, file->ino.size); + (unsigned long)file->inum, file->ino.size); break; } default: diff --git a/ubifs-utils/fsck.ubifs/rebuild_fs.c b/ubifs-utils/fsck.ubifs/rebuild_fs.c index b82d728..b399b3e 100644 --- a/ubifs-utils/fsck.ubifs/rebuild_fs.c +++ b/ubifs-utils/fsck.ubifs/rebuild_fs.c @@ -697,7 +697,7 @@ static void extract_dentry_tree(struct ubifs_info *c) file = list_entry(unreachable.next, struct scanned_file, list); dbg_fsck("remove unreachable file %lu, in %s", - file->inum, c->dev_name); + (unsigned long)file->inum, c->dev_name); list_del(&file->list); destroy_file_content(c, file); rb_erase(&file->rb, tree); @@ -1097,7 +1097,7 @@ static int record_file_used_lebs(struct ubifs_info *c, struct scanned_data_node *data_node; dbg_fsck("recovered file(inum:%lu name:%s type:%s), in %s", - file->inum, get_file_name(c, file), + (unsigned long)file->inum, get_file_name(c, file), file->ino.is_xattr ? "xattr" : ubifs_get_type_name(ubifs_get_dent_type(file->ino.mode)), c->dev_name); 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/dir.c b/ubifs-utils/libubifs/dir.c index 89f77eb..2eb4e75 100644 --- a/ubifs-utils/libubifs/dir.c +++ b/ubifs-utils/libubifs/dir.c @@ -249,7 +249,7 @@ int ubifs_mkdir(struct ubifs_info *c, struct ubifs_inode *dir_ui, * directory inode. */ dbg_gen("dent '%s', mode %#hx in dir ino %lu", - fname_name(nm), mode, dir->inum); + fname_name(nm), mode, (unsigned long)dir->inum); /* New dir is not allowed to be created under an encrypted directory. */ ubifs_assert(c, !(dir_ui->flags & UBIFS_CRYPT_FL)); @@ -315,7 +315,7 @@ int ubifs_link_recovery(struct ubifs_info *c, struct ubifs_inode *dir_ui, * changing the parent inode. */ dbg_gen("dent '%s' to ino %lu (nlink %d) in dir ino %lu", - fname_name(nm), inode->inum, inode->nlink, dir->inum); + fname_name(nm), (unsigned long)inode->inum, inode->nlink, (unsigned long)dir->inum); /* New dir is not allowed to be created under an encrypted directory. */ ubifs_assert(c, !(dir_ui->flags & UBIFS_CRYPT_FL)); 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" |
