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