- if (BufferSize >= 512) {
-
- // Search for NTFS, FAT, and MBR/EBR.
- // These all have 0xAA55 at the end of the first sector, but FAT and
- // MBR/EBR are not easily distinguished. Thus, we first check to see
- // if the "volume" is in fact a disk device; then look for NTFS
- // "magic"; and then check to see if the volume can be mounted, thus
- // relying on the EFI's built-in FAT driver to identify FAT.
- Magic16 = (UINT16*) (Buffer + 510);
- if (*Magic16 == FAT_MAGIC) {
- MagicString = (char*) (Buffer + 3);
- // Confusingly, "LogicalPartition" refers to the presence of a
- // partition table, not an MBR logical partition.
- if (Volume->BlockIO->Media->LogicalPartition) {
- Volume->FSType = FS_TYPE_WHOLEDISK;
- } else if (CompareMem(MagicString, NTFS_SIGNATURE, 8) == 0) {
- Volume->FSType = FS_TYPE_NTFS;
- CopyMem(&(Volume->VolUuid), Buffer + 0x48, sizeof(UINT64));
- } else {
- RootDir = LibOpenRoot(Volume->DeviceHandle);
- if (RootDir != NULL)
- Volume->FSType = FS_TYPE_FAT;
- } // if/elseif/else
- return;
- } // if
- } // search for FAT and NTFS magic
-