aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ubifs-utils/mkfs.ubifs/mkfs.ubifs.c13
-rw-r--r--ubifs-utils/mkfs.ubifs/mkfs.ubifs.h2
-rw-r--r--ubifs-utils/mkfs.ubifs/ubifs.h2
3 files changed, 17 insertions, 0 deletions
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 <uuid.h>
#include <sys/file.h>
+#include <openssl/rand.h>
+
#include <mtd/ubifs-media.h>
/* 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;