ref: 57c3921e0740fd268e794bdb86c6fea7994101b5
parent: 1e17302a6d811f32d889577d97b895eccc5c5ef2
author: gkostka <[email protected]>
date: Sun Oct 27 18:36:47 EDT 2013
Code format.
--- a/lwext4/ext4_dir.c
+++ b/lwext4/ext4_dir.c
@@ -52,8 +52,8 @@
return to_le32(de->inode);
}
-void ext4_dir_entry_ll_set_inode(struct ext4_directory_entry_ll *de,
- uint32_t inode)
+void ext4_dir_entry_ll_set_inode(struct ext4_directory_entry_ll *de,
+ uint32_t inode)
{
de->inode = to_le32(inode);
}
@@ -64,8 +64,8 @@
return to_le16(de->entry_length);
}
-void ext4_dir_entry_ll_set_entry_length(struct ext4_directory_entry_ll *de,
- uint16_t len)
+void ext4_dir_entry_ll_set_entry_length(struct ext4_directory_entry_ll *de,
+ uint16_t len)
{
de->entry_length = to_le16(len);
}
@@ -72,7 +72,7 @@
uint16_t ext4_dir_entry_ll_get_name_length(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de)
+ struct ext4_directory_entry_ll *de)
{
uint16_t v = de->name_length;
@@ -82,8 +82,8 @@
return v;
}
-void ext4_dir_entry_ll_set_name_length(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de, uint16_t len)
+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;
@@ -95,7 +95,7 @@
uint8_t ext4_dir_entry_ll_get_inode_type(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de)
+ struct ext4_directory_entry_ll *de)
{
if ((ext4_get32(sb, rev_level) > 0) ||
(ext4_get32(sb, minor_rev_level) >= 5))
@@ -105,8 +105,8 @@
}
-void ext4_dir_entry_ll_set_inode_type(struct ext4_sblock *sb,
- struct ext4_directory_entry_ll *de, uint8_t type)
+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))
@@ -216,7 +216,7 @@
int ext4_dir_iterator_init(struct ext4_directory_iterator *it,
- struct ext4_inode_ref *inode_ref, uint64_t pos)
+ struct ext4_inode_ref *inode_ref, uint64_t pos)
{
it->inode_ref = inode_ref;
it->current = 0;
@@ -237,7 +237,7 @@
if(!it->current)
break;
- /*Skip NULL referenced entry*/
+ /*Skip NULL referenced entry*/
if(it->current->inode != 0)
break;
}
@@ -281,7 +281,7 @@
}
int ext4_dir_add_entry(struct ext4_inode_ref *parent, const char *name,
- uint32_t name_len, struct ext4_inode_ref *child)
+ uint32_t name_len, struct ext4_inode_ref *child)
{
struct ext4_fs *fs = parent->fs;
@@ -361,7 +361,7 @@
memset(new_block.data, 0, block_size);
struct ext4_directory_entry_ll *block_entry = (void *)new_block.data;
ext4_dir_write_entry(&fs->sb, block_entry, block_size,
- child, name, name_len);
+ child, name, name_len);
/* Save new block */
new_block.dirty = true;
@@ -371,7 +371,7 @@
}
int ext4_dir_find_entry(struct ext4_directory_search_result *result,
- struct ext4_inode_ref *parent, const char *name, uint32_t name_len)
+ struct ext4_inode_ref *parent, const char *name, uint32_t name_len)
{
struct ext4_sblock *sb = &parent->fs->sb;
@@ -492,7 +492,7 @@
uint16_t del_entry_length =
ext4_dir_entry_ll_get_entry_length(result.dentry);
ext4_dir_entry_ll_set_entry_length(tmp_dentry,
- tmp_dentry_length + del_entry_length);
+ tmp_dentry_length + del_entry_length);
}
result.block.dirty = true;
@@ -553,10 +553,9 @@
struct ext4_directory_entry_ll *new_entry =
(void *) dentry + used_space;
ext4_dir_write_entry(sb, new_entry,
- free_space, child, name, name_len);
+ free_space, child, name, name_len);
target_block->dirty = true;
-
return EOK;
}
}
@@ -571,8 +570,8 @@
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)
+ size_t name_len, const char *name,
+ struct ext4_directory_entry_ll **res_entry)
{
/* Start from the first entry in block */
struct ext4_directory_entry_ll *dentry =
@@ -609,7 +608,7 @@
/* Jump to next entry */
dentry = (struct ext4_directory_entry_ll *)
- ((uint8_t *) dentry + dentry_len);
+ ((uint8_t *) dentry + dentry_len);
}
/* Entry not found */
--- a/lwext4/ext4_dir.h
+++ b/lwext4/ext4_dir.h
@@ -47,63 +47,78 @@
#include <ext4_blockdev.h>
#include <ext4_super.h>
-
#include <stdint.h>
+/**@brief TODO: ...*/
uint32_t ext4_dir_entry_ll_get_inode(struct ext4_directory_entry_ll *de);
+/**@brief TODO: ...*/
void ext4_dir_entry_ll_set_inode(struct ext4_directory_entry_ll *de,
uint32_t inode);
-
+/**@brief TODO: ...*/
uint16_t ext4_dir_entry_ll_get_entry_length(struct ext4_directory_entry_ll *de);
+
+/**@brief TODO: ...*/
void ext4_dir_entry_ll_set_entry_length(struct ext4_directory_entry_ll *de,
uint16_t len);
-
+/**@brief TODO: ...*/
uint16_t ext4_dir_entry_ll_get_name_length(struct ext4_sblock *sb,
struct ext4_directory_entry_ll *de);
+
+/**@brief TODO: ...*/
void ext4_dir_entry_ll_set_name_length(struct ext4_sblock *sb,
struct ext4_directory_entry_ll *de, uint16_t len);
-
-
+/**@brief TODO: ...*/
uint8_t ext4_dir_entry_ll_get_inode_type(struct ext4_sblock *sb,
struct ext4_directory_entry_ll *de);
-void ext4_dir_entry_ll_set_inode_type(struct ext4_sblock *sb,
+
+/**@brief TODO: ...*/
+void ext4_dir_entry_ll_set_inode_type(struct ext4_sblock *sb,
struct ext4_directory_entry_ll *de, uint8_t type);
-
+/**@brief TODO: ...*/
int ext4_dir_iterator_init(struct ext4_directory_iterator *it,
struct ext4_inode_ref *inode_ref, uint64_t pos);
+/**@brief TODO: ...*/
int ext4_dir_iterator_next(struct ext4_directory_iterator *it);
+
+/**@brief TODO: ...*/
int ext4_dir_iterator_fini(struct ext4_directory_iterator *it);
+/**@brief TODO: ...*/
void ext4_dir_write_entry(struct ext4_sblock *sb,
struct ext4_directory_entry_ll *entry, uint16_t entry_len,
struct ext4_inode_ref *child, const char *name, size_t name_len);
+/**@brief TODO: ...*/
int ext4_dir_add_entry(struct ext4_inode_ref *parent, const char *name,
- uint32_t name_len, struct ext4_inode_ref *child);
+ uint32_t name_len, struct ext4_inode_ref *child);
+/**@brief TODO: ...*/
int ext4_dir_find_entry(struct ext4_directory_search_result *result,
- struct ext4_inode_ref *parent, const char *name, uint32_t name_len);
+ struct ext4_inode_ref *parent, const char *name, uint32_t name_len);
+/**@brief TODO: ...*/
int ext4_dir_remove_entry(struct ext4_inode_ref *parent, const char *name,
uint32_t name_len);
+/**@brief TODO: ...*/
int ext4_dir_try_insert_entry(struct ext4_sblock *sb,
struct ext4_block *target_block, struct ext4_inode_ref *child,
const char *name, uint32_t name_len);
+/**@brief TODO: ...*/
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);
+/**@brief TODO: ...*/
int ext4_dir_destroy_result(struct ext4_inode_ref *parent,
struct ext4_directory_search_result *result);
-
#endif /* EXT4_DIR_H_ */
--- a/lwext4/ext4_errno.h
+++ b/lwext4/ext4_errno.h
@@ -41,47 +41,45 @@
#ifndef CONFIG_HAVE_OWN_ERRNO
#include <errno.h>
#else
-#define EPERM 1 /* Operation not permitted */
-#define ENOENT 2 /* No such file or directory */
-#define ESRCH 3 /* No such process */
-#define EINTR 4 /* Interrupted system call */
-#define EIO 5 /* I/O error */
-#define ENXIO 6 /* No such device or address */
-#define E2BIG 7 /* Argument list too long */
-#define ENOEXEC 8 /* Exec format error */
-#define EBADF 9 /* Bad file number */
-#define ECHILD 10 /* No child processes */
-#define EAGAIN 11 /* Try again */
-#define ENOMEM 12 /* Out of memory */
-#define EACCES 13 /* Permission denied */
-#define EFAULT 14 /* Bad address */
-#define ENOTBLK 15 /* Block device required */
-#define EBUSY 16 /* Device or resource busy */
-#define EEXIST 17 /* File exists */
-#define EXDEV 18 /* Cross-device link */
-#define ENODEV 19 /* No such device */
-#define ENOTDIR 20 /* Not a directory */
-#define EISDIR 21 /* Is a directory */
-#define EINVAL 22 /* Invalid argument */
-#define ENFILE 23 /* File table overflow */
-#define EMFILE 24 /* Too many open files */
-#define ENOTTY 25 /* Not a typewriter */
-#define ETXTBSY 26 /* Text file busy */
-#define EFBIG 27 /* File too large */
-#define ENOSPC 28 /* No space left on device */
-#define ESPIPE 29 /* Illegal seek */
-#define EROFS 30 /* Read-only file system */
-#define EMLINK 31 /* Too many links */
-#define EPIPE 32 /* Broken pipe */
-#define EDOM 33 /* Math argument out of domain of func */
-#define ERANGE 34 /* Math result not representable */
-
-#define ENOTSUP 95
+#define EPERM 1 /* Operation not permitted */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* I/O error */
+#define ENXIO 6 /* No such device or address */
+#define E2BIG 7 /* Argument list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file number */
+#define ECHILD 10 /* No child processes */
+#define EAGAIN 11 /* Try again */
+#define ENOMEM 12 /* Out of memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Device or resource busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* No such device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* File table overflow */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Not a typewriter */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+#define EDOM 33 /* Math argument out of domain of func */
+#define ERANGE 34 /* Math result not representable */
+#define ENOTSUP 95 /* Not supported */
#endif
-/**@brief OK return value*/
#ifndef EOK
-#define EOK 0
+#define EOK 0
#endif
#endif /* EXT4_ERRNO_H_ */
@@ -89,4 +87,3 @@
/**
* @}
*/
-
--- a/lwext4/ext4_fs.c
+++ b/lwext4/ext4_fs.c
@@ -131,58 +131,47 @@
if(features_incompatible &
EXT4_FEATURE_INCOMPAT_COMPRESSION){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_INCOMPAT_COMPRESSION\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "COMPRESSION\n");
}
if(features_incompatible &
EXT4_FEATURE_INCOMPAT_FILETYPE){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_INCOMPAT_FILETYPE\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "FILETYPE\n");
}
if(features_incompatible &
EXT4_FEATURE_INCOMPAT_RECOVER){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_INCOMPAT_RECOVER\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "RECOVER\n");
}
if(features_incompatible &
EXT4_FEATURE_INCOMPAT_JOURNAL_DEV){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_INCOMPAT_JOURNAL_DEV\n");
+ ext4_dprintf(EXT4_DEBUG_FS,"JOURNAL_DEV\n");
}
if(features_incompatible &
EXT4_FEATURE_INCOMPAT_META_BG){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_INCOMPAT_META_BG\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "META_BG\n");
}
if(features_incompatible &
EXT4_FEATURE_INCOMPAT_EXTENTS){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_INCOMPAT_EXTENTS\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "EXTENTS\n");
}
if(features_incompatible &
EXT4_FEATURE_INCOMPAT_64BIT){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_INCOMPAT_64BIT\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "64BIT\n");
}
if(features_incompatible &
EXT4_FEATURE_INCOMPAT_MMP){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_INCOMPAT_MMP\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "MMP\n");
}
if(features_incompatible &
EXT4_FEATURE_INCOMPAT_FLEX_BG){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_INCOMPAT_FLEX_BG\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "FLEX_BG\n");
}
if(features_incompatible &
EXT4_FEATURE_INCOMPAT_EA_INODE){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_INCOMPAT_EA_INODE\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "EA_INODE\n");
}
if(features_incompatible &
EXT4_FEATURE_INCOMPAT_DIRDATA){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_INCOMPAT_DIRDATA\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "DIRDATA\n");
}
}
static void ext4_fs_debug_features_comp(uint32_t features_compatible)
@@ -189,33 +178,27 @@
{
if(features_compatible &
EXT4_FEATURE_COMPAT_DIR_PREALLOC){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_COMPAT_DIR_PREALLOC\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "DIR_PREALLOC\n");
}
if(features_compatible &
EXT4_FEATURE_COMPAT_IMAGIC_INODES){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_COMPAT_IMAGIC_INODES\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "IMAGIC_INODES\n");
}
if(features_compatible &
EXT4_FEATURE_COMPAT_HAS_JOURNAL){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_COMPAT_HAS_JOURNAL\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "HAS_JOURNAL\n");
}
if(features_compatible &
EXT4_FEATURE_COMPAT_EXT_ATTR){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_COMPAT_EXT_ATTR\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "EXT_ATTR\n");
}
if(features_compatible &
EXT4_FEATURE_COMPAT_RESIZE_INODE){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_COMPAT_RESIZE_INODE\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "RESIZE_INODE\n");
}
if(features_compatible &
EXT4_FEATURE_COMPAT_DIR_INDEX){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_COMPAT_DIR_INDEX\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "DIR_INDEX\n");
}
}
@@ -223,38 +206,31 @@
{
if(features_ro &
EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "SPARSE_SUPER\n");
}
if(features_ro &
EXT4_FEATURE_RO_COMPAT_LARGE_FILE){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_RO_COMPAT_LARGE_FILE\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "LARGE_FILE\n");
}
if(features_ro &
EXT4_FEATURE_RO_COMPAT_BTREE_DIR){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_RO_COMPAT_BTREE_DIR\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "BTREE_DIR\n");
}
if(features_ro &
EXT4_FEATURE_RO_COMPAT_HUGE_FILE){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_RO_COMPAT_HUGE_FILE\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "HUGE_FILE\n");
}
if(features_ro &
EXT4_FEATURE_RO_COMPAT_GDT_CSUM){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_RO_COMPAT_GDT_CSUM\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "GDT_CSUM\n");
}
if(features_ro &
EXT4_FEATURE_RO_COMPAT_DIR_NLINK){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_RO_COMPAT_DIR_NLINK\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "DIR_NLINK\n");
}
if(features_ro &
EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE){
- ext4_dprintf(EXT4_DEBUG_FS,
- "EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE\n");
+ ext4_dprintf(EXT4_DEBUG_FS, "EXTRA_ISIZE\n");
}
}
@@ -307,7 +283,6 @@
*read_only = true;
return EOK;
}
-
*read_only = false;
return EOK;
--- a/lwext4/ext4_fs.h
+++ b/lwext4/ext4_fs.h
@@ -48,45 +48,62 @@
#include <stdint.h>
#include <stdbool.h>
+/**@brief TODO: ...*/
int ext4_fs_init(struct ext4_fs *fs, struct ext4_blockdev *bdev);
+
+/**@brief TODO: ...*/
int ext4_fs_fini(struct ext4_fs *fs);
+/**@brief TODO: ...*/
int ext4_fs_check_features(struct ext4_fs *fs, bool *read_only);
-
+/**@brief TODO: ...*/
uint32_t ext4_fs_baddr2_index_in_group(struct ext4_sblock *s, uint32_t baddr);
+
+/**@brief TODO: ...*/
uint32_t ext4_fs_index_in_group2_baddr(struct ext4_sblock *s, uint32_t index,
uint32_t bgid);
-
+/**@brief TODO: ...*/
int ext4_fs_get_block_group_ref(struct ext4_fs *fs, uint32_t bgid,
struct ext4_block_group_ref *ref);
+
+/**@brief TODO: ...*/
int ext4_fs_put_block_group_ref(struct ext4_block_group_ref *ref);
-
+/**@brief TODO: ...*/
int ext4_fs_get_inode_ref(struct ext4_fs *fs, uint32_t index,
struct ext4_inode_ref *ref);
+
+/**@brief TODO: ...*/
int ext4_fs_put_inode_ref(struct ext4_inode_ref *ref);
-
+/**@brief TODO: ...*/
int ext4_fs_alloc_inode(struct ext4_fs *fs, struct ext4_inode_ref *inode_ref,
bool is_directory);
+
+/**@brief TODO: ...*/
int ext4_fs_free_inode(struct ext4_inode_ref *inode_ref);
+/**@brief TODO: ...*/
int ext4_fs_truncate_inode(struct ext4_inode_ref *inode_ref,
- uint64_t new_size);
+ uint64_t new_size);
+/**@brief TODO: ...*/
int ext4_fs_get_inode_data_block_index(struct ext4_inode_ref *inode_ref,
- uint64_t iblock, uint32_t *fblock);
+ uint64_t iblock, uint32_t *fblock);
+/**@brief TODO: ...*/
int ext4_fs_set_inode_data_block_index(struct ext4_inode_ref *inode_ref,
- uint64_t iblock, uint32_t fblock);
+ uint64_t iblock, uint32_t fblock);
+/**@brief TODO: ...*/
int ext4_fs_release_inode_block(struct ext4_inode_ref *inode_ref,
- uint32_t iblock);
+ uint32_t iblock);
+/**@brief TODO: ...*/
int ext4_fs_append_inode_block(struct ext4_inode_ref *inode_ref,
- uint32_t *fblock, uint32_t *iblock);
+ uint32_t *fblock, uint32_t *iblock);
#endif /* EXT4_FS_H_ */
--- a/lwext4/ext4_hash.c
+++ b/lwext4/ext4_hash.c
@@ -195,7 +195,7 @@
static void
ext2_prep_hashbuf(const char *src, int slen, uint32_t *dst, int dlen,
- int unsigned_char)
+ int unsigned_char)
{
uint32_t padding = slen | (slen << 8) | (slen << 16) | (slen << 24);
uint32_t buf_val;
@@ -243,8 +243,8 @@
int
ext2_htree_hash(const char *name, int len,
- const uint32_t *hash_seed, int hash_version,
- uint32_t *hash_major, uint32_t *hash_minor)
+ const uint32_t *hash_seed, int hash_version,
+ uint32_t *hash_major, uint32_t *hash_minor)
{
uint32_t hash[4];
uint32_t data[8];
--- a/lwext4/ext4_ialloc.h
+++ b/lwext4/ext4_ialloc.h
@@ -49,8 +49,10 @@
#include <ext4_config.h>
#include <ext4_types.h>
-
+/**@brief TODO: ...*/
int ext4_ialloc_free_inode(struct ext4_fs *fs, uint32_t index, bool is_dir);
+
+/**@brief TODO: ...*/
int ext4_ialloc_alloc_inode(struct ext4_fs *fs, uint32_t *index, bool is_dir);
#ifdef __cplusplus
--- a/lwext4/ext4_inode.c
+++ b/lwext4/ext4_inode.c
@@ -44,6 +44,7 @@
#include <ext4_inode.h>
#include <ext4_super.h>
+/**@brief TODO: ...*/
static uint32_t ext4_inode_block_bits_count(uint32_t block_size)
{
uint32_t bits = 8;
@@ -57,7 +58,6 @@
return bits;
}
-
uint32_t ext4_inode_get_mode(struct ext4_sblock *sb, struct ext4_inode *inode)
{
uint32_t v = to_le16(inode->mode);
@@ -78,8 +78,6 @@
inode->osd2.hurd2.mode_high = to_le16(mode >> 16);
}
-
-
uint32_t ext4_inode_get_uid(struct ext4_inode *inode)
{
return to_le32(inode->uid);
@@ -90,7 +88,6 @@
inode->uid = to_le32(uid);
}
-
uint64_t ext4_inode_get_size(struct ext4_sblock *sb, struct ext4_inode *inode)
{
uint64_t v = to_le32(inode->size_lo);
@@ -102,18 +99,17 @@
return v;
}
-void ext4_inode_set_size(struct ext4_inode *inode, uint64_t size)
+void ext4_inode_set_size(struct ext4_inode *inode, uint64_t size)
{
inode->size_lo = to_le32((size << 32) >> 32);
inode->size_hi = to_le32(size >> 32);
}
-
uint32_t ext4_inode_get_access_time(struct ext4_inode *inode)
{
return to_le32(inode->access_time);
}
-void ext4_inode_set_access_time(struct ext4_inode *inode, uint32_t time)
+void ext4_inode_set_access_time(struct ext4_inode *inode, uint32_t time)
{
inode->access_time = to_le32(time);
}
@@ -123,7 +119,7 @@
{
return to_le32(inode->change_inode_time);
}
-void ext4_inode_set_change_inode_time(struct ext4_inode *inode,
+void ext4_inode_set_change_inode_time(struct ext4_inode *inode,
uint32_t time)
{
inode->change_inode_time = to_le32(time);
@@ -135,7 +131,7 @@
return to_le32(inode->modification_time);
}
-void ext4_inode_set_modification_time(struct ext4_inode *inode,
+void ext4_inode_set_modification_time(struct ext4_inode *inode,
uint32_t time)
{
inode->modification_time = to_le32(time);
@@ -147,7 +143,7 @@
return to_le32(inode->deletion_time);
}
-void ext4_inode_set_deletion_time(struct ext4_inode *inode, uint32_t time)
+void ext4_inode_set_deletion_time(struct ext4_inode *inode, uint32_t time)
{
inode->deletion_time = to_le32(time);
}
@@ -156,7 +152,7 @@
{
return to_le32(inode->gid);
}
-void ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid)
+void ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid)
{
inode->gid = to_le32(gid);
}
@@ -165,12 +161,11 @@
{
return to_le16(inode->links_count);
}
-void ext4_inode_set_links_count(struct ext4_inode *inode, uint16_t cnt)
+void ext4_inode_set_links_count(struct ext4_inode *inode, uint16_t cnt)
{
inode->links_count = to_le16(cnt);
}
-
uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,
struct ext4_inode *inode)
{
@@ -187,14 +182,12 @@
uint32_t block_bits =
ext4_inode_block_bits_count(ext4_sb_get_block_size(sb));
return count << (block_bits - 9);
- } else
- return count;
+ }
}
return count;
}
-
int ext4_inode_set_blocks_count(struct ext4_sblock *sb,
struct ext4_inode *inode, uint64_t count)
{
@@ -235,12 +228,11 @@
return EOK;
}
-
uint32_t ext4_inode_get_flags(struct ext4_inode *inode)
{
return to_le32(inode->flags);
}
-void ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags)
+void ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags)
{
inode->flags = to_le32(flags);
}
@@ -277,8 +269,6 @@
inode->osd2.linux2.file_acl_high = to_le16(acl >> 32);
}
-
-
uint32_t ext4_inode_get_direct_block(struct ext4_inode *inode, uint32_t idx)
{
return to_le32(inode->blocks[idx]);
@@ -289,7 +279,6 @@
inode->blocks[idx] = to_le32(block);
}
-
uint32_t ext4_inode_get_indirect_block(struct ext4_inode *inode, uint32_t idx)
{
return to_le32(inode->blocks[idx + EXT4_INODE_INDIRECT_BLOCK]);
@@ -308,12 +297,12 @@
EXT4_INODE_MODE_TYPE_MASK) == type;
}
-bool ext4_inode_has_flag(struct ext4_inode *inode, uint32_t f)
+bool ext4_inode_has_flag(struct ext4_inode *inode, uint32_t f)
{
return ext4_inode_get_flags(inode) & f;
}
-void ext4_inode_clear_flag(struct ext4_inode *inode, uint32_t f)
+void ext4_inode_clear_flag(struct ext4_inode *inode, uint32_t f)
{
uint32_t flags = ext4_inode_get_flags(inode);
flags = flags & (~f);
@@ -320,7 +309,7 @@
ext4_inode_set_flags(inode, flags);
}
-void ext4_inode_set_flag(struct ext4_inode *inode, uint32_t f)
+void ext4_inode_set_flag(struct ext4_inode *inode, uint32_t f)
{
uint32_t flags = ext4_inode_get_flags(inode);
flags = flags | f;
@@ -327,7 +316,7 @@
ext4_inode_set_flags(inode, flags);
}
-bool ext4_inode_can_truncate(struct ext4_sblock *sb,
+bool ext4_inode_can_truncate(struct ext4_sblock *sb,
struct ext4_inode *inode)
{
if ((ext4_inode_has_flag(inode, EXT4_INODE_FLAG_APPEND)) ||
@@ -340,7 +329,6 @@
return false;
}
-
struct ext4_extent_header * ext4_inode_get_extent_header(
struct ext4_inode *inode)
--- a/lwext4/ext4_inode.h
+++ b/lwext4/ext4_inode.h
@@ -45,77 +45,119 @@
#include <ext4_config.h>
#include <stdint.h>
+/**@brief TODO: ...*/
uint32_t ext4_inode_get_mode(struct ext4_sblock *sb, struct ext4_inode *inode);
+
+
+/**@brief TODO: ...*/
void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode,
uint32_t mode);
-
+/**@brief TODO: ...*/
uint32_t ext4_inode_get_uid(struct ext4_inode *inode);
-void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid);
+/**@brief TODO: ...*/
+void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid);
+/**@brief TODO: ...*/
uint64_t ext4_inode_get_size(struct ext4_sblock *sb, struct ext4_inode *inode);
+
+/**@brief TODO: ...*/
void ext4_inode_set_size(struct ext4_inode *inode, uint64_t size);
-
+/**@brief TODO: ...*/
uint32_t ext4_inode_get_access_time(struct ext4_inode *inode);
-void ext4_inode_set_access_time(struct ext4_inode *inode, uint32_t time);
+/**@brief TODO: ...*/
+void ext4_inode_set_access_time(struct ext4_inode *inode, uint32_t time);
+/**@brief TODO: ...*/
uint32_t ext4_inode_get_change_inode_time(struct ext4_inode *inode);
+
+/**@brief TODO: ...*/
void ext4_inode_set_change_inode_time(struct ext4_inode *inode,
uint32_t time);
-
+/**@brief TODO: ...*/
uint32_t ext4_inode_get_modification_time(struct ext4_inode *inode);
+
+/**@brief TODO: ...*/
void ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time);
-
+/**@brief TODO: ...*/
uint32_t ext4_inode_get_deletion_time(struct ext4_inode *inode);
+
+/**@brief TODO: ...*/
void ext4_inode_set_deletion_time(struct ext4_inode *inode, uint32_t time);
+/**@brief TODO: ...*/
uint32_t ext4_inode_get_gid(struct ext4_inode *inode);
-void ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid);
+/**@brief TODO: ...*/
+void ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid);
+
+/**@brief TODO: ...*/
uint16_t ext4_inode_get_links_count(struct ext4_inode *inode);
+
+/**@brief TODO: ...*/
void ext4_inode_set_links_count(struct ext4_inode *inode, uint16_t cnt);
-
+/**@brief TODO: ...*/
uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,
struct ext4_inode *inode);
+
+/**@brief TODO: ...*/
int ext4_inode_set_blocks_count(struct ext4_sblock *sb,
struct ext4_inode *inode, uint64_t cnt);
-
+/**@brief TODO: ...*/
uint32_t ext4_inode_get_flags(struct ext4_inode *inode);
+
+/**@brief TODO: ...*/
void ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags);
+/**@brief TODO: ...*/
uint32_t ext4_inode_get_generation(struct ext4_inode *inode);
+
+/**@brief TODO: ...*/
void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen);
+/**@brief TODO: ...*/
uint64_t ext4_inode_get_file_acl(struct ext4_inode *inode,
struct ext4_sblock *sb);
+
+/**@brief TODO: ...*/
void ext4_inode_set_file_acl(struct ext4_inode *inode,
struct ext4_sblock *sb, uint64_t acl);
-
+/**@brief TODO: ...*/
uint32_t ext4_inode_get_direct_block(struct ext4_inode *inode, uint32_t idx);
+
+/**@brief TODO: ...*/
void ext4_inode_set_direct_block(struct ext4_inode *inode, uint32_t idx,
uint32_t block);
-
+/**@brief TODO: ...*/
uint32_t ext4_inode_get_indirect_block(struct ext4_inode *inode, uint32_t idx);
+
+/**@brief TODO: ...*/
void ext4_inode_set_indirect_block(struct ext4_inode *inode, uint32_t idx,
uint32_t block);
+/**@brief TODO: ...*/
bool ext4_inode_is_type(struct ext4_sblock *sb, struct ext4_inode *inode,
uint32_t type);
-
+/**@brief TODO: ...*/
bool ext4_inode_has_flag(struct ext4_inode *inode, uint32_t f);
+
+/**@brief TODO: ...*/
void ext4_inode_clear_flag(struct ext4_inode *inode, uint32_t f);
+
+/**@brief TODO: ...*/
void ext4_inode_set_flag(struct ext4_inode *inode, uint32_t f);
+/**@brief TODO: ...*/
bool ext4_inode_can_truncate(struct ext4_sblock *sb, struct ext4_inode *inode);
--- a/lwext4/ext4_super.h
+++ b/lwext4/ext4_super.h
@@ -49,28 +49,28 @@
/****************************Unstandard access to superblock*****************/
-/**@brief Blocks count get stored in superblock.
- * @param s superblock descriptor
- * @return count of blocks*/
-static inline uint64_t ext4_sb_get_blocks_cnt(struct ext4_sblock *s)
+/**@brief Blocks count get stored in superblock.
+ * @param s superblock descriptor
+ * @return count of blocks*/
+static inline uint64_t ext4_sb_get_blocks_cnt(struct ext4_sblock *s)
{
return ((uint64_t) to_le32(s->blocks_count_hi) << 32) |
to_le32(s->blocks_count_lo);
}
-/**@brief Free blocks count get stored in superblock.
- * @param s superblock descriptor
- * @return free blocks*/
-static inline uint64_t ext4_sb_get_free_blocks_cnt(struct ext4_sblock *s)
+/**@brief Free blocks count get stored in superblock.
+ * @param s superblock descriptor
+ * @return free blocks*/
+static inline uint64_t ext4_sb_get_free_blocks_cnt(struct ext4_sblock *s)
{
return ((uint64_t) to_le32(s->free_blocks_count_hi) << 32) |
to_le32(s->free_blocks_count_lo);
}
-/**@brief Free blocks count set.
- * @param s superblock descriptor
- * @param cnt new value of free blocks*/
-static inline void ext4_sb_set_free_blocks_cnt(struct ext4_sblock *s,
+/**@brief Free blocks count set.
+ * @param s superblock descriptor
+ * @param cnt new value of free blocks*/
+static inline void ext4_sb_set_free_blocks_cnt(struct ext4_sblock *s,
uint64_t cnt)
{
s->free_blocks_count_lo = to_le32((cnt << 32) >> 32);
@@ -77,17 +77,17 @@
s->free_blocks_count_hi = to_le32(cnt >> 32);
}
-/**@brief Block size get from superblock.
- * @param s superblock descriptor
- * @return block size in bytes*/
-static inline uint32_t ext4_sb_get_block_size(struct ext4_sblock *s)
+/**@brief Block size get from superblock.
+ * @param s superblock descriptor
+ * @return block size in bytes*/
+static inline uint32_t ext4_sb_get_block_size(struct ext4_sblock *s)
{
return 1024 << to_le32(s->log_block_size);
}
-/**@brief Block group descriptor size.
- * @param s superblock descriptor
- * @return block group descriptor size in bytes*/
+/**@brief Block group descriptor size.
+ * @param s superblock descriptor
+ * @return block group descriptor size in bytes*/
static inline uint16_t ext4_sb_get_desc_size(struct ext4_sblock *s)
{
uint16_t size = to_le16(s->desc_size);
@@ -98,19 +98,19 @@
/*************************Flags and features*********************************/
-/**@brief Support check of flag.
- * @param s superblock descriptor
- * @param v flag to check
- * @return true if flag is supported*/
+/**@brief Support check of flag.
+ * @param s superblock descriptor
+ * @param v flag to check
+ * @return true if flag is supported*/
static inline bool ext4_sb_check_flag(struct ext4_sblock *s, uint32_t v)
{
return to_le32(s->flags) & v;
}
-/**@brief Support check of feature compatible.
- * @param s superblock descriptor
- * @param v feature to check
- * @return true if feature is supported*/
+/**@brief Support check of feature compatible.
+ * @param s superblock descriptor
+ * @param v feature to check
+ * @return true if feature is supported*/
static inline bool ext4_sb_check_feature_compatible(struct ext4_sblock *s,
uint32_t v)
{
@@ -118,10 +118,10 @@
}
-/**@brief Support check of feature incompatible.
- * @param s superblock descriptor
- * @param v feature to check
- * @return true if feature is supported*/
+/**@brief Support check of feature incompatible.
+ * @param s superblock descriptor
+ * @param v feature to check
+ * @return true if feature is supported*/
static inline bool ext4_sb_check_feature_incompatible(struct ext4_sblock *s,
uint32_t v)
{
@@ -129,10 +129,10 @@
}
-/**@brief Support check of read only flag.
- * @param s superblock descriptor
- * @param v flag to check
- * @return true if flag is supported*/
+/**@brief Support check of read only flag.
+ * @param s superblock descriptor
+ * @param v flag to check
+ * @return true if flag is supported*/
static inline bool ext4_sb_check_read_only(struct ext4_sblock *s, uint32_t v)
{
return to_le32(s->features_read_only) & v;
@@ -140,42 +140,42 @@
/**************************More complex functions****************************/
-/**@brief Returns a block group count.
- * @param s superblock descriptor
- * @return count of block groups*/
+/**@brief Returns a block group count.
+ * @param s superblock descriptor
+ * @return count of block groups*/
uint32_t ext4_block_group_cnt(struct ext4_sblock *s);
-/**@brief Returns block count in block group
+/**@brief Returns block count in block group
* (last block group may have less blocks)
- * @param s superblock descriptor
- * @param bgid block group id
- * @return blocks count*/
+ * @param s superblock descriptor
+ * @param bgid block group id
+ * @return blocks count*/
uint32_t ext4_blocks_in_group_cnt(struct ext4_sblock *s, uint32_t bgid);
-/**@brief Returns inodes count in block group
+/**@brief Returns inodes count in block group
* (last block group may have less inodes)
- * @param s superblock descriptor
- * @param bgid block group id
- * @return inodes count*/
+ * @param s superblock descriptor
+ * @param bgid block group id
+ * @return inodes count*/
uint32_t ext4_inodes_in_group_cnt(struct ext4_sblock *s, uint32_t bgid);
/***************************Read/write/check superblock**********************/
-/**@brief Superblock write.
- * @param bdev block device descriptor.
- * @param s superblock descruptor
- * @return Standard error code */
+/**@brief Superblock write.
+ * @param bdev block device descriptor.
+ * @param s superblock descruptor
+ * @return Standard error code */
int ext4_sb_write(struct ext4_blockdev *bdev, struct ext4_sblock *s);
-/**@brief Superblock read.
- * @param bdev block device descriptor.
- * @param s superblock descruptor
- * @return Standard error code */
+/**@brief Superblock read.
+ * @param bdev block device descriptor.
+ * @param s superblock descruptor
+ * @return Standard error code */
int ext4_sb_read(struct ext4_blockdev *bdev, struct ext4_sblock *s);
-/**@brief Superblock simple validation.
- * @param s superblock dsecriptor
- * @return true if OK*/
+/**@brief Superblock simple validation.
+ * @param s superblock dsecriptor
+ * @return true if OK*/
bool ext4_sb_check(struct ext4_sblock *s);