1997-04-29 20:15:03 +04:00
|
|
|
/*
|
|
|
|
* message.c --- print e2fsck messages (with compression)
|
|
|
|
*
|
|
|
|
* Copyright 1996, 1997 by Theodore Ts'o
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
|
|
|
*
|
|
|
|
* print_e2fsck_message() prints a message to the user, using
|
|
|
|
* compression techniques and expansions of abbreviations.
|
|
|
|
*
|
|
|
|
* The following % expansions are supported:
|
|
|
|
*
|
|
|
|
* %b <blk> block number
|
|
|
|
* %B <blkcount> integer
|
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
|
|
|
* %c <blk2> block number
|
1997-04-29 20:15:03 +04:00
|
|
|
* %di <dirent>->ino inode number
|
|
|
|
* %dn <dirent>->name string
|
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
|
|
|
* %dr <dirent>->rec_len
|
|
|
|
* %dl <dirent>->name_len
|
1997-04-29 20:15:03 +04:00
|
|
|
* %D <dir> inode number
|
|
|
|
* %g <group> integer
|
|
|
|
* %i <ino> inode number
|
|
|
|
* %Is <inode> -> i_size
|
|
|
|
* %Ib <inode> -> i_blocks
|
|
|
|
* %Il <inode> -> i_links_count
|
|
|
|
* %Im <inode> -> i_mode
|
|
|
|
* %IM <inode> -> i_mtime
|
|
|
|
* %IF <inode> -> i_faddr
|
|
|
|
* %If <inode> -> i_file_acl
|
|
|
|
* %Id <inode> -> i_dir_acl
|
|
|
|
* %j <ino2> inode number
|
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
|
|
|
* %m <com_err error message>
|
1997-04-29 20:15:03 +04:00
|
|
|
* %N <num>
|
|
|
|
* %p ext2fs_get_pathname of directory <ino>
|
|
|
|
* %P ext2fs_get_pathname of <dirent>->ino with <ino2> as
|
|
|
|
* the containing directory. (If dirent is NULL
|
|
|
|
* then return the pathname of directory <ino2>)
|
|
|
|
* %q ext2fs_get_pathname of directory <dir>
|
|
|
|
* %Q ext2fs_get_pathname of directory <ino> with <dir> as
|
|
|
|
* the containing directory.
|
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
|
|
|
* %s <str> miscellaneous string
|
|
|
|
* %S backup superblock
|
1997-04-29 20:15:03 +04:00
|
|
|
*
|
|
|
|
* The following '@' expansions are supported:
|
|
|
|
*
|
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
|
|
|
* @A error allocating
|
1997-04-29 20:15:03 +04:00
|
|
|
* @b block
|
|
|
|
* @B bitmap
|
|
|
|
* @C conflicts with some other fs block
|
|
|
|
* @i inode
|
1997-08-14 21:17:16 +04:00
|
|
|
* @I illegal
|
1997-04-29 20:15:03 +04:00
|
|
|
* @D deleted
|
|
|
|
* @d directory
|
|
|
|
* @e entry
|
|
|
|
* @E Entry '%Dn' in %p (%i)
|
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
|
|
|
* @f filesystem
|
1997-04-29 20:15:03 +04:00
|
|
|
* @F for @i %i (%Q) is
|
|
|
|
* @g group
|
|
|
|
* @l lost+found
|
|
|
|
* @L is a link
|
|
|
|
* @u unattached
|
|
|
|
* @r root 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
|
|
|
* @s should be
|
|
|
|
* @S superblock
|
1997-04-29 20:15:03 +04:00
|
|
|
* @z zero-length
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <termios.h>
|
|
|
|
|
|
|
|
#include "e2fsck.h"
|
|
|
|
|
|
|
|
#include "problem.h"
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define _INLINE_ __inline__
|
|
|
|
#else
|
|
|
|
#define _INLINE_
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This structure defines the abbreviations used by the text strings
|
|
|
|
* below. The first character in the string is the index letter. An
|
|
|
|
* abbreviation of the form '@<i>' is expanded by looking up the index
|
|
|
|
* letter <i> in the table below.
|
|
|
|
*/
|
|
|
|
static const char *abbrevs[] = {
|
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
|
|
|
"Aerror allocating",
|
1997-04-29 20:15:03 +04:00
|
|
|
"bblock",
|
|
|
|
"Bbitmap",
|
|
|
|
"Cconflicts with some other fs @b",
|
|
|
|
"iinode",
|
1997-08-14 21:17:16 +04:00
|
|
|
"Iillegal",
|
1997-04-29 20:15:03 +04:00
|
|
|
"Ddeleted",
|
|
|
|
"ddirectory",
|
|
|
|
"eentry",
|
|
|
|
"E@e '%Dn' in %p (%i)",
|
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
|
|
|
"ffilesystem",
|
1997-04-29 20:15:03 +04:00
|
|
|
"Ffor @i %i (%Q) is",
|
|
|
|
"ggroup",
|
|
|
|
"llost+found",
|
|
|
|
"Lis a link",
|
|
|
|
"uunattached",
|
|
|
|
"rroot @i",
|
|
|
|
"sshould be",
|
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
|
|
|
"Ssuper@b",
|
1997-04-29 20:15:03 +04:00
|
|
|
"zzero-length",
|
|
|
|
"@@",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Give more user friendly names to the "special" inodes.
|
|
|
|
*/
|
|
|
|
#define num_special_inodes 7
|
|
|
|
static const char *special_inode_name[] =
|
|
|
|
{
|
|
|
|
"<The NULL inode>", /* 0 */
|
|
|
|
"<The bad blocks inode>", /* 1 */
|
|
|
|
"/", /* 2 */
|
|
|
|
"<The ACL index inode>", /* 3 */
|
|
|
|
"<The ACL data inode>", /* 4 */
|
|
|
|
"<The boot loader inode>", /* 5 */
|
|
|
|
"<The undelete directory inode>" /* 6 */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function prints a pathname, using the ext2fs_get_pathname
|
|
|
|
* function
|
|
|
|
*/
|
|
|
|
static void print_pathname(ext2_filsys fs, ino_t dir, ino_t ino)
|
|
|
|
{
|
|
|
|
errcode_t retval;
|
|
|
|
char *path;
|
|
|
|
|
|
|
|
if (!dir && (ino < num_special_inodes)) {
|
|
|
|
fputs(special_inode_name[ino], stdout);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = ext2fs_get_pathname(fs, dir, ino, &path);
|
|
|
|
if (retval)
|
|
|
|
fputs("???", stdout);
|
|
|
|
else {
|
|
|
|
fputs(path, stdout);
|
1997-11-03 22:42:40 +03:00
|
|
|
ext2fs_free_mem((void **) &path);
|
1997-04-29 20:15:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function handles the '@' expansion. We allow recursive
|
|
|
|
* expansion; an @ expression can contain further '@' and '%'
|
|
|
|
* expressions.
|
|
|
|
*/
|
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 _INLINE_ void expand_at_expression(e2fsck_t ctx, char ch,
|
|
|
|
struct problem_context *pctx,
|
1997-04-29 20:15:03 +04:00
|
|
|
int *first)
|
|
|
|
{
|
|
|
|
const char **cpp, *str;
|
|
|
|
|
|
|
|
/* Search for the abbreviation */
|
|
|
|
for (cpp = abbrevs; *cpp; cpp++) {
|
|
|
|
if (ch == *cpp[0])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (*cpp) {
|
|
|
|
str = (*cpp) + 1;
|
|
|
|
if (*first && islower(*str)) {
|
|
|
|
*first = 0;
|
|
|
|
fputc(toupper(*str++), 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
|
|
|
print_e2fsck_message(ctx, str, pctx, *first);
|
1997-04-29 20:15:03 +04:00
|
|
|
} else
|
|
|
|
printf("@%c", ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function expands '%kX' expressions
|
|
|
|
*/
|
|
|
|
static _INLINE_ void expand_inode_expression(char ch,
|
|
|
|
struct problem_context *ctx)
|
|
|
|
{
|
|
|
|
struct ext2_inode *inode;
|
|
|
|
char * time_str;
|
|
|
|
time_t t;
|
|
|
|
|
|
|
|
if (!ctx || !ctx->inode)
|
|
|
|
goto no_inode;
|
|
|
|
|
|
|
|
inode = ctx->inode;
|
|
|
|
|
|
|
|
switch (ch) {
|
|
|
|
case 's':
|
|
|
|
printf("%u", inode->i_size);
|
|
|
|
break;
|
|
|
|
case 'b':
|
|
|
|
printf("%u", inode->i_blocks);
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
printf("%d", inode->i_links_count);
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
printf("0%o", inode->i_mode);
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
t = inode->i_mtime;
|
|
|
|
time_str = ctime(&t);
|
|
|
|
printf("%.24s", time_str);
|
|
|
|
break;
|
|
|
|
case 'F':
|
|
|
|
printf("%u", inode->i_faddr);
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
printf("%u", inode->i_file_acl);
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
printf("%u", inode->i_dir_acl);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
no_inode:
|
|
|
|
printf("%%I%c", ch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function expands '%dX' expressions
|
|
|
|
*/
|
|
|
|
static _INLINE_ void expand_dirent_expression(char ch,
|
|
|
|
struct problem_context *ctx)
|
|
|
|
{
|
|
|
|
struct ext2_dir_entry *dirent;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!ctx || !ctx->dirent)
|
|
|
|
goto no_dirent;
|
|
|
|
|
|
|
|
dirent = ctx->dirent;
|
|
|
|
|
|
|
|
switch (ch) {
|
|
|
|
case 'i':
|
|
|
|
printf("%u", dirent->inode);
|
|
|
|
break;
|
|
|
|
case 'n':
|
1998-03-09 16:10:37 +03:00
|
|
|
len = dirent->name_len & 0xFF;
|
1997-04-29 20:15:03 +04:00
|
|
|
if (len > EXT2_NAME_LEN)
|
|
|
|
len = EXT2_NAME_LEN;
|
|
|
|
if (len > dirent->rec_len)
|
|
|
|
len = dirent->rec_len;
|
1998-03-09 16:10:37 +03:00
|
|
|
printf("%.*s", len, dirent->name);
|
1997-04-29 20:15:03 +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 'r':
|
|
|
|
printf("%u", dirent->rec_len);
|
|
|
|
break;
|
|
|
|
case 'l':
|
1998-03-09 16:10:37 +03:00
|
|
|
printf("%u", dirent->name_len & 0xFF);
|
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;
|
1997-04-29 20:15:03 +04:00
|
|
|
default:
|
|
|
|
no_dirent:
|
|
|
|
printf("%%D%c", ch);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch,
|
|
|
|
struct problem_context *ctx)
|
|
|
|
{
|
|
|
|
if (!ctx)
|
|
|
|
goto no_context;
|
|
|
|
|
|
|
|
switch (ch) {
|
|
|
|
case '%':
|
|
|
|
fputc('%', stdout);
|
|
|
|
break;
|
|
|
|
case 'b':
|
|
|
|
printf("%u", ctx->blk);
|
|
|
|
break;
|
|
|
|
case 'B':
|
|
|
|
printf("%d", ctx->blkcount);
|
|
|
|
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 'c':
|
|
|
|
printf("%u", ctx->blk2);
|
|
|
|
break;
|
1997-04-29 20:15:03 +04:00
|
|
|
case 'd':
|
|
|
|
printf("%lu", ctx->dir);
|
|
|
|
break;
|
|
|
|
case 'g':
|
|
|
|
printf("%d", ctx->group);
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
printf("%lu", ctx->ino);
|
|
|
|
break;
|
|
|
|
case 'j':
|
|
|
|
printf("%lu", ctx->ino2);
|
|
|
|
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 'm':
|
|
|
|
printf("%s", error_message(ctx->errcode));
|
|
|
|
break;
|
1997-04-29 20:15:03 +04:00
|
|
|
case 'N':
|
|
|
|
printf("%u", ctx->num);
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
print_pathname(fs, ctx->ino, 0);
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
print_pathname(fs, ctx->ino2,
|
|
|
|
ctx->dirent ? ctx->dirent->inode : 0);
|
|
|
|
break;
|
|
|
|
case 'q':
|
|
|
|
print_pathname(fs, ctx->dir, 0);
|
|
|
|
break;
|
|
|
|
case 'Q':
|
|
|
|
print_pathname(fs, ctx->dir, ctx->ino);
|
|
|
|
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 'S':
|
|
|
|
printf("%d", get_backup_sb(fs));
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
printf("%s", ctx->str);
|
|
|
|
break;
|
1997-04-29 20:15:03 +04:00
|
|
|
default:
|
|
|
|
no_context:
|
|
|
|
printf("%%%c", ch);
|
|
|
|
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
|
|
|
void print_e2fsck_message(e2fsck_t ctx, const char *msg,
|
|
|
|
struct problem_context *pctx, int first)
|
1997-04-29 20:15:03 +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
|
|
|
ext2_filsys fs = ctx->fs;
|
1997-04-29 20:15:03 +04:00
|
|
|
const char * cp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (cp = msg; *cp; cp++) {
|
|
|
|
if (cp[0] == '@') {
|
|
|
|
cp++;
|
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
|
|
|
expand_at_expression(ctx, *cp, pctx, &first);
|
1997-04-29 20:15:03 +04:00
|
|
|
} else if (cp[0] == '%' && cp[1] == 'I') {
|
|
|
|
cp += 2;
|
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
|
|
|
expand_inode_expression(*cp, pctx);
|
1997-04-29 20:15:03 +04:00
|
|
|
} else if (cp[0] == '%' && cp[1] == 'D') {
|
|
|
|
cp += 2;
|
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
|
|
|
expand_dirent_expression(*cp, pctx);
|
1997-04-29 20:15:03 +04:00
|
|
|
} else if ((cp[0] == '%')) {
|
|
|
|
cp++;
|
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
|
|
|
expand_percent_expression(fs, *cp, pctx);
|
1997-04-29 20:15:03 +04:00
|
|
|
} else {
|
|
|
|
for (i=0; cp[i]; i++)
|
|
|
|
if ((cp[i] == '@') || cp[i] == '%')
|
|
|
|
break;
|
|
|
|
printf("%.*s", i, cp);
|
|
|
|
cp += i-1;
|
|
|
|
}
|
|
|
|
first = 0;
|
|
|
|
}
|
|
|
|
}
|