fsck: small optimization

This commit is contained in:
Denis Vlasenko 2007-01-19 02:01:19 +00:00
parent 74c9d2365a
commit a0e701d137

View File

@ -99,22 +99,22 @@ static const char *const really_wanted[] = {
#define BASE_MD "/dev/md" #define BASE_MD "/dev/md"
static volatile int cancel_requested;
static char **devices; static char **devices;
static char **args; static char **args;
static int num_devices, num_args; static int num_devices;
static int num_args;
static int verbose; static int verbose;
static int doall; static volatile smallint cancel_requested;
static int noexecute; static smallint doall;
static int serialize; static smallint noexecute;
static int skip_root; static smallint serialize;
static int like_mount; static smallint skip_root;
static int notitle; /* static smallint like_mount; */
static int parallel_root; static smallint notitle;
static int progress; static smallint parallel_root;
static smallint force_all_parallel;
static smallint progress;
static int progress_fd; static int progress_fd;
static int force_all_parallel;
static int num_running; static int num_running;
static int max_running; static int max_running;
static char *fstype; static char *fstype;
@ -419,7 +419,7 @@ static void load_fs_info(const char *filename)
lineno++; lineno++;
if (r < 0) { if (r < 0) {
bb_error_msg("WARNING: bad format " bb_error_msg("WARNING: bad format "
"on line %d of %s\n", lineno, filename); "on line %d of %s", lineno, filename);
continue; continue;
} }
if (!fs) if (!fs)
@ -555,7 +555,7 @@ static int execute(const char *type, const char *device, const char *mntpt,
*/ */
static void kill_all_if_cancel_requested(void) static void kill_all_if_cancel_requested(void)
{ {
static int kill_sent; static smallint kill_sent;
struct fsck_instance *inst; struct fsck_instance *inst;
@ -644,8 +644,7 @@ static struct fsck_instance *wait_one(int flags)
status = EXIT_ERROR; status = EXIT_ERROR;
} }
inst->exit_status = status; inst->exit_status = status;
if (progress && (inst->flags & FLAG_PROGRESS) && if (progress && (inst->flags & FLAG_PROGRESS) && !progress_active()) {
!progress_active()) {
for (inst2 = instance_list; inst2; inst2 = inst2->next) { for (inst2 = instance_list; inst2; inst2 = inst2->next) {
if (inst2->flags & FLAG_DONE) if (inst2->flags & FLAG_DONE)
continue; continue;
@ -978,7 +977,7 @@ static int check_all(void)
} }
/* /*
* This is for the bone-headed user who enters the root * This is for the bone-headed user who enters the root
* filesystem twice. Skip root will skep all root entries. * filesystem twice. Skip root will skip all root entries.
*/ */
if (skip_root) if (skip_root)
for (fs = filesys_info; fs; fs = fs->next) for (fs = filesys_info; fs; fs = fs->next)
@ -1053,16 +1052,6 @@ static void signal_cancel(int sig ATTRIBUTE_UNUSED)
cancel_requested = 1; cancel_requested = 1;
} }
static int string_to_int(const char *s)
{
int n;
if (!s) bb_show_usage();
n = bb_strtou(s, NULL, 0);
if (errno || n < 0) bb_show_usage();
return n;
}
static void parse_args(int argc, char *argv[]) static void parse_args(int argc, char *argv[])
{ {
int i, j; int i, j;
@ -1133,37 +1122,37 @@ static void parse_args(int argc, char *argv[])
} }
switch (arg[j]) { switch (arg[j]) {
case 'A': case 'A':
doall++; doall = 1;
break; break;
case 'C': case 'C':
progress++; progress = 1;
if (arg[++j]) { /* -Cn */ if (arg[++j]) { /* -Cn */
progress_fd = string_to_int(&arg[j]); progress_fd = xatoi_u(&arg[j]);
goto next_arg; goto next_arg;
} }
/* -C n */ /* -C n */
progress_fd = string_to_int(argv[++i]); progress_fd = xatoi_u(argv[++i]);
goto next_arg; goto next_arg;
case 'V': case 'V':
verbose++; verbose++;
break; break;
case 'N': case 'N':
noexecute++; noexecute = 1;
break; break;
case 'R': case 'R':
skip_root++; skip_root = 1;
break; break;
case 'T': case 'T':
notitle++; notitle = 1;
break;
case 'M':
like_mount++;
break; break;
/* case 'M':
like_mount = 1;
break; */
case 'P': case 'P':
parallel_root++; parallel_root = 1;
break; break;
case 's': case 's':
serialize++; serialize = 1;
break; break;
case 't': case 't':
if (fstype) if (fstype)
@ -1202,7 +1191,7 @@ static void parse_args(int argc, char *argv[])
} }
} }
if (getenv("FSCK_FORCE_ALL_PARALLEL")) if (getenv("FSCK_FORCE_ALL_PARALLEL"))
force_all_parallel++; force_all_parallel = 1;
tmp = getenv("FSCK_MAX_INST"); tmp = getenv("FSCK_MAX_INST");
if (tmp) if (tmp)
max_running = xatoi(tmp); max_running = xatoi(tmp);
@ -1238,8 +1227,8 @@ int fsck_main(int argc, char *argv[])
return check_all(); return check_all();
if (num_devices == 0) { if (num_devices == 0) {
serialize++; serialize = 1;
interactive++; interactive = 1;
return check_all(); return check_all();
} }