[ui] use GNU fdisk's sys_type.h for FS type description

* also fixed persistent FS tooltip when no device is attached
This commit is contained in:
Pete Batard 2011-11-25 13:29:35 +00:00
parent df42dadd08
commit 7280b0c45b
5 changed files with 163 additions and 78 deletions

View File

@ -150,6 +150,7 @@
<ClInclude Include="..\msapi_utf8.h" />
<ClInclude Include="..\rufus.h" />
<ClInclude Include="..\license.h" />
<ClInclude Include="..\sys_types.h" />
</ItemGroup>
<ItemGroup>
<Manifest Include="..\common_controls_and_elevation.manifest" />

View File

@ -32,6 +32,9 @@
<ClInclude Include="..\license.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sys_types.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\rufus.ico">

View File

@ -26,6 +26,10 @@ const char* additional_copyrights =
"http://pcunleashed.com\r\n"
"Freeware\r\n"
"\r\n"
"FS Type description from by GNU fdisk:\r\n"
"http://www.gnu.org/software/fdisk\r\n"
"GNU General Public License (GPL) v3 or later\r\n"
"\r\n"
"About and License dialogs inspired by WinSCP\r\n"
"Copyright (c) 2000-2011 Martin Prikryl\r\n"
"GNU General Public License (GPL) v3 or later";

89
rufus.c
View File

