Skip to contentSkip to conversation

common: filetype: is_fat_or_mbr() considered harmful

RFC In review Peter Mamonov 4 participants 9 messages Oct 7, 2015 – Oct 13, 2015

lore
Share & tools
lore
#0 lore raw

RFC 1/1 common: filetype: is_fat_or_mbr() considered harmful

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(-)
common/filetype.c +0 -30
index cc3099b..49a0c8d 100644
@@ -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;
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

Hi Peter,

Quoted 8 lines · 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.

Quoted 8 lines

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

This is_fat_or_mbr mechanism never worked very well and had funny side effects. Would be nice to get rid of it.
Simply removing this option is not a solution though, we have to find a proper way to keep the current feature and make it more sane.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw
Quoted 20 lines · On Fri, 9 Oct 2015 10:06:24 +0200 Sascha Hauer <[email protected]> wrote:

Hi Peter,

Quoted 8 lines · 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.

Quoted 8 lines

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

Quoted 4 lines

This is_fat_or_mbr mechanism never worked very well and had funny side effects. Would be nice to get rid of it.
Simply removing this option is not a solution though, we have to find a proper way to keep the current feature and make it more sane.

Ok, the patch comment is misleading a bit. I do not propose to get rid of the is_fat_or_mbr() completely. However, I do not see the point to check for a FAT FS, after the device was correctly detected as an MBR-type device:

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);
       }

The deleted code snippet was introduced by this patch:

commit 010ee209b75c5732ae4144e3ee9ce14158193c1f

Author: Franck Jullien <[email protected]>
Date:   Wed Sep 19 13:09:01 2012 +0200

filetype: Improve FAT detection

We may have some disk with MBR as a first sector. In this case, the current FAT check returns an error. However, the FAT sector exist and the MBR can tell us where it is.

This patch add to file_name_detect_type function the ability to find the FAT boot sector on the first sector of the first partition in case it is not on sector 0.

It also introduce is_fat_or_mbr to check if a buffer is a FAT boot or MBR sector

According to the patch message it was introduced to workaround FAT detection. However, after deletion of the code I'm still able to detect and mount FAT-containig partiotions.

Peter

Quoted 3 lines

Sascha

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw
Quoted 72 lines · Peter Mamonov
Quoted 20 lines · On Fri, 9 Oct 2015 10:06:24 +0200 Sascha Hauer <[email protected]> wrote:

Hi Peter,

Quoted 8 lines · 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.

Quoted 8 lines

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

Quoted 4 lines

This is_fat_or_mbr mechanism never worked very well and had funny side effects. Would be nice to get rid of it.
Simply removing this option is not a solution though, we have to find a proper way to keep the current feature and make it more sane.

Ok, the patch comment is misleading a bit. I do not propose to get rid of the is_fat_or_mbr() completely. However, I do not see the point to check for a FAT FS, after the device was correctly detected as an MBR-type device:

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);
       }

The deleted code snippet was introduced by this patch:

commit 010ee209b75c5732ae4144e3ee9ce14158193c1f

Author: Franck Jullien <[email protected]>
Date:   Wed Sep 19 13:09:01 2012 +0200

filetype: Improve FAT detection

We may have some disk with MBR as a first sector. In this case, the current FAT check returns an error. However, the FAT sector exist and the MBR can tell us where it is.

This patch add to file_name_detect_type function the ability to find the FAT boot sector on the first sector of the first partition in case it is not on sector 0.

It also introduce is_fat_or_mbr to check if a buffer is a FAT boot or MBR sector

Quoted 6 lines

According to the patch message it was introduced to workaround FAT detection. However, after deletion of the code I'm still able to detect and mount FAT-containig partiotions.

But can you mount /dev/disk0 if this disk contains a partition table and the FAT is on /dev/disk0.0? This is what the patch is about. The problem the patches solved is that when you plug in a USB drive then you don't know whether a FAT is directly on the device or if the device is partitioned. You want to be able to mount both ways with the same command, so no matter if the FAT is on /dev/disk0 or /dev/disk0.0 you can mount both using /dev/disk0.
The way this problem is solved currently is not very good, we should find a better way.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw
Quoted 77 lines · On Fri, 9 Oct 2015 18:11:44 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 76 lines · Peter Mamonov
Quoted 20 lines · On Fri, 9 Oct 2015 10:06:24 +0200 Sascha Hauer <[email protected]> wrote:

