static int parse_fstab_line(char *line, struct fs_info **ret_fs) { char *dev, *device, *mntpnt, *type, *opts, *freq, *passno, *cp; struct fs_info *fs; *ret_fs = 0; strip_line(line); if ((cp = strchr(line, '#'))) *cp = 0; /* Ignore everything after the comment char */ cp = line; device = parse_word(&cp); mntpnt = parse_word(&cp); type = parse_word(&cp); opts = parse_word(&cp); freq = parse_word(&cp); passno = parse_word(&cp); if (!device) return 0; /* Allow blank lines */ if (!mntpnt || !type) return -1; parse_escape(device); parse_escape(mntpnt); parse_escape(type); parse_escape(opts); parse_escape(freq); parse_escape(passno); dev = blkid_get_devname(cache, device, NULL); if (dev) device = dev; if (strchr(type, ',')) type = 0; fs = create_fs_device(device, mntpnt, type ? type : "auto", opts, freq ? atoi(freq) : -1, passno ? atoi(passno) : -1); if (dev) free(dev); if (!fs) return -1; *ret_fs = fs; return 0; }
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, 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; }