Imported reiserfsprogs-3.6.13
This commit is contained in:
1 parent
cccefa4d84
commit
18057cdad6
78 files changed
+1697
-2226
No files matched your search
+1
-1
@@ -7,5 +7,5 @@ ufile.c check_tree.c info.c super.c fsck.h
|
||||
man_MANS = reiserfsck.8
|
||||
EXTRA_DIST = $(man_MANS)
|
||||
|
||||
LDADD = $(LDFLAGS) $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
|
||||
reiserfsck_LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
|
||||
|
||||
+2
-2
@@ -77,6 +77,7 @@ RANLIB = @RANLIB@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
UUID_LIBS = @UUID_LIBS@
|
||||
VERSION = @VERSION@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_RANLIB = @ac_ct_RANLIB@
|
||||
@@ -114,7 +115,7 @@ ufile.c check_tree.c info.c super.c fsck.h
|
||||
man_MANS = reiserfsck.8
|
||||
EXTRA_DIST = $(man_MANS)
|
||||
|
||||
LDADD = $(LDFLAGS) $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
|
||||
reiserfsck_LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
|
||||
subdir = fsck
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/include/config.h
|
||||
@@ -129,7 +130,6 @@ am_reiserfsck_OBJECTS = main.$(OBJEXT) pass0.$(OBJEXT) pass1.$(OBJEXT) \
|
||||
ufile.$(OBJEXT) check_tree.$(OBJEXT) info.$(OBJEXT) \
|
||||
super.$(OBJEXT)
|
||||
reiserfsck_OBJECTS = $(am_reiserfsck_OBJECTS)
|
||||
reiserfsck_LDADD = $(LDADD)
|
||||
reiserfsck_DEPENDENCIES = $(top_srcdir)/lib/libmisc.a \
|
||||
$(top_srcdir)/reiserfscore/libcore.a
|
||||
reiserfsck_LDFLAGS =
|
||||
|
||||
+221
-170
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1999-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
@@ -141,17 +141,19 @@ static void init_control_bitmap (reiserfs_filsys_t * fs)
|
||||
unsigned long reserved;
|
||||
|
||||
|
||||
control_bitmap = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
|
||||
control_bitmap = reiserfs_create_bitmap(get_sb_block_count(fs->fs_ondisk_sb));
|
||||
if (!control_bitmap)
|
||||
die ("init_control_bitmap: Failed to allocate a control bitmap.");
|
||||
|
||||
/*printf ("Initially number of zeros in control bitmap %d\n", reiserfs_bitmap_zeros (control_bitmap));*/
|
||||
/*printf ("Initially number of zeros in control bitmap %d\n",
|
||||
reiserfs_bitmap_zeros (control_bitmap));*/
|
||||
|
||||
/* skipped and super block */
|
||||
for (i = 0; i <= fs->fs_super_bh->b_blocknr; i ++)
|
||||
we_met_it (i);
|
||||
|
||||
/*printf ("SKIPPED: %d blocks marked used (%d)\n", hits, reiserfs_bitmap_zeros (control_bitmap));
|
||||
/*printf ("SKIPPED: %d blocks marked used (%d)\n", hits,
|
||||
reiserfs_bitmap_zeros (control_bitmap));
|
||||
hits = 0;*/
|
||||
|
||||
/* bitmaps */
|
||||
@@ -160,11 +162,15 @@ static void init_control_bitmap (reiserfs_filsys_t * fs)
|
||||
we_met_it (block);
|
||||
|
||||
if (spread_bitmaps (fs))
|
||||
block = (block / (fs->fs_blocksize * 8) + 1) * (fs->fs_blocksize * 8);
|
||||
block = (block / (fs->fs_blocksize * 8) + 1) *
|
||||
(fs->fs_blocksize * 8);
|
||||
else
|
||||
block ++;
|
||||
}
|
||||
/*printf ("BITMAPS: %d blocks marked used (%d)\n", hits, reiserfs_bitmap_zeros (control_bitmap));
|
||||
|
||||
/*printf ("BITMAPS: %d blocks marked used (%d)\n", hits,
|
||||
reiserfs_bitmap_zeros (control_bitmap));
|
||||
|
||||
hits = 0;*/
|
||||
|
||||
/* mark as used area of the main device either containing a journal or
|
||||
@@ -176,7 +182,8 @@ static void init_control_bitmap (reiserfs_filsys_t * fs)
|
||||
|
||||
if (!is_new_sb_location (fs->fs_super_bh->b_blocknr, fs->fs_blocksize) &&
|
||||
!is_old_sb_location (fs->fs_super_bh->b_blocknr, fs->fs_blocksize))
|
||||
die ("init_control_bitmap: Wrong super block location. You must run --rebuild-sb.");
|
||||
die ("init_control_bitmap: Wrong super block location. You must run "
|
||||
"--rebuild-sb.");
|
||||
|
||||
block = get_journal_start_must (fs);
|
||||
|
||||
@@ -199,16 +206,20 @@ static void handle_bitmaps (reiserfs_filsys_t * fs)
|
||||
int problem = 0;
|
||||
|
||||
if (tree_scanning_failed) {
|
||||
fsck_progress ("Could not scan the internal tree. --rebuild-tree is required\n");
|
||||
fsck_progress ("Could not scan the internal tree. --rebuild-tree "
|
||||
"is required\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fsck_progress ("Comparing bitmaps..");
|
||||
|
||||
/* check free block counter */
|
||||
if (get_sb_free_blocks (fs->fs_ondisk_sb) != reiserfs_bitmap_zeros (control_bitmap)) {
|
||||
/* fsck_log ("vpf-10630: The count of free blocks in the on-disk bitmap (%lu) mismatches "
|
||||
"with the correct one (%lu).\n", get_sb_free_blocks (fs->fs_ondisk_sb),
|
||||
if (get_sb_free_blocks (fs->fs_ondisk_sb) !=
|
||||
reiserfs_bitmap_zeros (control_bitmap))
|
||||
{
|
||||
/* fsck_log ("vpf-10630: The count of free blocks in the on-disk bitmap "
|
||||
"(%lu) mismatches with the correct one (%lu).\n",
|
||||
get_sb_free_blocks (fs->fs_ondisk_sb),
|
||||
reiserfs_bitmap_zeros (control_bitmap));
|
||||
*/
|
||||
problem++;
|
||||
@@ -222,28 +233,34 @@ static void handle_bitmaps (reiserfs_filsys_t * fs)
|
||||
fsck_log ("vpf-10630: The on-disk and the correct bitmaps differs. "
|
||||
"Will be fixed later.\n");
|
||||
// fsck_progress ("Trying to fix bitmap ..\n");
|
||||
/* mark blocks as used in source bitmap if they are used in control bitmap */
|
||||
/* mark blocks as used in source bitmap if they are used in
|
||||
control bitmap */
|
||||
reiserfs_bitmap_disjunction (source_bitmap, control_bitmap);
|
||||
/* change used blocks count accordinly source bitmap,
|
||||
copy bitmap changes to on_disk bitmap */
|
||||
set_sb_free_blocks (fs->fs_ondisk_sb, reiserfs_bitmap_zeros (source_bitmap));
|
||||
/* change used blocks count accordinly source bitmap, copy bitmap
|
||||
changes to on_disk bitmap */
|
||||
set_sb_free_blocks (fs->fs_ondisk_sb,
|
||||
reiserfs_bitmap_zeros(source_bitmap));
|
||||
reiserfs_bitmap_copy (fs->fs_bitmap2, source_bitmap);
|
||||
mark_buffer_dirty (fs->fs_super_bh);
|
||||
/*
|
||||
// check again
|
||||
if ((diff = reiserfs_bitmap_compare (source_bitmap, control_bitmap)) != 0) {
|
||||
// do not mark them as fatal or fixable because one can live with leaked space.
|
||||
// So this is not a fatal corruption, and fix-fixable cannot fix it
|
||||
fsck_progress (" bitmaps were not recovered. \n"
|
||||
"\tYou can either run rebuild-tree or live with %d leaked blocks\n", diff);
|
||||
if ((diff = reiserfs_bitmap_compare(source_bitmap,
|
||||
control_bitmap)) != 0)
|
||||
{
|
||||
// do not mark them as fatal or fixable because one can live
|
||||
// with leaked space. So this is not a fatal corruption, and
|
||||
// fix-fixable cannot fix it
|
||||
fsck_progress (" bitmaps were not recovered.\n\tYou can either "
|
||||
"run rebuild-tree or live with %d leaked blocks\n", diff);
|
||||
} else {
|
||||
fsck_progress ("finished\n");
|
||||
}
|
||||
*/
|
||||
} else if (problem) {
|
||||
fsck_log ("vpf-10640: The on-disk and the correct bitmaps differs.\n");
|
||||
fsck_log ("vpf-10640: The on-disk and the correct bitmaps differs.\n");
|
||||
while (problem) {
|
||||
/* fixable corruptions because we can try to recover them without rebuilding the tree */
|
||||
/* fixable corruptions because we can try to recover them
|
||||
without rebuilding the tree */
|
||||
one_more_corruption (fs, FIXABLE);
|
||||
problem --;
|
||||
}
|
||||
@@ -312,7 +329,9 @@ static int got_already (reiserfs_filsys_t * fs, unsigned long block)
|
||||
}
|
||||
|
||||
/* 1 if it does not look like reasonable stat data */
|
||||
static int bad_stat_data (reiserfs_filsys_t * fs, struct buffer_head * bh, struct item_head * ih)
|
||||
static int bad_stat_data (reiserfs_filsys_t * fs,
|
||||
struct buffer_head * bh,
|
||||
struct item_head * ih)
|
||||
{
|
||||
unsigned long objectid;
|
||||
// __u32 links;
|
||||
@@ -320,9 +339,9 @@ static int bad_stat_data (reiserfs_filsys_t * fs, struct buffer_head * bh, struc
|
||||
objectid = get_key_objectid (&ih->ih_key);
|
||||
if (!is_objectid_used (fs, objectid)) {
|
||||
/* FIXME: this could be cured right here */
|
||||
fsck_log ("bad_stat_data: The objectid (%lu) is marked free, but used by an object %k\n",
|
||||
objectid, &ih->ih_key);
|
||||
|
||||
fsck_log ("bad_stat_data: The objectid (%lu) is marked free, but used "
|
||||
"by an object %k\n", objectid, &ih->ih_key);
|
||||
|
||||
/* if it is FIX_FIXABLE we flush objectid map at the end
|
||||
no way to call one_less_corruption later
|
||||
*/
|
||||
@@ -331,7 +350,9 @@ static int bad_stat_data (reiserfs_filsys_t * fs, struct buffer_head * bh, struc
|
||||
}
|
||||
|
||||
if (id_map_mark(proper_id_map (fs), objectid)) {
|
||||
fsck_log ("bad_stat_data: The objectid (%lu) is shared by at least two files\n", objectid);
|
||||
fsck_log ("bad_stat_data: The objectid (%lu) is shared by at least two "
|
||||
"files\n", objectid);
|
||||
|
||||
if (fsck_mode (fs) == FSCK_FIX_FIXABLE)
|
||||
to_be_relocated (&ih->ih_key);
|
||||
|
||||
@@ -361,13 +382,18 @@ static int bad_stat_data (reiserfs_filsys_t * fs, struct buffer_head * bh, struc
|
||||
|
||||
|
||||
/* it looks like we can check item length only */
|
||||
static int bad_direct_item (reiserfs_filsys_t * fs, struct buffer_head * bh, struct item_head * ih)
|
||||
static int bad_direct_item (reiserfs_filsys_t * fs,
|
||||
struct buffer_head * bh,
|
||||
struct item_head * ih)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
inline void handle_one_pointer (reiserfs_filsys_t * fs, struct buffer_head * bh, __u32 * ptr) {
|
||||
inline void handle_one_pointer (reiserfs_filsys_t * fs,
|
||||
struct buffer_head * bh,
|
||||
__u32 * ptr)
|
||||
{
|
||||
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
|
||||
fsck_log (" - zeroed");
|
||||
*ptr = 0;
|
||||
@@ -377,31 +403,38 @@ inline void handle_one_pointer (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
static int bad_badblocks_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
struct item_head * ih) {
|
||||
int i;
|
||||
__u32 i;
|
||||
__u32 * ind = (__u32 *)B_I_PITEM (bh, ih);
|
||||
|
||||
if (get_ih_item_len (ih) % 4) {
|
||||
fsck_log ("%s: block %lu: item (%H) has bad length\n", __FUNCTION__,
|
||||
bh->b_blocknr, ih);
|
||||
one_more_corruption (fs, fatal);
|
||||
one_more_corruption (fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* All valid badblocks are given in badblock bitmap. Nothing to check anymore. */
|
||||
if (fs->fs_badblocks_bm)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < I_UNFM_NUM (ih); i ++) {
|
||||
// __u32 unfm_ptr;
|
||||
|
||||
// unfm_ptr = le32_to_cpu (ind [i]);
|
||||
if (!le32_to_cpu (ind [i])) {
|
||||
fsck_log ("%s: block %lu: badblocks item (%H) has zero pointer.");
|
||||
fsck_log ("Not an error, but could be deleted with --fix-fixable\n",
|
||||
__FUNCTION__, bh->b_blocknr, ih);
|
||||
/* fsck_log ("%s: block %lu: badblocks item (%H) has zero pointer.",
|
||||
__FUNCTION__, bh->b_blocknr, ih);
|
||||
|
||||
if (fsck_mode(fs) != FSCK_FIX_FIXABLE) {
|
||||
fsck_log("Not an error, but could be deleted with --fix-fixable\n");
|
||||
} else {
|
||||
fsck_log("Will be deleted later.\n");
|
||||
}*/
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// check list of badblocks pointers
|
||||
/* check list of badblocks pointers */
|
||||
if (le32_to_cpu (ind [i]) >= get_sb_block_count (fs->fs_ondisk_sb)) {
|
||||
fsck_log ("%s: badblock pointer (block %lu) points out of disk spase (%lu)",
|
||||
__FUNCTION__, bh->b_blocknr, le32_to_cpu (ind [i]));
|
||||
@@ -410,32 +443,34 @@ static int bad_badblocks_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
}
|
||||
|
||||
if (did_we_meet_it (le32_to_cpu (ind [i]))) {
|
||||
// it can be
|
||||
// 1. not_data_block
|
||||
// delete pointer
|
||||
// 2. ind [i] or internal/leaf
|
||||
// advice to run fix-fixable if there is no fatal errors
|
||||
// with list of badblocks, say that it could fix it.
|
||||
/* it can be
|
||||
1. not_data_block
|
||||
delete pointer
|
||||
2. ind [i] or internal/leaf
|
||||
advice to run fix-fixable if there is no fatal errors
|
||||
with list of badblocks, say that it could fix it. */
|
||||
|
||||
if (not_data_block (fs, le32_to_cpu (ind [i]))) {
|
||||
fsck_log ("%s: badblock pointer (block %lu) points on fs metadata (%lu)",
|
||||
__FUNCTION__, bh->b_blocknr, le32_to_cpu (ind [i]));
|
||||
__FUNCTION__, bh->b_blocknr, le32_to_cpu (ind [i]));
|
||||
handle_one_pointer (fs, bh, &ind[i]);
|
||||
fsck_log ("\n");
|
||||
} else {
|
||||
one_more_corruption (fs, badblocks);
|
||||
fsck_log ("%s: badblock item points to a block"
|
||||
" which in the tree already. Use --badblock-file option"
|
||||
" to fix the problem\n", __FUNCTION__);
|
||||
one_more_corruption(fs, FIXABLE);
|
||||
fsck_log ("%s: badblock pointer (block %lu) points to a block (%lu) "
|
||||
"which is in the tree already. Use badblock option (-B) to"
|
||||
" fix the problem\n", __FUNCTION__, bh->b_blocknr,
|
||||
le32_to_cpu(ind[i]));
|
||||
}
|
||||
} else {
|
||||
we_met_it (le32_to_cpu (ind [i]));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
we_met_it(le32_to_cpu(ind[i]));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
/* for each unformatted node pointer: make sure it points to data area and
|
||||
that it is not in the tree yet */
|
||||
@@ -465,16 +500,20 @@ static int bad_indirect_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
/* check unformatted node pointer and mark it used in the
|
||||
control bitmap */
|
||||
if (bad_block_number (fs, le32_to_cpu (ind [i]))) {
|
||||
fsck_log ("%s: block %lu: The item %k has the bad pointer (%d) to the block (%lu)",
|
||||
__FUNCTION__, bh->b_blocknr, &ih->ih_key, i, le32_to_cpu (ind [i]));
|
||||
fsck_log ("%s: block %lu: The item %k has the bad pointer (%d) to "
|
||||
"the block (%lu)", __FUNCTION__, bh->b_blocknr,
|
||||
&ih->ih_key, i, le32_to_cpu (ind [i]));
|
||||
|
||||
handle_one_pointer (fs, bh, &ind[i]);
|
||||
fsck_log ("\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (got_already (fs, le32_to_cpu (ind [i]))) {
|
||||
fsck_log ("%s: block %lu: The item (%H) has the bad pointer (%d) to the block (%lu), "
|
||||
"which is in tree already", __FUNCTION__, bh->b_blocknr, ih, i, le32_to_cpu (ind [i]));
|
||||
fsck_log ("%s: block %lu: The item (%H) has the bad pointer (%d) "
|
||||
"to the block (%lu), which is in tree already",
|
||||
__FUNCTION__, bh->b_blocknr, ih, i, le32_to_cpu(ind[i]));
|
||||
|
||||
handle_one_pointer (fs, bh, &ind [i]);
|
||||
fsck_log ("\n");
|
||||
continue;
|
||||
@@ -498,7 +537,9 @@ static int bad_indirect_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
|
||||
|
||||
/* FIXME: this was is_bad_directory from pass0.c */
|
||||
static int bad_directory_item (reiserfs_filsys_t * fs, struct buffer_head * bh, struct item_head * ih)
|
||||
static int bad_directory_item (reiserfs_filsys_t * fs,
|
||||
struct buffer_head * bh,
|
||||
struct item_head * ih)
|
||||
{
|
||||
char * name;
|
||||
int namelen;
|
||||
@@ -520,16 +561,20 @@ static int bad_directory_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
/* make sure item looks like a directory */
|
||||
if (get_ih_item_len (ih) / (DEH_SIZE + min_entry_size) < count) {
|
||||
/* entry count can not be that big */
|
||||
fsck_log ("%s: block %lu: The directory item %k has the exsessively big entry count (%u)\n",
|
||||
__FUNCTION__, bh->b_blocknr, &ih->ih_key, count);
|
||||
fsck_log ("%s: block %lu: The directory item %k has the exsessively "
|
||||
"big entry count (%u)\n", __FUNCTION__, bh->b_blocknr,
|
||||
&ih->ih_key, count);
|
||||
|
||||
one_more_corruption (fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (get_deh_location (&deh[count - 1]) != DEH_SIZE * count) {
|
||||
/* last entry should start right after array of dir entry headers */
|
||||
fsck_log ("%s: block %lu: The directory item %k has the corrupted entry structure\n",
|
||||
__FUNCTION__, bh->b_blocknr, &ih->ih_key);
|
||||
fsck_log ("%s: block %lu: The directory item %k has the corrupted "
|
||||
"entry structure\n", __FUNCTION__, bh->b_blocknr,
|
||||
&ih->ih_key);
|
||||
|
||||
one_more_corruption (fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
@@ -539,8 +584,10 @@ static int bad_directory_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
namelen = name_in_entry_length (ih, deh, i);
|
||||
name = name_in_entry (deh, i);
|
||||
if (!is_properly_hashed (fs, name, namelen, get_deh_offset (deh))) {
|
||||
fsck_log ("%s: block %lu: The directory item %k has a not properly hashed entry (%d)\n",
|
||||
__FUNCTION__, bh->b_blocknr, &ih->ih_key, i);
|
||||
fsck_log ("%s: block %lu: The directory item %k has a not properly "
|
||||
"hashed entry (%d)\n", __FUNCTION__, bh->b_blocknr,
|
||||
&ih->ih_key, i);
|
||||
|
||||
one_more_corruption (fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
@@ -551,10 +598,12 @@ static int bad_directory_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
/* ok, items looks like a directory */
|
||||
for (i = 0; i < count; i ++, deh ++) {
|
||||
if (get_deh_state (deh) != state) {
|
||||
fsck_log ("bad_directory_item: block %lu: The directory item %k has the entry (%d) "
|
||||
"\"%.*s\" with a not legal state (%o), (%o) expected",
|
||||
bh->b_blocknr, &ih->ih_key, i, name_in_entry_length (ih, deh, i),
|
||||
name_in_entry (deh, i), get_deh_state (deh), state);
|
||||
fsck_log ("bad_directory_item: block %lu: The directory item %k "
|
||||
"has the entry (%d) \"%.*s\" with a not legal state "
|
||||
"(%o), (%o) expected", bh->b_blocknr, &ih->ih_key, i,
|
||||
name_in_entry_length (ih, deh, i), name_in_entry (deh, i),
|
||||
get_deh_state (deh), state);
|
||||
|
||||
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
|
||||
set_deh_state (deh, 1 << DEH_Visible2);
|
||||
mark_buffer_dirty (bh);
|
||||
@@ -580,11 +629,12 @@ static int bad_item (reiserfs_filsys_t * fs, struct buffer_head * bh, int num)
|
||||
if ((get_ih_flags(ih)) != 0) {
|
||||
if (fsck_mode(fs) != FSCK_FIX_FIXABLE) {
|
||||
one_more_corruption (fs, FIXABLE);
|
||||
fsck_log ("%s: vpf-10570: block %lu: The item header (%d) has not cleaned flags.\n",
|
||||
__FUNCTION__, bh->b_blocknr, num);
|
||||
fsck_log ("%s: vpf-10570: block %lu: The item header (%d) has not "
|
||||
"cleaned flags.\n", __FUNCTION__, bh->b_blocknr, num);
|
||||
} else {
|
||||
fsck_log ("%s: vpf-10580: block %lu: Flags in the item header (%d) were cleaned\n",
|
||||
__FUNCTION__, bh->b_blocknr, num);
|
||||
fsck_log ("%s: vpf-10580: block %lu: Flags in the item header "
|
||||
"(%d) were cleaned\n", __FUNCTION__, bh->b_blocknr, num);
|
||||
|
||||
clean_ih_flags(ih);
|
||||
mark_buffer_dirty(bh);
|
||||
}
|
||||
@@ -601,72 +651,54 @@ static int bad_item (reiserfs_filsys_t * fs, struct buffer_head * bh, int num)
|
||||
if (format != get_ih_key_format(ih)) {
|
||||
if (fsck_mode(fs) != FSCK_FIX_FIXABLE) {
|
||||
one_more_corruption (fs, FIXABLE);
|
||||
fsck_log ("%s: vpf-10710: block %lu: The format (%d) specified in the item header (%d) "
|
||||
"differs from the key format (%d).\n", __FUNCTION__, bh->b_blocknr,
|
||||
get_ih_key_format(ih), num, format);
|
||||
fsck_log ("%s: vpf-10710: block %lu: The format (%d) specified "
|
||||
"in the item header (%d) differs from the key format "
|
||||
"(%d).\n", __FUNCTION__, bh->b_blocknr,
|
||||
get_ih_key_format(ih), num, format);
|
||||
} else {
|
||||
fsck_log ("%s: vpf-10720: block %lu: The format (%d) specified in the item header (%d) "
|
||||
"was fixed to the key format (%d).\n", __FUNCTION__, bh->b_blocknr,
|
||||
get_ih_key_format(ih), num, format);
|
||||
fsck_log ("%s: vpf-10720: block %lu: The format (%d) specified in "
|
||||
"the item header (%d) was fixed to the key format (%d).\n",
|
||||
__FUNCTION__, bh->b_blocknr, get_ih_key_format(ih), num,
|
||||
format);
|
||||
|
||||
set_ih_key_format(ih, format);
|
||||
mark_buffer_dirty(bh);
|
||||
}
|
||||
}
|
||||
|
||||
if (get_key_dirid (&ih->ih_key) == (__u32)-1) {
|
||||
if (get_key_objectid (&ih->ih_key) != (__u32)-1) {
|
||||
/* safe link can be
|
||||
if (get_key_objectid (&ih->ih_key) == BADBLOCK_OBJID) {
|
||||
if (get_key_dirid (&ih->ih_key) == BADBLOCK_DIRID && is_indirect_ih (ih)) {
|
||||
/* Bad Block support. */
|
||||
return bad_badblocks_item (fs, bh, ih);
|
||||
}
|
||||
|
||||
goto error;
|
||||
} else {
|
||||
if (get_key_dirid (&ih->ih_key) == (__u32)-1) {
|
||||
/* Safe Link support. Allowable safe links are:
|
||||
-1 object_id 0x1 INDIRECT (truncate) or
|
||||
-1 object_id blocksize+1 DIRECT (unlink)
|
||||
*/
|
||||
-1 object_id blocksize+1 DIRECT (unlink) */
|
||||
if (is_direct_ih(ih) && get_offset(&ih->ih_key) == fs->fs_blocksize + 1) {
|
||||
if (get_ih_item_len (ih) == 4) {
|
||||
/*fsck_log("vpf-00010: safe link found %k\n", &ih->ih_key);*/
|
||||
fsck_check_stat(fs)->safe ++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_direct_ih(ih))
|
||||
if (get_offset(&ih->ih_key) == fs->fs_blocksize + 1)
|
||||
if (get_ih_item_len (ih) == 4) {
|
||||
/*fsck_log("vpf-00010: safe link found %k\n", &ih->ih_key);*/
|
||||
fsck_check_stat(fs)->safe ++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (is_indirect_ih(ih))
|
||||
if(get_offset(&ih->ih_key) == 0x1)
|
||||
if (get_ih_item_len (ih) == 4) {
|
||||
/*fsck_log("vpf-00020: safe link found %k\n", &ih->ih_key);*/
|
||||
fsck_check_stat(fs)->safe ++;
|
||||
return 0;
|
||||
}
|
||||
if (is_indirect_ih(ih) && get_offset(&ih->ih_key) == 0x1) {
|
||||
if (get_ih_item_len (ih) == 4) {
|
||||
/*fsck_log("vpf-00020: safe link found %k\n", &ih->ih_key);*/
|
||||
fsck_check_stat(fs)->safe ++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* it does not look like safe link */
|
||||
|
||||
/* dir_id == -1 can be used only by safe links */
|
||||
one_more_corruption (fs, FATAL);
|
||||
fsck_log ("%s: vpf-10290: block %lu, item %d: The item has a wrong key %k\n",
|
||||
__FUNCTION__, num, bh->b_blocknr, &ih->ih_key);
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
/* BAD BLOCK LIST SUPPORT
|
||||
if (is_indirect_ih (ih)) {
|
||||
// it looks like badblocks item
|
||||
if (fs->fs_badblocks_bm)
|
||||
return 0;
|
||||
else
|
||||
return bad_badblocks_item (fs, bh, ih);
|
||||
} else {*/
|
||||
|
||||
one_more_corruption (fs, FATAL);
|
||||
fsck_log ("%s: vpf-10300: block %lu, item %d: The item has a wrong key %k\n",
|
||||
__FUNCTION__, num, bh->b_blocknr, &ih->ih_key);
|
||||
return 1;
|
||||
goto error;
|
||||
}
|
||||
} else if (get_key_objectid (&ih->ih_key) == (__u32)-1) {
|
||||
one_more_corruption (fs, FATAL);
|
||||
fsck_log ("%s: vpf-10310: block %lu, item %d: The item has a wrong key %k\n",
|
||||
__FUNCTION__, num, bh->b_blocknr, &ih->ih_key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (is_stat_data_ih (ih))
|
||||
return bad_stat_data (fs, bh, ih);
|
||||
|
||||
@@ -677,12 +709,17 @@ static int bad_item (reiserfs_filsys_t * fs, struct buffer_head * bh, int num)
|
||||
return bad_indirect_item (fs, bh, ih);
|
||||
|
||||
return bad_directory_item (fs, bh, ih);
|
||||
|
||||
error:
|
||||
one_more_corruption (fs, FATAL);
|
||||
fsck_log ("%s: vpf-10310: block %lu, item %d: The item has a wrong "
|
||||
"key %k\n", __FUNCTION__, num, bh->b_blocknr, &ih->ih_key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* 1 if i-th and (i-1)-th items can not be neighbors in a leaf */
|
||||
int bad_pair (reiserfs_filsys_t * fs, struct buffer_head * bh, int pos)
|
||||
{
|
||||
int bad_pair (reiserfs_filsys_t * fs, struct buffer_head * bh, int pos) {
|
||||
struct item_head * ih;
|
||||
|
||||
ih = B_N_PITEM_HEAD (bh, pos);
|
||||
@@ -701,15 +738,15 @@ int bad_pair (reiserfs_filsys_t * fs, struct buffer_head * bh, int pos)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (get_key_dirid (&ih->ih_key) == (__u32)-1) {
|
||||
if (get_key_objectid (&ih->ih_key) == (__u32)-1) {
|
||||
/* BAD BLOCK LIST SUPPORT
|
||||
if (is_indirect_ih (ih) && comp_short_keys (&((ih - 1)->ih_key), &ih->ih_key) != 0)
|
||||
return 0; // badblocks item
|
||||
*/
|
||||
/* it does not look like badblocks item */
|
||||
} else {
|
||||
/* safe link ? */
|
||||
if (get_key_objectid (&ih->ih_key) == BADBLOCK_OBJID) {
|
||||
/* BAD BLOCK LIST SUPPORT. */
|
||||
if (get_key_dirid(&ih->ih_key) == BADBLOCK_DIRID &&
|
||||
is_indirect_ih(ih) && comp_short_keys(&((ih - 1)->ih_key),
|
||||
&ih->ih_key))
|
||||
return 0;
|
||||
} else {
|
||||
/* Safe link support. */
|
||||
if (get_key_dirid (&ih->ih_key) == (__u32)-1) {
|
||||
if (comp_short_keys (&((ih - 1)->ih_key), &ih->ih_key) == 0) {
|
||||
if (is_indirect_ih (ih - 1) && is_direct_ih(ih))
|
||||
return 0; /* safe link */
|
||||
@@ -719,24 +756,25 @@ int bad_pair (reiserfs_filsys_t * fs, struct buffer_head * bh, int pos)
|
||||
return 0; /* safe link */
|
||||
/* it does not look like safe link */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (is_direct_ih(ih)) {
|
||||
/* left item must be indirect or stat data item of the same
|
||||
file */
|
||||
/* left item must be indirect or stat data item of the same file */
|
||||
if (not_of_one_file (&((ih - 1)->ih_key), &ih->ih_key)) {
|
||||
if (fsck_mode (fs) != FSCK_REBUILD)
|
||||
one_more_corruption (fs, FATAL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!((is_stat_data_ih (ih - 1) && get_offset (&ih->ih_key) == 1) ||
|
||||
(is_indirect_ih (ih - 1) &&
|
||||
get_offset (&(ih - 1)->ih_key) + get_bytes_number (ih-1, bh->b_size) ==
|
||||
get_offset (&ih->ih_key)))) {
|
||||
(is_indirect_ih (ih - 1) && get_offset (&(ih - 1)->ih_key) +
|
||||
get_bytes_number (ih-1, bh->b_size) == get_offset (&ih->ih_key))))
|
||||
{
|
||||
if (fsck_mode (fs) != FSCK_REBUILD)
|
||||
one_more_corruption (fs, FATAL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -764,14 +802,15 @@ static int bad_leaf (reiserfs_filsys_t * fs, struct buffer_head * bh)
|
||||
|
||||
for (i = 0; i < B_NR_ITEMS (bh); i ++) {
|
||||
if (bad_item (fs, bh, i)) {
|
||||
fsck_log ("bad_leaf: block %lu, item %d: The corrupted item found (%H)\n",
|
||||
bh->b_blocknr, i, B_N_PITEM_HEAD (bh, i));
|
||||
fsck_log ("bad_leaf: block %lu, item %d: The corrupted item found "
|
||||
"(%H)\n", bh->b_blocknr, i, B_N_PITEM_HEAD (bh, i));
|
||||
}
|
||||
|
||||
if (i && bad_pair (fs, bh, i)) {
|
||||
fsck_log ("bad_leaf: block %lu, items %d and %d: The wrong order of items: %k, %k\n",
|
||||
bh->b_blocknr, i-1, i, &B_N_PITEM_HEAD (bh, i-1)->ih_key,
|
||||
&B_N_PITEM_HEAD (bh, i)->ih_key);
|
||||
fsck_log ("bad_leaf: block %lu, items %d and %d: The wrong order "
|
||||
"of items: %k, %k\n", bh->b_blocknr, i - 1, i,
|
||||
&B_N_PITEM_HEAD (bh, i-1)->ih_key,
|
||||
&B_N_PITEM_HEAD (bh, i)->ih_key);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -785,19 +824,24 @@ static int bad_internal (reiserfs_filsys_t * fs, struct buffer_head * bh)
|
||||
for (i = 0; i <= B_NR_ITEMS (bh); i ++) {
|
||||
if (i != B_NR_ITEMS (bh) && i != B_NR_ITEMS (bh) - 1)
|
||||
/* make sure that keys are in increasing order */
|
||||
if (comp_keys (B_N_PDELIM_KEY (bh, i), B_N_PDELIM_KEY (bh, i + 1)) != -1) {
|
||||
fsck_log ("%s: vpf-10320: block %lu, items %d and %d: The wrong order "
|
||||
"of items: %k, %k\n", __FUNCTION__, bh->b_blocknr, i, i+1,
|
||||
B_N_PDELIM_KEY (bh, i), B_N_PDELIM_KEY (bh, i + 1));
|
||||
if (comp_keys (B_N_PDELIM_KEY (bh, i),
|
||||
B_N_PDELIM_KEY (bh, i + 1)) != -1)
|
||||
{
|
||||
fsck_log ("%s: vpf-10320: block %lu, items %d and %d: The "
|
||||
"wrong order of items: %k, %k\n", __FUNCTION__,
|
||||
bh->b_blocknr, i, i + 1, B_N_PDELIM_KEY (bh, i),
|
||||
B_N_PDELIM_KEY (bh, i + 1));
|
||||
|
||||
one_more_corruption (fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* make sure that the child is correct */
|
||||
if (bad_block_number (fs, get_dc_child_blocknr (B_N_CHILD (bh,i)))) {
|
||||
fsck_log ("%s: vpf-10330: block %lu, item %d: The internal item points to the "
|
||||
"not legal block (%lu)\n", __FUNCTION__, bh->b_blocknr, i,
|
||||
get_dc_child_blocknr (B_N_CHILD (bh,i)));
|
||||
fsck_log ("%s: vpf-10330: block %lu, item %d: The internal item "
|
||||
"points to the not legal block (%lu)\n", __FUNCTION__,
|
||||
bh->b_blocknr, i, get_dc_child_blocknr (B_N_CHILD (bh,i)));
|
||||
|
||||
one_more_corruption (fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
@@ -819,22 +863,24 @@ static int bad_node (reiserfs_filsys_t * fs, struct buffer_head ** path, int h)
|
||||
struct buffer_head ** pbh = &path[h];
|
||||
|
||||
if (B_LEVEL (*pbh) != h_to_level (fs, h)) {
|
||||
fsck_log ("block %lu: The level of the node (%d) is not correct, (%d) expected\n",
|
||||
(*pbh)->b_blocknr, B_LEVEL (*pbh), h_to_level (fs, h));
|
||||
fsck_log ("block %lu: The level of the node (%d) is not correct, "
|
||||
"(%d) expected\n", (*pbh)->b_blocknr, B_LEVEL (*pbh),
|
||||
h_to_level (fs, h));
|
||||
|
||||
one_more_corruption (fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bad_block_number (fs, (*pbh)->b_blocknr)) {
|
||||
one_more_corruption (fs, FATAL);
|
||||
fsck_log ("%s: vpf-10340: The node in the wrong block number (%lu) found in the tree\n",
|
||||
__FUNCTION__, (*pbh)->b_blocknr);
|
||||
fsck_log ("%s: vpf-10340: The node in the wrong block number (%lu) "
|
||||
"found in the tree\n", __FUNCTION__, (*pbh)->b_blocknr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (got_already (fs, (*pbh)->b_blocknr)) {
|
||||
fsck_log ("%s: vpf-10350: The block (%lu) is used more than once in the tree.\n",
|
||||
__FUNCTION__, (*pbh)->b_blocknr);
|
||||
fsck_log ("%s: vpf-10350: The block (%lu) is used more than once "
|
||||
"in the tree.\n", __FUNCTION__, (*pbh)->b_blocknr);
|
||||
one_more_corruption (fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
@@ -927,7 +973,7 @@ static int bad_path (reiserfs_filsys_t * fs, struct buffer_head ** path, int h1)
|
||||
dk = rkey (path, h);
|
||||
if (dk && comp_keys (dk, B_N_PKEY (path[h],
|
||||
get_blkh_nr_items (B_BLK_HEAD (path[h])) - 1)) != 1) {
|
||||
/* right delimiting key must be greater than the key of the last item in the node */
|
||||
/* right delimiting key must be gt the key of the last item in the node */
|
||||
fsck_log ("bad_path: The right delimiting key %k of the node (%lu) must "
|
||||
"be greater than the last (%d) element's key %k within the node.\n",
|
||||
dk, path[h]->b_blocknr, get_blkh_nr_items (B_BLK_HEAD (path[h])) - 1,
|
||||
@@ -950,8 +996,11 @@ static int bad_path (reiserfs_filsys_t * fs, struct buffer_head ** path, int h1)
|
||||
|
||||
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
|
||||
set_dc_child_size (B_N_CHILD(path[h-1],pos), path[h]->b_size -
|
||||
get_blkh_free_space ((struct block_head *)path[h]->b_data) - BLKH_SIZE);
|
||||
fsck_log (" - corrected to (%lu)\n", get_dc_child_size (B_N_CHILD(path[h-1],pos)));
|
||||
get_blkh_free_space ((struct block_head *)path[h]->b_data)
|
||||
- BLKH_SIZE);
|
||||
fsck_log (" - corrected to (%lu)\n",
|
||||
get_dc_child_size (B_N_CHILD(path[h-1], pos)));
|
||||
|
||||
mark_buffer_dirty (path[h-1]);
|
||||
} else {
|
||||
one_more_corruption (fs, FIXABLE);
|
||||
@@ -1010,13 +1059,17 @@ void check_fs_tree (reiserfs_filsys_t * fs)
|
||||
after_check_fs_tree (fs);
|
||||
}
|
||||
|
||||
static int clean_attributes_handler (reiserfs_filsys_t * fs, struct buffer_head ** path, int h) {
|
||||
static int clean_attributes_handler (reiserfs_filsys_t * fs,
|
||||
struct buffer_head ** path,
|
||||
int h)
|
||||
{
|
||||
struct buffer_head * bh = path[h];
|
||||
int i;
|
||||
|
||||
if (B_LEVEL (bh) != h_to_level (fs, h)) {
|
||||
reiserfs_panic ("The node (%lu) with wrong level (%d) found in the tree, (%d) expected\n",
|
||||
bh->b_blocknr, B_LEVEL (bh), h_to_level (fs, h));
|
||||
reiserfs_panic ("The node (%lu) with wrong level (%d) found in the "
|
||||
"tree, (%d) expected\n", bh->b_blocknr, B_LEVEL (bh),
|
||||
h_to_level (fs, h));
|
||||
}
|
||||
|
||||
if (!is_leaf_node (bh))
|
||||
@@ -1038,5 +1091,3 @@ void do_clean_attributes (reiserfs_filsys_t * fs) {
|
||||
set_sb_v2_flag (fs->fs_ondisk_sb, reiserfs_attrs_cleared);
|
||||
mark_buffer_dirty (fs->fs_super_bh);
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "misc.h"
|
||||
#include "reiserfs_lib.h"
|
||||
|
||||
#include "../include/config.h"
|
||||
#include "../version.h"
|
||||
|
||||
/* main.c */
|
||||
extern reiserfs_filsys_t * fs;
|
||||
@@ -30,6 +32,7 @@ int main (int argc, char * argv []);
|
||||
/* Exit codes. */
|
||||
#define EXIT_OK 0
|
||||
#define EXIT_FIXED 1
|
||||
#define EXIT_REBOOT 2
|
||||
#define EXIT_FATAL 4
|
||||
#define EXIT_FIXABLE 6
|
||||
#define EXIT_OPER 8 /* Some operation returns error. */
|
||||
@@ -187,7 +190,6 @@ void pass_3a_look_for_lost (reiserfs_filsys_t *);
|
||||
void load_lost_found_result (reiserfs_filsys_t *);
|
||||
|
||||
/* pass4.c */
|
||||
//void get_next_key (struct path * path, int i, struct key * key);
|
||||
void pass_4_check_unaccessed_items (void);
|
||||
|
||||
/* check.c */
|
||||
@@ -406,6 +408,7 @@ struct check_info {
|
||||
struct fsck_data {
|
||||
unsigned short mode; /* check, rebuild, etc*/
|
||||
unsigned long options;
|
||||
unsigned long mounted;
|
||||
|
||||
struct rebuild_info rebuild;
|
||||
struct check_info check;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 2000-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
|
||||
+149
-132
@@ -1,14 +1,12 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
#include "fsck.h"
|
||||
#include <getopt.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include "../include/config.h"
|
||||
#include "../version.h"
|
||||
#include <sys/mman.h>
|
||||
|
||||
extern int screen_width;
|
||||
extern int screen_savebuffer_len;
|
||||
@@ -18,7 +16,7 @@ reiserfs_filsys_t * fs;
|
||||
char * badblocks_file;
|
||||
|
||||
#define print_usage_and_exit() { \
|
||||
fsck_progress ("\nUsage: %s [mode] [options] " \
|
||||
fsck_progress ("Usage: %s [mode] [options] " \
|
||||
" device\n" \
|
||||
"\n" \
|
||||
"Modes:\n" \
|
||||
@@ -32,6 +30,7 @@ fsck_progress ("\nUsage: %s [mode] [options] " \
|
||||
" --clean-attributes\t\tclean garbage in reserved fields in StatDatas \n" \
|
||||
"Options:\n" \
|
||||
" -j | --journal device\t\tspecify journal if relocated\n" \
|
||||
" -B | --badblocks file\t\tfile with list of all bad blocks on the fs\n" \
|
||||
" -l | --logfile file\t\tmake fsck to complain to specifed file\n" \
|
||||
" -n | --nolog\t\t\tmake fsck to not complain\n" \
|
||||
" -z | --adjust-size\t\tfix file sizes to real size\n" \
|
||||
@@ -49,9 +48,6 @@ fsck_progress ("\nUsage: %s [mode] [options] " \
|
||||
}
|
||||
|
||||
/*
|
||||
" -B badblocks-file\n"\
|
||||
" \t\t\tlist of all bad blocks on the fs\n"\
|
||||
|
||||
-B works with --fix-fixable
|
||||
fixes indirect pointers pointed to
|
||||
badblocks, adds badblocks to badblock list in fs.
|
||||
@@ -101,6 +97,7 @@ static char * parse_options (struct fsck_data * data, int argc, char * argv [])
|
||||
{"clean-attributes", no_argument, &mode, FSCK_CLEAN_ATTRIBUTES},
|
||||
/* options */
|
||||
{"logfile", required_argument, 0, 'l'},
|
||||
{"badblocks", required_argument, 0, 'B'},
|
||||
{"interactive", no_argument, 0, 'i'},
|
||||
{"adjust-size", no_argument, 0, 'z'},
|
||||
{"quiet", no_argument, 0, 'q'},
|
||||
@@ -124,7 +121,7 @@ static char * parse_options (struct fsck_data * data, int argc, char * argv [])
|
||||
{"journal", required_argument, 0, 'j'},
|
||||
{"no-journal-available", no_argument, &flag, OPT_SKIP_JOURNAL},
|
||||
|
||||
// {"bad-block-file", required_argument, 0, 'B'},
|
||||
{"bad-block-file", required_argument, 0, 'B'},
|
||||
|
||||
/* start reiserfsck in background and exit */
|
||||
{"background", no_argument, 0, 'g'},
|
||||
@@ -133,7 +130,7 @@ static char * parse_options (struct fsck_data * data, int argc, char * argv [])
|
||||
};
|
||||
int option_index;
|
||||
|
||||
c = getopt_long (argc, argv, "iql:nb:Szd:R:h:j:gafVrpyt:",
|
||||
c = getopt_long (argc, argv, "iql:nb:Szd:R:h:j:gafVrpyt:B:",
|
||||
options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
@@ -280,9 +277,13 @@ static char * parse_options (struct fsck_data * data, int argc, char * argv [])
|
||||
print_usage_and_exit();
|
||||
}
|
||||
|
||||
if ((data->options & BADBLOCKS_FILE) && ((mode == FSCK_SB)
|
||||
|| (mode == FSCK_CLEAN_ATTRIBUTES) || (mode == FSCK_CHECK)))
|
||||
if ((data->options & BADBLOCKS_FILE) && mode != FSCK_REBUILD &&
|
||||
mode != FSCK_FIX_FIXABLE)
|
||||
{
|
||||
fprintf(stderr, "Badblocks can be specified with --fix-fixable or "
|
||||
"--rebuild-tree only.\n");
|
||||
print_usage_and_exit();
|
||||
}
|
||||
|
||||
if ((mode == FSCK_REBUILD) && (data->options & OPT_YES))
|
||||
data->options &= ~OPT_YES;
|
||||
@@ -296,36 +297,36 @@ static char * parse_options (struct fsck_data * data, int argc, char * argv [])
|
||||
|
||||
|
||||
#define REBUILD_WARNING \
|
||||
" *************************************************************\n\
|
||||
** Do not run the program with --rebuild-tree unless **\n\
|
||||
** something is broken and MAKE A BACKUP before using it. **\n\
|
||||
** If you have bad sectors on a drive it is usually a bad **\n\
|
||||
** idea to continue using it. Then you probably should get **\n\
|
||||
** a working hard drive, copy the file system from the bad **\n\
|
||||
** drive to the good one -- dd_rescue is a good tool for **\n\
|
||||
** that -- and only then run this program. **\n\
|
||||
** If you are using the latest reiserfsprogs and it fails **\n\
|
||||
** please email bug reports to reiserfs-list@namesys.com, **\n\
|
||||
** providing as much information as possible -- your **\n\
|
||||
** hardware, kernel, patches, settings, all reiserfsck **\n\
|
||||
** messages (including version), the reiserfsck logfile, **\n\
|
||||
** check the syslog file for any related information. **\n\
|
||||
** If you would like advice on using this program, support **\n\
|
||||
** is available for $25 at www.namesys.com/support.html. **\n\
|
||||
*************************************************************\n\
|
||||
"*************************************************************\n\
|
||||
** Do not run the program with --rebuild-tree unless **\n\
|
||||
** something is broken and MAKE A BACKUP before using it. **\n\
|
||||
** If you have bad sectors on a drive it is usually a bad **\n\
|
||||
** idea to continue using it. Then you probably should get **\n\
|
||||
** a working hard drive, copy the file system from the bad **\n\
|
||||
** drive to the good one -- dd_rescue is a good tool for **\n\
|
||||
** that -- and only then run this program. **\n\
|
||||
** If you are using the latest reiserfsprogs and it fails **\n\
|
||||
** please email bug reports to reiserfs-list@namesys.com, **\n\
|
||||
** providing as much information as possible -- your **\n\
|
||||
** hardware, kernel, patches, settings, all reiserfsck **\n\
|
||||
** messages (including version), the reiserfsck logfile, **\n\
|
||||
** check the syslog file for any related information. **\n\
|
||||
** If you would like advice on using this program, support **\n\
|
||||
** is available for $25 at www.namesys.com/support.html. **\n\
|
||||
*************************************************************\n\
|
||||
\nWill rebuild the filesystem (%s) tree\n"
|
||||
|
||||
#define START_WARNING \
|
||||
" *************************************************************\n\
|
||||
** If you are using the latest reiserfsprogs and it fails **\n\
|
||||
** please email bug reports to reiserfs-list@namesys.com, **\n\
|
||||
** providing as much information as possible -- your **\n\
|
||||
** hardware, kernel, patches, settings, all reiserfsck **\n\
|
||||
** messages (including version), the reiserfsck logfile, **\n\
|
||||
** check the syslog file for any related information. **\n\
|
||||
** If you would like advice on using this program, support **\n\
|
||||
** is available for $25 at www.namesys.com/support.html. **\n\
|
||||
*************************************************************\n\
|
||||
"*************************************************************\n\
|
||||
** If you are using the latest reiserfsprogs and it fails **\n\
|
||||
** please email bug reports to reiserfs-list@namesys.com, **\n\
|
||||
** providing as much information as possible -- your **\n\
|
||||
** hardware, kernel, patches, settings, all reiserfsck **\n\
|
||||
** messages (including version), the reiserfsck logfile, **\n\
|
||||
** check the syslog file for any related information. **\n\
|
||||
** If you would like advice on using this program, support **\n\
|
||||
** is available for $25 at www.namesys.com/support.html. **\n\
|
||||
*************************************************************\n\
|
||||
\n"
|
||||
|
||||
|
||||
@@ -530,7 +531,7 @@ static void reset_super_block (reiserfs_filsys_t * fs)
|
||||
set_sb_reserved_for_journal (sb, 0);
|
||||
|
||||
set_jp_journal_dev (sb_jp(sb), 0);
|
||||
set_jp_journal_magic (sb_jp(sb) ,0);
|
||||
set_jp_journal_magic (sb_jp(sb), get_random());
|
||||
set_jp_journal_1st_block (sb_jp(sb), get_journal_start_must (fs));
|
||||
set_jp_journal_size (sb_jp(sb),
|
||||
journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize));
|
||||
@@ -545,7 +546,8 @@ static void reset_super_block (reiserfs_filsys_t * fs)
|
||||
set_jp_journal_max_trans_age (sb_jp(sb), advise_journal_max_trans_age());
|
||||
|
||||
set_jp_journal_dev (&jh->jh_journal, 0);
|
||||
set_jp_journal_magic (&jh->jh_journal ,0);
|
||||
set_jp_journal_magic (&jh->jh_journal,
|
||||
get_jp_journal_magic(sb_jp(sb)));
|
||||
set_jp_journal_1st_block (&jh->jh_journal,
|
||||
get_jp_journal_1st_block(sb_jp(sb)));
|
||||
set_jp_journal_size (&jh->jh_journal, get_jp_journal_size(sb_jp(sb)));
|
||||
@@ -722,9 +724,10 @@ static void reiserfsck_replay_journal (reiserfs_filsys_t * fs) {
|
||||
fs->fs_ondisk_sb = on_place_sb;
|
||||
}
|
||||
|
||||
static void the_end (reiserfs_filsys_t * fs)
|
||||
static int the_end (reiserfs_filsys_t * fs)
|
||||
{
|
||||
struct reiserfs_super_block * sb;
|
||||
int ret = EXIT_FIXED;
|
||||
|
||||
sb = fs->fs_ondisk_sb;
|
||||
|
||||
@@ -744,41 +747,85 @@ static void the_end (reiserfs_filsys_t * fs)
|
||||
mark_filesystem_consistent (fs);
|
||||
clear_buffer_do_not_flush (fs->fs_super_bh);
|
||||
|
||||
if (fsck_data(fs)->mounted == MF_RO) {
|
||||
reiserfs_warning(stderr, "\nThe partition is mounted ro. It "
|
||||
"is better to umount and mount it again.\n\n");
|
||||
ret = EXIT_REBOOT;
|
||||
}
|
||||
|
||||
/* write all dirty blocks */
|
||||
fsck_progress ("Syncing..");
|
||||
fs->fs_dirt = 1;
|
||||
clean_after_dma_check(fs->fs_dev, &dma_info);
|
||||
reiserfs_close (fs);
|
||||
fsck_progress ("finished\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* check umounted or read-only mounted filesystems only */
|
||||
static void prepare_fs_for_check(reiserfs_filsys_t * fs) {
|
||||
/* The method could be called from auto_check already. */
|
||||
if (fs->fs_flags == O_RDWR)
|
||||
return;
|
||||
|
||||
static void rebuild_tree (reiserfs_filsys_t * fs)
|
||||
{
|
||||
reiserfs_reopen (fs, O_RDWR);
|
||||
|
||||
fsck_data(fs)->mounted = misc_device_mounted(fs->fs_file_name);
|
||||
|
||||
if (fsck_data(fs)->mounted > 0) {
|
||||
if (fsck_data(fs)->mounted == MF_RW) {
|
||||
fsck_progress ("Partition %s is mounted with write permissions, "
|
||||
"cannot check it\n", fs->fs_file_name);
|
||||
reiserfs_close(fs);
|
||||
exit(EXIT_USER);
|
||||
}
|
||||
|
||||
/* If not CHECK mode, lock the process in the memory. */
|
||||
if (fsck_mode (fs) != FSCK_CHECK) {
|
||||
if (mlockall(MCL_CURRENT)) {
|
||||
reiserfs_warning (stderr, "Failed to lock the process to "
|
||||
"fsck the mounted ro partition. %s.\n",
|
||||
strerror(errno));
|
||||
exit(EXIT_OPER);
|
||||
}
|
||||
}
|
||||
|
||||
if (!reiserfs_journal_opened (fs)) {
|
||||
/* just to make sure */
|
||||
reiserfs_panic ("Journal is not opened");
|
||||
} else if (reiserfs_journal_params_check(fs)) {
|
||||
reiserfs_close (fs);
|
||||
exit(EXIT_FATAL);
|
||||
}
|
||||
|
||||
fsck_progress ("Filesystem seems mounted read-only. Skipping journal "
|
||||
"replay.\n");
|
||||
|
||||
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
|
||||
fsck_progress ("--fix-fixable ignored\n");
|
||||
fsck_mode (fs) = FSCK_CHECK;
|
||||
}
|
||||
} else if (!fsck_skip_journal (fs)) {
|
||||
if (reiserfs_journal_params_check(fs)) {
|
||||
reiserfs_close (fs);
|
||||
exit(EXIT_FATAL);
|
||||
}
|
||||
|
||||
/* filesystem is not mounted, replay journal before checking */
|
||||
reiserfsck_replay_journal (fs);
|
||||
}
|
||||
}
|
||||
|
||||
static void rebuild_tree (reiserfs_filsys_t * fs) {
|
||||
time_t t;
|
||||
int ret;
|
||||
|
||||
if (is_mounted (fs->fs_file_name)) {
|
||||
fsck_progress ("rebuild_tree: Cannot rebuild tree of mounted filesystem\n");
|
||||
exit(EXIT_USER);
|
||||
}
|
||||
|
||||
init_rollback_file (state_rollback_file(fs), &fs->fs_blocksize,
|
||||
fsck_data(fs)->log);
|
||||
|
||||
reiserfs_reopen (fs, O_RDWR);
|
||||
|
||||
if (!fsck_skip_journal (fs)) {
|
||||
if (reiserfs_journal_params_check(fs)) {
|
||||
reiserfs_close(fs);
|
||||
exit(EXIT_FATAL);
|
||||
}
|
||||
|
||||
/* rebuild starts with journal replaying */
|
||||
if (!fsck_skip_journal (fs))
|
||||
reiserfsck_replay_journal (fs);
|
||||
}
|
||||
|
||||
prepare_fs_for_check(fs);
|
||||
|
||||
ret = reiserfs_open_ondisk_bitmap (fs);
|
||||
if (ret < 0) {
|
||||
fsck_progress ("reiserfsck: Could not open bitmap\n");
|
||||
@@ -818,67 +865,16 @@ static void rebuild_tree (reiserfs_filsys_t * fs)
|
||||
/* 4. look for unaccessed items in the leaves */
|
||||
pass_4_check_unaccessed_items ();
|
||||
|
||||
the_end (fs);
|
||||
ret = the_end (fs);
|
||||
}
|
||||
|
||||
close_rollback_file ();
|
||||
|
||||
|
||||
time (&t);
|
||||
fsck_progress ("###########\n"
|
||||
"reiserfsck finished at %s"
|
||||
"###########\n", ctime (&t));
|
||||
exit (EXIT_OK);
|
||||
}
|
||||
|
||||
|
||||
/* check umounted or read-only mounted filesystems only */
|
||||
static void prepare_fs_for_check(reiserfs_filsys_t * fs)
|
||||
{
|
||||
/* The method could be called from auto_check already. */
|
||||
if (fs->fs_flags == O_RDWR)
|
||||
return;
|
||||
|
||||
reiserfs_reopen (fs, O_RDWR);
|
||||
|
||||
if (is_mounted (fs->fs_file_name)) {
|
||||
/* filesystem seems mounted. */
|
||||
if (fsck_mode (fs) == FSCK_CLEAN_ATTRIBUTES) {
|
||||
fsck_progress ("Partition %s is mounted, cannot clean attributes "
|
||||
"on mounted device\n", fs->fs_file_name);
|
||||
reiserfs_close (fs);
|
||||
exit(EXIT_USER);
|
||||
}
|
||||
|
||||
if (!is_mounted_read_only (fs->fs_file_name)) {
|
||||
fsck_progress ("Partition %s is mounted with write permissions, "
|
||||
"cannot check it\n", fs->fs_file_name);
|
||||
reiserfs_close (fs);
|
||||
exit(EXIT_USER);
|
||||
}
|
||||
if (!reiserfs_journal_opened (fs)) {
|
||||
/* just to make sure */
|
||||
reiserfs_panic ("Journal is not opened");
|
||||
} else if (reiserfs_journal_params_check(fs)) {
|
||||
reiserfs_close (fs);
|
||||
exit(EXIT_FATAL);
|
||||
}
|
||||
|
||||
fsck_progress ("Filesystem seems mounted read-only. Skipping journal "
|
||||
"replay.\n");
|
||||
|
||||
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
|
||||
fsck_progress ("--fix-fixable ignored\n");
|
||||
fsck_mode (fs) = FSCK_CHECK;
|
||||
}
|
||||
} else if (!fsck_skip_journal (fs)) {
|
||||
if (reiserfs_journal_params_check(fs)) {
|
||||
reiserfs_close (fs);
|
||||
exit(EXIT_FATAL);
|
||||
}
|
||||
|
||||
/* filesystem is not mounted, replay journal before checking */
|
||||
reiserfsck_replay_journal (fs);
|
||||
}
|
||||
exit (ret);
|
||||
}
|
||||
|
||||
static void clean_attributes (reiserfs_filsys_t * fs) {
|
||||
@@ -990,6 +986,7 @@ static int auto_check (reiserfs_filsys_t *fs) {
|
||||
}
|
||||
|
||||
check_fs_tree (fs);
|
||||
|
||||
if (fsck_data (fs)->check.fatal_corruptions) {
|
||||
fprintf(stderr, "%lu fatal corruption(s) found in the root block. Running "
|
||||
"with the --rebuild-tree is required.\n",
|
||||
@@ -1096,12 +1093,21 @@ static void check_fs (reiserfs_filsys_t * fs)
|
||||
} else {
|
||||
fsck_progress ("No corruptions found\n");
|
||||
stage_report (5, fs);
|
||||
retval = fsck_mode(fs) == FSCK_CHECK ? EXIT_OK : EXIT_FIXED;
|
||||
|
||||
if (fsck_mode(fs) != FSCK_CHECK) {
|
||||
if (misc_device_mounted(fs->fs_file_name) == MF_RO) {
|
||||
reiserfs_warning(stderr, "\nThe partition is mounted ro. It is better "
|
||||
"to umount and mount it again.\n\n");
|
||||
retval = EXIT_REBOOT;
|
||||
} else
|
||||
retval = EXIT_FIXED;
|
||||
} else
|
||||
retval = EXIT_OK;
|
||||
|
||||
mark_filesystem_consistent (fs);
|
||||
}
|
||||
|
||||
if (fsck_mode (fs) == FSCK_FIX_FIXABLE)
|
||||
if (fsck_mode (fs) == FSCK_FIX_FIXABLE && !fsck_data (fs)->check.fatal_corruptions)
|
||||
id_map_flush(proper_id_map (fs), fs);
|
||||
|
||||
id_map_free(proper_id_map (fs));
|
||||
@@ -1185,8 +1191,9 @@ int main (int argc, char * argv [])
|
||||
char * file_name;
|
||||
struct fsck_data * data;
|
||||
struct rlimit rlim = {0xffffffff, 0xffffffff};
|
||||
int retval;
|
||||
char *width;
|
||||
int retval;
|
||||
int errno;
|
||||
|
||||
width = getenv("COLUMNS");
|
||||
if ( width )
|
||||
@@ -1250,17 +1257,22 @@ int main (int argc, char * argv [])
|
||||
if (open_devices_for_rollback (file_name, data) == -1)
|
||||
exit(EXIT_OPER);
|
||||
} else {
|
||||
fs = reiserfs_open (file_name, O_RDONLY, 0, data,
|
||||
fs = reiserfs_open (file_name, O_RDONLY, &errno, data,
|
||||
data->mode != FSCK_SB);
|
||||
|
||||
if (data->mode != FSCK_SB) {
|
||||
if (no_reiserfs_found (fs))
|
||||
die ("Failed to open the filesystem.\n\n"
|
||||
"If the partition table has not been changed, and the partition is\n"
|
||||
"valid and it really contains a reiserfs partition, then the\n"
|
||||
"superblock is corrupted and you need to run this utility with\n"
|
||||
"--rebuild-sb.\n");
|
||||
|
||||
if (no_reiserfs_found (fs)) {
|
||||
if (errno) {
|
||||
die ("Failed to open the device '%s': %s\n\n",
|
||||
file_name, strerror(errno));
|
||||
} else {
|
||||
die ("Failed to open the filesystem.\n\n"
|
||||
"If the partition table has not been changed, and the partition is\n"
|
||||
"valid and it really contains a reiserfs partition, then the\n"
|
||||
"superblock is corrupted and you need to run this utility with\n"
|
||||
"--rebuild-sb.\n");
|
||||
}
|
||||
}
|
||||
if (fsck_skip_journal (fs) &&
|
||||
!is_reiserfs_jr_magic_string (fs->fs_ondisk_sb))
|
||||
{
|
||||
@@ -1270,21 +1282,26 @@ int main (int argc, char * argv [])
|
||||
}
|
||||
|
||||
if (!fsck_skip_journal (fs)) {
|
||||
if (reiserfs_open_journal(fs, data->journal_dev_name, O_RDONLY)) {
|
||||
retval = reiserfs_open_journal(fs, data->journal_dev_name, O_RDONLY);
|
||||
|
||||
if (retval) {
|
||||
fsck_progress ("Failed to open the journal device (%s).\n",
|
||||
data->journal_dev_name);
|
||||
|
||||
if (retval == 1) {
|
||||
fsck_progress ("Run --rebuild-sb to rebuild journal parameters.\n");
|
||||
}
|
||||
|
||||
reiserfs_close (fs);
|
||||
exit(EXIT_OPER);
|
||||
}
|
||||
}
|
||||
|
||||
if (data->options & BADBLOCKS_FILE) {
|
||||
if (create_badblock_bitmap (fs, badblocks_file) != 0) {
|
||||
badblocks_file = NULL;
|
||||
data->options &= ~BADBLOCKS_FILE;
|
||||
}
|
||||
if (create_badblock_bitmap (fs, badblocks_file) != 0)
|
||||
exit(EXIT_OPER);
|
||||
}
|
||||
|
||||
register_timer();
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
@@ -559,7 +559,7 @@ static __inline__ int does_it_fit_into_dev (__u64 offset, __u64 fs_size) {
|
||||
|
||||
static int is_wrong_short_key (struct key * key) {
|
||||
if (get_key_dirid (key) == 0 || get_key_objectid (key) == 0 || get_key_objectid (key) == 1 ||
|
||||
get_key_dirid (key) == ~0ul || get_key_objectid (key) == ~0ul ||
|
||||
get_key_dirid (key) == ~(__u32)0 || get_key_objectid (key) == ~(__u32)0 ||
|
||||
get_key_dirid (key) == get_key_objectid (key) ||
|
||||
(get_key_dirid (key) == 1 && get_key_objectid (key) != 2) ||
|
||||
(get_key_dirid (key) != 1 && get_key_objectid (key) == 2) )
|
||||
@@ -642,9 +642,13 @@ static void pass0_correct_leaf (reiserfs_filsys_t * fs,
|
||||
|
||||
/* Delete all safe links. */
|
||||
for (i = get_blkh_nr_items (B_BLK_HEAD (bh)) - 1; i >= 0; i--) {
|
||||
if (get_key_dirid (&B_N_PITEM_HEAD (bh, i)->ih_key) == ~0ul) {
|
||||
if (get_key_dirid (&B_N_PITEM_HEAD (bh, i)->ih_key) == ~(__u32)0) {
|
||||
delete_item (fs, bh, i);
|
||||
}
|
||||
if (get_key_dirid (&B_N_PITEM_HEAD (bh, i)->ih_key) == BADBLOCK_DIRID &&
|
||||
get_key_objectid (&B_N_PITEM_HEAD (bh, i)->ih_key) == BADBLOCK_OBJID) {
|
||||
delete_item (fs, bh, i);
|
||||
}
|
||||
}
|
||||
|
||||
fs_size = (__u64)fs->fs_blocksize * get_sb_block_count (fs->fs_ondisk_sb);
|
||||
|
||||
+8
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
@@ -28,10 +28,10 @@ struct buffer_head * make_buffer (int dev, unsigned long blocknr, int size, char
|
||||
|
||||
|
||||
int find_not_of_one_file(struct key * to_find, struct key * key) {
|
||||
if ((get_key_objectid (to_find) != ~0ul) &&
|
||||
if ((get_key_objectid (to_find) != ~(__u32)0) &&
|
||||
(get_key_objectid (to_find) != get_key_objectid (key)))
|
||||
return 1;
|
||||
if ((get_key_dirid (to_find) != ~0ul) &&
|
||||
if ((get_key_dirid (to_find) != ~(__u32)0) &&
|
||||
(get_key_dirid (to_find) != get_key_dirid (key)))
|
||||
return 1;
|
||||
return 0;
|
||||
@@ -246,7 +246,8 @@ static void get_max_buffer_key (struct buffer_head * bh, struct key * key)
|
||||
|
||||
int tree_is_empty (void)
|
||||
{
|
||||
return (get_sb_root_block (fs->fs_ondisk_sb) == ~0ul || get_sb_root_block (fs->fs_ondisk_sb) == 0) ? 1 : 0;
|
||||
return (get_sb_root_block (fs->fs_ondisk_sb) == ~(__u32)0 ||
|
||||
get_sb_root_block (fs->fs_ondisk_sb) == 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -543,8 +544,9 @@ static void find_allocable_blocks (reiserfs_filsys_t * fs)
|
||||
}
|
||||
|
||||
/* make allocable not leaves, not bad blocks */
|
||||
if (!is_used_leaf (i) &&
|
||||
(!fs->fs_badblocks_bm || !reiserfs_bitmap_test_bit (fs->fs_badblocks_bm, i))) {
|
||||
if (!is_used_leaf (i) && (!fs->fs_badblocks_bm ||
|
||||
!reiserfs_bitmap_test_bit (fs->fs_badblocks_bm, i)))
|
||||
{
|
||||
/* this is not leaf and it is not pointed by found indirect items,
|
||||
so it does not contains anything valuable */
|
||||
make_allocable (i);
|
||||
|
||||
+8
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
@@ -483,7 +483,7 @@ static void do_pass_2 (reiserfs_filsys_t * fs) {
|
||||
unsigned long done = 0, total;
|
||||
|
||||
|
||||
total = reiserfs_bitmap_zeros (fsck_uninsertables (fs)) * 2;
|
||||
total = reiserfs_bitmap_zeros(fsck_uninsertables(fs)) * 2;
|
||||
if (!total)
|
||||
return;
|
||||
|
||||
@@ -491,7 +491,9 @@ static void do_pass_2 (reiserfs_filsys_t * fs) {
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
j = 0;
|
||||
while (reiserfs_bitmap_find_zero_bit (fsck_uninsertables (fs), &j) == 0) {
|
||||
while ((j < fsck_uninsertables(fs)->bm_bit_size) &&
|
||||
reiserfs_bitmap_find_zero_bit(fsck_uninsertables(fs), &j) == 0)
|
||||
{
|
||||
bh = bread (fs->fs_dev, j, fs->fs_blocksize);
|
||||
if (bh == 0) {
|
||||
fsck_log ("pass_2: Reading of the block (%lu) failed on the device 0x%x\n",
|
||||
@@ -508,8 +510,8 @@ static void do_pass_2 (reiserfs_filsys_t * fs) {
|
||||
/* this must be leaf */
|
||||
what_node = who_is_this (bh->b_data, bh->b_size);
|
||||
if (what_node != THE_LEAF) { // || B_IS_KEYS_LEVEL(bh)) {
|
||||
fsck_log ("%s: The block (%b), marked as a leaf on the first two passes, is not a leaf! Will be skipped.\n",
|
||||
__FUNCTION__, bh);
|
||||
fsck_log ("%s: The block (%b), marked as a leaf on the first two passes, "
|
||||
"is not a leaf! Will be skipped.\n", __FUNCTION__, bh);
|
||||
goto cont;
|
||||
}
|
||||
/*
|
||||
@@ -622,7 +624,7 @@ void pass_2 (reiserfs_filsys_t * fs)
|
||||
|
||||
after_pass_2 (fs);
|
||||
|
||||
if (get_sb_root_block (fs->fs_ondisk_sb) == ~0ul ||
|
||||
if (get_sb_root_block (fs->fs_ondisk_sb) == ~(__u32)0 ||
|
||||
get_sb_root_block (fs->fs_ondisk_sb) == 0)
|
||||
die ( "\nNo reiserfs metadata found. If you are sure that you had the reiserfs\n"
|
||||
"on this partition, then the start of the partition might be changed\n"
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,7 @@ void pass_4_check_unaccessed_items (void)
|
||||
for (i = get_item_pos (&path), ih = get_ih (&path); i < B_NR_ITEMS (bh); i ++, ih ++) {
|
||||
if (!is_item_reachable (ih)) {
|
||||
PATH_LAST_POSITION (&path) = i;
|
||||
rdkey = get_next_key_2 (&path);
|
||||
rdkey = reiserfs_next_key(&path);
|
||||
if (rdkey)
|
||||
key = *rdkey;
|
||||
else
|
||||
|
||||
+27
-13
@@ -1,9 +1,9 @@
|
||||
.\" -*- nroff -*-
|
||||
.\" Copyright 1996-2003 Hans Reiser.
|
||||
.\" Copyright 1996-2004 Hans Reiser.
|
||||
.\"
|
||||
.TH REISERFSCK 8 "April 2003" "Reiserfsprogs-3.6.9"
|
||||
.TH REISERFSCK 8 "February 2004" "Reiserfsprogs-3.6.13"
|
||||
.SH NAME
|
||||
reiserfsck \- check a Linux Reiserfs file system
|
||||
reiserfsck \- checking tool for the ReiserFS filesystem
|
||||
.SH SYNOPSIS
|
||||
.B reiserfsck
|
||||
[ \fB-afprVy\fR ]
|
||||
@@ -13,6 +13,7 @@ reiserfsck \- check a Linux Reiserfs file system
|
||||
[ \fB-j\fR | \fB--journal\fR \fIdevice\fR ]
|
||||
[ \fB-z\fR | \fB--adjust-size\fR ]
|
||||
[ \fB-n\fR | \fB--nolog\fR ]
|
||||
[ \fB-B\fR | \fB--badblocks \fIfile\fR ]
|
||||
[ \fB-l\fR | \fB--logfile \fIfile\fR ]
|
||||
[ \fB-q\fR | \fB--quiet\fR ]
|
||||
[ \fB-y\fR | \fB--yes\fR ]
|
||||
@@ -51,11 +52,15 @@ zeroing invalid data-block pointers, correcting st_size and st_blocks
|
||||
for directories, and deleting invalid directory entries.
|
||||
.TP
|
||||
.B --rebuild-tree
|
||||
This option rebuilds the entire file system tree using leaf nodes found
|
||||
on the device. Normally you only need this option if the \fB--check\fR
|
||||
option reports "corruption that can be fixed only during \fB--rebuild-tree\fR".
|
||||
You are strongly encouraged to make a backup copy of the whole partition
|
||||
before attempting the \fB--rebuild-tree\fR option.
|
||||
This option rebuilds the entire filesystem tree using leaf nodes
|
||||
found on the device. Normally you only need this option if the
|
||||
\fBreiserfsck --check\fR reports "Running with \fB--rebuild-tree\fR
|
||||
is required". You are strongly encouraged to make a backup copy
|
||||
of the whole partition before attempting the \fB--rebuild-tree\fR
|
||||
option. Once \fBreiserfsck --rebuild-tree\fR is started it must
|
||||
finish its work (and you should not interrupt it), otherwise the
|
||||
filesystem will be left in the unmountable state to avoid subsequent
|
||||
data corruptions.
|
||||
.TP
|
||||
.B --clean-attributes
|
||||
This option cleans reserved fields of Stat-Data items.
|
||||
@@ -76,6 +81,13 @@ implies that holes at the end of a file will be removed. File
|
||||
sizes that are smaller than the offset of the last discovered
|
||||
byte are corrected by --fix-fixable.
|
||||
.TP
|
||||
\fB--badblocks \fIfile\fR, \fB-B \fI file\fR
|
||||
This option sets the badblock list to be the list of blocks specified in
|
||||
the given `file`. The filesystem badblock list is cleared before the new
|
||||
list is added. Can be used with \fB--fix-fixable\fR to fix the list of
|
||||
badblocks (see debugreiserfs -B) and must be given with \fB--rebuild-tree\fR
|
||||
option every time if the block device has bad blocks.
|
||||
.TP
|
||||
\fB--logfile \fIfile\fR, \fB-l \fI file\fR
|
||||
This option causes \fBreiserfsck\fR to report any corruption it finds
|
||||
to the specified log file rather than stderr.
|
||||
@@ -89,7 +101,7 @@ This option prevents \fBreiserfsck\fR from reporting its rate of progress.
|
||||
.B --yes, -y
|
||||
This option inhibits \fBreiserfsck\fR from asking you for confirmation after
|
||||
telling you what it is going to do, assuming yes. For safety, it does not
|
||||
work with the --rebuild-tree option.
|
||||
work with the \fB--rebuild-tree\fR option.
|
||||
.TP
|
||||
\fB-a\fR, \fB-p\fR
|
||||
These options are usually passed by fsck -A during the automatic checking
|
||||
@@ -140,9 +152,9 @@ If \fBreiserfsck --check\fR fails in some way you should also run \fBreiserfsck
|
||||
the whole partition before proceeding. Then run \fBreiserfsck --rebuild-tree
|
||||
--logfile rebuild.log /dev/hda1\fR.
|
||||
|
||||
6. If the \fB--rebuild-tree\fR step fails or does not recover what you expected,
|
||||
please submit this as a bug report. Try to provide as much information as
|
||||
possible and we will try to help solve the problem.
|
||||
6. If the \fBreiserfsck --rebuild-tree\fR step fails or does not recover what
|
||||
you expected, please submit this as a bug report. Try to provide as much
|
||||
information as possible and we will try to help solve the problem.
|
||||
.SH EXIT CODES
|
||||
\fBreiserfsck\fR uses the following exit codes:
|
||||
.br
|
||||
@@ -150,6 +162,8 @@ possible and we will try to help solve the problem.
|
||||
.br
|
||||
\ \fI1\fR \-\ File system errors corrected.
|
||||
.br
|
||||
\ \fI2\fR \-\ Reboot is needed.
|
||||
.br
|
||||
\ \fI4\fR \-\ File system fatal errors left uncorrected,
|
||||
.br
|
||||
\ \fBreiserfsck --rebuild-tree\fR needs to be launched.
|
||||
@@ -168,7 +182,7 @@ This version of \fBreiserfsck\fR has been written by Vitaly Fertman <vitaly@name
|
||||
There are likely to be some bugs. Please report bugs to the ReiserFS mail-list
|
||||
<reiserfs-list@namesys.com>.
|
||||
.SH TODO
|
||||
Faster recovering, signal handling, i/o error handling, etc.
|
||||
Faster recovering, signal handling.
|
||||
.SH SEE ALSO
|
||||
.BR mkreiserfs (8),
|
||||
.BR reiserfstune (8)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by reiserfsprogs/README
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by reiserfsprogs/README
|
||||
*/
|
||||
|
||||
#include "fsck.h"
|
||||
@@ -303,8 +303,10 @@ start_again:
|
||||
set_deh_objectid (deh, get_key_objectid (key));
|
||||
mark_buffer_dirty (bh);
|
||||
fsck_log (" - corrected\n");
|
||||
} else
|
||||
} else {
|
||||
one_more_corruption (fs, FIXABLE);
|
||||
fsck_log ("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,8 +320,10 @@ start_again:
|
||||
set_deh_objectid (deh, get_key_objectid (parent));
|
||||
mark_buffer_dirty (bh);
|
||||
fsck_log (" - corrected\n");
|
||||
} else
|
||||
} else {
|
||||
one_more_corruption (fs, FIXABLE);
|
||||
fsck_log ("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -697,7 +701,7 @@ int check_safe_links ()
|
||||
|
||||
set_key_dirid(&key, le32_to_cpu(*(__u32 *)get_item(&safe_link_path)));
|
||||
set_key_objectid(&key, get_key_objectid(&tmp_ih->ih_key));
|
||||
if ( (rkey = get_next_key_2 (&safe_link_path)) == NULL )
|
||||
if ((rkey = reiserfs_next_key(&safe_link_path)) == NULL)
|
||||
set_key_dirid (&safe_link_key, 0);
|
||||
else
|
||||
safe_link_key = *rkey;
|
||||
@@ -799,7 +803,7 @@ void semantic_check (void)
|
||||
fsck_allocable_bitmap (fs) = NULL;
|
||||
set_sb_free_blocks (fs->fs_ondisk_sb, reiserfs_bitmap_zeros (fs->fs_bitmap2));
|
||||
mark_buffer_dirty (fs->fs_super_bh);
|
||||
add_badblock_list(fs, 0);
|
||||
add_badblock_list(fs, 1);
|
||||
}
|
||||
|
||||
fsck_progress ("finished\n");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
@@ -105,7 +105,7 @@ int wrong_st_size (struct key * key, unsigned long long max_file_size,
|
||||
if (type == TYPE_DIRENTRY) {
|
||||
/* directory size must match to the sum of length of its entries */
|
||||
fsck_log ("vpf-10650: The directory %K has the wrong size in the StatData "
|
||||
"(%Ld)%s(%Ld)\n", key, sd_size, fsck_mode(fs) == FSCK_CHECK ?
|
||||
"(%Lu)%s(%Lu)\n", key, sd_size, fsck_mode(fs) == FSCK_CHECK ?
|
||||
", should be " : " - corrected to ", *size);
|
||||
return 1;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ int wrong_st_size (struct key * key, unsigned long long max_file_size,
|
||||
if (fsck_adjust_file_size (fs) || type == TYPE_SYMLINK) {
|
||||
/* but it -o is given - fix that */
|
||||
fsck_log ("vpf-10660: The file %K has too big size in the StatData "
|
||||
"(%Ld)%s(%Ld)\n", key, sd_size, fsck_mode(fs) == FSCK_CHECK ?
|
||||
"(%Lu)%s(%Lu)\n", key, sd_size, fsck_mode(fs) == FSCK_CHECK ?
|
||||
", should be " : " - corrected to ", *size);
|
||||
sem_pass_stat (fs)->fixed_sizes ++;
|
||||
return 1;
|
||||
@@ -145,7 +145,7 @@ int wrong_st_size (struct key * key, unsigned long long max_file_size,
|
||||
}
|
||||
}
|
||||
|
||||
fsck_log ("vpf-10670: The file %K has the wrong size in the StatData (%Ld)%s(%Ld)\n", key,
|
||||
fsck_log ("vpf-10670: The file %K has the wrong size in the StatData (%Lu)%s(%Lu)\n", key,
|
||||
sd_size, fsck_mode(fs) == FSCK_CHECK ? ", should be " : " - corrected to ",
|
||||
*size);
|
||||
sem_pass_stat (fs)->fixed_sizes ++;
|
||||
|
||||
+22
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 2001-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(HAVE_LIBUUID) && defined(HAVE_UUID_UUID_H)
|
||||
# include <uuid/uuid.h>
|
||||
#endif
|
||||
|
||||
#define fsck_conditional_log(sb_found, fmt, list...) { \
|
||||
if (sb_found) \
|
||||
fsck_log(fmt, ## list); \
|
||||
@@ -189,6 +193,12 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
struct stat64 stat_buf;
|
||||
int retval, exit_code = EXIT_OK;
|
||||
|
||||
#if defined(HAVE_LIBUUID) && defined(HAVE_UUID_UUID_H)
|
||||
char uuid[37];
|
||||
|
||||
uuid[36] = '\0';
|
||||
#endif
|
||||
|
||||
if (!no_reiserfs_found (fs)) {
|
||||
sb = getmem (sizeof (*sb));
|
||||
if (!is_opened_rw (fs)) {
|
||||
@@ -305,13 +315,12 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
getline (&answer, &n, stdin);
|
||||
if (strcmp ("\n", answer))
|
||||
block_count = atoi (answer);
|
||||
set_sb_block_count (sb, block_count);
|
||||
} else {
|
||||
fsck_conditional_log (magic_was_found, "rebuild-sb: wrong block count "
|
||||
"occured (%lu), fixed (%lu)\n", get_sb_block_count(sb), block_count);
|
||||
|
||||
set_sb_block_count (sb, block_count);
|
||||
}
|
||||
|
||||
set_sb_block_count (sb, block_count);
|
||||
}
|
||||
|
||||
if (get_sb_block_size (sb) != fs->fs_blocksize) {
|
||||
@@ -491,14 +500,13 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
}
|
||||
|
||||
if (version == 1 || version == 3) {
|
||||
if (!uuid_is_correct(sb->s_uuid)) {
|
||||
if (generate_random_uuid (sb->s_uuid)) {
|
||||
fsck_log ("rebuild-sb: no uuid found, failed to genetate UUID\n");
|
||||
} else {
|
||||
fsck_log ("rebuild-sb: no uuid found, a new uuid generated (%U)\n",
|
||||
sb->s_uuid);
|
||||
}
|
||||
#if defined(HAVE_LIBUUID) && defined(HAVE_UUID_UUID_H)
|
||||
if (uuid_is_null(sb->s_uuid)) {
|
||||
uuid_generate(sb->s_uuid);
|
||||
fsck_log ("rebuild-sb: no uuid found, a new uuid was "
|
||||
"generated (%U)\n", sb->s_uuid);
|
||||
}
|
||||
#endif
|
||||
if (sb->s_flags != 0 && sb->s_flags != 1) {
|
||||
fsck_log ("rebuild-sb: super block flags found (%u), zeroed\n",
|
||||
sb->s_flags);
|
||||
@@ -557,10 +565,10 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
}
|
||||
|
||||
if ((retval = reiserfs_open_journal(fs, filename, O_RDWR | O_LARGEFILE))) {
|
||||
fsck_log("\nrebuild-sb: Failed to open the journal device (%s).",
|
||||
fsck_log("\nrebuild-sb: Failed to open the journal device (%s).\n",
|
||||
filename);
|
||||
|
||||
exit(retval == 1 ? EXIT_USER : EXIT_OPER);
|
||||
exit(retval < 0 ? EXIT_OPER : EXIT_USER);
|
||||
}
|
||||
} else if (!fsck_skip_journal(fs)) {
|
||||
/* Check that specified non-standard journal device exists. */
|
||||
@@ -674,7 +682,7 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
fsck_log("\nrebuild-sb: Failed to open a journal device (%s).",
|
||||
journal_dev_name);
|
||||
|
||||
exit(retval == 1 ? EXIT_USER : EXIT_OPER);
|
||||
exit(retval < 0 ? EXIT_OPER : EXIT_USER);
|
||||
}
|
||||
|
||||
/* SB was found, but journal params were broken and have been recovered.
|
||||
@@ -760,8 +768,6 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
set_jp_journal_magic (&j_head->jh_journal, magic);
|
||||
|
||||
}
|
||||
} else {
|
||||
set_jp_journal_magic (sb_jp(sb), 0);
|
||||
}
|
||||
|
||||
retval = memcmp(&j_head->jh_journal, sb_jp(sb), sizeof(struct journal_params));
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
@@ -225,7 +225,7 @@ int are_file_items_correct (struct item_head * sd_ih, void * sd, __u64 * size, _
|
||||
}
|
||||
|
||||
// does not change path
|
||||
next_key = get_next_key_2 (&path);
|
||||
next_key = reiserfs_next_key(&path);
|
||||
|
||||
if (next_key == 0 || not_of_one_file (key, next_key) ||
|
||||
(!is_indirect_key (next_key) && !is_direct_key(next_key)))
|
||||
|
||||
+8
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
when --rebuild-tree - fsck builds map of objectids it inserts into tree */
|
||||
|
||||
#define ALLOC_SIZE 1024
|
||||
#define MAX_ID (~0ul)
|
||||
#define MAX_ID (~(__u32)0)
|
||||
|
||||
/* 2 bytes for the counter */
|
||||
#define BM_SIZE (ALLOC_SIZE - sizeof(__u16))
|
||||
@@ -21,10 +21,12 @@
|
||||
|
||||
#define id_map_local_count(interval) (interval + BM_SIZE)
|
||||
|
||||
/*
|
||||
typedef struct sb_id_map {
|
||||
__u32 * m_begin;
|
||||
__u32 m_size, m_used_slot_count;
|
||||
} sb_id_map_t;
|
||||
*/
|
||||
|
||||
id_map_t *id_map_init() {
|
||||
id_map_t *map;
|
||||
@@ -103,7 +105,7 @@ int id_map_mark(id_map_t *map, __u32 id) {
|
||||
/* call this for proper_id_map only!! */
|
||||
__u32 id_map_alloc(id_map_t *map) {
|
||||
__u32 i, zero_count;
|
||||
__u32 id = 0, first = ~0ul;
|
||||
__u32 id = 0, first = ~(__u32)0;
|
||||
|
||||
for (i = 0, zero_count = 0; zero_count < 10 && i < INDEX_COUNT - 1; i++) {
|
||||
if (map->index[i] == (void *)0) {
|
||||
@@ -121,7 +123,7 @@ __u32 id_map_alloc(id_map_t *map) {
|
||||
die ("Id is out of interval size, interval looks corrupted.");
|
||||
|
||||
id += i * BM_INTERVAL;
|
||||
} else if (first != ~0ul) {
|
||||
} else if (first != ~(__u32)0) {
|
||||
id = first * BM_INTERVAL;
|
||||
if (id == 0)
|
||||
id = 2;
|
||||
@@ -232,7 +234,7 @@ void id_map_flush(struct id_map * map, reiserfs_filsys_t * fs) {
|
||||
if (map->index[map->last_used] == (void *)1) {
|
||||
prev_id = BM_INTERVAL - 1;
|
||||
} else {
|
||||
prev_id = ~0ul;
|
||||
prev_id = ~(__u32)0;
|
||||
|
||||
if (id < map->last_used * BM_INTERVAL)
|
||||
id = 0;
|
||||
@@ -248,7 +250,7 @@ void id_map_flush(struct id_map * map, reiserfs_filsys_t * fs) {
|
||||
prev_id = id;
|
||||
}
|
||||
|
||||
if (prev_id == ~0ul)
|
||||
if (prev_id == ~(__u32)0)
|
||||
die ("Objectid interval does not contain any set bit what is expected.");
|
||||
|
||||
prev_id++;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2003 by Hans Reiser, licensing governed by
|
||||
* Copyright 1996-2004 by Hans Reiser, licensing governed by
|
||||
* reiserfsprogs/README
|
||||
*/
|
||||
|
||||
|
||||
Reference in new issue
Block a user