Bool DriveTypeSet(U8 drv_let, I64 type=FSt_REDSEA)
{//Very dangerous
        I64                      i, j, ext_base, drv_num, offset, cur_type;
        CMasterBoot      mbr;
        CBlkDev         *bd;

        drv_let = Letter2Letter(drv_let);
        bd = Letter2BlkDev(drv_let);
        drv_num = bd->first_drive_let - 'A';
        switch (bd->type)
        {
                case BDT_ATA:
                        offset = 0;
                        ext_base = INVALID_CLUS;
                        while (TRUE)
                        {
                                AHCIAtaBlksRead(bd, &mbr, offset, 1);
                                j =- 1;
                                for (i = 0; i < 4; i++)
                                {
                                        cur_type = mbr.p[i].type;
                                        if (cur_type)
                                        {
                                                if (cur_type == 5 || cur_type == 15)
                                                        j = i;
                                                else
                                                {
                                                        if (drv_num + 'A' == drv_let)
                                                        {
                                                                switch (type)
                                                                {
                                                                        case FSt_REDSEA:
                                                                                mbr.p[i].type = MBR_PT_REDSEA;
                                                                                break;

                                                                        case FSt_FAT32:
                                                                                mbr.p[i].type = MBR_PT_FAT32a;
                                                                                break;

                                                                        default:
                                                                                throw('Drive');
                                                                }
                                                                mbr.p[i].active = 0x80;
                                                                AHCIAtaBlksWrite(bd, &mbr, offset, 1);
                                                                return TRUE;
                                                        }
                                                        drv_num++;
                                                }
                                        }
                                }
                                if (j < 0)
                                        break;
                                if (!mbr.p[j].offset)
                                        break;
                                if (ext_base == INVALID_CLUS)
                                {
                                        offset = mbr.p[j].offset;
                                        ext_base = offset;
                                }
                                else
                                        offset = mbr.p[j].offset+ext_base;
                        }
                        break;
        }
}

U0 Format(I64 drv_let, Bool quick=TRUE, Bool confirm=TRUE, I64 type=FSt_FAT32)
{//Format hard drive or RAM drive.
//Warning: Destroys all prev info.
        //quick=FALSE means fill entire drive with zeros.
        //Choose FSt_FAT32 or FSt_REDSEA.
        //You don't format a CD/DVD with this.
        CDrive  *drive = Letter2Drive(drv_let);
        Bool     old_silent = IsSilent;

        if (confirm && !AreYouSure)
                return;
        if (!drive)
        {
                PrintErr("Invalid Drive\n");
                return;
        }
        switch (type)
        {
                case FSt_FAT32:
                        if (drive->bd->type == BDT_ATA)
                        {
                                Silent;
                                Drive(drv_let);
                                Silent(old_silent);
                                FAT32Format(drv_let, quick);
                                DiskCacheInvalidate(Letter2Drive(drv_let));
                                Drive(drv_let);
                                break;
                        }
                        "Using RedSea File System.\n";
                case FSt_REDSEA:
                        Silent;
                        Drive(drv_let);
                        Silent(old_silent);
                        RedSeaFormat(drv_let, quick);
                        DiskCacheInvalidate(Letter2Drive(drv_let));
                        Drive(drv_let);
                        break;

                default:
                        PrintErr("File System Not Supported\n");
        }
}