/* * Wait until all executing child processes have exited; return the * logical OR of all of their exit code values. */ static int wait_all(NOARGS) { struct fsck_instance *inst; int global_status = 0; while (instance_list) { inst = wait_one(); if (!inst) break; global_status |= inst->exit_status; free_instance(inst); } return global_status; }
/* * Wait until all executing child processes have exited; return the * logical OR of all of their exit code values. */ static int wait_all(int flags) { struct fsck_instance *inst; int global_status = 0; while ((inst = wait_one(flags))) { global_status |= inst->exit_status; free_instance(inst); #ifdef RANDOM_DEBUG if (noexecute && (flags & WNOHANG) && !(random() % 3)) break; #endif } return global_status; }
/* * Wait until all executing child processes have exited; return the * logical OR of all of their exit code values. */ static int wait_many(int flags) { struct fsck_instance *inst; int global_status = 0; int wait_flags = 0; while ((inst = wait_one(wait_flags))) { global_status |= inst->exit_status; free_instance(inst); #ifdef RANDOM_DEBUG if (noexecute && (flags & WNOHANG) && !(random() % 3)) break; #endif if (flags & FLAG_WAIT_ATLEAST_ONE) wait_flags = WNOHANG; } return global_status; }
int fsck_main(int argc, char *argv[]) { int i, status = 0; int interactive = 0; const char *fstab; struct fs_info *fs; setvbuf(stdout, NULL, _IONBF, BUFSIZ); setvbuf(stderr, NULL, _IONBF, BUFSIZ); blkid_get_cache(&cache, NULL); PRS(argc, argv); if (!notitle) printf("fsck %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE); fstab = getenv("FSTAB_FILE"); if (!fstab) fstab = _PATH_MNTTAB; load_fs_info(fstab); fsck_path = e2fs_set_sbin_path(); if ((num_devices == 1) || (serialize)) interactive = 1; /* If -A was specified ("check all"), do that! */ if (doall) return check_all(); if (num_devices == 0) { serialize++; interactive++; return check_all(); } for (i = 0 ; i < num_devices; i++) { if (cancel_requested) { if (!kill_sent) { kill_all(SIGTERM); kill_sent++; } break; } fs = lookup(devices[i]); if (!fs) { fs = create_fs_device(devices[i], 0, "auto", 0, -1, -1); if (!fs) continue; } fsck_device(fs, interactive); if (serialize || (max_running && (num_running >= max_running))) { struct fsck_instance *inst; inst = wait_one(0); if (inst) { status |= inst->exit_status; free_instance(inst); } if (verbose > 1) printf("----------------------------------\n"); } } status |= wait_many(FLAG_WAIT_ALL); blkid_put_cache(cache); return status; }
int main(int argc, char *argv[]) { int i; int status = 0; int interactive = 0; char *oldpath = getenv("PATH"); const char *fstab; #ifdef ENABLE_NLS setlocale(LC_MESSAGES, ""); setlocale(LC_CTYPE, ""); bindtextdomain(NLS_CAT_NAME, LOCALEDIR); textdomain(NLS_CAT_NAME); #endif PRS(argc, argv); if (!notitle) printf("fsck %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE); fstab = getenv("FSTAB_FILE"); if (!fstab) fstab = _PATH_MNTTAB; load_fs_info(fstab); /* Update our search path to include uncommon directories. */ if (oldpath) { fsck_path = malloc (strlen (fsck_prefix_path) + 1 + strlen (oldpath) + 1); strcpy (fsck_path, fsck_prefix_path); strcat (fsck_path, ":"); strcat (fsck_path, oldpath); } else { fsck_path = string_copy(fsck_prefix_path); } if ((num_devices == 1) || (serialize)) interactive = 1; /* If -A was specified ("check all"), do that! */ if (doall) return check_all(); if (num_devices == 0) { serialize++; interactive++; return check_all(); } for (i = 0 ; i < num_devices; i++) { if (cancel_requested) { if (!kill_sent) { kill_all(SIGTERM); kill_sent++; } break; } fsck_device(devices[i], interactive); if (serialize || (max_running && (num_running >= max_running))) { struct fsck_instance *inst; inst = wait_one(0); if (inst) { status |= inst->exit_status; free_instance(inst); } if (verbose > 1) printf("----------------------------------\n"); } } status |= wait_all(0); free(fsck_path); return status; }
int main(int argc, char *argv[]) { int i, status = 0; int interactive = 0; char *oldpath = getenv("PATH"); const char *fstab; struct fs_info *fs; setvbuf(stdout, NULL, _IONBF, BUFSIZ); setvbuf(stderr, NULL, _IONBF, BUFSIZ); #ifdef ENABLE_NLS setlocale(LC_MESSAGES, ""); setlocale(LC_CTYPE, ""); bindtextdomain(NLS_CAT_NAME, LOCALEDIR); textdomain(NLS_CAT_NAME); #endif blkid_get_cache(&cache, NULL); PRS(argc, argv); if (!notitle) printf("fsck %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE); fstab = getenv("FSTAB_FILE"); if (!fstab) fstab = _PATH_MNTTAB; load_fs_info(fstab); /* Update our search path to include uncommon directories. */ if (oldpath) { fsck_path = malloc (strlen (fsck_prefix_path) + 1 + strlen (oldpath) + 1); if (!fsck_path) { fprintf(stderr, "%s: Unable to allocate memory for fsck_path\n", progname); exit(EXIT_ERROR); } strcpy (fsck_path, fsck_prefix_path); strcat (fsck_path, ":"); strcat (fsck_path, oldpath); } else { fsck_path = string_copy(fsck_prefix_path); } if ((num_devices == 1) || (serialize)) interactive = 1; /* If -A was specified ("check all"), do that! */ if (doall) return check_all(); if (num_devices == 0) { serialize++; interactive++; return check_all(); } for (i = 0 ; i < num_devices; i++) { if (cancel_requested) { if (!kill_sent) { kill_all(SIGTERM); kill_sent++; } break; } fs = lookup(devices[i]); if (!fs) { fs = create_fs_device(devices[i], 0, "auto", 0, -1, -1); if (!fs) continue; } if (ignore_mounted && is_mounted(fs->device)) continue; fsck_device(fs, interactive); if (serialize || (max_running && (num_running >= max_running))) { struct fsck_instance *inst; inst = wait_one(0); if (inst) { status |= inst->exit_status; free_instance(inst); } if (verbose > 1) printf("----------------------------------\n"); } } status |= wait_many(FLAG_WAIT_ALL); free(fsck_path); blkid_put_cache(cache); return status; }
/* Check all file systems, using the /etc/fstab table. */ static int check_all(NOARGS) { struct fs_info *fs = NULL; struct fsck_instance *inst; int status = EXIT_OK; int not_done_yet = 1; int passno = 1; int pass_done; if (verbose) printf(_("Checking all file systems.\n")); /* * Do an initial scan over the filesystem; mark filesystems * which should be ignored as done, and resolve LABEL= and * UUID= specifications to the real device. */ for (fs = filesys_info; fs; fs = fs->next) { if (ignore(fs)) fs->flags |= FLAG_DONE; else fs->device = interpret_device(fs->device); } /* * Find and check the root filesystem. */ if (!parallel_root) { for (fs = filesys_info; fs; fs = fs->next) { if (!strcmp(fs->mountpt, "/")) break; } if (fs) { if (!skip_root && !ignore(fs)) { fsck_device(fs->device, 1); status |= wait_all(); if (status > EXIT_NONDESTRUCT) return status; } fs->flags |= FLAG_DONE; } } while (not_done_yet) { not_done_yet = 0; pass_done = 1; for (fs = filesys_info; fs; fs = fs->next) { if (fs->flags & FLAG_DONE) continue; /* * If the filesystem's pass number is higher * than the current pass number, then we don't * do it yet. */ if (fs->passno > passno) { not_done_yet++; continue; } /* * If a filesystem on a particular device has * already been spawned, then we need to defer * this to another pass. */ if (device_already_active(fs->device)) { pass_done = 0; continue; } /* * Spawn off the fsck process */ fsck_device(fs->device, serialize); fs->flags |= FLAG_DONE; if (serialize) { pass_done = 0; break; /* Only do one filesystem at a time */ } } if (verbose > 1) printf(_("--waiting-- (pass %d)\n"), passno); inst = wait_one(); if (inst) { status |= inst->exit_status; free_instance(inst); } if (pass_done) { status |= wait_all(); if (verbose > 1) printf("----------------------------------\n"); passno++; } else not_done_yet++; } status |= wait_all(); return status; }
int main(int argc, char *argv[]) { int i; int status = 0; int interactive = 0; char *oldpath = getenv("PATH"); const char *fstab; #ifdef ENABLE_NLS setlocale(LC_MESSAGES, ""); bindtextdomain(NLS_CAT_NAME, LOCALEDIR); textdomain(NLS_CAT_NAME); #endif PRS(argc, argv); if (!notitle) printf("fsck %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE); fstab = getenv("FSTAB_FILE"); if (!fstab) fstab = _PATH_MNTTAB; load_fs_info(fstab); /* Update our search path to include uncommon directories. */ if (oldpath) { fsck_path = malloc (strlen (fsck_prefix_path) + 1 + strlen (oldpath) + 1); strcpy (fsck_path, fsck_prefix_path); strcat (fsck_path, ":"); strcat (fsck_path, oldpath); } else { fsck_path = string_copy(fsck_prefix_path); } if ((num_devices == 1) || (serialize)) interactive = 1; /* If -A was specified ("check all"), do that! */ if (doall) return check_all(); if (num_devices == 0) { fprintf(stderr, _("\nNo devices specified to be checked!\n")); exit(EXIT_ERROR); } for (i = 0 ; i < num_devices; i++) { fsck_device(devices[i], interactive); if (serialize) { struct fsck_instance *inst; inst = wait_one(); if (inst) { status |= inst->exit_status; free_instance(inst); } } } status |= wait_all(); free(fsck_path); return status; }