* @offs: node offset
* @len: node length
*/
-static int add_to_index(union ubifs_key *key, char *name, int name_len, int lnum, int offs,
- int len)
+static int add_to_index(union ubifs_key *key, char *name, int name_len,
+ int lnum, int offs, int len)
{
struct idx_entry *e;
*/
static int add_node(union ubifs_key *key, char *name, int name_len, void *node, int len)
{
- int err, lnum, offs;
+ int err, lnum, offs, type = key_type(key);
- if (key_type(key) == UBIFS_DENT_KEY || key_type(key) == UBIFS_XENT_KEY) {
+ if (type == UBIFS_DENT_KEY || type == UBIFS_XENT_KEY) {
if (!name)
- return err_msg("Directory entry or xattr without name!");
+ return err_msg("Directory entry or xattr "
+ "without name!");
} else {
if (name)
return err_msg("Name given for non dir/xattr node!");
return 0;
}
-static int add_xattr(struct ubifs_ino_node *host_ino, struct stat *st, ino_t inum,
- char *name, const void *data, unsigned int data_len)
+static int add_xattr(struct ubifs_ino_node *host_ino, struct stat *st,
+ ino_t inum, char *name, const void *data,
+ unsigned int data_len)
{
struct ubifs_ino_node *ino;
struct ubifs_dent_node *xent;
{
struct fscrypt_symlink_data *sd;
void *outbuf;
- unsigned int link_disk_len = fscrypt_fname_encrypted_size(fctx, data_len) + sizeof(struct fscrypt_symlink_data);
+ unsigned int link_disk_len;
unsigned int cryptlen;
int ret;
+ link_disk_len = sizeof(struct fscrypt_symlink_data);
+ link_disk_len += fscrypt_fname_encrypted_size(fctx, data_len);
+
ret = encrypt_path(&outbuf, data, data_len, UBIFS_MAX_INO_DATA, fctx);
if (ret < 0)
return ret;
if (!kname)
return err_msg("cannot allocate memory");
} else {
- unsigned int max_namelen = type == UBIFS_ITYPE_LNK ? UBIFS_MAX_INO_DATA : UBIFS_MAX_NLEN;
+ unsigned int max_namelen = UBIFS_MAX_NLEN;
int ret;
+ if (type == UBIFS_ITYPE_LNK)
+ max_namelen = UBIFS_MAX_INO_DATA;
+
ret = encrypt_path((void **)&kname, dname.name, dname.len,
max_namelen, fctx);
if (ret < 0)
nlink += 1;
type = UBIFS_ITYPE_DIR;
} else {
- err = add_non_dir(name, &inum, 0, &type, &dent_st, new_fctx);
+ err = add_non_dir(name, &inum, 0, &type,
+ &dent_st, new_fctx);
if (err)
goto out_free;
}
nlink += 1;
type = UBIFS_ITYPE_DIR;
} else {
- err = add_non_dir(name, &inum, 0, &type, &fake_st, new_fctx);
+ err = add_non_dir(name, &inum, 0, &type,
+ &fake_st, new_fctx);
if (err)
goto out_free;
}
creat_sqnum = dir_creat_sqnum;
- err = add_dir_inode(dir ? dir_name : NULL, dir, dir_inum, size, nlink, st, fctx);
+ err = add_dir_inode(dir ? dir_name : NULL, dir, dir_inum, size,
+ nlink, st, fctx);
if (err)
goto out_free;