aboutsummaryrefslogtreecommitdiff
path: root/ubifs-utils/libubifs/tnc_commit.c
diff options
context:
space:
mode:
authorZhihao Cheng <chengzhihao1@huawei.com>2024-11-11 16:37:00 +0800
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-11-11 10:32:45 +0100
commit51e613c55ba87a57ca66d0dc37cb576f38882bf0 (patch)
treecfa771267a944cf805c25d128e8c51d2d56da3b9 /ubifs-utils/libubifs/tnc_commit.c
parent5278ea32ae168fe182a122e516ab4fa644df6469 (diff)
ubifs-utils: Adapt tnc subsystem in libubifs
Adapt tnc subsystem(tnc.c,tnc_misc.c,tnc_commit.c) in libubifs, compared with linux kernel implementations: 1. Remove debug related functions(eg. dbg_check_inode_size), debug functions are not needed by fsck, because fsck will check fs in another way. 2. Remove some functions(eg. ubifs_tnc_bulk_read) which won't be used in fsck/mkfs. 3. Adapt tnc_delete and ubifs_search_zbranch to handle empty TNC case, which could happen in fsck. 4. Don't skip checking the length of non-leaf index node's branch in read_znode. 5. Adapt try_read_node to ignore %-EBADMSG, subsequent steps will check nodes carefully. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/libubifs/tnc_commit.c')
-rw-r--r--ubifs-utils/libubifs/tnc_commit.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/ubifs-utils/libubifs/tnc_commit.c b/ubifs-utils/libubifs/tnc_commit.c
index a55e048..d797006 100644
--- a/ubifs-utils/libubifs/tnc_commit.c
+++ b/ubifs-utils/libubifs/tnc_commit.c
@@ -10,8 +10,14 @@
/* This file implements TNC functions for committing */
-#include <linux/random.h>
+#include "linux_err.h"
+#include "bitops.h"
+#include "kmem.h"
#include "ubifs.h"
+#include "defs.h"
+#include "debug.h"
+#include "key.h"
+#include "misc.h"
/**
* make_idx_node - make an index node for fill-the-gaps method of TNC commit.
@@ -546,8 +552,8 @@ static int layout_in_empty_space(struct ubifs_info *c)
break;
}
- c->dbg->new_ihead_lnum = lnum;
- c->dbg->new_ihead_offs = buf_offs;
+ c->new_ihead_lnum = lnum;
+ c->new_ihead_offs = buf_offs;
return 0;
}
@@ -700,7 +706,7 @@ static int alloc_idx_lebs(struct ubifs_info *c, int cnt)
c->ilebs[c->ileb_cnt++] = lnum;
dbg_cmt("LEB %d", lnum);
}
- if (dbg_is_chk_index(c) && !get_random_u32_below(8))
+ if (dbg_is_chk_index(c))
return -ENOSPC;
return 0;
}
@@ -1011,8 +1017,8 @@ static int write_index(struct ubifs_info *c)
break;
}
- if (lnum != c->dbg->new_ihead_lnum ||
- buf_offs != c->dbg->new_ihead_offs) {
+ if (lnum != c->new_ihead_lnum ||
+ buf_offs != c->new_ihead_offs) {
ubifs_err(c, "inconsistent ihead");
return -EINVAL;
}