Whamcloud - gitweb
LU-14345 e2fsck: fix check of directories over 4GB
[tools/e2fsprogs.git] / e2fsck / unix.c
index e4e28e0..ebb1b84 100644 (file)
@@ -82,7 +82,9 @@ static void usage(e2fsck_t ctx)
 
        fprintf(stderr, "%s", _("\nEmergency help:\n"
                " -p                   Automatic repair (no questions)\n"
+#ifdef CONFIG_PFSCK
                " -m                   multiple threads to speedup fsck\n"
+#endif
                " -n                   Make no changes to the filesystem\n"
                " -y                   Assume \"yes\" to all questions\n"
                " -c                   Check for bad blocks and add them to the badblock list\n"
@@ -907,6 +909,10 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
 #ifdef CONFIG_JBD_DEBUG
        char            *jbd_debug;
 #endif
+#ifdef CONFIG_PFSCK
+       char            *pm;
+       unsigned long   thread_num;
+#endif
        unsigned long long phys_mem_kb;
 
        retval = e2fsck_allocate_context(&ctx);
@@ -947,7 +953,11 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
        ctx->readahead_kb = ~0ULL;
        ctx->inode_badness_threshold = BADNESS_THRESHOLD;
 
-       while ((c = getopt(argc, argv, "pamnyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDkz:")) != EOF)
+#ifdef CONFIG_PFSCK
+       while ((c = getopt(argc, argv, "pam:nyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDkz:")) != EOF)
+#else
+       while ((c = getopt(argc, argv, "panyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDkz:")) != EOF)
+#endif
                switch (c) {
                case 'C':
                        ctx->progress = e2fsck_update_progress;
@@ -988,9 +998,22 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
                        }
                        ctx->options |= E2F_OPT_PREEN;
                        break;
+#ifdef CONFIG_PFSCK
                case 'm':
+                       thread_num = strtoul(optarg, &pm, 0);
+                       if (*pm)
+                               fatal_error(ctx,
+                                       _("Invalid multiple thread num.\n"));
+                       if (thread_num > E2FSCK_MAX_THREADS) {
+                               fprintf(stderr,
+                                       _("threads %lu too large (max %u)\n"),
+                                       thread_num, E2FSCK_MAX_THREADS);
+                               fatal_error(ctx, 0);
+                       }
                        ctx->options |= E2F_OPT_MULTITHREAD;
+                       ctx->pfs_num_threads = thread_num;
                        break;
+#endif
                case 'n':
                        if (ctx->options & (E2F_OPT_YES|E2F_OPT_PREEN))
                                goto conflict_opt;
@@ -1109,6 +1132,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
                        _("The -n and -l/-L options are incompatible."));
                fatal_error(ctx, 0);
        }
+#ifdef CONFIG_PFSCK
        if (ctx->options & E2F_OPT_MULTITHREAD) {
                if ((ctx->options & (E2F_OPT_YES|E2F_OPT_NO|E2F_OPT_PREEN)) == 0) {
                        com_err(ctx->program_name, 0, "%s",
@@ -1121,6 +1145,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
                        fatal_error(ctx, 0);
                }
        }
+#endif
        if (ctx->options & E2F_OPT_NO)
                ctx->options |= E2F_OPT_READONLY;
 
@@ -1616,6 +1641,7 @@ restart:
        }
 
        ctx->openfs_flags = flags;
+       ctx->io_manager = io_ptr;
        retval = try_open_fs(ctx, flags, io_ptr, &fs);
 
        if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) &&