Hi Peter,

Quoted 8 lines · 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.

Quoted 8 lines

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

Quoted 5 lines

This is_fat_or_mbr mechanism never worked very well and had funny side effects. Would be nice to get rid of it.
Simply removing this option is not a solution though, we have to find a proper way to keep the current feature and make it more sane.

Ok, the patch comment is misleading a bit. I do not propose to get rid of the is_fat_or_mbr() completely. However, I do not see the point to check for a FAT FS, after the device was correctly detected as an MBR-type device:

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);
       }

The deleted code snippet was introduced by this patch:

commit 010ee209b75c5732ae4144e3ee9ce14158193c1f

Author: Franck Jullien <[email protected]>
Date:   Wed Sep 19 13:09:01 2012 +0200

filetype: Improve FAT detection

We may have some disk with MBR as a first sector. In this case,
the current FAT check returns an error. However, the FAT sector exist and the MBR can tell us where it is.

This patch add to file_name_detect_type function the ability to
find the FAT boot sector on the first sector of the first partition in case it is not on sector 0.

It also introduce is_fat_or_mbr to check if a buffer is a FAT
boot or MBR sector

Quoted 6 lines
Quoted 3 lines

According to the patch message it was introduced to workaround FAT detection. However, after deletion of the code I'm still able to detect and mount FAT-containig partiotions.

But can you mount /dev/disk0 if this disk contains a partition table and the FAT is on /dev/disk0.0?

No. This is actually the purpose of my patch, since I don't want "mount -a" to mount the same partition (FAT on /dev/disk0.0) twice.

Quoted 6 lines

This is what the patch is about. The
problem the patches solved is that when you plug in a USB drive then you don't know whether a FAT is directly on the device or if the device is partitioned. You want to be able to mount both ways with the same command, so no matter if the FAT is on /dev/disk0 or /dev/disk0.0 you can mount both using /dev/disk0.

Ok. So what is the preferred way to prevent "mount -a" from mounting /dev/disk0 and /dev/disk0.0 at the same time?

Quoted 5 lines

The way this problem is solved currently is not very good, we should find a better way.

Sascha

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#5 lore raw
Quoted 84 lines · Peter Mamonov
Quoted 81 lines · On Fri, 9 Oct 2015 18:11:44 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 79 lines · Peter Mamonov
Quoted 20 lines · On Fri, 9 Oct 2015 10:06:24 +0200 Sascha Hauer <[email protected]> wrote:

Hi Peter,

Quoted 8 lines · 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.

Quoted 8 lines

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

Quoted 5 lines

This is_fat_or_mbr mechanism never worked very well and had funny side effects. Would be nice to get rid of it.
Simply removing this option is not a solution though, we have to find a proper way to keep the current feature and make it more sane.

Ok, the patch comment is misleading a bit. I do not propose to get rid of the is_fat_or_mbr() completely. However, I do not see the point to check for a FAT FS, after the device was correctly detected as an MBR-type device:

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);
       }

The deleted code snippet was introduced by this patch:

commit 010ee209b75c5732ae4144e3ee9ce14158193c1f

Author: Franck Jullien <[email protected]>
Date:   Wed Sep 19 13:09:01 2012 +0200

filetype: Improve FAT detection

We may have some disk with MBR as a first sector. In this case,
the current FAT check returns an error. However, the FAT sector exist and the MBR can tell us where it is.

This patch add to file_name_detect_type function the ability to
find the FAT boot sector on the first sector of the first partition in case it is not on sector 0.

It also introduce is_fat_or_mbr to check if a buffer is a FAT
boot or MBR sector

According to the patch message it was introduced to workaround FAT detection. However, after deletion of the code I'm still able to detect and mount FAT-containig partiotions.

Quoted 5 lines
Quoted 2 lines

But can you mount /dev/disk0 if this disk contains a partition table and the FAT is on /dev/disk0.0?

No. This is actually the purpose of my patch, since I don't want "mount -a" to mount the same partition (FAT on /dev/disk0.0) twice.

