shithub: lwext4

Download patch

ref: 5f8ffa50abd0840ea008547df257524abc880da5
parent: 0f9ff0446d301b8016b261d27f8a382c54364d34
author: gkostka <kostka.grzegorz@gmail.com>
date: Mon Oct 7 17:21:09 EDT 2013

Code format.

--- a/src/ext4.h
+++ b/src/ext4.h
@@ -72,7 +72,7 @@
 #define O_APPEND	02000
 #endif
 
-/********************************FILE SEEK FLAGS********************************/
+/********************************FILE SEEK FLAGS*****************************/
 
 #ifndef SEEK_SET
 #define SEEK_SET	0
@@ -86,7 +86,7 @@
 #define SEEK_END	2
 #endif
 
-/********************************OS LOCK INFERFACE****************************/
+/********************************OS LOCK INFERFACE***************************/
 
 /**@brief	OS dependent lock interface.*/
 struct ext4_lock {
@@ -99,7 +99,7 @@
 };
 
 
-/********************************FILE DESCRIPTOR******************************/
+/********************************FILE DESCRIPTOR*****************************/
 
 /**@brief	File descriptor*/
 typedef struct ext4_file {
@@ -120,7 +120,7 @@
     uint64_t fpos;
 }ext4_file;
 
-/*****************************DIRECTORY DESCRIPTOR****************************/
+/*****************************DIRECTORY DESCRIPTOR***************************/
 /**@brief	Directory entry types. Copy from ext4_types.h*/
 enum  {
     EXT4_DIRENTRY_UNKNOWN = 0,
@@ -152,13 +152,13 @@
     ext4_direntry	de;
 }ext4_dir;
 
-/********************************MOUNT OPERATIONS*****************************/
+/********************************MOUNT OPERATIONS****************************/
 
 /**@brief	Register a block device to a name.
  *          @warning Block device has to be filled by
  *          @ref EXT4_BLOCKDEV_STATIC_INSTANCE. Block cache may be created
  *          @ref EXT4_BCACHE_STATIC_INSTANCE.
- * 			Block cache may by created automaticly when bc parameter is 0.
+ *          Block cache may by created automaticly when bc parameter is 0.
  * @param   bd block device
  * @param   bd block device cache (0 = automatic cache mode)
  * @param   dev_name register name
@@ -224,7 +224,7 @@
 /**@brief	*/
 uint64_t ext4_fsize (ext4_file *f);
 
-/*********************************DIRECTORY OPERATION************************/
+/*********************************DIRECTORY OPERATION***********************/
 /**@brief	*/
 int ext4_mkdir(const char *path);
 
--- a/src/lwext4/ext4.c
+++ b/src/lwext4/ext4.c
@@ -113,7 +113,7 @@
     return ENOSPC;
 }
 
-/******************************************************************************/
+/****************************************************************************/
 
 
 static bool ext4_is_dots(const uint8_t *name, size_t name_size)
@@ -237,8 +237,9 @@
     return EOK;
 }
 
-static int ext4_unlink(struct ext4_mountpoint *mp, struct ext4_inode_ref *parent,
-        struct ext4_inode_ref *child_inode_ref, const char *name)
+static int ext4_unlink(struct ext4_mountpoint *mp,
+    struct ext4_inode_ref *parent, struct ext4_inode_ref *child_inode_ref,
+    const char *name)
 {
     bool has_children;
     int rc = ext4_has_children(&has_children, child_inode_ref);
@@ -301,7 +302,7 @@
     return EOK;
 }
 
-/*****************************************************************************/
+/****************************************************************************/
 
 int			ext4_mount(const char * dev_name,  char *mount_point)
 {
@@ -418,7 +419,7 @@
 }
 
 
-/********************************FILE OPERATIONS******************************/
+/********************************FILE OPERATIONS*****************************/
 
 static struct ext4_mountpoint*  ext4_get_mount(const char *path)
 {
@@ -492,7 +493,7 @@
     return false;
 }
 
-/*****************************************************************************/
+/****************************************************************************/
 
 static int ext4_generic_open (ext4_file *f, const char *path,
         const char *flags, bool file_expect)
@@ -572,7 +573,8 @@
             if(r != EOK){
                 /*Fali. Free new inode.*/
                 ext4_fs_free_inode(&child_ref);
-                /*We do not want to write new inode. But block has to be released.*/
+                /*We do not want to write new inode.
+                  But block has to be released.*/
                 child_ref.dirty = false;
                 ext4_fs_put_inode_ref(&child_ref);
                 break;
@@ -591,13 +593,15 @@
             break;
 
         /*If expected file error*/
-        if((inode_type == EXT4_DIRECTORY_FILETYPE_REG_FILE) && !file_expect && is_goal){
+        if((inode_type == EXT4_DIRECTORY_FILETYPE_REG_FILE)
+                && !file_expect && is_goal){
             r = ENOENT;
             break;
         }
 
         /*If expected directory error*/
-        if((inode_type == EXT4_DIRECTORY_FILETYPE_DIR) && file_expect && is_goal){
+        if((inode_type == EXT4_DIRECTORY_FILETYPE_DIR)
+                && file_expect && is_goal){
             r = ENOENT;
             break;
         }
@@ -628,7 +632,8 @@
         if(f->flags & O_TRUNC){
             /*Turncate.*/
             ext4_block_delay_cache_flush(mp->fs.bdev, 1);
-            /*Truncate may be IO heavy. Do it with delayed cache flush mode.*/
+            /*Truncate may be IO heavy.
+             Do it with delayed cache flush mode.*/
             r = ext4_fs_truncate_inode(&ref, 0);
             ext4_block_delay_cache_flush(mp->fs.bdev, 0);
 
@@ -654,7 +659,7 @@
     return r;
 }
 
-/*****************************************************************************/
+/****************************************************************************/
 
 int ext4_fremove(const char *path)
 {
@@ -1119,7 +1124,7 @@
     return  f->fsize;
 }
 
-/*********************************DIRECTORY OPERATION***************************/
+/*********************************DIRECTORY OPERATION************************/
 
 int	ext4_dir_open (ext4_dir *d, const char *path)
 {
--- a/src/lwext4/ext4_bcache.c
+++ b/src/lwext4/ext4_bcache.c
@@ -43,7 +43,8 @@
 #include <stdlib.h>
 
 
-int	ext4_bcache_init_dynamic(struct	ext4_bcache *bc, uint32_t cnt, uint32_t itemsize)
+int	ext4_bcache_init_dynamic(struct	ext4_bcache *bc, uint32_t cnt,
+    uint32_t itemsize)
 {
     ext4_assert(bc && cnt && itemsize);
 
@@ -136,7 +137,8 @@
 }
 
 
-int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b, bool *is_new)
+int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b,
+    bool *is_new)
 {
     uint32_t i;
     ext4_assert(bc && b && is_new);
@@ -221,11 +223,13 @@
         return EOK;
     }
 
-    ext4_dprintf(EXT4_DEBUG_BCACHE, "ext4_bcache_alloc: FAIL, unable to alloc block cache!\n");
+    ext4_dprintf(EXT4_DEBUG_BCACHE,
+        "ext4_bcache_alloc: FAIL, unable to alloc block cache!\n");
     return ENOMEM;
 }
 
-int ext4_bcache_free (struct ext4_bcache *bc, struct ext4_block *b, uint8_t free_delay)
+int ext4_bcache_free (struct ext4_bcache *bc, struct ext4_block *b,
+    uint8_t free_delay)
 {
     uint32_t i;
 
@@ -261,7 +265,8 @@
         return EOK;
     }
 
-    ext4_dprintf(EXT4_DEBUG_BCACHE, "ext4_bcache_free: FAIL, block should be in cache memory !\n");
+    ext4_dprintf(EXT4_DEBUG_BCACHE,
+        "ext4_bcache_free: FAIL, block should be in cache memory !\n");
     return EFAULT;
 }
 
