Programme d'écriture pour supprimer la cloison
Le programme pour supprimer la cloison est employé pour le but de dépannage. Par exemple, supposer que vous avez eu les cloisons de système de fichiers FAT32 dans votre disque. Maintenant vous avez décidé d'installer le logiciel d'exploitation de LINUX dans votre disque simultanément.
Si quel comment, l'installation du logiciel d'exploitation est interrompue dans l'intervalle, à l'étape quand les modifications étaient faites à la table de cloison du MBR. Il y a dans ces cas-ci beaucoup de possibilités qui la cloison, dans lequel vous entriez pour installer l'autre logiciel d'exploitation, devient inaccessible.
Dans ce cas-ci l'espace disque de la cloison perdue devient dû inutile à être inaccessible. Cependant si nous supprimons l'information de cloison de cette cloison de la table de cloison comment, nous pouvons encore faire à cet espace la commande employante utilisable de FDISK du DOS.
Le programme pour supprimer l'entrée de cloison de la table de cloison de MBR a été donné après :
/* Programme pour supprimer la deuxième entrée de cloison de la table de cloison de MBR */
# include <bios.h>
/* structure to read the partition entry from partition
table */
struct partition
{
/* Active Partition Byte */
unsigned char bootable ;
/* Starting Head */
unsigned char start_side ;
/* combination of Starting sector and cylinder number */
unsigned int start_sec_cyl ;
/* File system Indicator Byte */
unsigned char parttype ;
/* Ending Head */
unsigned char end_side ;
/* combination of Starting sector and cylinder number */
unsigned int end_sec_cyl ;
/* Relative Sector Number */
unsigned long part_beg ;
/* Partition length in sectors */
unsigned long plen ;
} ;
/* Structure to read-write MBR */
struct part
{
/* IPL (Initial Program Loader) */
unsigned char master_boot[446] ;
/* Partition table */
struct partition pt[4] ;
/* Magic Number */
int lasttwo ;
} ;
struct part p ;
void main()
{
unsigned int t1,t2;
clrscr();
biosdisk ( 2, 0x80, 0, 0, 1, 1, &p ) ;
display(); /* display the information of
Partition table */
getch();
p.pt[1].bootable = 0;
p.pt[1].start_side = 0 ;
p.pt[1].start_sec_cyl = 0 ;
p.pt[1].parttype = 0;
p.pt[1].end_side = 0;
p.pt[1].end_sec_cyl = 0;
p.pt[1].part_beg = 0;
p.pt[1].plen = 0;
printf("\n\n\n After Deleting the Second Partition
Entry From MBR Partition Table,");
printf("\n The Partition Table will Be Changed as
Follows: ");
/* To Delete Second Partition Information from partition
table of MBR Remove the forward slashes from the
biosdisk( ) function. Do not use Carelessly, Partition
information of Second Partition of Partition Table will
be Erased Completely. */
////// biosdisk ( 3, 0x80, 0, 0, 1, 1, &p ) ;
display(); /* Display the information of partition
table after modification */
getch();
}
Commentaires sur le programme :
Uncomment la fonction du biosdisk (3, 0x80, 0, 0, 1, 1, &p) pour supprimer la deuxième cloison de la table de cloison de MBR.
Pour supprimer la cloison, tous paramètres de elle, sont placés à 0 dans l'entrée de table de cloison dans MBR. Se rappeler toujours cela si vous supprimez la cloison prolongée, toutes cloisons logiques de cette cloison prolongée deviendra également inaccessible.
L'affichage de fonction () est employé pour montrer la table de cloison de MBR. Le codage de la fonction est comme suit :
/* Fonction pour montrer la table de cloison de MBR */
display()
{
unsigned int s_sec, s_trk, e_sec, e_trk, i, t1, t2 ;
char type[20], boot[5] ;
printf("\n\nPart. Boot Starting location Ending Location
Relative Number of");
printf("\nType Side Cylinder Sector Side Cylinder
Sector Sectors Sectors\n");
for ( i = 0 ; i <= 3 ; i++ )
{
if ( p.pt[i].bootable == 0x80 )
strcpy ( boot, "Yes" ) ;
else
strcpy ( boot, "No" ) ;
switch ( p.pt[i].parttype )
{
case 0x00 :
strcpy ( type, "Unused" ) ; break ;
case 0x1 :
strcpy ( type, "FAT12" ) ; break ;
case 0x2 :
strcpy ( type, "Xenix" ) ; break ;
case 0x3 :
strcpy ( type, "Xenix:usr" ) ; break ;
case 0x4 :
strcpy ( type, "FAT16<32M" ) ; break ;
case 0x5 :
strcpy ( type, "DOS-Ext." ) ; break ;
case 0x6 :
strcpy ( type, "FAT16>32M" ) ; break ;
case 0x7 :
strcpy ( type, "NTFS" ) ; break ;
case 0x0b :
strcpy ( type, "FAT32" ) ; break ;
case 0x0c :
strcpy ( type, "FAT32-LBA" ) ; break ;
case 0x0d :
strcpy ( type, "VFAT16" ) ; break ;
case 0x0e :
strcpy ( type, "VFAT16-LBA" ) ; break ;
case 0x0f :
strcpy ( type, "FAT EXT" ) ; break ;
case 0x17 :
strcpy ( type, "HPFS" ) ; break ;
case 0x81 :
strcpy ( type, "Old LINUX" ) ; break ;
case 0x82 :
strcpy ( type, "LinuxSwap" ) ; break ;
case 0x83 :
strcpy ( type, "LinuxNative" ) ; break ;
case 0x85 :
strcpy ( type, "Linux Ext." ) ; break ;
default :
strcpy ( type, "Unknown" ) ; break ;
}
s_sec = ( p.pt[i].start_sec_cyl & 0x3f ) ;
t1 = ( p.pt[i].start_sec_cyl & 0xff00 ) >> 8 ;
t2 = ( p.pt[i].start_sec_cyl & 0x00c0 ) << 2 ;
s_trk = t1 | t2 ;
e_sec = ( p.pt[i].end_sec_cyl & 0x3f ) ;
t1 = ( p.pt[i].end_sec_cyl & 0xff00 ) >> 8 ;
t2 = ( p.pt[i].end_sec_cyl & 0x00c0 ) << 2 ;
e_trk = t1 | t2 ;
printf ( "\n%6s %3s", type, boot ) ;
printf ( "%4d %6d %8d", p.pt[i].start_side,
s_trk,s_sec ) ;
printf ( "%7d %6u %8u", p.pt[i].end_side, e_trk,
e_sec ) ;
printf ( " %10lu %10lu", p.pt[i].part_beg,
p.pt[i].plen ) ;
}
return 0;
}
|
page 1 | 2 | 3 | 4 | 5 | 6 |
|
|
|