Skip to content

Commit f973118

Browse files
Luke T. Shumakerhsiangkao
authored andcommitted
erofs-utils: fsck: Add -a, -A, and -y flags
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>
1 parent 197e329 commit f973118

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

fsck/main.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ static void usage(int argc, char **argv)
9898
" --extract[=X] check if all files are well encoded, optionally\n"
9999
" extract to X\n"
100100
"\n"
101+
" -a, -A, -y no-op, for compatibility with fsck of other filesystems\n"
102+
"\n"
101103
"Extraction options (--extract=X is required):\n"
102104
" --force allow extracting to root\n"
103105
" --overwrite overwrite files that already exist\n"
@@ -124,7 +126,7 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv)
124126
int opt, ret;
125127
bool has_opt_preserve = false;
126128

127-
while ((opt = getopt_long(argc, argv, "Vd:ph",
129+
while ((opt = getopt_long(argc, argv, "Vd:phaAy",
128130
long_options, NULL)) != -1) {
129131
switch (opt) {
130132
case 'V':
@@ -144,6 +146,10 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv)
144146
case 'h':
145147
usage(argc, argv);
146148
exit(0);
149+
case 'a':
150+
case 'A':
151+
case 'y':
152+
break;
147153
case 2:
148154
fsckcfg.check_decomp = true;
149155
if (optarg) {

man/fsck.erofs.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ so it might take too much time depending on the image.
3434
.TP
3535
\fB\-h\fR, \fB\-\-help\fR
3636
Display help string and exit.
37+
.TP
38+
\fB\-a\fR, \fB\-A\fR, \fB-y\R
39+
These options do nothing at all; they are provided only for compatibility with
40+
the fsck programs of other filesystems.
3741
.SH AUTHOR
3842
This version of \fBfsck.erofs\fR is written by
3943
Daeho Jeong <daehojeong@google.com>.

0 commit comments

Comments
 (0)