From 583125d58cc604ba8bb3cdca1656c7f973fae69c Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Mon, 11 Nov 2024 16:36:42 +0800 Subject: ubifs-utils: Add linux type definitions Add linux type definitions, because there are many types (eg. u8/u16/u64) used in UBIFS linux kernel libs. Besides move type conversions (eg. cpu_to_le16, cpu_to_le32, etc.) into type definitions header file. This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ubifs-utils/mkfs.ubifs') diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c index 2181595..c2f5a29 100644 --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c @@ -46,6 +46,7 @@ #include #endif +#include "linux_types.h" #include "defs.h" #include "crypto.h" #include "fscrypt.h" @@ -1207,12 +1208,14 @@ static int add_xattr(struct ubifs_ino_node *host_ino, struct stat *st, struct ubifs_ino_node *ino; struct ubifs_dent_node *xent; struct qstr nm; + char *tmp_name; union ubifs_key xkey, nkey; int len, ret; nm.len = strlen(name); - nm.name = xmalloc(nm.len + 1); - memcpy(nm.name, name, nm.len + 1); + tmp_name = xmalloc(nm.len + 1); + memcpy(tmp_name, name, nm.len + 1); + nm.name = tmp_name; host_ino->xattr_cnt++; host_ino->xattr_size += CALC_DENT_SIZE(nm.len); @@ -1240,7 +1243,7 @@ static int add_xattr(struct ubifs_ino_node *host_ino, struct stat *st, xent->inum = cpu_to_le64(inum); - ret = add_node(&xkey, nm.name, nm.len, xent, len); + ret = add_node(&xkey, tmp_name, nm.len, xent, len); if (ret) goto out; -- cgit v1.2.3