+ if (will_rehash)
+ ctx->fs->flags = (flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) |
+ (ctx->fs->flags & ~EXT2_FLAG_IGNORE_CSUM_ERRORS);
+ if (retval && !fix)
+ return 0;
+ if (!retval) {
+ /* Lost+found shouldn't have inline data */
+ retval = ext2fs_read_inode_full(fs, ino, EXT2_INODE(&inode),
+ sizeof(inode));
+ if (fix && retval)
+ return 0;
+
+ if (fix && (inode.i_flags & EXT4_INLINE_DATA_FL)) {
+ if (!fix_problem(ctx, PR_3_LPF_INLINE_DATA, &pctx))
+ return 0;
+ goto unlink;
+ }
+
+ if (fix && (inode.i_flags & EXT4_ENCRYPT_FL)) {
+ if (!fix_problem(ctx, PR_3_LPF_ENCRYPTED, &pctx))
+ return 0;
+ goto unlink;
+ }
+
+ if (ext2fs_check_directory(fs, ino) == 0) {
+ ctx->lost_and_found = ino;
+ return ino;
+ }
+
+ /* Lost+found isn't a directory! */
+ if (!fix)
+ return 0;
+ pctx.ino = ino;
+ if (!fix_problem(ctx, PR_3_LPF_NOTDIR, &pctx))
+ return 0;
+
+unlink:
+ /* OK, unlink the old /lost+found file. */
+ pctx.errcode = ext2fs_unlink(fs, EXT2_ROOT_INO, name, ino, 0);
+ if (pctx.errcode) {
+ pctx.str = "ext2fs_unlink";
+ fix_problem(ctx, PR_3_CREATE_LPF_ERROR, &pctx);
+ return 0;
+ }
+ (void) e2fsck_dir_info_set_parent(ctx, ino, 0);
+ e2fsck_adjust_inode_count(ctx, ino, -1);
+ /*
+ * If the old lost+found was a directory, we've just
+ * disconnected it from the directory tree, which
+ * means we need to restart the directory tree scan.
+ * The simplest way to do this is restart the whole
+ * e2fsck operation.
+ */
+ if (LINUX_S_ISDIR(inode.i_mode))
+ ctx->flags |= E2F_FLAG_RESTART;
+ } else if (retval != EXT2_ET_FILE_NOT_FOUND) {