/*
* util.c --- miscellaneous utilities
- *
+ *
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
void fatal_error(e2fsck_t ctx, const char *msg)
{
- if (msg)
+ if (msg)
fprintf (stderr, "e2fsck: %s\n", msg);
if (ctx->fs && ctx->fs->io) {
if (ctx->fs->io->magic == EXT2_ET_MAGIC_IO_CHANNEL)
return ret;
}
-char *string_copy(e2fsck_t ctx EXT2FS_ATTR((unused)),
+char *string_copy(e2fsck_t ctx EXT2FS_ATTR((unused)),
const char *str, int len)
{
char *ret;
-
+
if (!str)
return NULL;
if (!len)
errcode_t retval;
const char *old_op;
- if (ext2fs_test_bb_dirty(fs)) {
- old_op = ehandler_operation(_("writing block bitmaps"));
- retval = ext2fs_write_block_bitmap(fs);
- ehandler_operation(old_op);
- if (retval) {
- com_err(ctx->program_name, retval,
- _("while retrying to write block bitmaps for %s"),
- ctx->device_name);
- fatal_error(ctx, 0);
- }
- }
-
- if (ext2fs_test_ib_dirty(fs)) {
- old_op = ehandler_operation(_("writing inode bitmaps"));
- retval = ext2fs_write_inode_bitmap(fs);
- ehandler_operation(old_op);
- if (retval) {
- com_err(ctx->program_name, retval,
- _("while retrying to write inode bitmaps for %s"),
- ctx->device_name);
- fatal_error(ctx, 0);
- }
+ old_op = ehandler_operation(_("writing block and inode bitmaps"));
+ retval = ext2fs_write_bitmaps(fs);
+ ehandler_operation(old_op);
+ if (retval) {
+ com_err(ctx->program_name, retval,
+ _("while rewriting block and inode bitmaps for %s"),
+ ctx->device_name);
+ fatal_error(ctx, 0);
}
}
fprintf(stderr, _("\n\n%s: UNEXPECTED INCONSISTENCY; "
"RUN fsck MANUALLY.\n\t(i.e., without -a or -p options)\n"),
ctx->device_name);
+ ctx->flags |= E2F_FLAG_EXITING;
if (fs != NULL) {
fs->super->s_state |= EXT2_ERROR_FS;
ext2fs_mark_super_dirty(fs);
struct rusage r;
#endif
io_stats io_start = 0;
-
+
track->brk_start = sbrk(0);
gettimeofday(&track->time_start, 0);
#ifdef HAVE_GETRUSAGE
#ifdef HAVE_MALLINFO
#define kbytes(x) (((x) + 1023) / 1024)
-
+
malloc_info = mallinfo();
printf(_("Memory used: %dk/%dk (%dk/%dk), "),
kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
#else
printf(_("Memory used: %d, "),
(int) (((char *) sbrk(0)) - ((char *) track->brk_start)));
-#endif
+#endif
#ifdef HAVE_GETRUSAGE
getrusage(RUSAGE_SELF, &r);
channel->manager->get_stats(channel, &delta);
if (delta) {
bytes_read = delta->bytes_read - track->bytes_read;
- bytes_written = delta->bytes_written -
+ bytes_written = delta->bytes_written -
track->bytes_written;
}
printf("I/O read: %lluMB, write: %lluMB, rate: %.2fMB/s\n",
void *buf = NULL;
int blocksize;
blk_t superblock, ret_sb = 8193;
-
+
if (fs && fs->super) {
ret_sb = (fs->super->s_blocks_per_group +
fs->super->s_first_data_block);
}
return ret_sb;
}
-
+
if (ctx) {
if (ctx->blocksize) {
ret_sb = ctx->blocksize * 8;
if (LINUX_S_ISDIR(mode))
return EXT2_FT_DIR;
-
+
if (LINUX_S_ISCHR(mode))
return EXT2_FT_CHRDEV;
-
+
if (LINUX_S_ISBLK(mode))
return EXT2_FT_BLKDEV;
-
+
if (LINUX_S_ISLNK(mode))
return EXT2_FT_SYMLINK;
if (LINUX_S_ISFIFO(mode))
return EXT2_FT_FIFO;
-
+
if (LINUX_S_ISSOCK(mode))
return EXT2_FT_SOCK;
-
+
return 0;
}