--- a/src/lwext4/ext4_bcache.h
+++ b/src/lwext4/ext4_bcache.h
@@ -91,21 +91,21 @@
 };
 
 /**@brief	Static initializer of block cache structure.*/
-#define EXT4_BCACHE_STATIC_INSTANCE(__name, __cnt, __itemsize)	\
-        static uint32_t	__name##_refctr[(__cnt)];					\
-        static uint32_t	__name##_lru_id[(__cnt)];					\
-        static uint8_t		__name##_free_delay[(__cnt)];			\
-        static uint64_t	__name##_lba[(__cnt)];						\
-        static uint8_t 	__name##_data[(__cnt) * (__itemsize)];		\
-        static struct ext4_bcache	__name = {						\
-                .cnt 	   = __cnt,										\
-                .itemsize  = __itemsize,								\
-                .lru_ctr   = 0,											\
-                .refctr	   = __name##_refctr,							\
-                .lru_id    = __name##_lru_id,							\
-                .lba	   = __name##_lba,								\
-                .free_delay= __name##_free_delay,						\
-                .data	   = __name##_data,								\
+#define EXT4_BCACHE_STATIC_INSTANCE(__name, __cnt, __itemsize)      \
+        static uint32_t	__name##_refctr[(__cnt)];                   \
+        static uint32_t	__name##_lru_id[(__cnt)];                   \
+        static uint8_t		__name##_free_delay[(__cnt)];           \
+        static uint64_t	__name##_lba[(__cnt)];                      \
+        static uint8_t 	__name##_data[(__cnt) * (__itemsize)];      \
+        static struct ext4_bcache	__name = {                      \
+                .cnt 	   = __cnt,                                 \
+                .itemsize  = __itemsize,                            \
+                .lru_ctr   = 0,                                     \
+                .refctr	   = __name##_refctr,                       \
+                .lru_id    = __name##_lru_id,                       \
+                .lba	   = __name##_lba,                          \
+                .free_delay= __name##_free_delay,                   \
+                .data	   = __name##_data,                         \
         }
 
 
@@ -114,7 +114,8 @@
  * @param	cnt items count in block cache
  * @param	itemsize single item size (in bytes)
  * @return	standard error code*/
-int	ext4_bcache_init_dynamic(struct	ext4_bcache *bc, uint32_t cnt, uint32_t itemsize);
+int	ext4_bcache_init_dynamic(struct	ext4_bcache *bc, uint32_t cnt,
+    uint32_t itemsize);
 
 /**@brief	Dynamic de-initialization of block cache.
  * @param	bc block cache descriptor
@@ -121,19 +122,22 @@
  * @return	standard error code*/
 int ext4_bcache_fini_dynamic(struct	ext4_bcache *bc);
 
-/**@brief	Allocate block from block cache memory. Unreferenced block allocation is based
- * 			on LRU (Last Recently Used) algorithm.
+/**@brief	Allocate block from block cache memory.
+ *          Unreferenced block allocation is based on LRU
+ *          (Last Recently Used) algorithm.
  * @param 	bc	block cache descriptor
  * @param	b block to alloc
  * @param	is_new block is new (needs to be read)
  * @return  standard error code*/
-int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b, bool *is_new);
+int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b,
+    bool *is_new);
 
 /**@brief	Free block from cache memory (decrement reference counter).
  * @param 	bc	block cache descriptor
  * @param	b block to free
  * @return  standard error code*/
-int ext4_bcache_free (struct ext4_bcache *bc, struct ext4_block *b, uint8_t free_delay);
+int ext4_bcache_free (struct ext4_bcache *bc, struct ext4_block *b,
+    uint8_t free_delay);
 
 
 /**@brief	Return a full status of block cache.
--- a/src/lwext4/ext4_bitmap.c
+++ b/src/lwext4/ext4_bitmap.c
@@ -40,7 +40,7 @@
 #include <ext4_errno.h>
 
 
-void	ext4_bmap_bits_free(uint8_t *bmap, uint32_t sbit, uint32_t bcnt)
+void ext4_bmap_bits_free(uint8_t *bmap, uint32_t sbit, uint32_t bcnt)
 {
     uint32_t i;
 
@@ -93,7 +93,8 @@
 
 
 
-int 	ext4_bmap_bit_find_clr(uint8_t *bmap, uint32_t sbit, uint32_t ebit, uint32_t *bit_id)
+int ext4_bmap_bit_find_clr(uint8_t *bmap, uint32_t sbit, uint32_t ebit,
+    uint32_t *bit_id)
 {
     uint32_t i;
     uint32_t bcnt = ebit - sbit;
--- a/src/lwext4/ext4_bitmap.h
+++ b/src/lwext4/ext4_bitmap.h
@@ -45,7 +45,7 @@
 /**@brief	Set bitmap bit.
  * @param	bmap bitmap
  * @param	bit	 bit to set*/
-static inline void	ext4_bmap_bit_set(uint8_t *bmap, uint32_t bit)
+static inline void ext4_bmap_bit_set(uint8_t *bmap, uint32_t bit)
 {
     *(bmap + (bit >> 3)) |= (1 << (bit & 7));
 }
@@ -53,7 +53,7 @@
 /**@brief	Clear bitmap bit.
  * @param	bmap bitmap buffer
  * @param	bit	 bit to clear*/
-static inline void	ext4_bmap_bit_clr(uint8_t *bmap, uint32_t bit)
+static inline void ext4_bmap_bit_clr(uint8_t *bmap, uint32_t bit)
 {
     *(bmap + (bit >> 3)) &= ~(1 << (bit & 7));
 }
@@ -62,7 +62,7 @@
 /**@brief	Check if the bitmap bit is set.
  * @param	bmap bitmap buffer
  * @param	bit	 bit to check*/
-static inline bool	 ext4_bmap_is_bit_set(uint8_t *bmap, uint32_t bit)
+static inline bool ext4_bmap_is_bit_set(uint8_t *bmap, uint32_t bit)
 {
     return (*(bmap + (bit >> 3)) & (1 << (bit & 7)));
 }
@@ -70,7 +70,7 @@
 /**@brief	Check if the bitmap bit is clear.
  * @param	bmap bitmap buffer
  * @param	bit	 bit to check*/
-static inline bool	 ext4_bmap_is_bit_clr(uint8_t *bmap, uint32_t bit)
+static inline bool ext4_bmap_is_bit_clr(uint8_t *bmap, uint32_t bit)
 {
     return !ext4_bmap_is_bit_set(bmap, bit);
 }
@@ -79,7 +79,7 @@
  * @param	bmap bitmap buffer
  * @param	sbit start bit
  * @param	bcnt bit count*/
-void	ext4_bmap_bits_free(uint8_t *bmap, uint32_t sbit, uint32_t bcnt);
+void ext4_bmap_bits_free(uint8_t *bmap, uint32_t sbit, uint32_t bcnt);
 
 /**@brief	Find first clear bit in bitmap.
  * @param	sbit start bit of search
@@ -86,7 +86,8 @@
  * @param	ebit end bit of search
  * @param	bit_id output parameter (first free bit)
  * @return	standard error code*/
-int 	ext4_bmap_bit_find_clr(uint8_t *bmap, uint32_t sbit, uint32_t ebit, uint32_t *bit_id);
+int ext4_bmap_bit_find_clr(uint8_t *bmap, uint32_t sbit, uint32_t ebit,
+    uint32_t *bit_id);
 
 
 #endif /* EXT4_BITMAP_H_ */
--- a/src/lwext4/ext4_block_group.h
+++ b/src/lwext4/ext4_block_group.h
@@ -50,7 +50,8 @@
 #include <stdint.h>
 #include <stdbool.h>
 
