diff --git a/bin/fdisk.ini b/bin/fdisk.ini index 8110946..4339fa8 100644 --- a/bin/fdisk.ini +++ b/bin/fdisk.ini @@ -16,6 +16,7 @@ ; CHECKEXTRA={TRUE | FALSE} ; COLORS={0<=N<=127} ; DEL_ND_LOG={ON | OFF} +; DLA={0 | 1 | 2} ; DRIVE=#-####-###-## ; FLAG_SECTOR={0 | 2<=N<=64 | 256} ; LBA_MARKER={ON | OFF} @@ -64,6 +65,16 @@ ; TRUE ; * FALSE ; +; DLA Drive letter assignment method. +; * 0 auto dectect by operating system +; 1 FreeDOS / Microsoft driver letter assignment +; one primary per disk (active first), then +; all extended sorted by disk and partition table, +; then all remaining primaries by disk and partition table +; 2 DR-DOS drive letter assignment +; all primaries first sorted by disk and partition table, +; then all logicals by disk and partition table +; ; FLAG_SECTOR Sector number where the flags will be located. The ; default is 2. ; 0 Disables sector flagging function. diff --git a/source/fdisk/Makefile b/source/fdisk/Makefile index 6628d6d..62362ac 100644 --- a/source/fdisk/Makefile +++ b/source/fdisk/Makefile @@ -22,7 +22,7 @@ TOOL_CC = wcc386 CC = wcc CFLAGS = -q -0 -bt=dos -wx -we -!ifdef __LINUX__ +!ifdef __UNIX__ CFLAGS += -i=$(%WATCOM)/h !endif @@ -30,7 +30,7 @@ AS = nasm ASFLAGS = -t -f obj LD = wlink LDFLAGS = -!ifdef __LINUX__ +!ifdef __UNIX__ SEP=/ CP = cp MV = mv @@ -76,6 +76,8 @@ CFLAGS += -DSMART_MBR=1 objs += smartmbr.obj !endif +.erase + all : fdisk.exe dist : ../../fdisk.zip dist-svardos: ../../fdisk.svp diff --git a/source/fdisk/display.c b/source/fdisk/display.c index c482710..1664472 100644 --- a/source/fdisk/display.c +++ b/source/fdisk/display.c @@ -67,6 +67,9 @@ void Display_Information( void ) con_print( "FAT32" ); } + con_set_cursor_xy( 68, 1 ); + con_printf("DLA%u", flags.dla ); + if ( flags.use_ambr == TRUE ) { con_set_cursor_xy( 73, 1 ); con_print( "AMBR" ); diff --git a/source/fdisk/fdiskio.c b/source/fdisk/fdiskio.c index 3bba4d1..27b7382 100644 --- a/source/fdisk/fdiskio.c +++ b/source/fdisk/fdiskio.c @@ -489,6 +489,19 @@ void Process_Fdiskini_File( void ) command_ok = TRUE; } + /* Check for the COLORS statement */ + if ( 0 == stricmp( command_buffer, "DLA" ) ) { + number = atoi( setting_buffer ); + + if ( ( number >= 0 ) && ( number <= 2 ) ) { + flags.dla = number; + } + else { + goto parse_error; + } + command_ok = TRUE; + } + /* Check for the DEL_ND_LOG statement */ if ( 0 == stricmp( command_buffer, "DEL_ND_LOG" ) ) { if ( !bool_string_to_int( &flags.del_non_dos_log_drives, diff --git a/source/fdisk/main.c b/source/fdisk/main.c index 2e0849f..c956dd8 100644 --- a/source/fdisk/main.c +++ b/source/fdisk/main.c @@ -165,6 +165,15 @@ static int Get_Environment_Settings( char *environment[] ) bool_string_to_int( &flags.del_non_dos_log_drives, setting_buffer ); } + /* Check for drive letter ordering */ + if ( 0 == strcmp( command_buffer, "FFD_DLA" ) ) { + number = atoi( setting_buffer ); + + if ( ( number >= 0 ) && ( number <= 2 ) ) { + flags.dla = number; + } + } + /* Check for the FLAG_SECTOR statement */ if ( 0 == strcmp( command_buffer, "FFD_FLAG_SECTOR" ) ) { number = atoi( setting_buffer ); @@ -247,6 +256,7 @@ static void InitOptions( char *environment[] ) /* initialize flags, the ones not set here default to FALSE */ flags.display_name_description_copyright = TRUE; + flags.dla = 0; /* drive letter assignment based on OS */ flags.drive_number = 128; flags.flag_sector = 2; flags.lba_marker = TRUE; @@ -287,8 +297,18 @@ static void InitOptions( char *environment[] ) if ( flags.version >= COMP_W95B ) { flags.fat32 = TRUE; } + + if ( flags.dla == DLA_AUTO ) { + if ( os_oem == OEM_DRDOS ) { + flags.dla = DLA_DRDOS; + } + else { + flags.dla = DLA_MSDOS; + } + } } + static void InitDisks( void ) { /* Check for interrupt 0x13 extensions (If the proper version is set.) */ diff --git a/source/fdisk/main.h b/source/fdisk/main.h index e4db4be..8c8129b 100644 --- a/source/fdisk/main.h +++ b/source/fdisk/main.h @@ -152,6 +152,7 @@ typedef struct flags_structure { int using_default_drive_number; int check_for_extra_cylinder; int do_not_pause_help_information; + int dla; int drive_number; int esc; int extended_options_flag; diff --git a/source/fdisk/pdiskio.c b/source/fdisk/pdiskio.c index c46b381..2b1197f 100644 --- a/source/fdisk/pdiskio.c +++ b/source/fdisk/pdiskio.c @@ -66,6 +66,7 @@ extern void Pause( void ); int os_version = 0; int os_version_minor = 0; +int os_oem = 0; int os_gui_running = 0; void Determine_DOS_Version( void ) @@ -75,9 +76,24 @@ void Determine_DOS_Version( void ) /* check for DOS <5 */ r.w.ax = 0x3000; intr( 0x21, &r ); - if ( r.h.al < 5 ) { - os_version = r.h.al; - os_version_minor = r.h.ah; + os_version = r.h.al; + os_version_minor = r.h.ah; + os_oem = r.h.bh; + + if ( os_oem == OEM_IBM ) { + /* Is it DR-DOS pretending to be PC-DOS? */ + r.w.ax = 0x4452; + intr( 0x21, &r ); + if ( !( r.w.flags & INTR_CF ) ) { + os_oem = OEM_DRDOS; + } + } + if ( os_oem == OEM_NOVELL ) { + /* treat Novell DR-DOS as all other DR-DOS versions */ + os_oem = OEM_DRDOS; + } + + if ( os_version < 5 ) { return; } @@ -262,25 +278,45 @@ int Num_Ext_Part( Partition_Table *pDrive ) return num_ext; } +void dla_msdos( int *cl ); +void dla_drdos( int *cl ); +void dla_nondos( void ); + /* Determine drive letters */ int Determine_Drive_Letters( void ) /* Returns last used drive letter as ASCII number. */ { - // int active_found=FALSE; int current_letter = 'C'; - // int drive_found=FALSE; - int index = 0; - int non_dos_partition; - int non_dos_partition_counter; - int sub_index = 0; - - int active_part_found[MAX_DISKS]; Load_Brief_Partition_Table(); /* Clear drive_lettering_buffer[8] [27] */ memset( drive_lettering_buffer, 0, sizeof( drive_lettering_buffer ) ); + if ( flags.dla == DLA_MSDOS ) { + dla_msdos( ¤t_letter ); + } + else { + /* DR-DOS drive letter assignment puts all primaries of all drives + first, in order of partition table, then all logicals, drive by + drive. */ + dla_drdos( ¤t_letter ); + } + + /* assign numbers to non-DOS partitions */ + dla_nondos(); + + return current_letter - 1; +} + + +void dla_msdos( int *cl ) +{ + int current_letter = *cl; + int index = 0; + int sub_index = 0; + int active_part_found[MAX_DISKS]; + /* Set all active_part_found[] values to 0. */ memset( active_part_found, 0, sizeof( active_part_found ) ); @@ -352,6 +388,60 @@ int Determine_Drive_Letters( void ) } } } + *cl = current_letter; +} + + +void dla_drdos( int *cl ) +{ + int current_letter = *cl; + int index = 0; + int sub_index = 0; + + /* assign up to one drive letter to an active or non-active partition + per disk */ + for ( index = 0; index < MAX_DISKS; index++ ) { + Partition_Table *pDrive = &part_table[index]; + if ( !pDrive->usable ) { + continue; + } + + /* find active partition for drive */ + for ( sub_index = 0; sub_index < 4; sub_index++ ) { + if ( ( IsRecognizedFatPartition( + brief_partition_table[index][sub_index] ) ) ) { + drive_lettering_buffer[index][sub_index] = current_letter; + current_letter++; + } + } + } + + /* Next assign drive letters to applicable extended partitions... */ + for ( index = 0; index < MAX_DISKS; index++ ) { + Partition_Table *pDrive = &part_table[index]; + if ( !pDrive->usable ) { + continue; + } + + for ( sub_index = 4; sub_index < 27; sub_index++ ) { + if ( IsRecognizedFatPartition( + brief_partition_table[index][sub_index] ) ) { + drive_lettering_buffer[index][sub_index] = current_letter; + current_letter++; + } + } + } + + *cl = current_letter; +} + + +void dla_nondos( void ) +{ + int index = 0; + int sub_index = 0; + int non_dos_partition; + int non_dos_partition_counter; /* Find the Non-DOS Logical Drives in the Extended Partition Table */ for ( index = 0; index < MAX_DISKS; index++ ) { @@ -381,11 +471,10 @@ int Determine_Drive_Letters( void ) } } } - } - - return ( current_letter - 1 ); + } } + void Clear_Partition( Partition *p ) { memset( p, 0, sizeof( Partition ) ); diff --git a/source/fdisk/pdiskio.h b/source/fdisk/pdiskio.h index fb528b0..1fd4584 100644 --- a/source/fdisk/pdiskio.h +++ b/source/fdisk/pdiskio.h @@ -12,8 +12,19 @@ #define OS_WIN_ME 8 #define OS_WIN_NT 32 +#define OEM_IBM 0x00 +#define OEM_DRDOS 0xee +#define OEM_NOVELL 0xef +#define OEM_FRERDOS 0xfd + +#define DLA_AUTO 0 +#define DLA_MSDOS 1 +#define DLA_DRDOS 2 /* all primary partitions first, then logicals */ + extern int os_version; extern int os_version_minor; +extern int os_oem; + extern int os_gui_running; /* Buffers */