From 29ef97363d352ab157c1c5422ac5de43c038e60e Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 18 Oct 2018 16:36:40 +0200 Subject: mkfs.ubifs: Implement UBIFS_FLG_DOUBLE_HASH Signed-off-by: Richard Weinberger Signed-off-by: David Oberhollenzer --- ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 13 +++++++++++++ ubifs-utils/mkfs.ubifs/mkfs.ubifs.h | 2 ++ ubifs-utils/mkfs.ubifs/ubifs.h | 2 ++ 3 files changed, 17 insertions(+) diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c index fd6538c..e7acf17 100644 --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c @@ -1436,6 +1436,14 @@ static int add_symlink_inode(const char *path_name, struct stat *st, ino_t inum, return add_inode(st, inum, buf, len, flags, path_name); } +static void set_dent_cookie(struct ubifs_dent_node *dent) +{ + if (c->double_hash) + RAND_bytes((void *)&dent->cookie, sizeof(dent->cookie)); + else + dent->cookie = 0; +} + /** * add_dent_node - write a directory entry node. * @dir_inum: target inode number of directory @@ -1469,6 +1477,7 @@ static int add_dent_node(ino_t dir_inum, const char *name, ino_t inum, dent->nlen = cpu_to_le16(dname.len); memcpy(dent->name, dname.name, dname.len); dent->name[dname.len] = '\0'; + set_dent_cookie(dent); len = UBIFS_DENT_NODE_SZ + dname.len + 1; @@ -2268,6 +2277,8 @@ static int write_super(void) sup.flags |= cpu_to_le32(UBIFS_FLG_BIGLPT); if (c->space_fixup) sup.flags |= cpu_to_le32(UBIFS_FLG_SPACE_FIXUP); + if (c->double_hash) + sup.flags |= cpu_to_le32(UBIFS_FLG_DOUBLE_HASH); return write_node(&sup, UBIFS_SB_NODE_SZ, UBIFS_SB_LNUM); } @@ -2630,6 +2641,8 @@ int main(int argc, char *argv[]) if (crypto_init()) return -1; + RAND_poll(); + err = get_options(argc, argv); if (err) return err; diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h index 1321191..aa03239 100644 --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h @@ -46,6 +46,8 @@ #include #include +#include + #include /* common.h requires the PROGRAM_NAME macro */ diff --git a/ubifs-utils/mkfs.ubifs/ubifs.h b/ubifs-utils/mkfs.ubifs/ubifs.h index 2f080a8..5a4af99 100644 --- a/ubifs-utils/mkfs.ubifs/ubifs.h +++ b/ubifs-utils/mkfs.ubifs/ubifs.h @@ -330,6 +330,7 @@ struct ubifs_znode * @nhead_offs: offset of LPT head * @big_lpt: flag that LPT is too big to write whole during commit * @space_fixup: flag indicating that free space in LEBs needs to be cleaned up + * @double_hash: flag indicating that we can do lookups by hash * @lpt_sz: LPT size * * @ltab_lnum: LEB number of LPT's own lprops table @@ -408,6 +409,7 @@ struct ubifs_info int nhead_offs; int big_lpt; int space_fixup; + int double_hash; long long lpt_sz; int ltab_lnum; -- cgit v1.2.3