OSDN Git Service

[PATCH] fix /proc/partitions display with USB-FDD geometry
authorWilly TARREAU <willy@pcw.(none)>
Thu, 20 Apr 2006 09:08:08 +0000 (11:08 +0200)
committerWilly TARREAU <willy@pcw.(none)>
Thu, 20 Apr 2006 09:08:08 +0000 (11:08 +0200)
commit068cd1d7986d8de608fdbefc39f2ab8e2f08aaa4
tree6ab3a0a406e76a21292ed643e33e9893d3c02794
parent3c1e09e173e5fec7535a3795c4bc7870c8026ff3
[PATCH] fix /proc/partitions display with USB-FDD geometry

When an USB flash disk is formatted under as a floppy (without partitions),
random partitions appear in /proc/partitions depending on the code and data
used by the boot loader at the offset where the partition table is expected :

   8     0     128000 sda
   8     1  985184692 sda1
   8     2  271759162 sda2
   8     3 1093808825 sda3
   8     4      26721 sda4

Such layout appears when Windows is used to format the USB stick, or when
putting a boot-loader such as syslinux on an device.

A patch was introduced in 2.6 to fix this by ensuring that all 4 partitions
boot flags are either 0x00 or 0x80 before interpreting the boot sector as an
MBR.

This fix has been back-ported to 2.4 by Gilles Espinasse. The behaviour has
been carefully tested, and 2.4.32 with this patch now behaves as 2.6.16 in
that such USB sticks are correctly detected without partitions, while others
still work correctly :

   8     0     128000 sda   => 128 MB USB stick formatted under windows
   8     0     261216 sdb   => 256 MB USB stick which contains a real partition
   8     1     261040 sdb1
fs/partitions/msdos.c