开源ext2read代码走读之-MBR中的一个分区表的构成与分区类型值

根据前面的MBR中包含的4个分区表中的一个分区表的信息,对应的结构体为:
struct MBRpartition {
    unsigned char boot_ind;         /* 0x80 - active */
    unsigned char head;             /* starting head */
    unsigned char sector;           /* starting sector */
    unsigned char cyl;              /* starting cylinder */
    unsigned char sys_ind;          /* What partition type */
    unsigned char end_head;         /* end head */
    unsigned char end_sector;       /* end sector */
    unsigned char end_cyl;          /* end cylinder */
    unsigned char start4[4];        /* starting sector counting from 0 */
    unsigned char size4[4];         /* nr of sectors in partition */
};
以上的结构中,当boot_ind为0x80的时候,表示此分区是已经进行了初始化的,通俗地讲,也即是进行了分区的建立并进行了

格式化的。
而sys_ind此值表示当前分区的类型,例如:在windows下一般都有Fat16,Fat32,NTFS,ExFat等,而在GNU Linux中有

ext2,ext3,ext4等文件系统,若是扩展分区,那么则为0x05。
分区的类型对应的值为:

switch(type)
    {
     case  0x06:    return "FAT16";
     case  0x07:    return "NTFS";
     case  0x0b:    return "FAT32";
     case  0x0c:    return "FAT32";
     case  0x0f:    return "Extended";
     case  0x82:    return "Linux Swap/Solaris";
     case  0x83:    return "EXT2fs/EXT3fs";
     case  0x8e:    return "Linux LVM";
     case  0x00:    return "empty";
     case  0x01:    return "DOS 12-bit FAT";
     case  0x04:    return "DOS 16-bit FAT";
     case  0x05:    return "Extended";
     case  0x85:    return "Linux Extended";
     case  0xfd:    return "Linux Raid";

     case  0x02:    return "XENIX root";
     case  0x03:    return "XENIX /usr";
     case  0x08:    return "AIX bootable";
     case  0x09:    return "AIX data";
     case  0x0A:    return "OS/2 Boot Manager";
     case  0x10:    return "OPUS";
     case  0x11:    return "OS/2 Boot Manager hidden 12-bit FAT";
     case  0x12:    return "Compaq Diagnostics";
     case  0x14:    return "OS/2 Boot Manager hidden sub-32M 16-bit FAT";
     case  0x16:    return "OS/2 Boot Manager hidden over-32M 16-bit FAT";
     case  0x17:    return "OS/2 Boot Manager hidden HPFS";
     case  0x18:    return "AST special Windows swap";
     case  0x24:    return "NEC MS-DOS";
     case  0x3C:    return "PowerQuest PartitionMagic recovery partition";
     case  0x40:    return "VENIX 80286";
     case  0x42:    return "SFS (Secure File System)";
     case  0x50:    return "Disk Manager (ro)";
     case  0x51:    return "Novell";
     case  0x52:    return "Microport System V/386";
     case  0x56:    return "GoldenBow VFeature";
     case  0x61:    return "SpeedStor";
     case  0x63:    return "GNU HURD";
     case  0x64:    return "Novell NetWare";
     case  0x65:    return "Novell NetWare";
     case  0x70:    return "DiskSecure Multi-Boot";
     case  0x75:    return "PC/IX";
     case  0x80:    return "Minix";
     case  0x81:    return "Minix";
     case  0x84:    return "OS/2-hidden";
     case  0x93:    return "Amoeba";
     case  0x94:    return "Amoeba bad";
     case  0xA5:    return "FreeBSD";
     case  0xB7:    return "BSDI";
     case  0xB8:    return "BSDI swap ";
     case  0xC1:    return "DR-DOS 6.0 LOGIN.EXE-secured 12-bit FAT";
     case  0xC4:    return "DR-DOS 6.0 LOGIN.EXE-secured 16-bit";
     case  0xC6:    return "DR-DOS 6.0 LOGIN.EXE-secured Huge";
      case  0xC7:    return "Cyrnix Boot";
     case  0xDB:    return "CP/M";
     case  0xE1:    return "SpeedStor 12-bit FAT extended";
     case  0xE4:    return "SpeedStor 16-bit FAT extended";
     case  0xF2:    return "DOS 3.3+ secondary";
     case  0xF4:    return "SpeedStor";
     case  0xFE:    return "LANstep";
     case  0xFF:    return "bad";
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值