mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [RFC] common: filetype: is_fat_or_mbr() considered harmful
@ 2015-10-07 18:03 Peter Mamonov
  2015-10-09  8:06 ` Sascha Hauer
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Mamonov @ 2015-10-07 18:03 UTC (permalink / raw)
  To: barebox; +Cc: Peter Mamonov

Deleted pieces of code detect MBR-containig device as a FAT-type device,
if it's first partition contains a FAT filesystem. So, one can mount the first
partition of a hard drive containing FAT FS using the following command:
	barebox: mount /dev/ata0.0 /mnt/0
as well as this one:
	barebox: mount /dev/ata0 /mnt/1
Both commands mount the same FS.

This behaviour causes automount (mount -a) to mount FAT FS
on a first partition twice:
	barebox: mount
	none on / type ramfs
	none on /dev type devfs
	/dev/ata0 on /mnt/ata0 type fat
	/dev/ata0.0 on /mnt/ata0.0 type fat
	/dev/ata0.1 on /mnt/ata0.1 type ext4
---
 common/filetype.c | 30 ------------------------------
 1 file changed, 30 deletions(-)

diff --git a/common/filetype.c b/common/filetype.c
index cc3099b..49a0c8d 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -345,21 +345,6 @@ enum filetype file_name_detect_type(const char *filename)
 
 	type = file_detect_type(buf, ret);
 
-	if (type == filetype_mbr) {
-		/*
-		 * Get the first partition start sector
-		 * and check for FAT in it
-		 */
-		is_fat_or_mbr(buf, &bootsec);
-		ret = lseek(fd, (bootsec) * 512, SEEK_SET);
-		if (ret < 0)
-			goto err_out;
-		ret = read(fd, buf, 512);
-		if (ret < 0)
-			goto err_out;
-		type = is_fat_or_mbr((u8 *)buf, NULL);
-	}
-
 err_out:
 	close(fd);
 	free(buf);
@@ -384,21 +369,6 @@ enum filetype cdev_detect_type(const char *name)
 
 	type = file_detect_type(buf, ret);
 
-	if (type == filetype_mbr) {
-		unsigned long bootsec;
-		/*
-		 * Get the first partition start sector
-		 * and check for FAT in it
-		 */
-		is_fat_or_mbr(buf, &bootsec);
-
-		ret = cdev_read(cdev, buf, 512, bootsec * 512, 0);
-		if (ret < 0)
-			goto err_out;
-
-		type = is_fat_or_mbr((u8 *)buf, NULL);
-	}
-
 err_out:
 	free(buf);
 	return type;
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2015-10-13  8:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-07 18:03 [RFC] common: filetype: is_fat_or_mbr() considered harmful Peter Mamonov
2015-10-09  8:06 ` Sascha Hauer
2015-10-09 12:40   ` Peter Mamonov
2015-10-09 16:11     ` Sascha Hauer
2015-10-12 10:27       ` Peter Mamonov
2015-10-12 13:51         ` Sascha Hauer
2015-10-12 14:21           ` Antony Pavlov
2015-10-12 14:37             ` Franck Jullien
2015-10-13  8:32               ` Sascha Hauer

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