int i;
ext2_inode_scan scan = 0;
ext2_ino_t ino;
- struct ext2_inode inode;
errcode_t retval;
+ struct ext2_inode *inode;
+ int inode_size;
char *block_buf;
if (argc < 2) {
if (check_fs_open(argv[0]))
return;
+ inode_size = EXT2_INODE_SIZE(current_fs->super);
+ retval = ext2fs_get_mem(inode_size, &inode);
+ if (retval)
+ return;
+
bw.barray = malloc(sizeof(struct block_info) * argc);
if (!bw.barray) {
+ ext2fs_free_mem(&inode);
com_err("icheck", ENOMEM,
"while allocating inode info array");
return;
}
do {
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
} while (retval == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE);
if (retval) {
com_err("icheck", retval, "while starting inode scan");
while (ino) {
blk64_t blk;
- if (!inode.i_links_count)
+ if (!inode->i_links_count)
goto next;
bw.inode = ino;
- blk = ext2fs_file_acl_block(current_fs, &inode);
+ blk = ext2fs_file_acl_block(current_fs, inode);
if (blk) {
icheck_proc(current_fs, &blk, 0,
0, 0, &bw);
if (bw.blocks_left == 0)
break;
- ext2fs_file_acl_block_set(current_fs, &inode, blk);
+ ext2fs_file_acl_block_set(current_fs, inode, blk);
}
- if (!ext2fs_inode_has_valid_blocks2(current_fs, &inode))
+ if (!ext2fs_inode_has_valid_blocks2(current_fs, inode))
goto next;
/*
* To handle filesystems touched by 0.3c extfs; can be
* removed later.
*/
- if (inode.i_dtime)
+ if (inode->i_dtime)
goto next;
retval = ext2fs_block_iterate3(current_fs, ino,
next:
do {
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
} while (retval == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE);
if (retval) {
com_err("icheck", retval,
}
error_out:
+ ext2fs_free_mem(&inode);
free(bw.barray);
free(block_buf);
if (scan)
int num_delarray, max_delarray;
ext2_inode_scan scan = 0;
ext2_ino_t ino;
- struct ext2_inode inode;
+ struct ext2_inode *inode = NULL;
+ int inode_size;
errcode_t retval;
char *block_buf;
int i;
"while opening inode scan");
goto error_out;
}
+ inode_size = EXT2_INODE_SIZE(current_fs->super);
+ retval = ext2fs_get_mem(inode_size, &inode);
+ if (retval)
+ goto error_out;
do {
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
} while (retval == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE);
if (retval) {
com_err("ls_deleted_inodes", retval,
}
while (ino) {
- if ((inode.i_dtime == 0) ||
- (secs && ((unsigned) abs(now - secs) > inode.i_dtime)))
+ if ((inode->i_dtime == 0) ||
+ (secs && ((unsigned) abs(now - secs) > inode->i_dtime)))
goto next;
lsd.inode = ino;
}
delarray[num_delarray].ino = ino;
- delarray[num_delarray].mode = inode.i_mode;
- delarray[num_delarray].uid = inode_uid(inode);
- delarray[num_delarray].size = EXT2_I_SIZE(&inode);
- delarray[num_delarray].dtime = inode.i_dtime;
+ delarray[num_delarray].mode = inode->i_mode;
+ delarray[num_delarray].uid = inode_uid(*inode);
+ delarray[num_delarray].size = EXT2_I_SIZE(inode);
+ delarray[num_delarray].dtime = inode->i_dtime;
delarray[num_delarray].num_blocks = lsd.num_blocks;
delarray[num_delarray].free_blocks = lsd.free_blocks;
num_delarray++;
next:
do {
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
} while (retval == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE);
if (retval) {
com_err("ls_deleted_inodes", retval,
close_pager(out);
error_out:
+ ext2fs_free_mem(&inode);
free(block_buf);
free(delarray);
if (scan)
int c, i;
ext2_inode_scan scan = 0;
ext2_ino_t ino;
- struct ext2_inode inode;
+ struct ext2_inode *inode = NULL;
+ int inode_size;
errcode_t retval;
char *tmp;
com_err("ncheck", retval, "while opening inode scan");
goto error_out;
}
+ inode_size = EXT2_INODE_SIZE(current_fs->super);
+ retval = ext2fs_get_mem(inode_size, &inode);
+ if (retval)
+ goto error_out;
do {
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
} while (retval == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE);
if (retval) {
com_err("ncheck", retval, "while starting inode scan");
printf("Inode\tPathname\n");
while (ino) {
- if (!inode.i_links_count)
+ if (!inode->i_links_count)
goto next;
/*
* To handle filesystems touched by 0.3c extfs; can be
* removed later.
*/
- if (inode.i_dtime)
+ if (inode->i_dtime)
goto next;
/* Ignore anything that isn't a directory */
- if (!LINUX_S_ISDIR(inode.i_mode))
+ if (!LINUX_S_ISDIR(inode->i_mode))
goto next;
iw.position = 0;
next:
do {
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
} while (retval == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE);
if (retval) {
}
error_out:
+ ext2fs_free_mem(inode);
free(iw.iarray);
if (scan)
ext2fs_close_inode_scan(scan);
* For pass1_check_directory and pass1_get_blocks
*/
ext2_ino_t stashed_ino;
- struct ext2_inode *stashed_inode;
+ struct ext2_inode_large *stashed_inode;
/*
* Location of the lost and found directory
ext2_filsys fs;
ext2_ino_t ino;
__u32 num_inodes = 0;
- struct ext2_inode inode;
+ struct ext2_inode *inode = NULL;
+ int inode_size;
+ int ret = 0;
ext2_inode_scan scan;
init_resource_track(&global_rtrack);
retval = ext2fs_open_inode_scan(fs, inode_buffer_blocks, &scan);
if (retval) {
com_err(program_name, retval, _("while opening inode scan"));
+ ext2fs_close_free(&fs);
+ exit(1);
+ }
+
+ inode_size = EXT2_INODE_SIZE(current_fs->super);
+ retval = ext2fs_get_mem(inode_size, &inode);
+ if (retval) {
+ ext2fs_close_inode_scan(&scan);
+ ext2fs_close_free(&fs);
exit(1);
}
while (1) {
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
if (retval) {
com_err(program_name, retval,
_("while getting next inode"));
+ ext2fs_close_inode_scan(&scan);
+ ext2fs_close_free(&fs);
+ ext2fs_free_mem(&inode);
exit(1);
}
if (ino == 0)
break;
num_inodes++;
}
-
+ ext2fs_free_mem(&inode);
print_resource_track(NULL, &global_rtrack);
printf(_("%u inodes scanned.\n"), num_inodes);
j_inode->i_ext2.i_mode = LINUX_S_IFREG | 0600;
e2fsck_use_inode_shortcuts(ctx, 1);
ctx->stashed_ino = j_inode->i_ino;
- ctx->stashed_inode = &j_inode->i_ext2;
+ ctx->stashed_inode = (struct ext2_inode_large *)&j_inode->i_ext2;
tried_backup_jnl++;
}
if (!j_inode->i_ext2.i_links_count ||
struct process_inode_block {
ext2_ino_t ino;
- struct ext2_inode inode;
+ struct ext2_inode_large inode;
};
struct scan_callback_struct {
return;
}
inode_size = EXT2_INODE_SIZE(fs->super);
- inode = (struct ext2_inode *)
- e2fsck_allocate_memory(ctx, inode_size, "scratch inode");
+ inode = e2fsck_allocate_memory(ctx, inode_size, "scratch inode");
- inodes_to_process = (struct process_inode_block *)
- e2fsck_allocate_memory(ctx,
+ inodes_to_process = e2fsck_allocate_memory(ctx,
(ctx->process_inode_size *
sizeof(struct process_inode_block)),
"array of inodes to process");
goto endit;
}
ext2fs_inode_scan_flags(scan, EXT2_SF_SKIP_MISSING_ITABLE, 0);
- ctx->stashed_inode = inode;
+ ctx->stashed_inode = (struct ext2_inode_large *)inode;
scan_struct.ctx = ctx;
scan_struct.block_buf = block_buf;
ext2fs_set_inode_callback(scan, scan_callback, &scan_struct);
inode->i_block[EXT2_TIND_BLOCK] ||
ext2fs_file_acl_block(fs, inode))) {
inodes_to_process[process_inode_count].ino = ino;
- inodes_to_process[process_inode_count].inode = *inode;
+ inodes_to_process[process_inode_count].inode =
+ *((struct ext2_inode_large *)inode);
process_inode_count++;
} else
check_blocks(ctx, &pctx, block_buf);
static void process_inodes(e2fsck_t ctx, char *block_buf)
{
int i;
- struct ext2_inode *old_stashed_inode;
+ struct ext2_inode_large *old_stashed_inode;
ext2_ino_t old_stashed_ino;
const char *old_operation;
char buf[80];
sizeof(struct process_inode_block), process_inode_cmp);
clear_problem_context(&pctx);
for (i=0; i < process_inode_count; i++) {
- pctx.inode = ctx->stashed_inode = &inodes_to_process[i].inode;
+ ctx->stashed_inode = &inodes_to_process[i].inode;
+ pctx.inode = (struct ext2_inode *)ctx->stashed_inode;
pctx.ino = ctx->stashed_ino = inodes_to_process[i].ino;
#if 0
* inodes, so it's OK to pass NULL to
* ext2fs_file_acl_block() here.
*/
- ret = ext2fs_file_acl_block(0, &(ib_a->inode)) -
- ext2fs_file_acl_block(0, &(ib_b->inode));
+ ret = ext2fs_file_acl_block(0, (struct ext2_inode *)&(ib_a->inode)) -
+ ext2fs_file_acl_block(0, (struct ext2_inode *)&(ib_b->inode));
if (ret == 0)
ret = ib_a->ino - ib_b->ino;
return ret;
if ((ino != ctx->stashed_ino) || !ctx->stashed_inode)
return EXT2_ET_CALLBACK_NOTHANDLED;
- *inode = *ctx->stashed_inode;
+ *inode = *(struct ext2_inode *)ctx->stashed_inode;
return 0;
}
e2fsck_t ctx = (e2fsck_t) fs->priv_data;
if ((ino == ctx->stashed_ino) && ctx->stashed_inode &&
- (inode != ctx->stashed_inode))
- *ctx->stashed_inode = *inode;
+ (inode != (struct ext2_inode *)ctx->stashed_inode))
+ *(struct ext2_inode *)ctx->stashed_inode = *inode;
return EXT2_ET_CALLBACK_NOTHANDLED;
}
{
ext2_filsys fs = ctx->fs;
ext2_ino_t ino = 0;
- struct ext2_inode inode;
+ struct ext2_inode *inode;
+ int inode_size;
ext2_inode_scan scan;
struct process_block_struct pb;
struct problem_context pctx;
ctx->flags |= E2F_FLAG_ABORT;
return;
}
- ctx->stashed_inode = &inode;
+ inode_size = EXT2_INODE_SIZE(fs->super);
+ pctx.errcode = ext2fs_get_mem(inode_size, &inode);
+ if (pctx.errcode) {
+ ext2fs_close_inode_scan(scan);
+ ctx->flags |= E2F_FLAG_ABORT;
+ return;
+ }
+
+ ctx->stashed_inode = (struct ext2_inode_large *)inode;
pb.ctx = ctx;
pb.pctx = &pctx;
pctx.str = "pass1b";
if (e2fsck_mmp_update(fs))
fatal_error(ctx, 0);
}
- pctx.errcode = ext2fs_get_next_inode(scan, &ino, &inode);
+ pctx.errcode = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE)
continue;
if (pctx.errcode) {
pb.ino = ino;
pb.dup_blocks = 0;
- pb.inode = &inode;
+ pb.inode = inode;
pb.cur_cluster = ~0;
pb.phys_cluster = ~0;
- if (ext2fs_inode_has_valid_blocks2(fs, &inode) ||
+ if (ext2fs_inode_has_valid_blocks2(fs, inode) ||
(ino == EXT2_BAD_INO))
pctx.errcode = ext2fs_block_iterate3(fs, ino,
BLOCK_FLAG_READ_ONLY, block_buf,
process_pass1b_block, &pb);
/* If the feature is not set, attrs will be cleared later anyway */
if ((fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR) &&
- ext2fs_file_acl_block(fs, &inode)) {
- blk64_t blk = ext2fs_file_acl_block(fs, &inode);
+ ext2fs_file_acl_block(fs, inode)) {
+ blk64_t blk = ext2fs_file_acl_block(fs, inode);
process_pass1b_block(fs, &blk,
BLOCK_COUNT_EXTATTR, 0, 0, &pb);
- ext2fs_file_acl_block_set(fs, &inode, blk);
+ ext2fs_file_acl_block_set(fs, inode, blk);
}
if (pb.dup_blocks) {
end_problem_latch(ctx, PR_LATCH_DBLOCK);
if (pctx.errcode)
fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
}
+ ext2fs_free_mem(&inode);
ext2fs_close_inode_scan(scan);
e2fsck_use_inode_shortcuts(ctx, 0);
}
int main (int argc, char *argv[])
{
errcode_t retval = 0;
- int exit_value = 0;
int i;
ext2_filsys fs;
ext2_inode_scan scan;
ext2_ino_t ino;
- struct ext2_inode inode;
+ struct ext2_inode *inode;
+ int inode_size;
printf(_("size of inode=%d\n"), sizeof(inode));
com_err(argv[0], retval, _("while opening inode scan"));
exit(1);
}
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+
+ inode_size = EXT2_INODE_SIZE(fs->super);
+ retval = ext2fs_get_mem(inode_size, &inode);
+ if (retval) {
+ com_err(argv[0], retval, _("while allocating inode memory"));
+ exit(1);
+ }
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
if (retval) {
com_err(argv[0], retval, _("while starting inode scan"));
exit(1);
}
while (ino) {
- if (!inode.i_links_count)
+ if (!inode->i_links_count)
goto next;
- printf("%lu\n", inode.i_blocks);
+ printf("%lu\n", inode->i_blocks);
next:
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
if (retval) {
com_err(argv[0], retval,
_("while doing inode scan"));
}
+ ext2fs_free_mem(&inode);
ext2fs_close_free(&fs);
print_resource_track(&global_rtrack);
-
- return exit_value;
+ return 0;
}
errcode_t retval;
char *block_buf;
ext2_inode_scan scan;
- struct ext2_inode inode;
+ struct ext2_inode *inode;
+ int inode_size;
ext2_ino_t ino;
dgrp_t nr;
time_t t;
default:
break;
}
+ inode_size = EXT2_INODE_SIZE(fs->super);
+ retval = ext2fs_get_mem(inode_size, &inode);
+ if (retval) {
+ fprintf(stderr, "%s: failed to allocate inode memory\n",
+ argv[0]);
+ exit(1);
+ }
t = time(NULL);
fprintf(stderr, "scanning inode tables .. ");
done_group_callback(fs, scan, -readahead_groups * 2, NULL);
done_group_callback(fs, scan, -readahead_groups, NULL);
- while (ext2fs_get_next_inode(scan, &ino, &inode) == 0) {
+ while (ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size) == 0) {
if (ino == 0)
break;
continue;
switch (scan_data.mode) {
case SM_DATABASE:
- database_iscan_action(ino, &inode, scan_data.db.fd,
+ database_iscan_action(ino, inode, scan_data.db.fd,
block_buf);
break;
case SM_FILELIST:
- filelist_iscan_action(ino, &inode, block_buf);
+ filelist_iscan_action(ino, inode, block_buf);
break;
default:
ext2fs_close_inode_scan(scan);
ext2fs_close(fs);
free(block_buf);
+ ext2fs_free_mem(&inode);
return 0;
}
int flags)
{
ext2_ino_t ino;
- struct ext2_inode inode;
+ struct ext2_inode *inode;
+ int inode_size;
errcode_t retval;
struct process_block_struct pb;
ext2_inode_scan scan;
- char *block_buf;
+ char *block_buf = NULL;
+
+ inode_size = EXT2_INODE_SIZE(fs->super);
+ retval = ext2fs_get_mem(inode_size, &inode);
+ if (retval)
+ return retval;
retval = ext2fs_open_inode_scan(fs, 0, &scan);
if (retval)
}
retval = ext2fs_init_dblist(fs, 0);
if (retval)
- return retval;
+ goto error;
}
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
if (retval)
- return retval;
+ goto error;
while (ino) {
- if ((inode.i_links_count == 0) ||
- !ext2fs_inode_has_valid_blocks2(fs, &inode))
+ if ((inode->i_links_count == 0) ||
+ !ext2fs_inode_has_valid_blocks2(fs, inode))
goto next;
pb.ino = ino;
- pb.inode = &inode;
+ pb.inode = inode;
pb.add_dir = (LINUX_S_ISDIR(inode.i_mode) &&
flags & EXT2_BMOVE_GET_DBLIST);
retval = ext2fs_block_iterate3(fs, ino, 0, block_buf,
process_block, &pb);
if (retval)
- return retval;
- if (pb.error)
- return pb.error;
+ goto error;
+ if (pb.error) {
+ retval = pb.error;
+ goto error;
+ }
next:
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
if (retval == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE)
goto next;
}
+error:
+ ext2fs_free_mem(&inode);
+ ext2fs_free_mem(&block_buf);
return 0;
}
(struct ext2_inode_large *) scan->temp_buffer,
0, bufsize);
#else
- *inode = *((struct ext2_inode *) scan->temp_buffer);
+ memcpy(inode, scan->temp_buffer, bufsize);
#endif
if (scan->scan_flags & EXT2_SF_BAD_EXTRA_BYTES)
retval = EXT2_ET_BAD_BLOCK_IN_INODE_TABLE;
*/
static void iterate(void)
{
- struct ext2_inode inode;
+ struct ext2_inode *inode;
+ int inode_size;
ext2_inode_scan scan;
errcode_t retval;
ext2_ino_t ino;
com_err("iterate", retval, "While opening inode scan");
exit(1);
}
+
+ inode_size = EXT2_INODE_SIZE(test_fs->super);
+ retval = ext2fs_get_mem(inode_size, &inode);
+ if (retval) {
+ com_err("iterate", retval, "while allocating inode mem");
+ exit(1);
+ }
printf("Reading blocks: ");
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
if (retval) {
com_err("iterate", retval, "while reading first inode");
exit(1);
}
while (ino) {
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
if (retval == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE) {
ext2fs_mark_inode_bitmap2(bad_inode_map, ino);
continue;
}
}
printf("\n");
+ ext2fs_free_mem(&inode);
ext2fs_close_inode_scan(scan);
}
ext2_filsys fs;
ext2_ino_t ino;
errcode_t ret;
- struct ext2_inode inode;
+ struct ext2_inode* inode;
+ int inode_size;
qsize_t space;
ext2_inode_scan scan;
if (!qctx)
return 0;
+ inode_size = EXT2_INODE_SIZE(qctx->fs->super);
+ ret = ext2fs_get_mem(inode_size, &inode);
+ if (ret)
+ return ret;
+
fs = qctx->fs;
ret = ext2fs_open_inode_scan(fs, 0, &scan);
if (ret) {
+ ext2fs_free_mem(&inode);
log_err("while opening inode scan. ret=%ld", ret);
return ret;
}
while (1) {
- ret = ext2fs_get_next_inode(scan, &ino, &inode);
+ ret = ext2fs_get_next_inode_full(scan, &ino, inode,
+ inode_size);
if (ret) {
log_err("while getting next inode. ret=%ld", ret);
- ext2fs_close_inode_scan(scan);
- return ret;
+ goto err;
}
if (ino == 0)
break;
- if (inode.i_links_count &&
+ if (inode->i_links_count &&
(ino == EXT2_ROOT_INO ||
ino >= EXT2_FIRST_INODE(fs->super))) {
- space = ext2fs_inode_i_blocks(fs, &inode) << 9;
- quota_data_add(qctx, &inode, ino, space);
- quota_data_inodes(qctx, &inode, ino, +1);
+ space = ext2fs_inode_i_blocks(fs, inode) << 9;
+ quota_data_add(qctx, inode, ino, space);
+ quota_data_inodes(qctx, inode, ino, +1);
}
}
+err:
ext2fs_close_inode_scan(scan);
+ ext2fs_free_mem(&inode);
- return 0;
+ return ret;
}
struct scan_dquots_data {
static void write_raw_image_file(ext2_filsys fs, int fd, int type, int flags)
{
struct process_block_struct pb;
- struct ext2_inode inode;
+ struct ext2_inode *inode;
+ int inode_size;
ext2_inode_scan scan;
ext2_ino_t ino;
errcode_t retval;
exit(1);
}
+ inode_size = EXT2_INODE_SIZE(fs->super);
+ retval = ext2fs_get_mem(inode_size, &inode);
+ if (retval) {
+ com_err(program_name, retval,
+ _("while allocating inode memory"));
+ exit(1);
+ }
+
use_inode_shortcuts(fs, 1);
- stashed_inode = &inode;
+ stashed_inode = inode;
while (1) {
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
if (retval == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE)
continue;
if (retval) {
}
if (ino == 0)
break;
- if (!inode.i_links_count)
+ if (!inode->i_links_count)
continue;
- if (ext2fs_file_acl_block(fs, &inode)) {
+ if (ext2fs_file_acl_block(fs, inode)) {
ext2fs_mark_block_bitmap2(meta_block_map,
- ext2fs_file_acl_block(fs, &inode));
+ ext2fs_file_acl_block(fs, inode));
meta_blocks_count++;
}
- if (!ext2fs_inode_has_valid_blocks2(fs, &inode))
+ if (!ext2fs_inode_has_valid_blocks2(fs, inode))
continue;
stashed_ino = ino;
pb.ino = ino;
- pb.is_dir = LINUX_S_ISDIR(inode.i_mode);
- if (LINUX_S_ISDIR(inode.i_mode) ||
- (LINUX_S_ISLNK(inode.i_mode) &&
- ext2fs_inode_has_valid_blocks2(fs, &inode)) ||
+ pb.is_dir = LINUX_S_ISDIR(inode->i_mode);
+ if (LINUX_S_ISDIR(inode->i_mode) ||
+ (LINUX_S_ISLNK(inode->i_mode) &&
+ ext2fs_inode_has_valid_blocks2(fs, inode)) ||
ino == fs->super->s_journal_inum) {
retval = ext2fs_block_iterate3(fs, ino,
BLOCK_FLAG_READ_ONLY, block_buf,
exit(1);
}
} else {
- if ((inode.i_flags & EXT4_EXTENTS_FL) ||
- inode.i_block[EXT2_IND_BLOCK] ||
- inode.i_block[EXT2_DIND_BLOCK] ||
- inode.i_block[EXT2_TIND_BLOCK] || all_data) {
+ if ((inode->i_flags & EXT4_EXTENTS_FL) ||
+ inode->i_block[EXT2_IND_BLOCK] ||
+ inode->i_block[EXT2_DIND_BLOCK] ||
+ inode->i_block[EXT2_TIND_BLOCK] || all_data) {
retval = ext2fs_block_iterate3(fs,
ino, BLOCK_FLAG_READ_ONLY, block_buf,
process_file_block, &pb);
else
output_meta_data_blocks(fs, fd, flags);
+ ext2fs_free_mem(&inode);
ext2fs_free_mem(&block_buf);
ext2fs_close_inode_scan(scan);
ext2fs_free_block_bitmap(meta_block_map);
ext2_ino_t ino;
blk64_t blk;
char *block_buf = 0;
- struct ext2_inode inode;
+ struct ext2_inode *inode;
+ int inode_size;
ext2_inode_scan scan = NULL;
- retval = ext2fs_get_mem(fs->blocksize * 3, &block_buf);
+ inode_size = EXT2_INODE_SIZE(fs->super);
+ retval = ext2fs_get_mem(inode_size, &inode);
if (retval)
return retval;
+ retval = ext2fs_get_mem(fs->blocksize * 3, &block_buf);
+ if (retval)
+ goto err_out;
+
retval = ext2fs_open_inode_scan(fs, 0, &scan);
if (retval)
goto err_out;
while (1) {
- retval = ext2fs_get_next_inode(scan, &ino, &inode);
+ retval = ext2fs_get_next_inode_full(scan, &ino,
+ inode, inode_size);
if (retval)
goto err_out;
if (!ino)
break;
- if (inode.i_links_count == 0)
+ if (inode->i_links_count == 0)
continue; /* inode not in use */
/* FIXME!!
* Do we need to fix this ??
*/
- if (ext2fs_file_acl_block(fs, &inode) &&
+ if (ext2fs_file_acl_block(fs, inode) &&
ext2fs_test_block_bitmap2(bmap,
- ext2fs_file_acl_block(fs, &inode))) {
+ ext2fs_file_acl_block(fs, inode))) {
blk = translate_block(ext2fs_file_acl_block(fs,
- &inode));
+ inode));
if (!blk)
continue;
- ext2fs_file_acl_block_set(fs, &inode, blk);
+ ext2fs_file_acl_block_set(fs, inode, blk);
/*
* Write the inode to disk so that inode table
* resizing can work
*/
- retval = ext2fs_write_inode(fs, ino, &inode);
+ retval = ext2fs_write_inode(fs, ino, inode);
if (retval)
goto err_out;
}
- if (!ext2fs_inode_has_valid_blocks2(fs, &inode))
+ if (!ext2fs_inode_has_valid_blocks2(fs, inode))
continue;
retval = ext2fs_block_iterate3(fs, ino, 0, block_buf,
}
err_out:
+ ext2fs_free_mem(&inode);
ext2fs_free_mem(&block_buf);
ext2fs_close_inode_scan(scan);
pb.error = 0;
new_inode = EXT2_FIRST_INODE(rfs->new_fs->super);
inode_size = EXT2_INODE_SIZE(rfs->new_fs->super);
- inode = malloc(inode_size);
- if (!inode) {
+ retval = ext2fs_get_mem(inode_size, &inode);
+ if (retval) {
retval = ENOMEM;
goto errout;
}
ext2fs_close_inode_scan(scan);
if (block_buf)
ext2fs_free_mem(&block_buf);
- free(inode);
+ if (inode)
+ ext2fs_free_mem(&inode);
return retval;
}