summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2019-10-30 15:09:20 +0800
committerIru Cai <mytbk920423@gmail.com>2019-10-30 15:09:20 +0800
commiteef8e7b05ffab4c7d12a5f7e135357c0462c180c (patch)
treec9f0168afa6bc3588d55fddcbf50a59c8074ce8c
parentae51f41d14f548d494ac41e0d21137c5a4c3f59c (diff)
downloaduext4-eef8e7b05ffab4c7d12a5f7e135357c0462c180c.tar.xz
printf -> dbg_printf
-rw-r--r--ext4_common.c116
-rw-r--r--ext4_common.h6
-rw-r--r--ext4_journal.c22
-rw-r--r--ext4_write.c30
-rw-r--r--ext4fs.c4
5 files changed, 92 insertions, 86 deletions
diff --git a/ext4_common.c b/ext4_common.c
index 5bf78b5..7524a40 100644
--- a/ext4_common.c
+++ b/ext4_common.c
@@ -208,9 +208,9 @@ void put_ext4(uint64_t off, const void *buf, uint32_t size)
if ((startblock + (size >> log2blksz)) >
(part_offset + fs->total_sect)) {
- printf("part_offset is " LBAFU "\n", part_offset);
- printf("total_sector is %llu\n", fs->total_sect);
- printf("error: overflow occurs\n");
+ dbg_printf("part_offset is " LBAFU "\n", part_offset);
+ dbg_printf("total_sector is %llu\n", fs->total_sect);
+ dbg_printf("error: overflow occurs\n");
return;
}
@@ -492,13 +492,13 @@ int ext4fs_update_parent_dentry(char *filename, int file_type)
zero_buffer = zalloc(fs->blksz);
if (!zero_buffer) {
- printf("No Memory\n");
+ dbg_printf("No Memory\n");
return -1;
}
root_first_block_buffer = zalloc(fs->blksz);
if (!root_first_block_buffer) {
free(zero_buffer);
- printf("No Memory\n");
+ dbg_printf("No Memory\n");
return -1;
}
new_entry_byte_reqd = ROUND(strlen(filename) +
@@ -540,24 +540,24 @@ restart_read:
break;
} else {
if (blk_idx > 0) {
- printf("Block full, trying previous\n");
+ dbg_printf("Block full, trying previous\n");
blk_idx--;
goto restart_read;
}
- printf("All blocks full: Allocate new\n");
+ dbg_printf("All blocks full: Allocate new\n");
if (le32_to_cpu(g_parent_inode->flags) &
EXT4_EXTENTS_FL) {
- printf("Directory uses extents\n");
+ dbg_printf("Directory uses extents\n");
goto fail;
}
if (directory_blocks >= INDIRECT_BLOCKS) {
- printf("Directory exceeds limit\n");
+ dbg_printf("Directory exceeds limit\n");
goto fail;
}
new_blk_no = ext4fs_get_new_blk_no();
if (new_blk_no == -1) {
- printf("no block left to assign\n");
+ dbg_printf("no block left to assign\n");
goto fail;
}
put_ext4((uint64_t)new_blk_no * fs->blksz, zero_buffer, fs->blksz);
@@ -598,7 +598,7 @@ restart_read:
/* get the next available inode number */
inodeno = ext4fs_get_new_inode_no();
if (inodeno == -1) {
- printf("no inode left to assign\n");
+ dbg_printf("no inode left to assign\n");
goto fail;
}
dir->inode = cpu_to_le32(inodeno);
@@ -660,7 +660,7 @@ static int search_dir(struct ext2_inode *parent_inode, char *dirname)
offset = 0;
do {
if (offset & 3) {
- printf("Badly aligned ext2_dirent\n");
+ dbg_printf("Badly aligned ext2_dirent\n");
break;
}
@@ -763,7 +763,7 @@ int ext4fs_get_parent_inode_num(const char *dirname, char *dname, int flags)
struct ext2_inode temp_inode;
if (*dirname != '/') {
- printf("Please supply Absolute path\n");
+ dbg_printf("Please supply Absolute path\n");
return -1;
}
@@ -804,7 +804,7 @@ int ext4fs_get_parent_inode_num(const char *dirname, char *dname, int flags)
} else {
if (ptr[i + 1] == NULL)
break;
- printf("Invalid path\n");
+ dbg_printf("Invalid path\n");
result_inode_no = -1;
goto fail;
}
@@ -833,7 +833,7 @@ end:
if (matched_inode_no != -1) {
ext4fs_iget(matched_inode_no, &temp_inode);
if (le16_to_cpu(temp_inode.mode) & S_IFDIR) {
- printf("It is a Directory\n");
+ dbg_printf("It is a Directory\n");
result_inode_no = -1;
goto fail;
}
@@ -885,7 +885,7 @@ static int unlink_filename(char *filename, unsigned int blknr)
offset = 0;
do {
if (offset & 3) {
- printf("Badly aligned ext2_dirent\n");
+ dbg_printf("Badly aligned ext2_dirent\n");
break;
}
@@ -908,7 +908,7 @@ static int unlink_filename(char *filename, unsigned int blknr)
} while (offset < fs->blksz);
if (inodeno > 0) {
- printf("file found, deleting\n");
+ dbg_printf("file found, deleting\n");
if (ext4fs_log_journal(block_buffer, blknr))
goto fail;
@@ -1220,13 +1220,13 @@ static void alloc_single_indirect_block(struct ext2_inode *file_inode,
if (*total_remaining_blocks != 0) {
si_buffer = zalloc(fs->blksz);
if (!si_buffer) {
- printf("No Memory\n");
+ dbg_printf("No Memory\n");
return;
}
si_start_addr = si_buffer;
si_blockno = ext4fs_get_new_blk_no();
if (si_blockno == -1) {
- printf("no block left to assign\n");
+ dbg_printf("no block left to assign\n");
goto fail;
}
(*no_blks_reqd)++;
@@ -1241,7 +1241,7 @@ static void alloc_single_indirect_block(struct ext2_inode *file_inode,
for (i = 0; i < (fs->blksz / sizeof(int)); i++) {
actual_block_no = ext4fs_get_new_blk_no();
if (actual_block_no == -1) {
- printf("no block left to assign\n");
+ dbg_printf("no block left to assign\n");
goto fail;
}
*si_buffer = cpu_to_le32(actual_block_no);
@@ -1284,7 +1284,7 @@ static void alloc_double_indirect_block(struct ext2_inode *file_inode,
/* double indirect parent block connecting to inode */
di_blockno_parent = ext4fs_get_new_blk_no();
if (di_blockno_parent == -1) {
- printf("no block left to assign\n");
+ dbg_printf("no block left to assign\n");
goto fail;
}
di_parent_buffer = zalloc(fs->blksz);
@@ -1301,7 +1301,7 @@ static void alloc_double_indirect_block(struct ext2_inode *file_inode,
fs->blksz, (char *)di_parent_buffer);
if (!status) {
- printf("%s: Device read error!\n", __func__);
+ dbg_printf("%s: Device read error!\n", __func__);
goto fail;
}
memset(di_parent_buffer, '\0', fs->blksz);
@@ -1313,7 +1313,7 @@ static void alloc_double_indirect_block(struct ext2_inode *file_inode,
for (i = 0; i < (fs->blksz / sizeof(int)); i++) {
di_blockno_child = ext4fs_get_new_blk_no();
if (di_blockno_child == -1) {
- printf("no block left to assign\n");
+ dbg_printf("no block left to assign\n");
goto fail;
}
di_child_buff = zalloc(fs->blksz);
@@ -1333,7 +1333,7 @@ static void alloc_double_indirect_block(struct ext2_inode *file_inode,
(char *)di_child_buff);
if (!status) {
- printf("%s: Device read error!\n", __func__);
+ dbg_printf("%s: Device read error!\n", __func__);
goto fail;
}
memset(di_child_buff, '\0', fs->blksz);
@@ -1341,7 +1341,7 @@ static void alloc_double_indirect_block(struct ext2_inode *file_inode,
for (j = 0; j < (fs->blksz / sizeof(int)); j++) {
actual_block_no = ext4fs_get_new_blk_no();
if (actual_block_no == -1) {
- printf("no block left to assign\n");
+ dbg_printf("no block left to assign\n");
goto fail;
}
*di_child_buff = cpu_to_le32(actual_block_no);
@@ -1393,7 +1393,7 @@ static void alloc_triple_indirect_block(struct ext2_inode *file_inode,
/* triple indirect grand parent block connecting to inode */
ti_gp_blockno = ext4fs_get_new_blk_no();
if (ti_gp_blockno == -1) {
- printf("no block left to assign\n");
+ dbg_printf("no block left to assign\n");
return;
}
ti_gp_buff = zalloc(fs->blksz);
@@ -1409,7 +1409,7 @@ static void alloc_triple_indirect_block(struct ext2_inode *file_inode,
for (i = 0; i < (fs->blksz / sizeof(int)); i++) {
ti_parent_blockno = ext4fs_get_new_blk_no();
if (ti_parent_blockno == -1) {
- printf("no block left to assign\n");
+ dbg_printf("no block left to assign\n");
goto fail;
}
ti_parent_buff = zalloc(fs->blksz);
@@ -1427,7 +1427,7 @@ static void alloc_triple_indirect_block(struct ext2_inode *file_inode,
for (j = 0; j < (fs->blksz / sizeof(int)); j++) {
ti_child_blockno = ext4fs_get_new_blk_no();
if (ti_child_blockno == -1) {
- printf("no block left assign\n");
+ dbg_printf("no block left assign\n");
goto fail1;
}
ti_child_buff = zalloc(fs->blksz);
@@ -1447,7 +1447,7 @@ static void alloc_triple_indirect_block(struct ext2_inode *file_inode,
actual_block_no =
ext4fs_get_new_blk_no();
if (actual_block_no == -1) {
- printf("no block left\n");
+ dbg_printf("no block left\n");
free(ti_cbuff_start_addr);
goto fail1;
}
@@ -1502,7 +1502,7 @@ void ext4fs_allocate_blocks(struct ext2_inode *file_inode,
for (i = 0; total_remaining_blocks && i < INDIRECT_BLOCKS; i++) {
direct_blockno = ext4fs_get_new_blk_no();
if (direct_blockno == -1) {
- printf("no block left to assign\n");
+ dbg_printf("no block left to assign\n");
return;
}
file_inode->b.blocks.dir_blocks[i] = cpu_to_le32(direct_blockno);
@@ -1674,7 +1674,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
inode->b.blocks.dir_blocks,
fileblock, log2_blksz);
if (!ext_block) {
- printf("invalid extent block\n");
+ dbg_printf("invalid extent block\n");
if (!cache)
ext_cache_fini(c);
return -EINVAL;
@@ -1716,7 +1716,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
if (ext4fs_indir1_block == NULL) {
ext4fs_indir1_block = zalloc(blksz);
if (ext4fs_indir1_block == NULL) {
- printf("** SI ext2fs read block (indir 1)"
+ dbg_printf("** SI ext2fs read block (indir 1)"
"malloc failed. **\n");
return -1;
}
@@ -1730,7 +1730,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
ext4fs_indir1_blkno = -1;
ext4fs_indir1_block = zalloc(blksz);
if (ext4fs_indir1_block == NULL) {
- printf("** SI ext2fs read block (indir 1):"
+ dbg_printf("** SI ext2fs read block (indir 1):"
"malloc failed. **\n");
return -1;
}
@@ -1744,7 +1744,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
indir_block) << log2_blksz, 0,
blksz, (char *)ext4fs_indir1_block);
if (status == 0) {
- printf("** SI ext2fs read block (indir 1)"
+ dbg_printf("** SI ext2fs read block (indir 1)"
"failed. **\n");
return -1;
}
@@ -1765,7 +1765,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
if (ext4fs_indir1_block == NULL) {
ext4fs_indir1_block = zalloc(blksz);
if (ext4fs_indir1_block == NULL) {
- printf("** DI ext2fs read block (indir 2 1)"
+ dbg_printf("** DI ext2fs read block (indir 2 1)"
"malloc failed. **\n");
return -1;
}
@@ -1779,7 +1779,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
ext4fs_indir1_blkno = -1;
ext4fs_indir1_block = zalloc(blksz);
if (ext4fs_indir1_block == NULL) {
- printf("** DI ext2fs read block (indir 2 1)"
+ dbg_printf("** DI ext2fs read block (indir 2 1)"
"malloc failed. **\n");
return -1;
}
@@ -1794,7 +1794,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
0, blksz,
(char *)ext4fs_indir1_block);
if (status == 0) {
- printf("** DI ext2fs read block (indir 2 1)"
+ dbg_printf("** DI ext2fs read block (indir 2 1)"
"failed. **\n");
return -1;
}
@@ -1806,7 +1806,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
if (ext4fs_indir2_block == NULL) {
ext4fs_indir2_block = zalloc(blksz);
if (ext4fs_indir2_block == NULL) {
- printf("** DI ext2fs read block (indir 2 2)"
+ dbg_printf("** DI ext2fs read block (indir 2 2)"
"malloc failed. **\n");
return -1;
}
@@ -1820,7 +1820,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
ext4fs_indir2_blkno = -1;
ext4fs_indir2_block = zalloc(blksz);
if (ext4fs_indir2_block == NULL) {
- printf("** DI ext2fs read block (indir 2 2)"
+ dbg_printf("** DI ext2fs read block (indir 2 2)"
"malloc failed. **\n");
return -1;
}
@@ -1835,7 +1835,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
blksz,
(char *)ext4fs_indir2_block);
if (status == 0) {
- printf("** DI ext2fs read block (indir 2 2)"
+ dbg_printf("** DI ext2fs read block (indir 2 2)"
"failed. **\n");
return -1;
}
@@ -1857,7 +1857,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
if (ext4fs_indir1_block == NULL) {
ext4fs_indir1_block = zalloc(blksz);
if (ext4fs_indir1_block == NULL) {
- printf("** TI ext2fs read block (indir 2 1)"
+ dbg_printf("** TI ext2fs read block (indir 2 1)"
"malloc failed. **\n");
return -1;
}
@@ -1871,7 +1871,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
ext4fs_indir1_blkno = -1;
ext4fs_indir1_block = zalloc(blksz);
if (ext4fs_indir1_block == NULL) {
- printf("** TI ext2fs read block (indir 2 1)"
+ dbg_printf("** TI ext2fs read block (indir 2 1)"
"malloc failed. **\n");
return -1;
}
@@ -1885,7 +1885,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
<< log2_blksz, 0, blksz,
(char *)ext4fs_indir1_block);
if (status == 0) {
- printf("** TI ext2fs read block (indir 2 1)"
+ dbg_printf("** TI ext2fs read block (indir 2 1)"
"failed. **\n");
return -1;
}
@@ -1897,7 +1897,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
if (ext4fs_indir2_block == NULL) {
ext4fs_indir2_block = zalloc(blksz);
if (ext4fs_indir2_block == NULL) {
- printf("** TI ext2fs read block (indir 2 2)"
+ dbg_printf("** TI ext2fs read block (indir 2 2)"
"malloc failed. **\n");
return -1;
}
@@ -1911,7 +1911,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
ext4fs_indir2_blkno = -1;
ext4fs_indir2_block = zalloc(blksz);
if (ext4fs_indir2_block == NULL) {
- printf("** TI ext2fs read block (indir 2 2)"
+ dbg_printf("** TI ext2fs read block (indir 2 2)"
"malloc failed. **\n");
return -1;
}
@@ -1928,7 +1928,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
log2_blksz, 0, blksz,
(char *)ext4fs_indir2_block);
if (status == 0) {
- printf("** TI ext2fs read block (indir 2 2)"
+ dbg_printf("** TI ext2fs read block (indir 2 2)"
"failed. **\n");
return -1;
}
@@ -1941,7 +1941,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
if (ext4fs_indir3_block == NULL) {
ext4fs_indir3_block = zalloc(blksz);
if (ext4fs_indir3_block == NULL) {
- printf("** TI ext2fs read block (indir 2 2)"
+ dbg_printf("** TI ext2fs read block (indir 2 2)"
"malloc failed. **\n");
return -1;
}
@@ -1955,7 +1955,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
ext4fs_indir3_blkno = -1;
ext4fs_indir3_block = zalloc(blksz);
if (ext4fs_indir3_block == NULL) {
- printf("** TI ext2fs read block (indir 2 2)"
+ dbg_printf("** TI ext2fs read block (indir 2 2)"
"malloc failed. **\n");
return -1;
}
@@ -1972,7 +1972,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock,
% (blksz / 4)]) << log2_blksz, 0,
blksz, (char *)ext4fs_indir3_block);
if (status == 0) {
- printf("** TI ext2fs read block (indir 2 2)"
+ dbg_printf("** TI ext2fs read block (indir 2 2)"
"failed. **\n");
return -1;
}
@@ -2049,7 +2049,7 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
#ifdef DEBUG
if (name != NULL)
- printf("Iterate dir %s\n", name);
+ dbg_printf("Iterate dir %s\n", name);
#endif /* of DEBUG */
if (!diro->inode_read) {
status = ext4fs_read_inode(diro->data, diro->ino, &diro->inode);
@@ -2067,7 +2067,7 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
return 0;
if (dirent.direntlen == 0) {
- printf("Failed to iterate over directory %s\n", name);
+ dbg_printf("Failed to iterate over directory %s\n", name);
return 0;
}
@@ -2128,7 +2128,7 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
}
}
#ifdef DEBUG
- printf("iterate >%s<\n", filename);
+ dbg_printf("iterate >%s<\n", filename);
#endif /* of DEBUG */
if ((name != NULL) && (fnode != NULL)
&& (ftype != NULL)) {
@@ -2151,19 +2151,19 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
}
switch (type) {
case FILETYPE_DIRECTORY:
- printf("<DIR> ");
+ dbg_printf("<DIR> ");
break;
case FILETYPE_SYMLINK:
- printf("<SYM> ");
+ dbg_printf("<SYM> ");
break;
case FILETYPE_REG:
- printf(" ");
+ dbg_printf(" ");
break;
default:
- printf("< ? > ");
+ dbg_printf("< ? > ");
break;
}
- printf("%10u %s\n",
+ dbg_printf("%10u %s\n",
le32_to_cpu(fdiro->inode.size),
filename);
}
@@ -2412,7 +2412,7 @@ int ext4fs_mount(unsigned part_length)
return 1;
fail:
- printf("Failed to mount ext2 filesystem...\n");
+ dbg_printf("Failed to mount ext2 filesystem...\n");
fail_noerr:
free(data);
ext4fs_root = NULL;
diff --git a/ext4_common.h b/ext4_common.h
index 145b0da..238ff63 100644
--- a/ext4_common.h
+++ b/ext4_common.h
@@ -42,6 +42,12 @@
#define ARCH_DMA_MINALIGN 64 /* should be ok for all architectures */
+#ifdef DEBUG_PRINTF
+#define dbg_printf printf
+#else
+#define dbg_printf(s, ...)
+#endif
+
static inline void *zalloc(size_t size)
{
void *p = memalign(ARCH_DMA_MINALIGN, size);
diff --git a/ext4_journal.c b/ext4_journal.c
index 3559daf..4a255d4 100644
--- a/ext4_journal.c
+++ b/ext4_journal.c
@@ -157,7 +157,7 @@ int ext4fs_log_journal(char *journal_buffer, uint32_t blknr)
short i;
if (!journal_buffer) {
- printf("Invalid input arguments %s\n", __func__);
+ dbg_printf("Invalid input arguments %s\n", __func__);
return -EINVAL;
}
@@ -187,7 +187,7 @@ int ext4fs_put_metadata(char *metadata_buffer, uint32_t blknr)
{
struct ext_filesystem *fs = get_fs();
if (!metadata_buffer) {
- printf("Invalid input arguments %s\n", __func__);
+ dbg_printf("Invalid input arguments %s\n", __func__);
return -EINVAL;
}
if (dirty_block_ptr[gd_index]->buf)
@@ -216,11 +216,11 @@ void print_revoke_blks(char *revk_blk)
header = (struct journal_revoke_header_t *) revk_blk;
offset = sizeof(struct journal_revoke_header_t);
max = be32_to_cpu(header->r_count);
- printf("total bytes %d\n", max);
+ dbg_printf("total bytes %d\n", max);
while (offset < max) {
blocknr = be32_to_cpu(*((__be32 *)(revk_blk + offset)));
- printf("revoke blknr is %ld\n", blocknr);
+ dbg_printf("revoke blknr is %ld\n", blocknr);
offset += 4;
}
}
@@ -242,12 +242,12 @@ void ext4fs_push_revoke_blk(char *buffer)
struct revoke_blk_list *node = NULL;
struct ext_filesystem *fs = get_fs();
if (buffer == NULL) {
- printf("buffer ptr is NULL\n");
+ dbg_printf("buffer ptr is NULL\n");
return;
}
node = _get_node();
if (!node) {
- printf("_get_node: malloc failed\n");
+ dbg_printf("_get_node: malloc failed\n");
return;
}
@@ -386,9 +386,9 @@ fail:
void print_jrnl_status(int recovery_flag)
{
if (recovery_flag == RECOVER)
- printf("Journal Recovery Completed\n");
+ dbg_printf("Journal Recovery Completed\n");
else
- printf("Journal Scan Completed\n");
+ dbg_printf("Journal Scan Completed\n");
}
int ext4fs_check_journal_state(int recovery_flag)
@@ -427,10 +427,10 @@ int ext4fs_check_journal_state(int recovery_flag)
if (le32_to_cpu(fs->sb->feature_incompat) & EXT3_FEATURE_INCOMPAT_RECOVER) {
if (recovery_flag == RECOVER)
- printf("Recovery required\n");
+ dbg_printf("Recovery required\n");
} else {
if (recovery_flag == RECOVER)
- printf("File System is consistent\n");
+ dbg_printf("File System is consistent\n");
goto end;
}
@@ -662,5 +662,5 @@ void ext4fs_update_journal(void)
}
blknr = read_allocated_block(&inode_journal, jrnl_blk_idx++, NULL);
update_commit_block(blknr);
- printf("update journal finished\n");
+ dbg_printf("update journal finished\n");
}
diff --git a/ext4_write.c b/ext4_write.c
index 3368bd8..5098435 100644
--- a/ext4_write.c
+++ b/ext4_write.c
@@ -120,7 +120,7 @@ int ext4fs_get_bgdtable(void)
goto fail;
if (ext4fs_log_gdt(fs->gdtable)) {
- printf("Error in ext4fs_log_gdt\n");
+ dbg_printf("Error in ext4fs_log_gdt\n");
return -1;
}
@@ -144,7 +144,7 @@ static void delete_single_indirect_block(struct ext2_inode *inode)
struct ext_filesystem *fs = get_fs();
char *journal_buffer = zalloc(fs->blksz);
if (!journal_buffer) {
- printf("No memory\n");
+ dbg_printf("No memory\n");
return;
}
@@ -195,14 +195,14 @@ static void delete_double_indirect_block(struct ext2_inode *inode)
struct ext_filesystem *fs = get_fs();
char *journal_buffer = zalloc(fs->blksz);
if (!journal_buffer) {
- printf("No memory\n");
+ dbg_printf("No memory\n");
return;
}
if (inode->b.blocks.double_indir_block != 0) {
di_buffer = zalloc(fs->blksz);
if (!di_buffer) {
- printf("No memory\n");
+ dbg_printf("No memory\n");
return;
}
dib_start_addr = di_buffer;
@@ -294,14 +294,14 @@ static void delete_triple_indirect_block(struct ext2_inode *inode)
struct ext_filesystem *fs = get_fs();
char *journal_buffer = zalloc(fs->blksz);
if (!journal_buffer) {
- printf("No memory\n");
+ dbg_printf("No memory\n");
return;
}
if (inode->b.blocks.triple_indir_block != 0) {
tigp_buffer = zalloc(fs->blksz);
if (!tigp_buffer) {
- printf("No memory\n");
+ dbg_printf("No memory\n");
return;
}
tib_start_addr = tigp_buffer;
@@ -576,7 +576,7 @@ static int ext4fs_delete_file(int inodeno)
ext4fs_reinit_global();
if (ext4fs_init() != 0) {
- printf("error in File System init\n");
+ dbg_printf("error in File System init\n");
goto fail;
}
@@ -622,7 +622,7 @@ int ext4fs_init(void)
/* get the block group descriptor table */
fs->gdtable_blkno = ((EXT2_MIN_BLOCK_SIZE == fs->blksz) + 1);
if (ext4fs_get_bgdtable() == -1) {
- printf("Error in getting the block group descriptor table\n");
+ dbg_printf("Error in getting the block group descriptor table\n");
goto fail;
}
@@ -873,12 +873,12 @@ int ext4fs_write(const char *fname, const char *buffer,
goto fail;
if (ext4fs_init() != 0) {
- printf("error in File System init\n");
+ dbg_printf("error in File System init\n");
return -1;
}
if (le32_to_cpu(fs->sb->feature_ro_compat) & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) {
- printf("Unsupported feature metadata_csum found, not writing.\n");
+ dbg_printf("Unsupported feature metadata_csum found, not writing.\n");
return -1;
}
@@ -890,7 +890,7 @@ int ext4fs_write(const char *fname, const char *buffer,
goto fail;
/* do not mess up a directory using hash trees */
if (le32_to_cpu(g_parent_inode->flags) & EXT4_INDEX_FL) {
- printf("hash tree directory\n");
+ dbg_printf("hash tree directory\n");
goto fail;
}
/* check if the filename is already present in root */
@@ -923,7 +923,7 @@ int ext4fs_write(const char *fname, const char *buffer,
blocks_remaining = blks_reqd_for_file;
/* test for available space in partition */
if (le32_to_cpu(fs->sb->free_blocks) < blks_reqd_for_file) {
- printf("Not enough space on partition !!!\n");
+ dbg_printf("Not enough space on partition !!!\n");
goto fail;
}
@@ -979,7 +979,7 @@ int ext4fs_write(const char *fname, const char *buffer,
goto fail;
/* copy the file content into data blocks */
if (ext4fs_write_file(file_inode, 0, sizebytes, buffer) == -1) {
- printf("Error in copying content\n");
+ dbg_printf("Error in copying content\n");
/* FIXME: Deallocate data blocks */
goto fail;
}
@@ -1039,13 +1039,13 @@ int ext4_write_file(const char *filename, void *buf, loff_t offset,
int ret;
if (offset != 0) {
- printf("** Cannot support non-zero offset **\n");
+ dbg_printf("** Cannot support non-zero offset **\n");
return -1;
}
ret = ext4fs_write(filename, buf, len, FILETYPE_REG);
if (ret) {
- printf("** Error ext4fs_write() **\n");
+ dbg_printf("** Error ext4fs_write() **\n");
goto fail;
}
diff --git a/ext4fs.c b/ext4fs.c
index 37b31d9..ba4c1da 100644
--- a/ext4fs.c
+++ b/ext4fs.c
@@ -190,7 +190,7 @@ int ext4fs_ls(const char *dirname)
status = ext4fs_find_file(dirname, &ext4fs_root->diropen, &dirnode,
FILETYPE_DIRECTORY);
if (status != 1) {
- printf("** Can not find directory. **\n");
+ dbg_printf("** Can not find directory. **\n");
if (dirnode)
ext4fs_free_node(dirnode, &ext4fs_root->diropen);
return 1;
@@ -245,7 +245,7 @@ int ext4_read_file(const char *filename, void *buf, loff_t offset, loff_t len,
ret = ext4fs_open(filename, &file_len);
if (ret < 0) {
- printf("** File not found %s **\n", filename);
+ dbg_printf("** File not found %s **\n", filename);
return -1;
}