ref: 2dcb04101f350c40b7ea7ea160933d0be5d86826
parent: 529a2b7118a139f632ca60220467c4f3d4315ad2
author: gkostka <kostka.grzegorz@gmail.com>
date: Thu Oct 29 18:59:18 EDT 2015
Refactor directory related names (shorter)
--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -147,7 +147,7 @@
return EOK;
}
- struct ext4_directory_iterator it;
+ struct ext4_dir_iterator it;
int rc = ext4_dir_iterator_init(&it, enode, 0);
if (rc != EOK)
return rc;
@@ -243,7 +243,7 @@
int has_flag_index =
ext4_inode_has_flag(child->inode,
EXT4_INODE_FLAG_INDEX);
- struct ext4_directory_search_result result;
+ struct ext4_dir_search_result result;
if (!has_flag_index) {
rc = ext4_dir_find_entry(&result,
child, "..",
@@ -588,7 +588,7 @@
int r;
struct ext4_mountpoint *mp = ext4_get_mount(path);
- struct ext4_directory_search_result result;
+ struct ext4_dir_search_result result;
struct ext4_inode_ref ref;
f->mp = 0;
@@ -770,7 +770,7 @@
int r;
struct ext4_mountpoint *mp = ext4_get_mount(path);
- struct ext4_directory_search_result result;
+ struct ext4_dir_search_result result;
struct ext4_inode_ref ref;
if (!mp)
@@ -2196,7 +2196,7 @@
struct ext4_mountpoint *mp = ext4_get_mount(path);
struct ext4_inode_ref current;
struct ext4_inode_ref child;
- struct ext4_directory_iterator it;
+ struct ext4_dir_iterator it;
uint32_t name_off;
uint32_t inode_up;
@@ -2447,7 +2447,7 @@
int r;
ext4_direntry *de = 0;
struct ext4_inode_ref dir;
- struct ext4_directory_iterator it;
+ struct ext4_dir_iterator it;
EXT4_MP_LOCK(d->f.mp);
--- a/lwext4/ext4_dir.c
+++ b/lwext4/ext4_dir.c
@@ -51,17 +51,17 @@
/****************************************************************************/
/* Walk through a dirent block to find a checksum "dirent" at the tail */
-static struct ext4_directory_entry_tail *
+static struct ext4_dir_entry_tail *
ext4_dir_get_tail(struct ext4_inode_ref *inode_ref,
- struct ext4_directory_entry_ll *de)
+ struct ext4_dir_entry_ll *de)
{
- struct ext4_directory_entry_tail *t;
+ struct ext4_dir_entry_tail *t;
struct ext4_sblock *sb = &inode_ref->fs->sb;
t = EXT4_DIRENT_TAIL(de, ext4_sb_get_block_size(sb));
if (t->reserved_zero1 ||
- to_le16(t->rec_len) != sizeof(struct ext4_directory_entry_tail) ||
+ to_le16(t->rec_len) != sizeof(struct ext4_dir_entry_tail) ||
t->reserved_zero2 ||
t->reserved_ft != EXT4_DIRENTRY_DIR_CSUM)
return NULL;
@@ -71,7 +71,7 @@
#if CONFIG_META_CSUM_ENABLE
static uint32_t ext4_dir_checksum(struct ext4_inode_ref *inode_ref,
- struct ext4_directory_entry_ll *dirent, int size)
+ struct ext4_dir_entry_ll *dirent, int size)
{
uint32_t checksum;
struct ext4_sblock *sb = &inode_ref->fs->sb;
@@ -97,10 +97,10 @@
bool
ext4_dir_checksum_verify(struct ext4_inode_ref *inode_ref,
- struct ext4_directory_entry_ll *dirent)
+ struct ext4_dir_entry_ll *dirent)
{
#ifdef CONFIG_META_CSUM_ENABLE
- struct ext4_directory_entry_tail *t;
+ struct ext4_dir_entry_tail *t;
struct ext4_sblock *sb = &inode_ref->fs->sb;
/* Compute the checksum only if the filesystem supports it */
@@ -121,17 +121,17 @@
}
/* checksumming functions */
-void initialize_dir_tail(struct ext4_directory_entry_tail *t)
+void initialize_dir_tail(struct ext4_dir_entry_tail *t)
{
- memset(t, 0, sizeof(struct ext4_directory_entry_tail));
- t->rec_len = to_le16(sizeof(struct ext4_directory_entry_tail));
+ memset(t, 0, sizeof(struct ext4_dir_entry_tail));
+ t->rec_len = to_le16(sizeof(struct ext4_dir_entry_tail));
t->reserved_ft = EXT4_DIRENTRY_DIR_CSUM;
}
void ext4_dir_set_checksum(struct ext4_inode_ref *inode_ref,
- struct ext4_directory_entry_ll *dirent)
+ struct ext4_dir_entry_ll *dirent)
{
- struct ext4_directory_entry_tail *t;
+ struct ext4_dir_entry_tail *t;
struct ext4_sblock *sb = &inode_ref->fs->sb;
/* Compute the checksum only if the filesystem supports it */
@@ -152,7 +152,7 @@
* @param block_size Size of data block
* @return Error code
*/
-static int ext4_dir_iterator_set(struct ext4_directory_iterator *it,
+static int ext4_dir_iterator_set(struct ext4_dir_iterator *it,
uint32_t block_size)
{
it->current = NULL;
@@ -167,7 +167,7 @@
if (offset_in_block > block_size - 8)
return EIO;
- struct ext4_directory_entry_ll *entry =
+ struct ext4_dir_entry_ll *entry =
(void *)(it->current_block.data + offset_in_block);
/* Ensure that the whole entry does not overflow the block */
@@ -191,7 +191,7 @@
* @param pos Position of the next entry
* @return Error code
*/
-static int ext4_dir_iterator_seek(struct ext4_directory_iterator *it,
+static int ext4_dir_iterator_seek(struct ext4_dir_iterator *it,
uint64_t pos)
{
uint64_t size =
@@ -257,7 +257,7 @@
return ext4_dir_iterator_set(it, block_size);
}
-int ext4_dir_iterator_init(struct ext4_directory_iterator *it,
+int ext4_dir_iterator_init(struct ext4_dir_iterator *it,
struct ext4_inode_ref *inode_ref, uint64_t pos)
{
it->inode_ref = inode_ref;
@@ -268,7 +268,7 @@
return ext4_dir_iterator_seek(it, pos);
}
-int ext4_dir_iterator_next(struct ext4_directory_iterator *it)
+int ext4_dir_iterator_next(struct ext4_dir_iterator *it)
{
int r = EOK;
uint16_t skip;
@@ -287,7 +287,7 @@
return r;
}
-int ext4_dir_iterator_fini(struct ext4_directory_iterator *it)
+int ext4_dir_iterator_fini(struct ext4_dir_iterator *it)
{
it->current = 0;
@@ -299,7 +299,7 @@
}
void ext4_dir_write_entry(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *entry,
+ struct ext4_dir_entry_ll *entry,
uint16_t entry_len, struct ext4_inode_ref *child,
const char *name, size_t name_len)
{
@@ -383,7 +383,7 @@
if (!ext4_dir_checksum_verify(
parent,
- (struct ext4_directory_entry_ll *)
+ (struct ext4_dir_entry_ll *)
block.data)) {
ext4_dbg(DEBUG_DIR,
DBG_WARN "Leaf block checksum failed."
@@ -424,12 +424,12 @@
/* Fill block with zeroes */
memset(new_block.data, 0, block_size);
- struct ext4_directory_entry_ll *block_entry = (void *)new_block.data;
+ struct ext4_dir_entry_ll *block_entry = (void *)new_block.data;
/* Save new block */
if (ext4_sb_feature_ro_com(&fs->sb, EXT4_FRO_COM_METADATA_CSUM)) {
ext4_dir_write_entry(&fs->sb, block_entry,
- block_size - sizeof(struct ext4_directory_entry_tail),
+ block_size - sizeof(struct ext4_dir_entry_tail),
child,
name, name_len);
initialize_dir_tail(EXT4_DIRENT_TAIL(new_block.data,
@@ -439,7 +439,7 @@
name_len);
ext4_dir_set_checksum(parent,
- (struct ext4_directory_entry_ll *)new_block.data);
+ (struct ext4_dir_entry_ll *)new_block.data);
new_block.dirty = true;
rc = ext4_block_set(fs->bdev, &new_block);
@@ -446,7 +446,7 @@
return rc;
}
-int ext4_dir_find_entry(struct ext4_directory_search_result *result,
+int ext4_dir_find_entry(struct ext4_dir_search_result *result,
struct ext4_inode_ref *parent, const char *name,
uint32_t name_len)
{
@@ -498,7 +498,7 @@
if (!ext4_dir_checksum_verify(
parent,
- (struct ext4_directory_entry_ll *)
+ (struct ext4_dir_entry_ll *)
block.data)) {
ext4_dbg(DEBUG_DIR,
DBG_WARN "Leaf block checksum failed."
@@ -509,7 +509,7 @@
}
/* Try to find entry in block */
- struct ext4_directory_entry_ll *res_entry;
+ struct ext4_dir_entry_ll *res_entry;
rc = ext4_dir_find_in_block(&block, sb, name_len, name,
&res_entry);
if (rc == EOK) {
@@ -542,7 +542,7 @@
return ENOTDIR;
/* Try to find entry */
- struct ext4_directory_search_result result;
+ struct ext4_dir_search_result result;
int rc = ext4_dir_find_entry(&result, parent, name, name_len);
if (rc != EOK)
return rc;
@@ -561,7 +561,7 @@
uint32_t offset = 0;
/* Start from the first entry in block */
- struct ext4_directory_entry_ll *tmp_dentry =
+ struct ext4_dir_entry_ll *tmp_dentry =
(void *)result.block.data;
uint16_t tmp_dentry_length =
ext4_dir_entry_ll_get_entry_length(tmp_dentry);
@@ -585,7 +585,7 @@
}
ext4_dir_set_checksum(parent,
- (struct ext4_directory_entry_ll *)result.block.data);
+ (struct ext4_dir_entry_ll *)result.block.data);
result.block.dirty = true;
return ext4_dir_destroy_result(parent, &result);
@@ -600,14 +600,14 @@
/* Compute required length entry and align it to 4 bytes */
uint32_t block_size = ext4_sb_get_block_size(sb);
uint16_t required_len =
- sizeof(struct ext4_fake_directory_entry) + name_len;
+ sizeof(struct ext4_fake_dir_entry) + name_len;
if ((required_len % 4) != 0)
required_len += 4 - (required_len % 4);
/* Initialize pointers, stop means to upper bound */
- struct ext4_directory_entry_ll *dentry = (void *)target_block->data;
- struct ext4_directory_entry_ll *stop =
+ struct ext4_dir_entry_ll *dentry = (void *)target_block->data;
+ struct ext4_dir_entry_ll *stop =
(void *)(target_block->data + block_size);
/*
@@ -626,7 +626,7 @@
ext4_dir_write_entry(sb, dentry, rec_len, child, name,
name_len);
ext4_dir_set_checksum(inode_ref,
- (struct ext4_directory_entry_ll *)
+ (struct ext4_dir_entry_ll *)
target_block->data);
target_block->dirty = true;
@@ -639,7 +639,7 @@
ext4_dir_entry_ll_get_name_length(sb, dentry);
uint16_t used_space =
- sizeof(struct ext4_fake_directory_entry) +
+ sizeof(struct ext4_fake_dir_entry) +
used_name_len;
if ((used_name_len % 4) != 0)
@@ -652,13 +652,13 @@
/* Cut tail of current entry */
ext4_dir_entry_ll_set_entry_length(dentry,
used_space);
- struct ext4_directory_entry_ll *new_entry =
+ struct ext4_dir_entry_ll *new_entry =
(void *)((uint8_t *)dentry + used_space);
ext4_dir_write_entry(sb, new_entry, free_space,
child, name, name_len);
ext4_dir_set_checksum(inode_ref,
- (struct ext4_directory_entry_ll *)
+ (struct ext4_dir_entry_ll *)
target_block->data);
target_block->dirty = true;
return EOK;
@@ -675,11 +675,11 @@
int ext4_dir_find_in_block(struct ext4_block *block, struct ext4_sblock *sb,
size_t name_len, const char *name,
- struct ext4_directory_entry_ll **res_entry)
+ struct ext4_dir_entry_ll **res_entry)
{
/* Start from the first entry in block */
- struct ext4_directory_entry_ll *dentry =
- (struct ext4_directory_entry_ll *)block->data;
+ struct ext4_dir_entry_ll *dentry =
+ (struct ext4_dir_entry_ll *)block->data;
/* Set upper bound for cycling */
uint8_t *addr_limit = block->data + ext4_sb_get_block_size(sb);
@@ -712,7 +712,7 @@
return EINVAL;
/* Jump to next entry */
- dentry = (struct ext4_directory_entry_ll *)((uint8_t *)dentry +
+ dentry = (struct ext4_dir_entry_ll *)((uint8_t *)dentry +
dentry_len);
}
@@ -721,7 +721,7 @@
}
int ext4_dir_destroy_result(struct ext4_inode_ref *parent,
- struct ext4_directory_search_result *result)
+ struct ext4_dir_search_result *result)
{
if (result->block.lb_id)
return ext4_block_set(parent->fs->bdev, &result->block);
--- a/lwext4/ext4_dir.h
+++ b/lwext4/ext4_dir.h
@@ -54,7 +54,7 @@
* @return I-node number
*/
static inline uint32_t
-ext4_dir_entry_ll_get_inode(struct ext4_directory_entry_ll *de)
+ext4_dir_entry_ll_get_inode(struct ext4_dir_entry_ll *de)
{
return to_le32(de->inode);
}
@@ -64,7 +64,7 @@
* @param inode I-node number
*/
static inline void
-ext4_dir_entry_ll_set_inode(struct ext4_directory_entry_ll *de, uint32_t inode)
+ext4_dir_entry_ll_set_inode(struct ext4_dir_entry_ll *de, uint32_t inode)
{
de->inode = to_le32(inode);
}
@@ -74,7 +74,7 @@
* @param inode I-node number
*/
static inline void
-ext4_dx_dot_entry_set_inode(struct ext4_directory_dx_dot_entry *de, uint32_t inode)
+ext4_dx_dot_entry_set_inode(struct ext4_dir_idx_dot_entry *de, uint32_t inode)
{
de->inode = to_le32(inode);
}
@@ -84,7 +84,7 @@
* @return Entry length
*/
static inline uint16_t
-ext4_dir_entry_ll_get_entry_length(struct ext4_directory_entry_ll *de)
+ext4_dir_entry_ll_get_entry_length(struct ext4_dir_entry_ll *de)
{
return to_le16(de->entry_length);
}
@@ -94,7 +94,7 @@
* @param length Entry length
*/
static inline void
-ext4_dir_entry_ll_set_entry_length(struct ext4_directory_entry_ll *de,
+ext4_dir_entry_ll_set_entry_length(struct ext4_dir_entry_ll *de,
uint16_t len)
{
de->entry_length = to_le16(len);
@@ -107,7 +107,7 @@
*/
static inline uint16_t
ext4_dir_entry_ll_get_name_length(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de)
+ struct ext4_dir_entry_ll *de)
{
uint16_t v = de->name_length;
@@ -124,7 +124,7 @@
* @param length Entry name length
*/
static inline void ext4_dir_entry_ll_set_name_length(
- struct ext4_sblock *sb, struct ext4_directory_entry_ll *de, uint16_t len)
+ struct ext4_sblock *sb, struct ext4_dir_entry_ll *de, uint16_t len)
{
de->name_length = (len << 8) >> 8;
@@ -140,7 +140,7 @@
*/
static inline uint8_t
ext4_dir_entry_ll_get_inode_type(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de)
+ struct ext4_dir_entry_ll *de)
{
if ((ext4_get32(sb, rev_level) > 0) ||
(ext4_get32(sb, minor_rev_level) >= 5))
@@ -155,7 +155,7 @@
*/
static inline void ext4_dir_entry_ll_set_inode_type(
- struct ext4_sblock *sb, struct ext4_directory_entry_ll *de, uint8_t type)
+ struct ext4_sblock *sb, struct ext4_dir_entry_ll *de, uint8_t type)
{
if ((ext4_get32(sb, rev_level) > 0) ||
(ext4_get32(sb, minor_rev_level) >= 5))
@@ -169,7 +169,7 @@
*/
bool
ext4_dir_checksum_verify(struct ext4_inode_ref *inode_ref,
- struct ext4_directory_entry_ll *dirent);
+ struct ext4_dir_entry_ll *dirent);
/**@brief Initialize directory iterator.
* Set position to the first valid entry from the required position.
@@ -178,7 +178,7 @@
* @param pos Position to start reading entries from
* @return Error code
*/
-int ext4_dir_iterator_init(struct ext4_directory_iterator *it,
+int ext4_dir_iterator_init(struct ext4_dir_iterator *it,
struct ext4_inode_ref *inode_ref, uint64_t pos);
/**@brief Jump to the next valid entry
@@ -185,7 +185,7 @@
* @param it Initialized iterator
* @return Error code
*/
-int ext4_dir_iterator_next(struct ext4_directory_iterator *it);
+int ext4_dir_iterator_next(struct ext4_dir_iterator *it);
/**@brief Uninitialize directory iterator.
* Release all allocated structures.
@@ -192,7 +192,7 @@
* @param it Iterator to be finished
* @return Error code
*/
-int ext4_dir_iterator_fini(struct ext4_directory_iterator *it);
+int ext4_dir_iterator_fini(struct ext4_dir_iterator *it);
/**@brief Write directory entry to concrete data block.
* @param sb Superblock
@@ -203,7 +203,7 @@
* @param name_len Length of entry name
*/
void ext4_dir_write_entry(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *entry,
+ struct ext4_dir_entry_ll *entry,
uint16_t entry_len, struct ext4_inode_ref *child,
const char *name, size_t name_len);
@@ -223,7 +223,7 @@
* @param name_len Name length
* @return Error code
*/
-int ext4_dir_find_entry(struct ext4_directory_search_result *result,
+int ext4_dir_find_entry(struct ext4_dir_search_result *result,
struct ext4_inode_ref *parent, const char *name,
uint32_t name_len);
@@ -261,7 +261,7 @@
*/
int ext4_dir_find_in_block(struct ext4_block *block, struct ext4_sblock *sb,
size_t name_len, const char *name,
- struct ext4_directory_entry_ll **res_entry);
+ struct ext4_dir_entry_ll **res_entry);
/**@brief Simple function to release allocated data from result.
* @param parent Parent inode
@@ -270,13 +270,13 @@
*
*/
int ext4_dir_destroy_result(struct ext4_inode_ref *parent,
- struct ext4_directory_search_result *result);
+ struct ext4_dir_search_result *result);
void ext4_dir_set_checksum(struct ext4_inode_ref *inode_ref,
- struct ext4_directory_entry_ll *dirent);
+ struct ext4_dir_entry_ll *dirent);
/* checksumming functions */
-void initialize_dir_tail(struct ext4_directory_entry_tail *t);
+void initialize_dir_tail(struct ext4_dir_entry_tail *t);
#endif /* EXT4_DIR_H_ */
--- a/lwext4/ext4_dir_idx.c
+++ b/lwext4/ext4_dir_idx.c
@@ -52,7 +52,7 @@
* @return Hash algorithm version
*/
static inline uint8_t ext4_dir_dx_root_info_get_hash_version(
- struct ext4_directory_dx_root_info *root_info)
+ struct ext4_dir_idx_root_info *root_info)
{
return root_info->hash_version;
}
@@ -62,7 +62,7 @@
* @param v Hash algorithm version
*/
static inline void ext4_dir_dx_root_info_set_hash_version(
- struct ext4_directory_dx_root_info *root_info, uint8_t v)
+ struct ext4_dir_idx_root_info *root_info, uint8_t v)
{
root_info->hash_version = v;
}
@@ -72,7 +72,7 @@
* @return Length of the structure
*/
static inline uint8_t ext4_dir_dx_root_info_get_info_length(
- struct ext4_directory_dx_root_info *root_info)
+ struct ext4_dir_idx_root_info *root_info)
{
return root_info->info_length;
}
@@ -82,7 +82,7 @@
* @param info_length Length of the structure
*/
static inline void ext4_dir_dx_root_info_set_info_length(
- struct ext4_directory_dx_root_info *root_info, uint8_t len)
+ struct ext4_dir_idx_root_info *root_info, uint8_t len)
{
root_info->info_length = len;
}
@@ -92,7 +92,7 @@
* @return Height of HTree (actually only 0 or 1)
*/
static inline uint8_t ext4_dir_dx_root_info_get_indirect_levels(
- struct ext4_directory_dx_root_info *root_info)
+ struct ext4_dir_idx_root_info *root_info)
{
return root_info->indirect_levels;
}
@@ -102,7 +102,7 @@
* @param lvl Height of HTree (actually only 0 or 1)
*/
static inline void ext4_dir_dx_root_info_set_indirect_levels(
- struct ext4_directory_dx_root_info *root_info, uint8_t lvl)
+ struct ext4_dir_idx_root_info *root_info, uint8_t lvl)
{
root_info->indirect_levels = lvl;
}
@@ -112,7 +112,7 @@
* @return Maximum of entries in node
*/
static inline uint16_t
-ext4_dir_dx_countlimit_get_limit(struct ext4_directory_dx_countlimit *climit)
+ext4_dir_dx_countlimit_get_limit(struct ext4_dir_idx_countlimit *climit)
{
return to_le16(climit->limit);
}
@@ -122,7 +122,7 @@
* @param limit Maximum of entries in node
*/
static inline void
-ext4_dir_dx_countlimit_set_limit(struct ext4_directory_dx_countlimit *climit,
+ext4_dir_dx_countlimit_set_limit(struct ext4_dir_idx_countlimit *climit,
uint16_t limit)
{
climit->limit = to_le16(limit);
@@ -133,7 +133,7 @@
* @return Number of entries in node
*/
static inline uint16_t
-ext4_dir_dx_countlimit_get_count(struct ext4_directory_dx_countlimit *climit)
+ext4_dir_dx_countlimit_get_count(struct ext4_dir_idx_countlimit *climit)
{
return to_le16(climit->count);
}
@@ -143,7 +143,7 @@
* @param count Number of entries in node
*/
static inline void
-ext4_dir_dx_countlimit_set_count(struct ext4_directory_dx_countlimit *climit,
+ext4_dir_dx_countlimit_set_count(struct ext4_dir_idx_countlimit *climit,
uint16_t count)
{
climit->count = to_le16(count);
@@ -154,7 +154,7 @@
* @return Hash value
*/
static inline uint32_t
-ext4_dir_dx_entry_get_hash(struct ext4_directory_dx_entry *entry)
+ext4_dir_dx_entry_get_hash(struct ext4_dir_idx_entry *entry)
{
return to_le32(entry->hash);
}
@@ -164,7 +164,7 @@
* @param hash Hash value
*/
static inline void
-ext4_dir_dx_entry_set_hash(struct ext4_directory_dx_entry *entry, uint32_t hash)
+ext4_dir_dx_entry_set_hash(struct ext4_dir_idx_entry *entry, uint32_t hash)
{
entry->hash = to_le32(hash);
}
@@ -174,7 +174,7 @@
* @return Block address of child node
*/
static inline uint32_t
-ext4_dir_dx_entry_get_block(struct ext4_directory_dx_entry *entry)
+ext4_dir_dx_entry_get_block(struct ext4_dir_idx_entry *entry)
{
return to_le32(entry->block);
}
@@ -184,7 +184,7 @@
* @param block Block address of child node
*/
static inline void
-ext4_dir_dx_entry_set_block(struct ext4_directory_dx_entry *entry,
+ext4_dir_dx_entry_set_block(struct ext4_dir_idx_entry *entry,
uint32_t block)
{
entry->block = to_le32(block);
@@ -208,7 +208,7 @@
static uint32_t
ext4_dir_dx_checksum(struct ext4_inode_ref *inode_ref,
void *dirent,
- int count_offset, int count, struct ext4_directory_dx_tail *t)
+ int count_offset, int count, struct ext4_dir_idx_tail *t)
{
uint32_t orig_checksum, checksum = 0;
struct ext4_sblock *sb = &inode_ref->fs->sb;
@@ -221,7 +221,7 @@
to_le32(ext4_inode_get_generation(inode_ref->inode));
size = count_offset +
- (count * sizeof(struct ext4_directory_dx_tail));
+ (count * sizeof(struct ext4_dir_idx_tail));
orig_checksum = t->checksum;
t->checksum = 0;
/* First calculate crc32 checksum against fs uuid */
@@ -237,19 +237,19 @@
checksum = ext4_crc32c(checksum, dirent, size);
/* Finally calculate crc32 checksum for dx_tail */
checksum = ext4_crc32c(checksum, t,
- sizeof(struct ext4_directory_dx_tail));
+ sizeof(struct ext4_dir_idx_tail));
t->checksum = orig_checksum;
}
return checksum;
}
-static struct ext4_directory_dx_countlimit *
+static struct ext4_dir_idx_countlimit *
ext4_dir_dx_get_countlimit(struct ext4_inode_ref *inode_ref,
- struct ext4_directory_entry_ll *dirent,
+ struct ext4_dir_entry_ll *dirent,
int *offset)
{
- struct ext4_directory_entry_ll *dp;
- struct ext4_directory_dx_root *root;
+ struct ext4_dir_entry_ll *dp;
+ struct ext4_dir_idx_root *root;
struct ext4_sblock *sb = &inode_ref->fs->sb;
int count_offset;
@@ -257,13 +257,13 @@
ext4_sb_get_block_size(sb))
count_offset = 8;
else if (ext4_dir_entry_ll_get_entry_length(dirent) == 12) {
- root = (struct ext4_directory_dx_root *)dirent;
- dp = (struct ext4_directory_entry_ll *)&root->dots[1];
+ root = (struct ext4_dir_idx_root *)dirent;
+ dp = (struct ext4_dir_entry_ll *)&root->dots[1];
if (ext4_dir_entry_ll_get_entry_length(dp) !=
ext4_sb_get_block_size(sb) - 12)
return NULL;
if (root->info.reserved_zero ||
- root->info.info_length != sizeof(struct ext4_directory_dx_root_info))
+ root->info.info_length != sizeof(struct ext4_dir_idx_root_info))
return NULL;
count_offset = 32;
} else
@@ -271,7 +271,7 @@
if (offset)
*offset = count_offset;
- return (struct ext4_directory_dx_countlimit *)(((char *)dirent) + count_offset);
+ return (struct ext4_dir_idx_countlimit *)(((char *)dirent) + count_offset);
}
/*
@@ -280,29 +280,29 @@
*/
static bool
ext4_dir_dx_checksum_verify(struct ext4_inode_ref *inode_ref,
- struct ext4_directory_entry_ll *dirent)
+ struct ext4_dir_entry_ll *dirent)
{
struct ext4_sblock *sb = &inode_ref->fs->sb;
int count_offset, limit, count;
if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM)) {
- struct ext4_directory_dx_countlimit *countlimit =
+ struct ext4_dir_idx_countlimit *countlimit =
ext4_dir_dx_get_countlimit(inode_ref, dirent, &count_offset);
if (!countlimit) {
/* Directory seems corrupted. */
return true;
}
- struct ext4_directory_dx_tail *t;
+ struct ext4_dir_idx_tail *t;
limit = ext4_dir_dx_countlimit_get_limit(countlimit);
count = ext4_dir_dx_countlimit_get_count(countlimit);
- if (count_offset + (limit * sizeof(struct ext4_directory_dx_entry)) >
+ if (count_offset + (limit * sizeof(struct ext4_dir_idx_entry)) >
ext4_sb_get_block_size(sb) -
- sizeof(struct ext4_directory_dx_tail)) {
+ sizeof(struct ext4_dir_idx_tail)) {
/* There is no space to hold the checksum */
return true;
}
- t = (struct ext4_directory_dx_tail *)
- (((struct ext4_directory_dx_entry *)countlimit) + limit);
+ t = (struct ext4_dir_idx_tail *)
+ (((struct ext4_dir_idx_entry *)countlimit) + limit);
if (t->checksum != to_le32(ext4_dir_dx_checksum(inode_ref,
dirent,
@@ -316,29 +316,29 @@
static void
ext4_dir_set_dx_checksum(struct ext4_inode_ref *inode_ref,
- struct ext4_directory_entry_ll *dirent)
+ struct ext4_dir_entry_ll *dirent)
{
int count_offset, limit, count;
struct ext4_sblock *sb = &inode_ref->fs->sb;
if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM)) {
- struct ext4_directory_dx_countlimit *countlimit =
+ struct ext4_dir_idx_countlimit *countlimit =
ext4_dir_dx_get_countlimit(inode_ref, dirent, &count_offset);
if (!countlimit) {
/* Directory seems corrupted. */
return;
}
- struct ext4_directory_dx_tail *t;
+ struct ext4_dir_idx_tail *t;
limit = ext4_dir_dx_countlimit_get_limit(countlimit);
count = ext4_dir_dx_countlimit_get_count(countlimit);
- if (count_offset + (limit * sizeof(struct ext4_directory_dx_entry)) >
+ if (count_offset + (limit * sizeof(struct ext4_dir_idx_entry)) >
ext4_sb_get_block_size(sb) -
- sizeof(struct ext4_directory_dx_tail)) {
+ sizeof(struct ext4_dir_idx_tail)) {
/* There is no space to hold the checksum */
return;
}
- t = (struct ext4_directory_dx_tail *)
- (((struct ext4_directory_dx_entry *)countlimit) + limit);
+ t = (struct ext4_dir_idx_tail *)
+ (((struct ext4_dir_idx_entry *)countlimit) + limit);
t->checksum =
to_le32(ext4_dir_dx_checksum(inode_ref, dirent, count_offset, count, t));
@@ -367,12 +367,12 @@
return rc;
/* Initialize pointers to data structures */
- struct ext4_directory_dx_root *root = (void *)block.data;
- struct ext4_directory_dx_root_info *info = &(root->info);
+ struct ext4_dir_idx_root *root = (void *)block.data;
+ struct ext4_dir_idx_root_info *info = &(root->info);
/* Initialize dot entries */
ext4_dir_write_entry(&dir->fs->sb,
- (struct ext4_directory_entry_ll *)root->dots,
+ (struct ext4_dir_entry_ll *)root->dots,
12,
dir,
".",
@@ -379,7 +379,7 @@
strlen("."));
ext4_dir_write_entry(&dir->fs->sb,
- (struct ext4_directory_entry_ll *)(root->dots + 1),
+ (struct ext4_dir_entry_ll *)(root->dots + 1),
ext4_sb_get_block_size(sb) - 12,
parent,
"..",
@@ -393,20 +393,20 @@
ext4_dir_dx_root_info_set_info_length(info, 8);
/* Set limit and current number of entries */
- struct ext4_directory_dx_countlimit *countlimit =
- (struct ext4_directory_dx_countlimit *)&root->entries;
+ struct ext4_dir_idx_countlimit *countlimit =
+ (struct ext4_dir_idx_countlimit *)&root->entries;
ext4_dir_dx_countlimit_set_count(countlimit, 1);
uint32_t block_size = ext4_sb_get_block_size(&dir->fs->sb);
uint32_t entry_space = block_size -
- 2 * sizeof(struct ext4_directory_dx_dot_entry) -
- sizeof(struct ext4_directory_dx_root_info);
+ 2 * sizeof(struct ext4_dir_idx_dot_entry) -
+ sizeof(struct ext4_dir_idx_root_info);
if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
- entry_space -= sizeof(struct ext4_directory_dx_tail);
+ entry_space -= sizeof(struct ext4_dir_idx_tail);
uint16_t root_limit =
- entry_space / sizeof(struct ext4_directory_dx_entry);
+ entry_space / sizeof(struct ext4_dir_idx_entry);
ext4_dir_dx_countlimit_set_limit(countlimit, root_limit);
@@ -426,12 +426,12 @@
}
/* Fill the whole block with empty entry */
- struct ext4_directory_entry_ll *block_entry = (void *)new_block.data;
+ struct ext4_dir_entry_ll *block_entry = (void *)new_block.data;
if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM)) {
ext4_dir_entry_ll_set_entry_length(block_entry,
block_size -
- sizeof(struct ext4_directory_entry_tail));
+ sizeof(struct ext4_dir_entry_tail));
ext4_dir_entry_ll_set_name_length(sb,
block_entry,
0);
@@ -442,7 +442,7 @@
initialize_dir_tail(EXT4_DIRENT_TAIL(block_entry,
ext4_sb_get_block_size(sb)));
ext4_dir_set_checksum(dir,
- (struct ext4_directory_entry_ll *)new_block.data);
+ (struct ext4_dir_entry_ll *)new_block.data);
} else {
ext4_dir_entry_ll_set_entry_length(block_entry, block_size);
}
@@ -457,11 +457,11 @@
}
/* Connect new block to the only entry in index */
- struct ext4_directory_dx_entry *entry = root->entries;
+ struct ext4_dir_idx_entry *entry = root->entries;
ext4_dir_dx_entry_set_block(entry, iblock);
ext4_dir_set_dx_checksum(dir,
- (struct ext4_directory_entry_ll *)block.data);
+ (struct ext4_dir_entry_ll *)block.data);
block.dirty = true;
return ext4_block_set(dir->fs->bdev, &block);
@@ -480,8 +480,8 @@
struct ext4_sblock *sb, size_t name_len,
const char *name)
{
- struct ext4_directory_dx_root *root =
- (struct ext4_directory_dx_root *)root_block->data;
+ struct ext4_dir_idx_root *root =
+ (struct ext4_dir_idx_root *)root_block->data;
if ((root->info.hash_version != EXT2_HTREE_LEGACY) &&
(root->info.hash_version != EXT2_HTREE_HALF_MD4) &&
@@ -499,14 +499,14 @@
/* Check if node limit is correct */
uint32_t block_size = ext4_sb_get_block_size(sb);
uint32_t entry_space = block_size;
- entry_space -= 2 * sizeof(struct ext4_directory_dx_dot_entry);
- entry_space -= sizeof(struct ext4_directory_dx_root_info);
+ entry_space -= 2 * sizeof(struct ext4_dir_idx_dot_entry);
+ entry_space -= sizeof(struct ext4_dir_idx_root_info);
if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
- entry_space -= sizeof(struct ext4_directory_dx_tail);
- entry_space = entry_space / sizeof(struct ext4_directory_dx_entry);
+ entry_space -= sizeof(struct ext4_dir_idx_tail);
+ entry_space = entry_space / sizeof(struct ext4_dir_idx_entry);
uint16_t limit = ext4_dir_dx_countlimit_get_limit(
- (struct ext4_directory_dx_countlimit *)&root->entries);
+ (struct ext4_dir_idx_countlimit *)&root->entries);
if (limit != entry_space)
return EXT4_ERR_BAD_DX_DIR;
@@ -541,30 +541,30 @@
static int ext4_dir_dx_get_leaf(struct ext4_hash_info *hinfo,
struct ext4_inode_ref *inode_ref,
struct ext4_block *root_block,
- struct ext4_directory_dx_block **dx_block,
- struct ext4_directory_dx_block *dx_blocks)
+ struct ext4_dir_idx_block **dx_block,
+ struct ext4_dir_idx_block *dx_blocks)
{
- struct ext4_directory_dx_block *tmp_dx_block = dx_blocks;
- struct ext4_directory_dx_root *root =
- (struct ext4_directory_dx_root *)root_block->data;
- struct ext4_directory_dx_entry *entries =
- (struct ext4_directory_dx_entry *)&root->entries;
+ struct ext4_dir_idx_block *tmp_dx_block = dx_blocks;
+ struct ext4_dir_idx_root *root =
+ (struct ext4_dir_idx_root *)root_block->data;
+ struct ext4_dir_idx_entry *entries =
+ (struct ext4_dir_idx_entry *)&root->entries;
uint16_t limit = ext4_dir_dx_countlimit_get_limit(
- (struct ext4_directory_dx_countlimit *)entries);
+ (struct ext4_dir_idx_countlimit *)entries);
uint8_t indirect_level =
ext4_dir_dx_root_info_get_indirect_levels(&root->info);
struct ext4_block *tmp_block = root_block;
- struct ext4_directory_dx_entry *p;
- struct ext4_directory_dx_entry *q;
- struct ext4_directory_dx_entry *m;
- struct ext4_directory_dx_entry *at;
+ struct ext4_dir_idx_entry *p;
+ struct ext4_dir_idx_entry *q;
+ struct ext4_dir_idx_entry *m;
+ struct ext4_dir_idx_entry *at;
/* Walk through the index tree */
while (true) {
uint16_t count = ext4_dir_dx_countlimit_get_count(
- (struct ext4_directory_dx_countlimit *)entries);
+ (struct ext4_dir_idx_countlimit *)entries);
if ((count == 0) || (count > limit))
return EXT4_ERR_BAD_DX_DIR;
@@ -611,20 +611,20 @@
return rc;
entries =
- ((struct ext4_directory_dx_node *)tmp_block->data)->entries;
+ ((struct ext4_dir_idx_node *)tmp_block->data)->entries;
limit = ext4_dir_dx_countlimit_get_limit(
- (struct ext4_directory_dx_countlimit *)entries);
+ (struct ext4_dir_idx_countlimit *)entries);
uint16_t entry_space =
ext4_sb_get_block_size(&inode_ref->fs->sb) -
- sizeof(struct ext4_fake_directory_entry);
+ sizeof(struct ext4_fake_dir_entry);
if (ext4_sb_feature_ro_com(&inode_ref->fs->sb,
EXT4_FRO_COM_METADATA_CSUM))
- entry_space -= sizeof(struct ext4_directory_dx_tail);
+ entry_space -= sizeof(struct ext4_dir_idx_tail);
entry_space =
- entry_space / sizeof(struct ext4_directory_dx_entry);
+ entry_space / sizeof(struct ext4_dir_idx_entry);
if (limit != entry_space) {
ext4_block_set(inode_ref->fs->bdev, tmp_block);
@@ -632,7 +632,7 @@
}
if (!ext4_dir_dx_checksum_verify(inode_ref,
- (struct ext4_directory_entry_ll *)tmp_block->data)) {
+ (struct ext4_dir_entry_ll *)tmp_block->data)) {
ext4_dbg(DEBUG_DIR_IDX,
DBG_WARN "HTree checksum failed."
"Inode: %" PRIu32", "
@@ -657,17 +657,17 @@
*/
static int ext4_dir_dx_next_block(struct ext4_inode_ref *inode_ref,
uint32_t hash,
- struct ext4_directory_dx_block *dx_block,
- struct ext4_directory_dx_block *dx_blocks)
+ struct ext4_dir_idx_block *dx_block,
+ struct ext4_dir_idx_block *dx_blocks)
{
uint32_t num_handles = 0;
- struct ext4_directory_dx_block *p = dx_block;
+ struct ext4_dir_idx_block *p = dx_block;
/* Try to find data block with next bunch of entries */
while (true) {
p->position++;
uint16_t count = ext4_dir_dx_countlimit_get_count(
- (struct ext4_directory_dx_countlimit *)p->entries);
+ (struct ext4_dir_idx_countlimit *)p->entries);
if (p->position < p->entries + count)
break;
@@ -703,7 +703,7 @@
return rc;
if (!ext4_dir_dx_checksum_verify(inode_ref,
- (struct ext4_directory_entry_ll *)block.data)) {
+ (struct ext4_dir_entry_ll *)block.data)) {
ext4_dbg(DEBUG_DIR_IDX,
DBG_WARN "HTree checksum failed."
"Inode: %" PRIu32", "
@@ -721,7 +721,7 @@
memcpy(&p->block, &block, sizeof(block));
p->entries =
- ((struct ext4_directory_dx_node *)block.data)->entries;
+ ((struct ext4_dir_idx_node *)block.data)->entries;
p->position = p->entries;
}
@@ -728,7 +728,7 @@
return ENOENT;
}
-int ext4_dir_dx_find_entry(struct ext4_directory_search_result *result,
+int ext4_dir_dx_find_entry(struct ext4_dir_search_result *result,
struct ext4_inode_ref *inode_ref, size_t name_len,
const char *name)
{
@@ -749,7 +749,7 @@
return rc;
if (!ext4_dir_dx_checksum_verify(inode_ref,
- (struct ext4_directory_entry_ll *)root_block.data)) {
+ (struct ext4_dir_entry_ll *)root_block.data)) {
ext4_dbg(DEBUG_DIR_IDX,
DBG_WARN "HTree root checksum failed."
"Inode: %" PRIu32", "
@@ -770,9 +770,9 @@
* Hardcoded number 2 means maximum height of index tree,
* specified in the Linux driver.
*/
- struct ext4_directory_dx_block dx_blocks[2];
- struct ext4_directory_dx_block *dx_block;
- struct ext4_directory_dx_block *tmp;
+ struct ext4_dir_idx_block dx_blocks[2];
+ struct ext4_dir_idx_block *dx_block;
+ struct ext4_dir_idx_block *tmp;
rc = ext4_dir_dx_get_leaf(&hinfo, inode_ref, &root_block, &dx_block,
dx_blocks);
@@ -799,7 +799,7 @@
goto cleanup;
if (!ext4_dir_checksum_verify(inode_ref,
- (struct ext4_directory_entry_ll *)leaf_block.data)) {
+ (struct ext4_dir_entry_ll *)leaf_block.data)) {
ext4_dbg(DEBUG_DIR_IDX,
DBG_WARN "HTree leaf block checksum failed."
"Inode: %" PRIu32", "
@@ -809,7 +809,7 @@
}
/* Linear search inside block */
- struct ext4_directory_entry_ll *res_dentry;
+ struct ext4_dir_entry_ll *res_dentry;
rc = ext4_dir_find_in_block(&leaf_block, &fs->sb, name_len,
name, &res_dentry);
@@ -922,17 +922,17 @@
*/
static void
ext4_dir_dx_insert_entry(struct ext4_inode_ref *inode_ref __unused,
- struct ext4_directory_dx_block *index_block,
+ struct ext4_dir_idx_block *index_block,
uint32_t hash, uint32_t iblock)
{
- struct ext4_directory_dx_entry *old_index_entry = index_block->position;
- struct ext4_directory_dx_entry *new_index_entry = old_index_entry + 1;
+ struct ext4_dir_idx_entry *old_index_entry = index_block->position;
+ struct ext4_dir_idx_entry *new_index_entry = old_index_entry + 1;
- struct ext4_directory_dx_countlimit *countlimit =
- (struct ext4_directory_dx_countlimit *)index_block->entries;
+ struct ext4_dir_idx_countlimit *countlimit =
+ (struct ext4_dir_idx_countlimit *)index_block->entries;
uint32_t count = ext4_dir_dx_countlimit_get_count(countlimit);
- struct ext4_directory_dx_entry *start_index = index_block->entries;
+ struct ext4_dir_idx_entry *start_index = index_block->entries;
size_t bytes =
(uint8_t *)(start_index + count) - (uint8_t *)(new_index_entry);
@@ -944,7 +944,7 @@
ext4_dir_dx_countlimit_set_count(countlimit, count + 1);
ext4_dir_set_dx_checksum(inode_ref,
- (struct ext4_directory_entry_ll *)index_block->block.data);
+ (struct ext4_dir_entry_ll *)index_block->block.data);
index_block->block.dirty = true;
}
@@ -958,7 +958,7 @@
static int ext4_dir_dx_split_data(struct ext4_inode_ref *inode_ref,
struct ext4_hash_info *hinfo,
struct ext4_block *old_data_block,
- struct ext4_directory_dx_block *index_block,
+ struct ext4_dir_idx_block *index_block,
struct ext4_block *new_data_block)
{
int rc = EOK;
@@ -972,7 +972,7 @@
/* dot entry has the smallest size available */
uint32_t max_entry_count =
- block_size / sizeof(struct ext4_directory_dx_dot_entry);
+ block_size / sizeof(struct ext4_dir_idx_dot_entry);
/* Allocate sort entry */
struct ext4_dx_sort_entry *sort_array =
@@ -991,7 +991,7 @@
memcpy(&tmp_hinfo, hinfo, sizeof(struct ext4_hash_info));
/* Load all valid entries to the buffer */
- struct ext4_directory_entry_ll *dentry = (void *)old_data_block->data;
+ struct ext4_dir_entry_ll *dentry = (void *)old_data_block->data;
uint8_t *entry_buffer_ptr = entry_buffer;
while ((void *)dentry < (void *)(old_data_block->data + block_size)) {
/* Read only valid entries */
@@ -1082,7 +1082,7 @@
void *ptr;
struct ext4_sblock *sb = &inode_ref->fs->sb;
if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
- block_size -= sizeof(struct ext4_directory_entry_tail);
+ block_size -= sizeof(struct ext4_dir_entry_tail);
/* First part - to the old block */
for (i = 0; i < mid; ++i) {
@@ -1089,7 +1089,7 @@
ptr = old_data_block->data + offset;
memcpy(ptr, sort_array[i].dentry, sort_array[i].rec_len);
- struct ext4_directory_entry_ll *tmp = ptr;
+ struct ext4_dir_entry_ll *tmp = ptr;
if (i < (mid - 1))
ext4_dir_entry_ll_set_entry_length(
tmp, sort_array[i].rec_len);
@@ -1106,7 +1106,7 @@
ptr = new_data_block_tmp.data + offset;
memcpy(ptr, sort_array[i].dentry, sort_array[i].rec_len);
- struct ext4_directory_entry_ll *tmp = ptr;
+ struct ext4_dir_entry_ll *tmp = ptr;
if (i < (idx - 1))
ext4_dir_entry_ll_set_entry_length(
tmp, sort_array[i].rec_len);
@@ -1128,9 +1128,9 @@
block_size));
}
ext4_dir_set_checksum(inode_ref,
- (struct ext4_directory_entry_ll *)old_data_block->data);
+ (struct ext4_dir_entry_ll *)old_data_block->data);
ext4_dir_set_checksum(inode_ref,
- (struct ext4_directory_entry_ll *)new_data_block_tmp.data);
+ (struct ext4_dir_entry_ll *)new_data_block_tmp.data);
old_data_block->dirty = true;
new_data_block_tmp.dirty = true;
@@ -1154,24 +1154,24 @@
*/
static int
ext4_dir_dx_split_index(struct ext4_inode_ref *inode_ref,
- struct ext4_directory_dx_block *dx_blocks,
- struct ext4_directory_dx_block *dx_block,
- struct ext4_directory_dx_block **new_dx_block)
+ struct ext4_dir_idx_block *dx_blocks,
+ struct ext4_dir_idx_block *dx_block,
+ struct ext4_dir_idx_block **new_dx_block)
{
struct ext4_sblock *sb = &inode_ref->fs->sb;
- struct ext4_directory_dx_entry *entries;
+ struct ext4_dir_idx_entry *entries;
if (dx_block == dx_blocks)
entries =
- ((struct ext4_directory_dx_root *)dx_block->block.data)
+ ((struct ext4_dir_idx_root *)dx_block->block.data)
->entries;
else
entries =
- ((struct ext4_directory_dx_node *)dx_block->block.data)
+ ((struct ext4_dir_idx_node *)dx_block->block.data)
->entries;
- struct ext4_directory_dx_countlimit *countlimit =
- (struct ext4_directory_dx_countlimit *)entries;
+ struct ext4_dir_idx_countlimit *countlimit =
+ (struct ext4_dir_idx_countlimit *)entries;
uint16_t leaf_limit = ext4_dir_dx_countlimit_get_limit(countlimit);
uint16_t leaf_count = ext4_dir_dx_countlimit_get_count(countlimit);
@@ -1180,12 +1180,12 @@
if (leaf_limit == leaf_count) {
size_t levels = dx_block - dx_blocks;
- struct ext4_directory_dx_entry *root_entries =
- ((struct ext4_directory_dx_root *)dx_blocks[0].block.data)
+ struct ext4_dir_idx_entry *root_entries =
+ ((struct ext4_dir_idx_root *)dx_blocks[0].block.data)
->entries;
- struct ext4_directory_dx_countlimit *root_countlimit =
- (struct ext4_directory_dx_countlimit *)root_entries;
+ struct ext4_dir_idx_countlimit *root_countlimit =
+ (struct ext4_dir_idx_countlimit *)root_entries;
uint16_t root_limit =
ext4_dir_dx_countlimit_get_limit(root_countlimit);
uint16_t root_count =
@@ -1210,12 +1210,12 @@
if (rc != EOK)
return rc;
- struct ext4_directory_dx_node *new_node =
+ struct ext4_dir_idx_node *new_node =
(void *)new_block.data;
- struct ext4_directory_dx_entry *new_entries = new_node->entries;
+ struct ext4_dir_idx_entry *new_entries = new_node->entries;
memset(&new_node->fake, 0,
- sizeof(struct ext4_fake_directory_entry));
+ sizeof(struct ext4_fake_dir_entry));
uint32_t block_size =
ext4_sb_get_block_size(&inode_ref->fs->sb);
@@ -1233,13 +1233,13 @@
memcpy((void *)new_entries,
(void *)(entries + count_left),
count_right *
- sizeof(struct ext4_directory_dx_entry));
+ sizeof(struct ext4_dir_idx_entry));
/* Initialize new node */
- struct ext4_directory_dx_countlimit *left_countlimit =
- (struct ext4_directory_dx_countlimit *)entries;
- struct ext4_directory_dx_countlimit *right_countlimit =
- (struct ext4_directory_dx_countlimit *)new_entries;
+ struct ext4_dir_idx_countlimit *left_countlimit =
+ (struct ext4_dir_idx_countlimit *)entries;
+ struct ext4_dir_idx_countlimit *right_countlimit =
+ (struct ext4_dir_idx_countlimit *)new_entries;
ext4_dir_dx_countlimit_set_count(left_countlimit,
count_left);
@@ -1248,12 +1248,12 @@
uint32_t entry_space =
block_size -
- sizeof(struct ext4_fake_directory_entry);
+ sizeof(struct ext4_fake_dir_entry);
if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
- entry_space -= sizeof(struct ext4_directory_dx_tail);
+ entry_space -= sizeof(struct ext4_dir_idx_tail);
uint32_t node_limit =
- entry_space / sizeof(struct ext4_directory_dx_entry);
+ entry_space / sizeof(struct ext4_dir_idx_entry);
ext4_dir_dx_countlimit_set_limit(right_countlimit,
node_limit);
@@ -1264,7 +1264,7 @@
if (position_index >= count_left) {
ext4_dir_set_dx_checksum(
inode_ref,
- (struct ext4_directory_entry_ll *)
+ (struct ext4_dir_entry_ll *)
dx_block->block.data);
dx_block->block.dirty = true;
@@ -1284,16 +1284,16 @@
dx_blocks, hash_right,
new_iblock);
ext4_dir_set_dx_checksum(inode_ref,
- (struct ext4_directory_entry_ll *)
+ (struct ext4_dir_entry_ll *)
dx_blocks[0].block.data);
ext4_dir_set_dx_checksum(inode_ref,
- (struct ext4_directory_entry_ll *)
+ (struct ext4_dir_entry_ll *)
dx_blocks[1].block.data);
dx_blocks[0].block.dirty = true;
dx_blocks[1].block.dirty = true;
ext4_dir_set_dx_checksum(inode_ref,
- (struct ext4_directory_entry_ll *)
+ (struct ext4_dir_entry_ll *)
new_block.data);
new_block.dirty = true;
return ext4_block_set(inode_ref->fs->bdev, &new_block);
@@ -1303,32 +1303,32 @@
/* Copy data from root to child block */
memcpy((void *)new_entries, (void *)entries,
leaf_count *
- sizeof(struct ext4_directory_dx_entry));
+ sizeof(struct ext4_dir_idx_entry));
- struct ext4_directory_dx_countlimit *new_countlimit =
- (struct ext4_directory_dx_countlimit *)new_entries;
+ struct ext4_dir_idx_countlimit *new_countlimit =
+ (struct ext4_dir_idx_countlimit *)new_entries;
uint32_t entry_space =
block_size -
- sizeof(struct ext4_fake_directory_entry);
+ sizeof(struct ext4_fake_dir_entry);
if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
- entry_space -= sizeof(struct ext4_directory_dx_tail);
+ entry_space -= sizeof(struct ext4_dir_idx_tail);
uint32_t node_limit =
- entry_space / sizeof(struct ext4_directory_dx_entry);
+ entry_space / sizeof(struct ext4_dir_idx_entry);
ext4_dir_dx_countlimit_set_limit(new_countlimit,
node_limit);
/* Set values in root node */
- struct ext4_directory_dx_countlimit
+ struct ext4_dir_idx_countlimit
*new_root_countlimit =
- (struct ext4_directory_dx_countlimit *)entries;
+ (struct ext4_dir_idx_countlimit *)entries;
ext4_dir_dx_countlimit_set_count(new_root_countlimit,
1);
ext4_dir_dx_entry_set_block(entries, new_iblock);
- ((struct ext4_directory_dx_root *)dx_blocks[0]
+ ((struct ext4_dir_idx_root *)dx_blocks[0]
.block.data)
->info.indirect_levels = 1;
@@ -1342,10 +1342,10 @@
*new_dx_block = dx_block;
ext4_dir_set_dx_checksum(inode_ref,
- (struct ext4_directory_entry_ll *)
+ (struct ext4_dir_entry_ll *)
dx_blocks[0].block.data);
ext4_dir_set_dx_checksum(inode_ref,
- (struct ext4_directory_entry_ll *)
+ (struct ext4_dir_entry_ll *)
dx_blocks[1].block.data);
dx_blocks[0].block.dirty = true;
dx_blocks[1].block.dirty = true;
@@ -1377,7 +1377,7 @@
return rc;
if (!ext4_dir_dx_checksum_verify(parent,
- (struct ext4_directory_entry_ll *)root_block.data)) {
+ (struct ext4_dir_entry_ll *)root_block.data)) {
ext4_dbg(DEBUG_DIR_IDX,
DBG_WARN "HTree root checksum failed."
"Inode: %" PRIu32", "
@@ -1399,9 +1399,9 @@
* Hardcoded number 2 means maximum height of index
* tree defined in Linux.
*/
- struct ext4_directory_dx_block dx_blocks[2];
- struct ext4_directory_dx_block *dx_block;
- struct ext4_directory_dx_block *dx_it;
+ struct ext4_dir_idx_block dx_blocks[2];
+ struct ext4_dir_idx_block *dx_block;
+ struct ext4_dir_idx_block *dx_it;
rc = ext4_dir_dx_get_leaf(&hinfo, parent, &root_block, &dx_block,
dx_blocks);
@@ -1434,7 +1434,7 @@
goto release_index;
if (!ext4_dir_checksum_verify(parent,
- (struct ext4_directory_entry_ll *)target_block.data)) {
+ (struct ext4_dir_entry_ll *)target_block.data)) {
ext4_dbg(DEBUG_DIR_IDX,
DBG_WARN "HTree leaf block checksum failed."
"Inode: %" PRIu32", "
@@ -1514,7 +1514,7 @@
return rc;
if (!ext4_dir_dx_checksum_verify(dir,
- (struct ext4_directory_entry_ll *)block.data)) {
+ (struct ext4_dir_entry_ll *)block.data)) {
ext4_dbg(DEBUG_DIR_IDX,
DBG_WARN "HTree root checksum failed."
"Inode: %" PRIu32", "
@@ -1524,13 +1524,13 @@
}
/* Initialize pointers to data structures */
- struct ext4_directory_dx_root *root = (void *)block.data;
+ struct ext4_dir_idx_root *root = (void *)block.data;
/* Fill the inode field with a new parent ino. */
ext4_dx_dot_entry_set_inode(&root->dots[1], parent_inode);
ext4_dir_set_dx_checksum(dir,
- (struct ext4_directory_entry_ll *)
+ (struct ext4_dir_entry_ll *)
block.data);
block.dirty = true;
--- a/lwext4/ext4_dir_idx.h
+++ b/lwext4/ext4_dir_idx.h
@@ -64,7 +64,7 @@
* @param name Name to be found
* @return Error code
*/
-int ext4_dir_dx_find_entry(struct ext4_directory_search_result *result,
+int ext4_dir_dx_find_entry(struct ext4_dir_search_result *result,
struct ext4_inode_ref *inode_ref, size_t name_len,
const char *name);
--- a/lwext4/ext4_types.h
+++ b/lwext4/ext4_types.h
@@ -483,7 +483,7 @@
#define EXT4_DIRENTRY_DIR_CSUM 0xDE
-union ext4_directory_entry_ll_internal {
+union ext4_dir_entry_ll_internal {
uint8_t name_length_high; /* Higher 8 bits of name length */
uint8_t inode_type; /* Type of referenced inode (in rev >= 0.5) */
} __attribute__((packed));
@@ -491,36 +491,36 @@
/**
* Linked list directory entry structure
*/
-struct ext4_directory_entry_ll {
+struct ext4_dir_entry_ll {
uint32_t inode; /* I-node for the entry */
uint16_t entry_length; /* Distance to the next directory entry */
uint8_t name_length; /* Lower 8 bits of name length */
- union ext4_directory_entry_ll_internal in;
+ union ext4_dir_entry_ll_internal in;
uint8_t name[EXT4_DIRECTORY_FILENAME_LEN]; /* Entry name */
} __attribute__((packed));
-struct ext4_directory_iterator {
+struct ext4_dir_iterator {
struct ext4_inode_ref *inode_ref;
struct ext4_block current_block;
uint64_t current_offset;
- struct ext4_directory_entry_ll *current;
+ struct ext4_dir_entry_ll *current;
};
-struct ext4_directory_search_result {
+struct ext4_dir_search_result {
struct ext4_block block;
- struct ext4_directory_entry_ll *dentry;
+ struct ext4_dir_entry_ll *dentry;
};
/* Structures for indexed directory */
-struct ext4_directory_dx_countlimit {
+struct ext4_dir_idx_countlimit {
uint16_t limit;
uint16_t count;
};
-struct ext4_directory_dx_dot_entry {
+struct ext4_dir_idx_dot_entry {
uint32_t inode;
uint16_t entry_length;
uint8_t name_length;
@@ -528,7 +528,7 @@
uint8_t name[4];
};
-struct ext4_directory_dx_root_info {
+struct ext4_dir_idx_root_info {
uint32_t reserved_zero;
uint8_t hash_version;
uint8_t info_length;
@@ -536,18 +536,18 @@
uint8_t unused_flags;
};
-struct ext4_directory_dx_entry {
+struct ext4_dir_idx_entry {
uint32_t hash;
uint32_t block;
};
-struct ext4_directory_dx_root {
- struct ext4_directory_dx_dot_entry dots[2];
- struct ext4_directory_dx_root_info info;
- struct ext4_directory_dx_entry entries[];
+struct ext4_dir_idx_root {
+ struct ext4_dir_idx_dot_entry dots[2];
+ struct ext4_dir_idx_root_info info;
+ struct ext4_dir_idx_entry entries[];
};
-struct ext4_fake_directory_entry {
+struct ext4_fake_dir_entry {
uint32_t inode;
uint16_t entry_length;
uint8_t name_length;
@@ -554,21 +554,21 @@
uint8_t inode_type;
};
-struct ext4_directory_dx_node {
- struct ext4_fake_directory_entry fake;
- struct ext4_directory_dx_entry entries[];
+struct ext4_dir_idx_node {
+ struct ext4_fake_dir_entry fake;
+ struct ext4_dir_idx_entry entries[];
};
-struct ext4_directory_dx_block {
+struct ext4_dir_idx_block {
struct ext4_block block;
- struct ext4_directory_dx_entry *entries;
- struct ext4_directory_dx_entry *position;
+ struct ext4_dir_idx_entry *entries;
+ struct ext4_dir_idx_entry *position;
};
/*
* This goes at the end of each htree block.
*/
-struct ext4_directory_dx_tail {
+struct ext4_dir_idx_tail {
uint32_t reserved;
uint32_t checksum; /* crc32c(uuid+inum+dirblock) */
};
@@ -577,7 +577,7 @@
* This is a bogus directory entry at the end of each leaf block that
* records checksums.
*/
-struct ext4_directory_entry_tail {
+struct ext4_dir_entry_tail {
uint32_t reserved_zero1; /* Pretend to be unused */
uint16_t rec_len; /* 12 */
uint8_t reserved_zero2; /* Zero name length */
@@ -586,9 +586,8 @@
};
#define EXT4_DIRENT_TAIL(block, blocksize) \
- ((struct ext4_directory_entry_tail *)(((char *)(block)) + \
- ((blocksize) - \
- sizeof(struct ext4_directory_entry_tail))))
+ ((struct ext4_dir_entry_tail *)(((char *)(block)) + ((blocksize) - \
+ sizeof(struct ext4_dir_entry_tail))))
#define EXT4_ERR_BAD_DX_DIR (-25000)