ref: 6a8d105e116c0a1311bd3e60d947b2d8c9fcebcf
parent: ff9c19c3d8d2774746827b65242e3fe78943e613
author: gkostka <kostka.grzegorz@gmail.com>
date: Tue Oct 28 20:53:04 EDT 2014
Move same simple functions to header
--- a/lwext4/ext4_dir_idx.c
+++ b/lwext4/ext4_dir_idx.c
@@ -61,89 +61,7 @@
}
-uint8_t ext4_dir_dx_root_info_get_hash_version(
- struct ext4_directory_dx_root_info *root_info)
-{
- return root_info->hash_version;
-}
-
-void ext4_dir_dx_root_info_set_hash_version(
- struct ext4_directory_dx_root_info *root_info, uint8_t v)
-{
- root_info->hash_version = v;
-}
-
-uint8_t ext4_dir_dx_root_info_get_info_length(
- struct ext4_directory_dx_root_info *root_info)
-{
- return root_info->info_length;
-}
-void ext4_dir_dx_root_info_set_info_length(
- struct ext4_directory_dx_root_info *root_info, uint8_t len)
-{
- root_info->info_length = len;
-}
-
-uint8_t ext4_dir_dx_root_info_get_indirect_levels(
- struct ext4_directory_dx_root_info *root_info)
-{
- return root_info->indirect_levels;
-}
-
-void ext4_dir_dx_root_info_set_indirect_levels(
- struct ext4_directory_dx_root_info *root_info, uint8_t lvl)
-{
- root_info->indirect_levels = lvl;
-}
-
-
-
-uint16_t ext4_dir_dx_countlimit_get_limit(
- struct ext4_directory_dx_countlimit *climit)
-{
- return to_le16(climit->limit);
-}
-void ext4_dir_dx_countlimit_set_limit(
- struct ext4_directory_dx_countlimit *climit, uint16_t limit)
-{
- climit->limit = to_le16(limit);
-}
-
-uint16_t ext4_dir_dx_countlimit_get_count(
- struct ext4_directory_dx_countlimit *climit)
-{
- return to_le16(climit->count);
-}
-
-void ext4_dir_dx_countlimit_set_count(
- struct ext4_directory_dx_countlimit *climit, uint16_t count)
-{
- climit->count = to_le16(count);
-}
-
-
-uint32_t ext4_dir_dx_entry_get_hash(
- struct ext4_directory_dx_entry *entry)
-{
- return to_le32(entry->hash);
-}
-void ext4_dir_dx_entry_set_hash(
- struct ext4_directory_dx_entry *entry, uint32_t hash)
-{
- entry->hash = to_le32(hash);
-}
-
-uint32_t ext4_dir_dx_entry_get_block(
- struct ext4_directory_dx_entry *entry)
-{
- return to_le32(entry->block);
-}
-void ext4_dir_dx_entry_set_block(
- struct ext4_directory_dx_entry *entry, uint32_t block)
-{
- entry->block = to_le32(block);
-}
/****************************************************************************/
int ext4_dir_dx_init(struct ext4_inode_ref *dir)
--- a/lwext4/ext4_dir_idx.h
+++ b/lwext4/ext4_dir_idx.h
@@ -48,103 +48,147 @@
#include <stdint.h>
#include <stdbool.h>
+
/**@brief Get hash version used in directory index.
* @param root_info Pointer to root info structure of index
* @return Hash algorithm version
*/
-uint8_t ext4_dir_dx_root_info_get_hash_version(
- struct ext4_directory_dx_root_info *root_info);
+static inline uint8_t ext4_dir_dx_root_info_get_hash_version(
+ struct ext4_directory_dx_root_info *root_info)
+{
+ return root_info->hash_version;
+}
/**@brief Set hash version, that will be used in directory index.
* @param root_info Pointer to root info structure of index
* @param v Hash algorithm version
*/
-void ext4_dir_dx_root_info_set_hash_version(
- struct ext4_directory_dx_root_info *root_info, uint8_t v);
+static inline void ext4_dir_dx_root_info_set_hash_version(
+ struct ext4_directory_dx_root_info *root_info, uint8_t v)
+{
+ root_info->hash_version = v;
+}
/**@brief Get length of root_info structure in bytes.
* @param root_info Pointer to root info structure of index
* @return Length of the structure
*/
-uint8_t ext4_dir_dx_root_info_get_info_length(
- struct ext4_directory_dx_root_info *root_info);
+static inline uint8_t ext4_dir_dx_root_info_get_info_length(
+ struct ext4_directory_dx_root_info *root_info)
+{
+ return root_info->info_length;
+}
/**@brief Set length of root_info structure in bytes.
* @param root_info Pointer to root info structure of index
* @param info_length Length of the structure
*/
-void ext4_dir_dx_root_info_set_info_length(
- struct ext4_directory_dx_root_info *root_info, uint8_t len);
+static inline void ext4_dir_dx_root_info_set_info_length(
+ struct ext4_directory_dx_root_info *root_info, uint8_t len)
+{
+ root_info->info_length = len;
+}
/**@brief Get number of indirect levels of HTree.
* @param root_info Pointer to root info structure of index
* @return Height of HTree (actually only 0 or 1)
*/
-uint8_t ext4_dir_dx_root_info_get_indirect_levels(
- struct ext4_directory_dx_root_info *root_info);
+static inline uint8_t ext4_dir_dx_root_info_get_indirect_levels(
+ struct ext4_directory_dx_root_info *root_info)
+{
+ return root_info->indirect_levels;
+}
/**@brief Set number of indirect levels of HTree.
* @param root_info Pointer to root info structure of index
* @param lvl Height of HTree (actually only 0 or 1)
*/
-void ext4_dir_dx_root_info_set_indirect_levels(
- struct ext4_directory_dx_root_info *root_info, uint8_t lvl);
+static inline void ext4_dir_dx_root_info_set_indirect_levels(
+ struct ext4_directory_dx_root_info *root_info, uint8_t lvl)
+{
+ root_info->indirect_levels = lvl;
+}
/**@brief Get maximum number of index node entries.
* @param climit Pointer to counlimit structure
* @return Maximum of entries in node
*/
-uint16_t ext4_dir_dx_countlimit_get_limit(
- struct ext4_directory_dx_countlimit *climit);
+static inline uint16_t ext4_dir_dx_countlimit_get_limit(
+ struct ext4_directory_dx_countlimit *climit)
+{
+ return to_le16(climit->limit);
+}
/**@brief Set maximum number of index node entries.
* @param climit Pointer to counlimit structure
* @param limit Maximum of entries in node
*/
-void ext4_dir_dx_countlimit_set_limit(
- struct ext4_directory_dx_countlimit *climit, uint16_t limit);
+static inline void ext4_dir_dx_countlimit_set_limit(
+ struct ext4_directory_dx_countlimit *climit, uint16_t limit)
+{
+ climit->limit = to_le16(limit);
+}
+
/**@brief Get current number of index node entries.
* @param climit Pointer to counlimit structure
* @return Number of entries in node
*/
-uint16_t ext4_dir_dx_countlimit_get_count(
- struct ext4_directory_dx_countlimit *climit);
+static inline uint16_t ext4_dir_dx_countlimit_get_count(
+ struct ext4_directory_dx_countlimit *climit)
+{
+ return to_le16(climit->count);
+}
/**@brief Set current number of index node entries.
* @param climit Pointer to counlimit structure
* @param count Number of entries in node
*/
-void ext4_dir_dx_countlimit_set_count(
- struct ext4_directory_dx_countlimit *climit, uint16_t count);
+static inline void ext4_dir_dx_countlimit_set_count(
+ struct ext4_directory_dx_countlimit *climit, uint16_t count)
+{
+ climit->count = to_le16(count);
+}
/**@brief Get hash value of index entry.
* @param entry Pointer to index entry
* @return Hash value
*/
-uint32_t ext4_dir_dx_entry_get_hash(
- struct ext4_directory_dx_entry *entry);
+static inline uint32_t ext4_dir_dx_entry_get_hash(
+ struct ext4_directory_dx_entry *entry)
+{
+ return to_le32(entry->hash);
+}
/**@brief Set hash value of index entry.
* @param entry Pointer to index entry
* @param hash Hash value
*/
-void ext4_dir_dx_entry_set_hash(
- struct ext4_directory_dx_entry *entry, uint32_t hash);
+static inline void ext4_dir_dx_entry_set_hash(
+ struct ext4_directory_dx_entry *entry, uint32_t hash)
+{
+ entry->hash = to_le32(hash);
+}
/**@brief Get block address where child node is located.
* @param entry Pointer to index entry
* @return Block address of child node
*/
-uint32_t ext4_dir_dx_entry_get_block(
- struct ext4_directory_dx_entry *entry);
+static inline uint32_t ext4_dir_dx_entry_get_block(
+ struct ext4_directory_dx_entry *entry)
+{
+ return to_le32(entry->block);
+}
/**@brief Set block address where child node is located.
* @param entry Pointer to index entry
* @param block Block address of child node
*/
-void ext4_dir_dx_entry_set_block(
- struct ext4_directory_dx_entry *entry, uint32_t block);
+static inline void ext4_dir_dx_entry_set_block(
+ struct ext4_directory_dx_entry *entry, uint32_t block)
+{
+ entry->block = to_le32(block);
+}
/**@brief Initialize index structure of new directory.
* @param dir Pointer to directory i-node