public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Revert "fat: add simple validation for directory inode"
@ 2022-02-04  6:22 Gwendal Grignou
  2022-02-05  6:21 ` OGAWA Hirofumi
  0 siblings, 1 reply; 2+ messages in thread
From: Gwendal Grignou @ 2022-02-04  6:22 UTC (permalink / raw)
  To: hirofumi; +Cc: dlunev, linux-kernel, Gwendal Grignou

This reverts commit a3082d526f2d406d4b488e49a508a0062a23314f.

The reverted commit adds check for FAT images. However, the tools used
for creating images for the Lego Mindstrom EV3 are not adding '.' and
'..' entry in the 'Projects' directory.
Without this fix, the kernel can not fill the inode structure for
'Projects' directory.

See https://github.com/microsoft/pxt-ev3/issues/980
And https://github.com/microsoft/uf2-linux/issues/6

With the patch reverted, we can mount an image copied from the EV3

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
 fs/fat/inode.c | 22 ----------------------
 1 file changed, 22 deletions(-)

diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index a6f1c6d426d1..45c8dcc10547 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -494,24 +494,6 @@ static int fat_calc_dir_size(struct inode *inode)
 	return 0;
 }
 
-static int fat_validate_dir(struct inode *dir)
-{
-	struct super_block *sb = dir->i_sb;
-
-	if (dir->i_nlink < 2) {
-		/* Directory should have "."/".." entries at least. */
-		fat_fs_error(sb, "corrupted directory (invalid entries)");
-		return -EIO;
-	}
-	if (MSDOS_I(dir)->i_start == 0 ||
-	    MSDOS_I(dir)->i_start == MSDOS_SB(sb)->root_cluster) {
-		/* Directory should point valid cluster. */
-		fat_fs_error(sb, "corrupted directory (invalid i_start)");
-		return -EIO;
-	}
-	return 0;
-}
-
 /* doesn't deal with root inode */
 int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
 {
@@ -538,10 +520,6 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
 		MSDOS_I(inode)->mmu_private = inode->i_size;
 
 		set_nlink(inode, fat_subdirs(inode));
-
-		error = fat_validate_dir(inode);
-		if (error < 0)
-			return error;
 	} else { /* not a directory */
 		inode->i_generation |= 1;
 		inode->i_mode = fat_make_mode(sbi, de->attr,
-- 
2.35.0.263.gb82422642f-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Revert "fat: add simple validation for directory inode"
  2022-02-04  6:22 [PATCH] Revert "fat: add simple validation for directory inode" Gwendal Grignou
@ 2022-02-05  6:21 ` OGAWA Hirofumi
  0 siblings, 0 replies; 2+ messages in thread
From: OGAWA Hirofumi @ 2022-02-05  6:21 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: dlunev, linux-kernel

Gwendal Grignou <gwendal@chromium.org> writes:

> This reverts commit a3082d526f2d406d4b488e49a508a0062a23314f.
>
> The reverted commit adds check for FAT images. However, the tools used
> for creating images for the Lego Mindstrom EV3 are not adding '.' and
> '..' entry in the 'Projects' directory.
> Without this fix, the kernel can not fill the inode structure for
> 'Projects' directory.
>
> See https://github.com/microsoft/pxt-ev3/issues/980
> And https://github.com/microsoft/uf2-linux/issues/6

Looks like the bug of those tools. If you want to add the workaround for
those tools, it should not break sane format.

I.e. the workaround should at least set the directory link count to work
rmdir(2) without warnings, then should test other operations if works
well.

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-05  6:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-04  6:22 [PATCH] Revert "fat: add simple validation for directory inode" Gwendal Grignou
2022-02-05  6:21 ` OGAWA Hirofumi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox