erofs-utils: fsck: Add -a, -A, and -y flags
authorLuke T. Shumaker <lukeshu@umorpha.io>
Thu, 2 Nov 2023 19:31:22 +0000 (13:31 -0600)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Mon, 6 Nov 2023 05:42:17 +0000 (13:42 +0800)
Other fsck.${filesystem} commands generally take -a or -p and
sometimes -A to automatically repair a filesystem, and -y to either
repair agree to all prompts about repairing.

For example:

 - fsck.ext{2,3,4} takes -a or -p to repair, and -y to agree
 - fsck.xfs takes -y to repair; and -a, -A, or -p to silence a warning
   about repairing
 - fsck.btrfs takes -a, -A, -p, or -y to silence a warning about repairing

So, like fsck.btrfs, we should accept these flags as no-ops, for
compatibility with programs that expect to be able to pass these to
fsck.  In particular, Arch Linux's mkinitcpio (when fsck is enabled)
unconditionally passes -a to `fsck`.

Naturally, I'd have liked to include '-p' in the list, but it already
does something different for fsck.erofs.  I'd like to call out the
fsck.ext4 manual, which says:

       -a   This option does the same thing as the -p option. It is
            provided for backwards compatibility only; it is
            suggested that people use -p option whenever possible.

Signed-off-by: Luke T. Shumaker <lukeshu@umorpha.io>
Link: https://lore.kernel.org/r/20231102193122.140921-4-lukeshu@lukeshu.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fsck/main.c
man/fsck.erofs.1

index aeea892a720d1f8f9c541ba057763d03390c95cb..26cd1316f9254695a0b97e2cc2e649b0bead4343 100644 (file)
@@ -98,6 +98,8 @@ static void usage(int argc, char **argv)
                " --extract[=X]          check if all files are well encoded, optionally\n"
                "                        extract to X\n"
                "\n"
+               " -a, -A, -y             no-op, for compatibility with fsck of other filesystems\n"
+               "\n"
                "Extraction options (--extract=X is required):\n"
                " --force                allow extracting to root\n"
                " --overwrite            overwrite files that already exist\n"
@@ -124,7 +126,7 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv)
        int opt, ret;
        bool has_opt_preserve = false;
 
-       while ((opt = getopt_long(argc, argv, "Vd:ph",
+       while ((opt = getopt_long(argc, argv, "Vd:phaAy",
                                  long_options, NULL)) != -1) {
                switch (opt) {
                case 'V':
@@ -144,6 +146,10 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv)
                case 'h':
                        usage(argc, argv);
                        exit(0);
+               case 'a':
+               case 'A':
+               case 'y':
+                       break;
                case 2:
                        fsckcfg.check_decomp = true;
                        if (optarg) {
index a226995327e846096b4531472dfda4931f64faa9..c94fff9c025a9d6a3f6e4c07ec748f8d03d00300 100644 (file)
@@ -34,6 +34,10 @@ so it might take too much time depending on the image.
 .TP
 \fB\-h\fR, \fB\-\-help\fR
 Display help string and exit.
+.TP
+\fB\-a\fR, \fB\-A\fR, \fB-y\R
+These options do nothing at all; they are provided only for compatibility with
+the fsck programs of other filesystems.
 .SH AUTHOR
 This version of \fBfsck.erofs\fR is written by
 Daeho Jeong <daehojeong@google.com>.