Fix warnings
parent
97dc1bef18
commit
161e13aad8
2
Makefile
2
Makefile
|
@ -1,3 +1,3 @@
|
||||||
all: realloc-inodes
|
all: realloc-inodes
|
||||||
realloc-inodes: realloc-inodes.c
|
realloc-inodes: realloc-inodes.c
|
||||||
gcc -o realloc-inodes -lcom_err -lext2fs realloc-inodes.c
|
gcc -Wall -o realloc-inodes -lcom_err -lext2fs realloc-inodes.c
|
||||||
|
|
|
@ -118,7 +118,7 @@ ext2_ino_t realloc_search_inode_map(realloc_data *rd, ext2_ino_t old)
|
||||||
int shrink_move_inodes(realloc_data *rd)
|
int shrink_move_inodes(realloc_data *rd)
|
||||||
{
|
{
|
||||||
int retval = 0, inode_size = EXT2_INODE_SIZE(rd->fs->super);
|
int retval = 0, inode_size = EXT2_INODE_SIZE(rd->fs->super);
|
||||||
__u32 group, i, last = rd->inode_map_size;
|
__u32 group, i;
|
||||||
__u32 new_group;
|
__u32 new_group;
|
||||||
ext2_ino_t ino, new_ino;
|
ext2_ino_t ino, new_ino;
|
||||||
struct ext2_inode *inode = NULL;
|
struct ext2_inode *inode = NULL;
|
||||||
|
@ -241,7 +241,7 @@ int change_super_and_bgd(realloc_data *rd)
|
||||||
blk64_t it_start, blk;
|
blk64_t it_start, blk;
|
||||||
dgrp_t grp, n_flex, n_grp;
|
dgrp_t grp, n_flex, n_grp;
|
||||||
__u32 unus;
|
__u32 unus;
|
||||||
int i_per_g_diff;
|
int i_per_g_diff = 0;
|
||||||
int flexbg_size = 0, i, retval = 0;
|
int flexbg_size = 0, i, retval = 0;
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
ext2fs_flush(rd->fs);
|
ext2fs_flush(rd->fs);
|
||||||
|
@ -463,10 +463,8 @@ const char *program_name = "realloc-inodes";
|
||||||
int main(int narg, char **args)
|
int main(int narg, char **args)
|
||||||
{
|
{
|
||||||
realloc_data rd = { 0 };
|
realloc_data rd = { 0 };
|
||||||
int optind, fd, retval, io_flags = 0, force = 0;
|
int optind, retval, io_flags = 0, force = 0;
|
||||||
ext2fs_struct_stat st_buf;
|
ext2fs_struct_stat st_buf;
|
||||||
char *device_name, *io_options;
|
|
||||||
|
|
||||||
if (narg < 3)
|
if (narg < 3)
|
||||||
{
|
{
|
||||||
printf("USAGE: ./realloc-inodes <device> <new_inode_count>\n");
|
printf("USAGE: ./realloc-inodes <device> <new_inode_count>\n");
|
||||||
|
@ -475,9 +473,8 @@ int main(int narg, char **args)
|
||||||
optind = 1;
|
optind = 1;
|
||||||
rd.device_name = args[optind++];
|
rd.device_name = args[optind++];
|
||||||
rd.new_inode_count = atou(args[optind++]);
|
rd.new_inode_count = atou(args[optind++]);
|
||||||
|
|
||||||
add_error_table(&et_ext2_error_table);
|
add_error_table(&et_ext2_error_table);
|
||||||
|
// Open FS
|
||||||
rd.fs_fd = ext2fs_open_file(rd.device_name, O_RDWR, 0);
|
rd.fs_fd = ext2fs_open_file(rd.device_name, O_RDWR, 0);
|
||||||
if (rd.fs_fd < 0)
|
if (rd.fs_fd < 0)
|
||||||
{
|
{
|
||||||
|
@ -506,17 +503,26 @@ int main(int narg, char **args)
|
||||||
{
|
{
|
||||||
com_err(program_name, retval, _("while trying to open %s"), rd.device_name);
|
com_err(program_name, retval, _("while trying to open %s"), rd.device_name);
|
||||||
printf(_("Couldn't find valid filesystem superblock.\n"));
|
printf(_("Couldn't find valid filesystem superblock.\n"));
|
||||||
exit(1);
|
goto close_fd;
|
||||||
}
|
}
|
||||||
if (!force && ((rd.fs->super->s_state & EXT2_ERROR_FS) || ((rd.fs->super->s_state & EXT2_VALID_FS) == 0)))
|
if (!force && ((rd.fs->super->s_state & EXT2_ERROR_FS) || ((rd.fs->super->s_state & EXT2_VALID_FS) == 0)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, _("Please run 'e2fsck -f %s' first.\n\n"), rd.device_name);
|
fprintf(stderr, _("Please run 'e2fsck -f %s' first.\n\n"), rd.device_name);
|
||||||
exit(1);
|
goto close_fs;
|
||||||
}
|
}
|
||||||
do_realloc(&rd);
|
// Call main realloc function
|
||||||
|
retval = do_realloc(&rd);
|
||||||
|
if (retval)
|
||||||
|
{
|
||||||
|
com_err(program_name, retval, _("while resizing inode count"));
|
||||||
|
goto close_fs;
|
||||||
|
}
|
||||||
|
close_fs:
|
||||||
ext2fs_close(rd.fs);
|
ext2fs_close(rd.fs);
|
||||||
|
close_fd:
|
||||||
if (rd.fs_fd > 0)
|
if (rd.fs_fd > 0)
|
||||||
{
|
{
|
||||||
close(rd.fs_fd);
|
close(rd.fs_fd);
|
||||||
}
|
}
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue