fsck.minix: introduce long options to the command
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
86a9f3dad5
commit
158b8d6918
|
@ -1,16 +1,16 @@
|
||||||
_fsck.minix_module()
|
_fsck.minix_module()
|
||||||
{
|
{
|
||||||
local cur prev OPTS
|
local cur OPTS
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
case $cur in
|
||||||
case $prev in
|
-*)
|
||||||
'-V'|'--version')
|
OPTS="--list --auto --repair --verbose --super --uncleared --force --help --version"
|
||||||
|
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
OPTS="-l -a -r -v -s -m -f --version"
|
COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
|
||||||
COMPREPLY=( $(compgen -W "${OPTS[*]} $(lsblk -pnro name)" -- $cur) )
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
complete -F _fsck.minix_module fsck.minix
|
complete -F _fsck.minix_module fsck.minix
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
.\" Copyright 1992, 1993, 1994 Rickard E. Faith (faith@cs.unc.edu)
|
.\" Copyright 1992, 1993, 1994 Rickard E. Faith (faith@cs.unc.edu)
|
||||||
.\" May be freely distributed.
|
.\" May be freely distributed.
|
||||||
.TH FSCK.MINIX 8 "July 1996" "util-linux" "System Administration"
|
.TH FSCK.MINIX 8 "June 2015" "util-linux" "System Administration"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
fsck.minix \- check consistency of Minix filesystem
|
fsck.minix \- check consistency of Minix filesystem
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B fsck.minix
|
.B fsck.minix
|
||||||
.RB [ \-larvsmf ]
|
[options]
|
||||||
.I device
|
.I device
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B fsck.minix
|
.B fsck.minix
|
||||||
performs a consistency check for the Linux MINIX filesystem. The current
|
performs a consistency check for the Linux MINIX filesystem.
|
||||||
version supports the 14 character and 30 character filename options.
|
|
||||||
|
|
||||||
The program
|
The program
|
||||||
assumes the filesystem is quiescent.
|
assumes the filesystem is quiescent.
|
||||||
|
@ -51,31 +50,37 @@ on a mounted filesystem (i.e., the root filesystem), make sure nothing is
|
||||||
writing to the disk, and that no files are "zombies" waiting for deletion.
|
writing to the disk, and that no files are "zombies" waiting for deletion.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B \-l
|
\fB\-l\fR, \fB\-\-list\fR
|
||||||
List all filenames.
|
List all filenames.
|
||||||
.TP
|
.TP
|
||||||
.B \-r
|
\fB\-r\fR, \fB\-\-repair\fR
|
||||||
Perform interactive repairs.
|
Perform interactive repairs.
|
||||||
.TP
|
.TP
|
||||||
.B \-a
|
\fB\-a\fR, \fB\-\-auto\fR
|
||||||
Perform automatic repairs. (This option implies
|
Perform automatic repairs. (This option implies
|
||||||
.B \-r
|
.B \-\-repair
|
||||||
and serves to answer all of the questions asked with the default.) Note
|
and serves to answer all of the questions asked with the default.) Note
|
||||||
that this can be extremely dangerous in the case of extensive filesystem
|
that this can be extremely dangerous in the case of extensive filesystem
|
||||||
damage.
|
damage.
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
\fB\-v\fR, \fB\-\-verbose\fR
|
||||||
Be verbose.
|
Be verbose.
|
||||||
.TP
|
.TP
|
||||||
.B \-s
|
\fB\-s\fR, \fB\-\-super\fR
|
||||||
Output super-block information.
|
Output super-block information.
|
||||||
.TP
|
.TP
|
||||||
.B \-m
|
\fB\-m\fR, \fB\-\-uncleared\fR
|
||||||
Activate MINIX-like "mode not cleared" warnings.
|
Activate MINIX-like "mode not cleared" warnings.
|
||||||
.TP
|
.TP
|
||||||
.B \-f
|
\fB\-f\fR, \fB\-\-force\fR
|
||||||
Force a filesystem check even if the filesystem was marked as valid (this
|
Force a filesystem check even if the filesystem was marked as valid (this
|
||||||
marking is done by the kernel when the filesystem is unmounted).
|
marking is done by the kernel when the filesystem is unmounted).
|
||||||
|
.TP
|
||||||
|
\fB\-V\fR, \fB\-\-version\fR
|
||||||
|
Display version information and exit.
|
||||||
|
.TP
|
||||||
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
|
Display help text and exit.
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.BR fsck (8),
|
.BR fsck (8),
|
||||||
.BR fsck.ext2 (8),
|
.BR fsck.ext2 (8),
|
||||||
|
|
|
@ -76,17 +76,6 @@
|
||||||
* unless you can be sure nobody is writing to it (and remember that the
|
* unless you can be sure nobody is writing to it (and remember that the
|
||||||
* kernel can write to it when it searches for files).
|
* kernel can write to it when it searches for files).
|
||||||
*
|
*
|
||||||
* Usuage: fsck [-larvsm] device
|
|
||||||
* -l for a listing of all the filenames
|
|
||||||
* -a for automatic repairs (not implemented)
|
|
||||||
* -r for repairs (interactive) (not implemented)
|
|
||||||
* -v for verbose (tells how many files)
|
|
||||||
* -s for super-block info
|
|
||||||
* -m for minix-like "mode not cleared" warnings
|
|
||||||
* -f force filesystem check even if filesystem marked as valid
|
|
||||||
*
|
|
||||||
* The device may be a block device or a image of one, but this isn't
|
|
||||||
* enforced (but it's not much fun on a character device :-).
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -101,6 +90,7 @@
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "exitcodes.h"
|
#include "exitcodes.h"
|
||||||
|
@ -181,33 +171,31 @@ fatalsig(int sig) {
|
||||||
raise(sig);
|
raise(sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void __attribute__((__noreturn__))
|
||||||
leave(int status) {
|
leave(int status) {
|
||||||
reset();
|
reset();
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(void) {
|
usage(FILE *out) {
|
||||||
fputs(USAGE_HEADER, stderr);
|
fputs(USAGE_HEADER, out);
|
||||||
fprintf(stderr,
|
fprintf(out, _(" %s [options] <device>\n"), program_invocation_short_name);
|
||||||
_(" %s [options] <device>\n"), program_invocation_short_name);
|
fputs(USAGE_SEPARATOR, out);
|
||||||
|
fputs(_("Check the consistency of a Minix filesystem.\n"), out);
|
||||||
fputs(USAGE_SEPARATOR, stderr);
|
fputs(USAGE_OPTIONS, out);
|
||||||
fputs(_("Check the consistency of a Minix filesystem.\n"), stderr);
|
fputs(_(" -l, --list list all filenames\n"), out);
|
||||||
|
fputs(_(" -a, --auto automatic repair\n"), out);
|
||||||
fputs(USAGE_OPTIONS, stderr);
|
fputs(_(" -r, --repair interactive repair\n"), out);
|
||||||
fputs(_(" -l list all filenames\n"), stderr);
|
fputs(_(" -v, --verbose be verbose\n"), out);
|
||||||
fputs(_(" -a automatic repair\n"), stderr);
|
fputs(_(" -s, --super output super-block information\n"), out);
|
||||||
fputs(_(" -r interactive repair\n"), stderr);
|
fputs(_(" -m, --uncleared activate mode not cleared warnings\n"), out);
|
||||||
fputs(_(" -v be verbose\n"), stderr);
|
fputs(_(" -f, --force force check\n"), out);
|
||||||
fputs(_(" -s output super-block information\n"), stderr);
|
fputs(USAGE_SEPARATOR, out);
|
||||||
fputs(_(" -m activate mode not cleared warnings\n"), stderr);
|
fputs(USAGE_HELP, out);
|
||||||
fputs(_(" -f force check\n"), stderr);
|
fputs(USAGE_VERSION, out);
|
||||||
fputs(USAGE_SEPARATOR, stderr);
|
fprintf(out, USAGE_MAN_TAIL("fsck.minix(8)"));
|
||||||
fputs(USAGE_VERSION, stderr);
|
leave(out == stderr ? FSCK_EX_USAGE : FSCK_EX_OK);
|
||||||
fprintf(stderr, USAGE_MAN_TAIL("fsck.minix(8)"));
|
|
||||||
leave(FSCK_EX_USAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void die(const char *fmt, ...)
|
static void die(const char *fmt, ...)
|
||||||
|
@ -1259,33 +1247,32 @@ main(int argc, char **argv) {
|
||||||
struct termios tmp;
|
struct termios tmp;
|
||||||
int count;
|
int count;
|
||||||
int retcode = FSCK_EX_OK;
|
int retcode = FSCK_EX_OK;
|
||||||
|
int i;
|
||||||
|
static const struct option longopts[] = {
|
||||||
|
{"list", no_argument, NULL, 'l'},
|
||||||
|
{"auto", no_argument, NULL, 'a'},
|
||||||
|
{"repair", no_argument, NULL, 'r'},
|
||||||
|
{"verbose", no_argument, NULL, 'v'},
|
||||||
|
{"super", no_argument, NULL, 's'},
|
||||||
|
{"uncleared", no_argument, NULL, 'm'},
|
||||||
|
{"force", no_argument, NULL, 'f'},
|
||||||
|
{"version", no_argument, NULL, 'V'},
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{NULL, 0, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
atexit(close_stdout);
|
atexit(close_stdout);
|
||||||
|
|
||||||
if (argc == 2 &&
|
|
||||||
(!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) {
|
|
||||||
printf(UTIL_LINUX_VERSION);
|
|
||||||
exit(FSCK_EX_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (INODE_SIZE * MINIX_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
|
if (INODE_SIZE * MINIX_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
|
||||||
die(_("bad inode size"));
|
die(_("bad inode size"));
|
||||||
if (INODE2_SIZE * MINIX2_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
|
if (INODE2_SIZE * MINIX2_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
|
||||||
die(_("bad v2 inode size"));
|
die(_("bad v2 inode size"));
|
||||||
|
|
||||||
while (argc-- > 1) {
|
while ((i = getopt_long(argc, argv, "larvsmfVh", longopts, NULL)) != -1)
|
||||||
argv++;
|
switch (i) {
|
||||||
if (argv[0][0] != '-') {
|
|
||||||
if (device_name)
|
|
||||||
usage();
|
|
||||||
else
|
|
||||||
device_name = argv[0];
|
|
||||||
} else
|
|
||||||
while (*++argv[0])
|
|
||||||
switch (argv[0][0]) {
|
|
||||||
case 'l':
|
case 'l':
|
||||||
list = 1;
|
list = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -1309,12 +1296,21 @@ main(int argc, char **argv) {
|
||||||
case 'f':
|
case 'f':
|
||||||
force = 1;
|
force = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'V':
|
||||||
|
printf(UTIL_LINUX_VERSION);
|
||||||
|
return FSCK_EX_OK;
|
||||||
|
case 'h':
|
||||||
|
usage(stdout);
|
||||||
default:
|
default:
|
||||||
usage();
|
usage(stderr);
|
||||||
}
|
}
|
||||||
}
|
argc -= optind;
|
||||||
if (!device_name)
|
argv += optind;
|
||||||
usage();
|
if (0 < argc) {
|
||||||
|
device_name = argv[0];
|
||||||
|
} else
|
||||||
|
usage(stderr);
|
||||||
|
|
||||||
check_mount(); /* trying to check a mounted filesystem? */
|
check_mount(); /* trying to check a mounted filesystem? */
|
||||||
if (repair && !automatic) {
|
if (repair && !automatic) {
|
||||||
if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO))
|
if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO))
|
||||||
|
|
Loading…
Reference in New Issue