|
|
ffc768 |
commit 1061c4767b1d511a9461cd3bcf2e40239cf77d8a
|
|
|
ffc768 |
Author: Andrew Price <anprice@redhat.com>
|
|
|
ffc768 |
Date: Tue Oct 31 11:19:38 2017 +0000
|
|
|
ffc768 |
|
|
|
ffc768 |
fsck.gfs2: Make -p, -n and -y conflicting options
|
|
|
ffc768 |
|
|
|
ffc768 |
Exit with FSCK_USAGE when these options are used in combination. Also
|
|
|
ffc768 |
update the man page to make this behaviour explicit with other tweaks
|
|
|
ffc768 |
for conciseness. Tests included.
|
|
|
ffc768 |
|
|
|
ffc768 |
Resolves: rhbz#1507091
|
|
|
ffc768 |
|
|
|
ffc768 |
Signed-off-by: Andrew Price <anprice@redhat.com>
|
|
|
ffc768 |
|
|
|
ffc768 |
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
|
|
|
ffc768 |
index cd260ef3..ecdcd0f6 100644
|
|
|
ffc768 |
--- a/gfs2/fsck/main.c
|
|
|
ffc768 |
+++ b/gfs2/fsck/main.c
|
|
|
ffc768 |
@@ -75,6 +75,11 @@ static int read_cmdline(int argc, char **argv, struct gfs2_options *gopts)
|
|
|
ffc768 |
switch(c) {
|
|
|
ffc768 |
|
|
|
ffc768 |
case 'a':
|
|
|
ffc768 |
+ case 'p':
|
|
|
ffc768 |
+ if (gopts->yes || gopts->no) {
|
|
|
ffc768 |
+ fprintf(stderr, _("Options -p/-a, -y and -n may not be used together\n"));
|
|
|
ffc768 |
+ return FSCK_USAGE;
|
|
|
ffc768 |
+ }
|
|
|
ffc768 |
preen = 1;
|
|
|
ffc768 |
gopts->yes = 1;
|
|
|
ffc768 |
break;
|
|
|
ffc768 |
@@ -86,12 +91,12 @@ static int read_cmdline(int argc, char **argv, struct gfs2_options *gopts)
|
|
|
ffc768 |
exit(FSCK_OK);
|
|
|
ffc768 |
break;
|
|
|
ffc768 |
case 'n':
|
|
|
ffc768 |
+ if (gopts->yes || preen) {
|
|
|
ffc768 |
+ fprintf(stderr, _("Options -p/-a, -y and -n may not be used together\n"));
|
|
|
ffc768 |
+ return FSCK_USAGE;
|
|
|
ffc768 |
+ }
|
|
|
ffc768 |
gopts->no = 1;
|
|
|
ffc768 |
break;
|
|
|
ffc768 |
- case 'p':
|
|
|
ffc768 |
- preen = 1;
|
|
|
ffc768 |
- gopts->yes = 1;
|
|
|
ffc768 |
- break;
|
|
|
ffc768 |
case 'q':
|
|
|
ffc768 |
decrease_verbosity();
|
|
|
ffc768 |
break;
|
|
|
ffc768 |
@@ -103,6 +108,10 @@ static int read_cmdline(int argc, char **argv, struct gfs2_options *gopts)
|
|
|
ffc768 |
exit(FSCK_OK);
|
|
|
ffc768 |
break;
|
|
|
ffc768 |
case 'y':
|
|
|
ffc768 |
+ if (gopts->no || preen) {
|
|
|
ffc768 |
+ fprintf(stderr, _("Options -p/-a, -y and -n may not be used together\n"));
|
|
|
ffc768 |
+ return FSCK_USAGE;
|
|
|
ffc768 |
+ }
|
|
|
ffc768 |
gopts->yes = 1;
|
|
|
ffc768 |
break;
|
|
|
ffc768 |
case ':':
|
|
|
ffc768 |
diff --git a/gfs2/man/fsck.gfs2.8 b/gfs2/man/fsck.gfs2.8
|
|
|
ffc768 |
index 56dcddcd..b2b326fb 100644
|
|
|
ffc768 |
--- a/gfs2/man/fsck.gfs2.8
|
|
|
ffc768 |
+++ b/gfs2/man/fsck.gfs2.8
|
|
|
ffc768 |
@@ -40,7 +40,7 @@ administration.
|
|
|
ffc768 |
.SH OPTIONS
|
|
|
ffc768 |
.TP
|
|
|
ffc768 |
\fB-a\fP
|
|
|
ffc768 |
-Same as the -p (preen) option.
|
|
|
ffc768 |
+Same as the \fB-p\fP (preen) option.
|
|
|
ffc768 |
.TP
|
|
|
ffc768 |
\fB-f\fP
|
|
|
ffc768 |
Force checking even if the file system seems clean.
|
|
|
ffc768 |
@@ -54,29 +54,26 @@ This prints out the proper command line usage syntax.
|
|
|
ffc768 |
Quiet.
|
|
|
ffc768 |
.TP
|
|
|
ffc768 |
\fB-n\fP
|
|
|
ffc768 |
-No to all questions.
|
|
|
ffc768 |
-
|
|
|
ffc768 |
-By specifying this option, fsck.gfs2 will only show the changes that
|
|
|
ffc768 |
+No to all questions. By specifying this option, fsck.gfs2 will only show the changes that
|
|
|
ffc768 |
would be made, but not make any changes to the filesystem.
|
|
|
ffc768 |
+
|
|
|
ffc768 |
+This option may not be used with the \fB-y\fP or \fB-p\fP/\fB-a\fP options.
|
|
|
ffc768 |
.TP
|
|
|
ffc768 |
\fB-p\fP
|
|
|
ffc768 |
-Preen (same as -a: automatically repair the file system if it is dirty,
|
|
|
ffc768 |
-and safe to do so, otherwise exit.)
|
|
|
ffc768 |
+Automatically repair ("preen") the file system if it is dirty and safe to do so,
|
|
|
ffc768 |
+otherwise exit.
|
|
|
ffc768 |
+
|
|
|
ffc768 |
+If the file system has locking protocol \fIlock_nolock\fR, it is considered a
|
|
|
ffc768 |
+non-shared storage device and it is considered safe. If the locking protocol
|
|
|
ffc768 |
+is lock_dlm and \fB-a\fP or \fB-p\fP was specified, the check is considered unsafe as it
|
|
|
ffc768 |
+cannot be determined whether the device is mounted by other nodes in the cluster.
|
|
|
ffc768 |
+In this case a warning is given if any damage or dirty journals are found. The
|
|
|
ffc768 |
+file system should then be unmounted from all nodes in the cluster and
|
|
|
ffc768 |
+fsck.gfs2 should be run manually without the \fB-a\fP or \fB-p\fP options.
|
|
|
ffc768 |
|
|
|
ffc768 |
-Note: If the file system has locking protocol lock_nolock, the file system
|
|
|
ffc768 |
-is considered a non-shared storage device and the fsck is deemed safe.
|
|
|
ffc768 |
-However, fsck.gfs2 does not know whether it was called automatically
|
|
|
ffc768 |
-from the init process, due to options in the /etc/fstab file. Therefore, if
|
|
|
ffc768 |
-the locking protocol is lock_dlm and -a or -p was specified, fsck.gfs2
|
|
|
ffc768 |
-cannot determine whether the disk is mounted by other nodes in the cluster.
|
|
|
ffc768 |
-Therefore, the fsck is deemed to be unsafe and a warning is given
|
|
|
ffc768 |
-if any damage or dirty journals are found. In that case, the file system
|
|
|
ffc768 |
-should be unmounted from all nodes in the cluster and fsck.gfs2 should be
|
|
|
ffc768 |
-run manually without the -a or -p options.
|
|
|
ffc768 |
+This option may not be used with the \fB-n\fP or \fB-y\fP options.
|
|
|
ffc768 |
.TP
|
|
|
ffc768 |
\fB-V\fP
|
|
|
ffc768 |
-Version.
|
|
|
ffc768 |
-
|
|
|
ffc768 |
Print out the program version information.
|
|
|
ffc768 |
.TP
|
|
|
ffc768 |
\fB-v\fP
|
|
|
ffc768 |
@@ -85,7 +82,7 @@ Verbose operation.
|
|
|
ffc768 |
Print more information while running.
|
|
|
ffc768 |
.TP
|
|
|
ffc768 |
\fB-y\fP
|
|
|
ffc768 |
-Yes to all questions.
|
|
|
ffc768 |
-
|
|
|
ffc768 |
-By specifying this option, fsck.gfs2 will not prompt before making
|
|
|
ffc768 |
+Yes to all questions. By specifying this option, fsck.gfs2 will not prompt before making
|
|
|
ffc768 |
changes.
|
|
|
ffc768 |
+
|
|
|
ffc768 |
+This option may not be used with the \fB-n\fP or \fB-p\fP/\fB-a\fP options.
|
|
|
ffc768 |
diff --git a/tests/fsck.at b/tests/fsck.at
|
|
|
ffc768 |
index b9953fb4..0dfeac33 100644
|
|
|
ffc768 |
--- a/tests/fsck.at
|
|
|
ffc768 |
+++ b/tests/fsck.at
|
|
|
ffc768 |
@@ -1,6 +1,17 @@
|
|
|
ffc768 |
AT_TESTED([fsck.gfs2])
|
|
|
ffc768 |
AT_BANNER([fsck.gfs2 tests])
|
|
|
ffc768 |
|
|
|
ffc768 |
+AT_SETUP([Conflicting options])
|
|
|
ffc768 |
+AT_KEYWORDS(fsck.gfs2 fsck)
|
|
|
ffc768 |
+# Error code 16 is FSCK_USAGE
|
|
|
ffc768 |
+AT_CHECK([fsck.gfs2 -y -n $GFS_TGT], 16, [ignore], [ignore])
|
|
|
ffc768 |
+AT_CHECK([fsck.gfs2 -n -y $GFS_TGT], 16, [ignore], [ignore])
|
|
|
ffc768 |
+AT_CHECK([fsck.gfs2 -n -p $GFS_TGT], 16, [ignore], [ignore])
|
|
|
ffc768 |
+AT_CHECK([fsck.gfs2 -p -n $GFS_TGT], 16, [ignore], [ignore])
|
|
|
ffc768 |
+AT_CHECK([fsck.gfs2 -y -p $GFS_TGT], 16, [ignore], [ignore])
|
|
|
ffc768 |
+AT_CHECK([fsck.gfs2 -p -y $GFS_TGT], 16, [ignore], [ignore])
|
|
|
ffc768 |
+AT_CLEANUP
|
|
|
ffc768 |
+
|
|
|
ffc768 |
AT_SETUP([Fix invalid block sizes])
|
|
|
ffc768 |
AT_KEYWORDS(fsck.gfs2 fsck)
|
|
|
ffc768 |
GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set sb { sb_bsize: 0 }])
|