Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
/*
|
|
|
|
* unix.c - The unix-specific code for e2fsck
|
2008-08-28 07:07:54 +04:00
|
|
|
*
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
|
|
|
*/
|
|
|
|
|
2008-07-13 23:32:37 +04:00
|
|
|
#define _XOPEN_SOURCE 600 /* for inclusion of sa_handler in Solaris */
|
|
|
|
|
2011-09-19 01:34:37 +04:00
|
|
|
#include "config.h"
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#ifdef HAVE_STDLIB_H
|
|
|
|
#include <stdlib.h>
|
|
|
|
#endif
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <time.h>
|
1999-10-20 22:24:31 +04:00
|
|
|
#ifdef HAVE_SIGNAL_H
|
1999-07-19 19:27:37 +04:00
|
|
|
#include <signal.h>
|
1999-10-20 22:24:31 +04:00
|
|
|
#endif
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
#ifdef HAVE_GETOPT_H
|
|
|
|
#include <getopt.h>
|
Many files:
badblocks.c, dumpe2fs.c, e2label.c, mke2fs.c, tune2fs.c, uuidgen.c:
For platforms that don't define optarg.h, manually define optarg and
optind.
ChangeLog, main.c:
main.c: For platforms that don't define optarg.h, manually define
optarg and optind.
ChangeLog, unix.c:
unix.c: For platforms that don't define optarg.h, manually define
optarg and optind.
2000-04-03 20:22:35 +04:00
|
|
|
#else
|
|
|
|
extern char *optarg;
|
|
|
|
extern int optind;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
#endif
|
|
|
|
#include <unistd.h>
|
|
|
|
#ifdef HAVE_ERRNO_H
|
|
|
|
#include <errno.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MNTENT_H
|
|
|
|
#include <mntent.h>
|
|
|
|
#endif
|
2003-04-13 08:44:19 +04:00
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
#include <sys/ioctl.h>
|
2003-04-13 08:44:19 +04:00
|
|
|
#endif
|
2003-03-14 10:13:48 +03:00
|
|
|
#ifdef HAVE_MALLOC_H
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
#include <malloc.h>
|
2003-03-14 10:13:48 +03:00
|
|
|
#endif
|
2004-04-12 08:16:44 +04:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_DIRENT_H
|
|
|
|
#include <dirent.h>
|
|
|
|
#endif
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
2008-08-25 04:37:39 +04:00
|
|
|
#include "e2p/e2p.h"
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
#include "et/com_err.h"
|
2008-03-30 08:01:52 +04:00
|
|
|
#include "e2p/e2p.h"
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
#include "e2fsck.h"
|
|
|
|
#include "problem.h"
|
|
|
|
#include "../version.h"
|
|
|
|
|
|
|
|
/* Command line options */
|
2003-08-19 18:08:34 +04:00
|
|
|
static int cflag; /* check disk */
|
|
|
|
static int show_version_only;
|
|
|
|
static int verbose;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
2003-08-19 18:08:34 +04:00
|
|
|
static int replace_bad_blocks;
|
2004-02-24 08:16:09 +03:00
|
|
|
static int keep_bad_blocks;
|
2003-08-19 18:08:34 +04:00
|
|
|
static char *bad_blocks_file;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
2000-08-23 01:37:47 +04:00
|
|
|
e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */
|
|
|
|
|
2002-11-08 23:35:13 +03:00
|
|
|
#ifdef CONFIG_JBD_DEBUG /* Enabled by configure --enable-jfs-debug */
|
|
|
|
int journal_enable_debug = -1;
|
|
|
|
#endif
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
static void usage(e2fsck_t ctx)
|
|
|
|
{
|
|
|
|
fprintf(stderr,
|
2007-08-11 07:58:56 +04:00
|
|
|
_("Usage: %s [-panyrcdfvtDFV] [-b superblock] [-B blocksize]\n"
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
"\t\t[-I inode_buffer_blocks] [-P process_inode_size]\n"
|
2005-06-20 16:35:27 +04:00
|
|
|
"\t\t[-l|-L bad_blocks_file] [-C fd] [-j external_journal]\n"
|
2002-08-17 18:19:44 +04:00
|
|
|
"\t\t[-E extended-options] device\n"),
|
1999-07-19 19:27:37 +04:00
|
|
|
ctx->program_name);
|
1999-07-19 19:37:46 +04:00
|
|
|
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
fprintf(stderr, _("\nEmergency help:\n"
|
1999-07-19 19:37:46 +04:00
|
|
|
" -p Automatic repair (no questions)\n"
|
|
|
|
" -n Make no changes to the filesystem\n"
|
|
|
|
" -y Assume \"yes\" to all questions\n"
|
2003-01-30 05:04:52 +03:00
|
|
|
" -c Check for bad blocks and add them to the badblock list\n"
|
2001-01-06 08:55:58 +03:00
|
|
|
" -f Force checking even if filesystem is marked clean\n"));
|
|
|
|
fprintf(stderr, _(""
|
1999-07-19 19:37:46 +04:00
|
|
|
" -v Be verbose\n"
|
|
|
|
" -b superblock Use alternative superblock\n"
|
|
|
|
" -B blocksize Force blocksize when looking for superblock\n"
|
2005-06-20 16:35:27 +04:00
|
|
|
" -j external_journal Set location of the external journal\n"
|
1999-07-19 19:37:46 +04:00
|
|
|
" -l bad_blocks_file Add to badblocks list\n"
|
|
|
|
" -L bad_blocks_file Set badblocks list\n"
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
));
|
1999-07-19 19:37:46 +04:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
exit(FSCK_USAGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void show_stats(e2fsck_t ctx)
|
|
|
|
{
|
|
|
|
ext2_filsys fs = ctx->fs;
|
2006-09-12 22:56:17 +04:00
|
|
|
ext2_ino_t inodes, inodes_used;
|
2010-06-14 01:00:00 +04:00
|
|
|
blk64_t blocks, blocks_used;
|
|
|
|
unsigned int dir_links;
|
|
|
|
unsigned int num_files, num_links;
|
2008-12-09 05:33:11 +03:00
|
|
|
int frag_percent_file, frag_percent_dir, frag_percent_total;
|
2008-08-14 17:48:07 +04:00
|
|
|
int i, j;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
|
|
|
dir_links = 2 * ctx->fs_directory_count - 1;
|
|
|
|
num_files = ctx->fs_total_count - dir_links;
|
|
|
|
num_links = ctx->fs_links_count - dir_links;
|
|
|
|
inodes = fs->super->s_inodes_count;
|
|
|
|
inodes_used = (fs->super->s_inodes_count -
|
|
|
|
fs->super->s_free_inodes_count);
|
2009-09-08 04:46:34 +04:00
|
|
|
blocks = ext2fs_blocks_count(fs->super);
|
|
|
|
blocks_used = (ext2fs_blocks_count(fs->super) -
|
|
|
|
ext2fs_free_blocks_count(fs->super));
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
2008-12-09 05:33:11 +03:00
|
|
|
frag_percent_file = (10000 * ctx->fs_fragmented) / inodes_used;
|
|
|
|
frag_percent_file = (frag_percent_file + 5) / 10;
|
|
|
|
|
|
|
|
frag_percent_dir = (10000 * ctx->fs_fragmented_dir) / inodes_used;
|
|
|
|
frag_percent_dir = (frag_percent_dir + 5) / 10;
|
|
|
|
|
|
|
|
frag_percent_total = ((10000 * (ctx->fs_fragmented +
|
|
|
|
ctx->fs_fragmented_dir))
|
|
|
|
/ inodes_used);
|
|
|
|
frag_percent_total = (frag_percent_total + 5) / 10;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (!verbose) {
|
2010-06-14 01:00:00 +04:00
|
|
|
printf(_("%s: %u/%u files (%0d.%d%% non-contiguous), %llu/%llu blocks\n"),
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->device_name, inodes_used, inodes,
|
2008-12-09 05:33:11 +03:00
|
|
|
frag_percent_total / 10, frag_percent_total % 10,
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
blocks_used, blocks);
|
|
|
|
return;
|
|
|
|
}
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_("\n%8u inode used (%2.2f%%)\n", "\n%8u inodes used (%2.2f%%)\n",
|
|
|
|
inodes_used), inodes_used, 100.0 * inodes_used / inodes);
|
2008-12-09 05:33:11 +03:00
|
|
|
printf (P_("%8u non-contiguous file (%0d.%d%%)\n",
|
|
|
|
"%8u non-contiguous files (%0d.%d%%)\n",
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_fragmented),
|
2008-12-09 05:33:11 +03:00
|
|
|
ctx->fs_fragmented, frag_percent_file / 10,
|
|
|
|
frag_percent_file % 10);
|
|
|
|
printf (P_("%8u non-contiguous directory (%0d.%d%%)\n",
|
|
|
|
"%8u non-contiguous directories (%0d.%d%%)\n",
|
|
|
|
ctx->fs_fragmented_dir),
|
|
|
|
ctx->fs_fragmented_dir, frag_percent_dir / 10,
|
|
|
|
frag_percent_dir % 10);
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (_(" # of inodes with ind/dind/tind blocks: %u/%u/%u\n"),
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
ctx->fs_ind_count, ctx->fs_dind_count, ctx->fs_tind_count);
|
2008-08-14 17:48:07 +04:00
|
|
|
|
|
|
|
for (j=MAX_EXTENT_DEPTH_COUNT-1; j >=0; j--)
|
|
|
|
if (ctx->extent_depth_count[j])
|
|
|
|
break;
|
|
|
|
if (++j) {
|
|
|
|
printf (_(" Extent depth histogram: "));
|
|
|
|
for (i=0; i < j; i++) {
|
|
|
|
if (i)
|
|
|
|
fputc('/', stdout);
|
|
|
|
printf("%u", ctx->extent_depth_count[i]);
|
|
|
|
}
|
|
|
|
fputc('\n', stdout);
|
|
|
|
}
|
|
|
|
|
2010-06-14 01:00:00 +04:00
|
|
|
printf (P_("%8llu block used (%2.2f%%)\n",
|
|
|
|
"%8llu blocks used (%2.2f%%)\n",
|
2006-09-12 22:56:15 +04:00
|
|
|
blocks_used), blocks_used, 100.0 * blocks_used / blocks);
|
|
|
|
printf (P_("%8u bad block\n", "%8u bad blocks\n",
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_badblocks_count), ctx->fs_badblocks_count);
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_("%8u large file\n", "%8u large files\n",
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->large_files), ctx->large_files);
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_("\n%8u regular file\n", "\n%8u regular files\n",
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_regular_count), ctx->fs_regular_count);
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_("%8u directory\n", "%8u directories\n",
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_directory_count), ctx->fs_directory_count);
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_("%8u character device file\n",
|
|
|
|
"%8u character device files\n", ctx->fs_chardev_count),
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_chardev_count);
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_("%8u block device file\n", "%8u block device files\n",
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_blockdev_count), ctx->fs_blockdev_count);
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_("%8u fifo\n", "%8u fifos\n", ctx->fs_fifo_count),
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_fifo_count);
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_("%8u link\n", "%8u links\n",
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_links_count - dir_links),
|
|
|
|
ctx->fs_links_count - dir_links);
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_("%8u symbolic link", "%8u symbolic links",
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_symlinks_count), ctx->fs_symlinks_count);
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_(" (%u fast symbolic link)\n", " (%u fast symbolic links)\n",
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_fast_symlinks_count), ctx->fs_fast_symlinks_count);
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_("%8u socket\n", "%8u sockets\n", ctx->fs_sockets_count),
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_sockets_count);
|
|
|
|
printf ("--------\n");
|
2006-09-12 22:56:15 +04:00
|
|
|
printf (P_("%8u file\n", "%8u files\n",
|
2003-05-18 05:00:46 +04:00
|
|
|
ctx->fs_total_count - dir_links),
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
ctx->fs_total_count - dir_links);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void check_mount(e2fsck_t ctx)
|
|
|
|
{
|
|
|
|
errcode_t retval;
|
2002-11-08 00:16:55 +03:00
|
|
|
int cont;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
2002-11-08 00:16:55 +03:00
|
|
|
retval = ext2fs_check_if_mounted(ctx->filesystem_name,
|
|
|
|
&ctx->mount_flags);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (retval) {
|
|
|
|
com_err("ext2fs_check_if_mount", retval,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
_("while determining whether %s is mounted."),
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->filesystem_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-12-10 02:11:16 +03:00
|
|
|
* If the filesystem isn't mounted, or it's the root
|
|
|
|
* filesystem and it's mounted read-only, and we're not doing
|
|
|
|
* a read/write check, then everything's fine.
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
*/
|
2002-11-08 00:16:55 +03:00
|
|
|
if ((!(ctx->mount_flags & EXT2_MF_MOUNTED)) ||
|
|
|
|
((ctx->mount_flags & EXT2_MF_ISROOT) &&
|
2005-12-10 02:11:16 +03:00
|
|
|
(ctx->mount_flags & EXT2_MF_READONLY) &&
|
|
|
|
!(ctx->options & E2F_OPT_WRITECHECK)))
|
2001-07-31 00:29:52 +04:00
|
|
|
return;
|
|
|
|
|
2005-12-10 02:11:16 +03:00
|
|
|
if ((ctx->options & E2F_OPT_READONLY) &&
|
|
|
|
!(ctx->options & E2F_OPT_WRITECHECK)) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("Warning! %s is mounted.\n"), ctx->filesystem_name);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("%s is mounted. "), ctx->filesystem_name);
|
2003-08-19 18:08:34 +04:00
|
|
|
if (!ctx->interactive)
|
2000-08-23 01:37:47 +04:00
|
|
|
fatal_error(ctx, _("Cannot continue, aborting.\n\n"));
|
2011-10-10 01:08:47 +04:00
|
|
|
puts("\007\007\007\007");
|
|
|
|
printf(_("\n\nWARNING!!! "
|
2010-03-13 03:25:33 +03:00
|
|
|
"The filesystem is mounted. If you continue you ***WILL***\n"
|
2011-10-10 01:08:47 +04:00
|
|
|
"cause ***SEVERE*** filesystem damage.\n\n"));
|
|
|
|
puts("\007\007\007");
|
e2fsck: make the "fs is mounted; continue?" prompt more paranoid
A user received the "file system is mounted; do you really want to
continue" prompt, and then instead of typing "n" for no, forgot that
he hadn't declined to continuation question, and typed the up-arrow
key, which in his locale, the 'A' in "^[[A" was interpreted as "yes",
and he lost data.
This was clearly the user's fault, but to make e2fsck a bit safer
against user stupidity/carelessness, we will change the "fs is
mounted; continue?" prompt to default to no, and treat the escape
character (along with the return and space characters, currently) as a
request for the default answer.
Addresses-Debian-Bug: #619859
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-05-08 07:14:06 +04:00
|
|
|
cont = ask_yn(_("Do you really want to continue"), 0);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (!cont) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf (_("check aborted.\n"));
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-12-07 09:28:50 +03:00
|
|
|
static int is_on_batt(void)
|
2003-11-21 19:02:22 +03:00
|
|
|
{
|
|
|
|
FILE *f;
|
2004-04-12 08:16:44 +04:00
|
|
|
DIR *d;
|
|
|
|
char tmp[80], tmp2[80], fname[80];
|
2003-11-21 19:02:22 +03:00
|
|
|
unsigned int acflag;
|
2004-04-12 08:16:44 +04:00
|
|
|
struct dirent* de;
|
2003-11-21 19:02:22 +03:00
|
|
|
|
|
|
|
f = fopen("/proc/apm", "r");
|
|
|
|
if (f) {
|
2008-08-28 07:07:54 +04:00
|
|
|
if (fscanf(f, "%s %s %s %x", tmp, tmp, tmp, &acflag) != 4)
|
2003-11-21 19:02:22 +03:00
|
|
|
acflag = 1;
|
|
|
|
fclose(f);
|
|
|
|
return (acflag != 1);
|
|
|
|
}
|
2004-04-12 08:16:44 +04:00
|
|
|
d = opendir("/proc/acpi/ac_adapter");
|
2005-01-17 21:59:18 +03:00
|
|
|
if (d) {
|
2005-01-19 21:57:40 +03:00
|
|
|
while ((de=readdir(d)) != NULL) {
|
2005-01-17 21:59:18 +03:00
|
|
|
if (!strncmp(".", de->d_name, 1))
|
|
|
|
continue;
|
2008-08-28 07:07:54 +04:00
|
|
|
snprintf(fname, 80, "/proc/acpi/ac_adapter/%s/state",
|
2005-01-17 21:59:18 +03:00
|
|
|
de->d_name);
|
|
|
|
f = fopen(fname, "r");
|
|
|
|
if (!f)
|
|
|
|
continue;
|
|
|
|
if (fscanf(f, "%s %s", tmp2, tmp) != 2)
|
|
|
|
tmp[0] = 0;
|
|
|
|
fclose(f);
|
|
|
|
if (strncmp(tmp, "off-line", 8) == 0) {
|
|
|
|
closedir(d);
|
|
|
|
return 1;
|
|
|
|
}
|
2004-04-12 08:16:44 +04:00
|
|
|
}
|
2005-01-13 05:35:29 +03:00
|
|
|
closedir(d);
|
2005-01-17 21:59:18 +03:00
|
|
|
}
|
2003-11-21 19:02:22 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
/*
|
|
|
|
* This routine checks to see if a filesystem can be skipped; if so,
|
|
|
|
* it will exit with E2FSCK_OK. Under some conditions it will print a
|
|
|
|
* message explaining why a check is being forced.
|
|
|
|
*/
|
|
|
|
static void check_if_skip(e2fsck_t ctx)
|
|
|
|
{
|
|
|
|
ext2_filsys fs = ctx->fs;
|
2011-06-16 09:13:42 +04:00
|
|
|
struct problem_context pctx;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
const char *reason = NULL;
|
2001-06-14 05:16:17 +04:00
|
|
|
unsigned int reason_arg = 0;
|
2003-11-21 18:54:54 +03:00
|
|
|
long next_check;
|
2003-11-21 19:02:22 +03:00
|
|
|
int batt = is_on_batt();
|
2006-01-29 13:15:36 +03:00
|
|
|
int defer_check_on_battery;
|
2010-05-14 01:36:36 +04:00
|
|
|
int broken_system_clock;
|
2007-09-23 04:42:04 +04:00
|
|
|
time_t lastcheck;
|
2006-01-29 13:15:36 +03:00
|
|
|
|
2010-05-14 01:36:36 +04:00
|
|
|
profile_get_boolean(ctx->profile, "options", "broken_system_clock",
|
|
|
|
0, 0, &broken_system_clock);
|
|
|
|
if (ctx->flags & E2F_FLAG_TIME_INSANE)
|
|
|
|
broken_system_clock = 1;
|
2006-01-29 13:15:36 +03:00
|
|
|
profile_get_boolean(ctx->profile, "options",
|
2008-08-28 07:07:54 +04:00
|
|
|
"defer_check_on_battery", 0, 1,
|
2006-01-29 13:15:36 +03:00
|
|
|
&defer_check_on_battery);
|
|
|
|
if (!defer_check_on_battery)
|
|
|
|
batt = 0;
|
|
|
|
|
2007-08-11 07:58:56 +04:00
|
|
|
if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file || cflag)
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
return;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2010-11-13 02:09:07 +03:00
|
|
|
if (ctx->options & E2F_OPT_JOURNAL_ONLY)
|
|
|
|
goto skip;
|
|
|
|
|
2007-09-23 04:42:04 +04:00
|
|
|
lastcheck = fs->super->s_lastcheck;
|
|
|
|
if (lastcheck > ctx->now)
|
|
|
|
lastcheck -= ctx->time_fudge;
|
2005-01-25 11:09:24 +03:00
|
|
|
if ((fs->super->s_state & EXT2_ERROR_FS) ||
|
|
|
|
!ext2fs_test_valid(fs))
|
2001-06-14 05:16:17 +04:00
|
|
|
reason = _(" contains a file system with errors");
|
1998-08-26 19:23:31 +04:00
|
|
|
else if ((fs->super->s_state & EXT2_VALID_FS) == 0)
|
2001-06-14 05:16:17 +04:00
|
|
|
reason = _(" was not cleanly unmounted");
|
2007-10-01 17:18:54 +04:00
|
|
|
else if (check_backup_super_block(ctx))
|
|
|
|
reason = _(" primary superblock features different from backup");
|
2001-04-26 08:11:46 +04:00
|
|
|
else if ((fs->super->s_max_mnt_count > 0) &&
|
2000-07-07 08:13:21 +04:00
|
|
|
(fs->super->s_mnt_count >=
|
2001-06-14 05:16:17 +04:00
|
|
|
(unsigned) fs->super->s_max_mnt_count)) {
|
|
|
|
reason = _(" has been mounted %u times without being checked");
|
|
|
|
reason_arg = fs->super->s_mnt_count;
|
2008-08-28 07:07:54 +04:00
|
|
|
if (batt && (fs->super->s_mnt_count <
|
2003-11-21 19:02:22 +03:00
|
|
|
(unsigned) fs->super->s_max_mnt_count*2))
|
|
|
|
reason = 0;
|
2010-05-14 01:36:36 +04:00
|
|
|
} else if (!broken_system_clock && fs->super->s_checkinterval &&
|
|
|
|
(ctx->now < lastcheck)) {
|
2008-06-07 20:19:08 +04:00
|
|
|
reason = _(" has filesystem last checked time in the future");
|
|
|
|
if (batt)
|
|
|
|
reason = 0;
|
2010-05-14 01:36:36 +04:00
|
|
|
} else if (!broken_system_clock && fs->super->s_checkinterval &&
|
2008-08-28 07:07:54 +04:00
|
|
|
((ctx->now - lastcheck) >=
|
2008-06-07 19:04:10 +04:00
|
|
|
((time_t) fs->super->s_checkinterval))) {
|
2001-06-14 05:16:17 +04:00
|
|
|
reason = _(" has gone %u days without being checked");
|
2005-04-14 22:07:53 +04:00
|
|
|
reason_arg = (ctx->now - fs->super->s_lastcheck)/(3600*24);
|
2008-08-28 07:07:54 +04:00
|
|
|
if (batt && ((ctx->now - fs->super->s_lastcheck) <
|
2003-12-07 09:28:50 +03:00
|
|
|
fs->super->s_checkinterval*2))
|
2003-11-21 19:02:22 +03:00
|
|
|
reason = 0;
|
2001-06-14 05:16:17 +04:00
|
|
|
}
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (reason) {
|
2001-06-14 05:16:17 +04:00
|
|
|
fputs(ctx->device_name, stdout);
|
|
|
|
printf(reason, reason_arg);
|
|
|
|
fputs(_(", check forced.\n"), stdout);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
return;
|
|
|
|
}
|
2011-06-16 09:13:42 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the global counts from the block group counts. This
|
|
|
|
* is needed since modern kernels don't update the global
|
|
|
|
* counts so as to avoid locking the entire file system. So
|
|
|
|
* if the filesystem is not unmounted cleanly, the global
|
|
|
|
* counts may not be accurate. Update them here if we can,
|
|
|
|
* for the benefit of users who might examine the file system
|
|
|
|
* using dumpe2fs. (This is for cosmetic reasons only.)
|
|
|
|
*/
|
|
|
|
clear_problem_context(&pctx);
|
|
|
|
pctx.ino = fs->super->s_free_inodes_count;
|
|
|
|
pctx.ino2 = ctx->free_inodes;
|
|
|
|
if ((pctx.ino != pctx.ino2) &&
|
|
|
|
!(ctx->options & E2F_OPT_READONLY) &&
|
|
|
|
fix_problem(ctx, PR_0_FREE_INODE_COUNT, &pctx)) {
|
|
|
|
fs->super->s_free_inodes_count = ctx->free_inodes;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
}
|
|
|
|
clear_problem_context(&pctx);
|
|
|
|
pctx.blk = ext2fs_free_blocks_count(fs->super);
|
|
|
|
pctx.blk2 = ctx->free_blocks;
|
|
|
|
if ((pctx.blk != pctx.blk2) &&
|
|
|
|
!(ctx->options & E2F_OPT_READONLY) &&
|
|
|
|
fix_problem(ctx, PR_0_FREE_BLOCK_COUNT, &pctx)) {
|
|
|
|
ext2fs_free_blocks_count_set(fs->super, ctx->free_blocks);
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print the summary message when we're skipping a full check */
|
2009-09-08 04:46:34 +04:00
|
|
|
printf(_("%s: clean, %u/%u files, %llu/%llu blocks"), ctx->device_name,
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
fs->super->s_inodes_count - fs->super->s_free_inodes_count,
|
|
|
|
fs->super->s_inodes_count,
|
2009-09-08 04:46:34 +04:00
|
|
|
ext2fs_blocks_count(fs->super) -
|
|
|
|
ext2fs_free_blocks_count(fs->super),
|
|
|
|
ext2fs_blocks_count(fs->super));
|
2003-11-21 18:54:54 +03:00
|
|
|
next_check = 100000;
|
|
|
|
if (fs->super->s_max_mnt_count > 0) {
|
|
|
|
next_check = fs->super->s_max_mnt_count - fs->super->s_mnt_count;
|
2008-08-28 07:07:54 +04:00
|
|
|
if (next_check <= 0)
|
2003-11-21 18:54:54 +03:00
|
|
|
next_check = 1;
|
|
|
|
}
|
2010-05-14 01:36:36 +04:00
|
|
|
if (!broken_system_clock && fs->super->s_checkinterval &&
|
2005-04-14 22:07:53 +04:00
|
|
|
((ctx->now - fs->super->s_lastcheck) >= fs->super->s_checkinterval))
|
2003-11-21 18:54:54 +03:00
|
|
|
next_check = 1;
|
|
|
|
if (next_check <= 5) {
|
Print an explanation when skipping a check due being on battery
On Sat, Jan 28, 2006 at 12:53:33PM -0600, Fredrick Knieper wrote:
> Package: e2fsprogs
> Version: 1.38+1.39-WIP-2005.12.31-1
>
> When running fsck at boot or when running e2fsck manually on a device,
> fsck will not check a filesystem based on the maximum mount count,
> unless a flag such as -f or -c is used to force the filesystem check.
What's happening is that when you run on battery, e2fsck will delay
running the filesystem check, on the assumption that it is better to
defer the check until some time in the future when your laptop is
running on AC mains again. This deferral is not infinite, however; if
the number of mounts exceeds twice the max mount counts, or if the
interval between checks exceeds twice the check interval, e2fsck will
force the check even though you are on battery.
I've changed the sources to print a message to make this more clear.
Addresses Debian Bug: #350306
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-01-29 13:05:31 +03:00
|
|
|
if (next_check == 1) {
|
2008-08-28 07:07:54 +04:00
|
|
|
if (batt)
|
Print an explanation when skipping a check due being on battery
On Sat, Jan 28, 2006 at 12:53:33PM -0600, Fredrick Knieper wrote:
> Package: e2fsprogs
> Version: 1.38+1.39-WIP-2005.12.31-1
>
> When running fsck at boot or when running e2fsck manually on a device,
> fsck will not check a filesystem based on the maximum mount count,
> unless a flag such as -f or -c is used to force the filesystem check.
What's happening is that when you run on battery, e2fsck will delay
running the filesystem check, on the assumption that it is better to
defer the check until some time in the future when your laptop is
running on AC mains again. This deferral is not infinite, however; if
the number of mounts exceeds twice the max mount counts, or if the
interval between checks exceeds twice the check interval, e2fsck will
force the check even though you are on battery.
I've changed the sources to print a message to make this more clear.
Addresses Debian Bug: #350306
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-01-29 13:05:31 +03:00
|
|
|
fputs(_(" (check deferred; on battery)"),
|
|
|
|
stdout);
|
|
|
|
else
|
|
|
|
fputs(_(" (check after next mount)"), stdout);
|
|
|
|
} else
|
2003-12-07 09:28:50 +03:00
|
|
|
printf(_(" (check in %ld mounts)"), next_check);
|
2003-11-21 18:54:54 +03:00
|
|
|
}
|
|
|
|
fputc('\n', stdout);
|
2010-11-13 02:09:07 +03:00
|
|
|
skip:
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ext2fs_close(fs);
|
2001-07-29 20:06:58 +04:00
|
|
|
ctx->fs = NULL;
|
|
|
|
e2fsck_free_context(ctx);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
exit(FSCK_OK);
|
|
|
|
}
|
|
|
|
|
1998-05-07 09:02:00 +04:00
|
|
|
/*
|
|
|
|
* For completion notice
|
|
|
|
*/
|
1999-07-19 19:27:37 +04:00
|
|
|
struct percent_tbl {
|
|
|
|
int max_pass;
|
|
|
|
int table[32];
|
|
|
|
};
|
|
|
|
struct percent_tbl e2fsck_tbl = {
|
|
|
|
5, { 0, 70, 90, 92, 95, 100 }
|
|
|
|
};
|
2003-08-19 18:08:34 +04:00
|
|
|
static char bar[128], spaces[128];
|
1999-07-19 19:27:37 +04:00
|
|
|
|
|
|
|
static float calc_percent(struct percent_tbl *tbl, int pass, int curr,
|
|
|
|
int max)
|
|
|
|
{
|
|
|
|
float percent;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1999-07-19 19:27:37 +04:00
|
|
|
if (pass <= 0)
|
|
|
|
return 0.0;
|
2000-08-08 07:17:04 +04:00
|
|
|
if (pass > tbl->max_pass || max == 0)
|
1999-07-19 19:27:37 +04:00
|
|
|
return 100.0;
|
|
|
|
percent = ((float) curr) / ((float) max);
|
|
|
|
return ((percent * (tbl->table[pass] - tbl->table[pass-1]))
|
|
|
|
+ tbl->table[pass-1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void e2fsck_clear_progbar(e2fsck_t ctx)
|
|
|
|
{
|
|
|
|
if (!(ctx->flags & E2F_FLAG_PROG_BAR))
|
|
|
|
return;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2003-08-19 18:08:34 +04:00
|
|
|
printf("%s%s\r%s", ctx->start_meta, spaces + (sizeof(spaces) - 80),
|
|
|
|
ctx->stop_meta);
|
2003-04-16 22:05:06 +04:00
|
|
|
fflush(stdout);
|
1999-07-19 19:27:37 +04:00
|
|
|
ctx->flags &= ~E2F_FLAG_PROG_BAR;
|
|
|
|
}
|
|
|
|
|
2003-04-19 21:48:27 +04:00
|
|
|
int e2fsck_simple_progress(e2fsck_t ctx, const char *label, float percent,
|
2003-03-14 09:43:56 +03:00
|
|
|
unsigned int dpynum)
|
|
|
|
{
|
|
|
|
static const char spinner[] = "\\|/-";
|
|
|
|
int i;
|
2003-12-07 09:28:50 +03:00
|
|
|
unsigned int tick;
|
2003-03-14 09:43:56 +03:00
|
|
|
struct timeval tv;
|
|
|
|
int dpywidth;
|
2005-01-19 21:57:40 +03:00
|
|
|
int fixed_percent;
|
2003-03-14 09:43:56 +03:00
|
|
|
|
|
|
|
if (ctx->flags & E2F_FLAG_PROG_SUPPRESS)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the new progress position. If the
|
|
|
|
* percentage hasn't changed, then we skip out right
|
2008-08-28 07:07:54 +04:00
|
|
|
* away.
|
2003-03-14 09:43:56 +03:00
|
|
|
*/
|
2005-01-19 21:57:40 +03:00
|
|
|
fixed_percent = (int) ((10 * percent) + 0.5);
|
|
|
|
if (ctx->progress_last_percent == fixed_percent)
|
2003-03-14 09:43:56 +03:00
|
|
|
return 0;
|
2005-01-19 21:57:40 +03:00
|
|
|
ctx->progress_last_percent = fixed_percent;
|
2003-03-14 09:43:56 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we've already updated the spinner once within
|
|
|
|
* the last 1/8th of a second, no point doing it
|
|
|
|
* again.
|
|
|
|
*/
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
tick = (tv.tv_sec << 3) + (tv.tv_usec / (1000000 / 8));
|
|
|
|
if ((tick == ctx->progress_last_time) &&
|
2005-01-19 21:57:40 +03:00
|
|
|
(fixed_percent != 0) && (fixed_percent != 1000))
|
2003-03-14 09:43:56 +03:00
|
|
|
return 0;
|
|
|
|
ctx->progress_last_time = tick;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Advance the spinner, and note that the progress bar
|
|
|
|
* will be on the screen
|
|
|
|
*/
|
|
|
|
ctx->progress_pos = (ctx->progress_pos+1) & 3;
|
|
|
|
ctx->flags |= E2F_FLAG_PROG_BAR;
|
|
|
|
|
|
|
|
dpywidth = 66 - strlen(label);
|
|
|
|
dpywidth = 8 * (dpywidth / 8);
|
|
|
|
if (dpynum)
|
|
|
|
dpywidth -= 8;
|
|
|
|
|
|
|
|
i = ((percent * dpywidth) + 50) / 100;
|
2003-08-19 18:08:34 +04:00
|
|
|
printf("%s%s: |%s%s", ctx->start_meta, label,
|
|
|
|
bar + (sizeof(bar) - (i+1)),
|
2003-03-14 09:43:56 +03:00
|
|
|
spaces + (sizeof(spaces) - (dpywidth - i + 1)));
|
2005-01-19 21:57:40 +03:00
|
|
|
if (fixed_percent == 1000)
|
2003-03-14 09:43:56 +03:00
|
|
|
fputc('|', stdout);
|
|
|
|
else
|
|
|
|
fputc(spinner[ctx->progress_pos & 3], stdout);
|
2005-01-19 21:57:40 +03:00
|
|
|
printf(" %4.1f%% ", percent);
|
2003-03-14 09:43:56 +03:00
|
|
|
if (dpynum)
|
2005-01-19 21:57:40 +03:00
|
|
|
printf("%u\r", dpynum);
|
2003-03-14 09:43:56 +03:00
|
|
|
else
|
2005-01-19 21:57:40 +03:00
|
|
|
fputs(" \r", stdout);
|
|
|
|
fputs(ctx->stop_meta, stdout);
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2005-01-19 21:57:40 +03:00
|
|
|
if (fixed_percent == 1000)
|
2003-03-14 09:43:56 +03:00
|
|
|
e2fsck_clear_progbar(ctx);
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-05-07 09:02:00 +04:00
|
|
|
static int e2fsck_update_progress(e2fsck_t ctx, int pass,
|
|
|
|
unsigned long cur, unsigned long max)
|
|
|
|
{
|
2008-03-26 16:09:09 +03:00
|
|
|
char buf[1024];
|
1999-07-19 19:27:37 +04:00
|
|
|
float percent;
|
1998-08-01 08:18:06 +04:00
|
|
|
|
|
|
|
if (pass == 0)
|
|
|
|
return 0;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1998-05-07 09:02:00 +04:00
|
|
|
if (ctx->progress_fd) {
|
2008-08-28 07:07:54 +04:00
|
|
|
snprintf(buf, sizeof(buf), "%d %lu %lu %s\n",
|
2008-03-26 16:09:09 +03:00
|
|
|
pass, cur, max, ctx->device_name);
|
2009-04-22 23:09:41 +04:00
|
|
|
write_all(ctx->progress_fd, buf, strlen(buf));
|
1998-05-07 09:02:00 +04:00
|
|
|
} else {
|
2000-07-06 03:54:46 +04:00
|
|
|
percent = calc_percent(&e2fsck_tbl, pass, cur, max);
|
2003-03-14 09:43:56 +03:00
|
|
|
e2fsck_simple_progress(ctx, ctx->device_name,
|
|
|
|
percent, 0);
|
1998-05-07 09:02:00 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
|
|
|
#define PATH_SET "PATH=/sbin"
|
|
|
|
|
2011-09-17 00:49:38 +04:00
|
|
|
/*
|
|
|
|
* Make sure 0,1,2 file descriptors are open, so that we don't open
|
|
|
|
* the filesystem using the same file descriptor as stdout or stderr.
|
|
|
|
*/
|
2001-01-11 22:15:02 +03:00
|
|
|
static void reserve_stdio_fds(void)
|
1998-08-26 19:23:31 +04:00
|
|
|
{
|
2011-09-17 00:49:38 +04:00
|
|
|
int fd = 0;
|
1998-08-26 19:23:31 +04:00
|
|
|
|
2011-09-17 00:49:38 +04:00
|
|
|
while (fd <= 2) {
|
1998-08-26 19:23:31 +04:00
|
|
|
fd = open("/dev/null", O_RDWR);
|
1999-05-18 07:16:36 +04:00
|
|
|
if (fd < 0) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
fprintf(stderr, _("ERROR: Couldn't open "
|
|
|
|
"/dev/null (%s)\n"),
|
1999-05-18 07:16:36 +04:00
|
|
|
strerror(errno));
|
|
|
|
break;
|
|
|
|
}
|
1998-08-26 19:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-20 22:24:31 +04:00
|
|
|
#ifdef HAVE_SIGNAL_H
|
2003-12-07 09:28:50 +03:00
|
|
|
static void signal_progress_on(int sig EXT2FS_ATTR((unused)))
|
1999-07-19 19:27:37 +04:00
|
|
|
{
|
2000-08-23 01:37:47 +04:00
|
|
|
e2fsck_t ctx = e2fsck_global_ctx;
|
1999-07-19 19:27:37 +04:00
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ctx->progress = e2fsck_update_progress;
|
|
|
|
}
|
|
|
|
|
2003-12-07 09:28:50 +03:00
|
|
|
static void signal_progress_off(int sig EXT2FS_ATTR((unused)))
|
1999-07-19 19:27:37 +04:00
|
|
|
{
|
2000-08-23 01:37:47 +04:00
|
|
|
e2fsck_t ctx = e2fsck_global_ctx;
|
1999-07-19 19:27:37 +04:00
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
return;
|
|
|
|
|
|
|
|
e2fsck_clear_progbar(ctx);
|
|
|
|
ctx->progress = 0;
|
|
|
|
}
|
2002-07-21 22:14:03 +04:00
|
|
|
|
2003-12-07 09:28:50 +03:00
|
|
|
static void signal_cancel(int sig EXT2FS_ATTR((unused)))
|
2002-07-21 22:14:03 +04:00
|
|
|
{
|
|
|
|
e2fsck_t ctx = e2fsck_global_ctx;
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
exit(FSCK_CANCELED);
|
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_CANCEL;
|
|
|
|
}
|
1999-10-20 22:24:31 +04:00
|
|
|
#endif
|
1999-07-19 19:27:37 +04:00
|
|
|
|
2002-08-17 18:19:44 +04:00
|
|
|
static void parse_extended_opts(e2fsck_t ctx, const char *opts)
|
|
|
|
{
|
|
|
|
char *buf, *token, *next, *p, *arg;
|
2003-03-02 03:47:44 +03:00
|
|
|
int ea_ver;
|
2002-08-17 18:19:44 +04:00
|
|
|
int extended_usage = 0;
|
|
|
|
|
2003-03-02 03:47:44 +03:00
|
|
|
buf = string_copy(ctx, opts, 0);
|
2002-08-17 18:19:44 +04:00
|
|
|
for (token = buf; token && *token; token = next) {
|
|
|
|
p = strchr(token, ',');
|
|
|
|
next = 0;
|
|
|
|
if (p) {
|
|
|
|
*p = 0;
|
|
|
|
next = p+1;
|
2007-03-28 19:28:24 +04:00
|
|
|
}
|
2002-08-17 18:19:44 +04:00
|
|
|
arg = strchr(token, '=');
|
|
|
|
if (arg) {
|
|
|
|
*arg = 0;
|
|
|
|
arg++;
|
|
|
|
}
|
|
|
|
if (strcmp(token, "ea_ver") == 0) {
|
|
|
|
if (!arg) {
|
|
|
|
extended_usage++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ea_ver = strtoul(arg, &p, 0);
|
|
|
|
if (*p ||
|
|
|
|
((ea_ver != 1) && (ea_ver != 2))) {
|
|
|
|
fprintf(stderr,
|
|
|
|
_("Invalid EA version.\n"));
|
|
|
|
extended_usage++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ctx->ext_attr_ver = ea_ver;
|
2008-08-11 06:43:24 +04:00
|
|
|
} else if (strcmp(token, "fragcheck") == 0) {
|
|
|
|
ctx->options |= E2F_OPT_FRAGCHECK;
|
|
|
|
continue;
|
2010-11-13 02:09:07 +03:00
|
|
|
} else if (strcmp(token, "journal_only") == 0) {
|
|
|
|
if (arg) {
|
|
|
|
extended_usage++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ctx->options |= E2F_OPT_JOURNAL_ONLY;
|
2010-11-18 06:38:38 +03:00
|
|
|
} else if (strcmp(token, "discard") == 0) {
|
|
|
|
ctx->options |= E2F_OPT_DISCARD;
|
|
|
|
continue;
|
|
|
|
} else if (strcmp(token, "nodiscard") == 0) {
|
|
|
|
ctx->options &= ~E2F_OPT_DISCARD;
|
|
|
|
continue;
|
2005-06-20 16:35:27 +04:00
|
|
|
} else {
|
|
|
|
fprintf(stderr, _("Unknown extended option: %s\n"),
|
|
|
|
token);
|
2002-08-17 18:19:44 +04:00
|
|
|
extended_usage++;
|
2005-06-20 16:35:27 +04:00
|
|
|
}
|
2002-08-17 18:19:44 +04:00
|
|
|
}
|
2007-03-28 19:28:24 +04:00
|
|
|
free(buf);
|
|
|
|
|
2002-08-17 18:19:44 +04:00
|
|
|
if (extended_usage) {
|
2005-06-20 16:35:27 +04:00
|
|
|
fputs(("\nExtended options are separated by commas, "
|
|
|
|
"and may take an argument which\n"
|
|
|
|
"is set off by an equals ('=') sign. "
|
2008-08-11 06:43:24 +04:00
|
|
|
"Valid extended options are:\n"), stderr);
|
|
|
|
fputs(("\tea_ver=<ea_version (1 or 2)>\n"), stderr);
|
|
|
|
fputs(("\tfragcheck\n"), stderr);
|
2010-11-13 02:09:07 +03:00
|
|
|
fputs(("\tjournal_only\n"), stderr);
|
2010-11-18 06:38:38 +03:00
|
|
|
fputs(("\tdiscard\n"), stderr);
|
|
|
|
fputs(("\tnodiscard\n"), stderr);
|
2008-08-11 06:43:24 +04:00
|
|
|
fputc('\n', stderr);
|
2002-08-17 18:19:44 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
2007-03-28 19:28:24 +04:00
|
|
|
}
|
2002-08-17 18:19:44 +04:00
|
|
|
|
2006-01-04 18:32:16 +03:00
|
|
|
static void syntax_err_report(const char *filename, long err, int line_num)
|
|
|
|
{
|
2008-08-28 07:07:54 +04:00
|
|
|
fprintf(stderr,
|
2006-01-04 18:32:16 +03:00
|
|
|
_("Syntax error in e2fsck config file (%s, line #%d)\n\t%s\n"),
|
|
|
|
filename, line_num, error_message(err));
|
|
|
|
exit(FSCK_ERROR);
|
|
|
|
}
|
|
|
|
|
2006-06-10 18:08:18 +04:00
|
|
|
static const char *config_fn[] = { ROOT_SYSCONFDIR "/e2fsck.conf", 0 };
|
2002-08-17 18:19:44 +04:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
|
|
|
|
{
|
|
|
|
int flush = 0;
|
2001-05-02 01:13:37 +04:00
|
|
|
int c, fd;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
#ifdef MTRACE
|
|
|
|
extern void *mallwatch;
|
|
|
|
#endif
|
|
|
|
e2fsck_t ctx;
|
|
|
|
errcode_t retval;
|
1999-10-20 22:24:31 +04:00
|
|
|
#ifdef HAVE_SIGNAL_H
|
1999-07-19 19:27:37 +04:00
|
|
|
struct sigaction sa;
|
1999-10-20 22:24:31 +04:00
|
|
|
#endif
|
2002-08-17 18:19:44 +04:00
|
|
|
char *extended_opts = 0;
|
2006-01-01 00:21:00 +03:00
|
|
|
char *cp;
|
2007-08-21 06:55:33 +04:00
|
|
|
int res; /* result of sscanf */
|
|
|
|
#ifdef CONFIG_JBD_DEBUG
|
|
|
|
char *jbd_debug;
|
|
|
|
#endif
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
|
|
|
retval = e2fsck_allocate_context(&ctx);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
*ret_ctx = ctx;
|
|
|
|
|
2003-04-16 23:20:13 +04:00
|
|
|
setvbuf(stdout, NULL, _IONBF, BUFSIZ);
|
|
|
|
setvbuf(stderr, NULL, _IONBF, BUFSIZ);
|
2003-08-19 18:08:34 +04:00
|
|
|
if (isatty(0) && isatty(1)) {
|
|
|
|
ctx->interactive = 1;
|
|
|
|
} else {
|
|
|
|
ctx->start_meta[0] = '\001';
|
|
|
|
ctx->stop_meta[0] = '\002';
|
|
|
|
}
|
|
|
|
memset(bar, '=', sizeof(bar)-1);
|
|
|
|
memset(spaces, ' ', sizeof(spaces)-1);
|
2006-12-26 11:38:07 +03:00
|
|
|
add_error_table(&et_ext2_error_table);
|
|
|
|
add_error_table(&et_prof_error_table);
|
2003-03-02 03:47:44 +03:00
|
|
|
blkid_get_cache(&ctx->blkid, NULL);
|
2008-08-28 07:07:54 +04:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (argc && *argv)
|
|
|
|
ctx->program_name = *argv;
|
|
|
|
else
|
|
|
|
ctx->program_name = "e2fsck";
|
2010-11-18 06:38:38 +03:00
|
|
|
|
2004-02-24 08:16:09 +03:00
|
|
|
while ((c = getopt (argc, argv, "panyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDk")) != EOF)
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
switch (c) {
|
1998-05-07 09:02:00 +04:00
|
|
|
case 'C':
|
|
|
|
ctx->progress = e2fsck_update_progress;
|
2007-08-21 06:55:33 +04:00
|
|
|
res = sscanf(optarg, "%d", &ctx->progress_fd);
|
|
|
|
if (res != 1)
|
|
|
|
goto sscanf_err;
|
|
|
|
|
2008-03-26 15:26:01 +03:00
|
|
|
if (ctx->progress_fd < 0) {
|
|
|
|
ctx->progress = 0;
|
|
|
|
ctx->progress_fd = ctx->progress_fd * -1;
|
|
|
|
}
|
2001-05-12 17:43:46 +04:00
|
|
|
if (!ctx->progress_fd)
|
|
|
|
break;
|
2001-05-02 01:13:37 +04:00
|
|
|
/* Validate the file descriptor to avoid disasters */
|
|
|
|
fd = dup(ctx->progress_fd);
|
|
|
|
if (fd < 0) {
|
|
|
|
fprintf(stderr,
|
|
|
|
_("Error validating file descriptor %d: %s\n"),
|
|
|
|
ctx->progress_fd,
|
|
|
|
error_message(errno));
|
|
|
|
fatal_error(ctx,
|
|
|
|
_("Invalid completion information file descriptor"));
|
|
|
|
} else
|
|
|
|
close(fd);
|
1998-05-07 09:02:00 +04:00
|
|
|
break;
|
2002-07-25 08:00:08 +04:00
|
|
|
case 'D':
|
|
|
|
ctx->options |= E2F_OPT_COMPRESS_DIRS;
|
|
|
|
break;
|
2002-08-17 18:19:44 +04:00
|
|
|
case 'E':
|
|
|
|
extended_opts = optarg;
|
|
|
|
break;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
case 'p':
|
|
|
|
case 'a':
|
2003-01-03 00:36:44 +03:00
|
|
|
if (ctx->options & (E2F_OPT_YES|E2F_OPT_NO)) {
|
|
|
|
conflict_opt:
|
2008-08-28 07:07:54 +04:00
|
|
|
fatal_error(ctx,
|
2005-12-10 01:31:08 +03:00
|
|
|
_("Only one of the options -p/-a, -n or -y may be specified."));
|
2003-01-03 00:36:44 +03:00
|
|
|
}
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->options |= E2F_OPT_PREEN;
|
|
|
|
break;
|
|
|
|
case 'n':
|
2003-01-03 00:36:44 +03:00
|
|
|
if (ctx->options & (E2F_OPT_YES|E2F_OPT_PREEN))
|
|
|
|
goto conflict_opt;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->options |= E2F_OPT_NO;
|
|
|
|
break;
|
|
|
|
case 'y':
|
2003-01-03 00:36:44 +03:00
|
|
|
if (ctx->options & (E2F_OPT_PREEN|E2F_OPT_NO))
|
|
|
|
goto conflict_opt;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->options |= E2F_OPT_YES;
|
|
|
|
break;
|
|
|
|
case 't':
|
1997-10-20 05:38:32 +04:00
|
|
|
#ifdef RESOURCE_TRACK
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (ctx->options & E2F_OPT_TIME)
|
|
|
|
ctx->options |= E2F_OPT_TIME2;
|
|
|
|
else
|
|
|
|
ctx->options |= E2F_OPT_TIME;
|
1997-10-20 05:38:32 +04:00
|
|
|
#else
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
fprintf(stderr, _("The -t option is not "
|
|
|
|
"supported on this version of e2fsck.\n"));
|
1997-10-20 05:38:32 +04:00
|
|
|
#endif
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
break;
|
|
|
|
case 'c':
|
2001-12-24 23:01:59 +03:00
|
|
|
if (cflag++)
|
|
|
|
ctx->options |= E2F_OPT_WRITECHECK;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->options |= E2F_OPT_CHECKBLOCKS;
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
/* What we do by default, anyway! */
|
|
|
|
break;
|
|
|
|
case 'b':
|
2010-06-14 01:00:00 +04:00
|
|
|
res = sscanf(optarg, "%llu", &ctx->use_superblock);
|
2007-08-21 06:55:33 +04:00
|
|
|
if (res != 1)
|
|
|
|
goto sscanf_err;
|
2001-09-19 23:17:25 +04:00
|
|
|
ctx->flags |= E2F_FLAG_SB_SPECIFIED;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
break;
|
|
|
|
case 'B':
|
2001-12-24 06:27:52 +03:00
|
|
|
ctx->blocksize = atoi(optarg);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
break;
|
|
|
|
case 'I':
|
2007-08-21 06:55:33 +04:00
|
|
|
res = sscanf(optarg, "%d", &ctx->inode_buffer_blocks);
|
|
|
|
if (res != 1)
|
|
|
|
goto sscanf_err;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
break;
|
2001-07-23 08:17:49 +04:00
|
|
|
case 'j':
|
2010-12-07 01:07:27 +03:00
|
|
|
ctx->journal_name = blkid_get_devname(ctx->blkid,
|
|
|
|
optarg, NULL);
|
|
|
|
if (!ctx->journal_name) {
|
|
|
|
com_err(ctx->program_name, 0,
|
|
|
|
_("Unable to resolve '%s'"),
|
|
|
|
optarg);
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
2001-07-23 08:17:49 +04:00
|
|
|
break;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
case 'P':
|
2007-08-21 06:55:33 +04:00
|
|
|
res = sscanf(optarg, "%d", &ctx->process_inode_size);
|
|
|
|
if (res != 1)
|
|
|
|
goto sscanf_err;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
replace_bad_blocks++;
|
|
|
|
case 'l':
|
2003-03-02 03:47:44 +03:00
|
|
|
bad_blocks_file = string_copy(ctx, optarg, 0);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
ctx->options |= E2F_OPT_DEBUG;
|
|
|
|
break;
|
|
|
|
case 'f':
|
2001-12-22 07:28:54 +03:00
|
|
|
ctx->options |= E2F_OPT_FORCE;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
break;
|
|
|
|
case 'F':
|
|
|
|
flush = 1;
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
verbose = 1;
|
|
|
|
break;
|
|
|
|
case 'V':
|
|
|
|
show_version_only = 1;
|
|
|
|
break;
|
|
|
|
#ifdef MTRACE
|
|
|
|
case 'M':
|
|
|
|
mallwatch = (void *) strtol(optarg, NULL, 0);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case 'N':
|
2008-03-29 21:46:48 +03:00
|
|
|
ctx->device_name = string_copy(ctx, optarg, 0);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
break;
|
2004-02-24 08:16:09 +03:00
|
|
|
case 'k':
|
|
|
|
keep_bad_blocks++;
|
2004-02-27 18:39:27 +03:00
|
|
|
break;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
default:
|
|
|
|
usage(ctx);
|
|
|
|
}
|
|
|
|
if (show_version_only)
|
|
|
|
return 0;
|
|
|
|
if (optind != argc - 1)
|
|
|
|
usage(ctx);
|
2010-03-13 03:18:20 +03:00
|
|
|
if ((ctx->options & E2F_OPT_NO) &&
|
|
|
|
(ctx->options & E2F_OPT_COMPRESS_DIRS)) {
|
|
|
|
com_err(ctx->program_name, 0,
|
|
|
|
_("The -n and -D options are incompatible."));
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
|
|
|
if ((ctx->options & E2F_OPT_NO) && cflag) {
|
|
|
|
com_err(ctx->program_name, 0,
|
|
|
|
_("The -n and -c options are incompatible."));
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
|
|
|
if ((ctx->options & E2F_OPT_NO) && bad_blocks_file) {
|
|
|
|
com_err(ctx->program_name, 0,
|
|
|
|
_("The -n and -l/-L options are incompatible."));
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
|
|
|
if (ctx->options & E2F_OPT_NO)
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->options |= E2F_OPT_READONLY;
|
2007-10-22 06:04:03 +04:00
|
|
|
|
2004-11-30 22:07:11 +03:00
|
|
|
ctx->io_options = strchr(argv[optind], '?');
|
2008-08-28 07:07:54 +04:00
|
|
|
if (ctx->io_options)
|
2004-11-30 22:07:11 +03:00
|
|
|
*ctx->io_options++ = 0;
|
2003-03-02 03:47:44 +03:00
|
|
|
ctx->filesystem_name = blkid_get_devname(ctx->blkid, argv[optind], 0);
|
2003-11-21 17:10:29 +03:00
|
|
|
if (!ctx->filesystem_name) {
|
2008-08-28 07:07:54 +04:00
|
|
|
com_err(ctx->program_name, 0, _("Unable to resolve '%s'"),
|
2003-11-21 17:10:29 +03:00
|
|
|
argv[optind]);
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
2002-08-17 18:19:44 +04:00
|
|
|
if (extended_opts)
|
|
|
|
parse_extended_opts(ctx, extended_opts);
|
2005-12-31 08:00:10 +03:00
|
|
|
|
2006-01-01 00:21:00 +03:00
|
|
|
if ((cp = getenv("E2FSCK_CONFIG")) != NULL)
|
|
|
|
config_fn[0] = cp;
|
2006-01-04 18:32:16 +03:00
|
|
|
profile_set_syntax_err_cb(syntax_err_report);
|
2005-12-31 08:00:10 +03:00
|
|
|
profile_init(config_fn, &ctx->profile);
|
|
|
|
|
ChangeLog, bitops.h:
bitops.h (ext2fs_mark_generic_bitmap, ext2fs_unmark_generic_bitmap,
ext2fs_mark_block_bitmap, ext2fs_unmark_block_bitmap,
ext2fs_mark_inode_bitmap, ext2fs_unmark_inode_bitmap): Change to
return the previous state of the bit that is being marked or unmarked.
For speed optimization.
ChangeLog, pass3.c:
pass3.c (check_directory): Only do the loop detection algorithm if
we've searched over 2048 parent directories and haven't found the end
yet. This means that in the common case, we don't allocate or clear
the inode_loop_detection bitmap, which for large systems, merely
clearing the bitmap for each directory was turning out to be quite
expensive. Thanks to Jani Jaakkola (jjaakkol@cs.helsinki.fi) for
identifying this problem.
ChangeLog, Makefile.in, e2fsck.h, unix.c:
Makefile.in: Call sync after finishing building all in this directory.
unix.c (PRS): sync the filesystem before trying to use BLKFLSBUF, to
minimize the chance of causing dirty blocks to get dropped.
e2fsck.h: Manually define BLKFLSBUF if not defined, and we're on a
Linux/i386 system.
2000-02-08 22:14:02 +03:00
|
|
|
if (flush) {
|
2001-12-17 07:23:37 +03:00
|
|
|
fd = open(ctx->filesystem_name, O_RDONLY, 0);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (fd < 0) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
com_err("open", errno,
|
|
|
|
_("while opening %s for flushing"),
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->filesystem_name);
|
2000-08-23 01:37:47 +04:00
|
|
|
fatal_error(ctx, 0);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
ChangeLog, Makefile.in, swapfs.c, unix.c:
Makefile.in: Add message.c and swapfs.c to the list of source files to
build the make depend.
swapfs.c, unix.c: Only support the -s and -S options to e2fsck if
ENABLE_SWAPFS is defined.
Many files:
ext2fs.h, bitops.h, block.c, bmap.c, closefs.c, dirblock.c, inode.c,
native.c, openfs.c, rw_bitmaps.c, swapfs.c: Only include the
byte-swapping logic if ENABLE_SWAPFS is turned on or if we're on a
big-endian machine.
initialize.c (ext2fs_initialize):Use WORDS_BIGENDIAN directly to set
EXT2_FLAG_SWAP_BYTES, instead of using ext2fs_native_flag.
native.c (ext2fs_native_flag): Use WORDS_BIGENDIAN provided by
autoconf to determine whether or not return EXT2_FLAG_SWAP_BYTES.
2001-06-11 11:00:04 +04:00
|
|
|
if ((retval = ext2fs_sync_device(fd, 1))) {
|
2001-01-11 22:15:02 +03:00
|
|
|
com_err("ext2fs_sync_device", retval,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
_("while trying to flush %s"),
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->filesystem_name);
|
2000-08-23 01:37:47 +04:00
|
|
|
fatal_error(ctx, 0);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
}
|
2001-12-24 23:01:59 +03:00
|
|
|
if (cflag && bad_blocks_file) {
|
|
|
|
fprintf(stderr, _("The -c and the -l/-L options may "
|
|
|
|
"not be both used at the same time.\n"));
|
|
|
|
exit(FSCK_USAGE);
|
|
|
|
}
|
1999-10-20 22:24:31 +04:00
|
|
|
#ifdef HAVE_SIGNAL_H
|
1999-07-19 19:27:37 +04:00
|
|
|
/*
|
|
|
|
* Set up signal action
|
|
|
|
*/
|
|
|
|
memset(&sa, 0, sizeof(struct sigaction));
|
2002-07-25 08:00:08 +04:00
|
|
|
sa.sa_handler = signal_cancel;
|
|
|
|
sigaction(SIGINT, &sa, 0);
|
|
|
|
sigaction(SIGTERM, &sa, 0);
|
1999-07-19 19:27:37 +04:00
|
|
|
#ifdef SA_RESTART
|
|
|
|
sa.sa_flags = SA_RESTART;
|
|
|
|
#endif
|
2000-08-23 01:37:47 +04:00
|
|
|
e2fsck_global_ctx = ctx;
|
1999-07-19 19:27:37 +04:00
|
|
|
sa.sa_handler = signal_progress_on;
|
|
|
|
sigaction(SIGUSR1, &sa, 0);
|
|
|
|
sa.sa_handler = signal_progress_off;
|
|
|
|
sigaction(SIGUSR2, &sa, 0);
|
1999-10-20 22:24:31 +04:00
|
|
|
#endif
|
2001-07-29 20:06:58 +04:00
|
|
|
|
|
|
|
/* Update our PATH to include /sbin if we need to run badblocks */
|
|
|
|
if (cflag) {
|
|
|
|
char *oldpath = getenv("PATH");
|
2006-11-15 07:38:17 +03:00
|
|
|
char *newpath;
|
|
|
|
int len = sizeof(PATH_SET) + 1;
|
|
|
|
|
|
|
|
if (oldpath)
|
|
|
|
len += strlen(oldpath);
|
|
|
|
|
|
|
|
newpath = malloc(len);
|
|
|
|
if (!newpath)
|
|
|
|
fatal_error(ctx, "Couldn't malloc() newpath");
|
|
|
|
strcpy(newpath, PATH_SET);
|
|
|
|
|
2001-07-29 20:06:58 +04:00
|
|
|
if (oldpath) {
|
2006-11-15 07:38:17 +03:00
|
|
|
strcat(newpath, ":");
|
|
|
|
strcat(newpath, oldpath);
|
|
|
|
}
|
|
|
|
putenv(newpath);
|
2001-07-29 20:06:58 +04:00
|
|
|
}
|
2002-11-08 23:35:13 +03:00
|
|
|
#ifdef CONFIG_JBD_DEBUG
|
2007-08-21 06:55:33 +04:00
|
|
|
jbd_debug = getenv("E2FSCK_JBD_DEBUG");
|
2008-01-31 22:22:24 +03:00
|
|
|
if (jbd_debug) {
|
2007-08-21 06:55:33 +04:00
|
|
|
res = sscanf(jbd_debug, "%d", &journal_enable_debug);
|
|
|
|
if (res != 1) {
|
|
|
|
fprintf(stderr,
|
|
|
|
_("E2FSCK_JBD_DEBUG \"%s\" not an integer\n\n"),
|
|
|
|
jbd_debug);
|
|
|
|
exit (1);
|
|
|
|
}
|
2008-01-31 22:22:24 +03:00
|
|
|
}
|
2002-11-08 23:35:13 +03:00
|
|
|
#endif
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
return 0;
|
2007-08-21 06:55:33 +04:00
|
|
|
|
|
|
|
sscanf_err:
|
|
|
|
fprintf(stderr, _("\nInvalid non-numeric argument to -%c (\"%s\")\n\n"),
|
|
|
|
c, optarg);
|
|
|
|
exit (1);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
|
|
|
|
2009-05-29 07:40:18 +04:00
|
|
|
static errcode_t try_open_fs(e2fsck_t ctx, int flags, io_manager io_ptr,
|
|
|
|
ext2_filsys *ret_fs)
|
|
|
|
{
|
|
|
|
errcode_t retval;
|
|
|
|
|
|
|
|
*ret_fs = NULL;
|
|
|
|
if (ctx->superblock && ctx->blocksize) {
|
|
|
|
retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options,
|
|
|
|
flags, ctx->superblock, ctx->blocksize,
|
|
|
|
io_ptr, ret_fs);
|
|
|
|
} else if (ctx->superblock) {
|
|
|
|
int blocksize;
|
|
|
|
for (blocksize = EXT2_MIN_BLOCK_SIZE;
|
|
|
|
blocksize <= EXT2_MAX_BLOCK_SIZE; blocksize *= 2) {
|
|
|
|
if (*ret_fs) {
|
|
|
|
ext2fs_free(*ret_fs);
|
|
|
|
*ret_fs = NULL;
|
|
|
|
}
|
|
|
|
retval = ext2fs_open2(ctx->filesystem_name,
|
|
|
|
ctx->io_options, flags,
|
|
|
|
ctx->superblock, blocksize,
|
|
|
|
io_ptr, ret_fs);
|
|
|
|
if (!retval)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options,
|
|
|
|
flags, 0, 0, io_ptr, ret_fs);
|
2011-12-16 23:55:50 +04:00
|
|
|
|
|
|
|
if (ret_fs)
|
|
|
|
e2fsck_set_bitmap_type(*ret_fs, EXT2FS_BMAP64_RBTREE,
|
|
|
|
"default", NULL);
|
2009-05-29 07:40:18 +04:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
static const char *my_ver_string = E2FSPROGS_VERSION;
|
|
|
|
static const char *my_ver_date = E2FSPROGS_DATE;
|
2007-10-22 06:04:03 +04:00
|
|
|
|
2011-09-24 21:48:55 +04:00
|
|
|
int e2fsck_check_mmp(ext2_filsys fs, e2fsck_t ctx)
|
|
|
|
{
|
|
|
|
struct mmp_struct *mmp_s;
|
|
|
|
unsigned int mmp_check_interval;
|
|
|
|
errcode_t retval = 0;
|
|
|
|
struct problem_context pctx;
|
|
|
|
unsigned int wait_time = 0;
|
|
|
|
|
|
|
|
clear_problem_context(&pctx);
|
|
|
|
if (fs->mmp_buf == NULL) {
|
|
|
|
retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
|
|
|
|
if (retval)
|
|
|
|
goto check_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
|
|
|
|
if (retval)
|
|
|
|
goto check_error;
|
|
|
|
|
|
|
|
mmp_s = fs->mmp_buf;
|
|
|
|
|
|
|
|
mmp_check_interval = fs->super->s_mmp_update_interval;
|
|
|
|
if (mmp_check_interval < EXT4_MMP_MIN_CHECK_INTERVAL)
|
|
|
|
mmp_check_interval = EXT4_MMP_MIN_CHECK_INTERVAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If check_interval in MMP block is larger, use that instead of
|
|
|
|
* check_interval from the superblock.
|
|
|
|
*/
|
|
|
|
if (mmp_s->mmp_check_interval > mmp_check_interval)
|
|
|
|
mmp_check_interval = mmp_s->mmp_check_interval;
|
|
|
|
|
|
|
|
wait_time = mmp_check_interval * 2 + 1;
|
|
|
|
|
|
|
|
if (mmp_s->mmp_seq == EXT4_MMP_SEQ_CLEAN)
|
|
|
|
retval = 0;
|
|
|
|
else if (mmp_s->mmp_seq == EXT4_MMP_SEQ_FSCK)
|
|
|
|
retval = EXT2_ET_MMP_FSCK_ON;
|
|
|
|
else if (mmp_s->mmp_seq > EXT4_MMP_SEQ_MAX)
|
|
|
|
retval = EXT2_ET_MMP_UNKNOWN_SEQ;
|
|
|
|
|
|
|
|
if (retval)
|
|
|
|
goto check_error;
|
|
|
|
|
|
|
|
/* Print warning if e2fck will wait for more than 20 secs. */
|
|
|
|
if (verbose || wait_time > EXT4_MMP_MIN_CHECK_INTERVAL * 4) {
|
|
|
|
printf("MMP interval is %u seconds and total wait time is %u "
|
|
|
|
"seconds. Please wait...\n",
|
|
|
|
mmp_check_interval, wait_time * 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
check_error:
|
|
|
|
|
|
|
|
if (retval == EXT2_ET_MMP_BAD_BLOCK) {
|
|
|
|
if (fix_problem(ctx, PR_0_MMP_INVALID_BLK, &pctx)) {
|
|
|
|
fs->super->s_mmp_block = 0;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
retval = 0;
|
|
|
|
}
|
|
|
|
} else if (retval == EXT2_ET_MMP_FAILED) {
|
|
|
|
com_err(ctx->program_name, retval,
|
|
|
|
_("while checking MMP block"));
|
|
|
|
dump_mmp_msg(fs->mmp_buf, NULL);
|
|
|
|
} else if (retval == EXT2_ET_MMP_FSCK_ON ||
|
|
|
|
retval == EXT2_ET_MMP_UNKNOWN_SEQ) {
|
|
|
|
com_err(ctx->program_name, retval,
|
|
|
|
_("while checking MMP block"));
|
|
|
|
dump_mmp_msg(fs->mmp_buf,
|
|
|
|
_("If you are sure the filesystem is not "
|
|
|
|
"in use on any node, run:\n"
|
|
|
|
"'tune2fs -f -E clear_mmp {device}'\n"));
|
|
|
|
} else if (retval == EXT2_ET_MMP_MAGIC_INVALID) {
|
|
|
|
if (fix_problem(ctx, PR_0_MMP_INVALID_MAGIC, &pctx)) {
|
|
|
|
ext2fs_mmp_clear(fs);
|
|
|
|
retval = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
int main (int argc, char *argv[])
|
|
|
|
{
|
2009-09-02 04:01:38 +04:00
|
|
|
errcode_t retval = 0, retval2 = 0, orig_retval = 0;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
int exit_value = FSCK_OK;
|
|
|
|
ext2_filsys fs = 0;
|
|
|
|
io_manager io_ptr;
|
2001-01-01 18:51:50 +03:00
|
|
|
struct ext2_super_block *sb;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
const char *lib_ver_date;
|
|
|
|
int my_ver, lib_ver;
|
|
|
|
e2fsck_t ctx;
|
2009-05-29 07:40:18 +04:00
|
|
|
blk_t orig_superblock;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
struct problem_context pctx;
|
1997-11-03 22:42:40 +03:00
|
|
|
int flags, run_result;
|
2007-06-21 19:59:06 +04:00
|
|
|
int journal_size;
|
2007-08-04 04:43:37 +04:00
|
|
|
int sysval, sys_page_size = 4096;
|
2009-08-23 06:29:02 +04:00
|
|
|
int old_bitmaps;
|
2008-02-27 04:59:56 +03:00
|
|
|
__u32 features[3];
|
2008-03-26 16:09:09 +03:00
|
|
|
char *cp;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
clear_problem_context(&pctx);
|
2011-08-11 22:56:49 +04:00
|
|
|
sigcatcher_setup();
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
#ifdef MTRACE
|
|
|
|
mtrace();
|
|
|
|
#endif
|
|
|
|
#ifdef MCHECK
|
|
|
|
mcheck(0);
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
setlocale(LC_MESSAGES, "");
|
2002-03-05 11:26:52 +03:00
|
|
|
setlocale(LC_CTYPE, "");
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
|
|
|
|
textdomain(NLS_CAT_NAME);
|
2011-10-05 09:00:30 +04:00
|
|
|
set_com_err_gettext(gettext);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
#endif
|
|
|
|
my_ver = ext2fs_parse_version_string(my_ver_string);
|
|
|
|
lib_ver = ext2fs_get_library_version(0, &lib_ver_date);
|
|
|
|
if (my_ver > lib_ver) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
fprintf( stderr, _("Error: ext2fs library version "
|
|
|
|
"out of date!\n"));
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
show_version_only++;
|
|
|
|
}
|
2008-08-28 07:07:54 +04:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
retval = PRS(argc, argv, &ctx);
|
|
|
|
if (retval) {
|
|
|
|
com_err("e2fsck", retval,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
_("while trying to initialize program"));
|
2000-08-23 01:37:47 +04:00
|
|
|
exit(FSCK_ERROR);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
1998-08-26 19:23:31 +04:00
|
|
|
reserve_stdio_fds();
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2007-08-04 04:07:09 +04:00
|
|
|
init_resource_track(&ctx->global_rtrack, NULL);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (!(ctx->options & E2F_OPT_PREEN) || show_version_only)
|
2003-04-16 23:20:13 +04:00
|
|
|
fprintf(stderr, "e2fsck %s (%s)\n", my_ver_string,
|
2001-08-27 20:44:23 +04:00
|
|
|
my_ver_date);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
|
|
|
if (show_version_only) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
fprintf(stderr, _("\tUsing %s, %s\n"),
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
error_message(EXT2_ET_BASE), lib_ver_date);
|
2000-08-23 01:37:47 +04:00
|
|
|
exit(FSCK_OK);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
2008-08-28 07:07:54 +04:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
check_mount(ctx);
|
2008-08-28 07:07:54 +04:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (!(ctx->options & E2F_OPT_PREEN) &&
|
|
|
|
!(ctx->options & E2F_OPT_NO) &&
|
|
|
|
!(ctx->options & E2F_OPT_YES)) {
|
2003-08-19 18:08:34 +04:00
|
|
|
if (!ctx->interactive)
|
Many files:
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
1997-11-14 08:23:04 +03:00
|
|
|
fatal_error(ctx,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
_("need terminal for interactive repairs"));
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
|
|
|
ctx->superblock = ctx->use_superblock;
|
2011-09-24 21:48:55 +04:00
|
|
|
|
|
|
|
flags = EXT2_FLAG_SKIP_MMP;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
restart:
|
2003-05-05 20:08:47 +04:00
|
|
|
#ifdef CONFIG_TESTIO_DEBUG
|
2008-09-01 19:17:29 +04:00
|
|
|
if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
|
|
|
|
io_ptr = test_io_manager;
|
|
|
|
test_io_backing_manager = unix_io_manager;
|
|
|
|
} else
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
#endif
|
2008-09-01 19:17:29 +04:00
|
|
|
io_ptr = unix_io_manager;
|
2011-09-24 21:48:55 +04:00
|
|
|
flags |= EXT2_FLAG_NOFREE_ON_ERROR;
|
2009-08-23 06:29:02 +04:00
|
|
|
profile_get_boolean(ctx->profile, "options", "old_bitmaps", 0, 0,
|
|
|
|
&old_bitmaps);
|
|
|
|
if (!old_bitmaps)
|
|
|
|
flags |= EXT2_FLAG_64BITS;
|
2000-07-07 08:13:21 +04:00
|
|
|
if ((ctx->options & E2F_OPT_READONLY) == 0)
|
|
|
|
flags |= EXT2_FLAG_RW;
|
2006-03-19 04:01:09 +03:00
|
|
|
if ((ctx->mount_flags & EXT2_MF_MOUNTED) == 0)
|
|
|
|
flags |= EXT2_FLAG_EXCLUSIVE;
|
2000-07-07 08:13:21 +04:00
|
|
|
|
2009-05-29 07:40:18 +04:00
|
|
|
retval = try_open_fs(ctx, flags, io_ptr, &fs);
|
|
|
|
|
2001-09-19 23:17:25 +04:00
|
|
|
if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) &&
|
|
|
|
!(ctx->flags & E2F_FLAG_SB_SPECIFIED) &&
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
((retval == EXT2_ET_BAD_MAGIC) ||
|
2007-09-08 00:54:11 +04:00
|
|
|
(retval == EXT2_ET_CORRUPT_SUPERBLOCK) ||
|
2009-09-02 04:01:38 +04:00
|
|
|
((retval == 0) && (retval2 = ext2fs_check_desc(fs))))) {
|
|
|
|
if (retval2 == ENOMEM) {
|
|
|
|
retval = retval2;
|
|
|
|
goto failure;
|
|
|
|
}
|
2008-02-27 04:59:56 +03:00
|
|
|
if (fs->flags & EXT2_FLAG_NOFREE_ON_ERROR) {
|
|
|
|
ext2fs_free(fs);
|
|
|
|
fs = NULL;
|
|
|
|
}
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (!fs || (fs->group_desc_count > 1)) {
|
2007-09-08 00:54:11 +04:00
|
|
|
printf(_("%s: %s trying backup blocks...\n"),
|
2008-08-28 07:07:54 +04:00
|
|
|
ctx->program_name,
|
2007-09-08 00:54:11 +04:00
|
|
|
retval ? _("Superblock invalid,") :
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
_("Group descriptors look bad..."));
|
2009-05-29 07:40:18 +04:00
|
|
|
orig_superblock = ctx->superblock;
|
2001-12-24 06:27:52 +03:00
|
|
|
get_backup_sb(ctx, fs, ctx->filesystem_name, io_ptr);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (fs)
|
|
|
|
ext2fs_close(fs);
|
2007-09-08 00:54:11 +04:00
|
|
|
orig_retval = retval;
|
2009-05-29 07:40:18 +04:00
|
|
|
retval = try_open_fs(ctx, flags, io_ptr, &fs);
|
|
|
|
if ((orig_retval == 0) && retval != 0) {
|
2010-07-05 23:06:37 +04:00
|
|
|
if (fs)
|
|
|
|
ext2fs_close(fs);
|
2009-05-29 07:40:18 +04:00
|
|
|
com_err(ctx->program_name, retval,
|
|
|
|
"when using the backup blocks");
|
|
|
|
printf(_("%s: going back to original "
|
|
|
|
"superblock\n"), ctx->program_name);
|
|
|
|
ctx->superblock = orig_superblock;
|
|
|
|
retval = try_open_fs(ctx, flags, io_ptr, &fs);
|
|
|
|
}
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
|
|
|
}
|
2008-02-27 04:59:56 +03:00
|
|
|
if (((retval == EXT2_ET_UNSUPP_FEATURE) ||
|
|
|
|
(retval == EXT2_ET_RO_UNSUPP_FEATURE)) &&
|
|
|
|
fs && fs->super) {
|
|
|
|
sb = fs->super;
|
2008-08-28 07:07:54 +04:00
|
|
|
features[0] = (sb->s_feature_compat &
|
2008-02-27 04:59:56 +03:00
|
|
|
~EXT2_LIB_FEATURE_COMPAT_SUPP);
|
2008-08-28 07:07:54 +04:00
|
|
|
features[1] = (sb->s_feature_incompat &
|
2008-02-27 04:59:56 +03:00
|
|
|
~EXT2_LIB_FEATURE_INCOMPAT_SUPP);
|
2008-08-28 07:07:54 +04:00
|
|
|
features[2] = (sb->s_feature_ro_compat &
|
2008-02-27 04:59:56 +03:00
|
|
|
~EXT2_LIB_FEATURE_RO_COMPAT_SUPP);
|
|
|
|
if (features[0] || features[1] || features[2])
|
|
|
|
goto print_unsupp_features;
|
|
|
|
}
|
2009-09-02 04:01:38 +04:00
|
|
|
failure:
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (retval) {
|
2007-09-08 00:54:11 +04:00
|
|
|
if (orig_retval)
|
|
|
|
retval = orig_retval;
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
com_err(ctx->program_name, retval, _("while trying to open %s"),
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->filesystem_name);
|
1998-02-01 03:16:40 +03:00
|
|
|
if (retval == EXT2_ET_REV_TOO_HIGH) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("The filesystem revision is apparently "
|
1998-02-01 03:16:40 +03:00
|
|
|
"too high for this version of e2fsck.\n"
|
|
|
|
"(Or the filesystem superblock "
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
"is corrupt)\n\n"));
|
1998-02-01 03:16:40 +03:00
|
|
|
fix_problem(ctx, PR_0_SB_CORRUPT, &pctx);
|
|
|
|
} else if (retval == EXT2_ET_SHORT_READ)
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("Could this be a zero-length partition?\n"));
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
else if ((retval == EPERM) || (retval == EACCES))
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("You must have %s access to the "
|
|
|
|
"filesystem or be root\n"),
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
(ctx->options & E2F_OPT_READONLY) ?
|
|
|
|
"r/o" : "r/w");
|
|
|
|
else if (retval == ENXIO)
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("Possibly non-existent or swap device?\n"));
|
2006-03-19 04:01:09 +03:00
|
|
|
else if (retval == EBUSY)
|
|
|
|
printf(_("Filesystem mounted or opened exclusively "
|
|
|
|
"by another program?\n"));
|
2010-09-08 18:12:08 +04:00
|
|
|
else if (retval == ENOENT)
|
|
|
|
printf(_("Possibly non-existent device?\n"));
|
1997-11-04 07:25:22 +03:00
|
|
|
#ifdef EROFS
|
|
|
|
else if (retval == EROFS)
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("Disk write-protected; use the -n option "
|
1997-11-04 07:25:22 +03:00
|
|
|
"to do a read-only\n"
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
"check of the device.\n"));
|
1997-11-04 07:25:22 +03:00
|
|
|
#endif
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
else
|
|
|
|
fix_problem(ctx, PR_0_SB_CORRUPT, &pctx);
|
2000-08-23 01:37:47 +04:00
|
|
|
fatal_error(ctx, 0);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
2007-06-19 02:26:50 +04:00
|
|
|
/*
|
|
|
|
* We only update the master superblock because (a) paranoia;
|
|
|
|
* we don't want to corrupt the backup superblocks, and (b) we
|
|
|
|
* don't need to update the mount count and last checked
|
|
|
|
* fields in the backup superblock (the kernel doesn't update
|
|
|
|
* the backup superblocks anyway). With newer versions of the
|
|
|
|
* library this flag is set by ext2fs_open2(), but we set this
|
|
|
|
* here just to be sure. (No, we don't support e2fsck running
|
|
|
|
* with some other libext2fs than the one that it was shipped
|
|
|
|
* with, but just in case....)
|
|
|
|
*/
|
|
|
|
fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
|
2007-06-04 09:14:52 +04:00
|
|
|
|
|
|
|
if (!(ctx->flags & E2F_FLAG_GOT_DEVSIZE)) {
|
|
|
|
__u32 blocksize = EXT2_BLOCK_SIZE(fs->super);
|
|
|
|
int need_restart = 0;
|
|
|
|
|
2010-03-15 02:26:48 +03:00
|
|
|
pctx.errcode = ext2fs_get_device_size2(ctx->filesystem_name,
|
|
|
|
blocksize,
|
|
|
|
&ctx->num_blocks);
|
2007-06-04 09:14:52 +04:00
|
|
|
/*
|
|
|
|
* The floppy driver refuses to allow anyone else to
|
|
|
|
* open the device if has been opened with O_EXCL;
|
|
|
|
* this is unlike other block device drivers in Linux.
|
|
|
|
* To handle this, we close the filesystem and then
|
|
|
|
* reopen the filesystem after we get the device size.
|
|
|
|
*/
|
|
|
|
if (pctx.errcode == EBUSY) {
|
|
|
|
ext2fs_close(fs);
|
|
|
|
need_restart++;
|
2008-08-28 07:07:54 +04:00
|
|
|
pctx.errcode =
|
2010-03-15 02:26:48 +03:00
|
|
|
ext2fs_get_device_size2(ctx->filesystem_name,
|
|
|
|
blocksize,
|
|
|
|
&ctx->num_blocks);
|
2007-06-04 09:14:52 +04:00
|
|
|
}
|
|
|
|
if (pctx.errcode == EXT2_ET_UNIMPLEMENTED)
|
|
|
|
ctx->num_blocks = 0;
|
|
|
|
else if (pctx.errcode) {
|
|
|
|
fix_problem(ctx, PR_0_GETSIZE_ERROR, &pctx);
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT;
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
|
|
|
ctx->flags |= E2F_FLAG_GOT_DEVSIZE;
|
|
|
|
if (need_restart)
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->fs = fs;
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 17:50:49 +03:00
|
|
|
fs->priv_data = ctx;
|
2005-09-25 05:59:45 +04:00
|
|
|
fs->now = ctx->now;
|
2001-01-01 18:51:50 +03:00
|
|
|
sb = fs->super;
|
|
|
|
if (sb->s_rev_level > E2FSCK_CURRENT_REV) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
com_err(ctx->program_name, EXT2_ET_REV_TOO_HIGH,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
_("while trying to open %s"),
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->filesystem_name);
|
Many files:
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
1997-11-14 08:23:04 +03:00
|
|
|
get_newer:
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
fatal_error(ctx, _("Get a newer version of e2fsck!"));
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
2000-08-14 18:25:19 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the device name, which is used whenever we print error
|
|
|
|
* or informational messages to the user.
|
|
|
|
*/
|
|
|
|
if (ctx->device_name == 0 &&
|
2001-01-01 18:51:50 +03:00
|
|
|
(sb->s_volume_name[0] != 0)) {
|
2003-03-02 03:47:44 +03:00
|
|
|
ctx->device_name = string_copy(ctx, sb->s_volume_name,
|
|
|
|
sizeof(sb->s_volume_name));
|
2000-08-14 18:25:19 +04:00
|
|
|
}
|
|
|
|
if (ctx->device_name == 0)
|
2008-03-26 16:09:09 +03:00
|
|
|
ctx->device_name = string_copy(ctx, ctx->filesystem_name, 0);
|
|
|
|
for (cp = ctx->device_name; *cp; cp++)
|
|
|
|
if (isspace(*cp) || *cp == ':')
|
|
|
|
*cp = '_';
|
2000-08-14 18:25:19 +04:00
|
|
|
|
2009-05-18 07:03:04 +04:00
|
|
|
ehandler_init(fs->io);
|
|
|
|
|
2011-09-24 21:48:55 +04:00
|
|
|
if ((fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) &&
|
|
|
|
(flags & EXT2_FLAG_SKIP_MMP)) {
|
|
|
|
if (e2fsck_check_mmp(fs, ctx))
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restart in order to reopen fs but this time start mmp.
|
|
|
|
*/
|
|
|
|
if (flags & EXT2_FLAG_SKIP_MMP) {
|
|
|
|
ext2fs_close(fs);
|
2011-09-30 23:40:05 +04:00
|
|
|
ctx->fs = NULL;
|
2011-09-24 21:48:55 +04:00
|
|
|
flags &= ~EXT2_FLAG_SKIP_MMP;
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
|
2009-04-28 17:09:44 +04:00
|
|
|
if ((ctx->mount_flags & EXT2_MF_MOUNTED) &&
|
|
|
|
!(sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER))
|
|
|
|
goto skip_journal;
|
|
|
|
|
2000-07-07 08:13:21 +04:00
|
|
|
/*
|
2000-12-13 21:50:22 +03:00
|
|
|
* Make sure the ext3 superblock fields are consistent.
|
2000-07-07 08:13:21 +04:00
|
|
|
*/
|
2000-08-14 18:25:19 +04:00
|
|
|
retval = e2fsck_check_ext3_journal(ctx);
|
|
|
|
if (retval) {
|
|
|
|
com_err(ctx->program_name, retval,
|
|
|
|
_("while checking ext3 journal for %s"),
|
|
|
|
ctx->device_name);
|
2000-08-23 01:37:47 +04:00
|
|
|
fatal_error(ctx, 0);
|
2000-08-14 18:25:19 +04:00
|
|
|
}
|
|
|
|
|
2000-12-13 21:50:22 +03:00
|
|
|
/*
|
|
|
|
* Check to see if we need to do ext3-style recovery. If so,
|
|
|
|
* do it, and then restart the fsck.
|
|
|
|
*/
|
2001-01-01 18:51:50 +03:00
|
|
|
if (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) {
|
2000-08-23 01:50:04 +04:00
|
|
|
if (ctx->options & E2F_OPT_READONLY) {
|
|
|
|
printf(_("Warning: skipping journal recovery "
|
|
|
|
"because doing a read-only filesystem "
|
|
|
|
"check.\n"));
|
|
|
|
io_channel_flush(ctx->fs->io);
|
|
|
|
} else {
|
2003-01-03 00:53:54 +03:00
|
|
|
if (ctx->flags & E2F_FLAG_RESTARTED) {
|
|
|
|
/*
|
|
|
|
* Whoops, we attempted to run the
|
|
|
|
* journal twice. This should never
|
|
|
|
* happen, unless the hardware or
|
|
|
|
* device driver is being bogus.
|
|
|
|
*/
|
|
|
|
com_err(ctx->program_name, 0,
|
|
|
|
_("unable to set superblock flags on %s\n"), ctx->device_name);
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
2000-08-23 01:50:04 +04:00
|
|
|
retval = e2fsck_run_ext3_journal(ctx);
|
|
|
|
if (retval) {
|
|
|
|
com_err(ctx->program_name, retval,
|
2000-08-14 18:25:19 +04:00
|
|
|
_("while recovering ext3 journal of %s"),
|
2000-08-23 01:50:04 +04:00
|
|
|
ctx->device_name);
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
|
|
|
ext2fs_close(ctx->fs);
|
|
|
|
ctx->fs = 0;
|
2003-01-03 00:53:54 +03:00
|
|
|
ctx->flags |= E2F_FLAG_RESTARTED;
|
2000-08-23 01:50:04 +04:00
|
|
|
goto restart;
|
2000-07-07 08:13:21 +04:00
|
|
|
}
|
|
|
|
}
|
2000-08-14 18:25:19 +04:00
|
|
|
|
2009-04-28 17:09:44 +04:00
|
|
|
skip_journal:
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
/*
|
|
|
|
* Check for compatibility with the feature sets. We need to
|
|
|
|
* be more stringent than ext2fs_open().
|
|
|
|
*/
|
2008-02-27 04:59:56 +03:00
|
|
|
features[0] = sb->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP;
|
|
|
|
features[1] = sb->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP;
|
2008-08-28 07:07:54 +04:00
|
|
|
features[2] = (sb->s_feature_ro_compat &
|
2008-02-27 04:59:56 +03:00
|
|
|
~EXT2_LIB_FEATURE_RO_COMPAT_SUPP);
|
|
|
|
print_unsupp_features:
|
|
|
|
if (features[0] || features[1] || features[2]) {
|
|
|
|
int i, j;
|
|
|
|
__u32 *mask = features, m;
|
|
|
|
|
2008-08-28 07:07:54 +04:00
|
|
|
fprintf(stderr, _("%s has unsupported feature(s):"),
|
2008-02-27 04:59:56 +03:00
|
|
|
ctx->filesystem_name);
|
|
|
|
|
|
|
|
for (i=0; i <3; i++,mask++) {
|
|
|
|
for (j=0,m=1; j < 32; j++, m<<=1) {
|
|
|
|
if (*mask & m)
|
2008-08-28 07:07:54 +04:00
|
|
|
fprintf(stderr, " %s",
|
2008-02-27 04:59:56 +03:00
|
|
|
e2p_feature2string(i, m));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
putc('\n', stderr);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
goto get_newer;
|
|
|
|
}
|
Many files:
unix.c (main): If compression is enabled on the filesystem, print a
warning message (for now).
message.c: Add new compression shortcut: @c == compress
problem.c, problem.h (PR_1_COMPR_SET): Add new error code.
pass1.c (check_blocks): If the inode has EXT2_COMPRBLK_FL flag set,
check to see if the filesystem supports compression. If it does pass
this information down to process_block() so it can treat the
compressed block flag words correctly. If not, offer to clear the
flag, since it shouldn't be set.
(process_block): If an inode has the compressed inode flag set, allow
EXT2FS_COMPRESSED_BLKADDR.
pass1b.c (process_pass1b_block, delete_file_block, clone_file_block):
pass2.c (deallocate_inode_block): Use HOLE_BLKADDR to check to see if
the block can be skipped.
ChangeLog, Makefile.in:
Makefile.in: Exclude the internationalization files from being
distributed.
ChangeLog, configure, configure.in:
configure.in: Add support for --enable-compression. This is
experimental code only for now, which is why it's under --enable test.
Once it's stable, it will always be compiled in.
TODO:
Commit additional TODO items.
2000-02-11 18:55:07 +03:00
|
|
|
#ifdef ENABLE_COMPRESSION
|
2001-01-01 18:51:50 +03:00
|
|
|
if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION)
|
Many files:
unix.c (main): If compression is enabled on the filesystem, print a
warning message (for now).
message.c: Add new compression shortcut: @c == compress
problem.c, problem.h (PR_1_COMPR_SET): Add new error code.
pass1.c (check_blocks): If the inode has EXT2_COMPRBLK_FL flag set,
check to see if the filesystem supports compression. If it does pass
this information down to process_block() so it can treat the
compressed block flag words correctly. If not, offer to clear the
flag, since it shouldn't be set.
(process_block): If an inode has the compressed inode flag set, allow
EXT2FS_COMPRESSED_BLKADDR.
pass1b.c (process_pass1b_block, delete_file_block, clone_file_block):
pass2.c (deallocate_inode_block): Use HOLE_BLKADDR to check to see if
the block can be skipped.
ChangeLog, Makefile.in:
Makefile.in: Exclude the internationalization files from being
distributed.
ChangeLog, configure, configure.in:
configure.in: Add support for --enable-compression. This is
experimental code only for now, which is why it's under --enable test.
Once it's stable, it will always be compiled in.
TODO:
Commit additional TODO items.
2000-02-11 18:55:07 +03:00
|
|
|
com_err(ctx->program_name, 0,
|
|
|
|
_("Warning: compression support is experimental.\n"));
|
|
|
|
#endif
|
2002-06-26 07:26:34 +04:00
|
|
|
#ifndef ENABLE_HTREE
|
|
|
|
if (sb->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) {
|
|
|
|
com_err(ctx->program_name, 0,
|
|
|
|
_("E2fsck not compiled with HTREE support,\n\t"
|
|
|
|
"but filesystem %s has HTREE directories.\n"),
|
|
|
|
ctx->device_name);
|
|
|
|
goto get_newer;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
/*
|
|
|
|
* If the user specified a specific superblock, presumably the
|
|
|
|
* master superblock has been trashed. So we mark the
|
|
|
|
* superblock as dirty, so it can be written out.
|
|
|
|
*/
|
|
|
|
if (ctx->superblock &&
|
|
|
|
!(ctx->options & E2F_OPT_READONLY))
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
|
2007-08-04 04:43:37 +04:00
|
|
|
/*
|
|
|
|
* Calculate the number of filesystem blocks per pagesize. If
|
|
|
|
* fs->blocksize > page_size, set the number of blocks per
|
|
|
|
* pagesize to 1 to avoid division by zero errors.
|
|
|
|
*/
|
|
|
|
#ifdef _SC_PAGESIZE
|
|
|
|
sysval = sysconf(_SC_PAGESIZE);
|
|
|
|
if (sysval > 0)
|
|
|
|
sys_page_size = sysval;
|
|
|
|
#endif /* _SC_PAGESIZE */
|
|
|
|
ctx->blocks_per_page = sys_page_size / fs->blocksize;
|
|
|
|
if (ctx->blocks_per_page == 0)
|
|
|
|
ctx->blocks_per_page = 1;
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (ctx->superblock)
|
|
|
|
set_latch_flags(PR_LATCH_RELOC, PRL_LATCHED, 0);
|
2005-01-25 11:09:24 +03:00
|
|
|
ext2fs_mark_valid(fs);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
check_super_block(ctx);
|
1998-02-24 23:22:23 +03:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
2000-08-23 01:37:47 +04:00
|
|
|
fatal_error(ctx, 0);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
check_if_skip(ctx);
|
2009-04-23 08:39:06 +04:00
|
|
|
check_resize_inode(ctx);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (bad_blocks_file)
|
|
|
|
read_bad_blocks_file(ctx, bad_blocks_file, replace_bad_blocks);
|
|
|
|
else if (cflag)
|
2004-02-24 08:16:09 +03:00
|
|
|
read_bad_blocks_file(ctx, 0, !keep_bad_blocks); /* Test disk */
|
1998-02-24 23:22:23 +03:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
2000-08-23 01:37:47 +04:00
|
|
|
fatal_error(ctx, 0);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Mark the system as valid, 'til proven otherwise
|
|
|
|
*/
|
|
|
|
ext2fs_mark_valid(fs);
|
|
|
|
|
|
|
|
retval = ext2fs_read_bb_inode(fs, &fs->badblocks);
|
|
|
|
if (retval) {
|
|
|
|
com_err(ctx->program_name, retval,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
_("while reading bad blocks inode"));
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
preenhalt(ctx);
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("This doesn't bode well,"
|
|
|
|
" but we'll try to go on...\n"));
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
1997-11-03 22:42:40 +03:00
|
|
|
|
2007-06-21 19:59:06 +04:00
|
|
|
/*
|
|
|
|
* Save the journal size in megabytes.
|
|
|
|
* Try and use the journal size from the backup else let e2fsck
|
|
|
|
* find the default journal size.
|
|
|
|
*/
|
|
|
|
if (sb->s_jnl_backup_type == EXT3_JNL_BACKUP_BLOCKS)
|
2011-06-11 20:17:29 +04:00
|
|
|
journal_size = (sb->s_jnl_blocks[15] << (32 - 20)) |
|
|
|
|
(sb->s_jnl_blocks[16] >> 20);
|
2007-06-21 19:59:06 +04:00
|
|
|
else
|
|
|
|
journal_size = -1;
|
|
|
|
|
2011-07-20 22:40:06 +04:00
|
|
|
if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_QUOTA) {
|
|
|
|
int qtype;
|
|
|
|
/* Quotas were enabled. Do quota accounting during fsck. */
|
|
|
|
if ((sb->s_usr_quota_inum && sb->s_grp_quota_inum) ||
|
|
|
|
(!sb->s_usr_quota_inum && !sb->s_grp_quota_inum))
|
|
|
|
qtype = -1;
|
|
|
|
else
|
|
|
|
qtype = sb->s_usr_quota_inum ? USRQUOTA : GRPQUOTA;
|
|
|
|
|
2011-11-14 19:55:54 +04:00
|
|
|
quota_init_context(&ctx->qctx, ctx->fs, qtype);
|
2011-07-20 22:40:06 +04:00
|
|
|
}
|
|
|
|
|
1997-11-03 22:42:40 +03:00
|
|
|
run_result = e2fsck_run(ctx);
|
1999-07-19 19:27:37 +04:00
|
|
|
e2fsck_clear_progbar(ctx);
|
2007-06-21 19:59:06 +04:00
|
|
|
|
|
|
|
if (ctx->flags & E2F_FLAG_JOURNAL_INODE) {
|
|
|
|
if (fix_problem(ctx, PR_6_RECREATE_JOURNAL, &pctx)) {
|
|
|
|
if (journal_size < 1024)
|
2009-09-08 04:46:34 +04:00
|
|
|
journal_size = ext2fs_default_journal_size(ext2fs_blocks_count(fs->super));
|
2007-06-21 19:59:06 +04:00
|
|
|
if (journal_size < 0) {
|
|
|
|
fs->super->s_feature_compat &=
|
|
|
|
~EXT3_FEATURE_COMPAT_HAS_JOURNAL;
|
2007-10-06 20:37:08 +04:00
|
|
|
fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
|
2008-08-28 07:07:54 +04:00
|
|
|
com_err(ctx->program_name, 0,
|
2007-06-21 19:59:06 +04:00
|
|
|
_("Couldn't determine journal size"));
|
|
|
|
goto no_journal;
|
|
|
|
}
|
|
|
|
printf(_("Creating journal (%d blocks): "),
|
|
|
|
journal_size);
|
|
|
|
fflush(stdout);
|
|
|
|
retval = ext2fs_add_journal_inode(fs,
|
|
|
|
journal_size, 0);
|
|
|
|
if (retval) {
|
|
|
|
com_err("Error ", retval,
|
|
|
|
_("\n\twhile trying to create journal"));
|
|
|
|
goto no_journal;
|
|
|
|
}
|
|
|
|
printf(_(" Done.\n"));
|
|
|
|
printf(_("\n*** journal has been re-created - "
|
|
|
|
"filesystem is now ext3 again ***\n"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
no_journal:
|
|
|
|
|
2011-07-20 22:40:06 +04:00
|
|
|
if (ctx->qctx) {
|
2011-11-14 19:55:54 +04:00
|
|
|
quota_write_inode(ctx->qctx, -1);
|
|
|
|
quota_release_context(&ctx->qctx);
|
2011-07-20 22:40:06 +04:00
|
|
|
}
|
|
|
|
|
1997-11-03 22:42:40 +03:00
|
|
|
if (run_result == E2F_FLAG_RESTART) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("Restarting e2fsck from the beginning...\n"));
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
retval = e2fsck_reset_context(ctx);
|
|
|
|
if (retval) {
|
|
|
|
com_err(ctx->program_name, retval,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
_("while resetting context"));
|
2000-08-23 01:37:47 +04:00
|
|
|
fatal_error(ctx, 0);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
1999-01-04 10:35:45 +03:00
|
|
|
ext2fs_close(fs);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
goto restart;
|
|
|
|
}
|
2002-07-21 22:14:03 +04:00
|
|
|
if (run_result & E2F_FLAG_CANCEL) {
|
|
|
|
printf(_("%s: e2fsck canceled.\n"), ctx->device_name ?
|
|
|
|
ctx->device_name : ctx->filesystem_name);
|
|
|
|
exit_value |= FSCK_CANCELED;
|
|
|
|
}
|
|
|
|
if (run_result & E2F_FLAG_ABORT)
|
|
|
|
fatal_error(ctx, _("aborted"));
|
2007-10-01 17:18:54 +04:00
|
|
|
if (check_backup_super_block(ctx)) {
|
|
|
|
fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
}
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
|
|
|
#ifdef MTRACE
|
|
|
|
mtrace_print("Cleanup");
|
|
|
|
#endif
|
|
|
|
if (ext2fs_test_changed(fs)) {
|
2002-07-21 22:14:03 +04:00
|
|
|
exit_value |= FSCK_NONDESTRUCT;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
if (!(ctx->options & E2F_OPT_PREEN))
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"),
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->device_name);
|
2002-11-08 00:16:55 +03:00
|
|
|
if (ctx->mount_flags & EXT2_MF_ISROOT) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("%s: ***** REBOOT LINUX *****\n"),
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
ctx->device_name);
|
2002-07-21 22:14:03 +04:00
|
|
|
exit_value |= FSCK_REBOOT;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
}
|
|
|
|
}
|
2005-12-31 08:52:23 +03:00
|
|
|
if (!ext2fs_test_valid(fs) ||
|
2008-08-28 07:07:54 +04:00
|
|
|
((exit_value & FSCK_CANCELED) &&
|
2005-12-31 08:52:23 +03:00
|
|
|
(sb->s_state & EXT2_ERROR_FS))) {
|
2001-07-20 22:13:49 +04:00
|
|
|
printf(_("\n%s: ********** WARNING: Filesystem still has "
|
|
|
|
"errors **********\n\n"), ctx->device_name);
|
2002-07-21 22:14:03 +04:00
|
|
|
exit_value |= FSCK_UNCORRECTED;
|
|
|
|
exit_value &= ~FSCK_NONDESTRUCT;
|
2001-07-20 22:13:49 +04:00
|
|
|
}
|
2005-12-31 08:52:23 +03:00
|
|
|
if (exit_value & FSCK_CANCELED) {
|
|
|
|
int allow_cancellation;
|
|
|
|
|
|
|
|
profile_get_boolean(ctx->profile, "options",
|
2008-08-28 07:07:54 +04:00
|
|
|
"allow_cancellation", 0, 0,
|
2005-12-31 08:52:23 +03:00
|
|
|
&allow_cancellation);
|
2002-07-21 22:14:03 +04:00
|
|
|
exit_value &= ~FSCK_NONDESTRUCT;
|
2005-12-31 08:52:23 +03:00
|
|
|
if (allow_cancellation && ext2fs_test_valid(fs) &&
|
2008-08-28 07:07:54 +04:00
|
|
|
(sb->s_state & EXT2_VALID_FS) &&
|
2005-12-31 08:52:23 +03:00
|
|
|
!(sb->s_state & EXT2_ERROR_FS))
|
|
|
|
exit_value = 0;
|
|
|
|
} else {
|
2002-07-21 22:14:03 +04:00
|
|
|
show_stats(ctx);
|
2002-11-08 23:55:17 +03:00
|
|
|
if (!(ctx->options & E2F_OPT_READONLY)) {
|
|
|
|
if (ext2fs_test_valid(fs)) {
|
|
|
|
if (!(sb->s_state & EXT2_VALID_FS))
|
|
|
|
exit_value |= FSCK_NONDESTRUCT;
|
|
|
|
sb->s_state = EXT2_VALID_FS;
|
|
|
|
} else
|
|
|
|
sb->s_state &= ~EXT2_VALID_FS;
|
|
|
|
sb->s_mnt_count = 0;
|
2010-05-14 01:36:36 +04:00
|
|
|
if (!(ctx->flags & E2F_FLAG_TIME_INSANE))
|
|
|
|
sb->s_lastcheck = ctx->now;
|
2010-06-25 18:53:13 +04:00
|
|
|
memset(((char *) sb) + EXT4_S_ERR_START, 0,
|
|
|
|
EXT4_S_ERR_LEN);
|
2002-11-08 23:55:17 +03:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
}
|
|
|
|
}
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
|
2010-05-18 06:54:06 +04:00
|
|
|
if ((run_result & E2F_FLAG_CANCEL) == 0 &&
|
|
|
|
sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM &&
|
2008-03-31 18:50:19 +04:00
|
|
|
!(ctx->options & E2F_OPT_READONLY)) {
|
|
|
|
retval = ext2fs_set_gdt_csum(ctx->fs);
|
|
|
|
if (retval) {
|
|
|
|
com_err(ctx->program_name, retval,
|
|
|
|
_("while setting block group checksum info"));
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
|
|
|
}
|
2007-10-22 06:04:03 +04:00
|
|
|
|
Many files:
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
1997-11-14 08:23:04 +03:00
|
|
|
e2fsck_write_bitmaps(ctx);
|
2007-08-04 04:07:09 +04:00
|
|
|
io_channel_flush(ctx->fs->io);
|
2009-05-28 17:55:10 +04:00
|
|
|
print_resource_track(ctx, NULL, &ctx->global_rtrack, ctx->fs->io);
|
|
|
|
|
2001-07-29 20:26:46 +04:00
|
|
|
ext2fs_close(fs);
|
|
|
|
ctx->fs = NULL;
|
2003-03-02 03:47:44 +03:00
|
|
|
free(ctx->journal_name);
|
2005-07-25 20:36:43 +04:00
|
|
|
|
|
|
|
e2fsck_free_context(ctx);
|
2006-12-26 11:38:07 +03:00
|
|
|
remove_error_table(&et_ext2_error_table);
|
|
|
|
remove_error_table(&et_prof_error_table);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
return exit_value;
|
|
|
|
}
|