ref: 29c449921a96ee3420a2944022bb78bde02885fc
parent: 6a8d105e116c0a1311bd3e60d947b2d8c9fcebcf
author: gkostka <kostka.grzegorz@gmail.com>
date: Tue Oct 28 20:57:59 EDT 2014
Move some simple functions to header
--- a/lwext4/ext4_dir.c
+++ b/lwext4/ext4_dir.c
@@ -47,71 +47,7 @@
#include <string.h>
-uint32_t ext4_dir_entry_ll_get_inode(struct ext4_directory_entry_ll *de)
-{
- return to_le32(de->inode);
-}
-void ext4_dir_entry_ll_set_inode(struct ext4_directory_entry_ll *de,
- uint32_t inode)
-{
- de->inode = to_le32(inode);
-}
-
-
-uint16_t ext4_dir_entry_ll_get_entry_length(struct ext4_directory_entry_ll *de)
-{
- return to_le16(de->entry_length);
-}
-
-void ext4_dir_entry_ll_set_entry_length(struct ext4_directory_entry_ll *de,
- uint16_t len)
-{
- de->entry_length = to_le16(len);
-}
-
-
-uint16_t ext4_dir_entry_ll_get_name_length(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de)
-{
- uint16_t v = de->name_length;
-
- if ((ext4_get32(sb, rev_level) == 0) &&
- (ext4_get32(sb, minor_rev_level) < 5))
- v |= ((uint16_t)de->in.name_length_high) << 8;
-
- return v;
-}
-void ext4_dir_entry_ll_set_name_length(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de, uint16_t len)
-{
- de->name_length = (len << 8) >> 8;
-
- if ((ext4_get32(sb, rev_level) == 0) &&
- (ext4_get32(sb, minor_rev_level) < 5))
- de->in.name_length_high = len >> 8;
-}
-
-
-
-uint8_t ext4_dir_entry_ll_get_inode_type(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de)
-{
- if ((ext4_get32(sb, rev_level) > 0) ||
- (ext4_get32(sb, minor_rev_level) >= 5))
- return de->in.inode_type;
-
- return EXT4_DIRECTORY_FILETYPE_UNKNOWN;
-}
-
-
-void ext4_dir_entry_ll_set_inode_type(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de, uint8_t type)
-{
- if ((ext4_get32(sb, rev_level) > 0) ||
- (ext4_get32(sb, minor_rev_level) >= 5))
- de->in.inode_type = type;
-}
/****************************************************************************/
--- a/lwext4/ext4_dir.h
+++ b/lwext4/ext4_dir.h
@@ -53,59 +53,105 @@
* @param de Directory entry
* @return I-node number
*/
-uint32_t ext4_dir_entry_ll_get_inode(struct ext4_directory_entry_ll *de);
+static inline uint32_t ext4_dir_entry_ll_get_inode(
+ struct ext4_directory_entry_ll *de)
+{
+ return to_le32(de->inode);
+}
+
/**@brief Set i-node number to directory entry.
* @param de Directory entry
* @param inode I-node number
*/
-void ext4_dir_entry_ll_set_inode(struct ext4_directory_entry_ll *de,
- uint32_t inode);
+static inline void ext4_dir_entry_ll_set_inode(
+ struct ext4_directory_entry_ll *de, uint32_t inode)
+{
+ de->inode = to_le32(inode);
+}
+
/**@brief Get directory entry length.
* @param de Directory entry
* @return Entry length
*/
-uint16_t ext4_dir_entry_ll_get_entry_length(struct ext4_directory_entry_ll *de);
+static inline uint16_t ext4_dir_entry_ll_get_entry_length(
+ struct ext4_directory_entry_ll *de)
+{
+ return to_le16(de->entry_length);
+}
/**@brief Set directory entry length.
* @param de Directory entry
* @param length Entry length
*/
-void ext4_dir_entry_ll_set_entry_length(struct ext4_directory_entry_ll *de,
- uint16_t len);
+static inline void ext4_dir_entry_ll_set_entry_length(
+ struct ext4_directory_entry_ll *de, uint16_t len)
+{
+ de->entry_length = to_le16(len);
+}
+
/**@brief Get directory entry name length.
* @param sb Superblock
* @param de Directory entry
* @return Entry name length
*/
-uint16_t ext4_dir_entry_ll_get_name_length(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de);
+static inline uint16_t ext4_dir_entry_ll_get_name_length(struct ext4_sblock *sb,
+ struct ext4_directory_entry_ll *de)
+{
+ uint16_t v = de->name_length;
+ if ((ext4_get32(sb, rev_level) == 0) &&
+ (ext4_get32(sb, minor_rev_level) < 5))
+ v |= ((uint16_t)de->in.name_length_high) << 8;
+
+ return v;
+}
+
/**@brief Set directory entry name length.
* @param sb Superblock
* @param de Directory entry
* @param length Entry name length
*/
-void ext4_dir_entry_ll_set_name_length(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de, uint16_t len);
+static inline void ext4_dir_entry_ll_set_name_length(struct ext4_sblock *sb,
+ struct ext4_directory_entry_ll *de, uint16_t len)
+{
+ de->name_length = (len << 8) >> 8;
+ if ((ext4_get32(sb, rev_level) == 0) &&
+ (ext4_get32(sb, minor_rev_level) < 5))
+ de->in.name_length_high = len >> 8;
+}
+
+
/**@brief Get i-node type of directory entry.
* @param sb Superblock
* @param de Directory entry
* @return I-node type (file, dir, etc.)
*/
-uint8_t ext4_dir_entry_ll_get_inode_type(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de);
+static inline uint8_t ext4_dir_entry_ll_get_inode_type(struct ext4_sblock *sb,
+ struct ext4_directory_entry_ll *de)
+{
+ if ((ext4_get32(sb, rev_level) > 0) ||
+ (ext4_get32(sb, minor_rev_level) >= 5))
+ return de->in.inode_type;
+ return EXT4_DIRECTORY_FILETYPE_UNKNOWN;
+}
/**@brief Set i-node type of directory entry.
* @param sb Superblock
* @param de Directory entry
* @param type I-node type (file, dir, etc.)
*/
-void ext4_dir_entry_ll_set_inode_type(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de, uint8_t type);
+
+static inline void ext4_dir_entry_ll_set_inode_type(struct ext4_sblock *sb,
+ struct ext4_directory_entry_ll *de, uint8_t type)
+{
+ if ((ext4_get32(sb, rev_level) > 0) ||
+ (ext4_get32(sb, minor_rev_level) >= 5))
+ de->in.inode_type = type;
+}
/**@brief Initialize directory iterator.
* Set position to the first valid entry from the required position.