[SETUPLIB][USETUP] Improve disk HW numbering, removable disk support, and "super...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 11 Mar 2019 23:13:25 +0000 (00:13 +0100)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 12 Mar 2019 01:17:11 +0000 (02:17 +0100)
commit47a1acedf7b28252674211d12314755f7ba96be7
treed5a3a2df8859567817f2dff07441e0c0e3b2db0a
parent85c5d035d918e3f914b6347c8a69cebb1e2c97ba
[SETUPLIB][USETUP] Improve disk HW numbering, removable disk support, and "super-floppy" partitioning.

Nowadays more and more people try to install ReactOS from removable
drives (e.g. USB sticks) onto fixed HDDs, or try to install it into
USB sticks too.

Both fixed and removable drives, as well as partitions on these, are
represented in NT using the same device name format:

  \Device\HarddiskM\PartitionN ,

with an increasing disk number M. Using this number for building the
corresponding firmware-specific ARC multi(x)disk(y)rdisk(z) path used
by the NT/ROS loader (FreeLdr, ...) is then prone to error since there
may have  been  removable drives  inserted  and  accounted for in the
calculation  of  the disk number.  These drives must be  correctly
subtracted in order to generate the correct ARC path, valid once all
the removable drives have been ejected (which should also be the
situation seen from the BIOS when booting up, except of course if you
boot on a USB stick).

This problem is now solved. Note that it matters only for the disks
that have also been enumerated by the firmware (BIOS; Int 13h). We
don't have to care about the other drives, since the ARC path will be
of a different format and will not use the disk number (instead, the
SCSI coordinates are used).

We also try to enumerate all the disks found in all the possible disk
adapters and  controllers enumerated  in the Hardware registry tree
(and that are visible by FreeLdr) in order to cover all.

Finally, we detect whether a disk reports as  a "super-floppy",  i.e.
an unpartitioned disk with a valid VBR. This is indeed how a standard
floppy disk looks like, or how USB sticks are partitioned on Windows.
Such disk is reported has having only one single partition starting at
the beginning of the disk, with partition number == 0, its type being
FAT16 non-bootable.
This allows us to forbid creating any new partitions on such disks.
Note that accessing either \Device\HarddiskN\Partition0 or Partition1
on such a disk returns the same data.
Note also that on the contrary, regular MBR-partitioned disks would
report at least four partitions entries, instead of just one.

The other improvements are:

- Do *NOT* write any MBR on a disk partitioned as "super-floppy".
  CORE-13703

- Fix the computed disk identifier, of format: %08x-%08x-%c .
  The numbers are respectively the checksum of the first sector, and
  the disk signature. The terminating letter is A or X, depending
  whether the first sector ends with 0x55AA/0xAA55 or not (see also
  commit 5053f1f5).

- Warn if the user attempts to install ReactOS on a disk that is not
  visible by the  firmware of his computer,  because it may not be
  bootable.
base/setup/lib/setuplib.c
base/setup/lib/utils/partlist.c
base/setup/lib/utils/partlist.h
base/setup/reactos/drivepage.c
base/setup/usetup/usetup.c