kbytes_written = stats->bytes_written >> 10;
ext2fs_mmp_stop(fs);
- fsname = strdup(fs->device_name);
+ fsname = fs->device_name;
+ fs->device_name = NULL;
fsflags = fs->flags;
fsblocksize = fs->blocksize;
ext2fs_free(fs);
- retval = ext2fs_open(fsname, fsflags,
- 0, fsblocksize, io_ptr,
- fsp);
- free(fsname);
+ *fsp = NULL;
+ retval = ext2fs_open(fsname, fsflags, 0, fsblocksize, io_ptr, fsp);
+ ext2fs_free_mem(&fsname);
if (retval)
return retval;
fctx.err_fp = fopen(logfile, "a");
if (!fctx.err_fp) {
perror(logfile);
- goto out_nofs;
+ goto out;
}
} else
fctx.err_fp = stderr;
if (err) {
printf(_("%s: %s.\n"), fctx.device, error_message(err));
printf(_("Please run e2fsck -fy %s.\n"), fctx.device);
- goto out_nofs;
+ goto out;
}
fctx.fs = global_fs;
global_fs->priv_data = &fctx;
ret = 0;
out:
- err = ext2fs_close(global_fs);
- if (err)
- com_err(argv[0], err, "while closing fs");
- global_fs = NULL;
-out_nofs:
-
+ if (global_fs) {
+ err = ext2fs_close(global_fs);
+ if (err)
+ com_err(argv[0], err, "while closing fs");
+ global_fs = NULL;
+ }
return ret;
}
static void convert_64bit(ext2_filsys fs, int direction)
{
- if (!direction)
- return;
-
/*
* Is resize2fs going to demand a fsck run? Might as well tell the
* user now.
if (err) {
com_err("tune2fs", err, "while recovering journal.\n");
printf(_("Please run e2fsck -fy %s.\n"), argv[1]);
- goto closefs;
+ if (fs)
+ ext2fs_close_free(&fs);
+ exit(1);
}
ext2fs_clear_feature_journal_needs_recovery(fs->super);
ext2fs_mark_super_dirty(fs);
#endif
}
- convert_64bit(fs, feature_64bit);
+ if (feature_64bit)
+ convert_64bit(fs, feature_64bit);
return (ext2fs_close_free(&fs) ? 1 : 0);
}