-static inline uint64_t ext4_bg_get_block_bitmap(struct ext4_bgroup *bg, struct ext4_sblock *s)
+static inline uint64_t ext4_bg_get_block_bitmap(struct ext4_bgroup *bg,
+    struct ext4_sblock *s)
 {
     uint64_t v = to_le32(bg->block_bitmap_lo);
 
@@ -60,7 +61,8 @@
     return v;
 }
 
-static inline uint64_t ext4_bg_get_inode_bitmap(struct ext4_bgroup *bg, struct ext4_sblock *s)
+static inline uint64_t ext4_bg_get_inode_bitmap(struct ext4_bgroup *bg,
+    struct ext4_sblock *s)
 {
 
     uint64_t v = to_le32(bg->inode_bitmap_lo);
@@ -71,7 +73,8 @@
     return v;
 }
 
-static inline uint64_t ext4_bg_get_inode_table_first_block(struct ext4_bgroup *bg, struct ext4_sblock *s)
+static inline uint64_t ext4_bg_get_inode_table_first_block(
+    struct ext4_bgroup *bg, struct ext4_sblock *s)
 {
     uint64_t v = to_le32(bg->inode_table_first_block_lo);
 
@@ -81,7 +84,8 @@
     return v;
 }
 
-static inline uint32_t ext4_bg_get_free_blocks_count(struct ext4_bgroup *bg, struct ext4_sblock *s)
+static inline uint32_t ext4_bg_get_free_blocks_count(struct ext4_bgroup *bg,
+    struct ext4_sblock *s)
 {
     uint32_t v = to_le16(bg->free_blocks_count_lo);
 
@@ -91,7 +95,8 @@
     return v;
 }
 
-static inline void 	 ext4_bg_set_free_blocks_count(struct ext4_bgroup *bg, struct ext4_sblock *s, uint32_t cnt)
+static inline void 	 ext4_bg_set_free_blocks_count(struct ext4_bgroup *bg,
+    struct ext4_sblock *s, uint32_t cnt)
 {
     bg->free_blocks_count_lo = to_le16((cnt << 16) >> 16);
     if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
@@ -98,7 +103,8 @@
         bg->free_blocks_count_hi = to_le16(cnt >> 16);
 }
 
-static inline uint32_t ext4_bg_get_free_inodes_count(struct ext4_bgroup *bg, struct ext4_sblock *s)
+static inline uint32_t ext4_bg_get_free_inodes_count(struct ext4_bgroup *bg,
+    struct ext4_sblock *s)
 {
     uint32_t v = to_le16(bg->free_inodes_count_lo);
 
@@ -108,7 +114,8 @@
     return v;
 }
 
-static inline void 	 ext4_bg_set_free_inodes_count(struct ext4_bgroup *bg, struct ext4_sblock *s, uint32_t cnt)
+static inline void 	 ext4_bg_set_free_inodes_count(struct ext4_bgroup *bg,
+    struct ext4_sblock *s, uint32_t cnt)
 {
     bg->free_inodes_count_lo = to_le16((cnt << 16) >> 16);
     if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
@@ -116,7 +123,8 @@
 }
 
 
-static inline uint32_t ext4_bg_get_used_dirs_count(struct ext4_bgroup *bg, struct ext4_sblock *s)
+static inline uint32_t ext4_bg_get_used_dirs_count(struct ext4_bgroup *bg,
+    struct ext4_sblock *s)
 {
     uint32_t v = to_le16(bg->used_dirs_count_lo);
 
@@ -126,7 +134,8 @@
     return v;
 }
 
-static inline void 	 ext4_bg_set_used_dirs_count(struct ext4_bgroup *bg, struct ext4_sblock *s, uint32_t cnt)
+static inline void 	 ext4_bg_set_used_dirs_count(struct ext4_bgroup *bg,
+    struct ext4_sblock *s, uint32_t cnt)
 {
     bg->used_dirs_count_lo = to_le16((cnt << 16) >> 16);
     if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
@@ -134,7 +143,8 @@
 }
 
 
-static inline uint32_t ext4_bg_get_itable_unused(struct ext4_bgroup *bg, struct ext4_sblock *s)
+static inline uint32_t ext4_bg_get_itable_unused(struct ext4_bgroup *bg,
+    struct ext4_sblock *s)
 {
 
     uint32_t v = to_le16(bg->itable_unused_lo);
@@ -145,7 +155,8 @@
     return v;
 }
 
-static inline void 	 ext4_bg_set_itable_unused(struct ext4_bgroup *bg, struct ext4_sblock *s, uint32_t cnt)
+static inline void 	 ext4_bg_set_itable_unused(struct ext4_bgroup *bg,
+    struct ext4_sblock *s, uint32_t cnt)
 {
     bg->itable_unused_lo = to_le16((cnt << 16) >> 16);
     if (ext4_sb_get_desc_size(s) > EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
@@ -153,7 +164,8 @@
 }
 
 
-static inline void 	 ext4_bg_set_checksum(struct ext4_bgroup *bg, uint16_t crc)
+static inline void 	 ext4_bg_set_checksum(struct ext4_bgroup *bg,
+    uint16_t crc)
 {
     bg->checksum = to_le16(crc);
 }
--- a/src/lwext4/ext4_blockdev.c
+++ b/src/lwext4/ext4_blockdev.c
@@ -89,7 +89,8 @@
 }
 
 
-int ext4_block_get(struct	ext4_blockdev *bdev, struct	ext4_block *b, uint64_t lba)
+int ext4_block_get(struct	ext4_blockdev *bdev, struct	ext4_block *b,
+    uint64_t lba)
 {
     uint64_t pba;
     uint32_t pb_cnt;
@@ -175,7 +176,9 @@
                     continue;
 
                 /*Buffer free was delayed and have no reference. Flush it.*/
-                r = ext4_block_set_direct(bdev, bdev->bc->data + bdev->bc->itemsize * i, bdev->bc->lba[i]);
+                r = ext4_block_set_direct(bdev,
+                        bdev->bc->data + bdev->bc->itemsize * i,
+                        bdev->bc->lba[i]);
                 if(r != EOK)
                     return r;
 
@@ -208,7 +211,8 @@
     return EOK;
 }
 
