[Ocfs2-tools-devel] [PATCH 2/3] fsck.ocfs2: Add the '-p' and '-a' options.
Joel Becker
Joel.Becker at oracle.com
Mon Jun 7 14:48:31 PDT 2010
ocfs2 filesystems in /etc/fstab often halt the boot process because
fsck.ocfs2 doesn't understand the '-a' (automatic repair) option. This
is annoying to have to escape from every reboot.
We copy the extN scheme. The '-p' ("preen") option means: "fix whatever
can be corrected safely without asking any questions." Right now, that
just means journal replay for ocfs2. ost->ost_answer will have to get a
smarter mode for us to differentiate between automatic and interactive
repairs.
The '-a' option is just an alias for '-p'.
Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
fsck.ocfs2/fsck.c | 22 ++++++++++++++++++----
fsck.ocfs2/fsck.ocfs2.8.in | 18 +++++++++++++++++-
2 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/fsck.ocfs2/fsck.c b/fsck.ocfs2/fsck.c
index 1941fd4..a3c14b5 100644
--- a/fsck.ocfs2/fsck.c
+++ b/fsck.ocfs2/fsck.c
@@ -118,12 +118,13 @@ static void block_signals(int how)
static void print_usage(void)
{
fprintf(stderr,
- "Usage: fsck.ocfs2 [ -fGnuvVy ] [ -b superblock block ]\n"
+ "Usage: fsck.ocfs2 {-y|-n|-p} [ -fGnuvVy ] [ -b superblock block ]\n"
" [ -B block size ] [-r num] device\n"
"\n"
"Critical flags for emergency repair:\n"
" -n Check but don't change the file system\n"
" -y Answer 'yes' to all repair questions\n"
+ " -p Automatic repair (no questions, only safe repairs)\n"
" -f Force checking even if file system is clean\n"
" -F Ignore cluster locking (dangerous!)\n"
" -r restore backup superblock(dangerous!)\n"
@@ -654,7 +655,7 @@ int main(int argc, char **argv)
setlinebuf(stderr);
setlinebuf(stdout);
- while((c = getopt(argc, argv, "b:B:DfFGnuvVyr:")) != EOF) {
+ while((c = getopt(argc, argv, "b:B:DfFGnupavVyr:")) != EOF) {
switch (c) {
case 'b':
blkno = read_number(optarg);
@@ -696,10 +697,23 @@ int main(int argc, char **argv)
break;
case 'n':
- ost->ost_ask = 0;
- ost->ost_answer = 0;
open_flags &= ~OCFS2_FLAG_RW;
open_flags |= OCFS2_FLAG_RO;
+ /* Fall through */
+
+ case 'a':
+ case 'p':
+ /*
+ * Like extN, -a maps to -p, which is
+ * 'preen'. This means only fix things
+ * that don't require human interaction.
+ * Unlike extN, this is only journal
+ * replay for now. To make it smarter,
+ * ost->ost_answer needs to learn a
+ * new mode.
+ */
+ ost->ost_ask = 0;
+ ost->ost_answer = 0;
break;
case 'y':
diff --git a/fsck.ocfs2/fsck.ocfs2.8.in b/fsck.ocfs2/fsck.ocfs2.8.in
index 4018de0..7d295c8 100644
--- a/fsck.ocfs2/fsck.ocfs2.8.in
+++ b/fsck.ocfs2/fsck.ocfs2.8.in
@@ -2,7 +2,7 @@
.SH "NAME"
fsck.ocfs2 \- Check an \fIOCFS2\fR file system.
.SH "SYNOPSIS"
-\fBfsck.ocfs2\fR [ \fB\-fFGnuvVy\fR ] [ \fB\-b\fR \fIsuperblock block\fR ] [ \fB\-B\fR \fIblock size\fR ] \fIdevice\fR
+\fBfsck.ocfs2\fR [ \fB\-pafFGnuvVy\fR ] [ \fB\-b\fR \fIsuperblock block\fR ] [ \fB\-B\fR \fIblock size\fR ] \fIdevice\fR
.SH "DESCRIPTION"
.PP
\fBfsck.ocfs2\fR is used to check an OCFS2 file system.
@@ -12,6 +12,12 @@ It will almost always be a device file but a regular file will work as well.
.SH "OPTIONS"
.TP
+\fB\-a\fR
+This option does the same thing as the \fB-p\fR option. It is provided for
+backwards compatibility only: it is suggested that people use the \fB-p\fR
+option whenever possible.
+
+.TP
\fB\-b\fR \fIsuperblock block\fR
Normally, \fBfsck.ocfs2\fR will read the superblock from the first block of
the device. This option specifies an alternate block that the superblock
@@ -56,6 +62,16 @@ read-only. The output of \fBfsck.ocfs2\fR with this option can be redirected
to produce a record of a file system's faults.
.TP
+\fB\-p\fR
+Automatically repair ("preen") the file system. This option will cause
+\fBfsck.ocfs2\fR to automatically fix any problem that can be safely
+corrected without human intervention. If there are problems that require
+intervention, the descriptions will be printed and fsck.ocfs2 will exit
+with the value 4 logically or'd into the exit code. (See the
+\fBEXIT CODE\fR section.) This option is normally used by the system's
+boot scripts.
+
+.TP
\fB\-r\fR \fIbackup-number\fR
\fImkfs.ocfs2\fR makes upto 6 backup copies of the superblock at offsets
1G, 4G, 16G, 64G, 256G and 1T depending on the size of the volume.
--
1.7.1
--
"Behind every successful man there's a lot of unsuccessful years."
- Bob Brown
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
More information about the Ocfs2-tools-devel
mailing list