aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2014-09-11 12:48:04 -0700
committerTheodore Ts'o <tytso@mit.edu>2014-09-11 18:09:14 -0400
commitf0770b16ef4c3052996b8b72ce1587d2332efb89 (patch)
treed25030314418f68a759af08be53a1020937a7312
parentc6c681632e45df376360303a00539b2a86ed7400 (diff)
downloade2fsprogs-f0770b16ef4c3052996b8b72ce1587d2332efb89.tar.gz
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>
-rw-r--r--e2fsck/pass3.c8
-rw-r--r--tests/f_expandroot_create_lnf/expect.112
-rw-r--r--tests/f_expandroot_create_lnf/expect.27
-rw-r--r--tests/f_expandroot_create_lnf/image.gzbin0 -> 1622 bytes
-rw-r--r--tests/f_expandroot_create_lnf/name1
5 files changed, 28 insertions, 0 deletions
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
--- /dev/null
+++ b/tests/f_expandroot_create_lnf/image.gz
Binary files 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