-int ext4_block_get_direct(struct	ext4_blockdev *bdev, void *buf, uint64_t lba)
+int ext4_block_get_direct(struct	ext4_blockdev *bdev, void *buf,
+    uint64_t lba)
 {
     uint64_t pba;
     uint32_t pb_cnt;
@@ -225,7 +229,8 @@
 
 
 
-int ext4_block_set_direct(struct	ext4_blockdev *bdev, const void *buf, uint64_t lba)
+int ext4_block_set_direct(struct	ext4_blockdev *bdev, const void *buf,
+    uint64_t lba)
 {
     uint64_t pba;
     uint32_t pb_cnt;
@@ -241,7 +246,8 @@
 }
 
 
-int	ext4_block_writebytes(struct	ext4_blockdev *bdev, uint64_t off, const void *buf, uint32_t len)
+int	ext4_block_writebytes(struct	ext4_blockdev *bdev, uint64_t off,
+    const void *buf, uint32_t len)
 {
     uint64_t block_idx;
     uint64_t block_end;
@@ -270,7 +276,8 @@
     unalg = (off & (bdev->ph_bsize - 1));
     if(unalg){
 
-        uint32_t wlen = (bdev->ph_bsize - unalg) > len ? len : (bdev->ph_bsize - unalg);
+        uint32_t wlen = (bdev->ph_bsize - unalg) > len ?
+                len : (bdev->ph_bsize - unalg);
 
         r = bdev->bread(bdev, bdev->ph_bbuf, block_idx, 1);
 
@@ -326,7 +333,8 @@
 
 
 
-int ext4_block_readbytes(struct	ext4_blockdev *bdev, uint64_t off, void *buf, uint32_t len)
+int ext4_block_readbytes(struct	ext4_blockdev *bdev, uint64_t off, void *buf,
+    uint32_t len)
 {
 
     uint64_t block_idx;
@@ -355,7 +363,8 @@
     unalg = (off & (bdev->ph_bsize - 1));
     if(unalg){
 
-        uint32_t rlen = (bdev->ph_bsize - unalg) > len ? len : (bdev->ph_bsize - unalg);
+        uint32_t rlen = (bdev->ph_bsize - unalg) > len ?
+                len : (bdev->ph_bsize - unalg);
 
         r = bdev->bread(bdev, bdev->ph_bbuf, block_idx, 1);
 
@@ -399,7 +408,8 @@
     return r;
 }
 
-int 	ext4_block_delay_cache_flush(struct	ext4_blockdev *bdev, uint8_t on_off)
+int 	ext4_block_delay_cache_flush(struct	ext4_blockdev *bdev,
+    uint8_t on_off)
 {
     int r;
     uint32_t i;
@@ -418,7 +428,9 @@
                 continue;
 
             /*Buffer free was delayed and have no reference. Flush it.*/
-            r = ext4_block_set_direct(bdev, bdev->bc->data + bdev->bc->itemsize * i, bdev->bc->lba[i]);
+            r = ext4_block_set_direct(bdev,
+                    bdev->bc->data + bdev->bc->itemsize * i,
+                    bdev->bc->lba[i]);
             if(r != EOK)
                 return r;
 
--- a/src/lwext4/ext4_blockdev.h
+++ b/src/lwext4/ext4_blockdev.h
@@ -60,13 +60,15 @@
      * @param	buf	output buffer
      * @param	blk_id	block id
      * @param	blk_cnt block count*/
-    int			(*bread)(struct	ext4_blockdev *bdev, void 	*buf, uint64_t blk_id, uint32_t blk_cnt);
+    int			(*bread)(struct	ext4_blockdev *bdev, void *buf,
+                uint64_t blk_id, uint32_t blk_cnt);
 
     /**@brief	Block write function.
      * @param	buf input buffer
      * @param	blk_id block id
      * @param	blk_cnt block count*/
-    int			(*bwrite)(struct	ext4_blockdev *bdev, const void *buf, uint64_t blk_id, uint32_t blk_cnt);
+    int			(*bwrite)(struct	ext4_blockdev *bdev, const void *buf,
+                uint64_t blk_id, uint32_t blk_cnt);
 
     /**@brief	Close device function.
      * @param	bdev block device.*/
@@ -101,16 +103,17 @@
 
 
 /**@brief	Static initialization fo the block device.*/
-#define EXT4_BLOCKDEV_STATIC_INSTANCE(__name, __bsize, __bcnt, __open, __bread, __bwrite, __close)	\
-        static uint8_t	__name##_ph_bbuf[(__bsize)];													\
-        static struct	ext4_blockdev __name = {														\
-                .open   = __open,																			\
-                .bread  = __bread,																			\
-                .bwrite = __bwrite,																			\
-                .close  = __close,																			\
-                .ph_bsize  = __bsize,																		\
-                .ph_bcnt   = __bcnt,																		\
-                .ph_bbuf   = __name##_ph_bbuf,																\
+#define EXT4_BLOCKDEV_STATIC_INSTANCE(__name, __bsize, __bcnt, __open,  \
+                                            __bread, __bwrite, __close)	\
+        static uint8_t	__name##_ph_bbuf[(__bsize)];                    \
+        static struct	ext4_blockdev __name = {                        \
+                .open   = __open,                                       \
+                .bread  = __bread,                                      \
+                .bwrite = __bwrite,                                     \
+                .close  = __close,                                      \
+                .ph_bsize  = __bsize,                                   \
+                .ph_bcnt   = __bcnt,                                    \
+                .ph_bbuf   = __name##_ph_bbuf,                          \
         }
 
 /**@brief	Block device initialization.
@@ -125,7 +128,8 @@
  * @param	bdev block device descriptor
  * @param	bc block cache descriptor
  * @return 	standard error code*/
-int ext4_block_bind_bcache(struct ext4_blockdev *bdev, struct ext4_bcache *bc);
+int ext4_block_bind_bcache(struct ext4_blockdev *bdev,
+    struct ext4_bcache *bc);
 
 /**@brief	Close block device
  * @param	bdev block device descriptor
@@ -137,7 +141,8 @@
  * @param	bdev block device descriptor
  * @param	lb_size ligical block size (in bytes)
  * @return 	standard error code*/
-void ext4_block_set_lb_size(struct	ext4_blockdev *bdev, uint64_t	lb_bsize);
+void ext4_block_set_lb_size(struct	ext4_blockdev *bdev,
+    uint64_t lb_bsize);
 
 /**@brief	Block get function (through cache).
  * @param	bdev block device descriptor
@@ -144,7 +149,8 @@
  * @param	b block descriptor
  * @param	lba logical block address
  * @return 	standard error code*/
-int ext4_block_get(struct	ext4_blockdev *bdev, struct	ext4_block *b, uint64_t lba);
+int ext4_block_get(struct	ext4_blockdev *bdev, struct	ext4_block *b,
+    uint64_t lba);
 
 /**@brief	Block set procedure (through cache).
  * @param	bdev block device descriptor
@@ -158,7 +164,8 @@
  * @param	buf output buffer
  * @param	lba logical block adderss
  * @return 	standard error code*/
-int ext4_block_get_direct(struct	ext4_blockdev *bdev, void *buf, uint64_t lba);
+int ext4_block_get_direct(struct	ext4_blockdev *bdev, void *buf,
+    uint64_t lba);
 
 
 /**@brief	Block write procedure (without cache)
@@ -166,7 +173,8 @@
  * @param	buf output buffer
  * @param	lba logical block address
  * @return 	standard error code*/
-int ext4_block_set_direct(struct	ext4_blockdev *bdev, const void *buf, uint64_t lba);
+int ext4_block_set_direct(struct	ext4_blockdev *bdev, const void *buf,
+    uint64_t lba);
 
 /**@brief	Write to block device (by direct adress).
  * @param	bdev block device descriptor
@@ -174,7 +182,8 @@
  * @param	buf input buffer
  * @param	len length of the write nuffer
  * @return 	EOK when sucess*/
-int	ext4_block_writebytes(struct	ext4_blockdev *bdev, uint64_t off, const void *buf, uint32_t len);
+int	ext4_block_writebytes(struct	ext4_blockdev *bdev, uint64_t off,
+    const void *buf, uint32_t len);
 
 
 
@@ -184,7 +193,8 @@
  * @param	buf input buffer
  * @param	len length of the write nuffer
  * @return 	EOK when sucess*/
-int ext4_block_readbytes(struct	ext4_blockdev *bdev, uint64_t off, void *buf, uint32_t len);
+int ext4_block_readbytes(struct	ext4_blockdev *bdev, uint64_t off,
+    void *buf, uint32_t len);
 
 /**@brief	Enable/disable delayed cache flush mode.
  * @param	bdev block device descriptor
--- a/src/lwext4/ext4_debug.h
+++ b/src/lwext4/ext4_debug.h
@@ -98,11 +98,11 @@
 
 
 #if CONFIG_DEBUG_ASSERT
-#define 	ext4_assert(_v)	do {						\
-        if(!(_v)){											\
-            printf("Assertion failed:\nModule: %s\nFunc: %s\nLine: %d\n", __FILE__, __FUNCTION__, __LINE__);	\
-            fflush(stdout);																					\
-        }																								\
+#define 	ext4_assert(_v)	do {						                    \
+        if(!(_v)){											                \
+            printf("Assertion failed:\nModule: %s\nFunc: %s\nLine: %d\n",   \
+                    __FILE__, __FUNCTION__, __LINE__);                      \
+        }                                                                   \
 }while(0)
 #else
 #define 	ext4_assert(_v)
--- a/src/lwext4/ext4_dir.c
+++ b/src/lwext4/ext4_dir.c
@@ -113,10 +113,11 @@
         de->inode_type = type;
 }
 
-/*****************************************************************************/
+/****************************************************************************/
 
 
-static int ext4_dir_iterator_set(struct ext4_directory_iterator *it, uint32_t block_size)
+static int ext4_dir_iterator_set(struct ext4_directory_iterator *it,
+    uint32_t block_size)
 {
     it->current = NULL;
 
@@ -148,7 +149,8 @@
     return EOK;
 }
 
-static int ext4_dir_iterator_seek(struct ext4_directory_iterator *it, uint64_t pos)
+static int ext4_dir_iterator_seek(struct ext4_directory_iterator *it,
+    uint64_t pos)
 {
     uint64_t size = ext4_inode_get_size(&it->inode_ref->fs->sb,
             it->inode_ref->inode);
@@ -160,7 +162,8 @@
     if (pos >= size) {
         if (it->current_block.lb_id) {
 
-            int rc = ext4_block_set(it->inode_ref->fs->bdev, &it->current_block);
+            int rc = ext4_block_set(it->inode_ref->fs->bdev,
+                    &it->current_block);
             it->current_block.lb_id = 0;
 
             if (rc != EOK)
@@ -240,8 +243,9 @@
     return EOK;
 }
 
-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)
+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)
 {
     /* Check maximum entry length */
     uint32_t block_size = ext4_sb_get_block_size(sb);
@@ -486,8 +490,9 @@
     return ext4_dir_destroy_result(parent, &result);
 }
 
-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)
+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)
 {
     /* Compute required length entry and align it to 4 bytes */
     uint32_t block_size = ext4_sb_get_block_size(sb);
@@ -498,7 +503,8 @@
 
     /* Initialize pointers, stop means to upper bound */
     struct ext4_directory_entry_ll *dentry  = (void *)target_block->data;
-    struct ext4_directory_entry_ll *stop 	= (void *)(target_block->data + block_size);
+    struct ext4_directory_entry_ll *stop 	=
+            (void *)(target_block->data + block_size);
 
     /*
      * Walk through the block and check for invalid entries
@@ -555,7 +561,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 =
@@ -591,7 +598,8 @@
             return EINVAL;
 
         /* Jump to next entry */
-        dentry = (struct ext4_directory_entry_ll *) ((uint8_t *) dentry + dentry_len);
+        dentry = (struct ext4_directory_entry_ll *)
+                ((uint8_t *) dentry + dentry_len);
     }
 
     /* Entry not found */
@@ -598,7 +606,8 @@
     return ENOENT;
 }
 
-int ext4_dir_destroy_result(struct ext4_inode_ref *parent, struct ext4_directory_search_result *result)
+int ext4_dir_destroy_result(struct ext4_inode_ref *parent,
+    struct ext4_directory_search_result *result)
 {
     if (result->block.lb_id)
         return ext4_block_set(parent->fs->bdev, &result->block);
--- a/src/lwext4/ext4_dir.h
+++ b/src/lwext4/ext4_dir.h
@@ -52,52 +52,56 @@
 
 uint32_t ext4_dir_entry_ll_get_inode(struct ext4_directory_entry_ll *de);
 
-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);
 
 
 uint16_t ext4_dir_entry_ll_get_entry_length(struct ext4_directory_entry_ll *de);
-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);
 
 
 uint16_t ext4_dir_entry_ll_get_name_length(struct ext4_sblock *sb,
-        struct ext4_directory_entry_ll *de);
-void 	ext4_dir_entry_ll_set_name_length(struct ext4_sblock *sb,
-        struct ext4_directory_entry_ll *de, uint16_t len);
+    struct ext4_directory_entry_ll *de);
+void ext4_dir_entry_ll_set_name_length(struct ext4_sblock *sb,
+    struct ext4_directory_entry_ll *de, uint16_t len);
 
 
 
 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);
 void 	ext4_dir_entry_ll_set_inode_type(struct ext4_sblock *sb,
-        struct ext4_directory_entry_ll *de, uint8_t type);
+    struct ext4_directory_entry_ll *de, uint8_t type);
 
 
 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);
 
 int ext4_dir_iterator_next(struct ext4_directory_iterator *it);
 int ext4_dir_iterator_fini(struct ext4_directory_iterator *it);
 
