diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-19 02:01:19 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-19 02:01:19 +0000 |
| commit | a0e701d137a0d57befe9839ffadd30b69c05899e (patch) | |
| tree | a07847b8a0e1a3fc96f229fd4fddac4753cecbe1 | |
| parent | 74c9d2365a9ada53d8967a280a858acdc98f81fb (diff) | |
| download | busybox-w32-a0e701d137a0d57befe9839ffadd30b69c05899e.tar.gz busybox-w32-a0e701d137a0d57befe9839ffadd30b69c05899e.tar.bz2 busybox-w32-a0e701d137a0d57befe9839ffadd30b69c05899e.zip | |
fsck: small optimization
| -rw-r--r-- | e2fsprogs/fsck.c | 73 |
1 files changed, 31 insertions, 42 deletions
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c index acba5ec7a..ea311df6d 100644 --- a/e2fsprogs/fsck.c +++ b/e2fsprogs/fsck.c | |||
| @@ -99,22 +99,22 @@ static const char *const really_wanted[] = { | |||
| 99 | 99 | ||
| 100 | #define BASE_MD "/dev/md" | 100 | #define BASE_MD "/dev/md" |
| 101 | 101 | ||
| 102 | static volatile int cancel_requested; | ||
| 103 | |||
| 104 | static char **devices; | 102 | static char **devices; |
| 105 | static char **args; | 103 | static char **args; |
| 106 | static int num_devices, num_args; | 104 | static int num_devices; |
| 105 | static int num_args; | ||
| 107 | static int verbose; | 106 | static int verbose; |
| 108 | static int doall; | 107 | static volatile smallint cancel_requested; |
| 109 | static int noexecute; | 108 | static smallint doall; |
| 110 | static int serialize; | 109 | static smallint noexecute; |
| 111 | static int skip_root; | 110 | static smallint serialize; |
| 112 | static int like_mount; | 111 | static smallint skip_root; |
| 113 | static int notitle; | 112 | /* static smallint like_mount; */ |
| 114 | static int parallel_root; | 113 | static smallint notitle; |
| 115 | static int progress; | 114 | static smallint parallel_root; |
| 115 | static smallint force_all_parallel; | ||
| 116 | static smallint progress; | ||
| 116 | static int progress_fd; | 117 | static int progress_fd; |
| 117 | static int force_all_parallel; | ||
| 118 | static int num_running; | 118 | static int num_running; |
| 119 | static int max_running; | 119 | static int max_running; |
| 120 | static char *fstype; | 120 | static char *fstype; |
| @@ -419,7 +419,7 @@ static void load_fs_info(const char *filename) | |||
| 419 | lineno++; | 419 | lineno++; |
| 420 | if (r < 0) { | 420 | if (r < 0) { |
| 421 | bb_error_msg("WARNING: bad format " | 421 | bb_error_msg("WARNING: bad format " |
| 422 | "on line %d of %s\n", lineno, filename); | 422 | "on line %d of %s", lineno, filename); |
| 423 | continue; | 423 | continue; |
| 424 | } | 424 | } |
| 425 | if (!fs) | 425 | if (!fs) |
| @@ -555,7 +555,7 @@ static int execute(const char *type, const char *device, const char *mntpt, | |||
| 555 | */ | 555 | */ |
| 556 | static void kill_all_if_cancel_requested(void) | 556 | static void kill_all_if_cancel_requested(void) |
| 557 | { | 557 | { |
| 558 | static int kill_sent; | 558 | static smallint kill_sent; |
| 559 | 559 | ||
| 560 | struct fsck_instance *inst; | 560 | struct fsck_instance *inst; |
| 561 | 561 | ||
| @@ -644,8 +644,7 @@ static struct fsck_instance *wait_one(int flags) | |||
| 644 | status = EXIT_ERROR; | 644 | status = EXIT_ERROR; |
| 645 | } | 645 | } |
| 646 | inst->exit_status = status; | 646 | inst->exit_status = status; |
| 647 | if (progress && (inst->flags & FLAG_PROGRESS) && | 647 | if (progress && (inst->flags & FLAG_PROGRESS) && !progress_active()) { |
| 648 | !progress_active()) { | ||
| 649 | for (inst2 = instance_list; inst2; inst2 = inst2->next) { | 648 | for (inst2 = instance_list; inst2; inst2 = inst2->next) { |
| 650 | if (inst2->flags & FLAG_DONE) | 649 | if (inst2->flags & FLAG_DONE) |
| 651 | continue; | 650 | continue; |
| @@ -978,7 +977,7 @@ static int check_all(void) | |||
| 978 | } | 977 | } |
| 979 | /* | 978 | /* |
| 980 | * This is for the bone-headed user who enters the root | 979 | * This is for the bone-headed user who enters the root |
| 981 | * filesystem twice. Skip root will skep all root entries. | 980 | * filesystem twice. Skip root will skip all root entries. |
| 982 | */ | 981 | */ |
| 983 | if (skip_root) | 982 | if (skip_root) |
| 984 | for (fs = filesys_info; fs; fs = fs->next) | 983 | for (fs = filesys_info; fs; fs = fs->next) |
| @@ -1053,16 +1052,6 @@ static void signal_cancel(int sig ATTRIBUTE_UNUSED) | |||
| 1053 | cancel_requested = 1; | 1052 | cancel_requested = 1; |
| 1054 | } | 1053 | } |
| 1055 | 1054 | ||
| 1056 | static int string_to_int(const char *s) | ||
| 1057 | { | ||
| 1058 | int n; | ||
| 1059 | |||
| 1060 | if (!s) bb_show_usage(); | ||
| 1061 | n = bb_strtou(s, NULL, 0); | ||
| 1062 | if (errno || n < 0) bb_show_usage(); | ||
| 1063 | return n; | ||
| 1064 | } | ||
| 1065 | |||
| 1066 | static void parse_args(int argc, char *argv[]) | 1055 | static void parse_args(int argc, char *argv[]) |
| 1067 | { | 1056 | { |
| 1068 | int i, j; | 1057 | int i, j; |
| @@ -1133,37 +1122,37 @@ static void parse_args(int argc, char *argv[]) | |||
| 1133 | } | 1122 | } |
| 1134 | switch (arg[j]) { | 1123 | switch (arg[j]) { |
| 1135 | case 'A': | 1124 | case 'A': |
| 1136 | doall++; | 1125 | doall = 1; |
| 1137 | break; | 1126 | break; |
| 1138 | case 'C': | 1127 | case 'C': |
| 1139 | progress++; | 1128 | progress = 1; |
| 1140 | if (arg[++j]) { /* -Cn */ | 1129 | if (arg[++j]) { /* -Cn */ |
| 1141 | progress_fd = string_to_int(&arg[j]); | 1130 | progress_fd = xatoi_u(&arg[j]); |
| 1142 | goto next_arg; | 1131 | goto next_arg; |
| 1143 | } | 1132 | } |
| 1144 | /* -C n */ | 1133 | /* -C n */ |
| 1145 | progress_fd = string_to_int(argv[++i]); | 1134 | progress_fd = xatoi_u(argv[++i]); |
| 1146 | goto next_arg; | 1135 | goto next_arg; |
| 1147 | case 'V': | 1136 | case 'V': |
| 1148 | verbose++; | 1137 | verbose++; |
| 1149 | break; | 1138 | break; |
| 1150 | case 'N': | 1139 | case 'N': |
| 1151 | noexecute++; | 1140 | noexecute = 1; |
| 1152 | break; | 1141 | break; |
| 1153 | case 'R': | 1142 | case 'R': |
| 1154 | skip_root++; | 1143 | skip_root = 1; |
| 1155 | break; | 1144 | break; |
| 1156 | case 'T': | 1145 | case 'T': |
| 1157 | notitle++; | 1146 | notitle = 1; |
| 1158 | break; | ||
| 1159 | case 'M': | ||
| 1160 | like_mount++; | ||
| 1161 | break; | 1147 | break; |
| 1148 | /* case 'M': | ||
| 1149 | like_mount = 1; | ||
| 1150 | break; */ | ||
| 1162 | case 'P': | 1151 | case 'P': |
| 1163 | parallel_root++; | 1152 | parallel_root = 1; |
| 1164 | break; | 1153 | break; |
| 1165 | case 's': | 1154 | case 's': |
| 1166 | serialize++; | 1155 | serialize = 1; |
| 1167 | break; | 1156 | break; |
| 1168 | case 't': | 1157 | case 't': |
| 1169 | if (fstype) | 1158 | if (fstype) |
| @@ -1202,7 +1191,7 @@ static void parse_args(int argc, char *argv[]) | |||
| 1202 | } | 1191 | } |
| 1203 | } | 1192 | } |
| 1204 | if (getenv("FSCK_FORCE_ALL_PARALLEL")) | 1193 | if (getenv("FSCK_FORCE_ALL_PARALLEL")) |
| 1205 | force_all_parallel++; | 1194 | force_all_parallel = 1; |
| 1206 | tmp = getenv("FSCK_MAX_INST"); | 1195 | tmp = getenv("FSCK_MAX_INST"); |
| 1207 | if (tmp) | 1196 | if (tmp) |
| 1208 | max_running = xatoi(tmp); | 1197 | max_running = xatoi(tmp); |
| @@ -1238,8 +1227,8 @@ int fsck_main(int argc, char *argv[]) | |||
| 1238 | return check_all(); | 1227 | return check_all(); |
| 1239 | 1228 | ||
| 1240 | if (num_devices == 0) { | 1229 | if (num_devices == 0) { |
| 1241 | serialize++; | 1230 | serialize = 1; |
| 1242 | interactive++; | 1231 | interactive = 1; |
| 1243 | return check_all(); | 1232 | return check_all(); |
| 1244 | } | 1233 | } |
| 1245 | 1234 | ||
