*
* Written by Theodore Ts'o, <tytso@mit.edu>
*
- * Usage: fsck [-ACVRNTM] [-s] [-t fstype] [fs-options] device
- *
* Miquel van Smoorenburg (miquels@drinkel.ow.org) 20-Oct-1994:
* o Changed -t fstype to behave like with mount when -A (all file
* systems) or -M (like mount) is specified.
* can be added without changing this front-end.
* o -R flag skip root file system.
*
- * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999 Theodore Ts'o.
+ * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+ * 2001, 2002, 2003, 2004, 2005 by Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
#include "../version.h"
#include "nls-enable.h"
int notitle = 0;
int parallel_root = 0;
int progress = 0;
+int progress_fd = 0;
int force_all_parallel = 0;
int num_running = 0;
int max_running = 0;
return ret;
}
+static int string_to_int(const char *s)
+{
+ long l;
+ char *p;
+
+ l = strtol(s, &p, 0);
+ if (*p || l == LONG_MIN || l == LONG_MAX || l < 0 || l > INT_MAX)
+ return -1;
+ else
+ return (int) l;
+}
+
static int ignore(struct fs_info *);
static char *skip_over_blank(char *cp)
fclose(f);
if (old_fstab) {
- fprintf(stderr, _("\007\007\007"
+ fputs(_("\007\007\007"
"WARNING: Your /etc/fstab does not contain the fsck passno\n"
" field. I will kludge around things for you, but you\n"
- " should fix your /etc/fstab file as soon as you can.\n\n"));
+ " should fix your /etc/fstab file as soon as you can.\n\n"), stderr);
for (fs = filesys_info; fs; fs = fs->next) {
fs->passno = 1;
for (i=0; i <num_args; i++)
argv[argc++] = string_copy(args[i]);
- if (progress & !progress_active()) {
+ if (progress && !progress_active()) {
if ((strcmp(type, "ext2") == 0) ||
(strcmp(type, "ext3") == 0)) {
- argv[argc++] = string_copy("-C0");
+ char tmp[80];
+ snprintf(tmp, 80, "-C%d", progress_fd);
+ argv[argc++] = string_copy(tmp);
inst->flags |= FLAG_PROGRESS;
}
}
cmp->list = malloc(num * sizeof(char *));
cmp->type = malloc(num * sizeof(int));
if (!cmp->list || !cmp->type) {
- fprintf(stderr, _("Couldn't allocate memory for "
- "filesystem types\n"));
+ fputs(_("Couldn't allocate memory for filesystem types\n"),
+ stderr);
exit(EXIT_ERROR);
}
memset(cmp->list, 0, num * sizeof(char *));
}
if ((negate && !cmp->negate) ||
(!negate && cmp->negate)) {
- fprintf(stderr, _(fs_type_syntax_error));
+ fputs(_(fs_type_syntax_error), stderr);
exit(EXIT_USAGE);
}
}
int pass_done;
if (verbose)
- printf(_("Checking all file systems.\n"));
+ fputs(_("Checking all file systems.\n"), stdout);
/*
* Do an initial scan over the filesystem; mark filesystems
static void usage(NOARGS)
{
- fprintf(stderr,
- _("Usage: fsck [-ACNPRTV] [-t fstype] [fs-options] [filesys ...]\n"));
+ fputs(_("Usage: fsck [-ANPRTV] [ -C [ fd ] ] [-t fstype] [fs-options] [filesys ...]\n"), stderr);
exit(EXIT_USAGE);
}
#ifdef HAVE_SIGNAL_H
-static void signal_cancel(int sig)
+static void signal_cancel(int sig FSCK_ATTR((unused)))
{
cancel_requested++;
}
break;
case 'C':
progress++;
+ if (arg[j+1]) {
+ progress_fd = string_to_int(arg+j+1);
+ if (progress_fd < 0)
+ progress_fd = 0;
+ else
+ goto next_arg;
+ } else if ((i+1) < argc &&
+ !strncmp(argv[i+1], "-", 1) == 0) {
+ progress_fd = string_to_int(argv[i]);
+ if (progress_fd < 0)
+ progress_fd = 0;
+ else {
+ goto next_arg;
+ i++;
+ }
+ }
break;
case 'V':
verbose++;
serialize++;
break;
case 't':
+ tmp = 0;
if (fstype)
usage();
if (arg[j+1])
if (oldpath) {
fsck_path = malloc (strlen (fsck_prefix_path) + 1 +
strlen (oldpath) + 1);
+ if (!fsck_path) {
+ fprintf(stderr, "%s: Unable to allocate memory for fsck_path\n", progname);
+ exit(EXIT_ERROR);
+ }
strcpy (fsck_path, fsck_prefix_path);
strcat (fsck_path, ":");
strcat (fsck_path, oldpath);