From 14dd317f2a50e0ef02aa811f5d3311e879b8e19a Mon Sep 17 00:00:00 2001 From: gkostka Date: Sun, 27 Oct 2013 23:00:15 +0000 Subject: [PATCH] Code format. --- ext4.h | 6 +-- lwext4/ext4.c | 81 +++++++++++++++++-------------------- lwext4/ext4_bcache.c | 2 +- lwext4/ext4_block_group.h | 20 +++++++-- lwext4/ext4_blockdev.c | 54 ++++++++----------------- lwext4/ext4_config.h | 19 +++++---- lwext4/ext4_dir_idx.c | 85 +++++++++++++++++++-------------------- lwext4/ext4_super.c | 8 ++-- 8 files changed, 128 insertions(+), 147 deletions(-) diff --git a/ext4.h b/ext4.h index 053c257..11d33bd 100644 --- a/ext4.h +++ b/ext4.h @@ -163,7 +163,7 @@ typedef struct { * @param bd block device cache (0 = automatic cache mode) * @param dev_name register name * @param standard error code*/ -int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc, +int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc, const char *dev_name); /**@brief Mount a block device with EXT4 partition to the mountpoint. @@ -174,12 +174,12 @@ int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc, * - /my_second_partition/ * * @return standard error code */ -int ext4_mount(const char * dev_name, char *mount_point); +int ext4_mount(const char * dev_name, char *mount_point); /**@brief Umount operation. * @param mount_point mount name * @return standard error code */ -int ext4_umount(char *mount_point); +int ext4_umount(char *mount_point); /**@brief Some of the filesystem stats.*/ diff --git a/lwext4/ext4.c b/lwext4/ext4.c index f567597..60f44fa 100644 --- a/lwext4/ext4.c +++ b/lwext4/ext4.c @@ -50,41 +50,41 @@ #include -/**@brief Mount point OS dependent lock*/ +/**@brief Mount point OS dependent lock*/ #define EXT4_MP_LOCK(_m) \ do { (_m)->os_locks ? (_m)->os_locks->lock() : 0; }while(0) -/**@brief Mount point OS dependent unlock*/ +/**@brief Mount point OS dependent unlock*/ #define EXT4_MP_UNLOCK(_m) \ do { (_m)->os_locks ? (_m)->os_locks->unlock() : 0; }while(0) -/**@brief Mount point descrpitor.*/ +/**@brief Mount point descrpitor.*/ struct ext4_mountpoint { /**@brief Mount point name (@ref ext4_mount)*/ - const char *name; + const char *name; /**@brief Os dependent lock/unlock functions.*/ struct ext4_lock *os_locks; /**@brief Ext4 filesystem internals.*/ - struct ext4_fs fs; + struct ext4_fs fs; /**@brief Dynamic alocation cache flag.*/ - bool cache_dynamic; + bool cache_dynamic; }; -/**@brief Block devices descriptor.*/ +/**@brief Block devices descriptor.*/ struct _ext4_devices { - /**@brief Block device name (@ref ext4_device_register)*/ - const char *name; + /**@brief Block device name (@ref ext4_device_register)*/ + const char *name; - /**@brief Block device handle.*/ - struct ext4_blockdev *bd; + /**@brief Block device handle.*/ + struct ext4_blockdev *bd; - /**@brief Block cache handle.*/ - struct ext4_bcache *bc; + /**@brief Block cache handle.*/ + struct ext4_bcache *bc; }; /**@brief Block devices.*/ @@ -92,11 +92,11 @@ struct _ext4_devices _bdevices[CONFIG_EXT4_BLOCKDEVS_COUNT]; /**@brief Mountpoints.*/ -struct ext4_mountpoint _mp[CONFIG_EXT4_MOUNTPOINTS_COUNT]; +struct ext4_mountpoint _mp[CONFIG_EXT4_MOUNTPOINTS_COUNT]; -int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc, +int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc, const char *dev_name) { uint32_t i; @@ -355,7 +355,6 @@ int ext4_mount(const char * dev_name, char *mount_point) bsize = ext4_sb_get_block_size(&mp->fs.sb); ext4_block_set_lb_size(bd, bsize); - mp->cache_dynamic = 0; if(!bc){ @@ -374,7 +373,6 @@ int ext4_mount(const char * dev_name, char *mount_point) if(bsize != bc->itemsize) return ENOTSUP; - /*Bind block cache to block device*/ r = ext4_block_bind_bcache(bd, bc); if(r != EOK){ @@ -468,7 +466,6 @@ static struct ext4_mountpoint* ext4_get_mount(const char *path) return 0; } - static int ext4_path_check(const char *path, bool* is_goal) { int i; @@ -683,7 +680,6 @@ static int ext4_generic_open (ext4_file *f, const char *path, if(f->flags & O_APPEND) f->fpos = f->fsize; - } r = ext4_fs_put_inode_ref(&ref); @@ -695,11 +691,11 @@ static int ext4_generic_open (ext4_file *f, const char *path, int ext4_fremove(const char *path) { ext4_file f; - uint32_t parent_inode; - uint32_t name_off; - int r; - int len; - bool is_goal; + uint32_t parent_inode; + uint32_t name_off; + int r; + int len; + bool is_goal; struct ext4_mountpoint *mp = ext4_get_mount(path); struct ext4_inode_ref child; @@ -788,7 +784,7 @@ int ext4_fclose(ext4_file *f) } int ext4_fread(ext4_file *f, void *buf, uint32_t size, uint32_t *rcnt) { - int r = EOK; + int r = EOK; uint32_t u; uint32_t fblock; uint32_t fblock_start; @@ -922,7 +918,7 @@ int ext4_fread(ext4_file *f, void *buf, uint32_t size, uint32_t *rcnt) int ext4_fwrite(ext4_file *f, void *buf, uint32_t size, uint32_t *wcnt) { - int r = EOK; + int r = EOK; uint32_t u; uint32_t fblock; struct ext4_block b; @@ -1096,13 +1092,10 @@ int ext4_fwrite(ext4_file *f, void *buf, uint32_t size, uint32_t *wcnt) } - - int ext4_fseek(ext4_file *f, uint64_t offset, uint32_t origin) { switch(origin){ case SEEK_SET: - if(offset > f->fsize) return EINVAL; @@ -1117,43 +1110,45 @@ int ext4_fseek(ext4_file *f, uint64_t offset, uint32_t origin) case SEEK_END: if(offset > f->fsize) return EINVAL; + f->fpos = f->fsize - offset; return EOK; } - return EINVAL; } uint64_t ext4_ftell (ext4_file *f) { - return f->fpos; + return f->fpos; } uint64_t ext4_fsize (ext4_file *f) { - return f->fsize; + return f->fsize; } /*********************************DIRECTORY OPERATION************************/ int ext4_dir_rm(const char *path) { - int r; - int len; - ext4_file f; - struct ext4_mountpoint *mp = ext4_get_mount(path); - struct ext4_inode_ref current; - struct ext4_inode_ref child; + int r; + int len; + ext4_file f; + struct ext4_mountpoint *mp = ext4_get_mount(path); + struct ext4_inode_ref current; + struct ext4_inode_ref child; struct ext4_directory_iterator it; + uint32_t name_off; uint32_t inode_up; uint32_t inode_current; uint32_t depth = 1; - bool has_children; - bool is_goal; - bool dir_end; + + bool has_children; + bool is_goal; + bool dir_end; if(!mp) return ENOENT; @@ -1313,7 +1308,7 @@ int ext4_dir_rm(const char *path) int ext4_dir_mk(const char *path) { int r; - ext4_file f; + ext4_file f; struct ext4_mountpoint *mp = ext4_get_mount(path); @@ -1362,7 +1357,7 @@ int ext4_dir_close(ext4_dir *d) ext4_direntry* ext4_dir_entry_get(ext4_dir *d, uint32_t id) { - int r; + int r; uint32_t i; ext4_direntry *de = 0; struct ext4_inode_ref dir; diff --git a/lwext4/ext4_bcache.c b/lwext4/ext4_bcache.c index bab156b..1ceaacb 100644 --- a/lwext4/ext4_bcache.c +++ b/lwext4/ext4_bcache.c @@ -43,7 +43,7 @@ #include -int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt, +int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt, uint32_t itemsize) { ext4_assert(bc && cnt && itemsize); diff --git a/lwext4/ext4_block_group.h b/lwext4/ext4_block_group.h index b7a4625..29c1ac7 100644 --- a/lwext4/ext4_block_group.h +++ b/lwext4/ext4_block_group.h @@ -50,6 +50,7 @@ #include #include +/**@brief TODO: ...*/ static inline uint64_t ext4_bg_get_block_bitmap(struct ext4_bgroup *bg, struct ext4_sblock *s) { @@ -61,6 +62,7 @@ static inline uint64_t ext4_bg_get_block_bitmap(struct ext4_bgroup *bg, return v; } +/**@brief TODO: ...*/ static inline uint64_t ext4_bg_get_inode_bitmap(struct ext4_bgroup *bg, struct ext4_sblock *s) { @@ -73,6 +75,7 @@ static inline uint64_t ext4_bg_get_inode_bitmap(struct ext4_bgroup *bg, return v; } +/**@brief TODO: ...*/ static inline uint64_t ext4_bg_get_inode_table_first_block( struct ext4_bgroup *bg, struct ext4_sblock *s) { @@ -84,6 +87,7 @@ static inline uint64_t ext4_bg_get_inode_table_first_block( return v; } +/**@brief TODO: ...*/ static inline uint32_t ext4_bg_get_free_blocks_count(struct ext4_bgroup *bg, struct ext4_sblock *s) { @@ -95,6 +99,7 @@ static inline uint32_t ext4_bg_get_free_blocks_count(struct ext4_bgroup *bg, return v; } +/**@brief TODO: ...*/ static inline void ext4_bg_set_free_blocks_count(struct ext4_bgroup *bg, struct ext4_sblock *s, uint32_t cnt) { @@ -103,6 +108,7 @@ static inline void ext4_bg_set_free_blocks_count(struct ext4_bgroup *bg, bg->free_blocks_count_hi = to_le16(cnt >> 16); } +/**@brief TODO: ...*/ static inline uint32_t ext4_bg_get_free_inodes_count(struct ext4_bgroup *bg, struct ext4_sblock *s) { @@ -114,6 +120,7 @@ static inline uint32_t ext4_bg_get_free_inodes_count(struct ext4_bgroup *bg, return v; } +/**@brief TODO: ...*/ static inline void ext4_bg_set_free_inodes_count(struct ext4_bgroup *bg, struct ext4_sblock *s, uint32_t cnt) { @@ -122,7 +129,7 @@ static inline void ext4_bg_set_free_inodes_count(struct ext4_bgroup *bg, bg->free_inodes_count_hi = to_le16(cnt >> 16); } - +/**@brief TODO: ...*/ static inline uint32_t ext4_bg_get_used_dirs_count(struct ext4_bgroup *bg, struct ext4_sblock *s) { @@ -134,6 +141,7 @@ static inline uint32_t ext4_bg_get_used_dirs_count(struct ext4_bgroup *bg, return v; } +/**@brief TODO: ...*/ static inline void ext4_bg_set_used_dirs_count(struct ext4_bgroup *bg, struct ext4_sblock *s, uint32_t cnt) { @@ -142,7 +150,7 @@ static inline void ext4_bg_set_used_dirs_count(struct ext4_bgroup *bg, bg->used_dirs_count_hi = to_le16(cnt >> 16); } - +/**@brief TODO: ...*/ static inline uint32_t ext4_bg_get_itable_unused(struct ext4_bgroup *bg, struct ext4_sblock *s) { @@ -155,6 +163,7 @@ static inline uint32_t ext4_bg_get_itable_unused(struct ext4_bgroup *bg, return v; } +/**@brief TODO: ...*/ static inline void ext4_bg_set_itable_unused(struct ext4_bgroup *bg, struct ext4_sblock *s, uint32_t cnt) { @@ -163,18 +172,20 @@ static inline void ext4_bg_set_itable_unused(struct ext4_bgroup *bg, bg->itable_unused_hi = to_le16(cnt >> 16); } - +/**@brief TODO: ...*/ static inline void ext4_bg_set_checksum(struct ext4_bgroup *bg, uint16_t crc) { bg->checksum = to_le16(crc); } +/**@brief TODO: ...*/ static inline bool ext4_bg_has_flag(struct ext4_bgroup *bg, uint32_t f) { return to_le16(bg->flags) & f; } +/**@brief TODO: ...*/ static inline void ext4_bg_set_flag(struct ext4_bgroup *bg, uint32_t f) { uint16_t flags = to_le16(bg->flags); @@ -182,6 +193,7 @@ static inline void ext4_bg_set_flag(struct ext4_bgroup *bg, uint32_t f) bg->flags = to_le16(flags); } +/**@brief TODO: ...*/ static inline void ext4_bg_clear_flag(struct ext4_bgroup *bg, uint32_t f) { uint16_t flags = to_le16(bg->flags); @@ -189,7 +201,7 @@ static inline void ext4_bg_clear_flag(struct ext4_bgroup *bg, uint32_t f) bg->flags = to_le16(flags); } - +/**@brief TODO: ...*/ uint16_t ext4_bg_crc16(uint16_t crc, const uint8_t *buffer, size_t len); #endif /* EXT4_BLOCK_GROUP_H_ */ diff --git a/lwext4/ext4_blockdev.c b/lwext4/ext4_blockdev.c index a6c7323..eaf7e68 100644 --- a/lwext4/ext4_blockdev.c +++ b/lwext4/ext4_blockdev.c @@ -94,9 +94,10 @@ int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b, { uint64_t pba; uint32_t pb_cnt; - bool is_new; - int r; uint32_t i; + bool is_new; + int r; + ext4_assert(bdev && b); if(!(bdev->flags & EXT4_BDEV_INITIALIZED)) @@ -148,9 +149,8 @@ int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b, if(!b->data) return ENOMEM; - pba = (lba * bdev->lg_bsize) / bdev->ph_bsize; - pb_cnt = bdev->lg_bsize / bdev->ph_bsize; - + pba = (lba * bdev->lg_bsize) / bdev->ph_bsize; + pb_cnt = bdev->lg_bsize / bdev->ph_bsize; r = bdev->bread(bdev, b->data, pba, pb_cnt); @@ -161,7 +161,6 @@ int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b, } bdev->bread_ctr++; - return EOK; } @@ -189,8 +188,8 @@ int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b) return ext4_bcache_free(bdev->bc, b, bdev->cache_flush_delay); } - pba = (b->lb_id * bdev->lg_bsize) / bdev->ph_bsize; - pb_cnt = bdev->lg_bsize / bdev->ph_bsize; + pba = (b->lb_id * bdev->lg_bsize) / bdev->ph_bsize; + pb_cnt = bdev->lg_bsize / bdev->ph_bsize; r = bdev->bwrite(bdev, b->data, pba, pb_cnt); @@ -215,16 +214,13 @@ int ext4_blocks_get_direct(struct ext4_blockdev *bdev, void *buf, ext4_assert(bdev && buf); - pba = (lba * bdev->lg_bsize) / bdev->ph_bsize; - pb_cnt = bdev->lg_bsize / bdev->ph_bsize; + pba = (lba * bdev->lg_bsize) / bdev->ph_bsize; + pb_cnt = bdev->lg_bsize / bdev->ph_bsize; bdev->bread_ctr++; - return bdev->bread(bdev, buf, pba, pb_cnt * cnt); } - - int ext4_blocks_set_direct(struct ext4_blockdev *bdev, const void *buf, uint64_t lba, uint32_t cnt) { @@ -233,8 +229,8 @@ int ext4_blocks_set_direct(struct ext4_blockdev *bdev, const void *buf, ext4_assert(bdev && buf); - pba = (lba * bdev->lg_bsize) / bdev->ph_bsize; - pb_cnt = bdev->lg_bsize / bdev->ph_bsize; + pba = (lba * bdev->lg_bsize) / bdev->ph_bsize; + pb_cnt = bdev->lg_bsize / bdev->ph_bsize; bdev->bwrite_ctr++; @@ -247,11 +243,9 @@ int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, { uint64_t block_idx; uint64_t block_end; - uint32_t blen; - uint32_t unalg; - int r = EOK; + int r = EOK; const uint8_t *p = (void *)buf; @@ -260,14 +254,12 @@ int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, if(!(bdev->flags & EXT4_BDEV_INITIALIZED)) return EIO; - block_idx = off / bdev->ph_bsize; block_end = block_idx + len / bdev->ph_bsize; if(!(block_end < bdev->ph_bcnt)) return EINVAL; /*Ups. Out of range operation*/ - /*OK lets deal with the first possible unaligned block*/ unalg = (off & (bdev->ph_bsize - 1)); if(unalg){ @@ -283,7 +275,6 @@ int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, memcpy(bdev->ph_bbuf + unalg, p, wlen); r = bdev->bwrite(bdev, bdev->ph_bbuf, block_idx, 1); - if(r != EOK) return r; @@ -295,13 +286,12 @@ int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, /*Aligned data*/ blen = len / bdev->ph_bsize; - r = bdev->bwrite(bdev, p, block_idx, blen); if(r != EOK) return r; - p += bdev->ph_bsize * blen; + p += bdev->ph_bsize * blen; len -= bdev->ph_bsize * blen; block_idx += blen; @@ -309,9 +299,7 @@ int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, /*Rest of the data*/ if(len){ - r = bdev->bread(bdev, bdev->ph_bbuf, block_idx, 1); - if(r != EOK) return r; @@ -332,13 +320,11 @@ int ext4_block_writebytes(struct ext4_blockdev *bdev, uint64_t off, int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf, uint32_t len) { - uint64_t block_idx; uint64_t block_end; uint32_t blen; - uint32_t unalg; - int r = EOK; + int r = EOK; uint8_t *p = (void *)buf; @@ -347,14 +333,12 @@ int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf, if(!(bdev->flags & EXT4_BDEV_INITIALIZED)) return EIO; - - block_idx = off / bdev->ph_bsize; - block_end = block_idx + len / bdev->ph_bsize; + block_idx = off / bdev->ph_bsize; + block_end = block_idx + len / bdev->ph_bsize; if(!(block_end < bdev->ph_bcnt)) return EINVAL; /*Ups. Out of range operation*/ - /*OK lets deal with the first possible unaligned block*/ unalg = (off & (bdev->ph_bsize - 1)); if(unalg){ @@ -363,7 +347,6 @@ int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf, len : (bdev->ph_bsize - unalg); r = bdev->bread(bdev, bdev->ph_bbuf, block_idx, 1); - if(r != EOK) return r; @@ -374,7 +357,6 @@ int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf, block_idx++; } - /*Aligned data*/ blen = len / bdev->ph_bsize; @@ -391,14 +373,11 @@ int ext4_block_readbytes(struct ext4_blockdev *bdev, uint64_t off, void *buf, /*Rest of the data*/ if(len){ - r = bdev->bread(bdev, bdev->ph_bbuf, block_idx, 1); - if(r != EOK) return r; memcpy(p, bdev->ph_bbuf, len); - } return r; @@ -437,7 +416,6 @@ int ext4_block_delay_cache_flush(struct ext4_blockdev *bdev, bdev->bc->ref_blocks--; } } - return EOK; } diff --git a/lwext4/ext4_config.h b/lwext4/ext4_config.h index 5080256..2f103c0 100644 --- a/lwext4/ext4_config.h +++ b/lwext4/ext4_config.h @@ -44,54 +44,53 @@ /**@brief Enable directory indexing feature (EXT3 feature)*/ #ifndef CONFIG_DIR_INDEX_ENABLE -#define CONFIG_DIR_INDEX_ENABLE 1 +#define CONFIG_DIR_INDEX_ENABLE 1 #endif /**@brief Enable extents feature (EXT4 feature)*/ #ifndef CONFIG_EXTENT_ENABLE -#define CONFIG_EXTENT_ENABLE 1 +#define CONFIG_EXTENT_ENABLE 1 #endif /**@brief Include error codes from ext4_errno or sandard library.*/ #ifndef CONFIG_HAVE_OWN_ERRNO -#define CONFIG_HAVE_OWN_ERRNO 1 +#define CONFIG_HAVE_OWN_ERRNO 1 #endif /**@brief Debug printf enable (stdout)*/ #ifndef CONFIG_DEBUG_PRINTF -#define CONFIG_DEBUG_PRINTF 1 +#define CONFIG_DEBUG_PRINTF 1 #endif /**@brief Assert printf enable (stdout)*/ #ifndef CONFIG_DEBUG_ASSERT -#define CONFIG_DEBUG_ASSERT 1 +#define CONFIG_DEBUG_ASSERT 1 #endif /**@brief Statistics of block device*/ #ifndef CONFIG_BLOCK_DEV_ENABLE_STATS -#define CONFIG_BLOCK_DEV_ENABLE_STATS 1 +#define CONFIG_BLOCK_DEV_ENABLE_STATS 1 #endif /**@brief Cache size of block device.*/ #ifndef CONFIG_BLOCK_DEV_CACHE_SIZE -#define CONFIG_BLOCK_DEV_CACHE_SIZE 8 +#define CONFIG_BLOCK_DEV_CACHE_SIZE 8 #endif /**@brief Ilosc urzadzen blokowych.*/ #ifndef CONFIG_EXT4_BLOCKDEVS_COUNT -#define CONFIG_EXT4_BLOCKDEVS_COUNT 2 +#define CONFIG_EXT4_BLOCKDEVS_COUNT 2 #endif /**@brief Ilosc punktow montowania systemu plikow*/ #ifndef CONFIG_EXT4_MOUNTPOINTS_COUNT -#define CONFIG_EXT4_MOUNTPOINTS_COUNT 2 +#define CONFIG_EXT4_MOUNTPOINTS_COUNT 2 #endif - #endif /* EXT4_CONFIG_H_ */ /** diff --git a/lwext4/ext4_dir_idx.c b/lwext4/ext4_dir_idx.c index 4a75a35..6f52462 100644 --- a/lwext4/ext4_dir_idx.c +++ b/lwext4/ext4_dir_idx.c @@ -48,7 +48,7 @@ struct ext4_dx_sort_entry { uint32_t hash; uint32_t rec_len; - void *dentry; + void *dentry; }; static int ext4_dir_dx_hash_string(struct ext4_hash_info *hinfo, int len, @@ -60,37 +60,37 @@ static int ext4_dir_dx_hash_string(struct ext4_hash_info *hinfo, int len, uint8_t ext4_dir_dx_root_info_get_hash_version( - struct ext4_directory_dx_root_info *root_info) + 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) +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) + 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) +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) + 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) + struct ext4_directory_dx_root_info *root_info, uint8_t lvl) { root_info->indirect_levels = lvl; } @@ -98,53 +98,53 @@ void ext4_dir_dx_root_info_set_indirect_levels( uint16_t ext4_dir_dx_countlimit_get_limit( - struct ext4_directory_dx_countlimit *climit) + 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) +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) + 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) +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) + 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) + 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) + 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) +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) +int ext4_dir_dx_init(struct ext4_inode_ref *dir) { /* Load block 0, where will be index root located */ uint32_t fblock; @@ -165,7 +165,6 @@ int ext4_dir_dx_init(struct ext4_inode_ref *dir) /* Initialize root info structure */ uint8_t hash_version = ext4_get8(&dir->fs->sb, default_hash_version); - ext4_dir_dx_root_info_set_hash_version(info, hash_version); ext4_dir_dx_root_info_set_indirect_levels(info, 0); ext4_dir_dx_root_info_set_info_length(info, 8); @@ -223,8 +222,8 @@ int ext4_dir_dx_init(struct ext4_inode_ref *dir) } static int ext4_dir_hinfo_init(struct ext4_hash_info *hinfo, - struct ext4_block *root_block, struct ext4_sblock *sb, size_t name_len, - const char *name) + struct ext4_block *root_block, 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; @@ -276,9 +275,9 @@ static int ext4_dir_hinfo_init(struct ext4_hash_info *hinfo, 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_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_directory_dx_block *tmp_dx_block = dx_blocks; struct ext4_directory_dx_root *root = @@ -368,8 +367,8 @@ static int ext4_dir_dx_get_leaf(struct ext4_hash_info *hinfo, } 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) + uint32_t hash, struct ext4_directory_dx_block *dx_block, + struct ext4_directory_dx_block *dx_blocks) { uint32_t num_handles = 0; struct ext4_directory_dx_block *p = dx_block; @@ -432,7 +431,7 @@ static int ext4_dir_dx_next_block(struct ext4_inode_ref *inode_ref, int ext4_dir_dx_find_entry(struct ext4_directory_search_result * result, - struct ext4_inode_ref *inode_ref, size_t name_len, const char *name) + struct ext4_inode_ref *inode_ref, size_t name_len, const char *name) { /* Load direct block 0 (index root) */ uint32_t root_block_addr; @@ -543,8 +542,8 @@ static int ext4_dir_dx_entry_comparator(const void *arg1, const void *arg2) } static void ext4_dir_dx_insert_entry( - struct ext4_directory_dx_block *index_block, uint32_t hash, - uint32_t iblock) + struct ext4_directory_dx_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; @@ -567,9 +566,9 @@ static void ext4_dir_dx_insert_entry( } 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_block *new_data_block) + struct ext4_hash_info *hinfo, struct ext4_block *old_data_block, + struct ext4_directory_dx_block *index_block, + struct ext4_block *new_data_block) { int rc = EOK; @@ -639,7 +638,7 @@ static int ext4_dir_dx_split_data(struct ext4_inode_ref *inode_ref, /* Sort all entries */ qsort(sort_array, idx, sizeof(struct ext4_dx_sort_entry), - ext4_dir_dx_entry_comparator); + ext4_dir_dx_entry_comparator); /* Allocate new block for store the second part of entries */ uint32_t new_fblock; @@ -729,7 +728,7 @@ static int ext4_dir_dx_split_data(struct ext4_inode_ref *inode_ref, free(entry_buffer); ext4_dir_dx_insert_entry(index_block, new_hash + continued, - new_iblock); + new_iblock); *new_data_block = new_data_block_tmp; @@ -746,9 +745,9 @@ static int ext4_dir_dx_split_data(struct ext4_inode_ref *inode_ref, * */ 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_directory_dx_block *dx_blocks, + struct ext4_directory_dx_block *dx_block, + struct ext4_directory_dx_block **new_dx_block) { struct ext4_directory_dx_entry *entries; @@ -819,7 +818,7 @@ static int ext4_dir_dx_split_index(struct ext4_inode_ref *inode_ref, /* Copy data to new node */ memcpy((void *) new_entries, (void *) (entries + count_left), - count_right * sizeof(struct ext4_directory_dx_entry)); + count_right * sizeof(struct ext4_directory_dx_entry)); /* Initialize new node */ struct ext4_directory_dx_countlimit *left_countlimit = @@ -902,8 +901,8 @@ static int ext4_dir_dx_split_index(struct ext4_inode_ref *inode_ref, return EOK; } -int ext4_dir_dx_add_entry(struct ext4_inode_ref *parent, - struct ext4_inode_ref *child, const char *name) +int ext4_dir_dx_add_entry(struct ext4_inode_ref *parent, + struct ext4_inode_ref *child, const char *name) { int rc2 = EOK; diff --git a/lwext4/ext4_super.c b/lwext4/ext4_super.c index c40a539..15cfc50 100644 --- a/lwext4/ext4_super.c +++ b/lwext4/ext4_super.c @@ -73,7 +73,7 @@ uint32_t ext4_inodes_in_group_cnt(struct ext4_sblock *s, uint32_t bgid) { uint32_t block_group_count = ext4_block_group_cnt(s); uint32_t inodes_per_group = ext4_get32(s, inodes_per_group); - uint32_t total_inodes = ext4_get32(s, inodes_count); + uint32_t total_inodes = ext4_get32(s, inodes_count); if (bgid < block_group_count - 1) @@ -117,12 +117,10 @@ bool ext4_sb_check(struct ext4_sblock *s) if (ext4_get32(s, first_inode) < 11) return false; - if (ext4_sb_get_desc_size(s) < - EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) + if (ext4_sb_get_desc_size(s) < EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE) return false; - if (ext4_sb_get_desc_size(s) > - EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE) + if (ext4_sb_get_desc_size(s) > EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE) return false; return true; -- 2.30.2