Imported reiserfsprogs-3.6.18
This commit is contained in:
1 parent
18057cdad6
commit
3078c83c48
64 files changed
+6508
-1071
No files matched your search
+21
-7
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.7.2 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.7.6 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
|
||||
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
|
||||
# Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -35,6 +35,7 @@ POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_triplet = @host@
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMDEP_FALSE = @AMDEP_FALSE@
|
||||
AMDEP_TRUE = @AMDEP_TRUE@
|
||||
@@ -63,7 +64,11 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
|
||||
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
@@ -85,12 +90,21 @@ ac_ct_STRIP = @ac_ct_STRIP@
|
||||
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
|
||||
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
datadir = @datadir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
@@ -117,6 +131,7 @@ EXTRA_DIST = $(man_MANS)
|
||||
|
||||
reiserfsck_LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
|
||||
subdir = fsck
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/include/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
@@ -161,10 +176,10 @@ all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o .obj
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu fsck/Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
|
||||
sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
install-sbinPROGRAMS: $(sbin_PROGRAMS)
|
||||
@@ -222,7 +237,7 @@ distclean-depend:
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
|
||||
@am__fastdepCC_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
|
||||
@am__fastdepCC_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
|
||||
@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
|
||||
@am__fastdepCC_TRUE@ fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@@ -233,7 +248,7 @@ distclean-depend:
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
|
||||
@am__fastdepCC_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
|
||||
@am__fastdepCC_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
|
||||
@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
|
||||
@am__fastdepCC_TRUE@ fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@@ -380,7 +395,6 @@ all-am: Makefile $(PROGRAMS) $(MANS)
|
||||
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(man8dir)
|
||||
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
|
||||
+92
-26
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "fsck.h"
|
||||
|
||||
#if 0
|
||||
struct check_relocated {
|
||||
__u32 old_dir_id;
|
||||
__u32 old_objectid;
|
||||
@@ -82,6 +83,8 @@ void clear_relocated_list() {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -351,12 +354,11 @@ static int bad_stat_data (reiserfs_filsys_t * fs,
|
||||
|
||||
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);
|
||||
|
||||
if (fsck_mode (fs) == FSCK_FIX_FIXABLE)
|
||||
to_be_relocated (&ih->ih_key);
|
||||
|
||||
"files. Can be fixed with --rebuild-tree only.\n", objectid);
|
||||
#if 0
|
||||
to_be_relocated (&ih->ih_key);
|
||||
// one_more_corruption (fs, FIXABLE);
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -392,11 +394,11 @@ static int bad_direct_item (reiserfs_filsys_t * fs,
|
||||
|
||||
inline void handle_one_pointer (reiserfs_filsys_t * fs,
|
||||
struct buffer_head * bh,
|
||||
__u32 * ptr)
|
||||
__u32 * item, int offset)
|
||||
{
|
||||
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
|
||||
fsck_log (" - zeroed");
|
||||
*ptr = 0;
|
||||
d32_put (item, offset, 0);
|
||||
mark_buffer_dirty (bh);
|
||||
} else {
|
||||
one_more_corruption (fs, FIXABLE);
|
||||
@@ -421,7 +423,7 @@ static int bad_badblocks_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < I_UNFM_NUM (ih); i ++) {
|
||||
if (!le32_to_cpu (ind [i])) {
|
||||
if (!d32_get (ind, i)) {
|
||||
/* fsck_log ("%s: block %lu: badblocks item (%H) has zero pointer.",
|
||||
__FUNCTION__, bh->b_blocknr, ih);
|
||||
|
||||
@@ -435,14 +437,14 @@ static int bad_badblocks_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
}
|
||||
|
||||
/* check list of badblocks pointers */
|
||||
if (le32_to_cpu (ind [i]) >= get_sb_block_count (fs->fs_ondisk_sb)) {
|
||||
if (d32_get (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]));
|
||||
handle_one_pointer (fs, bh, &ind[i]);
|
||||
__FUNCTION__, bh->b_blocknr, d32_get (ind, i));
|
||||
handle_one_pointer (fs, bh, ind, i);
|
||||
fsck_log ("\n");
|
||||
}
|
||||
|
||||
if (did_we_meet_it (le32_to_cpu (ind [i]))) {
|
||||
if (did_we_meet_it (d32_get (ind, i))) {
|
||||
/* it can be
|
||||
1. not_data_block
|
||||
delete pointer
|
||||
@@ -450,23 +452,23 @@ static int bad_badblocks_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
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]))) {
|
||||
if (not_data_block (fs, d32_get (ind, i))) {
|
||||
fsck_log ("%s: badblock pointer (block %lu) points on fs metadata (%lu)",
|
||||
__FUNCTION__, bh->b_blocknr, le32_to_cpu (ind [i]));
|
||||
handle_one_pointer (fs, bh, &ind[i]);
|
||||
__FUNCTION__, bh->b_blocknr, d32_get (ind, i));
|
||||
handle_one_pointer (fs, bh, ind, i);
|
||||
fsck_log ("\n");
|
||||
} else {
|
||||
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]));
|
||||
d32_get (ind, i));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
we_met_it(le32_to_cpu(ind[i]));
|
||||
we_met_it(d32_get(ind, i));
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -488,33 +490,31 @@ static int bad_indirect_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
|
||||
}
|
||||
|
||||
for (i = 0; i < I_UNFM_NUM (ih); i ++) {
|
||||
// __u32 unfm_ptr;
|
||||
|
||||
fsck_check_stat (fs)->unfm_pointers ++;
|
||||
// unfm_ptr = le32_to_cpu (ind [i]);
|
||||
if (!le32_to_cpu (ind [i])) {
|
||||
if (!d32_get (ind, i)) {
|
||||
fsck_check_stat (fs)->zero_unfm_pointers ++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* check unformatted node pointer and mark it used in the
|
||||
control bitmap */
|
||||
if (bad_block_number (fs, le32_to_cpu (ind [i]))) {
|
||||
if (bad_block_number (fs, d32_get (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]));
|
||||
&ih->ih_key, i, d32_get (ind, i));
|
||||
|
||||
handle_one_pointer (fs, bh, &ind[i]);
|
||||
handle_one_pointer (fs, bh, ind, i);
|
||||
fsck_log ("\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (got_already (fs, le32_to_cpu (ind [i]))) {
|
||||
if (got_already (fs, d32_get (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]));
|
||||
__FUNCTION__, bh->b_blocknr, ih, i, d32_get (ind, i));
|
||||
|
||||
handle_one_pointer (fs, bh, &ind [i]);
|
||||
handle_one_pointer (fs, bh, ind, i);
|
||||
fsck_log ("\n");
|
||||
continue;
|
||||
}
|
||||
@@ -856,6 +856,72 @@ static inline int h_to_level (reiserfs_filsys_t * fs, int h)
|
||||
return get_sb_tree_height (fs->fs_ondisk_sb) - h - 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int dc_fix(struct buffer_head *bh, int pos, __u32 block) {
|
||||
if (!bh || !bh->b_data)
|
||||
return -1;
|
||||
|
||||
if (B_NR_ITEMS(bh) < pos)
|
||||
return -1;
|
||||
|
||||
set_dc_child_blocknr(B_N_CHILD(bh,pos), block);
|
||||
|
||||
mark_buffer_dirty(bh);
|
||||
bwrite(bh);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Removes @N-th key and @(N+1) pointer. */
|
||||
int internal_remove(struct buffer_head *bh, int pos) {
|
||||
char *delete;
|
||||
__u32 nr;
|
||||
|
||||
if (!bh || !bh->b_data)
|
||||
return -1;
|
||||
|
||||
if (B_NR_ITEMS(bh) < pos)
|
||||
return -1;
|
||||
|
||||
delete = (char *)B_N_CHILD(bh, pos + 2);
|
||||
memmove(delete - DC_SIZE, delete,
|
||||
bh->b_size - (delete - bh->b_data));
|
||||
|
||||
delete = (char *)B_N_PDELIM_KEY(bh, pos + 1);
|
||||
memmove(delete - KEY_SIZE, delete,
|
||||
bh->b_size - (delete - bh->b_data));
|
||||
|
||||
nr = B_NR_ITEMS(bh) - 1;
|
||||
|
||||
set_blkh_nr_items(B_BLK_HEAD(bh), nr);
|
||||
set_blkh_free_space(B_BLK_HEAD(bh), bh->b_size -
|
||||
(BLKH_SIZE + KEY_SIZE * nr + DC_SIZE * (nr + 1)));
|
||||
|
||||
mark_buffer_dirty(bh);
|
||||
bwrite(bh);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int leaf_fix_key_oid(struct buffer_head *bh, int pos, __u32 oid) {
|
||||
struct item_head * ih;
|
||||
|
||||
|
||||
if (!bh || !bh->b_data)
|
||||
return -1;
|
||||
|
||||
if (B_NR_ITEMS(bh) < pos)
|
||||
return -1;
|
||||
|
||||
ih = B_N_PITEM_HEAD (bh, pos);
|
||||
set_key_objectid(&ih->ih_key, oid);
|
||||
|
||||
mark_buffer_dirty(bh);
|
||||
bwrite(bh);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* bh must be formatted node. blk_level must be tree_height - h + 1 */
|
||||
static int bad_node (reiserfs_filsys_t * fs, struct buffer_head ** path, int h)
|
||||
|
||||
+10
-18
@@ -5,24 +5,19 @@
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <asm/types.h>
|
||||
#include <sys/vfs.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <asm/types.h>
|
||||
#include <assert.h>
|
||||
#ifndef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "io.h"
|
||||
#include "misc.h"
|
||||
#include "reiserfs_lib.h"
|
||||
|
||||
#include "../include/config.h"
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../version.h"
|
||||
|
||||
/* main.c */
|
||||
@@ -210,9 +205,11 @@ void do_clean_attributes (reiserfs_filsys_t * fs);
|
||||
int bad_pair (reiserfs_filsys_t *, struct buffer_head * bh, int i);
|
||||
int bad_leaf_2 (reiserfs_filsys_t *, struct buffer_head * bh);
|
||||
|
||||
#if 0
|
||||
extern int should_be_relocated (struct key * key);
|
||||
extern void to_be_relocated (struct key * key);
|
||||
extern void clear_relocated_list(void);
|
||||
#endif
|
||||
|
||||
/* ustree.c */
|
||||
void reiserfsck_paste_into_item (struct path * path, const char * body, int size);
|
||||
@@ -231,10 +228,6 @@ typedef int do_after_read_t (reiserfs_filsys_t *, struct buffer_head **, int h);
|
||||
typedef int do_on_full_path_t (reiserfs_filsys_t *, struct buffer_head **, int);
|
||||
void pass_through_tree (reiserfs_filsys_t *, do_after_read_t, do_on_full_path_t, int depth);
|
||||
|
||||
//int comp_keys_3 (void * key1, void * key2);
|
||||
//int comp_dir_entries (void * key1, void * key2);
|
||||
|
||||
|
||||
/* bitmap.c */
|
||||
int reiserfsck_reiserfs_new_blocknrs (reiserfs_filsys_t * fs,
|
||||
unsigned long * pblocknrs,
|
||||
@@ -250,7 +243,6 @@ int is_block_uninsertable (unsigned long block);
|
||||
|
||||
/* objectid.c */
|
||||
int comp_ids(const void *p1, const void *p2);
|
||||
int is_objectid_used (reiserfs_filsys_t *, __u32 objectid);
|
||||
|
||||
typedef struct id_map {
|
||||
void **index;
|
||||
|
||||
+9
-13
@@ -7,6 +7,7 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/mman.h>
|
||||
#include <signal.h>
|
||||
|
||||
extern int screen_width;
|
||||
extern int screen_savebuffer_len;
|
||||
@@ -334,7 +335,7 @@ void warn_what_will_be_done (char * file_name, struct fsck_data * data)
|
||||
{
|
||||
FILE * warn_to;
|
||||
|
||||
warn_to = (data->progress ?: stderr);
|
||||
warn_to = (data->progress ? data->progress : stderr);
|
||||
|
||||
if (data->mode == FSCK_REBUILD)
|
||||
reiserfs_warning (warn_to, REBUILD_WARNING, file_name);
|
||||
@@ -412,7 +413,7 @@ void warn_what_will_be_done (char * file_name, struct fsck_data * data)
|
||||
|
||||
reiserfs_warning (warn_to, "Will put log info to '%s'\n",
|
||||
(data->log == stdout) ? "stdout" :
|
||||
(data->log_file_name ? : "fsck.run"));
|
||||
(data->log_file_name ? data->log_file_name : "fsck.run"));
|
||||
|
||||
if (!(data->options & OPT_YES) && !user_confirmed (warn_to, "\nDo you want to "
|
||||
"run this program?[N/Yes] (note need to type Yes if you do):", "Yes\n"))
|
||||
@@ -801,11 +802,6 @@ static void prepare_fs_for_check(reiserfs_filsys_t * fs) {
|
||||
|
||||
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);
|
||||
@@ -1115,7 +1111,7 @@ static void check_fs (reiserfs_filsys_t * fs)
|
||||
reiserfs_close (fs);
|
||||
close_rollback_file ();
|
||||
|
||||
clear_relocated_list();
|
||||
//clear_relocated_list();
|
||||
|
||||
time (&t);
|
||||
fsck_progress ("###########\n"
|
||||
@@ -1190,10 +1186,10 @@ int main (int argc, char * argv [])
|
||||
{
|
||||
char * file_name;
|
||||
struct fsck_data * data;
|
||||
struct rlimit rlim = {0xffffffff, 0xffffffff};
|
||||
struct rlimit rlim = {RLIM_INFINITY, RLIM_INFINITY};
|
||||
char *width;
|
||||
int retval;
|
||||
int errno;
|
||||
int error;
|
||||
|
||||
width = getenv("COLUMNS");
|
||||
if ( width )
|
||||
@@ -1257,14 +1253,14 @@ 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, &errno, data,
|
||||
fs = reiserfs_open (file_name, O_RDONLY, &error, data,
|
||||
data->mode != FSCK_SB);
|
||||
|
||||
if (data->mode != FSCK_SB) {
|
||||
if (no_reiserfs_found (fs)) {
|
||||
if (errno) {
|
||||
if (error) {
|
||||
die ("Failed to open the device '%s': %s\n\n",
|
||||
file_name, strerror(errno));
|
||||
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"
|
||||
|
||||
+9
-5
@@ -263,7 +263,10 @@ static int verify_directory_item (reiserfs_filsys_t * fs, struct buffer_head * b
|
||||
|
||||
if ( (get_ih_entry_count (ih) > (get_ih_item_len(ih) / (DEH_SIZE + min_entry_size))) ||
|
||||
(get_ih_entry_count (ih) == 0))
|
||||
{
|
||||
set_ih_entry_count (ih, (int)get_ih_item_len(ih) / (DEH_SIZE + min_entry_size));
|
||||
mark_buffer_dirty (bh);
|
||||
}
|
||||
|
||||
if (get_ih_entry_count (ih) == 0) {
|
||||
delete_item (fs, bh, item_num);
|
||||
@@ -561,7 +564,8 @@ 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) == ~(__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) ||
|
||||
/* the alloc=packing_groups used to allow dirid = 1
|
||||
(get_key_dirid (key) == 1 && get_key_objectid (key) != 2) || */
|
||||
(get_key_dirid (key) != 1 && get_key_objectid (key) == 2) )
|
||||
return 1;
|
||||
|
||||
@@ -1285,7 +1289,7 @@ static void pass0_correct_leaf (reiserfs_filsys_t * fs,
|
||||
*/
|
||||
ind_item = (__u32 *)B_I_PITEM (bh, ih);
|
||||
for (j = 0; j < (int)I_UNFM_NUM (ih); j ++) {
|
||||
unfm_ptr = le32_to_cpu (ind_item [j]);
|
||||
unfm_ptr = d32_get (ind_item, j);
|
||||
if (!unfm_ptr)
|
||||
continue;
|
||||
#if 0
|
||||
@@ -1309,7 +1313,7 @@ static void pass0_correct_leaf (reiserfs_filsys_t * fs,
|
||||
fsck_log ("pass0: %d-th pointer (%lu) in item %k (leaf block %lu) is wrong\n",
|
||||
j, unfm_ptr, &ih->ih_key, bh->b_blocknr);
|
||||
*/
|
||||
ind_item [j] = 0;
|
||||
d32_put(ind_item, j, 0);
|
||||
dirty = 1;
|
||||
continue;
|
||||
}
|
||||
@@ -1436,10 +1440,10 @@ static int is_bad_indirect (struct item_head * ih, char * item, int dev, int blo
|
||||
for (i = 0; i < I_UNFM_NUM (ih); i ++) {
|
||||
__u32 * ind = (__u32 *)item;
|
||||
|
||||
if (le32_to_cpu (ind[i]) >= blocks) {
|
||||
if (d32_get (ind, i) >= blocks) {
|
||||
bad ++;
|
||||
fsck_log ("is_bad_indirect: %d-th pointer of item %H looks bad (%lu)\n",
|
||||
i, ih, le32_to_cpu (ind [i]));
|
||||
i, ih, d32_get (ind, i));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-6
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
#include "fsck.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
reiserfs_bitmap_t * bad_unfm_in_tree_once_bitmap;
|
||||
|
||||
@@ -106,7 +105,7 @@ static void indirect_in_tree (struct buffer_head * bh,
|
||||
unp = (__u32 *)B_I_PITEM (bh, ih);
|
||||
|
||||
for (i = 0; i < I_UNFM_NUM (ih); i ++) {
|
||||
unfm_ptr = le32_to_cpu (unp[i]);
|
||||
unfm_ptr = d32_get (unp, i);
|
||||
if (unfm_ptr == 0)
|
||||
continue;
|
||||
if ((ret = still_bad_unfm_ptr_1 (unfm_ptr)))
|
||||
@@ -395,8 +394,8 @@ static void pass1_correct_leaf (reiserfs_filsys_t * fs,
|
||||
/* correct indirect items */
|
||||
ind_item = (__u32 *)B_I_PITEM (bh, ih);
|
||||
|
||||
for (j = 0; j < I_UNFM_NUM (ih); j ++, ind_item ++) {
|
||||
unfm_ptr = le32_to_cpu (*ind_item);
|
||||
for (j = 0; j < I_UNFM_NUM (ih); j ++) {
|
||||
unfm_ptr = d32_get (ind_item, j);
|
||||
|
||||
if (!unfm_ptr)
|
||||
continue;
|
||||
@@ -410,7 +409,7 @@ static void pass1_correct_leaf (reiserfs_filsys_t * fs,
|
||||
/* 1. zero slots pointing to a leaf */
|
||||
if (is_used_leaf (unfm_ptr)) {
|
||||
dirty ++;
|
||||
*ind_item = 0;
|
||||
d32_put (ind_item, j, 0);
|
||||
pass_1_stat (fs)->pointed_leaves ++;
|
||||
continue;
|
||||
}
|
||||
@@ -425,7 +424,7 @@ static void pass1_correct_leaf (reiserfs_filsys_t * fs,
|
||||
else {
|
||||
/* Yes, we have seen this pointer already, zero other pointers to it. */
|
||||
dirty ++;
|
||||
*ind_item = 0;
|
||||
d32_put (ind_item, j, 0);
|
||||
pass_1_stat (fs)->non_unique_pointers ++;
|
||||
continue;
|
||||
}
|
||||
|
||||
+36
-25
@@ -1,9 +1,9 @@
|
||||
.\" -*- nroff -*-
|
||||
.\" Copyright 1996-2004 Hans Reiser.
|
||||
.\"
|
||||
.TH REISERFSCK 8 "February 2004" "Reiserfsprogs-3.6.13"
|
||||
.TH REISERFSCK 8 "February 2004" "Reiserfsprogs-3.6.18"
|
||||
.SH NAME
|
||||
reiserfsck \- checking tool for the ReiserFS filesystem
|
||||
reiserfsck \- The checking tool for the ReiserFS filesystem.
|
||||
.SH SYNOPSIS
|
||||
.B reiserfsck
|
||||
[ \fB-afprVy\fR ]
|
||||
@@ -28,20 +28,24 @@ reiserfsck \- checking tool for the ReiserFS filesystem
|
||||
any necessary transactions, and either checks or repairs the file system.
|
||||
.TP
|
||||
.I device
|
||||
is the special file corresponding to the device or partition (e.g /dev/hdXX
|
||||
for IDE disk partition or /dev/sdXX for SCSI disk partition).
|
||||
is the special file corresponding to a device or to a partition (e.g
|
||||
/dev/hdXX for an IDE disk partition or /dev/sdXX for a SCSI disk partition).
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B --rebuild-sb
|
||||
This option recovers the superblock on a Reiserfs partition. Normally you
|
||||
only need this option if mount reports "read_super_block: can't find
|
||||
a reiserfs file system" and you are sure that a Reiserfs file system is
|
||||
there.
|
||||
there. But remember that if you have used some partition editor program and
|
||||
now you cannot find a filesystem, probably something has gone wrong while
|
||||
repartitioning and the start of the partition has been changed. If so,
|
||||
instead of rebuilding the super block on a wrong place you should find the
|
||||
correct start of the partition first.
|
||||
.TP
|
||||
.B --check
|
||||
This default action checks file system consistency and reports but
|
||||
This default action checks filesystem consistency and reports, but
|
||||
does not repair any corruption that it finds. This option may be
|
||||
used on a read-only file system mount.
|
||||
used on a read-only file system mount.
|
||||
.TP
|
||||
.B --fix-fixable
|
||||
This option recovers certain kinds of corruption that do not require
|
||||
@@ -63,7 +67,12 @@ 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.
|
||||
This option cleans reserved fields of Stat-Data items. There were days when
|
||||
there were no extended attributes in reiserfs. When they were implemented old
|
||||
partitions needed to be cleaned first -- reiserfs code in the kernel did not
|
||||
care about not used fields in its strutures. Thus if you have used one of the
|
||||
old (pre-attrbutes) kernels with a ReiserFS filesystem and you want to use
|
||||
extented attribues there, you should clean the filesystem first.
|
||||
.TP
|
||||
.B \fB--journal \fIdevice \fR, \fB-j \fIdevice \fR
|
||||
This option supplies the device name of the current file system journal.
|
||||
@@ -79,18 +88,18 @@ This option causes \fBreiserfsck\fR to correct file sizes that
|
||||
are larger than the offset of the last discovered byte. This
|
||||
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.
|
||||
byte are corrected by \fB--fix-fixable\fR.
|
||||
.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.
|
||||
list is added. It can be used with \fB--fix-fixable\fR to fix the list of
|
||||
badblocks (see \fBdebugreiserfs -B\fR). If the device has bad blocks, every
|
||||
time it must be given with the \fB--rebuild-tree\fR option.
|
||||
.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.
|
||||
to the specified log file rather than to stderr.
|
||||
.TP
|
||||
.B --nolog, -n
|
||||
This option prevents \fBreiserfsck\fR from reporting any kinds of corruption.
|
||||
@@ -100,24 +109,24 @@ This option prevents \fBreiserfsck\fR from reporting its rate of progress.
|
||||
.TP
|
||||
.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 \fB--rebuild-tree\fR option.
|
||||
telling you what it is going to do. It will assuem you confirm. For safety,
|
||||
it does not 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
|
||||
of those partitions listed in /etc/fstab. These options cause \fBreiserfsck\fR
|
||||
to print some information about the specified file system, check if error
|
||||
flags in the superblock are set and do some light-weight checks. If these
|
||||
to print some information about the specified filesystem, to check if error
|
||||
flags in the superblock are set and to do some light-weight checks. If these
|
||||
checks reveal a corruption or the flag indicating a (possibly fixable)
|
||||
corruption is found set in the superblock, then \fBreiserfsck\fR switches
|
||||
to the fix-fixable mode. If the flag indicating a fatal corruption is found
|
||||
set in the superblock, then \fBreiserfsck\fR finishes with an error.
|
||||
.TP
|
||||
.B -V
|
||||
This option prints the reiserfsprogs version and exit.
|
||||
This option prints the reiserfsprogs version and then exit.
|
||||
.TP
|
||||
\fB-r\fR, \fB-f\fR
|
||||
These options are ignored.
|
||||
These options are not yet operational and therefore are ignored.
|
||||
.SH EXPERT OPTIONS
|
||||
DO NOT USE THESE OPTIONS UNLESS YOU KNOW WHAT YOU ARE DOING.
|
||||
WE ARE NOT RESPONSIBLE IF YOU LOSE DATA AS A RESULT OF THESE
|
||||
@@ -130,9 +139,9 @@ the main data device. NOTE: after this operation you must use \fBreiserfstune\fR
|
||||
to specify a new journal device.
|
||||
.TP
|
||||
.B --scan-whole-partition, -S
|
||||
This option causes \fB--rebuild-tree\fR to scan the whole partition, not only
|
||||
used space on the partition.
|
||||
.SH EXAMPLE OF USING
|
||||
This option causes \fB--rebuild-tree\fR to scan the whole partition but not only
|
||||
the used space on the partition.
|
||||
.SH AN EXAMPLE OF USING reiserfsck
|
||||
1. You think something may be wrong with a reiserfs partition on /dev/hda1
|
||||
or you would just like to perform a periodic disk check.
|
||||
|
||||
@@ -154,7 +163,8 @@ the whole partition before proceeding. Then run \fBreiserfsck --rebuild-tree
|
||||
|
||||
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.
|
||||
information as possible including your platform and Linux kernel version. We
|
||||
will try to help solve the problem.
|
||||
.SH EXIT CODES
|
||||
\fBreiserfsck\fR uses the following exit codes:
|
||||
.br
|
||||
@@ -179,8 +189,9 @@ information as possible and we will try to help solve the problem.
|
||||
.SH AUTHOR
|
||||
This version of \fBreiserfsck\fR has been written by Vitaly Fertman <vitaly@namesys.com>.
|
||||
.SH BUGS
|
||||
There are likely to be some bugs. Please report bugs to the ReiserFS mail-list
|
||||
<reiserfs-list@namesys.com>.
|
||||
Please report bugs to the ReiserFS developers <reiserfs-dev@namesys.com>, providing
|
||||
as much information as possible--your hardware, kernel, patches, settings, all printed
|
||||
messages, the logfile; check the syslog file for any related information.
|
||||
.SH TODO
|
||||
Faster recovering, signal handling.
|
||||
.SH SEE ALSO
|
||||
|
||||
@@ -398,6 +398,7 @@ static int check_semantic_pass (struct key * key, struct key * parent, int dot_d
|
||||
/* It seems quite difficult to relocate objects on fix-fixable -
|
||||
* rewrite_file calls reiserfs_file_write which can convert tails
|
||||
* to unfm, plus unreachable, was_tail flags, etc. */
|
||||
#if 0
|
||||
if ((/* relocate = */ should_be_relocated(&ih->ih_key))) {
|
||||
/*
|
||||
if (fsck_mode(fs) == FSCK_CHECK)
|
||||
@@ -405,6 +406,7 @@ static int check_semantic_pass (struct key * key, struct key * parent, int dot_d
|
||||
*/
|
||||
one_more_corruption(fs, FATAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fix_obviously_wrong_sd_mode (&path)) {
|
||||
one_more_corruption (fs, FIXABLE);
|
||||
@@ -699,7 +701,7 @@ int check_safe_links ()
|
||||
reiserfs_panic ("Safe Link %k cannot be of the size %d",
|
||||
&tmp_ih->ih_key, get_ih_item_len (tmp_ih));
|
||||
|
||||
set_key_dirid(&key, le32_to_cpu(*(__u32 *)get_item(&safe_link_path)));
|
||||
set_key_dirid(&key, d32_get((__u32 *)get_item(&safe_link_path), 0));
|
||||
set_key_objectid(&key, get_key_objectid(&tmp_ih->ih_key));
|
||||
if ((rkey = reiserfs_next_key(&safe_link_path)) == NULL)
|
||||
set_key_dirid (&safe_link_key, 0);
|
||||
@@ -715,7 +717,7 @@ int check_safe_links ()
|
||||
} else if (fsck_mode(fs) == FSCK_FIX_FIXABLE) {
|
||||
fsck_log ("Invalid safe link %k: cannot find the pointed object (%K) - "
|
||||
"safe link was deleted\n", &tmp_ih->ih_key, &key);
|
||||
*(__u32 *)get_item(&safe_link_path) = (__u32)0;
|
||||
d32_put((__u32 *)get_item(&safe_link_path), 0, 0);
|
||||
pathrelse (&path);
|
||||
reiserfsck_delete_item (&safe_link_path, 0);
|
||||
continue;
|
||||
@@ -732,7 +734,7 @@ int check_safe_links ()
|
||||
} else if (fsck_mode(fs) == FSCK_FIX_FIXABLE) {
|
||||
fsck_log ("Invalid 'truncate' safe link %k, cannot happen for "
|
||||
"a directory (%K) - safe link was deleted\n", &tmp_ih->ih_key, &key);
|
||||
*(__u32 *)get_item(&safe_link_path) = (__u32)0;
|
||||
d32_put((__u32 *)get_item(&safe_link_path), 0, 0);
|
||||
pathrelse (&path);
|
||||
reiserfsck_delete_item (&safe_link_path, 0);
|
||||
continue;
|
||||
|
||||
@@ -174,7 +174,7 @@ int wrong_st_blocks (struct key * key, __u32 * blocks, __u32 sd_blocks, __u16 mo
|
||||
if (S_ISREG (mode) || S_ISLNK (mode) || S_ISDIR (mode)) {
|
||||
if (*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" : "file", key, sd_blocks,
|
||||
"(%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);
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
+2
-4
@@ -4,8 +4,6 @@
|
||||
*/
|
||||
|
||||
#include "fsck.h"
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(HAVE_LIBUUID) && defined(HAVE_UUID_UUID_H)
|
||||
# include <uuid/uuid.h>
|
||||
@@ -190,7 +188,7 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
|
||||
char * answer = 0;
|
||||
size_t n = 0;
|
||||
struct stat64 stat_buf;
|
||||
struct stat stat_buf;
|
||||
int retval, exit_code = EXIT_OK;
|
||||
|
||||
#if defined(HAVE_LIBUUID) && defined(HAVE_UUID_UUID_H)
|
||||
@@ -574,7 +572,7 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
|
||||
/* Check that specified non-standard journal device exists. */
|
||||
|
||||
journal_dev_name = fsck_data (fs)->journal_dev_name;
|
||||
retval = stat64(journal_dev_name, &stat_buf);
|
||||
retval = stat(journal_dev_name, &stat_buf);
|
||||
|
||||
if (retval == -1)
|
||||
reiserfs_exit (EXIT_USER, "rebuild_sb: error while detecting the "
|
||||
|
||||
+30
-29
@@ -36,7 +36,6 @@ static unsigned long indirect_to_direct (struct path * path, __u64 len, int syml
|
||||
struct buffer_head * unfm_bh = 0;
|
||||
struct item_head ins_ih;
|
||||
char * buf;
|
||||
__u32 * indirect;
|
||||
char bad_drct[fs->fs_blocksize];
|
||||
|
||||
/* direct item to insert */
|
||||
@@ -53,8 +52,7 @@ static unsigned long indirect_to_direct (struct path * path, __u64 len, int syml
|
||||
TYPE_DIRECT);
|
||||
|
||||
// we do not know what length this item should be
|
||||
indirect = get_item (path);
|
||||
unfm_ptr = le32_to_cpu (indirect [I_UNFM_NUM (ih) - 1]);
|
||||
unfm_ptr = d32_get ((__u32 *)get_item (path), I_UNFM_NUM (ih) - 1);
|
||||
if (unfm_ptr && (unfm_bh = bread (bh->b_dev, unfm_ptr, bh->b_size))) {
|
||||
/* we can read the block */
|
||||
buf = unfm_bh->b_data;
|
||||
@@ -302,7 +300,7 @@ int are_file_items_correct (struct item_head * sd_ih, void * sd, __u64 * size, _
|
||||
for (i = 0; i < I_UNFM_NUM (ih); i ++) {
|
||||
__u32 * ind = (__u32 *)get_item(&path);
|
||||
|
||||
if (ind[i] != 0)
|
||||
if (d32_get(ind, i) != 0)
|
||||
*blocks += (fs->fs_blocksize >> 9);
|
||||
}
|
||||
} else if (get_type (&ih->ih_key) == TYPE_DIRECT) {
|
||||
@@ -332,7 +330,7 @@ int are_file_items_correct (struct item_head * sd_ih, void * sd, __u64 * size, _
|
||||
/* DEBUG message.
|
||||
fsck_log ("are_file_items_correct: The indirect item is converted back to direct %K\n", &ih->ih_key);
|
||||
*/
|
||||
if (ind [I_UNFM_NUM (ih) - 1] == 0)
|
||||
if (d32_get(ind, I_UNFM_NUM (ih) - 1) == 0)
|
||||
*blocks += (fs->fs_blocksize >> 9);
|
||||
|
||||
/* path is released here. */
|
||||
@@ -536,10 +534,10 @@ static int create_first_item_of_file (struct item_head * ih, char * item, struct
|
||||
copy_key (&(indih.ih_key), &(ih->ih_key));
|
||||
set_ih_item_len (&indih, UNFM_P_SIZE);
|
||||
|
||||
set_ih_free_space (&indih, 0);
|
||||
if (get_offset (&ih->ih_key) > fs->fs_blocksize) {
|
||||
/* insert indirect item containing 0 unfm pointer */
|
||||
unfm_ptr = 0;
|
||||
set_ih_free_space (&indih, 0);
|
||||
retval = 0;
|
||||
} else {
|
||||
if (is_direct_ih (ih)) {
|
||||
@@ -551,9 +549,10 @@ static int create_first_item_of_file (struct item_head * ih, char * item, struct
|
||||
unfm_ptr = cpu_to_le32 (unbh->b_blocknr);
|
||||
memcpy (unbh->b_data + get_offset (&ih->ih_key) - 1, item, len);
|
||||
|
||||
set_ih_free_space (&indih, fs->fs_blocksize - len - (get_offset (&ih->ih_key) - 1));
|
||||
set_ih_free_space (&indih, fs->fs_blocksize -
|
||||
len - (get_offset (&ih->ih_key) - 1));
|
||||
|
||||
mark_ih_was_tail (&indih);
|
||||
|
||||
mark_buffer_dirty (unbh);
|
||||
mark_buffer_uptodate (unbh, 1);
|
||||
brelse (unbh);
|
||||
@@ -569,10 +568,10 @@ static int create_first_item_of_file (struct item_head * ih, char * item, struct
|
||||
|
||||
if (!was_in_tree) {
|
||||
for (i = 0; i < I_UNFM_NUM (ih); i++) {
|
||||
if (still_bad_unfm_ptr_2 (le32_to_cpu (ni[i])))
|
||||
if (still_bad_unfm_ptr_2 (d32_get(ni, i)))
|
||||
reiserfs_panic ("create_first_item_of_file: The file %K has a pointer to the bad block (%u)",
|
||||
&ih->ih_key, le32_to_cpu (unfm_ptr));
|
||||
mark_block_used (le32_to_cpu (ni[i]), 0);
|
||||
&ih->ih_key, d32_get(ni, i));
|
||||
mark_block_used (d32_get(ni, i), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -604,6 +603,7 @@ static unsigned long block_to_start (struct path * path)
|
||||
{
|
||||
struct buffer_head * bh;
|
||||
struct item_head * ih;
|
||||
__u32 blk;
|
||||
|
||||
bh = PATH_PLAST_BUFFER (path);
|
||||
ih = PATH_PITEM_HEAD (path);
|
||||
@@ -611,7 +611,8 @@ static unsigned long block_to_start (struct path * path)
|
||||
return bh->b_blocknr;
|
||||
|
||||
ih --;
|
||||
return (B_I_POS_UNFM_POINTER (bh, ih, I_UNFM_NUM (ih) - 1)) ?: bh->b_blocknr;
|
||||
blk = d32_get((__u32 *)B_I_PITEM(bh, ih), I_UNFM_NUM (ih) - 1);
|
||||
return (blk ? blk : bh->b_blocknr);
|
||||
}
|
||||
|
||||
|
||||
@@ -637,7 +638,7 @@ static void direct2indirect2 (unsigned long unfm, struct path * path)
|
||||
die ("direct2indirect: can not find first part of tail");
|
||||
}
|
||||
|
||||
unbh = reiserfsck_get_new_buffer (le32_to_cpu (unfm) ? le32_to_cpu (unfm) : block_to_start (path));
|
||||
unbh = reiserfsck_get_new_buffer (unfm ? unfm : block_to_start (path));
|
||||
memset (unbh->b_data, 0, unbh->b_size);
|
||||
|
||||
/* delete parts of tail coping their contents to new buffer */
|
||||
@@ -717,7 +718,7 @@ static int append_to_unformatted_node (struct item_head * comingih, struct item_
|
||||
int zero_number;
|
||||
|
||||
bh = PATH_PLAST_BUFFER (path);
|
||||
unfm_ptr = le32_to_cpu (B_I_POS_UNFM_POINTER (bh, ih, I_UNFM_NUM (ih) - 1));
|
||||
unfm_ptr = d32_get ((__u32 *)B_I_PITEM(bh, ih), I_UNFM_NUM (ih) - 1);
|
||||
|
||||
/* append to free space of the last unformatted node of indirect item ih */
|
||||
free_space = get_offset (&ih->ih_key) + fs->fs_blocksize * I_UNFM_NUM (ih) - get_offset (&comingih->ih_key);
|
||||
@@ -749,7 +750,7 @@ static int append_to_unformatted_node (struct item_head * comingih, struct item_
|
||||
/*if (unfm_ptr == 0 || unfm_ptr >= SB_BLOCK_COUNT (fs)) {*/
|
||||
unbh = reiserfsck_get_new_buffer (bh->b_blocknr);
|
||||
memset (unbh->b_data, 0, unbh->b_size);
|
||||
B_I_POS_UNFM_POINTER (bh, ih, I_UNFM_NUM (ih) - 1) = unbh->b_blocknr;
|
||||
d32_put ((__u32 *)B_I_PITEM(bh, ih), I_UNFM_NUM (ih) - 1, unbh->b_blocknr);
|
||||
/*mark_block_unformatted (unbh->b_blocknr);*/
|
||||
mark_buffer_dirty (bh);
|
||||
}
|
||||
@@ -802,7 +803,7 @@ int reiserfsck_append_file (struct item_head * comingih, char * item, int pos, s
|
||||
mark_buffer_uptodate (unbh, 1);
|
||||
|
||||
ni = getmem (UNFM_P_SIZE);
|
||||
*ni = cpu_to_le32 (unbh->b_blocknr);
|
||||
d32_put (ni, 0, unbh->b_blocknr);
|
||||
count = 1;
|
||||
|
||||
brelse (unbh);
|
||||
@@ -823,9 +824,9 @@ int reiserfsck_append_file (struct item_head * comingih, char * item, int pos, s
|
||||
|
||||
if (!was_in_tree) {
|
||||
for (i = 0; i < count; i++ ) {
|
||||
if (still_bad_unfm_ptr_2 (le32_to_cpu (ni[i])))
|
||||
die ("reiserfsck_append_file: Trying to insert a pointer to illegal block (%u)", le32_to_cpu (ni[i]));
|
||||
mark_block_used (le32_to_cpu (ni[i]), 0);
|
||||
if (still_bad_unfm_ptr_2 (d32_get (ni, i)))
|
||||
die ("reiserfsck_append_file: Trying to insert a pointer to illegal block (%u)", d32_get (ni, i));
|
||||
mark_block_used (d32_get (ni, i), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,7 +838,7 @@ int reiserfsck_append_file (struct item_head * comingih, char * item, int pos, s
|
||||
return retval;
|
||||
}
|
||||
|
||||
int must_there_be_a_hole (struct item_head * comingih, struct path * path)
|
||||
long long int must_there_be_a_hole (struct item_head * comingih, struct path * path)
|
||||
{
|
||||
struct item_head * ih = PATH_PITEM_HEAD (path);
|
||||
|
||||
@@ -857,10 +858,10 @@ int must_there_be_a_hole (struct item_head * comingih, struct path * path)
|
||||
}
|
||||
|
||||
|
||||
int reiserfs_append_zero_unfm_ptr (struct path * path, int p_count)
|
||||
int reiserfs_append_zero_unfm_ptr (struct path * path, long long int p_count)
|
||||
{
|
||||
__u32 * ni;
|
||||
int count;
|
||||
long long int count;
|
||||
|
||||
if (is_direct_ih (PATH_PITEM_HEAD (path)))
|
||||
/* convert direct item to indirect */
|
||||
@@ -894,7 +895,7 @@ static int overwrite_by_direct_item (struct item_head * comingih, char * item, s
|
||||
bh = PATH_PLAST_BUFFER (path);
|
||||
ih = PATH_PITEM_HEAD (path);
|
||||
|
||||
unfm_ptr = le32_to_cpu (B_I_POS_UNFM_POINTER (bh, ih, path->pos_in_item));
|
||||
unfm_ptr = d32_get ((__u32 *)B_I_PITEM(bh, ih), path->pos_in_item);
|
||||
unbh = 0;
|
||||
|
||||
if (unfm_ptr != 0 && unfm_ptr < get_sb_block_count (fs->fs_ondisk_sb)) {
|
||||
@@ -910,7 +911,7 @@ static int overwrite_by_direct_item (struct item_head * comingih, char * item, s
|
||||
if (unfm_ptr == 0 || unfm_ptr >= get_sb_block_count (fs->fs_ondisk_sb)) {
|
||||
if ((unbh = reiserfsck_get_new_buffer (bh->b_blocknr)) != NULL) {
|
||||
memset (unbh->b_data, 0, unbh->b_size);
|
||||
B_I_POS_UNFM_POINTER (bh, ih, path->pos_in_item) = cpu_to_le32 (unbh->b_blocknr);
|
||||
d32_put ((__u32 *)B_I_PITEM(bh, ih), path->pos_in_item, unbh->b_blocknr);
|
||||
mark_buffer_dirty (bh);
|
||||
} else {
|
||||
die ("overwrite_by_direct_item: Could not allocate a new block for new data");
|
||||
@@ -1017,11 +1018,11 @@ static int overwrite_by_indirect_item (struct item_head * comingih, __u32 * comi
|
||||
}
|
||||
|
||||
for (i = 0; i < to_copy; i ++) {
|
||||
if (coming_item[i] != 0 && item_in_tree[i] == 0) {
|
||||
if (d32_get (coming_item, i) != 0 && d32_get (item_in_tree, i) == 0) {
|
||||
/* overwrite holes only by correct a pointer in the coming item
|
||||
which must be correct */
|
||||
item_in_tree[i] = coming_item[i];
|
||||
mark_block_used (le32_to_cpu (coming_item[i]), 0);
|
||||
d32_put (item_in_tree, i, d32_get (coming_item, i));
|
||||
mark_block_used (d32_get (coming_item, i), 0);
|
||||
dirty ++;
|
||||
}
|
||||
}
|
||||
@@ -1051,7 +1052,7 @@ static int reiserfsck_overwrite_file (struct item_head * comingih, char * item,
|
||||
reiserfs_panic ("reiserfsck_overwrite_file: The second part of the tail %k can not"
|
||||
" be overwritten by indirect item %k", &ih->ih_key, &comingih->ih_key);
|
||||
/* use pointer from coming indirect item */
|
||||
unfm_ptr = le32_to_cpu (*(__u32 *)(item + *pos_in_coming_item * UNFM_P_SIZE));
|
||||
unfm_ptr = d32_get ((__u32 *)item, *pos_in_coming_item);
|
||||
if (!was_in_tree) {
|
||||
if (still_bad_unfm_ptr_2 (unfm_ptr))
|
||||
die ("reiserfsck_overwrite_file: The pointer to the unformatted block (%u)"
|
||||
@@ -1080,7 +1081,7 @@ static int reiserfsck_overwrite_file (struct item_head * comingih, char * item,
|
||||
int reiserfsck_file_write (struct item_head * ih, char * item, int was_in_tree) {
|
||||
struct path path;
|
||||
int count, pos_in_coming_item;
|
||||
int retval, written;
|
||||
long long int retval, written;
|
||||
struct key key;
|
||||
int file_format = KEY_FORMAT_UNDEFINED;
|
||||
int relocated = 0;
|
||||
|
||||
+6
-4
@@ -211,10 +211,12 @@ void id_map_flush(struct id_map * map, reiserfs_filsys_t * fs) {
|
||||
max = ((fs->fs_blocksize - size) >> 3 << 1);
|
||||
set_sb_oid_maxsize (fs->fs_ondisk_sb, max);
|
||||
|
||||
sb_objectid_map[0] = id = 1;
|
||||
id = 1;
|
||||
sb_objectid_map[0] = cpu_to_le32(1);
|
||||
|
||||
for (i = 1; i < max - 1; i++) {
|
||||
sb_objectid_map[i] = id = id_map_next_bound(map, id);
|
||||
for (i = 1; i < max - 1; i++) {
|
||||
id = id_map_next_bound(map, id);
|
||||
sb_objectid_map[i] = cpu_to_le32(id);
|
||||
if (id == 0) {
|
||||
if (i % 2)
|
||||
die ("%s: Used interval is not closed on flushing.", __FUNCTION__);
|
||||
@@ -256,7 +258,7 @@ void id_map_flush(struct id_map * map, reiserfs_filsys_t * fs) {
|
||||
prev_id++;
|
||||
}
|
||||
|
||||
sb_objectid_map[max - 1] = prev_id + map->last_used * BM_INTERVAL;
|
||||
sb_objectid_map[max - 1] = cpu_to_le32(prev_id + map->last_used * BM_INTERVAL);
|
||||
} else {
|
||||
i--;
|
||||
memset(sb_objectid_map + i, 0, (max - i) * sizeof (__u32));
|
||||
|
||||
+10
-24
@@ -5,23 +5,6 @@
|
||||
|
||||
#include "fsck.h"
|
||||
|
||||
|
||||
/* key1 and key2 are pointer to deh_offset of the struct reiserfs_de_head */
|
||||
int comp_dir_entries (void * key1, void * key2)
|
||||
{
|
||||
__u32 off1, off2;
|
||||
|
||||
off1 = le32_to_cpu (*(__u32 *)key1);
|
||||
off2 = le32_to_cpu (*(__u32 *)key2);
|
||||
|
||||
if (off1 < off2)
|
||||
return -1;
|
||||
if (off1 > off2)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct tree_balance * cur_tb = 0;
|
||||
|
||||
void reiserfsck_paste_into_item (struct path * path, const char * body, int size)
|
||||
@@ -54,19 +37,21 @@ static void free_unformatted_nodes (struct item_head * ih, struct buffer_head *
|
||||
__u32 * punfm = (__u32 *)B_I_PITEM (bh, ih);
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < I_UNFM_NUM (ih); i ++, punfm ++)
|
||||
if (*punfm != 0) {
|
||||
for (i = 0; i < I_UNFM_NUM (ih); i ++) {
|
||||
__u32 unfm = d32_get (punfm, i);
|
||||
if (unfm != 0) {
|
||||
struct buffer_head * to_be_forgotten;
|
||||
|
||||
to_be_forgotten = find_buffer (fs->fs_dev, le32_to_cpu (*punfm), fs->fs_blocksize);
|
||||
to_be_forgotten = find_buffer (fs->fs_dev, unfm, fs->fs_blocksize);
|
||||
if (to_be_forgotten) {
|
||||
//atomic_inc(&to_be_forgotten->b_count);
|
||||
to_be_forgotten->b_count ++;
|
||||
bforget (to_be_forgotten);
|
||||
}
|
||||
|
||||
reiserfs_free_block (fs, le32_to_cpu (*punfm));
|
||||
reiserfs_free_block (fs, unfm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void reiserfsck_delete_item (struct path * path, int temporary)
|
||||
@@ -95,17 +80,18 @@ void reiserfsck_cut_from_item (struct path * path, int cut_size)
|
||||
die ("reiserfsck_cut_from_item: cut size == %d", cut_size);
|
||||
|
||||
if (is_indirect_ih (ih = PATH_PITEM_HEAD (path))) {
|
||||
__u32 unfm_ptr = B_I_POS_UNFM_POINTER (PATH_PLAST_BUFFER (path), ih, I_UNFM_NUM (ih) - 1);
|
||||
struct buffer_head *bh = PATH_PLAST_BUFFER (path);
|
||||
__u32 unfm_ptr = d32_get ((__u32 *)B_I_PITEM(bh, ih), I_UNFM_NUM (ih) - 1);
|
||||
if (unfm_ptr != 0) {
|
||||
struct buffer_head * to_be_forgotten;
|
||||
|
||||
to_be_forgotten = find_buffer (fs->fs_dev, le32_to_cpu (unfm_ptr), fs->fs_blocksize);
|
||||
to_be_forgotten = find_buffer (fs->fs_dev, unfm_ptr, fs->fs_blocksize);
|
||||
if (to_be_forgotten) {
|
||||
//atomic_inc(&to_be_forgotten->b_count);
|
||||
to_be_forgotten->b_count ++;
|
||||
bforget (to_be_forgotten);
|
||||
}
|
||||
reiserfs_free_block (fs, le32_to_cpu (unfm_ptr));
|
||||
reiserfs_free_block (fs, unfm_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user