I know, and this is valid. It just conflicts with what Franck wants. He just wants to mount a USB device without having to know if the FAT is on the raw device or on the first partition.

Quoted 10 lines
Quoted 7 lines

This is what the patch is about. The
problem the patches solved is that when you plug in a USB drive then you don't know whether a FAT is directly on the device or if the device is partitioned. You want to be able to mount both ways with the same command, so no matter if the FAT is on /dev/disk0 or /dev/disk0.0 you can mount both using /dev/disk0.

Ok. So what is the preferred way to prevent "mount -a" from mounting /dev/disk0 and /dev/disk0.0 at the same time?

Sorry, I do not have a solution currently. I'll have a look into it.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw
Quoted 103 lines · On Mon, 12 Oct 2015 15:51:05 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 84 lines · Peter Mamonov
Quoted 81 lines · On Fri, 9 Oct 2015 18:11:44 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 79 lines · Peter Mamonov
Quoted 20 lines · On Fri, 9 Oct 2015 10:06:24 +0200 Sascha Hauer <[email protected]> wrote:

Hi Peter,

Quoted 8 lines · 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.

Quoted 8 lines

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

Quoted 5 lines

This is_fat_or_mbr mechanism never worked very well and had funny side effects. Would be nice to get rid of it.
Simply removing this option is not a solution though, we have to find a proper way to keep the current feature and make it more sane.

Ok, the patch comment is misleading a bit. I do not propose to get rid of the is_fat_or_mbr() completely. However, I do not see the point to check for a FAT FS, after the device was correctly detected as an MBR-type device:

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);
       }

The deleted code snippet was introduced by this patch:

commit 010ee209b75c5732ae4144e3ee9ce14158193c1f

Author: Franck Jullien <[email protected]>
Date:   Wed Sep 19 13:09:01 2012 +0200

filetype: Improve FAT detection

We may have some disk with MBR as a first sector. In this case,
the current FAT check returns an error. However, the FAT sector exist and the MBR can tell us where it is.

This patch add to file_name_detect_type function the ability to
find the FAT boot sector on the first sector of the first partition in case it is not on sector 0.

It also introduce is_fat_or_mbr to check if a buffer is a FAT
boot or MBR sector

According to the patch message it was introduced to workaround FAT detection. However, after deletion of the code I'm still able to detect and mount FAT-containig partiotions.

Quoted 5 lines
Quoted 2 lines

But can you mount /dev/disk0 if this disk contains a partition table and the FAT is on /dev/disk0.0?

No. This is actually the purpose of my patch, since I don't want "mount -a" to mount the same partition (FAT on /dev/disk0.0) twice.

I know, and this is valid. It just conflicts with what Franck wants. He just wants to mount a USB device without having to know if the FAT is on the raw device or on the first partition.

Quoted 8 lines
Quoted 7 lines

This is what the patch is about. The
problem the patches solved is that when you plug in a USB drive then you don't know whether a FAT is directly on the device or if the device is partitioned. You want to be able to mount both ways with the same command, so no matter if the FAT is on /dev/disk0 or /dev/disk0.0 you can mount both using /dev/disk0.

Quoted 4 lines
Quoted 2 lines

Ok. So what is the preferred way to prevent "mount -a" from mounting /dev/disk0 and /dev/disk0.0 at the same time?

Sorry, I do not have a solution currently. I'll have a look into it.

Can we just add a .config option for disabling "Frank mode"?

--
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#7 lore raw

2015-10-12 16:21 GMT+02:00 Antony Pavlov <[email protected]>:

Quoted 113 lines
Quoted 103 lines · On Mon, 12 Oct 2015 15:51:05 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 84 lines · Peter Mamonov
Quoted 81 lines · On Fri, 9 Oct 2015 18:11:44 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 79 lines · Peter Mamonov
Quoted 20 lines · On Fri, 9 Oct 2015 10:06:24 +0200 Sascha Hauer <[email protected]> wrote:

Hi Peter,

Quoted 8 lines · 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.

Quoted 8 lines

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

Quoted 5 lines