-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);
+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);
 
 int  ext4_dir_add_entry(struct ext4_inode_ref *parent, const char *name,
-        struct ext4_inode_ref *child);
+    struct ext4_inode_ref *child);
 
 int ext4_dir_find_entry(struct ext4_directory_search_result *result,
-        struct ext4_inode_ref *parent, const char *name);
+    struct ext4_inode_ref *parent, const char *name);
 
 int ext4_dir_remove_entry(struct ext4_inode_ref *parent, const char *name);
 
-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);
+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);
 
 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);
 
-int ext4_dir_destroy_result(struct ext4_inode_ref *parent, struct ext4_directory_search_result *result);
+int ext4_dir_destroy_result(struct ext4_inode_ref *parent,
+    struct ext4_directory_search_result *result);
 
 
 #endif /* EXT4_DIR_H_ */
--- a/src/lwext4/ext4_dir_idx.c
+++ b/src/lwext4/ext4_dir_idx.c
@@ -51,9 +51,11 @@
     void 	 *dentry;
 };
 
-static int ext4_dir_dx_hash_string(struct ext4_hash_info *hinfo, int len, const char *name)
+static int ext4_dir_dx_hash_string(struct ext4_hash_info *hinfo, int len,
+    const char *name)
 {
-    return ext2_htree_hash(name, len, hinfo->seed, hinfo->hash_version, &hinfo->hash, &hinfo->minor_hash);
+    return ext2_htree_hash(name, len, hinfo->seed, hinfo->hash_version,
+            &hinfo->hash, &hinfo->minor_hash);
 }
 
 
@@ -140,7 +142,7 @@
 {
     entry->block = to_le32(block);
 }
-/*****************************************************************************/
+/****************************************************************************/
 
 int 	ext4_dir_dx_init(struct ext4_inode_ref *dir)
 {
@@ -275,7 +277,8 @@
 
 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_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 =
@@ -387,7 +390,7 @@
         p--;
     }
 
-    /* Check hash collision (if not occured - no next block cannot be used) */
+    /* Check hash collision (if not occured - no next block cannot be used)*/
     uint32_t current_hash = ext4_dir_dx_entry_get_hash(p->position);
     if ((hash & 1) == 0) {
         if ((current_hash & ~1) != hash)
@@ -540,7 +543,8 @@
 }
 
 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;
@@ -564,7 +568,8 @@
 
 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_directory_dx_block *index_block,
+        struct ext4_block *new_data_block)
 {
     int rc = EOK;
 
@@ -605,7 +610,7 @@
             uint8_t len = ext4_dir_entry_ll_get_name_length(
                     &inode_ref->fs->sb, dentry);
 
-            rc = ext4_dir_dx_hash_string(&tmp_hinfo, len, (char *) dentry->name);
+            rc = ext4_dir_dx_hash_string(&tmp_hinfo, len, (char*)dentry->name);
             if(rc != EOK) {
                 free(sort_array);
                 free(entry_buffer);
@@ -741,7 +746,8 @@
  *
  */
 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 *dx_blocks,
+        struct ext4_directory_dx_block *dx_block)
 {
     struct ext4_directory_dx_entry *entries;
     if (dx_block == dx_blocks)
--- a/src/lwext4/ext4_fs.c
+++ b/src/lwext4/ext4_fs.c
@@ -97,7 +97,8 @@
     /*Validate FS*/
     tmp = ext4_get16(&fs->sb, state);
     if (tmp & EXT4_SUPERBLOCK_STATE_ERROR_FS) {
-        ext4_dprintf(EXT4_DEBUG_FS, "Filesystem was not cleanly unmounted before \n");
+        ext4_dprintf(EXT4_DEBUG_FS,
+                "Filesystem was not cleanly unmounted before \n");
     }
 
     /* Mark system as mounted */
@@ -134,12 +135,14 @@
     }
 
     /*Check features_incompatible*/
-    if ((ext4_get32(&fs->sb, features_incompatible) & (~EXT4_FEATURE_INCOMPAT_SUPP)) )
+    if ((ext4_get32(&fs->sb, features_incompatible) &
+            (~EXT4_FEATURE_INCOMPAT_SUPP)) )
         return ENOTSUP;
 
 
     /*Check features_read_only*/
-    if ((ext4_get32(&fs->sb, features_read_only) & (~EXT4_FEATURE_RO_COMPAT_SUPP))){
+    if ((ext4_get32(&fs->sb, features_read_only) &
+            (~EXT4_FEATURE_RO_COMPAT_SUPP))){
         *read_only = true;
         return EOK;
     }
@@ -160,7 +163,8 @@
 
 
 
-uint32_t ext4_fs_index_in_group2_baddr(struct ext4_sblock *s, uint32_t index, uint32_t bgid)
+uint32_t ext4_fs_index_in_group2_baddr(struct ext4_sblock *s, uint32_t index,
+    uint32_t bgid)
 {
     if(ext4_get32(s, first_data_block))
         index++;
@@ -178,7 +182,8 @@
             bg_ref->block_group, &bg_ref->fs->sb);
 
     struct ext4_block block_bitmap;
-    int rc = ext4_block_get(bg_ref->fs->bdev, &block_bitmap, bitmap_block_addr);
+    int rc = ext4_block_get(bg_ref->fs->bdev, &block_bitmap,
+            bitmap_block_addr);
     if (rc != EOK)
         return rc;
 
@@ -193,7 +198,7 @@
     uint32_t first_data_idx = ext4_fs_baddr2_index_in_group(
             &bg_ref->fs->sb, first_data);
 
-    /* Set bits from to first block to first data block - 1 to one (allocated) */
+    /*Set bits from to first block to first data block - 1 to one (allocated)*/
     /*TODO: Optimize it*/
     for (i = first_idx; i < first_data_idx; ++i)
         ext4_bmap_bit_set(block_bitmap.data, i);
@@ -212,7 +217,8 @@
             bg_ref->block_group, &bg_ref->fs->sb);
 
     struct ext4_block block_bitmap;
-    int rc = ext4_block_get(bg_ref->fs->bdev, &block_bitmap, bitmap_block_addr);
+    int rc = ext4_block_get(bg_ref->fs->bdev, &block_bitmap,
+            bitmap_block_addr);
     if (rc != EOK)
         return rc;
 
@@ -278,7 +284,8 @@
 }
 
 
-int ext4_fs_get_block_group_ref(struct ext4_fs *fs, uint32_t bgid, struct ext4_block_group_ref *ref)
+int ext4_fs_get_block_group_ref(struct ext4_fs *fs, uint32_t bgid,
+    struct ext4_block_group_ref *ref)
 {
     /* Compute number of descriptors, that fits in one data block */
     uint32_t dsc_per_block = ext4_sb_get_block_size(&fs->sb) /
@@ -310,7 +317,7 @@
             return rc;
         }
         ext4_bg_clear_flag(ref->block_group,
-                EXT4_BLOCK_GROUP_BLOCK_UNINIT);
+            EXT4_BLOCK_GROUP_BLOCK_UNINIT);
 
         ref->dirty = true;
     }
@@ -324,7 +331,7 @@
         }
 
         ext4_bg_clear_flag(ref->block_group,
-                EXT4_BLOCK_GROUP_INODE_UNINIT);
+            EXT4_BLOCK_GROUP_INODE_UNINIT);
 
         if (!ext4_bg_has_flag(ref->block_group,
                 EXT4_BLOCK_GROUP_ITABLE_ZEROED)) {
@@ -335,7 +342,7 @@
             }
 
             ext4_bg_set_flag(ref->block_group,
-                    EXT4_BLOCK_GROUP_ITABLE_ZEROED);
+                EXT4_BLOCK_GROUP_ITABLE_ZEROED);
         }
 
         ref->dirty = true;
@@ -344,7 +351,8 @@
     return EOK;
 }
 
-static uint16_t ext4_fs_bg_checksum(struct ext4_sblock *sb, uint32_t bgid, struct ext4_bgroup *bg)
+static uint16_t ext4_fs_bg_checksum(struct ext4_sblock *sb, uint32_t bgid,
+    struct ext4_bgroup *bg)
 {
     /* If checksum not supported, 0 will be returned */
     uint16_t crc = 0;
@@ -402,7 +410,8 @@
     return ext4_block_set(ref->fs->bdev, &ref->block);
 }
 
-int ext4_fs_get_inode_ref(struct ext4_fs *fs, uint32_t index,  struct ext4_inode_ref *ref)
+int ext4_fs_get_inode_ref(struct ext4_fs *fs, uint32_t index,
+    struct ext4_inode_ref *ref)
 {
     /* Compute number of i-nodes, that fits in one data block */
     uint32_t inodes_per_group = ext4_get32(&fs->sb, inodes_per_group);
@@ -440,7 +449,8 @@
     uint32_t byte_offset_in_group = offset_in_group * inode_size;
 
     /* Compute block address */
-    uint64_t block_id = inode_table_start + (byte_offset_in_group / block_size);
+    uint64_t block_id = inode_table_start +
+            (byte_offset_in_group / block_size);
 
 
     rc = ext4_block_get(fs->bdev, &ref->block, block_id);
@@ -472,7 +482,8 @@
     return  ext4_block_set(ref->fs->bdev, &ref->block);
 }
 
-int ext4_fs_alloc_inode(struct ext4_fs *fs, struct ext4_inode_ref *inode_ref, bool is_directory)
+int ext4_fs_alloc_inode(struct ext4_fs *fs, struct ext4_inode_ref *inode_ref,
+    bool is_directory)
 {
     /* Check if newly allocated i-node will be a directory */
     uint32_t i;
@@ -569,7 +580,7 @@
     /* For extents must be data block destroyed by other way */
     if ((ext4_sb_check_feature_incompatible(&fs->sb,
             EXT4_FEATURE_INCOMPAT_EXTENTS)) &&
-            (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))) {
+            (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))){
         /* Data structures are released during truncate operation... */
         goto finish;
     }
