Lines Matching refs:ctx
74 static void usage(e2fsck_t ctx) in usage() argument
80 ctx->program_name); in usage()
101 static void show_stats(e2fsck_t ctx) in show_stats() argument
103 ext2_filsys fs = ctx->fs; in show_stats()
112 dir_links = 2 * ctx->fs_directory_count - 1; in show_stats()
113 num_files = ctx->fs_total_count - dir_links; in show_stats()
114 num_links = ctx->fs_links_count - dir_links; in show_stats()
122 frag_percent_file = (10000 * ctx->fs_fragmented) / inodes_used; in show_stats()
125 frag_percent_dir = (10000 * ctx->fs_fragmented_dir) / inodes_used; in show_stats()
128 frag_percent_total = ((10000 * (ctx->fs_fragmented + in show_stats()
129 ctx->fs_fragmented_dir)) in show_stats()
134 log_out(ctx, _("%s: %u/%u files (%0d.%d%% non-contiguous), " in show_stats()
136 ctx->device_name, inodes_used, inodes, in show_stats()
141 profile_get_boolean(ctx->profile, "options", "report_features", 0, 0, in show_stats()
144 log_out(ctx, "\nFilesystem features:"); in show_stats()
145 mask = &ctx->fs->super->s_feature_compat; in show_stats()
149 log_out(ctx, " %s", in show_stats()
156 log_out(ctx, " (none)"); in show_stats()
157 log_out(ctx, "\n"); in show_stats()
160 log_out(ctx, P_("\n%12u inode used (%2.2f%%, out of %u)\n", in show_stats()
164 log_out(ctx, P_("%12u non-contiguous file (%0d.%d%%)\n", in show_stats()
166 ctx->fs_fragmented), in show_stats()
167 ctx->fs_fragmented, frag_percent_file / 10, in show_stats()
169 log_out(ctx, P_("%12u non-contiguous directory (%0d.%d%%)\n", in show_stats()
171 ctx->fs_fragmented_dir), in show_stats()
172 ctx->fs_fragmented_dir, frag_percent_dir / 10, in show_stats()
174 log_out(ctx, _(" # of inodes with ind/dind/tind blocks: " in show_stats()
176 ctx->fs_ind_count, ctx->fs_dind_count, ctx->fs_tind_count); in show_stats()
179 if (ctx->extent_depth_count[j]) in show_stats()
182 log_out(ctx, "%s", _(" Extent depth histogram: ")); in show_stats()
186 log_out(ctx, "%u", ctx->extent_depth_count[i]); in show_stats()
188 log_out(ctx, "\n"); in show_stats()
191 log_out(ctx, P_("%12llu block used (%2.2f%%, out of %llu)\n", in show_stats()
195 log_out(ctx, P_("%12u bad block\n", "%12u bad blocks\n", in show_stats()
196 ctx->fs_badblocks_count), ctx->fs_badblocks_count); in show_stats()
197 log_out(ctx, P_("%12u large file\n", "%12u large files\n", in show_stats()
198 ctx->large_files), ctx->large_files); in show_stats()
199 log_out(ctx, P_("\n%12u regular file\n", "\n%12u regular files\n", in show_stats()
200 ctx->fs_regular_count), ctx->fs_regular_count); in show_stats()
201 log_out(ctx, P_("%12u directory\n", "%12u directories\n", in show_stats()
202 ctx->fs_directory_count), ctx->fs_directory_count); in show_stats()
203 log_out(ctx, P_("%12u character device file\n", in show_stats()
204 "%12u character device files\n", ctx->fs_chardev_count), in show_stats()
205 ctx->fs_chardev_count); in show_stats()
206 log_out(ctx, P_("%12u block device file\n", "%12u block device files\n", in show_stats()
207 ctx->fs_blockdev_count), ctx->fs_blockdev_count); in show_stats()
208 log_out(ctx, P_("%12u fifo\n", "%12u fifos\n", ctx->fs_fifo_count), in show_stats()
209 ctx->fs_fifo_count); in show_stats()
210 log_out(ctx, P_("%12u link\n", "%12u links\n", num_links), in show_stats()
211 ctx->fs_links_count - dir_links); in show_stats()
212 log_out(ctx, P_("%12u symbolic link", "%12u symbolic links", in show_stats()
213 ctx->fs_symlinks_count), ctx->fs_symlinks_count); in show_stats()
214 log_out(ctx, P_(" (%u fast symbolic link)\n", in show_stats()
216 ctx->fs_fast_symlinks_count), in show_stats()
217 ctx->fs_fast_symlinks_count); in show_stats()
218 log_out(ctx, P_("%12u socket\n", "%12u sockets\n", in show_stats()
219 ctx->fs_sockets_count), in show_stats()
220 ctx->fs_sockets_count); in show_stats()
221 log_out(ctx, "------------\n"); in show_stats()
222 log_out(ctx, P_("%12u file\n", "%12u files\n", num_files), in show_stats()
226 static void check_mount(e2fsck_t ctx) in check_mount() argument
231 retval = ext2fs_check_if_mounted(ctx->filesystem_name, in check_mount()
232 &ctx->mount_flags); in check_mount()
236 ctx->filesystem_name); in check_mount()
245 if ((!(ctx->mount_flags & (EXT2_MF_MOUNTED | EXT2_MF_BUSY))) || in check_mount()
246 ((ctx->mount_flags & EXT2_MF_ISROOT) && in check_mount()
247 (ctx->mount_flags & EXT2_MF_READONLY) && in check_mount()
248 !(ctx->options & E2F_OPT_WRITECHECK))) in check_mount()
251 if (((ctx->options & E2F_OPT_READONLY) || in check_mount()
252 ((ctx->options & E2F_OPT_FORCE) && in check_mount()
253 (ctx->mount_flags & EXT2_MF_READONLY))) && in check_mount()
254 !(ctx->options & E2F_OPT_WRITECHECK)) { in check_mount()
255 if (ctx->mount_flags & EXT2_MF_MOUNTED) in check_mount()
256 log_out(ctx, _("Warning! %s is mounted.\n"), in check_mount()
257 ctx->filesystem_name); in check_mount()
259 log_out(ctx, _("Warning! %s is in use.\n"), in check_mount()
260 ctx->filesystem_name); in check_mount()
264 if (ctx->mount_flags & EXT2_MF_MOUNTED) in check_mount()
265 log_out(ctx, _("%s is mounted.\n"), ctx->filesystem_name); in check_mount()
267 log_out(ctx, _("%s is in use.\n"), ctx->filesystem_name); in check_mount()
268 if (!ctx->interactive || ctx->mount_flags & EXT2_MF_BUSY) in check_mount()
269 fatal_error(ctx, _("Cannot continue, aborting.\n\n")); in check_mount()
271 log_out(ctx, "%s", _("\n\nWARNING!!! " in check_mount()
276 cont = ask_yn(ctx, _("Do you really want to continue"), 0); in check_mount()
335 static void check_if_skip(e2fsck_t ctx) in check_if_skip() argument
337 ext2_filsys fs = ctx->fs; in check_if_skip()
347 if (ctx->flags & E2F_FLAG_PROBLEMS_FIXED) in check_if_skip()
350 profile_get_boolean(ctx->profile, "options", "broken_system_clock", in check_if_skip()
352 if (ctx->flags & E2F_FLAG_TIME_INSANE) in check_if_skip()
354 profile_get_boolean(ctx->profile, "options", in check_if_skip()
360 if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file || cflag) in check_if_skip()
363 if (ctx->options & E2F_OPT_JOURNAL_ONLY) in check_if_skip()
367 if (lastcheck > ctx->now) in check_if_skip()
368 lastcheck -= ctx->time_fudge; in check_if_skip()
374 else if (check_backup_super_block(ctx)) in check_if_skip()
385 (ctx->now < lastcheck)) { in check_if_skip()
390 ((ctx->now - lastcheck) >= in check_if_skip()
393 reason_arg = (ctx->now - fs->super->s_lastcheck)/(3600*24); in check_if_skip()
394 if (batt && ((ctx->now - fs->super->s_lastcheck) < in check_if_skip()
399 log_out(ctx, "%s", ctx->device_name); in check_if_skip()
400 log_out(ctx, reason, reason_arg); in check_if_skip()
401 log_out(ctx, "%s", _(", check forced.\n")); in check_if_skip()
416 pctx.ino2 = ctx->free_inodes; in check_if_skip()
418 !(ctx->options & E2F_OPT_READONLY) && in check_if_skip()
419 fix_problem(ctx, PR_0_FREE_INODE_COUNT, &pctx)) { in check_if_skip()
420 fs->super->s_free_inodes_count = ctx->free_inodes; in check_if_skip()
425 pctx.blk2 = ctx->free_blocks; in check_if_skip()
427 !(ctx->options & E2F_OPT_READONLY) && in check_if_skip()
428 fix_problem(ctx, PR_0_FREE_BLOCK_COUNT, &pctx)) { in check_if_skip()
429 ext2fs_free_blocks_count_set(fs->super, ctx->free_blocks); in check_if_skip()
434 log_out(ctx, _("%s: clean, %u/%u files, %llu/%llu blocks"), in check_if_skip()
435 ctx->device_name, in check_if_skip()
448 ((ctx->now - fs->super->s_lastcheck) >= fs->super->s_checkinterval)) in check_if_skip()
453 log_out(ctx, "%s", in check_if_skip()
456 log_out(ctx, "%s", in check_if_skip()
459 log_out(ctx, _(" (check in %ld mounts)"), in check_if_skip()
462 log_out(ctx, "\n"); in check_if_skip()
464 ext2fs_close_free(&ctx->fs); in check_if_skip()
465 e2fsck_free_context(ctx); in check_if_skip()
495 void e2fsck_clear_progbar(e2fsck_t ctx) in e2fsck_clear_progbar() argument
497 if (!(ctx->flags & E2F_FLAG_PROG_BAR)) in e2fsck_clear_progbar()
500 printf("%s%s\r%s", ctx->start_meta, spaces + (sizeof(spaces) - 80), in e2fsck_clear_progbar()
501 ctx->stop_meta); in e2fsck_clear_progbar()
503 ctx->flags &= ~E2F_FLAG_PROG_BAR; in e2fsck_clear_progbar()
506 int e2fsck_simple_progress(e2fsck_t ctx, const char *label, float percent, in e2fsck_simple_progress() argument
516 if (ctx->flags & E2F_FLAG_PROG_SUPPRESS) in e2fsck_simple_progress()
525 if (ctx->progress_last_percent == fixed_percent) in e2fsck_simple_progress()
527 ctx->progress_last_percent = fixed_percent; in e2fsck_simple_progress()
536 if ((tick == ctx->progress_last_time) && in e2fsck_simple_progress()
539 ctx->progress_last_time = tick; in e2fsck_simple_progress()
545 ctx->progress_pos = (ctx->progress_pos+1) & 3; in e2fsck_simple_progress()
546 ctx->flags |= E2F_FLAG_PROG_BAR; in e2fsck_simple_progress()
554 printf("%s%s: |%s%s", ctx->start_meta, label, in e2fsck_simple_progress()
560 fputc(spinner[ctx->progress_pos & 3], stdout); in e2fsck_simple_progress()
566 fputs(ctx->stop_meta, stdout); in e2fsck_simple_progress()
569 e2fsck_clear_progbar(ctx); in e2fsck_simple_progress()
575 static int e2fsck_update_progress(e2fsck_t ctx, int pass, in e2fsck_update_progress() argument
584 if (ctx->progress_fd) { in e2fsck_update_progress()
586 pass, cur, max, ctx->device_name); in e2fsck_update_progress()
587 write_all(ctx->progress_fd, buf, strlen(buf)); in e2fsck_update_progress()
590 e2fsck_simple_progress(ctx, ctx->device_name, in e2fsck_update_progress()
620 e2fsck_t ctx = e2fsck_global_ctx; in signal_progress_on() local
622 if (!ctx) in signal_progress_on()
625 ctx->progress = e2fsck_update_progress; in signal_progress_on()
630 e2fsck_t ctx = e2fsck_global_ctx; in signal_progress_off() local
632 if (!ctx) in signal_progress_off()
635 e2fsck_clear_progbar(ctx); in signal_progress_off()
636 ctx->progress = 0; in signal_progress_off()
641 e2fsck_t ctx = e2fsck_global_ctx; in signal_cancel() local
643 if (!ctx) in signal_cancel()
646 ctx->flags |= E2F_FLAG_CANCEL; in signal_cancel()
650 static void parse_extended_opts(e2fsck_t ctx, const char *opts) in parse_extended_opts() argument
657 buf = string_copy(ctx, opts, 0); in parse_extended_opts()
683 ctx->ext_attr_ver = ea_ver; in parse_extended_opts()
696 ctx->readahead_kb = reada_kb; in parse_extended_opts()
698 ctx->options |= E2F_OPT_FRAGCHECK; in parse_extended_opts()
705 ctx->options |= E2F_OPT_JOURNAL_ONLY; in parse_extended_opts()
707 ctx->options |= E2F_OPT_DISCARD; in parse_extended_opts()
710 ctx->options &= ~E2F_OPT_DISCARD; in parse_extended_opts()
716 ctx->log_fn = string_copy(ctx, arg, 0); in parse_extended_opts()
719 ctx->options |= E2F_OPT_CONVERT_BMAP; in parse_extended_opts()
722 ctx->options |= E2F_OPT_FIXES_ONLY; in parse_extended_opts()
766 e2fsck_t ctx; in PRS() local
779 retval = e2fsck_allocate_context(&ctx); in PRS()
783 *ret_ctx = ctx; in PRS()
784 e2fsck_global_ctx = ctx; in PRS()
789 ctx->interactive = 1; in PRS()
791 ctx->start_meta[0] = '\001'; in PRS()
792 ctx->stop_meta[0] = '\002'; in PRS()
798 blkid_get_cache(&ctx->blkid, NULL); in PRS()
801 ctx->program_name = *argv; in PRS()
803 ctx->program_name = "e2fsck"; in PRS()
806 ctx->readahead_kb = ~0ULL; in PRS()
810 ctx->progress = e2fsck_update_progress; in PRS()
811 res = sscanf(optarg, "%d", &ctx->progress_fd); in PRS()
815 if (ctx->progress_fd < 0) { in PRS()
816 ctx->progress = 0; in PRS()
817 ctx->progress_fd = ctx->progress_fd * -1; in PRS()
819 if (!ctx->progress_fd) in PRS()
822 fd = dup(ctx->progress_fd); in PRS()
826 ctx->progress_fd, in PRS()
828 fatal_error(ctx, in PRS()
834 ctx->options |= E2F_OPT_COMPRESS_DIRS; in PRS()
841 if (ctx->options & (E2F_OPT_YES|E2F_OPT_NO)) { in PRS()
843 fatal_error(ctx, in PRS()
846 ctx->options |= E2F_OPT_PREEN; in PRS()
849 if (ctx->options & (E2F_OPT_YES|E2F_OPT_PREEN)) in PRS()
851 ctx->options |= E2F_OPT_NO; in PRS()
854 if (ctx->options & (E2F_OPT_PREEN|E2F_OPT_NO)) in PRS()
856 ctx->options |= E2F_OPT_YES; in PRS()
860 if (ctx->options & E2F_OPT_TIME) in PRS()
861 ctx->options |= E2F_OPT_TIME2; in PRS()
863 ctx->options |= E2F_OPT_TIME; in PRS()
871 ctx->options |= E2F_OPT_WRITECHECK; in PRS()
872 ctx->options |= E2F_OPT_CHECKBLOCKS; in PRS()
878 res = sscanf(optarg, "%llu", &ctx->use_superblock); in PRS()
881 ctx->flags |= E2F_FLAG_SB_SPECIFIED; in PRS()
884 ctx->blocksize = atoi(optarg); in PRS()
887 res = sscanf(optarg, "%d", &ctx->inode_buffer_blocks); in PRS()
892 ctx->journal_name = blkid_get_devname(ctx->blkid, in PRS()
894 if (!ctx->journal_name) { in PRS()
895 com_err(ctx->program_name, 0, in PRS()
898 fatal_error(ctx, 0); in PRS()
902 res = sscanf(optarg, "%d", &ctx->process_inode_size); in PRS()
911 bad_blocks_file = string_copy(ctx, optarg, 0); in PRS()
914 ctx->options |= E2F_OPT_DEBUG; in PRS()
917 ctx->options |= E2F_OPT_FORCE; in PRS()
934 ctx->device_name = string_copy(ctx, optarg, 0); in PRS()
940 ctx->undo_file = optarg; in PRS()
943 usage(ctx); in PRS()
948 usage(ctx); in PRS()
949 if ((ctx->options & E2F_OPT_NO) && in PRS()
950 (ctx->options & E2F_OPT_COMPRESS_DIRS)) { in PRS()
951 com_err(ctx->program_name, 0, "%s", in PRS()
953 fatal_error(ctx, 0); in PRS()
955 if ((ctx->options & E2F_OPT_NO) && cflag) { in PRS()
956 com_err(ctx->program_name, 0, "%s", in PRS()
958 fatal_error(ctx, 0); in PRS()
960 if ((ctx->options & E2F_OPT_NO) && bad_blocks_file) { in PRS()
961 com_err(ctx->program_name, 0, "%s", in PRS()
963 fatal_error(ctx, 0); in PRS()
965 if (ctx->options & E2F_OPT_NO) in PRS()
966 ctx->options |= E2F_OPT_READONLY; in PRS()
968 ctx->io_options = strchr(argv[optind], '?'); in PRS()
969 if (ctx->io_options) in PRS()
970 *ctx->io_options++ = 0; in PRS()
971 ctx->filesystem_name = blkid_get_devname(ctx->blkid, argv[optind], 0); in PRS()
972 if (!ctx->filesystem_name) { in PRS()
973 com_err(ctx->program_name, 0, _("Unable to resolve '%s'"), in PRS()
975 fatal_error(ctx, 0); in PRS()
978 parse_extended_opts(ctx, extended_opts); in PRS()
982 ctx->options |= E2F_OPT_FIXES_ONLY; in PRS()
983 if ((ctx->options & E2F_OPT_COMPRESS_DIRS) && in PRS()
984 (ctx->options & E2F_OPT_FIXES_ONLY)) { in PRS()
985 com_err(ctx->program_name, 0, "%s", in PRS()
987 fatal_error(ctx, 0); in PRS()
989 if ((ctx->options & E2F_OPT_CONVERT_BMAP) && in PRS()
990 (ctx->options & E2F_OPT_FIXES_ONLY)) { in PRS()
991 com_err(ctx->program_name, 0, "%s", in PRS()
993 fatal_error(ctx, 0); in PRS()
999 profile_init(config_fn, &ctx->profile); in PRS()
1001 profile_get_boolean(ctx->profile, "options", "report_time", 0, 0, in PRS()
1004 ctx->options |= E2F_OPT_TIME | E2F_OPT_TIME2; in PRS()
1005 profile_get_boolean(ctx->profile, "options", "report_verbose", 0, 0, in PRS()
1010 if (ctx->readahead_kb == ~0ULL) { in PRS()
1011 profile_get_integer(ctx->profile, "options", in PRS()
1014 ctx->readahead_kb = phys_mem_kb * c / 100; in PRS()
1015 profile_get_integer(ctx->profile, "options", in PRS()
1018 ctx->readahead_kb = c; in PRS()
1019 if (ctx->readahead_kb != ~0ULL && in PRS()
1020 ctx->readahead_kb > phys_mem_kb) in PRS()
1021 ctx->readahead_kb = phys_mem_kb; in PRS()
1025 if ((ctx->options & E2F_OPT_NO) && in PRS()
1026 (ctx->options & E2F_OPT_DISCARD)) in PRS()
1027 ctx->options &= ~E2F_OPT_DISCARD; in PRS()
1030 fd = open(ctx->filesystem_name, O_RDONLY, 0); in PRS()
1034 ctx->filesystem_name); in PRS()
1035 fatal_error(ctx, 0); in PRS()
1040 ctx->filesystem_name); in PRS()
1041 fatal_error(ctx, 0); in PRS()
1078 fatal_error(ctx, "Couldn't malloc() newpath"); in PRS()
1107 static errcode_t try_open_fs(e2fsck_t ctx, int flags, io_manager io_ptr, in try_open_fs() argument
1113 if (ctx->superblock && ctx->blocksize) { in try_open_fs()
1114 retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options, in try_open_fs()
1115 flags, ctx->superblock, ctx->blocksize, in try_open_fs()
1117 } else if (ctx->superblock) { in try_open_fs()
1125 retval = ext2fs_open2(ctx->filesystem_name, in try_open_fs()
1126 ctx->io_options, flags, in try_open_fs()
1127 ctx->superblock, blocksize, in try_open_fs()
1133 retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options, in try_open_fs()
1137 (*ret_fs)->priv_data = ctx; in try_open_fs()
1147 static errcode_t e2fsck_check_mmp(ext2_filsys fs, e2fsck_t ctx) in e2fsck_check_mmp() argument
1193 log_out(ctx, _("MMP interval is %u seconds and total wait " in e2fsck_check_mmp()
1203 if (fix_problem(ctx, PR_0_MMP_INVALID_BLK, &pctx)) { in e2fsck_check_mmp()
1209 com_err(ctx->program_name, retval, "%s", in e2fsck_check_mmp()
1214 com_err(ctx->program_name, retval, "%s", in e2fsck_check_mmp()
1221 if (fix_problem(ctx, PR_0_MMP_INVALID_MAGIC, &pctx)) { in e2fsck_check_mmp()
1226 if (fix_problem(ctx, PR_0_MMP_CSUM_INVALID, &pctx)) { in e2fsck_check_mmp()
1231 com_err(ctx->program_name, retval, "%s", in e2fsck_check_mmp()
1236 static int e2fsck_setup_tdb(e2fsck_t ctx, io_manager *io_ptr) in e2fsck_setup_tdb() argument
1244 if (ctx->undo_file && ctx->undo_file[0] != 0) { in e2fsck_setup_tdb()
1249 retval = set_undo_io_backup_file(ctx->undo_file); in e2fsck_setup_tdb()
1255 ctx->undo_file, ctx->filesystem_name); in e2fsck_setup_tdb()
1265 profile_get_string(ctx->profile, "defaults", in e2fsck_setup_tdb()
1278 tmp_name = strdup(ctx->filesystem_name); in e2fsck_setup_tdb()
1292 com_err(ctx->program_name, retval, in e2fsck_setup_tdb()
1306 " e2undo %s %s\n\n"), tdb_file, ctx->filesystem_name); in e2fsck_setup_tdb()
1318 com_err(ctx->program_name, retval, "%s", in e2fsck_setup_tdb()
1332 e2fsck_t ctx; in main() local
1367 retval = PRS(argc, argv, &ctx); in main()
1375 set_up_logging(ctx); in main()
1376 if (ctx->logf) { in main()
1378 fputs("E2fsck run: ", ctx->logf); in main()
1381 fputc(' ', ctx->logf); in main()
1382 fputs(argv[i], ctx->logf); in main()
1384 fputc('\n', ctx->logf); in main()
1387 init_resource_track(&ctx->global_rtrack, NULL); in main()
1388 if (!(ctx->options & E2F_OPT_PREEN) || show_version_only) in main()
1389 log_err(ctx, "e2fsck %s (%s)\n", my_ver_string, in main()
1393 log_err(ctx, _("\tUsing %s, %s\n"), in main()
1398 check_mount(ctx); in main()
1400 if (!(ctx->options & E2F_OPT_PREEN) && in main()
1401 !(ctx->options & E2F_OPT_NO) && in main()
1402 !(ctx->options & E2F_OPT_YES)) { in main()
1403 if (!ctx->interactive) in main()
1404 fatal_error(ctx, in main()
1407 ctx->superblock = ctx->use_superblock; in main()
1419 profile_get_boolean(ctx->profile, "options", "old_bitmaps", 0, 0, in main()
1423 if ((ctx->options & E2F_OPT_READONLY) == 0) { in main()
1425 if (!(ctx->mount_flags & EXT2_MF_ISROOT && in main()
1426 ctx->mount_flags & EXT2_MF_READONLY)) in main()
1428 if ((ctx->mount_flags & EXT2_MF_READONLY) && in main()
1429 (ctx->options & E2F_OPT_FORCE)) in main()
1433 if (ctx->undo_file) { in main()
1434 retval = e2fsck_setup_tdb(ctx, &io_ptr); in main()
1439 ctx->openfs_flags = flags; in main()
1440 retval = try_open_fs(ctx, flags, io_ptr, &fs); in main()
1442 if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) && in main()
1443 !(ctx->flags & E2F_FLAG_SB_SPECIFIED) && in main()
1450 fix_problem(ctx, PR_0_OPEN_FAILED, &pctx); in main()
1454 fix_problem(ctx, PR_0_CHECK_DESC_FAILED, &pctx); in main()
1466 log_out(ctx, _("%s: %s trying backup blocks...\n"), in main()
1467 ctx->program_name, in main()
1470 orig_superblock = ctx->superblock; in main()
1471 get_backup_sb(ctx, fs, ctx->filesystem_name, io_ptr); in main()
1475 retval = try_open_fs(ctx, flags, io_ptr, &fs); in main()
1479 log_out(ctx, _("%s: %s while using the " in main()
1481 ctx->program_name, in main()
1483 log_out(ctx, _("%s: going back to original " in main()
1485 ctx->program_name); in main()
1486 ctx->superblock = orig_superblock; in main()
1487 retval = try_open_fs(ctx, flags, io_ptr, &fs); in main()
1508 com_err(ctx->program_name, retval, _("while trying to open %s"), in main()
1509 ctx->filesystem_name); in main()
1511 log_out(ctx, "%s", in main()
1516 fix_problem(ctx, PR_0_SB_CORRUPT, &pctx); in main()
1518 log_out(ctx, "%s", in main()
1521 log_out(ctx, _("You must have %s access to the " in main()
1523 (ctx->options & E2F_OPT_READONLY) ? in main()
1526 log_out(ctx, "%s", in main()
1529 log_out(ctx, "%s", _("Filesystem mounted or opened " in main()
1532 log_out(ctx, "%s", in main()
1536 log_out(ctx, "%s", _("Disk write-protected; use the " in main()
1541 fix_problem(ctx, PR_0_SB_CORRUPT, &pctx); in main()
1543 check_plausibility(ctx->filesystem_name, in main()
1546 fatal_error(ctx, 0); in main()
1561 if (!(ctx->flags & E2F_FLAG_GOT_DEVSIZE)) { in main()
1565 pctx.errcode = ext2fs_get_device_size2(ctx->filesystem_name, in main()
1567 &ctx->num_blocks); in main()
1579 ext2fs_get_device_size2(ctx->filesystem_name, in main()
1581 &ctx->num_blocks); in main()
1584 ctx->num_blocks = 0; in main()
1586 fix_problem(ctx, PR_0_GETSIZE_ERROR, &pctx); in main()
1587 ctx->flags |= E2F_FLAG_ABORT; in main()
1588 fatal_error(ctx, 0); in main()
1590 ctx->flags |= E2F_FLAG_GOT_DEVSIZE; in main()
1595 ctx->fs = fs; in main()
1596 fs->now = ctx->now; in main()
1600 com_err(ctx->program_name, EXT2_ET_REV_TOO_HIGH, in main()
1602 ctx->filesystem_name); in main()
1604 fatal_error(ctx, _("Get a newer version of e2fsck!")); in main()
1611 if (ctx->device_name == 0 && in main()
1613 ctx->device_name = string_copy(ctx, sb->s_volume_name, in main()
1616 if (ctx->device_name == 0) in main()
1617 ctx->device_name = string_copy(ctx, ctx->filesystem_name, 0); in main()
1618 for (cp = ctx->device_name; *cp; cp++) in main()
1626 if (e2fsck_check_mmp(fs, ctx)) in main()
1627 fatal_error(ctx, 0); in main()
1632 ext2fs_close_free(&ctx->fs); in main()
1637 if (ctx->logf) in main()
1638 fprintf(ctx->logf, "Filesystem UUID: %s\n", in main()
1644 if ((ctx->mount_flags & (EXT2_MF_MOUNTED | EXT2_MF_BUSY)) == 0) { in main()
1645 retval = e2fsck_check_ext3_journal(ctx); in main()
1647 com_err(ctx->program_name, retval, in main()
1649 ctx->device_name); in main()
1650 fatal_error(ctx, in main()
1660 if (ctx->options & E2F_OPT_READONLY) { in main()
1661 log_out(ctx, "%s", in main()
1664 io_channel_flush(ctx->fs->io); in main()
1666 if (ctx->flags & E2F_FLAG_RESTARTED) { in main()
1673 com_err(ctx->program_name, 0, in main()
1675 "on %s\n"), ctx->device_name); in main()
1676 fatal_error(ctx, 0); in main()
1678 retval = e2fsck_run_ext3_journal(ctx); in main()
1680 log_out(ctx, _("Journal checksum error " in main()
1682 ctx->device_name); in main()
1684 log_out(ctx, _("Journal corrupted in %s\n"), in main()
1685 ctx->device_name); in main()
1687 com_err(ctx->program_name, retval, in main()
1689 ctx->device_name); in main()
1691 ext2fs_close_free(&ctx->fs); in main()
1692 ctx->flags |= E2F_FLAG_RESTARTED; in main()
1710 log_err(ctx, _("%s has unsupported feature(s):"), in main()
1711 ctx->filesystem_name); in main()
1716 log_err(ctx, " %s", in main()
1720 log_err(ctx, "\n"); in main()
1729 if (ctx->superblock && in main()
1730 !(ctx->options & E2F_OPT_READONLY)) in main()
1743 ctx->blocks_per_page = sys_page_size / fs->blocksize; in main()
1744 if (ctx->blocks_per_page == 0) in main()
1745 ctx->blocks_per_page = 1; in main()
1747 if (ctx->superblock) in main()
1750 check_super_block(ctx); in main()
1751 if (ctx->flags & E2F_FLAG_SIGNAL_MASK) in main()
1752 fatal_error(ctx, 0); in main()
1753 check_if_skip(ctx); in main()
1754 check_resize_inode(ctx); in main()
1756 read_bad_blocks_file(ctx, bad_blocks_file, replace_bad_blocks); in main()
1758 read_bad_blocks_file(ctx, 0, !keep_bad_blocks); /* Test disk */ in main()
1759 if (ctx->flags & E2F_FLAG_SIGNAL_MASK) in main()
1760 fatal_error(ctx, 0); in main()
1769 log_out(ctx, _("%s: %s while reading bad blocks inode\n"), in main()
1770 ctx->program_name, error_message(retval)); in main()
1771 preenhalt(ctx); in main()
1772 log_out(ctx, "%s", _("This doesn't bode well, " in main()
1795 pctx.errcode = quota_init_context(&ctx->qctx, ctx->fs, in main()
1798 fix_problem(ctx, PR_0_QUOTA_INIT_CTX, &pctx); in main()
1799 fatal_error(ctx, 0); in main()
1803 run_result = e2fsck_run(ctx); in main()
1804 e2fsck_clear_progbar(ctx); in main()
1806 if (!ctx->invalid_bitmaps && in main()
1807 (ctx->flags & E2F_FLAG_JOURNAL_INODE)) { in main()
1808 if (fix_problem(ctx, PR_6_RECREATE_JOURNAL, &pctx)) { in main()
1814 log_out(ctx, "%s: Couldn't determine " in main()
1815 "journal size\n", ctx->program_name); in main()
1818 log_out(ctx, _("Creating journal (%d blocks): "), in main()
1824 log_out(ctx, "%s: while trying to create " in main()
1828 log_out(ctx, "%s", _(" Done.\n")); in main()
1829 log_out(ctx, "%s", in main()
1836 fatal_error(ctx, _("aborted")); in main()
1838 log_out(ctx, _("%s: e2fsck canceled.\n"), ctx->device_name ? in main()
1839 ctx->device_name : ctx->filesystem_name); in main()
1841 } else if (ctx->qctx && !ctx->invalid_bitmaps) { in main()
1849 retval = quota_compare_and_update(ctx->qctx, qtype, in main()
1852 fix_problem(ctx, PR_6_UPDATE_QUOTAS, &pctx)) { in main()
1853 pctx.errcode = quota_write_inode(ctx->qctx, in main()
1856 (void) fix_problem(ctx, in main()
1860 quota_release_context(&ctx->qctx); in main()
1864 log_out(ctx, "%s", in main()
1866 retval = e2fsck_reset_context(ctx); in main()
1868 com_err(ctx->program_name, retval, "%s", in main()
1870 fatal_error(ctx, 0); in main()
1872 ext2fs_close_free(&ctx->fs); in main()
1880 if (!(ctx->flags & E2F_FLAG_RUN_RETURN) && in main()
1881 !(ctx->options & E2F_OPT_READONLY)) { in main()
1886 if (check_backup_super_block(ctx)) in main()
1890 if (!(ctx->flags & E2F_FLAG_TIME_INSANE)) in main()
1891 sb->s_lastcheck = ctx->now; in main()
1894 pctx.errcode = ext2fs_set_gdt_csum(ctx->fs); in main()
1896 fix_problem(ctx, PR_6_SET_BG_CHECKSUM, &pctx); in main()
1900 e2fsck_write_bitmaps(ctx); in main()
1902 pctx.errcode = ext2fs_flush(ctx->fs); in main()
1904 fix_problem(ctx, PR_6_FLUSH_FILESYSTEM, &pctx); in main()
1906 pctx.errcode = io_channel_flush(ctx->fs->io); in main()
1908 fix_problem(ctx, PR_6_IO_FLUSH, &pctx); in main()
1911 int fs_fixed = (ctx->flags & E2F_FLAG_PROBLEMS_FIXED); in main()
1915 if (!(ctx->options & E2F_OPT_PREEN)) { in main()
1917 log_out(ctx, fs_fixed ? in main()
1921 ctx->device_name); in main()
1923 log_out(ctx, in main()
1925 ctx->device_name); in main()
1928 if (ctx->mount_flags & EXT2_MF_ISROOT) { in main()
1929 log_out(ctx, _("%s: ***** REBOOT SYSTEM *****\n"), in main()
1930 ctx->device_name); in main()
1937 log_out(ctx, _("\n%s: ********** WARNING: Filesystem still has " in main()
1938 "errors **********\n\n"), ctx->device_name); in main()
1945 profile_get_boolean(ctx->profile, "options", in main()
1954 show_stats(ctx); in main()
1956 print_resource_track(ctx, NULL, &ctx->global_rtrack, ctx->fs->io); in main()
1958 ext2fs_close_free(&ctx->fs); in main()
1959 free(ctx->journal_name); in main()
1961 e2fsck_free_context(ctx); in main()