+2001-01-06 <tytso@snap.thunk.org>
+
+ * journal.c, pass1.c, pass1b.c, pass3.c, recovery.c, revoke.c,
+ super.c, unix.c, util.c: Fix random gcc -Wall complaints.
+
+ * jfs_user.h: Use more sophisticated inline handling to allow
+ building with --enable-gcc-wall
+
2001-01-03 <tytso@snap.thunk.org>
* pass1.c (e2fsck_pass1): Moved journal inode handling out to its
#define kmalloc(len,flags) malloc(len)
#define kfree(p) free(p)
-static inline kmem_cache_t * do_cache_create(int len)
+/*
+ * We use the standard libext2fs portability tricks for inline
+ * functions.
+ */
+extern kmem_cache_t * do_cache_create(int len);
+
+#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
+#ifdef E2FSCK_INCLUDE_INLINE_FUNCS
+#define _INLINE_ extern
+#else
+#ifdef __GNUC__
+#define _INLINE_ extern __inline__
+#else /* For Watcom C */
+#define _INLINE_ extern inline
+#endif
+#endif
+
+_INLINE_ kmem_cache_t * do_cache_create(int len)
{
kmem_cache_t *new_cache;
new_cache = malloc(sizeof(*new_cache));
return new_cache;
}
+#undef _INLINE_
+#endif
+
/*
* Now pull in the real linux/jfs.h definitions.
*/
#include <sys/stat.h>
#endif
+#define E2FSCK_INCLUDE_INLINE_FUNCS
#include "jfs_user.h"
#include "problem.h"
#include "uuid/uuid.h"
return NULL;
jfs_debug(4, "getblk for block %lu (%d bytes)(total %d)\n",
- blocknr, blocksize, ++bh_count);
+ (unsigned long) blocknr, blocksize, ++bh_count);
bh->b_ctx = ctx;
bh->b_size = blocksize;
bh = *bhp++;
if (rw == READ && !bh->b_uptodate) {
jfs_debug(3, "reading block %lu/%p\n",
- bh->b_blocknr, bh);
+ (unsigned long) bh->b_blocknr, (void *) bh);
retval = io_channel_read_blk(bh->b_ctx->fs->io,
bh->b_blocknr,
1, bh->b_data);
bh->b_uptodate = 1;
} else if (rw == WRITE && bh->b_dirty) {
jfs_debug(3, "writing block %lu/%p\n",
- bh->b_blocknr, bh);
+ (unsigned long) bh->b_blocknr, (void *) bh);
retval = io_channel_write_blk(bh->b_ctx->fs->io,
bh->b_blocknr,
1, bh->b_data);
} else
jfs_debug(3, "no-op %s for block %lu\n",
rw == READ ? "read" : "write",
- bh->b_blocknr);
+ (unsigned long) bh->b_blocknr);
}
}
if (bh->b_dirty)
ll_rw_block(WRITE, 1, &bh);
jfs_debug(3, "freeing block %lu/%p (total %d)\n",
- bh->b_blocknr, bh, --bh_count);
+ (unsigned long) bh->b_blocknr, (void *) bh, --bh_count);
ext2fs_free_mem((void **) &bh);
}
ino_t journal_inum, journal_t **journal)
{
struct inode *inode;
- const char *cmdname = ctx->program_name;
struct buffer_head *bh;
blk_t start;
int retval;
char uuid_str[40];
struct problem_context pctx;
struct ext2_super_block *sb = ctx->fs->super;
- int recover = ctx->fs->super->s_feature_incompat &
- EXT3_FEATURE_INCOMPAT_RECOVER;
clear_problem_context(&pctx);
return 0;
}
-void e2fsck_journal_reset_super(e2fsck_t ctx, journal_superblock_t *jsb,
+static void e2fsck_journal_reset_super(e2fsck_t ctx, journal_superblock_t *jsb,
journal_t *journal)
{
char *p;
static int recover_ext3_journal(e2fsck_t ctx)
{
- ext2_filsys fs = ctx->fs;
journal_t *journal;
int retval;
int problem = 0;
ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
- switch (ino) {
- case EXT2_BOOT_LOADER_INO:
+ if (ino == EXT2_BOOT_LOADER_INO) {
if (LINUX_S_ISDIR(inode.i_mode))
problem = PR_1_RESERVED_BAD_MODE;
- break;
- default:
+ } else {
if (inode.i_mode != 0)
problem = PR_1_RESERVED_BAD_MODE;
- break;
}
if (problem) {
if (fix_problem(ctx, problem, &pctx)) {
/*
* This is a helper function for check_blocks().
*/
-int process_block(ext2_filsys fs,
+static int process_block(ext2_filsys fs,
blk_t *block_nr,
e2_blkcnt_t blockcnt,
blk_t ref_block,
ctx->flags |= E2F_FLAG_ABORT;
}
-int process_bad_block(ext2_filsys fs,
+static int process_bad_block(ext2_filsys fs,
blk_t *block_nr,
e2_blkcnt_t blockcnt,
blk_t ref_block,
ino_t ino;
struct ext2_inode inode;
ext2_inode_scan scan;
- errcode_t retval;
struct process_block_struct pb;
struct dup_inode *dp;
struct problem_context pctx;
fs->check_directory = 0;
}
-int process_pass1b_block(ext2_filsys fs,
- blk_t *block_nr,
- e2_blkcnt_t blockcnt,
- blk_t ref_blk,
- int ref_offset,
- void *priv_data)
+static int process_pass1b_block(ext2_filsys fs,
+ blk_t *block_nr,
+ e2_blkcnt_t blockcnt,
+ blk_t ref_blk,
+ int ref_offset,
+ void *priv_data)
{
struct process_block_struct *p;
struct dup_block *dp, *q, *r;
static void delete_file(e2fsck_t ctx, struct dup_inode *dp, char* block_buf)
{
ext2_filsys fs = ctx->fs;
- errcode_t retval;
struct process_block_struct pb;
struct ext2_inode inode;
struct problem_context pctx;
* This routine gets the lost_and_found inode, making it a directory
* if necessary
*/
-ino_t get_lost_and_found(e2fsck_t ctx)
+static ino_t get_lost_and_found(e2fsck_t ctx)
{
ext2_filsys fs = ctx->fs;
ino_t ino;
errcode_t retval;
struct ext2_inode inode;
char * block;
- const char name[] = "lost+found";
+ static const char name[] = "lost+found";
struct problem_context pctx;
struct dir_info *dirinfo;
* Miscellaneous bookkeeping that needs to be kept straight.
*/
e2fsck_add_dir_info(ctx, ino, EXT2_ROOT_INO);
- adjust_inode_count(ctx, EXT2_ROOT_INO, +1);
+ adjust_inode_count(ctx, EXT2_ROOT_INO, 1);
ext2fs_icount_store(ctx->inode_count, ino, 2);
ext2fs_icount_store(ctx->inode_link_info, ino, 2);
#if 0
fix_problem(ctx, PR_3_CANT_RECONNECT, &pctx);
return 1;
}
- adjust_inode_count(ctx, ino, +1);
+ adjust_inode_count(ctx, ino, 1);
return 0;
}
unsigned int max, nbufs, next, blocknr;
struct buffer_head *bh;
- #define MAXBUF 8
+#define MAXBUF 8
struct buffer_head * bufs[MAXBUF];
/* Do up to 128K of readahead */
* Count the number of in-use tags in a journal descriptor block.
*/
-int count_tags(struct buffer_head *bh, int size)
+static int count_tags(struct buffer_head *bh, int size)
{
char * tagp;
journal_block_tag_t * tag;
int err;
journal_superblock_t * sb;
- struct recovery_info info = {};
+ struct recovery_info info;
+
+ memset(&info, 0, sizeof(info));
sb = journal->j_superblock;
mark_buffer_dirty(nbh, 1);
++info->nr_replays;
- // ll_rw_block(WRITE, 1, &nbh);
+ /* ll_rw_block(WRITE, 1, &nbh); */
brelse(obh);
brelse(nbh);
}
(block << (hash_shift - 12))) & (table->hash_size - 1);
}
-int insert_revoke_hash(journal_t *journal, unsigned long blocknr, tid_t seq)
+static int insert_revoke_hash(journal_t *journal, unsigned long blocknr,
+ tid_t seq)
{
struct list_head *hash_list;
struct jfs_revoke_record_s *record;
if ((blk < fs->super->s_first_data_block) ||
(blk >= fs->super->s_blocks_count)) {
fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_BLOCK_NUM, pctx);
- abort:
+ return_abort:
pb->abort = 1;
return BLOCK_ABORT;
}
if (!ext2fs_test_block_bitmap(fs->block_map, blk)) {
fix_problem(ctx, PR_0_ORPHAN_ALREADY_CLEARED_BLOCK, pctx);
- goto abort;
+ goto return_abort;
}
/*
*/
if (blockcnt < 0) {
int i, limit;
- blk_t *block_nr;
+ blk_t *bp;
pb->errcode = io_channel_read_blk(fs->io, blk, 1,
pb->buf);
if (pb->errcode)
- goto abort;
+ goto return_abort;
limit = fs->blocksize >> 2;
- for (i = 0, block_nr = (blk_t *) pb->buf;
- i < limit; i++, block_nr++)
- if (*block_nr)
+ for (i = 0, bp = (blk_t *) pb->buf;
+ i < limit; i++, bp++)
+ if (*bp)
return 0;
}
/*
pb->errcode = io_channel_read_blk(fs->io, blk, 1,
pb->buf);
if (pb->errcode)
- goto abort;
+ goto return_abort;
memset(pb->buf + pb->truncate_offset, 0,
fs->blocksize - pb->truncate_offset);
pb->errcode = io_channel_write_blk(fs->io, blk, 1,
pb->buf);
if (pb->errcode)
- goto abort;
+ goto return_abort;
}
pb->truncated_blocks++;
*block_nr = 0;
if ((ino < EXT2_FIRST_INODE(fs->super)) ||
(ino > fs->super->s_inodes_count)) {
clear_problem_context(&pctx);
- pctx.ino;
+ pctx.ino = ino;
fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_HEAD_INODE, &pctx);
return 1;
}
(next_ino > fs->super->s_inodes_count))) {
pctx.ino = next_ino;
fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_INODE, &pctx);
- goto abort;
+ goto return_abort;
}
if (release_inode_blocks(ctx, ino, &inode, block_buf, &pctx))
- goto abort;
+ goto return_abort;
if (!inode.i_links_count) {
ext2fs_unmark_inode_bitmap(fs->inode_map, ino);
ino = next_ino;
}
return 0;
-abort:
+return_abort:
ext2fs_free_mem((void **) &block_buf);
return 1;
}
" -n Make no changes to the filesystem\n"
" -y Assume \"yes\" to all questions\n"
" -c Check for bad blocks\n"
- " -f Force checking even if filesystem is marked clean\n"
+ " -f Force checking even if filesystem is marked clean\n"));
+ fprintf(stderr, _(""
" -v Be verbose\n"
" -b superblock Use alternative superblock\n"
" -B blocksize Force blocksize when looking for superblock\n"
static int e2fsck_update_progress(e2fsck_t ctx, int pass,
unsigned long cur, unsigned long max)
{
- const char spinner[] = "\\|/-";
+ static const char spinner[] = "\\|/-";
char buf[80];
int i;
float percent;
{
int c;
const char *defstr;
- char *short_yes = _("yY");
- char *short_no = _("nN");
+ const char *short_yes = _("yY");
+ const char *short_no = _("nN");
#ifdef HAVE_TERMIOS_H
struct termios termios, tmp;
track->brk_start = sbrk(0);
gettimeofday(&track->time_start, 0);
#ifdef HAVE_GETRUSAGE
-#ifdef solaris
- memcpy(&r, 0, sizeof(struct rusage));
+#ifdef sun
+ memset(&r, 0, sizeof(struct rusage));
#endif
getrusage(RUSAGE_SELF, &r);
track->user_start = r.ru_utime;