• Home
  • Raw
  • Download

Lines Matching refs:ctx

75 static void usage(e2fsck_t ctx)  in usage()  argument
81 ctx->program_name); in usage()
102 static void show_stats(e2fsck_t ctx) in show_stats() argument
104 ext2_filsys fs = ctx->fs; in show_stats()
113 dir_links = 2 * ctx->fs_directory_count - 1; in show_stats()
114 num_files = ctx->fs_total_count - dir_links; in show_stats()
115 num_links = ctx->fs_links_count - dir_links; in show_stats()
124 frag_percent_file = (10000 * ctx->fs_fragmented) / inodes_used; in show_stats()
127 frag_percent_dir = (10000 * ctx->fs_fragmented_dir) / inodes_used; in show_stats()
130 frag_percent_total = ((10000 * (ctx->fs_fragmented + in show_stats()
131 ctx->fs_fragmented_dir)) in show_stats()
137 log_out(ctx, _("%s: %u/%u files (%0d.%d%% non-contiguous), " in show_stats()
139 ctx->device_name, inodes_used, inodes, in show_stats()
144 profile_get_boolean(ctx->profile, "options", "report_features", 0, 0, in show_stats()
147 log_out(ctx, "\nFilesystem features:"); in show_stats()
148 mask = &ctx->fs->super->s_feature_compat; in show_stats()
152 log_out(ctx, " %s", in show_stats()
159 log_out(ctx, " (none)"); in show_stats()
160 log_out(ctx, "\n"); in show_stats()
163 log_out(ctx, P_("\n%12u inode used (%2.2f%%, out of %u)\n", in show_stats()
167 log_out(ctx, P_("%12u non-contiguous file (%0d.%d%%)\n", in show_stats()
169 ctx->fs_fragmented), in show_stats()
170 ctx->fs_fragmented, frag_percent_file / 10, in show_stats()
172 log_out(ctx, P_("%12u non-contiguous directory (%0d.%d%%)\n", in show_stats()
174 ctx->fs_fragmented_dir), in show_stats()
175 ctx->fs_fragmented_dir, frag_percent_dir / 10, in show_stats()
177 log_out(ctx, _(" # of inodes with ind/dind/tind blocks: " in show_stats()
179 ctx->fs_ind_count, ctx->fs_dind_count, ctx->fs_tind_count); in show_stats()
182 if (ctx->extent_depth_count[j]) in show_stats()
185 log_out(ctx, "%s", _(" Extent depth histogram: ")); in show_stats()
189 log_out(ctx, "%u", ctx->extent_depth_count[i]); in show_stats()
191 log_out(ctx, "\n"); in show_stats()
194 log_out(ctx, P_("%12llu block used (%2.2f%%, out of %llu)\n", in show_stats()
198 log_out(ctx, P_("%12u bad block\n", "%12u bad blocks\n", in show_stats()
199 ctx->fs_badblocks_count), ctx->fs_badblocks_count); in show_stats()
200 log_out(ctx, P_("%12u large file\n", "%12u large files\n", in show_stats()
201 ctx->large_files), ctx->large_files); in show_stats()
202 log_out(ctx, P_("\n%12u regular file\n", "\n%12u regular files\n", in show_stats()
203 ctx->fs_regular_count), ctx->fs_regular_count); in show_stats()
204 log_out(ctx, P_("%12u directory\n", "%12u directories\n", in show_stats()
205 ctx->fs_directory_count), ctx->fs_directory_count); in show_stats()
206 log_out(ctx, P_("%12u character device file\n", in show_stats()
207 "%12u character device files\n", ctx->fs_chardev_count), in show_stats()
208 ctx->fs_chardev_count); in show_stats()
209 log_out(ctx, P_("%12u block device file\n", "%12u block device files\n", in show_stats()
210 ctx->fs_blockdev_count), ctx->fs_blockdev_count); in show_stats()
211 log_out(ctx, P_("%12u fifo\n", "%12u fifos\n", ctx->fs_fifo_count), in show_stats()
212 ctx->fs_fifo_count); in show_stats()
213 log_out(ctx, P_("%12u link\n", "%12u links\n", num_links), in show_stats()
214 ctx->fs_links_count - dir_links); in show_stats()
215 log_out(ctx, P_("%12u symbolic link", "%12u symbolic links", in show_stats()
216 ctx->fs_symlinks_count), ctx->fs_symlinks_count); in show_stats()
217 log_out(ctx, P_(" (%u fast symbolic link)\n", in show_stats()
219 ctx->fs_fast_symlinks_count), in show_stats()
220 ctx->fs_fast_symlinks_count); in show_stats()
221 log_out(ctx, P_("%12u socket\n", "%12u sockets\n", in show_stats()
222 ctx->fs_sockets_count), in show_stats()
223 ctx->fs_sockets_count); in show_stats()
224 log_out(ctx, "------------\n"); in show_stats()
225 log_out(ctx, P_("%12u file\n", "%12u files\n", num_files), in show_stats()
229 static void check_mount(e2fsck_t ctx) in check_mount() argument
234 retval = ext2fs_check_if_mounted(ctx->filesystem_name, in check_mount()
235 &ctx->mount_flags); in check_mount()
239 ctx->filesystem_name); in check_mount()
248 if ((!(ctx->mount_flags & (EXT2_MF_MOUNTED | EXT2_MF_BUSY))) || in check_mount()
249 ((ctx->mount_flags & EXT2_MF_ISROOT) && in check_mount()
250 (ctx->mount_flags & EXT2_MF_READONLY) && in check_mount()
251 !(ctx->options & E2F_OPT_WRITECHECK))) in check_mount()
254 if (((ctx->options & E2F_OPT_READONLY) || in check_mount()
255 ((ctx->options & E2F_OPT_FORCE) && in check_mount()
256 (ctx->mount_flags & EXT2_MF_READONLY))) && in check_mount()
257 !(ctx->options & E2F_OPT_WRITECHECK)) { in check_mount()
258 if (ctx->mount_flags & EXT2_MF_MOUNTED) in check_mount()
259 log_out(ctx, _("Warning! %s is mounted.\n"), in check_mount()
260 ctx->filesystem_name); in check_mount()
262 log_out(ctx, _("Warning! %s is in use.\n"), in check_mount()
263 ctx->filesystem_name); in check_mount()
267 if (ctx->mount_flags & EXT2_MF_MOUNTED) in check_mount()
268 log_out(ctx, _("%s is mounted.\n"), ctx->filesystem_name); in check_mount()
270 log_out(ctx, _("%s is in use.\n"), ctx->filesystem_name); in check_mount()
271 if (!ctx->interactive || ctx->mount_flags & EXT2_MF_BUSY) in check_mount()
272 fatal_error(ctx, _("Cannot continue, aborting.\n\n")); in check_mount()
274 log_out(ctx, "%s", _("\n\nWARNING!!! " in check_mount()
279 cont = ask_yn(ctx, _("Do you really want to continue"), 0); in check_mount()
339 static void check_if_skip(e2fsck_t ctx) in check_if_skip() argument
341 ext2_filsys fs = ctx->fs; in check_if_skip()
351 if (ctx->flags & E2F_FLAG_PROBLEMS_FIXED) in check_if_skip()
354 profile_get_boolean(ctx->profile, "options", "broken_system_clock", in check_if_skip()
356 if (ctx->flags & E2F_FLAG_TIME_INSANE) in check_if_skip()
358 profile_get_boolean(ctx->profile, "options", in check_if_skip()
364 if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file || cflag) in check_if_skip()
367 if (ctx->options & E2F_OPT_JOURNAL_ONLY) in check_if_skip()
371 if (lastcheck > ctx->now) in check_if_skip()
372 lastcheck -= ctx->time_fudge; in check_if_skip()
378 else if (check_backup_super_block(ctx)) in check_if_skip()
389 (ctx->now < lastcheck)) { in check_if_skip()
394 ((ctx->now - lastcheck) >= in check_if_skip()
397 reason_arg = (ctx->now - fs->super->s_lastcheck)/(3600*24); in check_if_skip()
398 if (batt && ((ctx->now - fs->super->s_lastcheck) < in check_if_skip()
402 log_out(ctx, "%s: ", ctx->device_name); in check_if_skip()
403 log_out(ctx, "%s", in check_if_skip()
408 log_out(ctx, "%s", ctx->device_name); in check_if_skip()
409 log_out(ctx, reason, reason_arg); in check_if_skip()
410 log_out(ctx, "%s", _(", check forced.\n")); in check_if_skip()
425 pctx.ino2 = ctx->free_inodes; in check_if_skip()
427 !(ctx->options & E2F_OPT_READONLY) && in check_if_skip()
428 fix_problem(ctx, PR_0_FREE_INODE_COUNT, &pctx)) { in check_if_skip()
429 fs->super->s_free_inodes_count = ctx->free_inodes; in check_if_skip()
434 pctx.blk2 = ctx->free_blocks; in check_if_skip()
436 !(ctx->options & E2F_OPT_READONLY) && in check_if_skip()
437 fix_problem(ctx, PR_0_FREE_BLOCK_COUNT, &pctx)) { in check_if_skip()
438 ext2fs_free_blocks_count_set(fs->super, ctx->free_blocks); in check_if_skip()
443 log_out(ctx, _("%s: clean, %u/%u files, %llu/%llu blocks"), in check_if_skip()
444 ctx->device_name, in check_if_skip()
457 ((ctx->now - fs->super->s_lastcheck) >= fs->super->s_checkinterval)) in check_if_skip()
462 log_out(ctx, "%s", in check_if_skip()
465 log_out(ctx, "%s", in check_if_skip()
468 log_out(ctx, _(" (check in %ld mounts)"), in check_if_skip()
471 log_out(ctx, "\n"); in check_if_skip()
473 ext2fs_close_free(&ctx->fs); in check_if_skip()
474 e2fsck_free_context(ctx); in check_if_skip()
504 void e2fsck_clear_progbar(e2fsck_t ctx) in e2fsck_clear_progbar() argument
506 if (!(ctx->flags & E2F_FLAG_PROG_BAR)) in e2fsck_clear_progbar()
509 printf("%s%s\r%s", ctx->start_meta, spaces + (sizeof(spaces) - 80), in e2fsck_clear_progbar()
510 ctx->stop_meta); in e2fsck_clear_progbar()
512 ctx->flags &= ~E2F_FLAG_PROG_BAR; in e2fsck_clear_progbar()
515 int e2fsck_simple_progress(e2fsck_t ctx, const char *label, float percent, in e2fsck_simple_progress() argument
525 if (ctx->flags & E2F_FLAG_PROG_SUPPRESS) in e2fsck_simple_progress()
534 if (ctx->progress_last_percent == fixed_percent) in e2fsck_simple_progress()
536 ctx->progress_last_percent = fixed_percent; in e2fsck_simple_progress()
545 if ((tick == ctx->progress_last_time) && in e2fsck_simple_progress()
548 ctx->progress_last_time = tick; in e2fsck_simple_progress()
554 ctx->progress_pos = (ctx->progress_pos+1) & 3; in e2fsck_simple_progress()
555 ctx->flags |= E2F_FLAG_PROG_BAR; in e2fsck_simple_progress()
563 printf("%s%s: |%s%s", ctx->start_meta, label, in e2fsck_simple_progress()
569 fputc(spinner[ctx->progress_pos & 3], stdout); in e2fsck_simple_progress()
575 fputs(ctx->stop_meta, stdout); in e2fsck_simple_progress()
578 e2fsck_clear_progbar(ctx); in e2fsck_simple_progress()
584 static int e2fsck_update_progress(e2fsck_t ctx, int pass, in e2fsck_update_progress() argument
593 if (ctx->progress_fd) { in e2fsck_update_progress()
595 pass, cur, max, ctx->device_name); in e2fsck_update_progress()
596 write_all(ctx->progress_fd, buf, strlen(buf)); in e2fsck_update_progress()
599 e2fsck_simple_progress(ctx, ctx->device_name, in e2fsck_update_progress()
630 e2fsck_t ctx = e2fsck_global_ctx; in signal_progress_on() local
632 if (!ctx) in signal_progress_on()
635 ctx->progress = e2fsck_update_progress; in signal_progress_on()
640 e2fsck_t ctx = e2fsck_global_ctx; in signal_progress_off() local
642 if (!ctx) in signal_progress_off()
645 e2fsck_clear_progbar(ctx); in signal_progress_off()
646 ctx->progress = 0; in signal_progress_off()
651 e2fsck_t ctx = e2fsck_global_ctx; in signal_cancel() local
653 if (!ctx) in signal_cancel()
656 ctx->flags |= E2F_FLAG_CANCEL; in signal_cancel()
660 static void parse_extended_opts(e2fsck_t ctx, const char *opts) in parse_extended_opts() argument
667 buf = string_copy(ctx, opts, 0); in parse_extended_opts()
693 ctx->ext_attr_ver = ea_ver; in parse_extended_opts()
706 ctx->readahead_kb = reada_kb; in parse_extended_opts()
708 ctx->options |= E2F_OPT_FRAGCHECK; in parse_extended_opts()
715 ctx->options |= E2F_OPT_JOURNAL_ONLY; in parse_extended_opts()
717 ctx->options |= E2F_OPT_DISCARD; in parse_extended_opts()
720 ctx->options &= ~E2F_OPT_DISCARD; in parse_extended_opts()
723 ctx->options &= ~E2F_OPT_NOOPT_EXTENTS; in parse_extended_opts()
726 ctx->options |= E2F_OPT_NOOPT_EXTENTS; in parse_extended_opts()
729 ctx->options |= E2F_OPT_ICOUNT_FULLMAP; in parse_extended_opts()
732 ctx->options &= ~E2F_OPT_ICOUNT_FULLMAP; in parse_extended_opts()
738 ctx->log_fn = string_copy(ctx, arg, 0); in parse_extended_opts()
744 ctx->problem_log_fn = string_copy(ctx, arg, 0); in parse_extended_opts()
747 ctx->options |= E2F_OPT_CONVERT_BMAP; in parse_extended_opts()
750 ctx->options |= E2F_OPT_FIXES_ONLY; in parse_extended_opts()
753 ctx->options |= E2F_OPT_UNSHARE_BLOCKS; in parse_extended_opts()
754 ctx->options |= E2F_OPT_FORCE; in parse_extended_opts()
804 e2fsck_t ctx; in PRS() local
817 retval = e2fsck_allocate_context(&ctx); in PRS()
821 *ret_ctx = ctx; in PRS()
822 e2fsck_global_ctx = ctx; in PRS()
827 ctx->interactive = 1; in PRS()
829 ctx->start_meta[0] = '\001'; in PRS()
830 ctx->stop_meta[0] = '\002'; in PRS()
836 blkid_get_cache(&ctx->blkid, NULL); in PRS()
839 ctx->program_name = *argv; in PRS()
841 ctx->program_name = "e2fsck"; in PRS()
844 ctx->readahead_kb = ~0ULL; in PRS()
848 ctx->progress = e2fsck_update_progress; in PRS()
849 res = sscanf(optarg, "%d", &ctx->progress_fd); in PRS()
853 if (ctx->progress_fd < 0) { in PRS()
854 ctx->progress = 0; in PRS()
855 ctx->progress_fd = ctx->progress_fd * -1; in PRS()
857 if (!ctx->progress_fd) in PRS()
860 fd = dup(ctx->progress_fd); in PRS()
864 ctx->progress_fd, in PRS()
866 fatal_error(ctx, in PRS()
872 ctx->options |= E2F_OPT_COMPRESS_DIRS; in PRS()
879 if (ctx->options & (E2F_OPT_YES|E2F_OPT_NO)) { in PRS()
881 fatal_error(ctx, in PRS()
884 ctx->options |= E2F_OPT_PREEN; in PRS()
887 if (ctx->options & (E2F_OPT_YES|E2F_OPT_PREEN)) in PRS()
889 ctx->options |= E2F_OPT_NO; in PRS()
892 if (ctx->options & (E2F_OPT_PREEN|E2F_OPT_NO)) in PRS()
894 ctx->options |= E2F_OPT_YES; in PRS()
898 if (ctx->options & E2F_OPT_TIME) in PRS()
899 ctx->options |= E2F_OPT_TIME2; in PRS()
901 ctx->options |= E2F_OPT_TIME; in PRS()
909 ctx->options |= E2F_OPT_WRITECHECK; in PRS()
910 ctx->options |= E2F_OPT_CHECKBLOCKS; in PRS()
916 res = sscanf(optarg, "%llu", &ctx->use_superblock); in PRS()
919 ctx->flags |= E2F_FLAG_SB_SPECIFIED; in PRS()
922 ctx->blocksize = atoi(optarg); in PRS()
925 res = sscanf(optarg, "%d", &ctx->inode_buffer_blocks); in PRS()
930 ctx->journal_name = blkid_get_devname(ctx->blkid, in PRS()
932 if (!ctx->journal_name) { in PRS()
933 com_err(ctx->program_name, 0, in PRS()
936 fatal_error(ctx, 0); in PRS()
940 res = sscanf(optarg, "%d", &ctx->process_inode_size); in PRS()
950 bad_blocks_file = string_copy(ctx, optarg, 0); in PRS()
953 ctx->options |= E2F_OPT_DEBUG; in PRS()
956 ctx->options |= E2F_OPT_FORCE; in PRS()
973 ctx->device_name = string_copy(ctx, optarg, 0); in PRS()
979 ctx->undo_file = optarg; in PRS()
982 usage(ctx); in PRS()
987 usage(ctx); in PRS()
988 if ((ctx->options & E2F_OPT_NO) && in PRS()
989 (ctx->options & E2F_OPT_COMPRESS_DIRS)) { in PRS()
990 com_err(ctx->program_name, 0, "%s", in PRS()
992 fatal_error(ctx, 0); in PRS()
994 if ((ctx->options & E2F_OPT_NO) && cflag) { in PRS()
995 com_err(ctx->program_name, 0, "%s", in PRS()
997 fatal_error(ctx, 0); in PRS()
999 if ((ctx->options & E2F_OPT_NO) && bad_blocks_file) { in PRS()
1000 com_err(ctx->program_name, 0, "%s", in PRS()
1002 fatal_error(ctx, 0); in PRS()
1004 if (ctx->options & E2F_OPT_NO) in PRS()
1005 ctx->options |= E2F_OPT_READONLY; in PRS()
1007 ctx->io_options = strchr(argv[optind], '?'); in PRS()
1008 if (ctx->io_options) in PRS()
1009 *ctx->io_options++ = 0; in PRS()
1010 ctx->filesystem_name = blkid_get_devname(ctx->blkid, argv[optind], 0); in PRS()
1011 if (!ctx->filesystem_name) { in PRS()
1012 com_err(ctx->program_name, 0, _("Unable to resolve '%s'"), in PRS()
1014 fatal_error(ctx, 0); in PRS()
1017 parse_extended_opts(ctx, extended_opts); in PRS()
1021 ctx->options |= E2F_OPT_FIXES_ONLY; in PRS()
1022 if ((ctx->options & E2F_OPT_COMPRESS_DIRS) && in PRS()
1023 (ctx->options & E2F_OPT_FIXES_ONLY)) { in PRS()
1024 com_err(ctx->program_name, 0, "%s", in PRS()
1026 fatal_error(ctx, 0); in PRS()
1028 if ((ctx->options & E2F_OPT_CONVERT_BMAP) && in PRS()
1029 (ctx->options & E2F_OPT_FIXES_ONLY)) { in PRS()
1030 com_err(ctx->program_name, 0, "%s", in PRS()
1032 fatal_error(ctx, 0); in PRS()
1038 profile_init(config_fn, &ctx->profile); in PRS()
1040 profile_get_boolean(ctx->profile, "options", "report_time", 0, 0, in PRS()
1043 ctx->options |= E2F_OPT_TIME | E2F_OPT_TIME2; in PRS()
1044 profile_get_boolean(ctx->profile, "options", "report_verbose", 0, 0, in PRS()
1049 profile_get_boolean(ctx->profile, "options", "no_optimize_extents", in PRS()
1052 ctx->options |= E2F_OPT_NOOPT_EXTENTS; in PRS()
1054 profile_get_boolean(ctx->profile, "options", "inode_count_fullmap", in PRS()
1057 ctx->options |= E2F_OPT_ICOUNT_FULLMAP; in PRS()
1059 if (ctx->readahead_kb == ~0ULL) { in PRS()
1060 profile_get_integer(ctx->profile, "options", in PRS()
1063 ctx->readahead_kb = phys_mem_kb * c / 100; in PRS()
1064 profile_get_integer(ctx->profile, "options", in PRS()
1067 ctx->readahead_kb = c; in PRS()
1068 if (ctx->readahead_kb != ~0ULL && in PRS()
1069 ctx->readahead_kb > phys_mem_kb) in PRS()
1070 ctx->readahead_kb = phys_mem_kb; in PRS()
1074 if ((ctx->options & E2F_OPT_NO) && in PRS()
1075 (ctx->options & E2F_OPT_DISCARD)) in PRS()
1076 ctx->options &= ~E2F_OPT_DISCARD; in PRS()
1079 fd = open(ctx->filesystem_name, O_RDONLY, 0); in PRS()
1083 ctx->filesystem_name); in PRS()
1084 fatal_error(ctx, 0); in PRS()
1089 ctx->filesystem_name); in PRS()
1090 fatal_error(ctx, 0); in PRS()
1127 fatal_error(ctx, "Couldn't malloc() newpath"); in PRS()
1156 static errcode_t try_open_fs(e2fsck_t ctx, int flags, io_manager io_ptr, in try_open_fs() argument
1162 if (ctx->superblock && ctx->blocksize) { in try_open_fs()
1163 retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options, in try_open_fs()
1164 flags, ctx->superblock, ctx->blocksize, in try_open_fs()
1166 } else if (ctx->superblock) { in try_open_fs()
1174 retval = ext2fs_open2(ctx->filesystem_name, in try_open_fs()
1175 ctx->io_options, flags, in try_open_fs()
1176 ctx->superblock, blocksize, in try_open_fs()
1182 retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options, in try_open_fs()
1186 (*ret_fs)->priv_data = ctx; in try_open_fs()
1196 static errcode_t e2fsck_check_mmp(ext2_filsys fs, e2fsck_t ctx) in e2fsck_check_mmp() argument
1242 log_out(ctx, _("MMP interval is %u seconds and total wait " in e2fsck_check_mmp()
1252 if (fix_problem(ctx, PR_0_MMP_INVALID_BLK, &pctx)) { in e2fsck_check_mmp()
1258 com_err(ctx->program_name, retval, "%s", in e2fsck_check_mmp()
1263 com_err(ctx->program_name, retval, "%s", in e2fsck_check_mmp()
1269 ctx->device_name); in e2fsck_check_mmp()
1271 if (fix_problem(ctx, PR_0_MMP_INVALID_MAGIC, &pctx)) { in e2fsck_check_mmp()
1276 if (fix_problem(ctx, PR_0_MMP_CSUM_INVALID, &pctx)) { in e2fsck_check_mmp()
1281 com_err(ctx->program_name, retval, "%s", in e2fsck_check_mmp()
1286 static int e2fsck_setup_tdb(e2fsck_t ctx, io_manager *io_ptr) in e2fsck_setup_tdb() argument
1294 if (ctx->undo_file && ctx->undo_file[0] != 0) { in e2fsck_setup_tdb()
1299 retval = set_undo_io_backup_file(ctx->undo_file); in e2fsck_setup_tdb()
1305 ctx->undo_file, ctx->filesystem_name); in e2fsck_setup_tdb()
1315 profile_get_string(ctx->profile, "defaults", in e2fsck_setup_tdb()
1328 tmp_name = strdup(ctx->filesystem_name); in e2fsck_setup_tdb()
1342 com_err(ctx->program_name, retval, in e2fsck_setup_tdb()
1356 " e2undo %s %s\n\n"), tdb_file, ctx->filesystem_name); in e2fsck_setup_tdb()
1368 com_err(ctx->program_name, retval, "%s", in e2fsck_setup_tdb()
1382 e2fsck_t ctx; in main() local
1416 retval = PRS(argc, argv, &ctx); in main()
1424 set_up_logging(ctx); in main()
1425 if (ctx->logf) { in main()
1428 fputs("E2fsck run: ", ctx->logf); in main()
1431 fputc(' ', ctx->logf); in main()
1432 fputs(argv[i], ctx->logf); in main()
1434 fputc('\n', ctx->logf); in main()
1436 if (ctx->problem_logf) { in main()
1440 ctx->problem_logf); in main()
1441 fprintf(ctx->problem_logf, "<problem_log time=\"%lu\">\n", in main()
1442 ctx->now); in main()
1443 fprintf(ctx->problem_logf, "<invocation prog=\"%s\"", in main()
1446 fprintf(ctx->problem_logf, " arg%d=\"%s\"", i, argv[i]); in main()
1447 fputs("/>\n", ctx->problem_logf); in main()
1450 init_resource_track(&ctx->global_rtrack, NULL); in main()
1451 if (!(ctx->options & E2F_OPT_PREEN) || show_version_only) in main()
1452 log_err(ctx, "e2fsck %s (%s)\n", my_ver_string, in main()
1456 log_err(ctx, _("\tUsing %s, %s\n"), in main()
1461 check_mount(ctx); in main()
1463 if (!(ctx->options & E2F_OPT_PREEN) && in main()
1464 !(ctx->options & E2F_OPT_NO) && in main()
1465 !(ctx->options & E2F_OPT_YES)) { in main()
1466 if (!ctx->interactive) in main()
1467 fatal_error(ctx, in main()
1470 ctx->superblock = ctx->use_superblock; in main()
1482 profile_get_boolean(ctx->profile, "options", "old_bitmaps", 0, 0, in main()
1486 if ((ctx->options & E2F_OPT_READONLY) == 0) { in main()
1488 if (!(ctx->mount_flags & EXT2_MF_ISROOT && in main()
1489 ctx->mount_flags & EXT2_MF_READONLY)) in main()
1491 if ((ctx->mount_flags & EXT2_MF_READONLY) && in main()
1492 (ctx->options & E2F_OPT_FORCE)) in main()
1496 if (ctx->undo_file) { in main()
1497 retval = e2fsck_setup_tdb(ctx, &io_ptr); in main()
1502 ctx->openfs_flags = flags; in main()
1503 retval = try_open_fs(ctx, flags, io_ptr, &fs); in main()
1505 if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) && in main()
1506 !(ctx->flags & E2F_FLAG_SB_SPECIFIED) && in main()
1513 fix_problem(ctx, PR_0_OPEN_FAILED, &pctx); in main()
1517 fix_problem(ctx, PR_0_CHECK_DESC_FAILED, &pctx); in main()
1529 log_out(ctx, _("%s: %s trying backup blocks...\n"), in main()
1530 ctx->program_name, in main()
1533 orig_superblock = ctx->superblock; in main()
1534 get_backup_sb(ctx, fs, ctx->filesystem_name, io_ptr); in main()
1538 retval = try_open_fs(ctx, flags, io_ptr, &fs); in main()
1542 log_out(ctx, _("%s: %s while using the " in main()
1544 ctx->program_name, in main()
1546 log_out(ctx, _("%s: going back to original " in main()
1548 ctx->program_name); in main()
1549 ctx->superblock = orig_superblock; in main()
1550 retval = try_open_fs(ctx, flags, io_ptr, &fs); in main()
1571 com_err(ctx->program_name, retval, _("while trying to open %s"), in main()
1572 ctx->filesystem_name); in main()
1574 log_out(ctx, "%s", in main()
1579 fix_problem(ctx, PR_0_SB_CORRUPT, &pctx); in main()
1581 log_out(ctx, "%s", in main()
1584 log_out(ctx, _("You must have %s access to the " in main()
1586 (ctx->options & E2F_OPT_READONLY) ? in main()
1589 log_out(ctx, "%s", in main()
1592 log_out(ctx, "%s", _("Filesystem mounted or opened " in main()
1595 log_out(ctx, "%s", in main()
1599 log_out(ctx, "%s", _("Disk write-protected; use the " in main()
1613 log_out(ctx, _("%s: Trying to load superblock " in main()
1615 ctx->program_name); in main()
1622 ctx->superblock = orig_superblock; in main()
1625 fix_problem(ctx, PR_0_SB_CORRUPT, &pctx); in main()
1627 check_plausibility(ctx->filesystem_name, in main()
1630 fatal_error(ctx, 0); in main()
1645 if (!(ctx->flags & E2F_FLAG_GOT_DEVSIZE)) { in main()
1649 pctx.errcode = ext2fs_get_device_size2(ctx->filesystem_name, in main()
1651 &ctx->num_blocks); in main()
1663 ext2fs_get_device_size2(ctx->filesystem_name, in main()
1665 &ctx->num_blocks); in main()
1668 ctx->num_blocks = 0; in main()
1670 fix_problem(ctx, PR_0_GETSIZE_ERROR, &pctx); in main()
1671 ctx->flags |= E2F_FLAG_ABORT; in main()
1672 fatal_error(ctx, 0); in main()
1674 ctx->flags |= E2F_FLAG_GOT_DEVSIZE; in main()
1679 ctx->fs = fs; in main()
1680 fs->now = ctx->now; in main()
1684 com_err(ctx->program_name, EXT2_ET_REV_TOO_HIGH, in main()
1686 ctx->filesystem_name); in main()
1688 fatal_error(ctx, _("Get a newer version of e2fsck!")); in main()
1695 if (ctx->device_name == 0 && sb->s_volume_name[0]) in main()
1696 ctx->device_name = string_copy(ctx, sb->s_volume_name, in main()
1699 if (ctx->device_name == 0) in main()
1700 ctx->device_name = string_copy(ctx, ctx->filesystem_name, 0); in main()
1701 for (cp = ctx->device_name; *cp; cp++) in main()
1705 if (ctx->problem_logf) { in main()
1707 fprintf(ctx->problem_logf, "<filesystem dev=\"%s\"", in main()
1708 ctx->filesystem_name); in main()
1713 fprintf(ctx->problem_logf, " uuid=\"%s\"", buf); in main()
1716 fprintf(ctx->problem_logf, " label=\"%.*s\"", in main()
1719 fputs("/>\n", ctx->problem_logf); in main()
1726 if (e2fsck_check_mmp(fs, ctx)) in main()
1727 fatal_error(ctx, 0); in main()
1732 ext2fs_close_free(&ctx->fs); in main()
1737 if (ctx->logf) in main()
1738 fprintf(ctx->logf, "Filesystem UUID: %s\n", in main()
1744 if ((ctx->mount_flags & (EXT2_MF_MOUNTED | EXT2_MF_BUSY)) == 0) { in main()
1745 retval = e2fsck_check_ext3_journal(ctx); in main()
1747 com_err(ctx->program_name, retval, in main()
1749 ctx->device_name); in main()
1750 fatal_error(ctx, in main()
1760 if (ctx->options & E2F_OPT_READONLY) { in main()
1761 log_out(ctx, "%s", in main()
1764 io_channel_flush(ctx->fs->io); in main()
1766 if (ctx->flags & E2F_FLAG_RESTARTED) { in main()
1773 com_err(ctx->program_name, 0, in main()
1775 "on %s\n"), ctx->device_name); in main()
1776 fatal_error(ctx, 0); in main()
1778 retval = e2fsck_run_ext3_journal(ctx); in main()
1780 log_out(ctx, _("Journal checksum error " in main()
1782 ctx->device_name); in main()
1784 log_out(ctx, _("Journal corrupted in %s\n"), in main()
1785 ctx->device_name); in main()
1787 com_err(ctx->program_name, retval, in main()
1789 ctx->device_name); in main()
1791 ext2fs_close_free(&ctx->fs); in main()
1792 ctx->flags |= E2F_FLAG_RESTARTED; in main()
1810 log_err(ctx, _("%s has unsupported feature(s):"), in main()
1811 ctx->filesystem_name); in main()
1816 log_err(ctx, " %s", in main()
1820 log_err(ctx, "\n"); in main()
1825 log_err(ctx, _("%s has unsupported encoding: %0x\n"), in main()
1826 ctx->filesystem_name, sb->s_encoding); in main()
1835 if (ctx->superblock && in main()
1836 !(ctx->options & E2F_OPT_READONLY)) in main()
1849 ctx->blocks_per_page = sys_page_size / fs->blocksize; in main()
1850 if (ctx->blocks_per_page == 0) in main()
1851 ctx->blocks_per_page = 1; in main()
1853 if (ctx->superblock) in main()
1856 check_super_block(ctx); in main()
1857 if (ctx->flags & E2F_FLAG_SIGNAL_MASK) in main()
1858 fatal_error(ctx, 0); in main()
1859 check_if_skip(ctx); in main()
1860 check_resize_inode(ctx); in main()
1862 read_bad_blocks_file(ctx, bad_blocks_file, replace_bad_blocks); in main()
1864 read_bad_blocks_file(ctx, 0, !keep_bad_blocks); /* Test disk */ in main()
1865 if (ctx->flags & E2F_FLAG_SIGNAL_MASK) in main()
1866 fatal_error(ctx, 0); in main()
1875 log_out(ctx, _("%s: %s while reading bad blocks inode\n"), in main()
1876 ctx->program_name, error_message(retval)); in main()
1877 preenhalt(ctx); in main()
1878 log_out(ctx, "%s", _("This doesn't bode well, " in main()
1896 pctx.errcode = quota_init_context(&ctx->qctx, ctx->fs, 0); in main()
1898 fix_problem(ctx, PR_0_QUOTA_INIT_CTX, &pctx); in main()
1899 fatal_error(ctx, 0); in main()
1903 run_result = e2fsck_run(ctx); in main()
1904 e2fsck_clear_progbar(ctx); in main()
1906 if (!ctx->invalid_bitmaps && in main()
1907 (ctx->flags & E2F_FLAG_JOURNAL_INODE)) { in main()
1908 if (fix_problem(ctx, PR_6_RECREATE_JOURNAL, &pctx)) { in main()
1914 log_out(ctx, "%s: Couldn't determine " in main()
1915 "journal size\n", ctx->program_name); in main()
1918 log_out(ctx, _("Creating journal (%d blocks): "), in main()
1924 log_out(ctx, "%s: while trying to create " in main()
1928 log_out(ctx, "%s", _(" Done.\n")); in main()
1929 log_out(ctx, "%s", in main()
1936 fatal_error(ctx, _("aborted")); in main()
1938 log_out(ctx, _("%s: e2fsck canceled.\n"), ctx->device_name ? in main()
1939 ctx->device_name : ctx->filesystem_name); in main()
1941 } else if (ctx->qctx && !ctx->invalid_bitmaps) { in main()
1949 retval = quota_compare_and_update(ctx->qctx, qtype, in main()
1952 fix_problem(ctx, PR_6_UPDATE_QUOTAS, &pctx)) { in main()
1953 pctx.errcode = quota_write_inode(ctx->qctx, in main()
1956 (void) fix_problem(ctx, in main()
1960 quota_release_context(&ctx->qctx); in main()
1964 log_out(ctx, "%s", in main()
1966 retval = e2fsck_reset_context(ctx); in main()
1968 com_err(ctx->program_name, retval, "%s", in main()
1970 fatal_error(ctx, 0); in main()
1972 ext2fs_close_free(&ctx->fs); in main()
1980 if (!(ctx->flags & E2F_FLAG_RUN_RETURN) && in main()
1981 !(ctx->options & E2F_OPT_READONLY)) { in main()
1986 if (check_backup_super_block(ctx)) in main()
1990 if (!(ctx->flags & E2F_FLAG_TIME_INSANE)) in main()
1991 sb->s_lastcheck = ctx->now; in main()
1994 pctx.errcode = ext2fs_set_gdt_csum(ctx->fs); in main()
1996 fix_problem(ctx, PR_6_SET_BG_CHECKSUM, &pctx); in main()
2000 if (ext2fs_has_feature_shared_blocks(ctx->fs->super) && in main()
2001 (ctx->options & E2F_OPT_UNSHARE_BLOCKS) && in main()
2002 (ctx->options & E2F_OPT_NO)) in main()
2008 if (!(ctx->options & E2F_OPT_READONLY)) { in main()
2009 e2fsck_write_bitmaps(ctx); in main()
2011 pctx.errcode = ext2fs_flush(ctx->fs); in main()
2013 fix_problem(ctx, PR_6_FLUSH_FILESYSTEM, &pctx); in main()
2015 pctx.errcode = io_channel_flush(ctx->fs->io); in main()
2017 fix_problem(ctx, PR_6_IO_FLUSH, &pctx); in main()
2021 int fs_fixed = (ctx->flags & E2F_FLAG_PROBLEMS_FIXED); in main()
2025 if (!(ctx->options & E2F_OPT_PREEN)) { in main()
2027 log_out(ctx, fs_fixed ? in main()
2031 ctx->device_name); in main()
2033 log_out(ctx, in main()
2035 ctx->device_name); in main()
2038 if (ctx->mount_flags & EXT2_MF_ISROOT) { in main()
2039 log_out(ctx, _("%s: ***** REBOOT SYSTEM *****\n"), in main()
2040 ctx->device_name); in main()
2049 log_out(ctx, _("\n%s: ********** WARNING: Filesystem still has " in main()
2050 "errors **********\n\n"), ctx->device_name); in main()
2057 profile_get_boolean(ctx->profile, "options", in main()
2066 show_stats(ctx); in main()
2068 print_resource_track(ctx, NULL, &ctx->global_rtrack, ctx->fs->io); in main()
2070 ext2fs_close_free(&ctx->fs); in main()
2071 free(ctx->journal_name); in main()
2073 if (ctx->logf) in main()
2074 fprintf(ctx->logf, "Exit status: %d\n", exit_value); in main()
2075 e2fsck_free_context(ctx); in main()