1997-04-26 21:21:57 +08:00
|
|
|
/*
|
|
|
|
* dumpe2fs.c - List the control structures of a second
|
|
|
|
* extended filesystem
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992, 1993, 1994 Remy Card <card@masi.ibp.fr>
|
|
|
|
* Laboratoire MASI, Institut Blaise Pascal
|
|
|
|
* Universite Pierre et Marie Curie (Paris VI)
|
|
|
|
*
|
1997-04-30 00:17:09 +08:00
|
|
|
* Copyright 1995, 1996, 1997 by Theodore Ts'o.
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
1997-04-26 21:21:57 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* History:
|
|
|
|
* 94/01/09 - Creation
|
|
|
|
* 94/02/27 - Ported to use the ext2fs library
|
|
|
|
*/
|
|
|
|
|
1997-04-26 22:00:26 +08:00
|
|
|
#ifdef HAVE_GETOPT_H
|
1997-04-26 21:21:57 +08:00
|
|
|
#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-04 00:22:35 +08:00
|
|
|
#else
|
|
|
|
extern char *optarg;
|
|
|
|
extern int optind;
|
1997-04-26 22:00:26 +08:00
|
|
|
#endif
|
1997-04-26 21:21:57 +08:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2image.c, findsuper.c, lsattr.c,
mke2fs.c, mklost+found.c, tune2fs.c, util.c: Change location of
ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, resize2fs.h:
resize2fs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, debugfs.h:
debugfs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, e2fsck.h, scantest.c:
e2fsck.h, scantest.c: Change location of ext2_fs.h to be
ext2fs/ext2_fs.h
ChangeLog, Makefile.in, tst_uuid.c, uuid_time.c:
tst_uuid.c, uuid_time.c: Remove unneeded #include of ext2_fs.h
ChangeLog, Makefile.in, e2p.h:
e2p.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, test_icount.c, test_rel.c:
test_icount.c, test_rel.c: Change location of ext2_fs.h to be
ext2fs/ext2_fs.h
2001-05-14 19:45:38 +08:00
|
|
|
#include "ext2fs/ext2_fs.h"
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
#include "ext2fs/ext2fs.h"
|
|
|
|
#include "e2p/e2p.h"
|
2001-01-16 15:47:31 +08:00
|
|
|
#include "jfs_user.h"
|
2001-12-17 12:23:37 +08:00
|
|
|
#include <uuid/uuid.h>
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
#include "../version.h"
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
#include "nls-enable.h"
|
1997-04-26 21:21:57 +08:00
|
|
|
|
1997-04-26 22:37:06 +08:00
|
|
|
#define in_use(m, x) (ext2fs_test_bit ((x), (m)))
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
const char * program_name = "dumpe2fs";
|
|
|
|
char * device_name = NULL;
|
2001-12-17 12:23:37 +08:00
|
|
|
const char *num_format = "%lu";
|
2001-12-22 12:59:46 +08:00
|
|
|
char range_format[16];
|
1997-04-26 21:21:57 +08:00
|
|
|
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
static void usage(void)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
2001-05-03 22:43:43 +08:00
|
|
|
fprintf (stderr, _("Usage: %s [-bfhixV] [-ob superblock] "
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
"[-oB blocksize] device\n"), program_name);
|
1997-04-26 21:21:57 +08:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_free (unsigned long group, char * bitmap,
|
|
|
|
unsigned long nbytes, unsigned long offset)
|
|
|
|
{
|
|
|
|
int p = 0;
|
|
|
|
unsigned long i;
|
|
|
|
unsigned long j;
|
|
|
|
|
2001-12-03 02:29:35 +08:00
|
|
|
offset += group * nbytes;
|
1997-04-26 21:21:57 +08:00
|
|
|
for (i = 0; i < nbytes; i++)
|
|
|
|
if (!in_use (bitmap, i))
|
|
|
|
{
|
|
|
|
if (p)
|
|
|
|
printf (", ");
|
2001-12-03 02:29:35 +08:00
|
|
|
printf (num_format, i + offset);
|
|
|
|
for (j = i; j < nbytes && !in_use (bitmap, j); j++)
|
|
|
|
;
|
|
|
|
if (--j != i) {
|
|
|
|
fputc('-', stdout);
|
|
|
|
printf(num_format, j + offset);
|
|
|
|
i = j;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
p = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void list_desc (ext2_filsys fs)
|
|
|
|
{
|
|
|
|
unsigned long i;
|
2001-12-03 02:29:35 +08:00
|
|
|
long diff;
|
1997-04-30 01:48:10 +08:00
|
|
|
blk_t group_blk, next_blk;
|
1997-04-26 21:34:30 +08:00
|
|
|
char * block_bitmap = fs->block_map->bitmap;
|
|
|
|
char * inode_bitmap = fs->inode_map->bitmap;
|
2000-08-14 23:32:11 +08:00
|
|
|
int inode_blocks_per_group;
|
|
|
|
int group_desc_blocks;
|
2002-10-20 12:38:57 +08:00
|
|
|
int meta_bg, meta_bg_size, has_super;
|
2000-08-14 23:32:11 +08:00
|
|
|
|
|
|
|
inode_blocks_per_group = ((fs->super->s_inodes_per_group *
|
|
|
|
EXT2_INODE_SIZE(fs->super)) +
|
|
|
|
EXT2_BLOCK_SIZE(fs->super) - 1) /
|
|
|
|
EXT2_BLOCK_SIZE(fs->super);
|
|
|
|
group_desc_blocks = ((fs->super->s_blocks_count -
|
|
|
|
fs->super->s_first_data_block +
|
|
|
|
EXT2_BLOCKS_PER_GROUP(fs->super) - 1) /
|
|
|
|
EXT2_BLOCKS_PER_GROUP(fs->super) +
|
|
|
|
EXT2_DESC_PER_BLOCK(fs->super) - 1) /
|
|
|
|
EXT2_DESC_PER_BLOCK(fs->super);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
2001-12-03 02:29:35 +08:00
|
|
|
fputc('\n', stdout);
|
1997-04-30 01:48:10 +08:00
|
|
|
group_blk = fs->super->s_first_data_block;
|
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
|
|
|
next_blk = group_blk + fs->super->s_blocks_per_group;
|
|
|
|
if (next_blk > fs->super->s_blocks_count)
|
|
|
|
next_blk = fs->super->s_blocks_count;
|
2001-12-03 02:29:35 +08:00
|
|
|
printf (_("Group %lu: (Blocks "), i);
|
2001-12-22 12:59:46 +08:00
|
|
|
printf(range_format, group_blk, next_blk - 1);
|
2001-12-03 02:29:35 +08:00
|
|
|
fputs(")\n", stdout);
|
2002-10-20 12:38:57 +08:00
|
|
|
has_super = ext2fs_bg_has_super(fs, i);
|
|
|
|
if (has_super) {
|
|
|
|
printf (_(" %s superblock at "),
|
2001-12-03 02:29:35 +08:00
|
|
|
i == 0 ? _("Primary") : _("Backup"));
|
|
|
|
printf(num_format, group_blk);
|
2002-10-20 12:38:57 +08:00
|
|
|
}
|
|
|
|
meta_bg_size = (fs->blocksize /
|
|
|
|
sizeof (struct ext2_group_desc));
|
|
|
|
meta_bg = i / meta_bg_size;
|
|
|
|
if (!(fs->super->s_feature_incompat &
|
|
|
|
EXT2_FEATURE_INCOMPAT_META_BG) ||
|
|
|
|
(meta_bg < fs->super->s_first_meta_bg)) {
|
|
|
|
fputc(has_super ? ',' : ' ', stdout);
|
|
|
|
printf(_(" Group descriptors at "));
|
2001-12-22 12:59:46 +08:00
|
|
|
printf(range_format, group_blk+1,
|
|
|
|
group_blk + group_desc_blocks);
|
2001-12-03 02:29:35 +08:00
|
|
|
fputc('\n', stdout);
|
2002-10-20 12:38:57 +08:00
|
|
|
} else {
|
|
|
|
if (has_super)
|
|
|
|
has_super = 1;
|
|
|
|
if (((i % meta_bg_size) == 0) ||
|
|
|
|
((i % meta_bg_size) == 1) ||
|
|
|
|
((i % meta_bg_size) == (meta_bg_size-1))) {
|
|
|
|
fputc(has_super ? ',' : ' ', stdout);
|
|
|
|
printf(_(" Group descriptor at "));
|
|
|
|
printf(num_format, group_blk + has_super);
|
|
|
|
fputc('\n', stdout);
|
|
|
|
} else if (has_super)
|
|
|
|
fputc('\n', stdout);
|
2001-12-03 02:29:35 +08:00
|
|
|
}
|
|
|
|
fputs(_(" Block bitmap at "), stdout);
|
|
|
|
printf(num_format, fs->group_desc[i].bg_block_bitmap);
|
|
|
|
diff = fs->group_desc[i].bg_block_bitmap - group_blk;
|
|
|
|
if (diff >= 0)
|
2001-12-17 12:23:37 +08:00
|
|
|
printf(" (+%ld)", diff);
|
2001-12-03 02:29:35 +08:00
|
|
|
fputs(_(", Inode bitmap at "), stdout);
|
|
|
|
printf(num_format, fs->group_desc[i].bg_inode_bitmap);
|
|
|
|
diff = fs->group_desc[i].bg_inode_bitmap - group_blk;
|
|
|
|
if (diff >= 0)
|
2001-12-17 12:23:37 +08:00
|
|
|
printf(" (+%ld)", diff);
|
2001-12-03 02:29:35 +08:00
|
|
|
fputs(_("\n Inode table at "), stdout);
|
2001-12-22 12:59:46 +08:00
|
|
|
printf(range_format, fs->group_desc[i].bg_inode_table,
|
|
|
|
fs->group_desc[i].bg_inode_table +
|
2001-12-03 02:29:35 +08:00
|
|
|
inode_blocks_per_group - 1);
|
|
|
|
diff = fs->group_desc[i].bg_inode_table - group_blk;
|
|
|
|
if (diff > 0)
|
2001-12-17 12:23:37 +08:00
|
|
|
printf(" (+%ld)", diff);
|
2001-12-03 02:29:35 +08:00
|
|
|
printf (_("\n %d free blocks, %d free inodes, "
|
|
|
|
"%d directories\n Free blocks: "),
|
1997-04-26 21:21:57 +08:00
|
|
|
fs->group_desc[i].bg_free_blocks_count,
|
|
|
|
fs->group_desc[i].bg_free_inodes_count,
|
|
|
|
fs->group_desc[i].bg_used_dirs_count);
|
|
|
|
print_free (i, block_bitmap, fs->super->s_blocks_per_group,
|
|
|
|
fs->super->s_first_data_block);
|
2001-12-03 02:29:35 +08:00
|
|
|
fputs(_("\n Free inodes: "), stdout);
|
1997-04-26 21:21:57 +08:00
|
|
|
print_free (i, inode_bitmap, fs->super->s_inodes_per_group, 1);
|
2001-12-03 02:29:35 +08:00
|
|
|
fputc('\n', stdout);
|
|
|
|
block_bitmap += fs->super->s_blocks_per_group / 8;
|
1997-04-26 21:21:57 +08:00
|
|
|
inode_bitmap += fs->super->s_inodes_per_group / 8;
|
1997-04-30 01:48:10 +08:00
|
|
|
group_blk = next_blk;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-22 12:59:46 +08:00
|
|
|
static void list_bad_blocks(ext2_filsys fs, int dump)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
|
|
|
badblocks_list bb_list = 0;
|
|
|
|
badblocks_iterate bb_iter;
|
|
|
|
blk_t blk;
|
|
|
|
errcode_t retval;
|
2001-12-22 12:59:46 +08:00
|
|
|
const char *header, *fmt;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
retval = ext2fs_read_bb_inode(fs, &bb_list);
|
|
|
|
if (retval) {
|
|
|
|
com_err("ext2fs_read_bb_inode", retval, "");
|
2001-12-22 12:59:46 +08:00
|
|
|
return;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
ChangeLog, dumpe2fs.c, mke2fs.c:
dumpe2fs.c: Use WORDS_BIGENDIAN to determine whether or not we're
(not) using i386 byte order.
dumpe2fs.c, mke2fs.c: Stop using the compatibility badblocks function,
and use the ext2fs_badblocks_* functions instead.
ChangeLog, inode.c, tst_iscan.c:
inode.c, tst_iscan.c: Stop using the compatibility badblocks function,
and use the ext2fs_badblocks_* functions instead.
ChangeLog, badblocks.c:
badblocks.c: Stop using the compatibility badblocks function, and use
the ext2fs_badblocks_* functions instead.
2001-06-13 08:12:04 +08:00
|
|
|
retval = ext2fs_badblocks_list_iterate_begin(bb_list, &bb_iter);
|
1997-04-26 21:21:57 +08:00
|
|
|
if (retval) {
|
ChangeLog, dumpe2fs.c, mke2fs.c:
dumpe2fs.c: Use WORDS_BIGENDIAN to determine whether or not we're
(not) using i386 byte order.
dumpe2fs.c, mke2fs.c: Stop using the compatibility badblocks function,
and use the ext2fs_badblocks_* functions instead.
ChangeLog, inode.c, tst_iscan.c:
inode.c, tst_iscan.c: Stop using the compatibility badblocks function,
and use the ext2fs_badblocks_* functions instead.
ChangeLog, badblocks.c:
badblocks.c: Stop using the compatibility badblocks function, and use
the ext2fs_badblocks_* functions instead.
2001-06-13 08:12:04 +08:00
|
|
|
com_err("ext2fs_badblocks_list_iterate_begin", retval,
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
_("while printing bad block list"));
|
2001-12-22 12:59:46 +08:00
|
|
|
return;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2001-12-22 12:59:46 +08:00
|
|
|
if (dump) {
|
|
|
|
header = fmt = "%d\n";
|
|
|
|
} else {
|
|
|
|
header = _("Bad blocks: %d");
|
|
|
|
fmt = ", %d";
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
2001-12-22 12:59:46 +08:00
|
|
|
while (ext2fs_badblocks_list_iterate(bb_iter, &blk)) {
|
|
|
|
printf(header ? header : fmt, blk);
|
|
|
|
header = 0;
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
ChangeLog, dumpe2fs.c, mke2fs.c:
dumpe2fs.c: Use WORDS_BIGENDIAN to determine whether or not we're
(not) using i386 byte order.
dumpe2fs.c, mke2fs.c: Stop using the compatibility badblocks function,
and use the ext2fs_badblocks_* functions instead.
ChangeLog, inode.c, tst_iscan.c:
inode.c, tst_iscan.c: Stop using the compatibility badblocks function,
and use the ext2fs_badblocks_* functions instead.
ChangeLog, badblocks.c:
badblocks.c: Stop using the compatibility badblocks function, and use
the ext2fs_badblocks_* functions instead.
2001-06-13 08:12:04 +08:00
|
|
|
ext2fs_badblocks_list_iterate_end(bb_iter);
|
2001-12-22 12:59:46 +08:00
|
|
|
if (!dump)
|
|
|
|
fputc('\n', stdout);
|
1997-04-29 22:53:37 +08:00
|
|
|
}
|
1997-04-26 21:34:30 +08:00
|
|
|
|
2001-01-16 15:47:31 +08:00
|
|
|
static void print_journal_information(ext2_filsys fs)
|
|
|
|
{
|
|
|
|
errcode_t retval;
|
|
|
|
char buf[1024];
|
|
|
|
char str[80];
|
|
|
|
int i;
|
|
|
|
journal_superblock_t *jsb;
|
|
|
|
|
|
|
|
/* Get the journal superblock */
|
2001-01-18 09:44:19 +08:00
|
|
|
if ((retval = io_channel_read_blk(fs->io, fs->super->s_first_data_block+1, -1024, buf))) {
|
2001-01-16 15:47:31 +08:00
|
|
|
com_err(program_name, retval,
|
|
|
|
_("while reading journal superblock"));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
jsb = (journal_superblock_t *) buf;
|
|
|
|
if ((jsb->s_header.h_magic != (unsigned) ntohl(JFS_MAGIC_NUMBER)) ||
|
|
|
|
(jsb->s_header.h_blocktype !=
|
|
|
|
(unsigned) ntohl(JFS_SUPERBLOCK_V2))) {
|
|
|
|
com_err(program_name, 0,
|
|
|
|
_("Couldn't find journal superblock magic numbers"));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2001-12-03 02:29:35 +08:00
|
|
|
printf(_("\nJournal block size: %d\n"
|
|
|
|
"Journal length: %d\n"
|
|
|
|
"Journal first block: %d\n"
|
|
|
|
"Journal sequence: 0x%08x\n"
|
|
|
|
"Journal start: %d\n"
|
|
|
|
"Journal number of users: %d\n"),
|
|
|
|
ntohl(jsb->s_blocksize), ntohl(jsb->s_maxlen),
|
|
|
|
ntohl(jsb->s_first), ntohl(jsb->s_sequence),
|
|
|
|
ntohl(jsb->s_start), ntohl(jsb->s_nr_users));
|
|
|
|
|
2001-01-16 15:47:31 +08:00
|
|
|
for (i=0; i < ntohl(jsb->s_nr_users); i++) {
|
|
|
|
uuid_unparse(&jsb->s_users[i*16], str);
|
2001-12-03 02:29:35 +08:00
|
|
|
printf(i ? " %s\n"
|
|
|
|
: "Journal users: %s\n",
|
|
|
|
str);
|
2001-01-16 15:47:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-09-16 10:13:52 +08:00
|
|
|
int main (int argc, char ** argv)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
|
|
|
errcode_t retval;
|
|
|
|
ext2_filsys fs;
|
1997-04-26 21:34:30 +08:00
|
|
|
int print_badblocks = 0;
|
1999-06-18 08:48:41 +08:00
|
|
|
int use_superblock = 0;
|
|
|
|
int use_blocksize = 0;
|
2001-05-03 22:43:43 +08:00
|
|
|
int image_dump = 0;
|
1999-09-15 04:11:19 +08:00
|
|
|
int force = 0;
|
2001-01-16 15:47:31 +08:00
|
|
|
int flags;
|
1999-09-15 04:11:19 +08:00
|
|
|
int header_only = 0;
|
1997-04-29 22:53:37 +08:00
|
|
|
int big_endian;
|
1997-10-25 11:49:49 +08:00
|
|
|
int c;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
setlocale(LC_MESSAGES, "");
|
2002-03-05 16:26:52 +08:00
|
|
|
setlocale(LC_CTYPE, "");
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
|
|
|
|
textdomain(NLS_CAT_NAME);
|
|
|
|
#endif
|
1997-04-29 23:29:49 +08:00
|
|
|
initialize_ext2_error_table();
|
2001-08-28 00:44:23 +08:00
|
|
|
fprintf (stderr, "dumpe2fs %s (%s)\n", E2FSPROGS_VERSION,
|
|
|
|
E2FSPROGS_DATE);
|
1997-04-26 21:21:57 +08:00
|
|
|
if (argc && *argv)
|
|
|
|
program_name = *argv;
|
1997-04-26 21:34:30 +08:00
|
|
|
|
2001-05-03 22:43:43 +08:00
|
|
|
while ((c = getopt (argc, argv, "bfhixVo:")) != EOF) {
|
1997-04-26 21:34:30 +08:00
|
|
|
switch (c) {
|
|
|
|
case 'b':
|
|
|
|
print_badblocks++;
|
|
|
|
break;
|
1999-09-15 04:11:19 +08:00
|
|
|
case 'f':
|
|
|
|
force++;
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
header_only++;
|
|
|
|
break;
|
2001-05-03 22:43:43 +08:00
|
|
|
case 'i':
|
|
|
|
image_dump++;
|
|
|
|
break;
|
1999-06-18 08:48:41 +08:00
|
|
|
case 'o':
|
|
|
|
if (optarg[0] == 'b')
|
|
|
|
use_superblock = atoi(optarg+1);
|
|
|
|
else if (optarg[0] == 'B')
|
|
|
|
use_blocksize = atoi(optarg+1);
|
|
|
|
else
|
|
|
|
usage();
|
|
|
|
break;
|
1997-04-29 23:29:49 +08:00
|
|
|
case 'V':
|
|
|
|
/* Print version number and exit */
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
fprintf(stderr, _("\tUsing %s\n"),
|
1997-04-29 23:29:49 +08:00
|
|
|
error_message(EXT2_ET_BASE));
|
|
|
|
exit(0);
|
2000-08-14 23:32:11 +08:00
|
|
|
case 'x':
|
2001-12-03 02:29:35 +08:00
|
|
|
num_format = "0x%04x";
|
2000-08-14 23:32:11 +08:00
|
|
|
break;
|
1997-04-26 21:34:30 +08:00
|
|
|
default:
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
usage();
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (optind > argc - 1)
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 13:11:14 +08:00
|
|
|
usage();
|
2001-12-22 12:59:46 +08:00
|
|
|
sprintf(range_format, "%s-%s", num_format, num_format);
|
1997-04-26 21:34:30 +08:00
|
|
|
device_name = argv[optind++];
|
1999-06-18 08:48:41 +08:00
|
|
|
if (use_superblock && !use_blocksize)
|
|
|
|
use_blocksize = 1024;
|
2001-01-16 15:47:31 +08:00
|
|
|
flags = EXT2_FLAG_JOURNAL_DEV_OK;
|
|
|
|
if (force)
|
|
|
|
flags |= EXT2_FLAG_FORCE;
|
2001-05-03 22:43:43 +08:00
|
|
|
if (image_dump)
|
|
|
|
flags |= EXT2_FLAG_IMAGE_FILE;
|
|
|
|
|
2001-01-16 15:47:31 +08:00
|
|
|
retval = ext2fs_open (device_name, flags, use_superblock,
|
|
|
|
use_blocksize, unix_io_manager, &fs);
|
1997-04-26 21:34:30 +08:00
|
|
|
if (retval) {
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
com_err (program_name, retval, _("while trying to open %s"),
|
1997-04-26 21:21:57 +08:00
|
|
|
device_name);
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
printf (_("Couldn't find valid filesystem superblock.\n"));
|
1997-04-26 21:21:57 +08:00
|
|
|
exit (1);
|
|
|
|
}
|
1997-04-26 21:34:30 +08:00
|
|
|
if (print_badblocks) {
|
2001-12-22 12:59:46 +08:00
|
|
|
list_bad_blocks(fs, 1);
|
1997-04-26 21:34:30 +08:00
|
|
|
} else {
|
1999-09-15 04:11:19 +08:00
|
|
|
big_endian = ((fs->flags & EXT2_FLAG_SWAP_BYTES) != 0);
|
ChangeLog, dumpe2fs.c, mke2fs.c:
dumpe2fs.c: Use WORDS_BIGENDIAN to determine whether or not we're
(not) using i386 byte order.
dumpe2fs.c, mke2fs.c: Stop using the compatibility badblocks function,
and use the ext2fs_badblocks_* functions instead.
ChangeLog, inode.c, tst_iscan.c:
inode.c, tst_iscan.c: Stop using the compatibility badblocks function,
and use the ext2fs_badblocks_* functions instead.
ChangeLog, badblocks.c:
badblocks.c: Stop using the compatibility badblocks function, and use
the ext2fs_badblocks_* functions instead.
2001-06-13 08:12:04 +08:00
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
big_endian = !big_endian;
|
|
|
|
#endif
|
1999-09-15 04:11:19 +08:00
|
|
|
if (big_endian)
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
printf(_("Note: This is a byte-swapped filesystem\n"));
|
1999-09-15 04:11:19 +08:00
|
|
|
list_super (fs->super);
|
2001-01-16 15:47:31 +08:00
|
|
|
if (fs->super->s_feature_incompat &
|
|
|
|
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
|
|
|
|
print_journal_information(fs);
|
|
|
|
ext2fs_close(fs);
|
|
|
|
exit(0);
|
|
|
|
}
|
2001-12-22 12:59:46 +08:00
|
|
|
list_bad_blocks(fs, 0);
|
1999-09-15 04:11:19 +08:00
|
|
|
if (header_only) {
|
|
|
|
ext2fs_close (fs);
|
|
|
|
exit (0);
|
|
|
|
}
|
1997-04-26 21:34:30 +08:00
|
|
|
retval = ext2fs_read_bitmaps (fs);
|
|
|
|
if (retval) {
|
|
|
|
com_err (program_name, retval,
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c, fsck.c,
get_device_by_label.c, lsattr.c, mke2fs.c, mklost+found.c,
nls-enable.h, partinfo.c, tune2fs.c, uuidgen.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-08 08:47:55 +08:00
|
|
|
_("while trying to read the bitmaps"),
|
1997-04-26 21:34:30 +08:00
|
|
|
device_name);
|
|
|
|
ext2fs_close (fs);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
list_desc (fs);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
ext2fs_close (fs);
|
|
|
|
exit (0);
|
|
|
|
}
|