Browse Source

Code format.

pull/1/head
gkostka 11 years ago
parent
commit
57c3921e07
  1. 1
      lwext4/ext4_dir.c
  2. 29
      lwext4/ext4_dir.h
  3. 5
      lwext4/ext4_errno.h
  4. 73
      lwext4/ext4_fs.c
  5. 25
      lwext4/ext4_fs.h
  6. 4
      lwext4/ext4_ialloc.h
  7. 16
      lwext4/ext4_inode.c
  8. 64
      lwext4/ext4_inode.h

1
lwext4/ext4_dir.c

@ -556,7 +556,6 @@ int ext4_dir_try_insert_entry(struct ext4_sblock *sb,
free_space, child, name, name_len);
target_block->dirty = true;
return EOK;
}
}

29
lwext4/ext4_dir.h

@ -47,64 +47,79 @@
#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);
/**@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);
/**@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);
/**@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_ */
/**

5
lwext4/ext4_errno.h

@ -75,11 +75,9 @@
#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 ENOTSUP 95 /* Not supported */
#endif
/**@brief OK return value*/
#ifndef EOK
#define EOK 0
#endif
@ -89,4 +87,3 @@
/**
* @}
*/

73
lwext4/ext4_fs.c

@ -131,91 +131,74 @@ static void ext4_fs_debug_features_incomp(uint32_t features_incompatible)
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)
{
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 @@ static void ext4_fs_debug_features_ro(uint32_t features_ro)
{
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 @@ int ext4_fs_check_features(struct ext4_fs *fs, bool *read_only)
*read_only = true;
return EOK;
}
*read_only = false;
return EOK;

25
lwext4/ext4_fs.h

@ -48,43 +48,60 @@
#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);
int ext4_fs_put_block_group_ref(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);
int ext4_fs_put_inode_ref(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);
/**@brief TODO: ...*/
int ext4_fs_get_inode_data_block_index(struct ext4_inode_ref *inode_ref,
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);
/**@brief TODO: ...*/
int ext4_fs_release_inode_block(struct ext4_inode_ref *inode_ref,
uint32_t iblock);
/**@brief TODO: ...*/
int ext4_fs_append_inode_block(struct ext4_inode_ref *inode_ref,
uint32_t *fblock, uint32_t *iblock);

4
lwext4/ext4_ialloc.h

@ -49,8 +49,10 @@ extern "C" {
#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

16
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 @@ static uint32_t ext4_inode_block_bits_count(uint32_t block_size)
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 @@ void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode,
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 @@ void ext4_inode_set_uid(struct ext4_inode *inode, uint32_t uid)
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);
@ -108,7 +105,6 @@ void ext4_inode_set_size(struct ext4_inode *inode, uint64_t size)
inode->size_hi = to_le32(size >> 32);
}
uint32_t ext4_inode_get_access_time(struct ext4_inode *inode)
{
return to_le32(inode->access_time);
@ -170,7 +166,6 @@ 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 @@ uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,
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,7 +228,6 @@ int ext4_inode_set_blocks_count(struct ext4_sblock *sb,
return EOK;
}
uint32_t ext4_inode_get_flags(struct ext4_inode *inode)
{
return to_le32(inode->flags);
@ -277,8 +269,6 @@ void ext4_inode_set_file_acl(struct ext4_inode *inode, struct ext4_sblock *sb,
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 @@ void ext4_inode_set_direct_block(struct ext4_inode *inode, uint32_t idx,
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]);
@ -341,7 +330,6 @@ bool ext4_inode_can_truncate(struct ext4_sblock *sb,
return false;
}
struct ext4_extent_header * ext4_inode_get_extent_header(
struct ext4_inode *inode)
{

64
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);
void ext4_inode_set_size(struct ext4_inode *inode, uint64_t size);
/**@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);
void ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time);
/**@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);
/**@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);
void ext4_inode_set_links_count(struct ext4_inode *inode, uint16_t cnt);
/**@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);

Loading…
Cancel
Save