diff options
author | Denis Vlasenko | 2006-12-26 02:51:29 +0000 |
---|---|---|
committer | Denis Vlasenko | 2006-12-26 02:51:29 +0000 |
commit | 0de9375ee6e766cf15942c6582c79b0ac6d310f5 (patch) | |
tree | 69a866577fc99e3e0c3153f486f22a2e675028a0 | |
parent | c4f623ef2a7980a63de7c9f1d539a656b83f10e7 (diff) | |
download | busybox-0de9375ee6e766cf15942c6582c79b0ac6d310f5.zip busybox-0de9375ee6e766cf15942c6582c79b0ac6d310f5.tar.gz |
leftover of e2fsck surgery
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | e2fsprogs/fsck.c | 118 | ||||
-rw-r--r-- | include/applets.h | 18 | ||||
-rw-r--r-- | include/libbb.h | 1 | ||||
-rw-r--r-- | include/usage.h | 8 | ||||
-rw-r--r-- | libbb/dump.c | 4 | ||||
-rw-r--r-- | libbb/skip_whitespace.c | 9 |
7 files changed, 61 insertions, 101 deletions
@@ -429,10 +429,6 @@ libs-y := \ coreutils/libcoreutils/ \ debianutils/ \ e2fsprogs/ \ - e2fsprogs/blkid/ \ - e2fsprogs/e2p/ \ - e2fsprogs/ext2fs/ \ - e2fsprogs/uuid/ \ editors/ \ findutils/ \ init/ \ diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c index d59206c..396174e 100644 --- a/e2fsprogs/fsck.c +++ b/e2fsprogs/fsck.c @@ -27,7 +27,6 @@ */ #include "busybox.h" -/*#include "e2fs_lib.h"*/ #define EXIT_OK 0 #define EXIT_NONDESTRUCT 1 @@ -41,9 +40,6 @@ #define DEFAULT_FSTYPE "ext2" #endif -#define MAX_DEVICES 32 -#define MAX_ARGS 32 - /* * Internal structure for mount tabel entries. */ @@ -76,7 +72,7 @@ struct fsck_instance { struct fsck_instance *next; }; -static const char * const ignored_types[] = { +static const char *const ignored_types[] = { "ignore", "iso9660", "nfs", @@ -88,7 +84,8 @@ static const char * const ignored_types[] = { NULL }; -static const char * const really_wanted[] = { +#if 0 +static const char *const really_wanted[] = { "minix", "ext2", "ext3", @@ -98,16 +95,15 @@ static const char * const really_wanted[] = { "xfs", NULL }; +#endif #define BASE_MD "/dev/md" -/* - * Global variables for options - */ +static volatile int cancel_requested; + static char **devices; static char **args; static int num_devices, num_args; - static int verbose; static int doall; static int noexecute; @@ -121,13 +117,10 @@ static int progress_fd; static int force_all_parallel; static int num_running; static int max_running; -static volatile int cancel_requested; -static int kill_sent; static char *fstype; -static struct fs_info *filesys_info, *filesys_last; +static struct fs_info *filesys_info; +static struct fs_info *filesys_last; static struct fsck_instance *instance_list; -/*static char *fsck_path;*/ -/*static blkid_cache cache;*/ #define FS_TYPE_FLAG_NORMAL 0 #define FS_TYPE_FLAG_OPT 1 @@ -439,11 +432,10 @@ static void load_fs_info(const char *filename) fclose(f); if (old_fstab) { - 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", stderr); - + fputs("\007" +"WARNING: Your /etc/fstab does not contain the fsck passno field.\n" +"I will kludge around things for you, but you should fix\n" +"your /etc/fstab file as soon as you can.\n\n", stderr); for (fs = filesys_info; fs; fs = fs->next) { fs->passno = 1; } @@ -455,10 +447,6 @@ static struct fs_info *lookup(char *filesys) { struct fs_info *fs; - /* No filesys name given. */ - if (filesys == NULL) - return NULL; - for (fs = filesys_info; fs; fs = fs->next) { if (strcmp(filesys, fs->device) == 0 || (fs->mountpt && strcmp(filesys, fs->mountpt) == 0) @@ -469,29 +457,6 @@ static struct fs_info *lookup(char *filesys) return fs; } -#if 0 -/* Find fsck program for a given fs type. */ -static char *find_fsck(char *type) -{ - char *s; - const char *tpl; - char *p = xstrdup(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"); - - 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; -} -#endif - static int progress_active(void) { struct fsck_instance *inst; @@ -588,18 +553,21 @@ static int execute(const char *type, const char *device, const char *mntpt, /* * Send a signal to all outstanding fsck child processes */ -static int kill_all(int signum) +static void kill_all_if_cancel_requested(void) { + static int kill_sent; + struct fsck_instance *inst; - int n = 0; + + if (!cancel_requested || kill_sent) + return; for (inst = instance_list; inst; inst = inst->next) { if (inst->flags & FLAG_DONE) continue; - kill(inst->pid, signum); - n++; + kill(inst->pid, SIGTERM); } - return n; + kill_sent = 1; } /* @@ -637,14 +605,11 @@ static struct fsck_instance *wait_one(int flags) do { pid = waitpid(-1, &status, flags); - if (cancel_requested && !kill_sent) { - kill_all(SIGTERM); - kill_sent++; - } - if ((pid == 0) && (flags & WNOHANG)) + kill_all_if_cancel_requested(); + if (pid == 0 && (flags & WNOHANG)) return NULL; if (pid < 0) { - if ((errno == EINTR) || (errno == EAGAIN)) + if (errno == EINTR || errno == EAGAIN) continue; if (errno == ECHILD) { bb_error_msg("wait: no more child process?!?"); @@ -704,7 +669,7 @@ static struct fsck_instance *wait_one(int flags) break; } } -ret_inst: + ret_inst: if (prev) prev->next = inst->next; else @@ -758,16 +723,16 @@ static void fsck_device(struct fs_info *fs, int interactive) interpret_type(fs); + type = DEFAULT_FSTYPE; if (strcmp(fs->type, "auto") != 0) type = fs->type; else if (fstype - && strncmp(fstype, "no", 2) - && strncmp(fstype, "opts=", 5) && strncmp(fstype, "loop", 4) + && (fstype[0] != 'n' || fstype[1] != 'o') /* != "no" */ + && strncmp(fstype, "opts=", 5) != 0 + && strncmp(fstype, "loop", 4) != 0 && !strchr(fstype, ',') ) type = fstype; - else - type = DEFAULT_FSTYPE; num_running++; retval = execute(type, fs->device, fs->mountpt, interactive); @@ -1078,17 +1043,14 @@ static int check_all(void) } else not_done_yet++; } - if (cancel_requested && !kill_sent) { - kill_all(SIGTERM); - kill_sent++; - } + kill_all_if_cancel_requested(); status |= wait_many(FLAG_WAIT_ATLEAST_ONE); return status; } static void signal_cancel(int sig ATTRIBUTE_UNUSED) { - cancel_requested++; + cancel_requested = 1; } static int string_to_int(const char *s) @@ -1126,9 +1088,6 @@ static void parse_args(int argc, char *argv[]) for (i = 1; i < argc; i++) { arg = argv[i]; if ((arg[0] == '/' && !opts_for_fsck) || strchr(arg, '=')) { - if (num_devices >= MAX_DEVICES) { - bb_error_msg_and_die("too many devices"); - } #if 0 char *dev; dev = blkid_get_devname(cache, arg, NULL); @@ -1138,8 +1097,8 @@ static void parse_args(int argc, char *argv[]) * /proc/partitions isn't found. */ if (access("/proc/partitions", R_OK) < 0) { - bb_perror_msg_and_die("cannot open /proc/partitions " - "(is /proc mounted?)"); + bb_perror_msg_and_die( +"cannot open /proc/partitions (is /proc mounted?)"); } /* * Check to see if this is because @@ -1147,10 +1106,10 @@ static void parse_args(int argc, char *argv[]) */ if (geteuid()) bb_error_msg_and_die( - "must be root to scan for matching filesystems: %s\n", arg); +"must be root to scan for matching filesystems: %s\n", arg); else bb_error_msg_and_die( - "cannot find matching filesystem: %s", arg); +"cannot find matching filesystem: %s", arg); } devices = xrealloc(devices, (num_devices+1) * sizeof(devices[0])); devices[num_devices++] = dev ? dev : xstrdup(arg); @@ -1271,8 +1230,6 @@ int fsck_main(int argc, char *argv[]) fstab = "/etc/fstab"; load_fs_info(fstab); - /*fsck_path = e2fs_set_sbin_path();*/ - if (num_devices == 1 || serialize) interactive = 1; @@ -1286,12 +1243,9 @@ int fsck_main(int argc, char *argv[]) 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); - kill_sent++; - } + kill_all_if_cancel_requested(); break; } fs = lookup(devices[i]); diff --git a/include/applets.h b/include/applets.h index d4a5564..8586ffc 100644 --- a/include/applets.h +++ b/include/applets.h @@ -102,8 +102,8 @@ USE_DPKG_DEB(APPLET_ODDNAME(dpkg-deb, dpkg_deb, _BB_DIR_USR_BIN, _BB_SUID_NEVER, USE_DU(APPLET(du, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_DUMPKMAP(APPLET(dumpkmap, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_APP_DUMPLEASES(APPLET(dumpleases, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) -USE_E2FSCK(APPLET(e2fsck, _BB_DIR_SBIN, _BB_SUID_NEVER)) -USE_E2LABEL(APPLET_NOUSAGE(e2label, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) +//USE_E2FSCK(APPLET(e2fsck, _BB_DIR_SBIN, _BB_SUID_NEVER)) +//USE_E2LABEL(APPLET_NOUSAGE(e2label, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_ECHO(APPLET(echo, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_FEATURE_GREP_EGREP_ALIAS(APPLET_NOUSAGE(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER)) @@ -121,13 +121,13 @@ USE_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_FEATURE_GREP_FGREP_ALIAS(APPLET_NOUSAGE(fgrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_FIND(APPLET(find, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) -USE_FINDFS(APPLET_NOUSAGE(findfs, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) +//USE_FINDFS(APPLET_NOUSAGE(findfs, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_FOLD(APPLET(fold, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_FREERAMDISK(APPLET(freeramdisk, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_FSCK(APPLET(fsck, _BB_DIR_SBIN, _BB_SUID_NEVER)) -USE_E2FSCK(APPLET_NOUSAGE(fsck.ext2, e2fsck, _BB_DIR_SBIN, _BB_SUID_NEVER)) -USE_E2FSCK(APPLET_NOUSAGE(fsck.ext3, e2fsck, _BB_DIR_SBIN, _BB_SUID_NEVER)) +//USE_E2FSCK(APPLET_NOUSAGE(fsck.ext2, e2fsck, _BB_DIR_SBIN, _BB_SUID_NEVER)) +//USE_E2FSCK(APPLET_NOUSAGE(fsck.ext3, e2fsck, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_FSCK_MINIX(APPLET_ODDNAME(fsck.minix, fsck_minix, _BB_DIR_SBIN, _BB_SUID_NEVER, fsck_minix)) USE_FTPGET(APPLET_ODDNAME(ftpget, ftpgetput, _BB_DIR_USR_BIN, _BB_SUID_NEVER,ftpget)) USE_FTPPUT(APPLET_ODDNAME(ftpput, ftpgetput, _BB_DIR_USR_BIN, _BB_SUID_NEVER,ftpput)) @@ -191,10 +191,10 @@ USE_MD5SUM(APPLET_ODDNAME(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_MKDIR(APPLET(mkdir, _BB_DIR_BIN, _BB_SUID_NEVER)) -USE_MKE2FS(APPLET(mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) +//USE_MKE2FS(APPLET(mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_MKFIFO(APPLET(mkfifo, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) -USE_MKE2FS(APPLET_NOUSAGE(mkfs.ext2, mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) -USE_MKE2FS(APPLET_NOUSAGE(mkfs.ext3, mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) +//USE_MKE2FS(APPLET_NOUSAGE(mkfs.ext2, mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) +//USE_MKE2FS(APPLET_NOUSAGE(mkfs.ext3, mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_MKFS_MINIX(APPLET_ODDNAME(mkfs.minix, mkfs_minix, _BB_DIR_SBIN, _BB_SUID_NEVER, mkfs_minix)) USE_MKNOD(APPLET(mknod, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_MKSWAP(APPLET(mkswap, _BB_DIR_SBIN, _BB_SUID_NEVER)) @@ -294,7 +294,7 @@ USE_TR(APPLET(tr, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_TRACEROUTE(APPLET(traceroute, _BB_DIR_USR_BIN, _BB_SUID_MAYBE)) USE_TRUE(APPLET(true, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_TTY(APPLET(tty, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) -USE_TUNE2FS(APPLET(tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) +//USE_TUNE2FS(APPLET(tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_APP_UDHCPC(APPLET(udhcpc, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_APP_UDHCPD(APPLET(udhcpd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) USE_UMOUNT(APPLET(umount, _BB_DIR_BIN, _BB_SUID_NEVER)) diff --git a/include/libbb.h b/include/libbb.h index d94dd59..68e4851 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -190,6 +190,7 @@ extern int sysinfo(struct sysinfo* info); extern void chomp(char *s); extern void trim(char *s); extern char *skip_whitespace(const char *); +extern char *skip_non_whitespace(const char *); extern const char *bb_mode_string(int mode); extern int is_directory(const char *name, int followLinks, struct stat *statBuf); diff --git a/include/usage.h b/include/usage.h index 59b0528..42b51fa 100644 --- a/include/usage.h +++ b/include/usage.h @@ -932,7 +932,7 @@ "$ freeramdisk /dev/ram2\n" #define fsck_trivial_usage \ - "[-ANPRTV] [ -C [ fd ] ] [-t fstype] [fs-options] [filesys ...]" + "[-ANPRTV] [ -C fd ] [-t fstype] [fs-options] [filesys ...]" #define fsck_full_usage \ "Check and repair filesystems" \ "\n\nOptions:\n" \ @@ -941,9 +941,9 @@ " -P When using -A, check filesystems in parallel\n" \ " -R When using -A, skip the root filesystem\n" \ " -T Don't show title on startup\n" \ - " -V Verbose mode\n" \ - " -C Write status information to specified filedescriptor\n" \ - " -t List of filesystem types to check" + " -V Verbose\n" \ + " -C n Write status information to specified filedescriptor\n" \ + " -t type List of filesystem types to check" #define fsck_minix_trivial_usage \ "[-larvsmf] /dev/name" diff --git a/libbb/dump.c b/libbb/dump.c index d6e31b9..06b73c9 100644 --- a/libbb/dump.c +++ b/libbb/dump.c @@ -724,7 +724,9 @@ void bb_dump_add(const char *fmt) /* byte count */ if (isdigit(*p)) { - for (savep = p; isdigit(*p); ++p); +// TODO: use bb_strtou + savep = p; + do p++; while(isdigit(*p)); if (!isspace(*p)) { bb_error_msg_and_die("bad format {%s}", fmt); } diff --git a/libbb/skip_whitespace.c b/libbb/skip_whitespace.c index 02c1f58..bdfb97d 100644 --- a/libbb/skip_whitespace.c +++ b/libbb/skip_whitespace.c @@ -7,12 +7,19 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#include <ctype.h> #include "libbb.h" char *skip_whitespace(const char *s) { + /* NB: isspace('0') returns 0 */ while (isspace(*s)) ++s; return (char *) s; } + +char *skip_non_whitespace(const char *s) +{ + while (*s && !isspace(*s)) ++s; + + return (char *) s; +} |