@@ -700,7 +711,7 @@
 }
 
 int ext4_fs_truncate_inode(struct ext4_inode_ref *inode_ref,
-        uint64_t new_size)
+    uint64_t new_size)
 {
     struct ext4_sblock *sb = &inode_ref->fs->sb;
     uint32_t i;
@@ -759,7 +770,7 @@
 }
 
 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)
 {
     struct ext4_fs *fs = inode_ref->fs;
 
@@ -867,7 +878,7 @@
 }
 
 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)
 {
     struct ext4_fs *fs = inode_ref->fs;
 
@@ -881,7 +892,8 @@
 
     /* Handle simple case when we are dealing with direct reference */
     if (iblock < EXT4_INODE_DIRECT_BLOCK_COUNT) {
-        ext4_inode_set_direct_block(inode_ref->inode, (uint32_t) iblock, fblock);
+        ext4_inode_set_direct_block(inode_ref->inode, (uint32_t) iblock,
+                fblock);
         inode_ref->dirty = true;
 
         return EOK;
@@ -924,7 +936,7 @@
 
         /* Update i-node */
         ext4_inode_set_indirect_block(inode_ref->inode, level - 1,
-                new_block_addr);
+            new_block_addr);
         inode_ref->dirty = true;
 
         /* Load newly allocated block */
@@ -1021,7 +1033,7 @@
 }
 
 int ext4_fs_release_inode_block(struct ext4_inode_ref *inode_ref,
-        uint32_t iblock)
+    uint32_t iblock)
 {
     uint32_t fblock;
 
@@ -1122,7 +1134,7 @@
 
 
 int ext4_fs_append_inode_block(struct ext4_inode_ref *inode_ref,
-        uint32_t *fblock, uint32_t *iblock)
+    uint32_t *fblock, uint32_t *iblock)
 {
     /* Handle extents separately */
     if ((ext4_sb_check_feature_incompatible(&inode_ref->fs->sb,
--- a/src/lwext4/ext4_fs.h
+++ b/src/lwext4/ext4_fs.h
@@ -55,18 +55,22 @@
 
 
 uint32_t ext4_fs_baddr2_index_in_group(struct ext4_sblock *s, uint32_t baddr);
-uint32_t ext4_fs_index_in_group2_baddr(struct ext4_sblock *s, uint32_t index, uint32_t bgid);
+uint32_t ext4_fs_index_in_group2_baddr(struct ext4_sblock *s, uint32_t index,
+    uint32_t bgid);
 
 
-int ext4_fs_get_block_group_ref(struct ext4_fs *fs, uint32_t bgid, struct ext4_block_group_ref *ref);
+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);
 
 
-int ext4_fs_get_inode_ref(struct ext4_fs *fs, uint32_t index,  struct ext4_inode_ref *ref);
+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);
 
 
-int ext4_fs_alloc_inode(struct ext4_fs *fs, struct ext4_inode_ref *inode_ref, bool is_directory);
+int ext4_fs_alloc_inode(struct ext4_fs *fs, struct ext4_inode_ref *inode_ref,
+    bool is_directory);
 int ext4_fs_free_inode(struct ext4_inode_ref *inode_ref);
 
 int ext4_fs_truncate_inode(struct ext4_inode_ref *inode_ref,
--- a/src/lwext4/ext4_ialloc.c
+++ b/src/lwext4/ext4_ialloc.c
@@ -48,7 +48,8 @@
 #include <ext4_block_group.h>
 #include <ext4_bitmap.h>
 
-static uint32_t ext4_ialloc_inode2index_in_group(struct ext4_sblock *sb, uint32_t inode)
+static uint32_t ext4_ialloc_inode2index_in_group(struct ext4_sblock *sb,
+    uint32_t inode)
 {
     uint32_t inodes_per_group = ext4_get32(sb, inodes_per_group);
     return (inode - 1) % inodes_per_group;
@@ -171,7 +172,8 @@
             uint32_t inodes_in_group = ext4_inodes_in_group_cnt(sb, bgid);
             uint32_t index_in_group;
 
-            rc = ext4_bmap_bit_find_clr(bitmap_block.data, 0, inodes_in_group, &index_in_group);
+            rc = ext4_bmap_bit_find_clr(bitmap_block.data, 0, inodes_in_group,
+                    &index_in_group);
             /* Block group has not any free i-node */
             if (rc == ENOSPC) {
                 ext4_block_set(fs->bdev, &bitmap_block);
@@ -228,7 +230,8 @@
 
 
             /* Compute the absolute i-nodex number */
-            *index = ext4_ialloc_index_in_group2inode(sb, index_in_group, bgid);
+            *index = ext4_ialloc_index_in_group2inode(sb,
+                    index_in_group, bgid);
 
             return EOK;
         }
--- a/src/lwext4/ext4_inode.c
+++ b/src/lwext4/ext4_inode.c
@@ -69,7 +69,8 @@
     return v;
 }
 
-void 	 ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode, uint32_t mode)
+void 	 ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode,
+    uint32_t mode)
 {
     inode->mode = to_le16((mode << 16) >> 16);
 
@@ -94,7 +95,8 @@
 {
     uint64_t v = to_le32(inode->size_lo);
 
-    if ((ext4_get32(sb, rev_level) > 0) && (ext4_inode_is_type(sb, inode, EXT4_INODE_MODE_FILE)))
+    if ((ext4_get32(sb, rev_level) > 0) && (ext4_inode_is_type(sb, inode,
+            EXT4_INODE_MODE_FILE)))
         v |= ((uint64_t)to_le32(inode->size_hi)) << 32;
 
     return v;
@@ -121,7 +123,8 @@
 {
     return to_le32(inode->change_inode_time);
 }
-void 	 ext4_inode_set_change_inode_time(struct ext4_inode *inode, uint32_t time)
+void 	 ext4_inode_set_change_inode_time(struct ext4_inode *inode,
+    uint32_t time)
 {
     inode->change_inode_time = to_le32(time);
 }
@@ -132,7 +135,8 @@
     return to_le32(inode->modification_time);
 }
 
-void 	 ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time)
+void 	 ext4_inode_set_modification_time(struct ext4_inode *inode,
+    uint32_t time)
 {
     inode->modification_time = to_le32(time);
 }
@@ -167,7 +171,8 @@
 }
 
 
-uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,  struct ext4_inode *inode)
+uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,
+    struct ext4_inode *inode)
 {
     uint64_t count = to_le32(inode->blocks_count_lo);
 
@@ -179,7 +184,8 @@
 
         if (ext4_inode_has_flag(inode, EXT4_INODE_FLAG_HUGE_FILE)) {
 
-            uint32_t block_bits = ext4_inode_block_bits_count(ext4_sb_get_block_size(sb));
+            uint32_t block_bits =
+                    ext4_inode_block_bits_count(ext4_sb_get_block_size(sb));
             return count << (block_bits - 9);
         } else
             return count;
@@ -189,7 +195,8 @@
 }
 
 
-int 	 ext4_inode_set_blocks_count(struct ext4_sblock *sb,  struct ext4_inode *inode, uint64_t count)
+int ext4_inode_set_blocks_count(struct ext4_sblock *sb,
+    struct ext4_inode *inode, uint64_t count)
 {
     /* 32-bit maximum */
     uint64_t max = 0;
@@ -247,7 +254,8 @@
     inode->generation = to_le32(gen);
 }
 
-uint64_t ext4_inode_get_file_acl(struct ext4_inode *inode, struct ext4_sblock *sb)
+uint64_t ext4_inode_get_file_acl(struct ext4_inode *inode,
+    struct ext4_sblock *sb)
 {
     /*TODO: Verify it*/
     uint64_t v = to_le32(inode->file_acl_lo);
@@ -259,7 +267,8 @@
     return v;
 }
 
-void 	 ext4_inode_set_file_acl(struct ext4_inode *inode, struct ext4_sblock *sb, uint64_t acl)
+void ext4_inode_set_file_acl(struct ext4_inode *inode, struct ext4_sblock *sb,
+    uint64_t acl)
 {
     /*TODO: Verify it*/
     inode->file_acl_lo = to_le32((acl << 32) >> 32);
@@ -274,7 +283,8 @@
 {
     return to_le32(inode->blocks[idx]);
 }
-void 	 ext4_inode_set_direct_block(struct ext4_inode *inode, uint32_t idx, uint32_t block)
+void ext4_inode_set_direct_block(struct ext4_inode *inode, uint32_t idx,
+    uint32_t block)
 {
     inode->blocks[idx] = to_le32(block);
 }
@@ -285,14 +295,17 @@
     return to_le32(inode->blocks[idx + EXT4_INODE_INDIRECT_BLOCK]);
 }
 
-void	 ext4_inode_set_indirect_block(struct ext4_inode *inode, uint32_t idx, uint32_t block)
+void ext4_inode_set_indirect_block(struct ext4_inode *inode, uint32_t idx,
+    uint32_t block)
 {
     inode->blocks[idx + EXT4_INODE_INDIRECT_BLOCK] = to_le32(block);
 }
 
-bool 	 ext4_inode_is_type(struct ext4_sblock *sb, struct ext4_inode *inode, uint32_t type)
+bool ext4_inode_is_type(struct ext4_sblock *sb, struct ext4_inode *inode,
+    uint32_t type)
 {
-    return (ext4_inode_get_mode(sb, inode) & EXT4_INODE_MODE_TYPE_MASK) == type;
+    return (ext4_inode_get_mode(sb, inode) &
+            EXT4_INODE_MODE_TYPE_MASK) == type;
 }
 
 bool 	 ext4_inode_has_flag(struct ext4_inode *inode, uint32_t f)
