while ((i = getopt(argc, argv, "f:")) != -1) {
switch (i) {
case 'f':
+ if (fp)
+ fclose(fp);
fp = fopen(optarg, "w");
if (fp == NULL) {
perror(optarg);
while ((i = getopt(argc, argv, "f:")) != -1) {
switch (i) {
case 'f':
+ if (fp)
+ fclose(fp);
fp = fopen(optarg, "r");
if (fp == NULL) {
perror(optarg);
pctx->blk2 = extent.e_lblk;
pctx->num = e_info.curr_level - 1;
problem = PR_1_EXTENT_INDEX_START_INVALID;
- if (fix_problem(ctx, problem, pctx))
- ext2fs_extent_fix_parents(ehandle);
+ if (fix_problem(ctx, problem, pctx)) {
+ pctx->errcode =
+ ext2fs_extent_fix_parents(ehandle);
+ if (pctx->errcode)
+ return;
+ }
}
scan_extent_node(ctx, pctx, pb, extent.e_lblk,
last_lblk, eof_block, ehandle);
return;
}
- should_be = sb->s_inodes_per_group * fs->group_desc_count;
+ should_be = (blk64_t)sb->s_inodes_per_group * fs->group_desc_count;
+ if (should_be > UINT_MAX)
+ should_be = UINT_MAX;
if (sb->s_inodes_count != should_be) {
pctx.ino = sb->s_inodes_count;
pctx.ino2 = should_be;
goto errout;
retval = 0;
- /* Jump forward to the next extent. */
- (void) ext2fs_extent_goto(handle, next_lblk);
+ /*
+ * Jump forward to the next extent. If there are
+ * errors, the ext2fs_extent_get down below will
+ * capture them for us.
+ */
+ (void)ext2fs_extent_goto(handle, next_lblk);
op = EXT2_EXTENT_CURRENT;
}
if (retval)
case S_IFSOCK:
mode = LINUX_S_IFSOCK;
filetype = EXT2_FT_SOCK;
+ break;
default:
- abort();
- /* NOTREACHED */
+ return EXT2_ET_INVALID_ARGUMENT;
}
if (!(fs->flags & EXT2_FLAG_RW)) {
}
if (retval) {
com_err(name, retval, 0);
- return -1;
+ return retval;
}
if (ext2fs_test_inode_bitmap2(fs->inode_map, ino))
com_err(__func__, 0, "Warning: inode already set");
int bufsize = IO_BUFSIZE;
int make_holes = 0;
- fd = open(src, O_RDONLY);
+ fd = ext2fs_open_file(src, O_RDONLY, 0);
if (fd < 0) {
com_err(src, errno, 0);
return errno;
com_err(__func__, errno,
_("while trying to readlink \"%s\""),
name);
- return errno;
+ retval = errno;
+ goto out;
}
ln_target[read_cnt] = '\0';
retval = do_symlink_internal(fs, parent_ino, name,