summaryrefslogtreecommitdiff
path: root/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2018-10-18 16:36:40 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2018-11-01 12:32:29 +0100
commit29ef97363d352ab157c1c5422ac5de43c038e60e (patch)
tree0dc8f9f80f80aa788f8f6f426e3e749ba0793f04 /ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
parent989fbb74d23dfebdf3feb0c0d736f92a6f9d8767 (diff)
mkfs.ubifs: Implement UBIFS_FLG_DOUBLE_HASH
Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/mkfs.ubifs/mkfs.ubifs.c')
-rw-r--r--ubifs-utils/mkfs.ubifs/mkfs.ubifs.c13
1 files changed, 13 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;