]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: use the correct block size when salvaging directories
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 10 Aug 2014 22:44:42 +0000 (18:44 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 10 Aug 2014 22:44:42 +0000 (18:44 -0400)
Now that the directory salvaging operation is fed the block size,
teach pass 2 that it should use the size of the inline data if the
directory is inline_data.  Without this, it'll "fix" inline
directories by setting the rec_len to something approaching the FS
blocksize, which is clearly wrong.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass2.c

index d56b4c84e59016b39dbd483491f1db2f3bfcb7be..abf95bd58195871d902894e48bae6c023c6dc754 100644 (file)
@@ -979,11 +979,17 @@ skip_checksum:
 
                problem = 0;
                if (!inline_data_size || dot_state > 1) {
+                       size_t max_block_size = fs->blocksize - de_csum_size;
+
+                       if (inline_data_size)
+                               max_block_size = inline_data_size;
                        dirent = (struct ext2_dir_entry *) (buf + offset);
                        (void) ext2fs_get_rec_len(fs, dirent, &rec_len);
                        cd->pctx.dirent = dirent;
                        cd->pctx.num = offset;
                        if (((offset + rec_len) > fs->blocksize) ||
+                           (inline_data_size > 0 &&
+                            (offset + rec_len) > inline_data_size) ||
                            (rec_len < 12) ||
                            ((rec_len % 4) != 0) ||
                            ((ext2fs_dirent_name_len(dirent) + 8) > rec_len)) {
@@ -991,8 +997,7 @@ skip_checksum:
                                                &cd->pctx)) {
                                        salvage_directory(fs, dirent, prev,
                                                          &offset,
-                                                         fs->blocksize -
-                                                         de_csum_size);
+                                                         max_block_size);
                                        dir_modified++;
                                        continue;
                                } else