e2fsck: use root dir for lost+found when really desperate

If we're totally unable to allocate a lost+found directory, ask the
user if he would like to dump orphaned files in the root directory.
Hopefully this enables the user to delete enough files so that a
subsequent run of e2fsck will make more progress.  Better to cram lost
files in the rootdir than the current behavior, which is to fail at
linking them in, thereby leaving them as lost files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
crypto
Darrick J. Wong 2014-08-02 22:18:30 -04:00 committed by Theodore Ts'o
parent 409f3884b5
commit 0991896720
7 changed files with 74 additions and 0 deletions

View File

@ -450,6 +450,12 @@ unlink:
goto skip_new_block;
}
retval = ext2fs_new_block2(fs, 0, ctx->block_found_map, &blk);
if (retval == EXT2_ET_BLOCK_ALLOC_FAIL &&
fix_problem(ctx, PR_3_LPF_NO_SPACE, &pctx)) {
printf("Delete some files and re-run e2fsck.\n\n");
ctx->lost_and_found = EXT2_ROOT_INO;
return 0;
}
if (retval) {
pctx.errcode = retval;
fix_problem(ctx, PR_3_ERR_LPF_NEW_BLOCK, &pctx);
@ -464,6 +470,12 @@ skip_new_block:
*/
retval = ext2fs_new_inode(fs, EXT2_ROOT_INO, 040700,
ctx->inode_used_map, &ino);
if (retval == EXT2_ET_INODE_ALLOC_FAIL &&
fix_problem(ctx, PR_3_LPF_NO_SPACE, &pctx)) {
printf("Delete some files and re-run e2fsck.\n\n");
ctx->lost_and_found = EXT2_ROOT_INO;
return 0;
}
if (retval) {
pctx.errcode = retval;
fix_problem(ctx, PR_3_ERR_LPF_NEW_INODE, &pctx);

View File

@ -1630,6 +1630,11 @@ static struct e2fsck_problem problem_table[] = {
N_("/@l has inline data\n"),
PROMPT_CLEAR, 0 },
/* Cannot allocate /lost+found. */
{ PR_3_LPF_NO_SPACE,
N_("Cannot allocate space for /@l.\nPlace lost files in root directory instead"),
PROMPT_NULL, 0 },
/* Pass 3A Directory Optimization */
/* Pass 3A: Optimizing directories */

View File

@ -973,6 +973,9 @@ struct problem_context {
/* Lost+found has inline data */
#define PR_3_LPF_INLINE_DATA 0x030018
/* Cannot allocate lost+found */
#define PR_3_LPF_NO_SPACE 0x030019
/*
* Pass 3a --- rehashing diretories
*/

View File

@ -0,0 +1,28 @@
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found. Create? yes
Cannot allocate space for /lost+found.
Place lost files in root directory instead? yes
Delete some files and re-run e2fsck.
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Unattached inode 125
Connect to /lost+found? yes
Inode 125 ref count is 2, should be 1. Fix? yes
Pass 5: Checking group summary information
Free blocks count wrong for group #0 (496, counted=495).
Fix? yes
Free blocks count wrong (496, counted=495).
Fix? yes
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
test_filesys: 128/128 files (0.0% non-contiguous), 17/512 blocks
Exit status is 1

View File

@ -0,0 +1,25 @@
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found. Create? yes
Cannot allocate space for /lost+found.
Place lost files in root directory instead? yes
Delete some files and re-run e2fsck.
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: -9
Fix? yes
Free blocks count wrong for group #0 (494, counted=495).
Fix? yes
Free blocks count wrong (494, counted=495).
Fix? yes
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
test_filesys: 128/128 files (0.0% non-contiguous), 17/512 blocks
Exit status is 1

Binary file not shown.

View File

@ -0,0 +1 @@
no space to create lost+found