Imported reiserfsprogs-3.6.19
This commit is contained in:
1 parent
3078c83c48
commit
0ed773997f
34 files changed
+724
-560
No files matched your search
+22
-4
@@ -541,8 +541,8 @@ static int bad_directory_item (reiserfs_filsys_t * fs,
|
||||
struct buffer_head * bh,
|
||||
struct item_head * ih)
|
||||
{
|
||||
char * name;
|
||||
int namelen;
|
||||
char *name, *prev_name;
|
||||
__u32 off, prev_off;
|
||||
unsigned int count, i;
|
||||
struct reiserfs_de_head * deh = B_I_DEH (bh, ih);
|
||||
int min_entry_size = 1;/* We have no way to understand whether the
|
||||
@@ -550,6 +550,7 @@ static int bad_directory_item (reiserfs_filsys_t * fs,
|
||||
converted to it. So, we assume that minimal name
|
||||
length is 1 */
|
||||
__u16 state;
|
||||
int namelen;
|
||||
|
||||
count = get_ih_entry_count (ih);
|
||||
|
||||
@@ -580,17 +581,34 @@ static int bad_directory_item (reiserfs_filsys_t * fs,
|
||||
}
|
||||
|
||||
/* check name hashing */
|
||||
prev_name = B_I_PITEM(bh, ih) + get_ih_item_len(ih);
|
||||
prev_off = 0;
|
||||
|
||||
for (i = 0; i < count; i ++, deh ++) {
|
||||
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))) {
|
||||
off = get_deh_offset (deh);
|
||||
|
||||
if (namelen > (int)REISERFS_MAX_NAME_LEN(fs->fs_blocksize) ||
|
||||
name >= prev_name || off <= prev_off)
|
||||
{
|
||||
fsck_log ("%s: block %lu: The directory item %k has a broken entry "
|
||||
"(%d)\n", __FUNCTION__, bh->b_blocknr, &ih->ih_key, i);
|
||||
one_more_corruption (fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!is_properly_hashed (fs, name, namelen, off)) {
|
||||
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);
|
||||
one_more_corruption (fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
prev_name = name;
|
||||
prev_off = off;
|
||||
}
|
||||
|
||||
deh = B_I_DEH (bh, ih);
|
||||
|
||||
+27
-19
@@ -228,6 +228,7 @@ static char * parse_options (struct fsck_data * data, int argc, char * argv [])
|
||||
|
||||
case 'a':
|
||||
case 'p':
|
||||
data->options |= OPT_QUIET;
|
||||
mode = FSCK_AUTO;
|
||||
break;
|
||||
|
||||
@@ -673,7 +674,8 @@ static void mark_filesystem_consistent (reiserfs_filsys_t * fs)
|
||||
if (!reiserfs_journal_opened (fs)) {
|
||||
/* make sure journal is not standard */
|
||||
if (!is_reiserfs_jr_magic_string (fs->fs_ondisk_sb))
|
||||
die ("Filesystem with default journal must be opened.");
|
||||
reiserfs_exit(EXIT_OPER, "Filesystem with default journal "
|
||||
"must be opened.");
|
||||
|
||||
fsck_progress ("WARNING: You must use reiserfstune to specify a new "
|
||||
"journal before mounting it.\n");
|
||||
@@ -785,13 +787,17 @@ static void prepare_fs_for_check(reiserfs_filsys_t * fs) {
|
||||
/* 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);
|
||||
reiserfs_exit(EXIT_OPER, "Failed to lock the process to "
|
||||
"fsck the mounted ro partition. %s.\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
if (fsck_skip_journal (fs)) {
|
||||
reiserfs_exit(EXIT_USER, "Jounrnal of the mounted "
|
||||
"filesystem must be specified.\n");
|
||||
}
|
||||
|
||||
if (!reiserfs_journal_opened (fs)) {
|
||||
/* just to make sure */
|
||||
reiserfs_panic ("Journal is not opened");
|
||||
@@ -879,7 +885,7 @@ static void clean_attributes (reiserfs_filsys_t * fs) {
|
||||
time (&t);
|
||||
|
||||
if (get_sb_umount_state (fs->fs_ondisk_sb) != FS_CLEANLY_UMOUNTED) {
|
||||
fsck_progress ("Filesystem does not look cleanly umounted\n"
|
||||
fsck_progress ("Filesystem is not clean\n"
|
||||
"Check consistency of the partition first.\n");
|
||||
exit(EXIT_USER);
|
||||
}
|
||||
@@ -1227,8 +1233,9 @@ int main (int argc, char * argv [])
|
||||
'fsck.run'. Logs get there if log file was not specified*/
|
||||
data->options |= OPT_QUIET;
|
||||
data->progress = fopen ("fsck.run", "a+");
|
||||
if (!data->progress)
|
||||
reiserfs_panic ("reiserfsck: Cannot not open \"fsck.run\"");
|
||||
if (!data->progress) {
|
||||
reiserfs_exit(EXIT_OPER, "reiserfsck: Cannot not open \"fsck.run\"");
|
||||
}
|
||||
|
||||
if (data->log == stdout)
|
||||
/* no log file specifed - redirect log into 'fsck.run' */
|
||||
@@ -1255,19 +1262,20 @@ int main (int argc, char * argv [])
|
||||
} else {
|
||||
fs = reiserfs_open (file_name, O_RDONLY, &error, data,
|
||||
data->mode != FSCK_SB);
|
||||
|
||||
|
||||
if (error) {
|
||||
reiserfs_exit(EXIT_OPER, "Failed to open the device "
|
||||
"'%s': %s\n\n", file_name, strerror(error));
|
||||
}
|
||||
|
||||
if (data->mode != FSCK_SB) {
|
||||
if (no_reiserfs_found (fs)) {
|
||||
if (error) {
|
||||
die ("Failed to open the device '%s': %s\n\n",
|
||||
file_name, strerror(error));
|
||||
} 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");
|
||||
}
|
||||
reiserfs_exit(EXIT_OPER, "Failed to open the filesystem.\n\n"
|
||||
"If the partition table has not been changed, "
|
||||
"and the partition is\nvalid 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))
|
||||
|
||||
+25
-11
@@ -365,8 +365,7 @@ static int verify_directory_item (reiserfs_filsys_t * fs, struct buffer_head * b
|
||||
hash_code = 0;
|
||||
|
||||
for (j = min_length; j <= max_length; j ++) {
|
||||
hash_code = find_hash_in_use (name, j,
|
||||
GET_HASH_VALUE (get_deh_offset (deh + i)),
|
||||
hash_code = find_hash_in_use (name, j, get_deh_offset (deh + i),
|
||||
get_sb_hash_code (fs->fs_ondisk_sb));
|
||||
/* add_hash_hit (fs, hash_code);*/
|
||||
if (code2func (hash_code) != 0) {
|
||||
@@ -527,9 +526,11 @@ static int verify_directory_item (reiserfs_filsys_t * fs, struct buffer_head * b
|
||||
}
|
||||
}
|
||||
|
||||
if (bad == get_ih_entry_count (&tmp) && lost_found != bad) {
|
||||
fsck_log ("%s: block %lu, item %H: All entries were deleted from the directory\n",
|
||||
__FUNCTION__, bh->b_blocknr, &tmp);
|
||||
if (bad == get_ih_entry_count (&tmp)) {
|
||||
if (lost_found != bad) {
|
||||
fsck_log ("%s: block %lu, item %H: All entries were deleted from the directory\n",
|
||||
__FUNCTION__, bh->b_blocknr, &tmp);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -586,6 +587,9 @@ int leaf_structure_check (reiserfs_filsys_t * fs, struct buffer_head * bh) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (get_blkh_nr_items (blkh) == 0)
|
||||
return 0;
|
||||
|
||||
counted = leaf_count_ih(bh->b_data, bh->b_size);
|
||||
|
||||
if (counted < get_blkh_nr_items (blkh)) {
|
||||
@@ -1770,12 +1774,19 @@ static void init_source_bitmap (reiserfs_filsys_t * fs)
|
||||
|
||||
case EXTERN_BITMAP:
|
||||
fp = fopen (fsck_data (fs)->rebuild.bitmap_file_name, "r");
|
||||
if (!fp)
|
||||
reiserfs_panic ("Could not load bitmap: %s\n", strerror(errno));
|
||||
|
||||
if (!fp) {
|
||||
reiserfs_exit (EXIT_OPER, "Could not load bitmap: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
fsck_source_bitmap (fs) = reiserfs_bitmap_load (fp);
|
||||
if (!fsck_source_bitmap (fs))
|
||||
reiserfs_panic ("Could not load fitmap from \"%s\"",
|
||||
fsck_data (fs)->rebuild.bitmap_file_name);
|
||||
|
||||
if (!fsck_source_bitmap (fs)) {
|
||||
reiserfs_exit (EXIT_OPER, "Could not load fitmap from \"%s\"",
|
||||
fsck_data (fs)->rebuild.bitmap_file_name);
|
||||
}
|
||||
|
||||
fsck_progress ("%d blocks marked used in extern bitmap\n",
|
||||
reiserfs_bitmap_ones (fsck_source_bitmap (fs)));
|
||||
fclose (fp);
|
||||
@@ -1967,7 +1978,10 @@ void pass_0 (reiserfs_filsys_t * fs)
|
||||
{
|
||||
if (get_reiserfs_format (fs->fs_ondisk_sb) != fs->fs_format ||
|
||||
get_reiserfs_format (fs->fs_ondisk_sb) == REISERFS_FORMAT_UNKNOWN)
|
||||
reiserfs_panic ("pass 0: ReiserFS format version mismatch found, you should run --rebuild-sb");
|
||||
{
|
||||
reiserfs_exit (EXIT_OPER, "pass 0: ReiserFS format version mismatch "
|
||||
"found, you should run --rebuild-sb");
|
||||
}
|
||||
|
||||
fsck_progress ("\nPass 0:\n");
|
||||
if (fsck_log_file (fs) != stderr)
|
||||
|
||||
+19
-2
@@ -349,11 +349,13 @@ static void pass1_correct_leaf (reiserfs_filsys_t * fs,
|
||||
for (i = 0; i < B_NR_ITEMS (bh); i ++, ih ++) {
|
||||
if (is_direntry_ih (ih)) {
|
||||
struct reiserfs_de_head * deh;
|
||||
__u32 offset;
|
||||
char * name;
|
||||
int name_len;
|
||||
unsigned int hash_code;
|
||||
|
||||
deh = B_I_DEH (bh, ih);
|
||||
offset = 0;
|
||||
for (j = 0; j < get_ih_entry_count (ih); j ++) {
|
||||
name = name_in_entry (deh + j, j);
|
||||
name_len = name_in_entry_length (ih, deh + j, j);
|
||||
@@ -363,8 +365,7 @@ static void pass1_correct_leaf (reiserfs_filsys_t * fs,
|
||||
continue;
|
||||
}
|
||||
|
||||
hash_code = find_hash_in_use (name, name_len,
|
||||
GET_HASH_VALUE (get_deh_offset (deh + j)),
|
||||
hash_code = find_hash_in_use (name, name_len, get_deh_offset (deh + j),
|
||||
get_sb_hash_code (fs->fs_ondisk_sb));
|
||||
if (hash_code != get_sb_hash_code (fs->fs_ondisk_sb)) {
|
||||
fsck_log ("pass1: block %lu, item %d, entry %d: The entry \"%.*s\" of the %k is hashed with %s "
|
||||
@@ -381,8 +382,24 @@ static void pass1_correct_leaf (reiserfs_filsys_t * fs,
|
||||
fsck_log(" - deleted\n");
|
||||
j --;
|
||||
deh = B_I_DEH (bh, ih);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (j && offset >= get_deh_offset (deh + j)) {
|
||||
fsck_log ("pass1: block %lu, item %d, entry %d: The entry "
|
||||
"\"%.*s\" of the %k has hash offset %lu not "
|
||||
"larger smaller than the previous one %lu. The "
|
||||
"entry is deleted.\n", bh->b_blocknr,
|
||||
i, j, name_len, name, &ih->ih_key,
|
||||
get_deh_offset(deh + j), offset);
|
||||
cut_entry (fs, bh, i, j, 1);
|
||||
j --;
|
||||
deh = B_I_DEH (bh, ih);
|
||||
continue;
|
||||
}
|
||||
|
||||
offset = get_deh_offset (deh + j);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
.\" -*- nroff -*-
|
||||
.\" Copyright 1996-2004 Hans Reiser.
|
||||
.\"
|
||||
.TH REISERFSCK 8 "February 2004" "Reiserfsprogs-3.6.18"
|
||||
.TH REISERFSCK 8 "February 2004" "Reiserfsprogs-3.6.19"
|
||||
.SH NAME
|
||||
reiserfsck \- The checking tool for the ReiserFS filesystem.
|
||||
.SH SYNOPSIS
|
||||
|
||||
@@ -172,7 +172,8 @@ int wrong_st_blocks (struct key * key, __u32 * blocks, __u32 sd_blocks, __u16 mo
|
||||
int ret = 0;
|
||||
|
||||
if (S_ISREG (mode) || S_ISLNK (mode) || S_ISDIR (mode)) {
|
||||
if (*blocks != sd_blocks) {
|
||||
if ((!S_ISLNK(mode) && *blocks != sd_blocks) ||
|
||||
(S_ISLNK(mode) && *blocks != sd_blocks && (ROUND_UP(*blocks) != sd_blocks))) {
|
||||
fsck_log ("vpf-10680: The %s %K has the wrong block count in the StatData "
|
||||
"(%u)%s(%u)\n", S_ISDIR (mode) ? "directory" : S_ISREG (mode) ? "file" : "link", key, sd_blocks,
|
||||
fsck_mode(fs) == FSCK_CHECK ? ", should be " : " - corrected to ", *blocks);
|
||||
|
||||
+9
-5
@@ -220,7 +220,8 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
fs->fs_blocksize = retval;
|
||||
}
|
||||
|
||||
block_count = count_blocks (filename, fs->fs_blocksize);
|
||||
if (!(block_count = count_blocks (filename, fs->fs_blocksize)))
|
||||
exit(EXIT_OPER);
|
||||
|
||||
/* save ondisk_sb somewhere and work in temp area */
|
||||
ondisk_sb = fs->fs_ondisk_sb;
|
||||
@@ -358,7 +359,8 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
retval = 4096;
|
||||
}
|
||||
|
||||
block_count = count_blocks (filename, retval);
|
||||
if (!(block_count = count_blocks (filename, retval)))
|
||||
exit(EXIT_OPER);
|
||||
|
||||
switch(version){
|
||||
case 1:
|
||||
@@ -601,8 +603,8 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
}
|
||||
|
||||
if (!reiserfs_journal_opened(fs)) {
|
||||
fsck_log ("Journal cannot be opened, assuming specified journal device "
|
||||
"is correct\n");
|
||||
fsck_log ("Journal cannot be opened, assuming specified "
|
||||
"journal device is correct\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,7 +631,9 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
} else
|
||||
set_jp_journal_1st_block (sb_jp(sb), default_value);
|
||||
|
||||
p_jp_dev_size = count_blocks (journal_dev_name, fs->fs_blocksize);
|
||||
if (!(p_jp_dev_size = count_blocks (journal_dev_name, fs->fs_blocksize)))
|
||||
exit(EXIT_OPER);
|
||||
|
||||
/* some checks for journal offset */
|
||||
if (strcmp(fs->fs_file_name, journal_dev_name) != 0) {
|
||||
if (p_jp_dev_size < get_jp_journal_1st_block (sb_jp(sb)) + 1)
|
||||
|
||||
Reference in new issue
Block a user