aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2005-12-10 21:50:30 -0500
committerTheodore Ts'o <tytso@mit.edu>2005-12-10 21:50:30 -0500
commit9b9a780f5a5823865f62f0c9fd194d262f63a06f (patch)
tree9cf96489ddfc5de1c9a36ec0b20e0f62dcb73be7
parentbc47952f10ff5ed2c61536f2713d54b6807795cd (diff)
downloade2fsprogs-9b9a780f5a5823865f62f0c9fd194d262f63a06f.tar.gz
e2fsprogs-9b9a780f5a5823865f62f0c9fd194d262f63a06f.tar.xz
e2fsprogs-9b9a780f5a5823865f62f0c9fd194d262f63a06f.zip
Fix various gcc -Wall complaints.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--debugfs/ChangeLog5
-rw-r--r--debugfs/debugfs.c72
-rw-r--r--debugfs/debugfs.h3
-rw-r--r--debugfs/logdump.c14
-rw-r--r--debugfs/ls.c2
-rw-r--r--lib/ext2fs/ChangeLog18
-rw-r--r--lib/ext2fs/bitops.h2
-rw-r--r--lib/ext2fs/ext2fs.h2
-rw-r--r--lib/ext2fs/initialize.c2
-rw-r--r--lib/ext2fs/mkjournal.c6
-rw-r--r--lib/ext2fs/read_bb_file.c18
-rw-r--r--lib/ext2fs/res_gdt.c4
-rw-r--r--misc/ChangeLog5
-rw-r--r--misc/dumpe2fs.c42
-rw-r--r--misc/e2image.c6
-rw-r--r--misc/filefrag.c2
-rw-r--r--misc/mke2fs.c146
17 files changed, 200 insertions, 149 deletions
diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog
index f92dc802..3d7193d0 100644
--- a/debugfs/ChangeLog
+++ b/debugfs/ChangeLog
@@ -1,3 +1,8 @@
+2005-12-10 Theodore Ts'o <tytso@mit.edu>
+
+ * debugfs.c, debugfs.h, logdump.c, ls.c: Clean up various gcc
+ -Wall complaints.
+
2005-09-24 Theodore Ts'o <tytso@mit.edu>
* set_fields.c (parse_time), util.c (string_to_time), debugfs.c
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 20d1f4bf..7eb7dc62 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -120,7 +120,6 @@ errout:
void do_open_filesys(int argc, char **argv)
{
- const char *usage = "Usage: open [-s superblock] [-b blocksize] [-c] [-w] <device>";
int c, err;
int catastrophic = 0;
blk_t superblock = 0;
@@ -159,19 +158,22 @@ void do_open_filesys(int argc, char **argv)
return;
break;
default:
- com_err(argv[0], 0, usage);
- return;
+ goto print_usage;
}
}
if (optind != argc-1) {
- com_err(argv[0], 0, usage);
- return;
+ goto print_usage;
}
if (check_fs_not_open(argv[0]))
return;
open_filesystem(argv[optind], open_flags,
superblock, blocksize, catastrophic,
data_filename);
+ return;
+
+print_usage:
+ fprintf(stderr, "%s: Usage: open [-s superblock] [-b blocksize] "
+ "[-c] [-w] <device>\n", argv[0]);
}
void do_lcd(int argc, char **argv)
@@ -195,16 +197,16 @@ static void close_filesystem(NOARGS)
if (current_fs->flags & EXT2_FLAG_IB_DIRTY) {
retval = ext2fs_write_inode_bitmap(current_fs);
if (retval)
- com_err("ext2fs_write_inode_bitmap", retval, "");
+ com_err("ext2fs_write_inode_bitmap", retval, 0);
}
if (current_fs->flags & EXT2_FLAG_BB_DIRTY) {
retval = ext2fs_write_block_bitmap(current_fs);
if (retval)
- com_err("ext2fs_write_block_bitmap", retval, "");
+ com_err("ext2fs_write_block_bitmap", retval, 0);
}
retval = ext2fs_close(current_fs);
if (retval)
- com_err("ext2fs_close", retval, "");
+ com_err("ext2fs_close", retval, 0);
current_fs = NULL;
return;
}
@@ -268,7 +270,6 @@ void do_show_super_stats(int argc, char *argv[])
struct ext2_group_desc *gdp;
int c, header_only = 0;
int numdirs = 0;
- const char *usage = "Usage: show_super [-h]";
reset_getopt();
while ((c = getopt (argc, argv, "h")) != EOF) {
@@ -277,13 +278,11 @@ void do_show_super_stats(int argc, char *argv[])
header_only++;
break;
default:
- com_err(argv[0], 0, usage);
- return;
+ goto print_usage;
}
}
if (optind != argc) {
- com_err(argv[0], 0, usage);
- return;
+ goto print_usage;
}
if (check_fs_open(argv[0]))
return;
@@ -317,6 +316,9 @@ void do_show_super_stats(int argc, char *argv[])
gdp->bg_used_dirs_count != 1 ? "directories"
: "directory");
close_pager(out);
+ return;
+print_usage:
+ fprintf(stderr, "%s: Usage: show_super [-h]\n", argv[0]);
}
void do_dirty_filesys(int argc EXT2FS_ATTR((unused)),
@@ -403,7 +405,7 @@ static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
return 0;
}
-void dump_xattr_string(FILE *out, const unsigned char *str, int len)
+static void dump_xattr_string(FILE *out, const char *str, int len)
{
int printable = 1;
int i;
@@ -422,14 +424,14 @@ void dump_xattr_string(FILE *out, const unsigned char *str, int len)
fprintf(out, "%02x ", str[i]);
}
-void internal_dump_inode_extra(FILE *out, const char *prefix,
- ext2_ino_t inode_num, struct ext2_inode_large *inode)
+static void internal_dump_inode_extra(FILE *out, const char *prefix,
+ ext2_ino_t inode_num,
+ struct ext2_inode_large *inode)
{
struct ext2_ext_attr_entry *entry;
__u32 *magic;
char *start, *end;
- int storage_size;
- int i;
+ unsigned int storage_size;
fprintf(out, "Size of extra inode fields: %d\n", inode->i_extra_isize);
if (inode->i_extra_isize > EXT2_INODE_SIZE(current_fs->super) -
@@ -631,7 +633,7 @@ void do_chroot(int argc, char *argv[])
retval = ext2fs_check_directory(current_fs, inode);
if (retval) {
- com_err(argv[1], retval, "");
+ com_err(argv[1], retval, 0);
return;
}
root = inode;
@@ -902,7 +904,7 @@ void do_change_working_dir(int argc, char *argv[])
retval = ext2fs_check_directory(current_fs, inode);
if (retval) {
- com_err(argv[1], retval, "");
+ com_err(argv[1], retval, 0);
return;
}
cwd = inode;
@@ -1013,7 +1015,7 @@ static void make_link(char *sourcename, char *destname)
retval = ext2fs_link(current_fs, dir, dest, ino,
ext2_file_type(inode.i_mode));
if (retval)
- com_err("make_link", retval, "");
+ com_err("make_link", retval, 0);
return;
}
@@ -1096,7 +1098,7 @@ static void unlink_file_by_name(char *filename)
}
retval = ext2fs_unlink(current_fs, dir, basename, 0, 0);
if (retval)
- com_err("unlink_file_by_name", retval, "");
+ com_err("unlink_file_by_name", retval, 0);
return;
}
@@ -1148,7 +1150,7 @@ void do_find_free_block(int argc, char *argv[])
retval = ext2fs_new_block(current_fs, free_blk + 1, 0,
&free_blk);
if (retval) {
- com_err("ext2fs_new_block", retval, "");
+ com_err("ext2fs_new_block", retval, 0);
return;
} else
printf("%d ", free_blk);
@@ -1190,7 +1192,7 @@ void do_find_free_inode(int argc, char *argv[])
retval = ext2fs_new_inode(current_fs, dir, mode, 0, &free_inode);
if (retval)
- com_err("ext2fs_new_inode", retval, "");
+ com_err("ext2fs_new_inode", retval, 0);
else
printf("Free inode found: %u\n", free_inode);
}
@@ -1251,11 +1253,11 @@ void do_write(int argc, char *argv[])
fd = open(argv[1], O_RDONLY);
if (fd < 0) {
- com_err(argv[1], errno, "");
+ com_err(argv[1], errno, 0);
return;
}
if (fstat(fd, &statbuf) < 0) {
- com_err(argv[1], errno, "");
+ com_err(argv[1], errno, 0);
close(fd);
return;
}
@@ -1269,7 +1271,7 @@ void do_write(int argc, char *argv[])
retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &newfile);
if (retval) {
- com_err(argv[0], retval, "");
+ com_err(argv[0], retval, 0);
close(fd);
return;
}
@@ -1286,7 +1288,7 @@ void do_write(int argc, char *argv[])
EXT2_FT_REG_FILE);
}
if (retval) {
- com_err(argv[2], retval, "");
+ com_err(argv[2], retval, 0);
close(fd);
return;
}
@@ -1306,7 +1308,7 @@ void do_write(int argc, char *argv[])
if (LINUX_S_ISREG(inode.i_mode)) {
retval = copy_file(fd, newfile);
if (retval)
- com_err("copy_file", retval, "");
+ com_err("copy_file", retval, 0);
}
close(fd);
}
@@ -1359,7 +1361,7 @@ void do_mknod(int argc, char *argv[])
return;
retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &newfile);
if (retval) {
- com_err(argv[0], retval, "");
+ com_err(argv[0], retval, 0);
return;
}
printf("Allocated inode: %u\n", newfile);
@@ -1374,7 +1376,7 @@ void do_mknod(int argc, char *argv[])
filetype);
}
if (retval) {
- com_err(argv[1], retval, "");
+ com_err(argv[1], retval, 0);
return;
}
if (ext2fs_test_inode_bitmap(current_fs->inode_map,newfile))
@@ -1413,7 +1415,7 @@ void do_mkdir(int argc, char *argv[])
*cp = 0;
parent = string_to_inode(argv[1]);
if (!parent) {
- com_err(argv[1], ENOENT, "");
+ com_err(argv[1], ENOENT, 0);
return;
}
name = cp+1;
@@ -1433,7 +1435,7 @@ try_again:
goto try_again;
}
if (retval) {
- com_err("ext2fs_mkdir", retval, "");
+ com_err("ext2fs_mkdir", retval, 0);
return;
}
@@ -1619,7 +1621,7 @@ void do_expand_dir(int argc, char *argv[])
retval = ext2fs_expand_dir(current_fs, inode);
if (retval)
- com_err("ext2fs_expand_dir", retval, "");
+ com_err("ext2fs_expand_dir", retval, 0);
return;
}
@@ -1701,8 +1703,6 @@ void do_imap(int argc, char *argv[])
void do_set_current_time(int argc, char *argv[])
{
- ext2_ino_t ino;
- unsigned long group, block, block_nr, offset;
time_t now;
if (common_args_process(argc, argv, 2, 2, argv[0],
diff --git a/debugfs/debugfs.h b/debugfs/debugfs.h
index 3081cce4..449563f9 100644
--- a/debugfs/debugfs.h
+++ b/debugfs/debugfs.h
@@ -44,6 +44,8 @@ extern int common_block_args_process(int argc, char *argv[],
blk_t *block, int *count);
extern int debugfs_read_inode(ext2_ino_t ino, struct ext2_inode * inode,
const char *cmd);
+extern int debugfs_read_inode_full(ext2_ino_t ino, struct ext2_inode * inode,
+ const char *cmd, int bufsize);
extern int debugfs_write_inode(ext2_ino_t ino, struct ext2_inode * inode,
const char *cmd);
extern int debugfs_write_new_inode(ext2_ino_t ino, struct ext2_inode * inode,
@@ -120,4 +122,5 @@ extern void do_expand_dir(int argc, char **argv);
extern void do_features(int argc, char **argv);
extern void do_bmap(int argc, char **argv);
extern void do_imap(int argc, char **argv);
+extern void do_set_current_time(int argc, char **argv);
diff --git a/debugfs/logdump.c b/debugfs/logdump.c
index ab85ffef..74bbc8d5 100644
--- a/debugfs/logdump.c
+++ b/debugfs/logdump.c
@@ -70,7 +70,6 @@ static void do_hexdump (FILE *, char *, int);
blocknr -= (be32_to_cpu((jsb)->s_maxlen) - \
be32_to_cpu((jsb)->s_first));
-
void do_logdump(int argc, char **argv)
{
int c;
@@ -86,9 +85,6 @@ void do_logdump(int argc, char **argv)
struct ext2_inode journal_inode;
ext2_file_t journal_file;
char *tmp;
- const char *logdump_usage = ("Usage: logdump "
- "[-ac] [-b<block>] [-i<inode>] "
- "[-f<journal_file>] [output_file]");
struct journal_source journal_source;
struct ext2_super_block *es = NULL;
@@ -132,13 +128,11 @@ void do_logdump(int argc, char **argv)
use_sb++;
break;
default:
- com_err(argv[0], 0, logdump_usage);
- return;
+ goto print_usage;
}
}
if (optind != argc && optind != argc-1) {
- com_err(argv[0], 0, logdump_usage);
- return;
+ goto print_usage;
}
if (current_fs)
@@ -267,6 +261,10 @@ void do_logdump(int argc, char **argv)
fclose(out_file);
return;
+
+print_usage:
+ fprintf(stderr, "%s: Usage: logdump [-ac] [-b<block>] [-i<inode>]\n\t"
+ "[-f<journal_file>] [output_file]\n", argv[0]);
}
diff --git a/debugfs/ls.c b/debugfs/ls.c
index 72874eb2..f1c52c99 100644
--- a/debugfs/ls.c
+++ b/debugfs/ls.c
@@ -157,7 +157,7 @@ void do_list_dir(int argc, char *argv[])
fprintf(ls.f, "\n");
close_pager(ls.f);
if (retval)
- com_err(argv[1], retval, "");
+ com_err(argv[1], retval, 0);
return;
}
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index a4295fb5..0db4eff4 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,5 +1,23 @@
2005-12-10 Theodore Ts'o <tytso@mit.edu>
+ * res_gdt.c (ext2fs_create_resize_inode): Fix type-punning warning.
+
+ * read_bb_file.c (ext2fs_read_bb_FILE): Use a data structure
+ instead of stuffing a function pointer dirctly into a void
+ pointer, since that isn't portable.
+
+ * mkjournal.c (ext2fs_add_journal_inode): Fix possiblely
+ uninitialized use of variable warning.
+
+ * initialize.c (calc_reserved_gdt_blocks): Fix signed vs. unsigned
+ type complaint.
+
+ * ext2fs.h: Make the type of the 'now' field to be time_t to avoid
+ gcc -Wall complaints.
+
+ * bitops.h (ext2fs_find_first_bit_set): Fix signed vs unsigned
+ type error.
+
* tst_badblocks.c (file_test_invalid): Add test which confirms
proper detection of invalid block numbers in
ext2fs_read_bb_FILE().
diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h
index 8d7c7206..cb4d8a39 100644
--- a/lib/ext2fs/bitops.h
+++ b/lib/ext2fs/bitops.h
@@ -318,7 +318,7 @@ _INLINE_ __u32 ext2fs_swab32(__u32 val)
#if !defined(_EXT2_HAVE_ASM_FINDBIT_)
_INLINE_ int ext2fs_find_first_bit_set(void * addr, unsigned size)
{
- char *cp = (unsigned char *) addr;
+ char *cp = (char *) addr;
int res = 0, d0;
if (!size)
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index d70e1b0c..fd99c3eb 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -229,7 +229,7 @@ struct struct_ext2_filsys {
struct ext2_super_block * orig_super;
struct ext2_image_hdr * image_header;
__u32 umask;
- __u32 now;
+ time_t now;
/*
* Reserved for future expansion
*/
diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index 5a0d100c..71e279da 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -79,7 +79,7 @@ static int calc_reserved_gdt_blocks(ext2_filsys fs)
max_blocks = sb->s_blocks_count * 1024;
rsv_groups = (max_blocks - sb->s_first_data_block + bpg - 1) / bpg;
rsv_gdb = (rsv_groups + gdpb - 1) / gdpb - fs->desc_blocks;
- if (rsv_gdb > EXT2_ADDR_PER_BLOCK(sb))
+ if (rsv_gdb > (int) EXT2_ADDR_PER_BLOCK(sb))
rsv_gdb = EXT2_ADDR_PER_BLOCK(sb);
#ifdef RES_GDT_DEBUG
printf("max_blocks %lu, rsv_groups = %lu, rsv_gdb = %lu\n",
diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c
index eb350137..4fe67c5b 100644
--- a/lib/ext2fs/mkjournal.c
+++ b/lib/ext2fs/mkjournal.c
@@ -318,7 +318,8 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags)
ext2_ino_t journal_ino;
struct stat st;
char jfile[1024];
- int fd, mount_flags, f;
+ int mount_flags, f;
+ int fd = -1;
if ((retval = ext2fs_check_mount_point(fs->device_name, &mount_flags,
jfile, sizeof(jfile)-10)))
@@ -388,7 +389,8 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags)
ext2fs_mark_super_dirty(fs);
return 0;
errout:
- close(fd);
+ if (fd > 0)
+ close(fd);
return retval;
}
diff --git a/lib/ext2fs/read_bb_file.c b/lib/ext2fs/read_bb_file.c
index 40c34ee3..2ac71f46 100644
--- a/lib/ext2fs/read_bb_file.c
+++ b/lib/ext2fs/read_bb_file.c
@@ -71,15 +71,19 @@ errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f,
return 0;
}
+struct compat_struct {
+ void (*invalid)(ext2_filsys, blk_t);
+};
+
static void call_compat_invalid(ext2_filsys fs, blk_t blk,
char *badstr EXT2FS_ATTR((unused)),
void *priv_data)
{
- void (*invalid)(ext2_filsys, blk_t);
+ struct compat_struct *st;
- invalid = (void (*)(ext2_filsys, blk_t)) priv_data;
- if (invalid)
- invalid(fs, blk);
+ st = (struct compat_struct *) priv_data;
+ if (st->invalid)
+ (st->invalid)(fs, blk);
}
@@ -90,7 +94,11 @@ errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f,
ext2_badblocks_list *bb_list,
void (*invalid)(ext2_filsys fs, blk_t blk))
{
- return ext2fs_read_bb_FILE2(fs, f, bb_list, (void *) invalid,
+ struct compat_struct st;
+
+ st.invalid = invalid;
+
+ return ext2fs_read_bb_FILE2(fs, f, bb_list, &st,
call_compat_invalid);
}
diff --git a/lib/ext2fs/res_gdt.c b/lib/ext2fs/res_gdt.c
index c03f1da0..9901c6e6 100644
--- a/lib/ext2fs/res_gdt.c
+++ b/lib/ext2fs/res_gdt.c
@@ -73,7 +73,7 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs)
sb = fs->super;
- retval = ext2fs_get_mem(2 * fs->blocksize, (void **)&dindir_buf);
+ retval = ext2fs_get_mem(2 * fs->blocksize, &dindir_buf);
if (retval)
goto out_free;
gdt_buf = (__u32 *)((char *)dindir_buf + fs->blocksize);
@@ -214,7 +214,7 @@ out_inode:
retval = retval2;
}
out_free:
- ext2fs_free_mem((void **)&dindir_buf);
+ ext2fs_free_mem(&dindir_buf);
return retval;
}
diff --git a/misc/ChangeLog b/misc/ChangeLog
index ebad1c40..773473fe 100644
--- a/misc/ChangeLog
+++ b/misc/ChangeLog
@@ -1,3 +1,8 @@
+2005-12-10 Theodore Ts'o <tytso@mit.edu>
+
+ * dumpe2fs.c, e2image.c, filefrag.c, mke2fs.c: Fix various gcc
+ -Wall complaints.
+
2005-12-09 Theodore Ts'o <tytso@mit.edu>
* mke2fs.8.in: Add more text describing the mke2fs -T option.
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index b6995fd4..c24dccf0 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -46,8 +46,7 @@ extern int optind;
const char * program_name = "dumpe2fs";
char * device_name = NULL;
-const char *num_format = "%lu";
-char range_format[16];
+int hex_format = 0;
static void usage(void)
{
@@ -56,9 +55,20 @@ static void usage(void)
exit (1);
}
-static void print_number (unsigned long num)
+static void print_number(unsigned long num)
{
- printf(num_format, num);
+ if (hex_format)
+ printf("0x%04lx", num);
+ else
+ printf("%lu", num);
+}
+
+static void print_range(unsigned long a, unsigned long b)
+{
+ if (hex_format)
+ printf("0x%04lx-0x%04lx", a, b);
+ else
+ printf("%lu-%lu", a, b);
}
static void print_free (unsigned long group, char * bitmap,
@@ -119,7 +129,7 @@ static void list_desc (ext2_filsys fs)
if (next_blk > fs->super->s_blocks_count)
next_blk = fs->super->s_blocks_count;
printf (_("Group %lu: (Blocks "), i);
- printf(range_format, group_blk, next_blk - 1);
+ print_range(group_blk, next_blk - 1);
fputs(")\n", stdout);
has_super = ((i==0) || super_blk);
if (has_super) {
@@ -129,14 +139,13 @@ static void list_desc (ext2_filsys fs)
}
if (old_desc_blk) {
printf(_(", Group descriptors at "));
- printf(range_format, old_desc_blk,
- old_desc_blk + old_desc_blocks - 1);
+ print_range(old_desc_blk,
+ old_desc_blk + old_desc_blocks - 1);
if (reserved_gdt) {
printf(_("\n Reserved GDT blocks at "));
- printf(range_format,
- old_desc_blk + old_desc_blocks,
- old_desc_blk + old_desc_blocks +
- reserved_gdt - 1);
+ print_range(old_desc_blk + old_desc_blocks,
+ old_desc_blk + old_desc_blocks +
+ reserved_gdt - 1);
}
} else if (new_desc_blk) {
fputc(has_super ? ',' : ' ', stdout);
@@ -157,9 +166,9 @@ static void list_desc (ext2_filsys fs)
if (diff >= 0)
printf(" (+%ld)", diff);
fputs(_("\n Inode table at "), stdout);
- printf(range_format, fs->group_desc[i].bg_inode_table,
- fs->group_desc[i].bg_inode_table +
- inode_blocks_per_group - 1);
+ print_range(fs->group_desc[i].bg_inode_table,
+ fs->group_desc[i].bg_inode_table +
+ inode_blocks_per_group - 1);
diff = fs->group_desc[i].bg_inode_table - group_blk;
if (diff > 0)
printf(" (+%ld)", diff);
@@ -197,7 +206,7 @@ static void list_bad_blocks(ext2_filsys fs, int dump)
retval = ext2fs_read_bb_inode(fs, &bb_list);
if (retval) {
- com_err("ext2fs_read_bb_inode", retval, "");
+ com_err("ext2fs_read_bb_inode", retval, 0);
return;
}
retval = ext2fs_badblocks_list_iterate_begin(bb_list, &bb_iter);
@@ -316,7 +325,7 @@ int main (int argc, char ** argv)
error_message(EXT2_ET_BASE));
exit(0);
case 'x':
- num_format = "0x%04x";
+ hex_format++;
break;
default:
usage();
@@ -324,7 +333,6 @@ int main (int argc, char ** argv)
}
if (optind > argc - 1)
usage();
- sprintf(range_format, "%s-%s", num_format, num_format);
device_name = argv[optind++];
if (use_superblock && !use_blocksize)
use_blocksize = 1024;
diff --git a/misc/e2image.c b/misc/e2image.c
index a7fc9b5d..19f2c515 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -357,7 +357,8 @@ static void scramble_dir_block(ext2_filsys fs, blk_t blk, char *buf)
if (rec_len < 8 || (rec_len % 4) ||
(p+rec_len > end)) {
printf("Corrupt directory block %lu: "
- "bad rec_len (%d)\n", blk, rec_len);
+ "bad rec_len (%d)\n", (unsigned long) blk,
+ rec_len);
rec_len = end - p;
#ifdef EXT2FS_ENABLE_SWAPFS
if (fs->flags & EXT2_FLAG_SWAP_BYTES)
@@ -367,7 +368,8 @@ static void scramble_dir_block(ext2_filsys fs, blk_t blk, char *buf)
}
if (dirent->name_len + 8 > rec_len) {
printf("Corrupt directory block %lu: "
- "bad name_len (%d)\n", blk, dirent->name_len);
+ "bad name_len (%d)\n", (unsigned long) blk,
+ dirent->name_len);
dirent->name_len = rec_len - 8;
continue;
}
diff --git a/misc/filefrag.c b/misc/filefrag.c
index d8e3754d..8cd9d018 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -118,7 +118,7 @@ static void frag_report(const char *filename)
is_ext2 = 0;
}
if (verbose)
- printf("Blocksize of file %s is %ld\n", filename, bs);
+ printf("Blocksize of file %s is %d\n", filename, bs);
bpib = bs / 4;
numblocks = (fileinfo.st_size + (bs-1)) / bs;
if (verbose) {
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index acdb842b..c80c1efd 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -78,7 +78,7 @@ int journal_flags;
char *bad_blocks_filename;
__u32 fs_stride;
-struct ext2_super_block param;
+struct ext2_super_block fs_param;
char *creator_os;
char *volume_label;
char *mount_dir;
@@ -691,9 +691,9 @@ static void show_stats(ext2_filsys fs)
dgrp_t i;
int need, col_left;
- if (param.s_blocks_count != s->s_blocks_count)
+ if (fs_param.s_blocks_count != s->s_blocks_count)
fprintf(stderr, _("warning: %d blocks unused.\n\n"),
- param.s_blocks_count - s->s_blocks_count);
+ fs_param.s_blocks_count - s->s_blocks_count);
memset(buf, 0, sizeof(buf));
strncpy(buf, s->s_volume_name, sizeof(s->s_volume_name));
@@ -857,7 +857,7 @@ static void parse_extended_opts(struct ext2_super_block *param,
rsv_groups = (resize + bpg - 1) / bpg;
rsv_gdb = (rsv_groups + gdpb - 1) / gdpb -
desc_blocks;
- if (rsv_gdb > EXT2_ADDR_PER_BLOCK(param))
+ if (rsv_gdb > (int) EXT2_ADDR_PER_BLOCK(param))
rsv_gdb = EXT2_ADDR_PER_BLOCK(param);
if (rsv_gdb > 0) {
@@ -945,12 +945,12 @@ static void PRS(int argc, char *argv[])
setbuf(stdout, NULL);
setbuf(stderr, NULL);
initialize_ext2_error_table();
- memset(&param, 0, sizeof(struct ext2_super_block));
- param.s_rev_level = 1; /* Create revision 1 filesystems now */
- param.s_feature_incompat |= EXT2_FEATURE_INCOMPAT_FILETYPE;
- param.s_feature_ro_compat |= EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
+ memset(&fs_param, 0, sizeof(struct ext2_super_block));
+ fs_param.s_rev_level = 1; /* Create revision 1 filesystems now */
+ fs_param.s_feature_incompat |= EXT2_FEATURE_INCOMPAT_FILETYPE;
+ fs_param.s_feature_ro_compat |= EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
#if 0
- param.s_feature_compat |= EXT2_FEATURE_COMPAT_DIR_INDEX;
+ fs_param.s_feature_compat |= EXT2_FEATURE_COMPAT_DIR_INDEX;
#endif
#ifdef __linux__
@@ -960,10 +960,10 @@ static void PRS(int argc, char *argv[])
}
linux_version_code = parse_version_number(ut.release);
if (linux_version_code && linux_version_code < (2*65536 + 2*256)) {
- param.s_rev_level = 0;
- param.s_feature_incompat = 0;
- param.s_feature_compat = 0;
- param.s_feature_ro_compat = 0;
+ fs_param.s_rev_level = 0;
+ fs_param.s_feature_incompat = 0;
+ fs_param.s_feature_compat = 0;
+ fs_param.s_feature_ro_compat = 0;
}
#endif
@@ -992,7 +992,7 @@ static void PRS(int argc, char *argv[])
"usable on most systems.\n"),
blocksize);
if (blocksize > 0)
- param.s_log_block_size =
+ fs_param.s_log_block_size =
int_log2(blocksize >>
EXT2_MIN_BLOCK_LOG_SIZE);
break;
@@ -1009,19 +1009,19 @@ static void PRS(int argc, char *argv[])
optarg);
exit(1);
}
- param.s_log_frag_size =
+ fs_param.s_log_frag_size =
int_log2(size >> EXT2_MIN_BLOCK_LOG_SIZE);
fprintf(stderr, _("Warning: fragments not supported. "
"Ignoring -f option\n"));
break;
case 'g':
- param.s_blocks_per_group = strtoul(optarg, &tmp, 0);
+ fs_param.s_blocks_per_group = strtoul(optarg, &tmp, 0);
if (*tmp) {
com_err(program_name, 0,
_("Illegal number for blocks per group"));
exit(1);
}
- if ((param.s_blocks_per_group % 8) != 0) {
+ if ((fs_param.s_blocks_per_group % 8) != 0) {
com_err(program_name, 0,
_("blocks per group must be multiple of 8"));
exit(1);
@@ -1043,7 +1043,7 @@ static void PRS(int argc, char *argv[])
parse_journal_opts(optarg);
break;
case 'j':
- param.s_feature_compat |=
+ fs_param.s_feature_compat |=
EXT3_FEATURE_COMPAT_HAS_JOURNAL;
if (!journal_size)
journal_size = -1;
@@ -1076,24 +1076,24 @@ static void PRS(int argc, char *argv[])
quiet = 1;
break;
case 'r':
- param.s_rev_level = strtoul(optarg, &tmp, 0);
+ fs_param.s_rev_level = strtoul(optarg, &tmp, 0);
if (*tmp) {
com_err(program_name, 0,
_("bad revision level - %s"), optarg);
exit(1);
}
- if (param.s_rev_level == EXT2_GOOD_OLD_REV) {
- param.s_feature_incompat = 0;
- param.s_feature_compat = 0;
- param.s_feature_ro_compat = 0;
+ if (fs_param.s_rev_level == EXT2_GOOD_OLD_REV) {
+ fs_param.s_feature_incompat = 0;
+ fs_param.s_feature_compat = 0;
+ fs_param.s_feature_ro_compat = 0;
}
break;
case 's': /* deprecated */
if (atoi(optarg))
- param.s_feature_ro_compat |=
+ fs_param.s_feature_ro_compat |=
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
else
- param.s_feature_ro_compat &=
+ fs_param.s_feature_ro_compat &=
~EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
break;
#ifdef EXT2_DYNAMIC_REV
@@ -1128,13 +1128,13 @@ static void PRS(int argc, char *argv[])
break;
case 'O':
if (!strcmp(optarg, "none")) {
- param.s_feature_compat = 0;
- param.s_feature_incompat = 0;
- param.s_feature_ro_compat = 0;
+ fs_param.s_feature_compat = 0;
+ fs_param.s_feature_incompat = 0;
+ fs_param.s_feature_ro_compat = 0;
break;
}
if (e2p_edit_feature(optarg,
- &param.s_feature_compat,
+ &fs_param.s_feature_compat,
ok_features)) {
fprintf(stderr,
_("Invalid filesystem option set: %s\n"), optarg);
@@ -1204,7 +1204,7 @@ static void PRS(int argc, char *argv[])
exit(1);
}
blocksize = jfs->blocksize;
- param.s_log_block_size =
+ fs_param.s_log_block_size =
int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
ext2fs_close(jfs);
}
@@ -1221,15 +1221,15 @@ static void PRS(int argc, char *argv[])
blocksize, sys_page_size);
}
if ((blocksize > 4096) &&
- (param.s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL))
+ (fs_param.s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL))
fprintf(stderr, _("\nWarning: some 2.4 kernels do not support "
"blocksizes greater than 4096\n\tusing ext3. "
"Use -b 4096 if this is an issue for you.\n\n"));
if (optind < argc) {
- param.s_blocks_count = parse_num_blocks(argv[optind++],
- param.s_log_block_size);
- if (!param.s_blocks_count) {
+ fs_param.s_blocks_count = parse_num_blocks(argv[optind++],
+ fs_param.s_log_block_size);
+ if (!fs_param.s_blocks_count) {
com_err(program_name, 0, _("invalid blocks count - %s"),
argv[optind - 1]);
exit(1);
@@ -1238,37 +1238,37 @@ static void PRS(int argc, char *argv[])
if (optind < argc)
usage();
- if (param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
+ if (fs_param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
if (!fs_type)
fs_type = "journal";
reserved_ratio = 0;
- param.s_feature_incompat = EXT3_FEATURE_INCOMPAT_JOURNAL_DEV;
- param.s_feature_compat = 0;
- param.s_feature_ro_compat = 0;
+ fs_param.s_feature_incompat = EXT3_FEATURE_INCOMPAT_JOURNAL_DEV;
+ fs_param.s_feature_compat = 0;
+ fs_param.s_feature_ro_compat = 0;
}
- if (param.s_rev_level == EXT2_GOOD_OLD_REV &&
- (param.s_feature_compat || param.s_feature_ro_compat ||
- param.s_feature_incompat))
- param.s_rev_level = 1; /* Create a revision 1 filesystem */
+ if (fs_param.s_rev_level == EXT2_GOOD_OLD_REV &&
+ (fs_param.s_feature_compat || fs_param.s_feature_ro_compat ||
+ fs_param.s_feature_incompat))
+ fs_param.s_rev_level = 1; /* Create a revision 1 filesystem */
if (!force)
check_plausibility(device_name);
check_mount(device_name, force, _("filesystem"));
- param.s_log_frag_size = param.s_log_block_size;
+ fs_param.s_log_frag_size = fs_param.s_log_block_size;
- if (noaction && param.s_blocks_count) {
- dev_size = param.s_blocks_count;
+ if (noaction && fs_param.s_blocks_count) {
+ dev_size = fs_param.s_blocks_count;
retval = 0;
} else {
retry:
retval = ext2fs_get_device_size(device_name,
- EXT2_BLOCK_SIZE(&param),
+ EXT2_BLOCK_SIZE(&fs_param),
&dev_size);
if ((retval == EFBIG) &&
(blocksize == 0) &&
- (param.s_log_block_size == 0)) {
- param.s_log_block_size = 2;
+ (fs_param.s_log_block_size == 0)) {
+ fs_param.s_log_block_size = 2;
blocksize = 4096;
goto retry;
}
@@ -1279,7 +1279,7 @@ static void PRS(int argc, char *argv[])
_("while trying to determine filesystem size"));
exit(1);
}
- if (!param.s_blocks_count) {
+ if (!fs_param.s_blocks_count) {
if (retval == EXT2_ET_UNIMPLEMENTED) {
com_err(program_name, 0,
_("Couldn't determine device size; you "
@@ -1299,13 +1299,13 @@ static void PRS(int argc, char *argv[])
));
exit(1);
}
- param.s_blocks_count = dev_size;
- if (sys_page_size > EXT2_BLOCK_SIZE(&param))
- param.s_blocks_count &= ~((sys_page_size /
- EXT2_BLOCK_SIZE(&param))-1);
+ fs_param.s_blocks_count = dev_size;
+ if (sys_page_size > EXT2_BLOCK_SIZE(&fs_param))
+ fs_param.s_blocks_count &= ~((sys_page_size /
+ EXT2_BLOCK_SIZE(&fs_param))-1);
}
- } else if (!force && (param.s_blocks_count > dev_size)) {
+ } else if (!force && (fs_param.s_blocks_count > dev_size)) {
com_err(program_name, 0,
_("Filesystem larger than apparent device size."));
proceed_question();
@@ -1315,15 +1315,15 @@ static void PRS(int argc, char *argv[])
* If the user asked for HAS_JOURNAL, then make sure a journal
* gets created.
*/
- if ((param.s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
+ if ((fs_param.s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
!journal_size)
journal_size = -1;
/* Set first meta blockgroup via an environment variable */
/* (this is mostly for debugging purposes) */
- if ((param.s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) &&
+ if ((fs_param.s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) &&
((tmp = getenv("MKE2FS_FIRST_META_BG"))))
- param.s_first_meta_bg = atoi(tmp);
+ fs_param.s_first_meta_bg = atoi(tmp);
/* Get the hardware sector size, if available */
retval = ext2fs_get_device_sectsize(device_name, &sector_size);
@@ -1336,33 +1336,34 @@ static void PRS(int argc, char *argv[])
if ((tmp = getenv("MKE2FS_DEVICE_SECTSIZE")) != NULL)
sector_size = atoi(tmp);
- set_fs_defaults(fs_type, &param, blocksize, sector_size, &inode_ratio);
- blocksize = EXT2_BLOCK_SIZE(&param);
+ set_fs_defaults(fs_type, &fs_param, blocksize, sector_size,
+ &inode_ratio);
+ blocksize = EXT2_BLOCK_SIZE(&fs_param);
if (extended_opts)
- parse_extended_opts(&param, extended_opts);
+ parse_extended_opts(&fs_param, extended_opts);
/* Since sparse_super is the default, we would only have a problem
* here if it was explicitly disabled.
*/
- if ((param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
- !(param.s_feature_ro_compat&EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
+ if ((fs_param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
+ !(fs_param.s_feature_ro_compat&EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
com_err(program_name, 0,
_("reserved online resize blocks not supported "
"on non-sparse filesystem"));
exit(1);
}
- if (param.s_blocks_per_group) {
- if (param.s_blocks_per_group < 256 ||
- param.s_blocks_per_group > 8 * (unsigned) blocksize) {
+ if (fs_param.s_blocks_per_group) {
+ if (fs_param.s_blocks_per_group < 256 ||
+ fs_param.s_blocks_per_group > 8 * (unsigned) blocksize) {
com_err(program_name, 0,
_("blocks per group count out of range"));
exit(1);
}
}
- if (!force && param.s_blocks_count >= (1 << 31)) {
+ if (!force && fs_param.s_blocks_count >= (1 << 31)) {
com_err(program_name, 0,
_("Filesystem too large. No more than 2**31-1 blocks\n"
"\t (8TB using a blocksize of 4k) are currently supported."));
@@ -1371,7 +1372,7 @@ static void PRS(int argc, char *argv[])
if (inode_size) {
if (inode_size < EXT2_GOOD_OLD_INODE_SIZE ||
- inode_size > EXT2_BLOCK_SIZE(&param) ||
+ inode_size > EXT2_BLOCK_SIZE(&fs_param) ||
inode_size & (inode_size - 1)) {
com_err(program_name, 0,
_("invalid inode size %d (min %d/max %d)"),
@@ -1383,20 +1384,21 @@ static void PRS(int argc, char *argv[])
fprintf(stderr, _("Warning: %d-byte inodes not usable "
"on most systems\n"),
inode_size);
- param.s_inode_size = inode_size;
+ fs_param.s_inode_size = inode_size;
}
/*
* Calculate number of inodes based on the inode ratio
*/
- param.s_inodes_count = num_inodes ? num_inodes :
- ((__u64) param.s_blocks_count * blocksize)
+ fs_param.s_inodes_count = num_inodes ? num_inodes :
+ ((__u64) fs_param.s_blocks_count * blocksize)
/ inode_ratio;
/*
* Calculate number of blocks to reserve
*/
- param.s_r_blocks_count = (param.s_blocks_count * reserved_ratio) / 100;
+ fs_param.s_r_blocks_count = (fs_param.s_blocks_count * reserved_ratio)
+ / 100;
}
int main (int argc, char *argv[])
@@ -1427,7 +1429,7 @@ int main (int argc, char *argv[])
/*
* Initialize the superblock....
*/
- retval = ext2fs_initialize(device_name, 0, &param,
+ retval = ext2fs_initialize(device_name, 0, &fs_param,
io_ptr, &fs);
if (retval) {
com_err(device_name, retval, _("while setting up superblock"));