diff options
Diffstat (limited to 'ext4_common.c')
-rw-r--r-- | ext4_common.c | 116 |
1 files changed, 58 insertions, 58 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; |