Imported reiserfsprogs-3.6.2

This commit is contained in:
Jeff Mahoney committed 2012-10-11 11:27:42 -04:00
1 parent e7102bdb66
commit b69459eb80
86 files changed
+23136 -13423

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
sbin_PROGRAMS = reiserfstune
reiserfstune_SOURCES = tune.c tune.h
man_MANS = reiserfstune.8
EXTRA_DIST = $(man_MANS)
LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
+328
View File
@@ -0,0 +1,328 @@
# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
CC = @CC@
MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
sbindir = @sbindir@
sbin_PROGRAMS = reiserfstune
reiserfstune_SOURCES = tune.c tune.h
man_MANS = reiserfstune.8
EXTRA_DIST = $(man_MANS)
LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../include/config.h
CONFIG_CLEAN_FILES =
PROGRAMS = $(sbin_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir) -I../include
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
reiserfstune_OBJECTS = tune.o
reiserfstune_LDADD = $(LDADD)
reiserfstune_DEPENDENCIES = $(top_srcdir)/lib/libmisc.a \
$(top_srcdir)/reiserfscore/libcore.a
reiserfstune_LDFLAGS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
man8dir = $(mandir)/man8
MANS = $(man_MANS)
NROFF = nroff
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
SOURCES = $(reiserfstune_SOURCES)
OBJECTS = $(reiserfstune_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps tune/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-sbinPROGRAMS:
clean-sbinPROGRAMS:
-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
distclean-sbinPROGRAMS:
maintainer-clean-sbinPROGRAMS:
install-sbinPROGRAMS: $(sbin_PROGRAMS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(sbindir)
@list='$(sbin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
else :; fi; \
done
uninstall-sbinPROGRAMS:
@$(NORMAL_UNINSTALL)
list='$(sbin_PROGRAMS)'; for p in $$list; do \
rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
done
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
reiserfstune: $(reiserfstune_OBJECTS) $(reiserfstune_DEPENDENCIES)
@rm -f reiserfstune
$(LINK) $(reiserfstune_LDFLAGS) $(reiserfstune_OBJECTS) $(reiserfstune_LDADD) $(LIBS)
install-man8:
$(mkinstalldirs) $(DESTDIR)$(man8dir)
@list='$(man8_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.8*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst"; \
$(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst; \
done
uninstall-man8:
@list='$(man8_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.8*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f $(DESTDIR)$(man8dir)/$$inst"; \
rm -f $(DESTDIR)$(man8dir)/$$inst; \
done
install-man: $(MANS)
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-man8
uninstall-man:
@$(NORMAL_UNINSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-man8
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = tune
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
tune.o: tune.c tune.h ../include/io.h ../include/misc.h \
../include/swab.h ../include/reiserfs_lib.h \
../include/reiserfs_fs.h ../include/config.h ../version.h
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-sbinPROGRAMS
install-exec: install-exec-am
install-data-am: install-man
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-sbinPROGRAMS uninstall-man
uninstall: uninstall-am
all-am: Makefile $(PROGRAMS) $(MANS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)/man8
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-sbinPROGRAMS mostlyclean-compile \
mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-sbinPROGRAMS clean-compile clean-tags clean-generic \
mostlyclean-am
clean: clean-am
distclean-am: distclean-sbinPROGRAMS distclean-compile distclean-tags \
distclean-generic clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-sbinPROGRAMS \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-sbinPROGRAMS distclean-sbinPROGRAMS \
clean-sbinPROGRAMS maintainer-clean-sbinPROGRAMS uninstall-sbinPROGRAMS \
install-sbinPROGRAMS mostlyclean-compile distclean-compile \
clean-compile maintainer-clean-compile install-man8 uninstall-man8 \
install-man uninstall-man tags mostlyclean-tags distclean-tags \
clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
check-am installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
+147
View File
@@ -0,0 +1,147 @@
.\" -*- nroff -*-
.\" Copyright 1996-2002 Hans Reiser.
.\"
.TH REISERFSTUNE 8 "January 2002" "Reiserfsprogs-3.6.2"
.SH NAME
reiserfstune
.SH SYNOPSIS
.B reiserfstune
[ \fB-f\fR ]
[ \fB-j\fR | \fB--journal-device\fR \fIFILE\fR ]
[ \fB--no-journal-available\fR ]
[ \fB--journal-new-device\fR \fIFILE\fR ]
[ \fB-s\fR | \fB--journal-new-size\fR \fIN\fR ]
[ \fB-o\fR | \fB--journal-new-offset\fR \fIN\fR ]
[ \fB-t\fR | \fB--max-transaction-size\fR \fIN\fR ]
[ \fB-u\fR | \fB--uuid \fIUUID\fR ]
[ \fB-l\fR | \fB--label \fILABEL\fR ]
.I device
.SH DESCRIPTION
\fBreiserfstune\fR is used for tuning the ReiserFS
journal. It can change two parameters (journal size and maximum
transaction size), and it can move the journal's location to a new specified
block device. (The old ReiserFS's journal may be
kept unused, or discarded at the user's option.) Note: At the time of
writing this feature was implemented for a special release of
ReiserFS, and was not expected to be put into the mainstream kernel
until approximately Linux 2.5. This means that if you have the stock
kernel you must apply a special patch. Without this patch the kernel
will refuse to mount the newly modified file system. We will charge
$25 to explain this to you if you ask us why it doesn't work.
.PP
Perhaps the most interesting application of this code is to put the
journal on a solid state disk.
.TP
\fIdevice
is the special file corresponding to the newly specified block device (e.g
/dev/hdXX for IDE disk partition or /dev/sdXX for the SCSI disk partition).
.SH OPTIONS
.TP
\fB-j\fR | \fB--journal-device\fR \fIFILE
\fIFILE\fR is the file name of the block device the file system has
the current journal (the one prior to running reiserfstune) on. This option is required when the journal is
already on a separate device from the main data device (although it
can be avoided with \fB--no-journal-available\fR). If you don't
specify journal device by this option, reiserfstune suppose that
journal is on main device.
.TP
\fB--no-journal-available
allows \fBreiserfstune\fR to continue when the current journal's block
device is no longer available. This might happen if a disk goes bad
and you remove it (and run fsck).
.TP
\fB--journal-new-device \fIFILE
\fIFILE\fR is the file name of the block device which will contain the
new journal for the file system. If you don't specify this,
reiserfstune supposes that journal device remains the same.
.TP
\fB \-s\fR | \fB\--journal-new-size \fIN
\fIN\fR is the size parameter for the new journal. When journal is to
be on a separate device - its size defaults to number of blocks that
device has. When journal is to be on the same device as the filesytem - its size defaults
to amount of blocks allocated for journal by \fImkreiserfs\fR when it
created the filesystem. Minimum is 513 for
both cases.
.TP
\fB \-o\fR | \fB\--journal-new-offset \fIN
\fIN\fR is an offset in blocks where journal will starts from when journal is to
be on a separate device. Default is 0. Has no effect when journal is
to be on the same device as the filesystem. Most users have no need
to use this feature. It can be used when you want the journals from
multiple filesystems to reside on the same device, and you don't want
to or cannot partition that device.
.TP
\fB \-t\fR | \fB\--maximal-transaction-size \fIN
\fI\fR is the maximum transaction size parameter for the new
journal. The default, and max possible, value is 1024 blocks. It
should be less than half the size of the journal. If specifed
incorrectly, it will be adjusted.
.TP
\fB\-f\fR | \fB--force\fR
Normally \fBreiserfstune\fR will refuse to change a journal of a
file system that was created before this journal relocation code. This
is because if you change the journal, you cannot go back (without special
option \fB--make-journal-standard\fR) to an old kernel that lacks this feature and be able to use your filesytem. This option forces it to do that. Specified more
than once it allows to avoid asking for confirmation.
.TP
\fB--make-journal-standard\fR
As it was mentioned above, if your file system has non-standard journal,
it can not be mounted on the kernel without journal relocation
code. The thing can be changed, the only condition is that there is reserved
area on main device of the standard journal size 8193 blocks (it will be so for
instance if you convert standard journal to non-standard). Just
specify this option when you relocate journal back, or without relocation
if you already have it on main device.
.TP
\fB-u\fR | \fB--uuid \fIUUID\fR
Set the universally unique identifier (\fB UUID \fR) of the filesystem to
\fIUUID\fR (see also \fBuuidgen(8)\fR). The format of the UUID is a
series of hex digits separated by hypthens, like this:
"c1b9d5a2-f162-11cf-9ece-0020afc76f16".
.TP
\fB-l\fR | \fB--label \fILABEL\fR
Set the volume label of the filesystem. \fILABEL\fR can be at most 16
characters long; if it is longer than 16 characters, reiserfstune will truncate it.
.SH POSSIBLE SCENARIOS OF USING REISERFSTUNE:
1. You have ReiserFS on /dev/hda1, and you wish to have
it working with its journal on the device /dev/journal
.nf
.IP
boot kernel patched with special "relocatable journal support" patch
reiserfstune /dev/hda1 --journal-new-device /dev/journal -f
mount /dev/hda1 and use.
You would like to change max transaction size to 512 blocks
reiserfstune -t 512 /dev/hda1
You would like to use your file system on another kernel that doesn't
contain relocatable journal support.
umount /dev/hda1
reiserfstune /dev/hda1 -j /dev/journal --journal-new-device /dev/hda1 --make-journal-standard
mount /dev/hda1 and use.
.LP
2. You would like to have ReiserFS on /dev/hda1 and to be able to
switch between different journals including journal located on the
device containing the filesystem.
.nf
.IP
boot kernel patched with special "relocatable journal support" patch
mkreiserfs /dev/hda1
you got solid state disk (perhaps /dev/sda, they typically look like scsi disks)
reiserfstune --journal-new-device /dev/sda1 -f /dev/hda1
Your scsi device dies, it is three in the morning, you have an extra IDE device
lying around
reiserfsck --no-journal-available /dev/hda1
or
reiserfsck --rebuild-tree --no-journal-available /dev/hda1
reiserfstune --no-journal-available --journal-new-device /dev/hda1 /dev/hda1
using /dev/hda1 under patched kernel
.SH AUTHOR
This version of \fBreiserfstune\fR has been written by Vladimir
Demidov <vova@namesys.com> and Edward Shishkin <edward@namesys.com>.
.SH BUGS
Please repoort bugs to the ReiserFS mail list <reiserfs-list@namesys.com>
.SH SEE ALSO
.BR reiserfsck (8),
.BR debugreiserfs (8),
.BR mkreiserfs (8)
+563
View File
@@ -0,0 +1,563 @@
/*
* Copyright 2002 Hans Reiser
*/
#include "tune.h"
char *program_name;
static void message( const char * fmt, ... )
__attribute__ ((format (printf, 1, 2)));
static void message( const char * fmt, ... )
{
char *buf;
va_list args;
buf = NULL;
va_start( args, fmt );
vasprintf( &buf, fmt, args );
va_end( args );
if( buf ) {
fprintf( stderr, "%s: %s\n", program_name, buf );
free( buf );
}
}
reiserfs_filsys_t * fs;
static void print_usage_and_exit(void)
{
message ("Usage: %s [options] "
" device [block-count]\n"
"\n"
"Options:\n\n"
" -j | --journal-device file\n"
" --journal-new-device file\n"
" -o | --journal-new-offset N\n"
" -s | --journal-new-size N\n"
" -t | --transaction-max-size N\n"
" --no-journal-available\n"
" --make-journal-standard\n"
/*"\t-p | --keep-old-journal-param (keep parametrs from old journal to new one)\n"*/
" -u | --uuid UUID|random\n"
" -l | --label LABEL\n"
" -f | --force \n", program_name);
exit (1);
}
unsigned long Journal_size = 0;
int Max_trans_size = JOURNAL_TRANS_MAX;
int Offset = 0;
__u16 Options = 0;
int Force = 0;
char * LABEL;
unsigned char UUID[16];
static int should_make_journal_non_standard (int force)
{
message ("ATTENTION! Filesystem with standard journal found. ");
check_forcing_ask_confirmation (force);
return 1;
}
static int should_make_journal_standard (reiserfs_filsys_t * fs, char * j_new_dev_name)
{
if (!is_reiserfs_jr_magic_string (fs->fs_ondisk_sb))
return 0;
if (!user_confirmed (stderr, "ATTENTION! Filesystem with non-standard journal "
"found. Continue? (y/n):", "y\n")) {
exit(1);
}
/* make sure journal is on main device, it has default size
and the file system has non-standard magic */
if (j_new_dev_name) {
/* new journal was specified - check if it is available */
if (strcmp (j_new_dev_name, fs->fs_file_name)) {
message ("Can not create standard journal on separated device %s",
j_new_dev_name);
return 0;
}
if (Journal_size && (Journal_size != journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize))) {
message ("Can not create standard journal of the size %lu",
Journal_size);
return 0;
}
if (Max_trans_size && (Max_trans_size != JOURNAL_TRANS_MAX)) {
message ("Can not create standard journal with the transaction "
"max size %u", Max_trans_size);
return 0;
}
}
else {
/* new journal was not specified - check ondisk journal params */
if (get_jp_journal_dev(sb_jp(fs->fs_ondisk_sb))) {
message ("Can not create standard journal on separated device [0x%x]",
get_jp_journal_dev(sb_jp(fs->fs_ondisk_sb)));
return 0;
}
if(get_jp_journal_size(sb_jp(fs->fs_ondisk_sb))!= journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize)){
message ("Can not create standard journal of the size %u",
get_jp_journal_size(sb_jp(fs->fs_ondisk_sb)));
return 0;
}
}
return 1;
}
static int set_standard_journal_params (reiserfs_filsys_t * fs)
{
/* ondisk superblock update */
if (get_sb_version(fs->fs_ondisk_sb) == 0)
memcpy (fs->fs_ondisk_sb->s_v1.s_magic, REISERFS_3_5_SUPER_MAGIC_STRING,
strlen (REISERFS_3_5_SUPER_MAGIC_STRING));
else if (get_sb_version(fs->fs_ondisk_sb) == 2)
memcpy (fs->fs_ondisk_sb->s_v1.s_magic, REISERFS_3_6_SUPER_MAGIC_STRING,
strlen (REISERFS_3_6_SUPER_MAGIC_STRING));
else {
message ("Can not set standard reiserfs magic: unknown format found %u,"
" try reiserfsck first", get_sb_version(fs->fs_ondisk_sb));
return 0;
}
if (get_jp_journal_max_trans_len(sb_jp(fs->fs_ondisk_sb)) != JOURNAL_TRANS_MAX)
set_jp_journal_max_trans_len(sb_jp(fs->fs_ondisk_sb), JOURNAL_TRANS_MAX);
if (get_jp_journal_max_batch(sb_jp(fs->fs_ondisk_sb)) != JOURNAL_MAX_BATCH)
set_jp_journal_max_batch(sb_jp(fs->fs_ondisk_sb), JOURNAL_MAX_BATCH);
if (get_jp_journal_max_commit_age(sb_jp(fs->fs_ondisk_sb)) != JOURNAL_MAX_COMMIT_AGE)
set_jp_journal_max_commit_age(sb_jp(fs->fs_ondisk_sb), JOURNAL_MAX_COMMIT_AGE);
if (get_jp_journal_max_trans_age(sb_jp(fs->fs_ondisk_sb)) != JOURNAL_MAX_TRANS_AGE)
set_jp_journal_max_trans_age(sb_jp(fs->fs_ondisk_sb), JOURNAL_MAX_TRANS_AGE);
set_sb_reserved_for_journal (fs->fs_ondisk_sb, 0);
/* journal_header update */
((struct reiserfs_journal_header *)(fs->fs_jh_bh->b_data)) -> jh_journal =
*(sb_jp(fs->fs_ondisk_sb));
return 1;
}
void zero_journal (reiserfs_filsys_t * fs)
{
int i;
struct buffer_head * bh;
unsigned long done;
unsigned long start, len;
fprintf (stderr, "Initializing journal - ");
start = get_jp_journal_1st_block (sb_jp (fs->fs_ondisk_sb));
len = get_jp_journal_size (sb_jp (fs->fs_ondisk_sb));
done = 0;
for (i = 0; i < len; i ++) {
print_how_far (stderr, &done, len, 1, 1/*be quiet*/);
bh = getblk (fs->fs_journal_dev, start + i, fs->fs_blocksize);
if (!bh)
die ("zero_journal: getblk failed");
memset (bh->b_data, 0, bh->b_size);
mark_buffer_dirty (bh);
mark_buffer_uptodate (bh, 1);
bwrite (bh);
brelse (bh);
}
fprintf (stderr, "\n");
fflush (stderr);
}
static int str2int (char * str)
{
int val;
char * tmp;
val = (int) strtol (str, &tmp, 0);
if (*tmp)
die ("%s: strtol is unable to make an integer of %s\n", program_name, str);
return val;
}
static void set_transaction_max_size (char * str)
{
Max_trans_size = str2int( str );
}
/* journal must fit into number of blocks pointed by first bitmap */
static void set_journal_device_size (char * str)
{
Journal_size = str2int (str) ;
}
static void set_offset_in_journal_device (char * str)
{
Offset = str2int( str );
}
int main (int argc, char **argv)
{
reiserfs_filsys_t * fs;
char * device_name;
char * jdevice_name;
char * j_new_device_name;
int c;
static int flag;
struct reiserfs_journal_header * j_head;
reiserfs_trans_t old, new;
int Is_journal_or_maxtrans_size_specified = 0;
program_name = strrchr( argv[ 0 ], '/' );
program_name = program_name ? ++ program_name : argv[ 0 ];
print_banner (program_name);
if (argc < 2)
print_usage_and_exit ();
device_name = 0;
jdevice_name = 0;
j_new_device_name = 0;
while (1) {
static struct option options[] = {
{"journal-device", required_argument, 0, 'j'},
{"journal-new-device", required_argument, &flag, OPT_NEW_J},
{"journal-new-size", required_argument, 0, 's'},
{"transaction-max-size", required_argument, 0, 't'},
{"journal-new-offset", required_argument, 0, 'o'},
{"no-journal-available", no_argument, &flag, OPT_SKIP_J},
/*{"keep-old-journal-param", no_argument, 0, 'p'},*/
{"uuid", required_argument, 0, 'u'},
{"label", required_argument, 0, 'l'},
{"force", no_argument, 0, 'f'},
{"really-force", no_argument, &flag, OPT_SUPER_FORCE},
{"make-journal-standard", no_argument, &flag, OPT_STANDARD},
{0, 0, 0, 0}
};
int option_index;
c = getopt_long (argc, argv, "j:s:t:o:fu:l:",
options, &option_index);
if (c == -1)
break;
switch (c) {
case 0:
/* long-only optins */
if (flag == OPT_NEW_J) {
Options |= OPT_NEW_J;
j_new_device_name = optarg;
}
if (flag == OPT_SKIP_J) {
Options |= OPT_SKIP_J;
}
if (flag == OPT_SUPER_FORCE) {
Options |=OPT_SUPER_FORCE;
}
if (flag == OPT_STANDARD) {
Options |=OPT_STANDARD;
}
break;
case 'j': /* --journal-device */
jdevice_name = optarg;
break;
case 's': /* --journal-new-size */
set_journal_device_size (optarg);
Is_journal_or_maxtrans_size_specified = 1;
break;
case 't': /* --transaction-max-size */
set_transaction_max_size (optarg);
Is_journal_or_maxtrans_size_specified = 1;
break;
case 'o': /* --offset */
set_offset_in_journal_device (optarg);
break;
case 'f':
/* forces replacing standard journal with non-standard
one. Specified more than once - allows to avoid asking for
confirmation */
Force ++;
break;
case 'u':
/* UUID */
if (!strcmp(optarg, "random")) {
if (generate_random_uuid (UUID))
message ("failed to genetate UUID\n");
} else {
if (set_uuid (optarg, UUID)) {
message ("wrong UUID specified\n");
return 1;
}
}
break;
case 'l':
/* LABEL */
LABEL = optarg;
break;
#if 0
case 'J': /* --journal-new-device */
Options |= OPT_NEW_J;
j_new_device_name = optarg;
break;
case 'u': /* --no-journal-available */
Options |= OPT_SKIPJ;
break;
case 'p': /* --keep-old-journal-param */
Options |= OPT_KEEPO;
break;
#endif
default:
print_usage_and_exit();
}
}
if (optind != argc - 1)
print_usage_and_exit ();
/* device to be formatted */
device_name = argv [optind];
if (!jdevice_name && !(Options & OPT_SKIP_J))
jdevice_name = device_name;
if (jdevice_name && (Options & OPT_SKIP_J)) {
message ("either specify journal device, "
"or choose the option --no-journal-awailable");
return 1;
}
fs = reiserfs_open (device_name, O_RDONLY, 0, NULL);
if (no_reiserfs_found(fs)) {
message ("Cannot open reiserfs on %s", device_name);
return 1;
}
/* now we try to open journal, it makes sence if there is no the flag
NEED_TUNE in ondisk superblock */
if (get_jp_journal_magic(sb_jp(fs->fs_ondisk_sb)) != NEED_TUNE) {
if (!reiserfs_open_journal (fs, jdevice_name, O_RDONLY)) {
if (!(Options & OPT_SKIP_J)) {
message ("Unable to open old journal.");
reiserfs_close (fs);
return 1;
}
else
if (!reiserfs_is_fs_consistent (fs)) {
message ("Check filesystem consistency first");
reiserfs_close (fs);
return 1;
}
/* forced to continue without journal available/specifed */
}
}
/* journal was opened or it wasn't opened but the option
--no-journal-available has been specified by user */
/* make sure filesystem is not mounted */
if (is_mounted (fs->fs_file_name)) {
/* fixme: it can not be mounted, btw */
message ("can not rebuild journal of mounted filesystem");
reiserfs_close (fs);
return 1;
}
/* in spite of journal was opened, the file system can be non-consistent or
there are non-replayed transaction in journal,
make sure it isn't (if there is no the flag NEED_TUNE in ondisk superblock */
if (get_jp_journal_magic(sb_jp(fs->fs_ondisk_sb)) != NEED_TUNE &&
reiserfs_journal_opened (fs)) {
j_head = (struct reiserfs_journal_header *)(fs->fs_jh_bh->b_data);
if (get_boundary_transactions(fs, &old, &new)) {
if (new.trans_id != get_jh_last_flushed(j_head)) {
if (!(Options & OPT_SUPER_FORCE)) {
message ("There are non-replayed transaction in old journal,"
" check filesystem consistency first");
reiserfs_close (fs);
return 1;
}
}
}
if (!reiserfs_is_fs_consistent (fs)) {
message ("Check filesystem consistency first");
reiserfs_close (fs);
return 1;
}
}
reiserfs_reopen (fs, O_RDWR);
/* set UUID and LABEL if specified */
if (fs->fs_format == REISERFS_FORMAT_3_6) {
if (uuid_is_correct (UUID)) {
memcpy (fs->fs_ondisk_sb->s_uuid, UUID, 16);
mark_buffer_dirty (fs->fs_super_bh);
}
if (LABEL != NULL) {
if (strlen (LABEL) > 16)
message ("Specified LABEL is longer then 16 characters, will be truncated\n");
strncpy (fs->fs_ondisk_sb->s_label, LABEL, 16);
mark_buffer_dirty (fs->fs_super_bh);
}
fs->fs_dirt = 1;
} else {
if (uuid_is_correct (UUID))
reiserfs_panic ("UUID cannot be specified for 3.5 format\n");
if (LABEL)
reiserfs_panic ("LABEL cannot be specified for 3.5 format\n");
}
if (!j_new_device_name) {
/* new journal device hasn't been specify */
printf ("Current parameters:\n");
print_filesystem_state (stdout, fs);
print_block (stdout, fs, fs->fs_super_bh);
printf ("Current journal parameters:\n");
print_journal_params (stdout, sb_jp (fs->fs_ondisk_sb));
if ((Options & OPT_STANDARD)
&& should_make_journal_standard(fs, j_new_device_name)) {
if (set_standard_journal_params (fs)) {
printf ("\nNew parameters:\n");
print_filesystem_state (stdout, fs);
print_block (stdout, fs, fs->fs_super_bh);
printf ("New journal parameters:\n");
print_journal_params (stdout, sb_jp (fs->fs_ondisk_sb));
mark_buffer_dirty (fs->fs_super_bh);
mark_buffer_uptodate (fs->fs_super_bh, 1);
mark_buffer_dirty (fs->fs_jh_bh);
mark_buffer_uptodate (fs->fs_jh_bh, 1);
reiserfs_close (fs);
printf ("Syncing.."); fflush (stdout);
sync ();
printf ("ok\n");
return 0;
}
}
if (Is_journal_or_maxtrans_size_specified)
/* new journal device hasn't been specified, but
journal size or max transaction size have been, so we suppose
that journal device remains the same */
j_new_device_name = jdevice_name;
else {
/* the only parameter has been specified is device_name, so
there is nothing to do */
reiserfs_close (fs);
return 0;
}
}
/* new journal device has been specified */
/* make sure new journal device is block device file */
if (!can_we_format_it (j_new_device_name, Force)) {
reiserfs_close (fs);
return 1;
}
if (!strcmp (device_name, j_new_device_name)) {
unsigned long reserved, journal_size;
/* we have to put journal on main device. It is only possible if there
is enough space reserved by mkreiserfs */
if (!is_reiserfs_jr_magic_string (fs->fs_ondisk_sb))
/* standard journal */
reserved = get_jp_journal_size(sb_jp(fs->fs_ondisk_sb)) + 1;
else
/* non-standard journal */
reserved = get_sb_reserved_for_journal (fs->fs_ondisk_sb);
journal_size = (Journal_size ? Journal_size : journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize));
/* journal_size = (Journal_size ? Journal_size : // specified
(fs->fs_blocksize == 1024 ? (fs->fs_blocksize) * 8 - 3 -
REISERFS_DISK_OFFSET_IN_BYTES / fs->fs_blocksize :
JOURNAL_DEFAULT_SIZE + 1)); // default
*/
if (journal_size > reserved) {
message ("There is no enough space reserved for journal on main "
"device (journal_size=%lu, reserved=%lu\n", journal_size,
reserved);
reiserfs_close (fs);
return 1;
}
}
message ("Current journal parameters:");
print_journal_params (stdout, sb_jp (fs->fs_ondisk_sb));
if (!is_reiserfs_jr_magic_string (fs->fs_ondisk_sb)) {
/* we have standard journal, so check if we can convert it
to non-standard one */
if (!should_make_journal_non_standard (Force)) {
reiserfs_close (fs);
return 1;
}
if (is_reiserfs_3_6_magic_string (fs->fs_ondisk_sb))
set_sb_version (fs->fs_ondisk_sb, REISERFS_FORMAT_3_6);
else if (is_reiserfs_3_5_magic_string (fs->fs_ondisk_sb))
set_sb_version (fs->fs_ondisk_sb, REISERFS_FORMAT_3_5);
else {
message ("Could not convert from unknown version, try reiserfsck first");
reiserfs_close (fs);
return 1;
}
memcpy (fs->fs_ondisk_sb->s_v1.s_magic, REISERFS_JR_SUPER_MAGIC_STRING,
strlen (REISERFS_JR_SUPER_MAGIC_STRING));
set_sb_reserved_for_journal (fs->fs_ondisk_sb,
get_jp_journal_size (sb_jp(fs->fs_ondisk_sb)) + 1);
}
/* now we are going to close old journal and to create a new one */
reiserfs_close_journal (fs);
if (!reiserfs_create_journal (fs, j_new_device_name, Offset,
Journal_size, Max_trans_size)) {
message ("Could not create new journal");
reiserfs_close (fs);
return 1;
}
if (Options & OPT_STANDARD)
if (should_make_journal_standard (fs, j_new_device_name))
set_standard_journal_params (fs);
message ("New journal parameters:");
print_journal_params (stdout, sb_jp (fs->fs_ondisk_sb));
print_block (stdout, fs, fs->fs_super_bh);
if (Force < 2) {
message ("ATTENTION: YOU ARE ABOUT TO SETUP THE NEW JOURNAL FOR THE \"%s\"!\n"
"AREA OF \"%s\" DEDICATED FOR JOURNAL WILL BE ZEROED!",
device_name, j_new_device_name);
if (!user_confirmed (stderr, "Continue (y/n):", "y\n")) {
return 1;
}
}
zero_journal (fs);
reiserfs_close (fs);
printf ("Syncing.."); fflush (stdout);
sync ();
printf ("ok\n");
return 0;
}
+48
View File
@@ -0,0 +1,48 @@
/*
* Copyright 2002 Hans Reiser, licensing governed by ../README
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <asm/types.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/vfs.h>
#include <time.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <linux/kdev_t.h>
#include <sys/utsname.h>
#include <getopt.h>
#include <stdarg.h>
#include "io.h"
#include "misc.h"
#include "reiserfs_lib.h"
#include "../include/config.h"
#include "../version.h"
/* main.c */
extern reiserfs_filsys_t * fs;
/*
* options
*/
#define OPT_SUPER_FORCE 0x0010
#define OPT_OLD_J 0x0100
#define OPT_NEW_J 0x0200
#define OPT_SIZEJ 0x0400
#define OPT_TMAXS 0x0800
#define OPT_OFSET 0x1000
#define OPT_SKIP_J 0x2000
#define OPT_KEEPO 0x4000
#define OPT_FORCE 0x8000
#define OPT_STANDARD 0x0020
extern char *program_name;