@@ -314,7 +327,8 @@
     ext4_inode_set_flags(inode, flags);
 }
 
-bool 	 ext4_inode_can_truncate(struct ext4_sblock *sb, struct ext4_inode *inode)
+bool 	 ext4_inode_can_truncate(struct ext4_sblock *sb,
+    struct ext4_inode *inode)
 {
     if ((ext4_inode_has_flag(inode, EXT4_INODE_FLAG_APPEND)) ||
             (ext4_inode_has_flag(inode, EXT4_INODE_FLAG_IMMUTABLE)))
@@ -328,7 +342,8 @@
 }
 
 
-struct ext4_extent_header * ext4_inode_get_extent_header(struct ext4_inode *inode)
+struct ext4_extent_header * ext4_inode_get_extent_header(
+    struct ext4_inode *inode)
 {
     return (struct ext4_extent_header *) inode->blocks;
 }
--- a/src/lwext4/ext4_inode.h
+++ b/src/lwext4/ext4_inode.h
@@ -46,7 +46,8 @@
 #include <stdint.h>
 
 uint32_t ext4_inode_get_mode(struct ext4_sblock *sb, struct ext4_inode *inode);
-void 	 ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode, uint32_t mode);
+void ext4_inode_set_mode(struct ext4_sblock *sb, struct ext4_inode *inode,
+    uint32_t mode);
 
 
 uint32_t ext4_inode_get_uid(struct ext4_inode *inode);
@@ -54,7 +55,7 @@
 
 
 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);
+void ext4_inode_set_size(struct ext4_inode *inode, uint64_t size);
 
 
 uint32_t ext4_inode_get_access_time(struct ext4_inode *inode);
@@ -62,52 +63,60 @@
 
 
 uint32_t ext4_inode_get_change_inode_time(struct ext4_inode *inode);
-void 	 ext4_inode_set_change_inode_time(struct ext4_inode *inode, uint32_t time);
+void ext4_inode_set_change_inode_time(struct ext4_inode *inode,
+    uint32_t time);
 
 
 uint32_t ext4_inode_get_modification_time(struct ext4_inode *inode);
-void 	 ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time);
+void ext4_inode_set_modification_time(struct ext4_inode *inode, uint32_t time);
 
 
 uint32_t ext4_inode_get_deletion_time(struct ext4_inode *inode);
-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);
 
 uint32_t ext4_inode_get_gid(struct ext4_inode *inode);
 void 	 ext4_inode_set_gid(struct ext4_inode *inode, uint32_t gid);
 
 uint16_t ext4_inode_get_links_count(struct ext4_inode *inode);
-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);
 
 
-uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,  struct ext4_inode *inode);
-int 	 ext4_inode_set_blocks_count(struct ext4_sblock *sb,  struct ext4_inode *inode, uint64_t cnt);
+uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,
+    struct ext4_inode *inode);
+int ext4_inode_set_blocks_count(struct ext4_sblock *sb,
+    struct ext4_inode *inode, uint64_t cnt);
 
 
 uint32_t ext4_inode_get_flags(struct ext4_inode *inode);
-void 	 ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags);
+void ext4_inode_set_flags(struct ext4_inode *inode, uint32_t flags);
 
 uint32_t ext4_inode_get_generation(struct ext4_inode *inode);
-void 	 ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen);
+void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen);
 
-uint64_t ext4_inode_get_file_acl(struct ext4_inode *inode, struct ext4_sblock *sb);
-void 	 ext4_inode_set_file_acl(struct ext4_inode *inode, struct ext4_sblock *sb, uint64_t acl);
+uint64_t ext4_inode_get_file_acl(struct ext4_inode *inode,
+    struct ext4_sblock *sb);
+void ext4_inode_set_file_acl(struct ext4_inode *inode,
+    struct ext4_sblock *sb, uint64_t acl);
 
 
 uint32_t ext4_inode_get_direct_block(struct ext4_inode *inode, uint32_t idx);
-void 	 ext4_inode_set_direct_block(struct ext4_inode *inode, uint32_t idx, uint32_t block);
+void ext4_inode_set_direct_block(struct ext4_inode *inode, uint32_t idx,
+    uint32_t block);
 
 
 uint32_t ext4_inode_get_indirect_block(struct ext4_inode *inode, uint32_t idx);
-void	 ext4_inode_set_indirect_block(struct ext4_inode *inode, uint32_t idx, uint32_t block);
+void ext4_inode_set_indirect_block(struct ext4_inode *inode, uint32_t idx,
+    uint32_t block);
 
-bool 	 ext4_inode_is_type(struct ext4_sblock *sb, struct ext4_inode *inode, uint32_t type);
+bool ext4_inode_is_type(struct ext4_sblock *sb, struct ext4_inode *inode,
+    uint32_t type);
 
 
-bool 	 ext4_inode_has_flag(struct ext4_inode *inode, uint32_t f);
-void 	 ext4_inode_clear_flag(struct ext4_inode *inode, uint32_t f);
-void 	 ext4_inode_set_flag(struct ext4_inode *inode, uint32_t f);
+bool ext4_inode_has_flag(struct ext4_inode *inode, uint32_t f);
+void ext4_inode_clear_flag(struct ext4_inode *inode, uint32_t f);
+void ext4_inode_set_flag(struct ext4_inode *inode, uint32_t f);
 
-bool 	 ext4_inode_can_truncate(struct ext4_sblock *sb, struct ext4_inode *inode);
+bool ext4_inode_can_truncate(struct ext4_sblock *sb, struct ext4_inode *inode);
 
 
 struct ext4_extent_header * ext4_inode_get_extent_header(struct ext4_inode *inode);
--- a/src/lwext4/ext4_super.h
+++ b/src/lwext4/ext4_super.h
@@ -54,7 +54,8 @@
  * @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);
+    return ((uint64_t) to_le32(s->blocks_count_hi) << 32) |
+            to_le32(s->blocks_count_lo);
 }
 
 /**@brief	Free blocks count get stored in superblock.
@@ -62,13 +63,15 @@
  * @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);
+    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, uint64_t cnt)
+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);
     s->free_blocks_count_hi = to_le32(cnt >> 32);
@@ -93,7 +96,7 @@
             EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE : size;
 }
 
-/*************************Flags and features**********************************/
+/*************************Flags and features*********************************/
 
 /**@brief	Support check of flag.
  * @param	s superblock descriptor
@@ -108,7 +111,8 @@
  * @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)
+static inline bool ext4_sb_check_feature_compatible(struct ext4_sblock *s,
+    uint32_t v)
 {
     return to_le32(s->features_compatible) & v;
 }
@@ -118,7 +122,8 @@
  * @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)
+static inline bool ext4_sb_check_feature_incompatible(struct ext4_sblock *s,
+    uint32_t v)
 {
     return to_le32(s->features_incompatible) & v;
 }
@@ -133,7 +138,7 @@
     return to_le32(s->features_read_only) & v;
 }
 
-/**************************More complex functions*****************************/
+/**************************More complex functions****************************/
 
 /**@brief	Returns a block group count.
  * @param	s superblock descriptor
@@ -140,19 +145,21 @@
  * @return	count of block groups*/
 uint32_t ext4_block_group_cnt(struct ext4_sblock *s);
 
-/**@brief	Returns block count in block group (last block group may have less blocks)
+/**@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*/
 uint32_t ext4_blocks_in_group_cnt(struct ext4_sblock *s, uint32_t bgid);
 
-/**@brief	Returns inodes count in block group (last block group may have less inodes)
+/**@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*/
 uint32_t ext4_inodes_in_group_cnt(struct ext4_sblock *s, uint32_t bgid);
 
-/***************************Read/write/check superblock***********************/
+/***************************Read/write/check superblock**********************/
 
 /**@brief	Superblock write.
  * @param	bdev block device descriptor.