Whamcloud - gitweb
e2fsck: notice when the realloc of dir_info fails
authorTheodore Ts'o <tytso@mit.edu>
Thu, 11 Sep 2014 16:24:07 +0000 (12:24 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 11 Sep 2014 16:24:07 +0000 (12:24 -0400)
If the reallocation of dir_info fails, we will eventually cause e2fsck
to fail with an internal error.  So if the realloc fails, print a
message and bail out with a fatal error early when at the time of the
reallocation failure.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/dirinfo.c
e2fsck/dx_dirinfo.c

index dbaf471..4a9019b 100644 (file)
@@ -140,6 +140,10 @@ void e2fsck_add_dir_info(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent)
                                           sizeof(struct dir_info),
                                           &ctx->dir_info->array);
                if (retval) {
+                       fprintf(stderr, "Couldn't reallocate dir_info "
+                               "structure to %d entries\n",
+                               ctx->dir_info->size);
+                       fatal_error(ctx, 0);
                        ctx->dir_info->size -= 10;
                        return;
                }
index 7838a40..be53fff 100644 (file)
@@ -40,6 +40,10 @@ void e2fsck_add_dx_dir(e2fsck_t ctx, ext2_ino_t ino, int num_blocks)
                                           sizeof(struct dx_dir_info),
                                           &ctx->dx_dir_info);
                if (retval) {
+                       fprintf(stderr, "Couldn't reallocate dx_dir_info "
+                               "structure to %d entries\n",
+                               ctx->dx_dir_info_size);
+                       fatal_error(ctx, 0);
                        ctx->dx_dir_info_size -= 10;
                        return;
                }