@ -47,6 +47,7 @@
#include "msapi_utf8.h"
#include "resource.h"
#include "rufus.h"
#include "sys_types.h"
#if !defined(GUID_DEVINTERFACE_DISK)
const GUID GUID_DEVINTERFACE_DISK = { 0x53f56307L, 0xb6bf, 0x11d0, {0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} };
@ -123,87 +124,17 @@ void StatusPrintf(const char *format, ...)
}
/*
* Convert a partition type to its human readable form
* http://www.win.tue.nl/~aeb/partitions/partition_types-1.html
* Convert a partition type to its human readable form using
* (slightly modified) entries from GNU fdisk
*/
static const char* GetPartitionType(BYTE Type)
{
switch(Type) {
case 0x00:
return "Unused";
case 0x01:
return "DOS FAT12";
case 0x02:
return "Logical Disk Manager";
case 0x04:
return "DOS 3.0+ FAT16";
case 0x05:
return "Extended Partition";
case 0x06:
return "DOS 3.31+ FAT16 (Huge)";
case 0x07:
return "NTFS";
case 0x0b:
return "Win95 FAT32";
case 0x0c:
return "Win95 FAT32 (LBA)";
case 0x0e:
return "Win95 FAT16 (LBA)";
case 0x0f:
return "Win95 Extended (LBA)";
case 0x11:
return "Hidden DOS FAT12";
case 0x12:
return "Diagnostics Partition";
case 0x14:
return "Hidden DOS 3.0+ FAT16";
case 0x16:
return "Hidden DOS 3.31+ FAT16 (Huge)";
case 0x17:
return "Hidden NTFS";
case 0x1b:
return "Hidden Win95 FAT32";
case 0x1c:
return "Hidden Win95 FAT32 (LBA)";
case 0x1e:
return "Hidden Win95 FAT16 (LBA)";
case 0x1f:
return "Hidden Win95 Extended (LBA)";
case 0x27:
return "Windows Recovery";
case 0x42:
return "Windows 2000 Dynamic Extended";
case 0x63:
return "Unix System V";
case 0x82:
return "Linux Swap";
case 0x83:
return "Linux";
case 0x85:
return "Linux Extended";
case 0x8e:
return "Linux LVM";
case 0x9f:
case 0xa6:
case 0xa9:
return "BSD";
case 0xa8:
case 0xaf:
return "OS-X";
case 0xab:
return "OS-X (Boot)";
case 0xeb:
return "BeOS";
case 0xfa:
return "Bochs";
case 0xfb:
case 0xfc:
return "VMWare";
case 0xfd:
return "Linux RAID";
default:
return "Unknown";
int i;
for (i=0; i<ARRAYSIZE(msdos_systypes); i++) {
if (msdos_systypes[i].type == Type)
return msdos_systypes[i].name;
}
return "Unknown";
}
/*
@ -351,7 +282,7 @@ static BOOL GetDriveInfo(void)
if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) {
uprintf("Partition #%d:\n", ++nb_partitions);
if (hFSTooltip == NULL) {
safe_sprintf(tmp, sizeof(tmp), "Existing file system: %s (0x%02X)",
safe_sprintf(tmp, sizeof(tmp), "Current file system: %s (0x%02X)",
GetPartitionType(DriveLayout->PartitionEntry[i].Mbr.PartitionType),
DriveLayout->PartitionEntry[i].Mbr.PartitionType);
hFSTooltip = CreateTooltip(hFileSystem, tmp, -1);
@ -413,7 +344,9 @@ static BOOL PopulateProperties(int ComboIndex)
IGNORE_RETVAL(ComboBox_ResetContent(hFileSystem));
SetWindowTextA(hLabel, "");
DestroyTooltip(hDeviceTooltip);
DestroyTooltip(hFSTooltip);
hDeviceTooltip = NULL;
hFSTooltip = NULL;
memset(&SelectedDrive, 0, sizeof(SelectedDrive));
if (ComboIndex < 0) {

144
sys_types.h Normal file
View File

@ -0,0 +1,144 @@
/*
GNU fdisk - a clone of Linux fdisk.
Copyright (C) 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef SYS_TYPES_H_INCLUDED
#define SYS_TYPES_H_INCLUDED
typedef struct {
unsigned char type;
const char *name;
} SysType;
#define N_(String) String
/* The system types for msdos partition tables
* Needed for lfdisk and some interface improvements
*/
SysType msdos_systypes[] = {
{ 0x00, N_("Empty") },
{ 0x01, N_("FAT12") },
{ 0x02, N_("XENIX root") },
{ 0x03, N_("XENIX usr") },
{ 0x04, N_("Small FAT16") },
{ 0x05, N_("Extended") },
{ 0x06, N_("FAT16") },
{ 0x07, N_("NTFS") },
{ 0x08, N_("AIX") },
{ 0x09, N_("AIX Bootable") },
{ 0x0a, N_("OS/2 Boot Manager") },
{ 0x0b, N_("FAT32") },
{ 0x0c, N_("FAT32 LBA") },
{ 0x0e, N_("FAT16 LBA") },
{ 0x0f, N_("Extended LBA") },
{ 0x10, N_("OPUS") },
{ 0x11, N_("Hidden FAT12") },
{ 0x12, N_("Compaq Diagnostics") },
{ 0x14, N_("Hidden Small FAT16") },
{ 0x16, N_("Hidden FAT16") },
{ 0x17, N_("Hidden NTFS") },
{ 0x18, N_("AST SmartSleep") },
{ 0x1b, N_("Hidden FAT32") },
{ 0x1c, N_("Hidden FAT32 LBA") },
{ 0x1e, N_("Hidden FAT16 LBA") },
{ 0x24, N_("NEC DOS") },
{ 0x27, N_("Hidden NTFS WinRE") },
{ 0x39, N_("Plan 9") },
{ 0x3c, N_("PMagic recovery") },
{ 0x40, N_("Venix 80286") },
{ 0x41, N_("PPC PReP Boot") },
{ 0x42, N_("SFS") },
{ 0x4d, N_("QNX4.x") },
{ 0x4e, N_("QNX4.x 2nd Partition") },
{ 0x4f, N_("QNX4.x 3rd Partition") },
{ 0x50, N_("OnTrack DM") },
{ 0x51, N_("OnTrackDM6 Aux1") },
{ 0x52, N_("CP/M") },
{ 0x53, N_("OnTrackDM6 Aux3") },
{ 0x54, N_("OnTrack DM6") },
{ 0x55, N_("EZ Drive") },
{ 0x56, N_("Golden Bow") },
{ 0x5c, N_("Priam Edisk") },
{ 0x61, N_("SpeedStor") },
{ 0x63, N_("GNU HURD/SysV") },
{ 0x64, N_("Netware 286") },
{ 0x65, N_("Netware 386") },
{ 0x70, N_("DiskSec MultiBoot") },
{ 0x75, N_("PC/IX") },
{ 0x80, N_("Minix <1.4a") },
{ 0x81, N_("Minix >1.4b") },
{ 0x82, N_("Linux Swap") },
{ 0x83, N_("Linux") },
{ 0x84, N_("OS/2 Hidden C:") },
{ 0x85, N_("Linux Extended") },
{ 0x86, N_("NTFS Volume Set") },
{ 0x87, N_("NTFS Volume Set") },
{ 0x88, N_("Linux Plaintext") },
{ 0x8e, N_("Linux LVM") },
{ 0x93, N_("Amoeba") },
/*This guys created a seperate partition for badblocks?! */
{ 0x94, N_("Amoeba BBT") },
{ 0x9f, N_("BSD/OS") },
{ 0xa0, N_("Thinkpad Hibernation") },
{ 0xa5, N_("FreeBSD") },
{ 0xa6, N_("OpenBSD") },
{ 0xa7, N_("NeXTSTEP") },
{ 0xa8, N_("Darwin UFS") },
{ 0xa9, N_("NetBSD") },
{ 0xab, N_("Darwin Boot") },
{ 0xaf, N_("HFS/HFS+") },
{ 0xb7, N_("BSDI") },
{ 0xb8, N_("BSDI Swap") },
/* Beware of the Hidden wizard */
{ 0xbb, N_("Boot Wizard Hidden") },
{ 0xbe, N_("Solaris Boot") },
{ 0xbf, N_("Solaris") },
{ 0xc1, N_("DRDOS/2 FAT12") },
{ 0xc4, N_("DRDOS/2 smFAT16") },
{ 0xc6, N_("DRDOS/2 FAT16") },
/* Reminds me of Rush - 2112 */
{ 0xc7, N_("Syrinx") },
{ 0xda, N_("Non-FS Data") },
{ 0xdb, N_("CP/M") },
{ 0xde, N_("Dell Utility") },
/* Should 0x20 be DontBootIt then? */
{ 0xdf, N_("BootIt") },
{ 0xe1, N_("DOS Access") },
{ 0xe3, N_("DOS R/O") },
/*I sense some strange déjà vu */
{ 0xe4, N_("SpeedStor") },
{ 0xfb, N_("VMware VMFS") },
{ 0xfc, N_("VMware VMKCORE") },
{ 0xeb, N_("BeOS") },
{ 0xee, N_("GPT") },
{ 0xef, N_("EFI FAT") },
{ 0xf0, N_("Linux/PA-RISC Boot") },
{ 0xf1, N_("SpeedStor") },
{ 0xf2, N_("DOS secondary") },
/* Are these guys trying for a Guinness record or something? */
{ 0xf4, N_("SpeedStor") },
{ 0xfd, N_("Linux RAID Auto") },
{ 0xfe, N_("LANstep") },
{ 0xff, N_("XENIX BBT") },
{ 0, NULL }
};
#endif