diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c index 9860cdf2..f03c7aec 100644 --- a/e2fsck/pass3.c +++ b/e2fsck/pass3.c @@ -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; diff --git a/tests/f_expandroot_create_lnf/expect.1 b/tests/f_expandroot_create_lnf/expect.1 new file mode 100644 index 00000000..9593dbf6 --- /dev/null +++ b/tests/f_expandroot_create_lnf/expect.1 @@ -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 diff --git a/tests/f_expandroot_create_lnf/expect.2 b/tests/f_expandroot_create_lnf/expect.2 new file mode 100644 index 00000000..5eec1f0b --- /dev/null +++ b/tests/f_expandroot_create_lnf/expect.2 @@ -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 diff --git a/tests/f_expandroot_create_lnf/image.gz b/tests/f_expandroot_create_lnf/image.gz new file mode 100644 index 00000000..ccdbfa7a Binary files /dev/null and b/tests/f_expandroot_create_lnf/image.gz differ diff --git a/tests/f_expandroot_create_lnf/name b/tests/f_expandroot_create_lnf/name new file mode 100644 index 00000000..f22542bc --- /dev/null +++ b/tests/f_expandroot_create_lnf/name @@ -0,0 +1 @@ +no space in root to create lost+found entry