Whamcloud - gitweb
e2fsck: expand root dir if linking l+f fails
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 11 Sep 2014 19:48:04 +0000 (12:48 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 11 Sep 2014 22:09:14 +0000 (18:09 -0400)
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>
e2fsck/pass3.c
tests/f_expandroot_create_lnf/expect.1 [new file with mode: 0644]
tests/f_expandroot_create_lnf/expect.2 [new file with mode: 0644]
tests/f_expandroot_create_lnf/image.gz [new file with mode: 0644]
tests/f_expandroot_create_lnf/name [new file with mode: 0644]

index 9860cdf..f03c7ae 100644 (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;
diff --git a/tests/f_expandroot_create_lnf/expect.1 b/tests/f_expandroot_create_lnf/expect.1
new file mode 100644 (file)
index 0000000..9593dbf
--- /dev/null
@@ -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 (file)
index 0000000..5eec1f0
--- /dev/null
@@ -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 (file)
index 0000000..ccdbfa7
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 (file)
index 0000000..f22542b
--- /dev/null
@@ -0,0 +1 @@
+no space in root to create lost+found entry