e2fsck: expand root dir if linking l+f fails

If there isn't space in the root directory to add the lost+found
entry, try expanding the root directory before failing the fsck.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
crypto
Darrick J. Wong 2014-09-11 12:48:04 -07:00 committed by Theodore Ts'o
parent c6c681632e
commit f0770b16ef
5 changed files with 28 additions and 0 deletions

View File

@ -530,7 +530,15 @@ skip_new_block:
* Finally, create the directory link
*/
pctx.errcode = ext2fs_link(fs, EXT2_ROOT_INO, name, ino, EXT2_FT_DIR);
if (pctx.errcode == EXT2_ET_DIR_NO_SPACE) {
pctx.errcode = ext2fs_expand_dir(fs, EXT2_ROOT_INO);
if (pctx.errcode)
goto link_error;
pctx.errcode = ext2fs_link(fs, EXT2_ROOT_INO, name, ino,
EXT2_FT_DIR);
}
if (pctx.errcode) {
link_error:
pctx.str = "ext2fs_link";
fix_problem(ctx, PR_3_CREATE_LPF_ERROR, &pctx);
return 0;

View File

@ -0,0 +1,12 @@
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found. Create? yes
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
test_filesys: 16/64 files (0.0% non-contiguous), 33/1024 blocks
Exit status is 1

View File

@ -0,0 +1,7 @@
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
test_filesys: 16/64 files (6.3% non-contiguous), 33/1024 blocks
Exit status is 0

Binary file not shown.

View File

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