This is_fat_or_mbr mechanism never worked very well and had funny side effects. Would be nice to get rid of it.
Simply removing this option is not a solution though, we have to find a proper way to keep the current feature and make it more sane.

Ok, the patch comment is misleading a bit. I do not propose to get rid of the is_fat_or_mbr() completely. However, I do not see the point to check for a FAT FS, after the device was correctly detected as an MBR-type device:

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);
       }

The deleted code snippet was introduced by this patch:

commit 010ee209b75c5732ae4144e3ee9ce14158193c1f

Author: Franck Jullien <[email protected]>
Date:   Wed Sep 19 13:09:01 2012 +0200

filetype: Improve FAT detection

We may have some disk with MBR as a first sector. In this case,
the current FAT check returns an error. However, the FAT sector exist and the MBR can tell us where it is.

This patch add to file_name_detect_type function the ability to
find the FAT boot sector on the first sector of the first partition in case it is not on sector 0.

It also introduce is_fat_or_mbr to check if a buffer is a FAT
boot or MBR sector

According to the patch message it was introduced to workaround FAT detection. However, after deletion of the code I'm still able to detect and mount FAT-containig partiotions.

Quoted 5 lines
Quoted 2 lines

But can you mount /dev/disk0 if this disk contains a partition table and the FAT is on /dev/disk0.0?

No. This is actually the purpose of my patch, since I don't want "mount -a" to mount the same partition (FAT on /dev/disk0.0) twice.

I know, and this is valid. It just conflicts with what Franck wants. He just wants to mount a USB device without having to know if the FAT is on the raw device or on the first partition.

Quoted 8 lines
Quoted 7 lines

This is what the patch is about. The
problem the patches solved is that when you plug in a USB drive then you don't know whether a FAT is directly on the device or if the device is partitioned. You want to be able to mount both ways with the same command, so no matter if the FAT is on /dev/disk0 or /dev/disk0.0 you can mount both using /dev/disk0.

Quoted 4 lines
Quoted 2 lines

Ok. So what is the preferred way to prevent "mount -a" from mounting /dev/disk0 and /dev/disk0.0 at the same time?

Sorry, I do not have a solution currently. I'll have a look into it.

Can we just add a .config option for disabling "Frank mode"?

Quoted 8 lines

--
Best regards,
Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

This is not important for me.
I faced this situation when I was playing with SD cards controllers.

However, if I had a problem it may arise for someone else.

Feel free to remove this detection or, as Antony suggested, add a config option.

Franck.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#8 lore raw
Quoted 38 lines · Franck Jullien
Quoted 29 lines
Quoted 22 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

According to the patch message it was introduced to workaround FAT detection. However, after deletion of the code I'm still able to detect and mount FAT-containig partiotions.

But can you mount /dev/disk0 if this disk contains a partition table and the FAT is on /dev/disk0.0?

No. This is actually the purpose of my patch, since I don't want "mount -a" to mount the same partition (FAT on /dev/disk0.0) twice.

I know, and this is valid. It just conflicts with what Franck wants. He just wants to mount a USB device without having to know if the FAT is on the raw device or on the first partition.

Quoted 8 lines
Quoted 7 lines

This is what the patch is about. The
problem the patches solved is that when you plug in a USB drive then you don't know whether a FAT is directly on the device or if the device is partitioned. You want to be able to mount both ways with the same command, so no matter if the FAT is on /dev/disk0 or /dev/disk0.0 you can mount both using /dev/disk0.

Quoted 4 lines
Quoted 2 lines

Ok. So what is the preferred way to prevent "mount -a" from mounting /dev/disk0 and /dev/disk0.0 at the same time?

Sorry, I do not have a solution currently. I'll have a look into it.

Can we just add a .config option for disabling "Frank mode"?

Quoted 8 lines

--
Best regards,
Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Quoted 6 lines

This is not important for me.
I faced this situation when I was playing with SD cards controllers.

However, if I had a problem it may arise for someone else.

Feel free to remove this detection or, as Antony suggested, add a config option.

The desired behaviour can be reached with a:

mount /dev/disk0 /fat || mount /dev/disk0.0 /fat || echo "Mounting failed"

So I tend to say that we should remove the is_fat_or_mbr detection and everything around it.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox