* 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
- * License.
- * %End-Header%
+ * Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
#include <sys/types.h>
#include "e2fsbb.h"
-#include "busybox.h"
+#include "libbb.h"
#ifndef _PATH_MNTTAB
#define _PATH_MNTTAB "/etc/fstab"
* Required for the uber-silly devfs /dev/ide/host1/bus2/target3/lun3
* pathames.
*/
-static const char * const devfs_hier[] = {
+static const char *const devfs_hier[] = {
"host", "bus", "target", "lun", 0
};
#endif
{
char *str, *cp;
#ifdef CONFIG_FEATURE_DEVFS
- const char * const *hier;
+ const char *const *hier;
const char *disk;
int len;
#endif
}
-static const char * const ignored_types[] = {
+static const char *const ignored_types[] = {
"ignore",
"iso9660",
"nfs",
NULL
};
-static const char * const really_wanted[] = {
+static const char *const really_wanted[] = {
"minix",
"ext2",
"ext3",
if (!s)
return 0;
- ret = strdup(s);
+ ret = xstrdup(s);
return ret;
}
if (i->base_device)
free(i->base_device);
free(i);
- return;
}
static struct fs_info *create_fs_device(const char *device, const char *mntpnt,
int old_fstab = 1;
struct fs_info *fs;
- if ((f = fopen(filename, "r")) == NULL) {
- bb_perror_msg("WARNING: cannot open %s", filename);
+ if ((f = fopen_or_warn(filename, "r")) == NULL) {
return;
}
while (!feof(f)) {
/* Find fsck program for a given fs type. */
static char *find_fsck(char *type)
{
- char *s;
- const char *tpl;
- char *p = string_copy(fsck_path);
- struct stat st;
+ char *s;
+ const char *tpl;
+ char *p = string_copy(fsck_path);
+ struct stat st;
- /* Are we looking for a program or just a type? */
- tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
+ /* Are we looking for a program or just a type? */
+ tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
- for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
- s = xasprintf(tpl, s, type);
- if (stat(s, &st) == 0) break;
- free(s);
- }
- free(p);
- return s;
+ for (s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
+ s = xasprintf(tpl, s, type);
+ if (stat(s, &st) == 0) break;
+ free(s);
+ }
+ free(p);
+ return s;
}
static int progress_active(void)
mntpt ? mntpt : device);
for (i=0; i < argc; i++)
printf("%s ", argv[i]);
- puts("");
+ bb_putchar('\n');
}
/* Fork and execute the correct program. */
if (!interactive)
close(0);
(void) execv(s, argv);
- bb_perror_msg_and_die("%s", argv[0]);
+ bb_simple_perror_msg_and_die(argv[0]);
}
for (i = 1; i < argc; i++)
list = string_copy(fs_type);
num = 0;
s = strtok(list, ",");
- while(s) {
+ while (s) {
negate = 0;
if (strncmp(s, "no", 2) == 0) {
s += 2;
list = string_copy(optlist);
s = strtok(list, ",");
- while(s) {
+ while (s) {
if (strcmp(s, opt) == 0) {
free(list);
return 1;
s = find_fsck(fs->type);
if (s == NULL) {
if (wanted)
- bb_error_msg("cannot check %s: fsck.%s not found",
+ bb_error_msg("can't check %s: fsck.%s not found",
fs->device, fs->type);
return 1;
}
cancel_requested++;
}
-static void PRS(int argc, char *argv[])
+static void PRS(int argc, char **argv)
{
int i, j;
char *arg, *dev, *tmp = 0;
* /proc/partitions isn't found.
*/
if (access("/proc/partitions", R_OK) < 0) {
- bb_perror_msg_and_die("cannot open /proc/partitions "
+ bb_perror_msg_and_die("can't open /proc/partitions "
"(is /proc mounted?)");
}
/*
"must be root to scan for matching filesystems: %s\n", arg);
else
bb_error_msg_and_die(
- "cannot find matching filesystem: %s", arg);
+ "can't find matching filesystem: %s", arg);
}
devices[num_devices++] = dev ? dev : string_copy(arg);
continue;
max_running = atoi(tmp);
}
-int fsck_main(int argc, char *argv[]);
-int fsck_main(int argc, char *argv[])
+int fsck_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int fsck_main(int argc, char **argv)
{
int i, status = 0;
int interactive = 0;
interactive++;
return check_all();
}
- for (i = 0 ; i < num_devices; i++) {
+ for (i = 0; i < num_devices; i++) {
if (cancel_requested) {
if (!kill_sent) {
kill_all(SIGTERM);