Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * fsck --- A generic, parallelizing front-end for the fsck program. |
| 4 | * It will automatically try to run fsck programs in parallel if the |
| 5 | * devices are on separate spindles. It is based on the same ideas as |
| 6 | * the generic front end for fsck by David Engel and Fred van Kempen, |
| 7 | * but it has been completely rewritten from scratch to support |
| 8 | * parallel execution. |
| 9 | * |
| 10 | * Written by Theodore Ts'o, <tytso@mit.edu> |
| 11 | * |
| 12 | * Miquel van Smoorenburg (miquels@drinkel.ow.org) 20-Oct-1994: |
| 13 | * o Changed -t fstype to behave like with mount when -A (all file |
| 14 | * systems) or -M (like mount) is specified. |
| 15 | * o fsck looks if it can find the fsck.type program to decide |
| 16 | * if it should ignore the fs type. This way more fsck programs |
| 17 | * can be added without changing this front-end. |
| 18 | * o -R flag skip root file system. |
| 19 | * |
| 20 | * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, |
| 21 | * 2001, 2002, 2003, 2004, 2005 by Theodore Ts'o. |
| 22 | * |
| 23 | * %Begin-Header% |
| 24 | * This file may be redistributed under the terms of the GNU Public |
| 25 | * License. |
| 26 | * %End-Header% |
| 27 | */ |
| 28 | |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 29 | /* All filesystem specific hooks have been removed. |
| 30 | * If filesystem cannot be determined, we will execute |
| 31 | * "fsck.auto". Currently this also happens if you specify |
| 32 | * UUID=xxx or LABEL=xxx as an object to check. |
| 33 | * Detection code for that is also probably has to be in fsck.auto. |
| 34 | * |
| 35 | * In other words, this is _really_ is just a driver program which |
| 36 | * spawns actual fsck.something for each filesystem to check. |
| 37 | * It doesn't guess filesystem types from on-disk format. |
| 38 | */ |
| 39 | |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 40 | #include "libbb.h" |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 41 | |
| 42 | #define EXIT_OK 0 |
| 43 | #define EXIT_NONDESTRUCT 1 |
| 44 | #define EXIT_DESTRUCT 2 |
| 45 | #define EXIT_UNCORRECTED 4 |
| 46 | #define EXIT_ERROR 8 |
| 47 | #define EXIT_USAGE 16 |
| 48 | #define FSCK_CANCELED 32 /* Aborted with a signal or ^C */ |
| 49 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 50 | /* |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 51 | * Internal structure for mount table entries. |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 52 | */ |
| 53 | |
| 54 | struct fs_info { |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 55 | struct fs_info *next; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 56 | char *device; |
| 57 | char *mountpt; |
| 58 | char *type; |
| 59 | char *opts; |
| 60 | int freq; |
| 61 | int passno; |
| 62 | int flags; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | #define FLAG_DONE 1 |
| 66 | #define FLAG_PROGRESS 2 |
| 67 | /* |
| 68 | * Structure to allow exit codes to be stored |
| 69 | */ |
| 70 | struct fsck_instance { |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 71 | struct fsck_instance *next; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 72 | int pid; |
| 73 | int flags; |
| 74 | int exit_status; |
| 75 | time_t start_time; |
| 76 | char *prog; |
| 77 | char *type; |
| 78 | char *device; |
| 79 | char *base_device; /* /dev/hda for /dev/hdaN etc */ |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 80 | }; |
| 81 | |
Denis Vlasenko | 6ca409e | 2007-08-12 20:58:27 +0000 | [diff] [blame] | 82 | static const char ignored_types[] ALIGN1 = |
Denis Vlasenko | 990d0f6 | 2007-07-24 15:54:42 +0000 | [diff] [blame] | 83 | "ignore\0" |
| 84 | "iso9660\0" |
| 85 | "nfs\0" |
| 86 | "proc\0" |
| 87 | "sw\0" |
| 88 | "swap\0" |
| 89 | "tmpfs\0" |
| 90 | "devpts\0"; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 91 | |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 92 | #if 0 |
Denis Vlasenko | 6ca409e | 2007-08-12 20:58:27 +0000 | [diff] [blame] | 93 | static const char really_wanted[] ALIGN1 = |
Denis Vlasenko | 990d0f6 | 2007-07-24 15:54:42 +0000 | [diff] [blame] | 94 | "minix\0" |
| 95 | "ext2\0" |
| 96 | "ext3\0" |
| 97 | "jfs\0" |
| 98 | "reiserfs\0" |
| 99 | "xiafs\0" |
| 100 | "xfs\0"; |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 101 | #endif |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 102 | |
| 103 | #define BASE_MD "/dev/md" |
| 104 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 105 | static char **devices; |
| 106 | static char **args; |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 107 | static int num_devices; |
| 108 | static int num_args; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 109 | static int verbose; |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 110 | |
| 111 | #define FS_TYPE_FLAG_NORMAL 0 |
| 112 | #define FS_TYPE_FLAG_OPT 1 |
| 113 | #define FS_TYPE_FLAG_NEGOPT 2 |
| 114 | static char **fs_type_list; |
| 115 | static uint8_t *fs_type_flag; |
| 116 | static smallint fs_type_negated; |
| 117 | |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 118 | static volatile smallint cancel_requested; |
| 119 | static smallint doall; |
| 120 | static smallint noexecute; |
| 121 | static smallint serialize; |
| 122 | static smallint skip_root; |
| 123 | /* static smallint like_mount; */ |
| 124 | static smallint notitle; |
| 125 | static smallint parallel_root; |
| 126 | static smallint force_all_parallel; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 127 | |
| 128 | /* "progress indicator" code is somewhat buggy and ext[23] specific. |
| 129 | * We should be filesystem agnostic. IOW: there should be a well-defined |
| 130 | * API for fsck.something, NOT ad-hoc hacks in generic fsck. */ |
| 131 | #define DO_PROGRESS_INDICATOR 0 |
| 132 | #if DO_PROGRESS_INDICATOR |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 133 | static smallint progress; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 134 | static int progress_fd; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 135 | #endif |
| 136 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 137 | static int num_running; |
| 138 | static int max_running; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 139 | static char *fstype; |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 140 | static struct fs_info *filesys_info; |
| 141 | static struct fs_info *filesys_last; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 142 | static struct fsck_instance *instance_list; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 143 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 144 | /* |
| 145 | * Return the "base device" given a particular device; this is used to |
| 146 | * assure that we only fsck one partition on a particular drive at any |
| 147 | * one time. Otherwise, the disk heads will be seeking all over the |
| 148 | * place. If the base device cannot be determined, return NULL. |
| 149 | * |
| 150 | * The base_device() function returns an allocated string which must |
| 151 | * be freed. |
| 152 | */ |
| 153 | #if ENABLE_FEATURE_DEVFS |
| 154 | /* |
| 155 | * Required for the uber-silly devfs /dev/ide/host1/bus2/target3/lun3 |
| 156 | * pathames. |
| 157 | */ |
| 158 | static const char *const devfs_hier[] = { |
| 159 | "host", "bus", "target", "lun", NULL |
| 160 | }; |
| 161 | #endif |
| 162 | |
| 163 | static char *base_device(const char *device) |
| 164 | { |
| 165 | char *str, *cp; |
| 166 | #if ENABLE_FEATURE_DEVFS |
| 167 | const char *const *hier; |
| 168 | const char *disk; |
| 169 | int len; |
| 170 | #endif |
| 171 | cp = str = xstrdup(device); |
| 172 | |
| 173 | /* Skip over /dev/; if it's not present, give up. */ |
| 174 | if (strncmp(cp, "/dev/", 5) != 0) |
| 175 | goto errout; |
| 176 | cp += 5; |
| 177 | |
| 178 | /* |
| 179 | * For md devices, we treat them all as if they were all |
| 180 | * on one disk, since we don't know how to parallelize them. |
| 181 | */ |
| 182 | if (cp[0] == 'm' && cp[1] == 'd') { |
| 183 | cp[2] = 0; |
| 184 | return str; |
| 185 | } |
| 186 | |
| 187 | /* Handle DAC 960 devices */ |
| 188 | if (strncmp(cp, "rd/", 3) == 0) { |
| 189 | cp += 3; |
| 190 | if (cp[0] != 'c' || !isdigit(cp[1]) |
| 191 | || cp[2] != 'd' || !isdigit(cp[3])) |
| 192 | goto errout; |
| 193 | cp[4] = 0; |
| 194 | return str; |
| 195 | } |
| 196 | |
| 197 | /* Now let's handle /dev/hd* and /dev/sd* devices.... */ |
| 198 | if ((cp[0] == 'h' || cp[0] == 's') && cp[1] == 'd') { |
| 199 | cp += 2; |
| 200 | /* If there's a single number after /dev/hd, skip it */ |
| 201 | if (isdigit(*cp)) |
| 202 | cp++; |
| 203 | /* What follows must be an alpha char, or give up */ |
| 204 | if (!isalpha(*cp)) |
| 205 | goto errout; |
| 206 | cp[1] = 0; |
| 207 | return str; |
| 208 | } |
| 209 | |
| 210 | #if ENABLE_FEATURE_DEVFS |
| 211 | /* Now let's handle devfs (ugh) names */ |
| 212 | len = 0; |
| 213 | if (strncmp(cp, "ide/", 4) == 0) |
| 214 | len = 4; |
| 215 | if (strncmp(cp, "scsi/", 5) == 0) |
| 216 | len = 5; |
| 217 | if (len) { |
| 218 | cp += len; |
| 219 | /* |
| 220 | * Now we proceed down the expected devfs hierarchy. |
| 221 | * i.e., .../host1/bus2/target3/lun4/... |
| 222 | * If we don't find the expected token, followed by |
| 223 | * some number of digits at each level, abort. |
| 224 | */ |
| 225 | for (hier = devfs_hier; *hier; hier++) { |
| 226 | len = strlen(*hier); |
| 227 | if (strncmp(cp, *hier, len) != 0) |
| 228 | goto errout; |
| 229 | cp += len; |
| 230 | while (*cp != '/' && *cp != 0) { |
| 231 | if (!isdigit(*cp)) |
| 232 | goto errout; |
| 233 | cp++; |
| 234 | } |
| 235 | cp++; |
| 236 | } |
| 237 | cp[-1] = 0; |
| 238 | return str; |
| 239 | } |
| 240 | |
| 241 | /* Now handle devfs /dev/disc or /dev/disk names */ |
| 242 | disk = 0; |
| 243 | if (strncmp(cp, "discs/", 6) == 0) |
| 244 | disk = "disc"; |
| 245 | else if (strncmp(cp, "disks/", 6) == 0) |
| 246 | disk = "disk"; |
| 247 | if (disk) { |
| 248 | cp += 6; |
| 249 | if (strncmp(cp, disk, 4) != 0) |
| 250 | goto errout; |
| 251 | cp += 4; |
| 252 | while (*cp != '/' && *cp != 0) { |
| 253 | if (!isdigit(*cp)) |
| 254 | goto errout; |
| 255 | cp++; |
| 256 | } |
| 257 | *cp = 0; |
| 258 | return str; |
| 259 | } |
| 260 | #endif |
| 261 | errout: |
| 262 | free(str); |
| 263 | return NULL; |
| 264 | } |
| 265 | |
| 266 | static void free_instance(struct fsck_instance *p) |
| 267 | { |
| 268 | free(p->prog); |
| 269 | free(p->device); |
| 270 | free(p->base_device); |
| 271 | free(p); |
| 272 | } |
| 273 | |
| 274 | static struct fs_info *create_fs_device(const char *device, const char *mntpnt, |
| 275 | const char *type, const char *opts, |
| 276 | int freq, int passno) |
| 277 | { |
| 278 | struct fs_info *fs; |
| 279 | |
| 280 | fs = xzalloc(sizeof(*fs)); |
| 281 | fs->device = xstrdup(device); |
| 282 | fs->mountpt = xstrdup(mntpnt); |
| 283 | fs->type = xstrdup(type); |
| 284 | fs->opts = xstrdup(opts ? opts : ""); |
| 285 | fs->freq = freq; |
| 286 | fs->passno = passno; |
| 287 | /*fs->flags = 0; */ |
| 288 | /*fs->next = NULL; */ |
| 289 | |
| 290 | if (!filesys_info) |
| 291 | filesys_info = fs; |
| 292 | else |
| 293 | filesys_last->next = fs; |
| 294 | filesys_last = fs; |
| 295 | |
| 296 | return fs; |
| 297 | } |
| 298 | |
| 299 | static void strip_line(char *line) |
| 300 | { |
| 301 | char *p = line + strlen(line) - 1; |
| 302 | |
| 303 | while (*line) { |
| 304 | if (*p != '\n' && *p != '\r') |
| 305 | break; |
| 306 | *p-- = '\0'; |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | static char *parse_word(char **buf) |
| 311 | { |
| 312 | char *word, *next; |
| 313 | |
| 314 | word = *buf; |
| 315 | if (*word == '\0') |
| 316 | return NULL; |
| 317 | |
| 318 | word = skip_whitespace(word); |
| 319 | next = skip_non_whitespace(word); |
| 320 | if (*next) |
| 321 | *next++ = '\0'; |
| 322 | *buf = next; |
| 323 | return word; |
| 324 | } |
| 325 | |
| 326 | static void parse_escape(char *word) |
| 327 | { |
| 328 | char *q, c; |
| 329 | const char *p; |
| 330 | |
| 331 | if (!word) |
| 332 | return; |
| 333 | |
| 334 | for (p = q = word; *p; q++) { |
| 335 | c = *p++; |
| 336 | if (c != '\\') { |
| 337 | *q = c; |
| 338 | } else { |
| 339 | *q = bb_process_escape_sequence(&p); |
| 340 | } |
| 341 | } |
| 342 | *q = '\0'; |
| 343 | } |
| 344 | |
| 345 | static int parse_fstab_line(char *line, struct fs_info **ret_fs) |
| 346 | { |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 347 | char *device, *mntpnt, *type, *opts, *freq, *passno, *cp; |
| 348 | struct fs_info *fs; |
| 349 | |
| 350 | *ret_fs = 0; |
| 351 | strip_line(line); |
Denis Vlasenko | c03e872 | 2007-12-26 20:56:55 +0000 | [diff] [blame] | 352 | *strchrnul(line, '#') = '\0'; /* Ignore everything after comment */ |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 353 | cp = line; |
| 354 | |
| 355 | device = parse_word(&cp); |
| 356 | if (!device) return 0; /* Allow blank lines */ |
| 357 | mntpnt = parse_word(&cp); |
| 358 | type = parse_word(&cp); |
| 359 | opts = parse_word(&cp); |
| 360 | freq = parse_word(&cp); |
| 361 | passno = parse_word(&cp); |
| 362 | |
| 363 | if (!mntpnt || !type) |
| 364 | return -1; |
| 365 | |
| 366 | parse_escape(device); |
| 367 | parse_escape(mntpnt); |
| 368 | parse_escape(type); |
| 369 | parse_escape(opts); |
| 370 | parse_escape(freq); |
| 371 | parse_escape(passno); |
| 372 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 373 | if (strchr(type, ',')) |
| 374 | type = NULL; |
| 375 | |
| 376 | fs = create_fs_device(device, mntpnt, type ? type : "auto", opts, |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 377 | freq ? atoi(freq) : -1, |
| 378 | passno ? atoi(passno) : -1); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 379 | *ret_fs = fs; |
| 380 | return 0; |
| 381 | } |
| 382 | |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 383 | /* Load the filesystem database from /etc/fstab */ |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 384 | static void load_fs_info(const char *filename) |
| 385 | { |
| 386 | FILE *f; |
| 387 | int lineno = 0; |
| 388 | int old_fstab = 1; |
| 389 | struct fs_info *fs; |
| 390 | |
| 391 | f = fopen_or_warn(filename, "r"); |
| 392 | if (f == NULL) { |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 393 | return; |
| 394 | } |
| 395 | while (1) { |
| 396 | int r; |
| 397 | char *buf = xmalloc_getline(f); |
| 398 | if (!buf) break; |
| 399 | r = parse_fstab_line(buf, &fs); |
| 400 | free(buf); |
| 401 | lineno++; |
| 402 | if (r < 0) { |
| 403 | bb_error_msg("WARNING: bad format " |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 404 | "on line %d of %s", lineno, filename); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 405 | continue; |
| 406 | } |
| 407 | if (!fs) |
| 408 | continue; |
| 409 | if (fs->passno < 0) |
| 410 | fs->passno = 0; |
| 411 | else |
| 412 | old_fstab = 0; |
| 413 | } |
| 414 | fclose(f); |
| 415 | |
| 416 | if (old_fstab) { |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 417 | fputs("\007" |
| 418 | "WARNING: Your /etc/fstab does not contain the fsck passno field.\n" |
| 419 | "I will kludge around things for you, but you should fix\n" |
| 420 | "your /etc/fstab file as soon as you can.\n\n", stderr); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 421 | for (fs = filesys_info; fs; fs = fs->next) { |
| 422 | fs->passno = 1; |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | /* Lookup filesys in /etc/fstab and return the corresponding entry. */ |
| 428 | static struct fs_info *lookup(char *filesys) |
| 429 | { |
| 430 | struct fs_info *fs; |
| 431 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 432 | for (fs = filesys_info; fs; fs = fs->next) { |
| 433 | if (strcmp(filesys, fs->device) == 0 |
| 434 | || (fs->mountpt && strcmp(filesys, fs->mountpt) == 0) |
| 435 | ) |
| 436 | break; |
| 437 | } |
| 438 | |
| 439 | return fs; |
| 440 | } |
| 441 | |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 442 | #if DO_PROGRESS_INDICATOR |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 443 | static int progress_active(void) |
| 444 | { |
| 445 | struct fsck_instance *inst; |
| 446 | |
| 447 | for (inst = instance_list; inst; inst = inst->next) { |
| 448 | if (inst->flags & FLAG_DONE) |
| 449 | continue; |
| 450 | if (inst->flags & FLAG_PROGRESS) |
| 451 | return 1; |
| 452 | } |
| 453 | return 0; |
| 454 | } |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 455 | #endif |
| 456 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 457 | |
| 458 | /* |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 459 | * Send a signal to all outstanding fsck child processes |
| 460 | */ |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 461 | static void kill_all_if_cancel_requested(void) |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 462 | { |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 463 | static smallint kill_sent; |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 464 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 465 | struct fsck_instance *inst; |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 466 | |
| 467 | if (!cancel_requested || kill_sent) |
| 468 | return; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 469 | |
| 470 | for (inst = instance_list; inst; inst = inst->next) { |
| 471 | if (inst->flags & FLAG_DONE) |
| 472 | continue; |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 473 | kill(inst->pid, SIGTERM); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 474 | } |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 475 | kill_sent = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | /* |
| 479 | * Wait for one child process to exit; when it does, unlink it from |
| 480 | * the list of executing child processes, and return it. |
| 481 | */ |
| 482 | static struct fsck_instance *wait_one(int flags) |
| 483 | { |
| 484 | int status; |
| 485 | int sig; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 486 | struct fsck_instance *inst, *prev; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 487 | pid_t pid; |
| 488 | |
| 489 | if (!instance_list) |
| 490 | return NULL; |
| 491 | |
| 492 | if (noexecute) { |
| 493 | inst = instance_list; |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 494 | prev = NULL; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 495 | #ifdef RANDOM_DEBUG |
| 496 | while (inst->next && (random() & 1)) { |
| 497 | prev = inst; |
| 498 | inst = inst->next; |
| 499 | } |
| 500 | #endif |
| 501 | inst->exit_status = 0; |
| 502 | goto ret_inst; |
| 503 | } |
| 504 | |
Denis Vlasenko | afa7023 | 2007-03-26 17:25:33 +0000 | [diff] [blame] | 505 | inst = prev = NULL; /* for gcc */ |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 506 | do { |
| 507 | pid = waitpid(-1, &status, flags); |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 508 | kill_all_if_cancel_requested(); |
| 509 | if (pid == 0 && (flags & WNOHANG)) |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 510 | return NULL; |
| 511 | if (pid < 0) { |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 512 | if (errno == EINTR || errno == EAGAIN) |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 513 | continue; |
| 514 | if (errno == ECHILD) { |
| 515 | bb_error_msg("wait: no more child process?!?"); |
| 516 | return NULL; |
| 517 | } |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 518 | bb_perror_msg("wait"); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 519 | continue; |
| 520 | } |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 521 | prev = NULL; |
| 522 | inst = instance_list; |
| 523 | while (inst) { |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 524 | if (inst->pid == pid) |
| 525 | break; |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 526 | prev = inst; |
| 527 | inst = inst->next; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 528 | } |
| 529 | } while (!inst); |
| 530 | |
| 531 | if (WIFEXITED(status)) |
| 532 | status = WEXITSTATUS(status); |
| 533 | else if (WIFSIGNALED(status)) { |
| 534 | sig = WTERMSIG(status); |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 535 | status = EXIT_UNCORRECTED; |
| 536 | if (sig != SIGINT) { |
| 537 | printf("Warning... %s %s exited " |
| 538 | "with signal %d\n", |
| 539 | inst->prog, inst->device, sig); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 540 | status = EXIT_ERROR; |
| 541 | } |
| 542 | } else { |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 543 | printf("%s %s: status is %x, should never happen\n", |
| 544 | inst->prog, inst->device, status); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 545 | status = EXIT_ERROR; |
| 546 | } |
| 547 | inst->exit_status = status; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 548 | |
| 549 | #if DO_PROGRESS_INDICATOR |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 550 | if (progress && (inst->flags & FLAG_PROGRESS) && !progress_active()) { |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 551 | struct fsck_instance *inst2; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 552 | for (inst2 = instance_list; inst2; inst2 = inst2->next) { |
| 553 | if (inst2->flags & FLAG_DONE) |
| 554 | continue; |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 555 | if (strcmp(inst2->type, "ext2") != 0 |
| 556 | && strcmp(inst2->type, "ext3") != 0 |
| 557 | ) { |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 558 | continue; |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 559 | } |
| 560 | /* ext[23], we will send USR1 |
| 561 | * (request to start displaying progress bar) |
| 562 | * |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 563 | * If we've just started the fsck, wait a tiny |
| 564 | * bit before sending the kill, to give it |
| 565 | * time to set up the signal handler |
| 566 | */ |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 567 | if (inst2->start_time >= time(NULL) - 1) |
| 568 | sleep(1); |
| 569 | kill(inst2->pid, SIGUSR1); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 570 | inst2->flags |= FLAG_PROGRESS; |
| 571 | break; |
| 572 | } |
| 573 | } |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 574 | #endif |
| 575 | |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 576 | ret_inst: |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 577 | if (prev) |
| 578 | prev->next = inst->next; |
| 579 | else |
| 580 | instance_list = inst->next; |
| 581 | if (verbose > 1) |
| 582 | printf("Finished with %s (exit status %d)\n", |
| 583 | inst->device, inst->exit_status); |
| 584 | num_running--; |
| 585 | return inst; |
| 586 | } |
| 587 | |
| 588 | #define FLAG_WAIT_ALL 0 |
| 589 | #define FLAG_WAIT_ATLEAST_ONE 1 |
| 590 | /* |
| 591 | * Wait until all executing child processes have exited; return the |
| 592 | * logical OR of all of their exit code values. |
| 593 | */ |
| 594 | static int wait_many(int flags) |
| 595 | { |
| 596 | struct fsck_instance *inst; |
| 597 | int global_status = 0; |
| 598 | int wait_flags = 0; |
| 599 | |
| 600 | while ((inst = wait_one(wait_flags))) { |
| 601 | global_status |= inst->exit_status; |
| 602 | free_instance(inst); |
| 603 | #ifdef RANDOM_DEBUG |
| 604 | if (noexecute && (flags & WNOHANG) && !(random() % 3)) |
| 605 | break; |
| 606 | #endif |
| 607 | if (flags & FLAG_WAIT_ATLEAST_ONE) |
| 608 | wait_flags = WNOHANG; |
| 609 | } |
| 610 | return global_status; |
| 611 | } |
| 612 | |
| 613 | /* |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 614 | * Execute a particular fsck program, and link it into the list of |
| 615 | * child processes we are waiting for. |
| 616 | */ |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 617 | static void execute(const char *type, const char *device, const char *mntpt, |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 618 | int interactive) |
| 619 | { |
| 620 | char *argv[num_args + 4]; /* see count below: */ |
| 621 | int argc; |
| 622 | int i; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 623 | struct fsck_instance *inst; |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 624 | pid_t pid; |
| 625 | |
| 626 | inst = xzalloc(sizeof(*inst)); |
| 627 | |
| 628 | argv[0] = xasprintf("fsck.%s", type); /* 1 */ |
| 629 | for (i = 0; i < num_args; i++) |
| 630 | argv[i+1] = args[i]; /* num_args */ |
| 631 | argc = num_args + 1; |
| 632 | |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 633 | #if DO_PROGRESS_INDICATOR |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 634 | if (progress && !progress_active()) { |
| 635 | if (strcmp(type, "ext2") == 0 |
| 636 | || strcmp(type, "ext3") == 0 |
| 637 | ) { |
| 638 | argv[argc++] = xasprintf("-C%d", progress_fd); /* 1 */ |
| 639 | inst->flags |= FLAG_PROGRESS; |
| 640 | } |
| 641 | } |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 642 | #endif |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 643 | |
| 644 | argv[argc++] = xstrdup(device); /* 1 */ |
| 645 | argv[argc] = NULL; /* 1 */ |
| 646 | |
| 647 | if (verbose || noexecute) { |
| 648 | printf("[%s (%d) -- %s]", argv[0], num_running, |
| 649 | mntpt ? mntpt : device); |
| 650 | for (i = 0; i < argc; i++) |
| 651 | printf(" %s", argv[i]); |
Denis Vlasenko | 4daad90 | 2007-09-27 10:20:47 +0000 | [diff] [blame] | 652 | bb_putchar('\n'); |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | /* Fork and execute the correct program. */ |
| 656 | pid = -1; |
| 657 | if (!noexecute) { |
Denis Vlasenko | 53091ec | 2007-03-26 13:35:09 +0000 | [diff] [blame] | 658 | pid = spawn(argv); |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 659 | if (pid < 0) |
Denis Vlasenko | 0c97c9d | 2007-10-01 11:58:38 +0000 | [diff] [blame] | 660 | bb_simple_perror_msg(argv[0]); |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | for (i = num_args+1; i < argc; i++) |
| 664 | free(argv[i]); |
| 665 | |
Denis Vlasenko | 30eb319 | 2008-02-02 18:54:58 +0000 | [diff] [blame] | 666 | /* No pid, so don't record an instance */ |
| 667 | if (pid < 0) { |
| 668 | free(inst); |
| 669 | return; |
| 670 | } |
| 671 | |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 672 | inst->pid = pid; |
| 673 | inst->prog = argv[0]; |
| 674 | inst->type = xstrdup(type); |
| 675 | inst->device = xstrdup(device); |
| 676 | inst->base_device = base_device(device); |
| 677 | inst->start_time = time(NULL); |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 678 | |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 679 | /* Add to the list of running fsck's. |
| 680 | * (was adding to the end, but adding to the front is simpler...) */ |
| 681 | inst->next = instance_list; |
| 682 | instance_list = inst; |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | /* |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 686 | * Run the fsck program on a particular device |
| 687 | * |
| 688 | * If the type is specified using -t, and it isn't prefixed with "no" |
| 689 | * (as in "noext2") and only one filesystem type is specified, then |
| 690 | * use that type regardless of what is specified in /etc/fstab. |
| 691 | * |
| 692 | * If the type isn't specified by the user, then use either the type |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 693 | * specified in /etc/fstab, or "auto". |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 694 | */ |
| 695 | static void fsck_device(struct fs_info *fs, int interactive) |
| 696 | { |
| 697 | const char *type; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 698 | |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 699 | if (strcmp(fs->type, "auto") != 0) { |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 700 | type = fs->type; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 701 | if (verbose > 2) |
| 702 | bb_info_msg("using filesystem type '%s' %s", |
| 703 | type, "from fstab"); |
| 704 | } else if (fstype |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 705 | && (fstype[0] != 'n' || fstype[1] != 'o') /* != "no" */ |
| 706 | && strncmp(fstype, "opts=", 5) != 0 |
| 707 | && strncmp(fstype, "loop", 4) != 0 |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 708 | && !strchr(fstype, ',') |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 709 | ) { |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 710 | type = fstype; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 711 | if (verbose > 2) |
| 712 | bb_info_msg("using filesystem type '%s' %s", |
| 713 | type, "from -t"); |
| 714 | } else { |
| 715 | type = "auto"; |
| 716 | if (verbose > 2) |
| 717 | bb_info_msg("using filesystem type '%s' %s", |
| 718 | type, "(default)"); |
| 719 | } |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 720 | |
| 721 | num_running++; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 722 | execute(type, fs->device, fs->mountpt, interactive); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | /* |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 726 | * Returns TRUE if a partition on the same disk is already being |
| 727 | * checked. |
| 728 | */ |
| 729 | static int device_already_active(char *device) |
| 730 | { |
| 731 | struct fsck_instance *inst; |
| 732 | char *base; |
| 733 | |
| 734 | if (force_all_parallel) |
| 735 | return 0; |
| 736 | |
| 737 | #ifdef BASE_MD |
| 738 | /* Don't check a soft raid disk with any other disk */ |
| 739 | if (instance_list |
| 740 | && (!strncmp(instance_list->device, BASE_MD, sizeof(BASE_MD)-1) |
| 741 | || !strncmp(device, BASE_MD, sizeof(BASE_MD)-1)) |
| 742 | ) { |
| 743 | return 1; |
| 744 | } |
| 745 | #endif |
| 746 | |
| 747 | base = base_device(device); |
| 748 | /* |
| 749 | * If we don't know the base device, assume that the device is |
| 750 | * already active if there are any fsck instances running. |
| 751 | */ |
| 752 | if (!base) |
| 753 | return (instance_list != NULL); |
| 754 | |
| 755 | for (inst = instance_list; inst; inst = inst->next) { |
| 756 | if (!inst->base_device || !strcmp(base, inst->base_device)) { |
| 757 | free(base); |
| 758 | return 1; |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | free(base); |
| 763 | return 0; |
| 764 | } |
| 765 | |
| 766 | /* |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 767 | * This function returns true if a particular option appears in a |
| 768 | * comma-delimited options list |
| 769 | */ |
| 770 | static int opt_in_list(char *opt, char *optlist) |
| 771 | { |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 772 | char *s; |
| 773 | int len; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 774 | |
| 775 | if (!optlist) |
| 776 | return 0; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 777 | |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 778 | len = strlen(opt); |
| 779 | s = optlist - 1; |
| 780 | while (1) { |
| 781 | s = strstr(s + 1, opt); |
| 782 | if (!s) |
| 783 | return 0; |
| 784 | /* neither "opt.." nor "xxx,opt.."? */ |
| 785 | if (s != optlist && s[-1] != ',') |
| 786 | continue; |
| 787 | /* neither "..opt" nor "..opt,xxx"? */ |
| 788 | if (s[len] != '\0' && s[len] != ',') |
| 789 | continue; |
| 790 | return 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 791 | } |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 792 | } |
| 793 | |
| 794 | /* See if the filesystem matches the criteria given by the -t option */ |
| 795 | static int fs_match(struct fs_info *fs) |
| 796 | { |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 797 | int n, ret, checked_type; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 798 | char *cp; |
| 799 | |
| 800 | if (!fs_type_list) |
| 801 | return 1; |
| 802 | |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 803 | ret = 0; |
| 804 | checked_type = 0; |
| 805 | n = 0; |
| 806 | while (1) { |
| 807 | cp = fs_type_list[n]; |
| 808 | if (!cp) |
| 809 | break; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 810 | switch (fs_type_flag[n]) { |
| 811 | case FS_TYPE_FLAG_NORMAL: |
| 812 | checked_type++; |
| 813 | if (strcmp(cp, fs->type) == 0) |
| 814 | ret = 1; |
| 815 | break; |
| 816 | case FS_TYPE_FLAG_NEGOPT: |
| 817 | if (opt_in_list(cp, fs->opts)) |
| 818 | return 0; |
| 819 | break; |
| 820 | case FS_TYPE_FLAG_OPT: |
| 821 | if (!opt_in_list(cp, fs->opts)) |
| 822 | return 0; |
| 823 | break; |
| 824 | } |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 825 | n++; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 826 | } |
| 827 | if (checked_type == 0) |
| 828 | return 1; |
| 829 | |
| 830 | return (fs_type_negated ? !ret : ret); |
| 831 | } |
| 832 | |
| 833 | /* Check if we should ignore this filesystem. */ |
| 834 | static int ignore(struct fs_info *fs) |
| 835 | { |
| 836 | /* |
| 837 | * If the pass number is 0, ignore it. |
| 838 | */ |
| 839 | if (fs->passno == 0) |
| 840 | return 1; |
| 841 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 842 | /* |
| 843 | * If a specific fstype is specified, and it doesn't match, |
| 844 | * ignore it. |
| 845 | */ |
| 846 | if (!fs_match(fs)) |
| 847 | return 1; |
| 848 | |
| 849 | /* Are we ignoring this type? */ |
Denis Vlasenko | 990d0f6 | 2007-07-24 15:54:42 +0000 | [diff] [blame] | 850 | if (index_in_strings(ignored_types, fs->type) >= 0) |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 851 | return 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 852 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 853 | /* We can and want to check this file system type. */ |
| 854 | return 0; |
| 855 | } |
| 856 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 857 | /* Check all file systems, using the /etc/fstab table. */ |
| 858 | static int check_all(void) |
| 859 | { |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 860 | struct fs_info *fs; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 861 | int status = EXIT_OK; |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 862 | smallint not_done_yet; |
| 863 | smallint pass_done; |
| 864 | int passno; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 865 | |
| 866 | if (verbose) |
| 867 | puts("Checking all filesystems"); |
| 868 | |
| 869 | /* |
| 870 | * Do an initial scan over the filesystem; mark filesystems |
| 871 | * which should be ignored as done, and resolve any "auto" |
| 872 | * filesystem types (done as a side-effect of calling ignore()). |
| 873 | */ |
| 874 | for (fs = filesys_info; fs; fs = fs->next) { |
| 875 | if (ignore(fs)) |
| 876 | fs->flags |= FLAG_DONE; |
| 877 | } |
| 878 | |
| 879 | /* |
| 880 | * Find and check the root filesystem. |
| 881 | */ |
| 882 | if (!parallel_root) { |
| 883 | for (fs = filesys_info; fs; fs = fs->next) { |
| 884 | if (LONE_CHAR(fs->mountpt, '/')) |
| 885 | break; |
| 886 | } |
| 887 | if (fs) { |
| 888 | if (!skip_root && !ignore(fs)) { |
| 889 | fsck_device(fs, 1); |
| 890 | status |= wait_many(FLAG_WAIT_ALL); |
| 891 | if (status > EXIT_NONDESTRUCT) |
| 892 | return status; |
| 893 | } |
| 894 | fs->flags |= FLAG_DONE; |
| 895 | } |
| 896 | } |
| 897 | /* |
| 898 | * This is for the bone-headed user who enters the root |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 899 | * filesystem twice. Skip root will skip all root entries. |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 900 | */ |
| 901 | if (skip_root) |
| 902 | for (fs = filesys_info; fs; fs = fs->next) |
| 903 | if (LONE_CHAR(fs->mountpt, '/')) |
| 904 | fs->flags |= FLAG_DONE; |
| 905 | |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 906 | not_done_yet = 1; |
| 907 | passno = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 908 | while (not_done_yet) { |
| 909 | not_done_yet = 0; |
| 910 | pass_done = 1; |
| 911 | |
| 912 | for (fs = filesys_info; fs; fs = fs->next) { |
| 913 | if (cancel_requested) |
| 914 | break; |
| 915 | if (fs->flags & FLAG_DONE) |
| 916 | continue; |
| 917 | /* |
| 918 | * If the filesystem's pass number is higher |
| 919 | * than the current pass number, then we don't |
| 920 | * do it yet. |
| 921 | */ |
| 922 | if (fs->passno > passno) { |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 923 | not_done_yet = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 924 | continue; |
| 925 | } |
| 926 | /* |
| 927 | * If a filesystem on a particular device has |
| 928 | * already been spawned, then we need to defer |
| 929 | * this to another pass. |
| 930 | */ |
| 931 | if (device_already_active(fs->device)) { |
| 932 | pass_done = 0; |
| 933 | continue; |
| 934 | } |
| 935 | /* |
| 936 | * Spawn off the fsck process |
| 937 | */ |
| 938 | fsck_device(fs, serialize); |
| 939 | fs->flags |= FLAG_DONE; |
| 940 | |
| 941 | /* |
| 942 | * Only do one filesystem at a time, or if we |
| 943 | * have a limit on the number of fsck's extant |
| 944 | * at one time, apply that limit. |
| 945 | */ |
| 946 | if (serialize |
| 947 | || (max_running && (num_running >= max_running)) |
| 948 | ) { |
| 949 | pass_done = 0; |
| 950 | break; |
| 951 | } |
| 952 | } |
| 953 | if (cancel_requested) |
| 954 | break; |
| 955 | if (verbose > 1) |
| 956 | printf("--waiting-- (pass %d)\n", passno); |
| 957 | status |= wait_many(pass_done ? FLAG_WAIT_ALL : |
| 958 | FLAG_WAIT_ATLEAST_ONE); |
| 959 | if (pass_done) { |
| 960 | if (verbose > 1) |
| 961 | puts("----------------------------------"); |
| 962 | passno++; |
| 963 | } else |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 964 | not_done_yet = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 965 | } |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 966 | kill_all_if_cancel_requested(); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 967 | status |= wait_many(FLAG_WAIT_ATLEAST_ONE); |
| 968 | return status; |
| 969 | } |
| 970 | |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 971 | /* |
| 972 | * Deal with the fsck -t argument. |
| 973 | * Huh, for mount "-t novfat,nfs" means "neither vfat nor nfs"! |
| 974 | * Why here we require "-t novfat,nonfs" ?? |
| 975 | */ |
| 976 | static void compile_fs_type(char *fs_type) |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 977 | { |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 978 | char *s; |
| 979 | int num = 2; |
| 980 | smallint negate; |
| 981 | |
| 982 | if (fs_type) { |
| 983 | s = fs_type; |
| 984 | while ((s = strchr(s, ','))) { |
| 985 | num++; |
| 986 | s++; |
| 987 | } |
| 988 | } |
| 989 | |
| 990 | fs_type_list = xzalloc(num * sizeof(fs_type_list[0])); |
| 991 | fs_type_flag = xzalloc(num * sizeof(fs_type_flag[0])); |
| 992 | fs_type_negated = -1; /* not yet known is it negated or not */ |
| 993 | |
| 994 | if (!fs_type) |
| 995 | return; |
| 996 | |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 997 | num = 0; |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 998 | s = fs_type; |
| 999 | while (1) { |
| 1000 | char *comma; |
| 1001 | |
| 1002 | negate = 0; |
| 1003 | if (s[0] == 'n' && s[1] == 'o') { /* "no.." */ |
| 1004 | s += 2; |
| 1005 | negate = 1; |
| 1006 | } else if (s[0] == '!') { |
| 1007 | s++; |
| 1008 | negate = 1; |
| 1009 | } |
Denis Vlasenko | e18a293 | 2007-01-19 02:03:14 +0000 | [diff] [blame] | 1010 | |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 1011 | if (strcmp(s, "loop") == 0) |
| 1012 | /* loop is really short-hand for opts=loop */ |
| 1013 | goto loop_special_case; |
| 1014 | if (strncmp(s, "opts=", 5) == 0) { |
| 1015 | s += 5; |
| 1016 | loop_special_case: |
| 1017 | fs_type_flag[num] = negate ? FS_TYPE_FLAG_NEGOPT : FS_TYPE_FLAG_OPT; |
| 1018 | } else { |
| 1019 | if (fs_type_negated == -1) |
| 1020 | fs_type_negated = negate; |
| 1021 | if (fs_type_negated != negate) |
| 1022 | bb_error_msg_and_die( |
| 1023 | "either all or none of the filesystem types passed to -t must be prefixed " |
| 1024 | "with 'no' or '!'"); |
| 1025 | } |
| 1026 | comma = strchr(s, ','); |
| 1027 | fs_type_list[num++] = comma ? xstrndup(s, comma-s) : xstrdup(s); |
| 1028 | if (!comma) |
| 1029 | break; |
| 1030 | s = comma + 1; |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 1031 | } |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1032 | } |
| 1033 | |
Bernhard Reutner-Fischer | febe3c4 | 2007-04-04 20:52:03 +0000 | [diff] [blame] | 1034 | static void parse_args(int argc, char **argv) |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1035 | { |
| 1036 | int i, j; |
| 1037 | char *arg, *tmp; |
| 1038 | char *options = NULL; |
| 1039 | int optpos = 0; |
| 1040 | int opts_for_fsck = 0; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1041 | |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1042 | /* in bss, so already zeroed |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1043 | num_devices = 0; |
| 1044 | num_args = 0; |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 1045 | instance_list = NULL; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1046 | */ |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1047 | |
| 1048 | /* TODO: getopt32 */ |
| 1049 | for (i = 1; i < argc; i++) { |
| 1050 | arg = argv[i]; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1051 | |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 1052 | /* "/dev/blk" or "/path" or "UUID=xxx" or "LABEL=xxx" */ |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1053 | if ((arg[0] == '/' && !opts_for_fsck) || strchr(arg, '=')) { |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 1054 | // FIXME: must check that arg is a blkdev, or resolve |
| 1055 | // "/path", "UUID=xxx" or "LABEL=xxx" into block device name |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1056 | // ("UUID=xxx"/"LABEL=xxx" can probably shifted to fsck.auto duties) |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1057 | devices = xrealloc(devices, (num_devices+1) * sizeof(devices[0])); |
| 1058 | devices[num_devices++] = xstrdup(arg); |
| 1059 | continue; |
| 1060 | } |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1061 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1062 | if (arg[0] != '-' || opts_for_fsck) { |
| 1063 | args = xrealloc(args, (num_args+1) * sizeof(args[0])); |
| 1064 | args[num_args++] = xstrdup(arg); |
| 1065 | continue; |
| 1066 | } |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1067 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1068 | for (j = 1; arg[j]; j++) { |
| 1069 | if (opts_for_fsck) { |
| 1070 | optpos++; |
| 1071 | /* one extra for '\0' */ |
| 1072 | options = xrealloc(options, optpos + 2); |
| 1073 | options[optpos] = arg[j]; |
| 1074 | continue; |
| 1075 | } |
| 1076 | switch (arg[j]) { |
| 1077 | case 'A': |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1078 | doall = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1079 | break; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1080 | #if DO_PROGRESS_INDICATOR |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1081 | case 'C': |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1082 | progress = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1083 | if (arg[++j]) { /* -Cn */ |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1084 | progress_fd = xatoi_u(&arg[j]); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1085 | goto next_arg; |
| 1086 | } |
| 1087 | /* -C n */ |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1088 | progress_fd = xatoi_u(argv[++i]); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1089 | goto next_arg; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1090 | #endif |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1091 | case 'V': |
| 1092 | verbose++; |
| 1093 | break; |
| 1094 | case 'N': |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1095 | noexecute = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1096 | break; |
| 1097 | case 'R': |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1098 | skip_root = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1099 | break; |
| 1100 | case 'T': |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1101 | notitle = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1102 | break; |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1103 | /* case 'M': |
| 1104 | like_mount = 1; |
| 1105 | break; */ |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1106 | case 'P': |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1107 | parallel_root = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1108 | break; |
| 1109 | case 's': |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1110 | serialize = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1111 | break; |
| 1112 | case 't': |
| 1113 | if (fstype) |
| 1114 | bb_show_usage(); |
| 1115 | if (arg[++j]) |
| 1116 | tmp = &arg[j]; |
| 1117 | else if (++i < argc) |
| 1118 | tmp = argv[i]; |
| 1119 | else |
| 1120 | bb_show_usage(); |
| 1121 | fstype = xstrdup(tmp); |
| 1122 | compile_fs_type(fstype); |
| 1123 | goto next_arg; |
| 1124 | case '-': |
| 1125 | opts_for_fsck++; |
| 1126 | break; |
| 1127 | case '?': |
| 1128 | bb_show_usage(); |
| 1129 | break; |
| 1130 | default: |
| 1131 | optpos++; |
| 1132 | /* one extra for '\0' */ |
| 1133 | options = xrealloc(options, optpos + 2); |
| 1134 | options[optpos] = arg[j]; |
| 1135 | break; |
| 1136 | } |
| 1137 | } |
| 1138 | next_arg: |
| 1139 | if (optpos) { |
| 1140 | options[0] = '-'; |
| 1141 | options[optpos + 1] = '\0'; |
| 1142 | args = xrealloc(args, (num_args+1) * sizeof(args[0])); |
| 1143 | args[num_args++] = options; |
| 1144 | optpos = 0; |
| 1145 | options = NULL; |
| 1146 | } |
| 1147 | } |
| 1148 | if (getenv("FSCK_FORCE_ALL_PARALLEL")) |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1149 | force_all_parallel = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1150 | tmp = getenv("FSCK_MAX_INST"); |
| 1151 | if (tmp) |
| 1152 | max_running = xatoi(tmp); |
| 1153 | } |
| 1154 | |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 1155 | static void signal_cancel(int sig ATTRIBUTE_UNUSED) |
| 1156 | { |
| 1157 | cancel_requested = 1; |
| 1158 | } |
| 1159 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 1160 | int fsck_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Bernhard Reutner-Fischer | febe3c4 | 2007-04-04 20:52:03 +0000 | [diff] [blame] | 1161 | int fsck_main(int argc, char **argv) |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1162 | { |
| 1163 | int i, status = 0; |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1164 | int interactive; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1165 | const char *fstab; |
| 1166 | struct fs_info *fs; |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 1167 | struct sigaction sa; |
| 1168 | |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 1169 | memset(&sa, 0, sizeof(sa)); |
| 1170 | sa.sa_handler = signal_cancel; |
| 1171 | sigaction(SIGINT, &sa, 0); |
| 1172 | sigaction(SIGTERM, &sa, 0); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1173 | |
| 1174 | setbuf(stdout, NULL); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1175 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1176 | parse_args(argc, argv); |
| 1177 | |
| 1178 | if (!notitle) |
| 1179 | puts("fsck (busybox "BB_VER", "BB_BT")"); |
| 1180 | |
Denis Vlasenko | 1abf91a | 2007-01-19 02:02:33 +0000 | [diff] [blame] | 1181 | /* Even plain "fsck /dev/hda1" needs fstab to get fs type, |
| 1182 | * so we are scanning it anyway */ |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1183 | fstab = getenv("FSTAB_FILE"); |
| 1184 | if (!fstab) |
| 1185 | fstab = "/etc/fstab"; |
| 1186 | load_fs_info(fstab); |
| 1187 | |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1188 | interactive = (num_devices == 1) | serialize; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1189 | |
| 1190 | /* If -A was specified ("check all"), do that! */ |
| 1191 | if (doall) |
| 1192 | return check_all(); |
| 1193 | |
| 1194 | if (num_devices == 0) { |
Denis Vlasenko | a0e701d | 2007-01-19 02:01:19 +0000 | [diff] [blame] | 1195 | serialize = 1; |
| 1196 | interactive = 1; |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1197 | return check_all(); |
| 1198 | } |
| 1199 | |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 1200 | for (i = 0; i < num_devices; i++) { |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1201 | if (cancel_requested) { |
Denis Vlasenko | 0de9375 | 2006-12-26 02:51:29 +0000 | [diff] [blame] | 1202 | kill_all_if_cancel_requested(); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1203 | break; |
| 1204 | } |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1205 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1206 | fs = lookup(devices[i]); |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1207 | if (!fs) |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1208 | fs = create_fs_device(devices[i], 0, "auto", 0, -1, -1); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1209 | fsck_device(fs, interactive); |
Denis Vlasenko | f8c11aa | 2007-01-19 02:04:09 +0000 | [diff] [blame] | 1210 | |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1211 | if (serialize |
| 1212 | || (max_running && (num_running >= max_running)) |
| 1213 | ) { |
| 1214 | struct fsck_instance *inst; |
| 1215 | |
| 1216 | inst = wait_one(0); |
| 1217 | if (inst) { |
| 1218 | status |= inst->exit_status; |
| 1219 | free_instance(inst); |
| 1220 | } |
| 1221 | if (verbose > 1) |
| 1222 | puts("----------------------------------"); |
| 1223 | } |
| 1224 | } |
| 1225 | status |= wait_many(FLAG_WAIT_ALL); |
Denis Vlasenko | c4f623e | 2006-12-26 01:30:59 +0000 | [diff] [blame] | 1226 | return status; |
| 1227 | } |