├── help ├── fdisk.fr ├── fdisk.sv ├── fdisk.tr ├── fdisk.en ├── fdisk.es ├── fdisk.ptb ├── FDISK.NL └── fdisk.de ├── appinfo ├── fdisk.de ├── fdisk.fr ├── fdisk.sv ├── fdisk.tr └── fdisk.lsm ├── .gitattributes ├── source └── fdisk │ ├── test │ └── ansitest.c │ ├── helpscr.h │ ├── compat.h │ ├── display.h │ ├── compat.c │ ├── kbdinput.h │ ├── fdiskio.h │ ├── utf8tocp │ ├── history.txt │ └── license │ ├── svarlang │ ├── version.c │ ├── history.txt │ ├── auto_exe.c │ ├── auto_nls.c │ ├── makefile │ ├── svarlang.h │ ├── svarlang.txt │ └── svarlang.c │ ├── cmd.h │ ├── pcompute.h │ ├── ui.h │ ├── zipfiles.txt │ ├── helpscr.c │ ├── Makefile.gcc │ ├── bintoc │ └── bintoc.c │ ├── printf.h │ ├── pdiskio.h │ ├── main.h │ ├── test.c │ ├── Makefile │ ├── clangfmt.cfg │ ├── bootnorm.asm │ ├── ansicon.h │ ├── smartmbr.asm │ ├── display.c │ └── ansicon.c ├── .gitignore ├── .github └── workflows │ └── build.yml ├── doc └── fdisk │ ├── contrib.txt │ ├── INSTALL.md │ ├── faq.txt │ ├── USAGE.md │ └── CHANGES.md ├── README.md ├── bin └── fdisk.ini └── LICENSE /help/fdisk.fr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/fdisk/HEAD/help/fdisk.fr -------------------------------------------------------------------------------- /help/fdisk.sv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/fdisk/HEAD/help/fdisk.sv -------------------------------------------------------------------------------- /help/fdisk.tr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/fdisk/HEAD/help/fdisk.tr -------------------------------------------------------------------------------- /appinfo/fdisk.de: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/fdisk/HEAD/appinfo/fdisk.de -------------------------------------------------------------------------------- /appinfo/fdisk.fr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/fdisk/HEAD/appinfo/fdisk.fr -------------------------------------------------------------------------------- /appinfo/fdisk.sv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/fdisk/HEAD/appinfo/fdisk.sv -------------------------------------------------------------------------------- /appinfo/fdisk.tr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/fdisk/HEAD/appinfo/fdisk.tr -------------------------------------------------------------------------------- /help/fdisk.en: -------------------------------------------------------------------------------- 1 | FDISK 2 | 3 | FDISK is a basic tool for removing and creating partitions on harddisks -------------------------------------------------------------------------------- /help/fdisk.es: -------------------------------------------------------------------------------- 1 | FDISK 2 | 3 | FDISK es una herramienta basica para gestionar particiones en discos duros. 4 | -------------------------------------------------------------------------------- /help/fdisk.ptb: -------------------------------------------------------------------------------- 1 | FDISK 2 | 3 | FDISK é uma ferramenta básica para criar e remover partições em discos rígidos 4 | -------------------------------------------------------------------------------- /help/FDISK.NL: -------------------------------------------------------------------------------- 1 | FDISK 2 | 3 | FDISK is een hulpprogramma om partities te verwijderen en te creeren op harde 4 | schijven 5 | -------------------------------------------------------------------------------- /help/fdisk.de: -------------------------------------------------------------------------------- 1 | FDISK 2 | 3 | FDISK ist ein grundlegendes Tool um auf Datenträgern Partitionen zu 4 | erstellen oder zu entfernen. 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=crlf 2 | *.com binary 3 | *.COM binary 4 | *.exe binary 5 | *.EXE binary 6 | *.lib binary 7 | *.LIB binary 8 | *.prj binary 9 | *.PRJ binary 10 | *.zip binary 11 | *.ZIP binary 12 | -------------------------------------------------------------------------------- /source/fdisk/test/ansitest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ansicon.h" 3 | #include "printf.h" 4 | 5 | int main( void ) 6 | { 7 | con_init( 1 ); 8 | con_print( "\33[1;5m\tThis\t\tshould blink!\33[22;25m\nAnd this NOT!\n"); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /source/fdisk/helpscr.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Program: Free FDISK 3 | // Module: HELPSCR.H 4 | // Module Description: Header File for HELPSCR.C 5 | // Written By: Brian E. Reifsnyder 6 | // Version: 1.2.1 7 | // Copyright: 1998-2001 under the terms of the GNU GPL, Version 2 8 | */ 9 | 10 | #ifndef HELPSCR_H 11 | 12 | void Display_Help_Screen( void ); 13 | 14 | #endif /* HELPSCR_H */ 15 | -------------------------------------------------------------------------------- /source/fdisk/compat.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPAT_H 2 | #define COMPAT_H 3 | 4 | #if defined( __WATCOMC__ ) || defined( __GNUC__ ) 5 | 6 | #endif 7 | 8 | #if defined( __WATCOMC__ ) 9 | 10 | char *searchpath( char *fn ); 11 | 12 | #endif /* COMPAT_H */ 13 | 14 | #if defined( __GNUC__ ) 15 | 16 | extern char *_searchpath( const char *__file ); 17 | #define searchpath _searchpath 18 | 19 | #ifndef stricmp 20 | #define stricmp strcasecmp 21 | #endif 22 | 23 | extern char **environ; 24 | 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /source/fdisk/display.h: -------------------------------------------------------------------------------- 1 | /* contains UI calls that required by command-line operations */ 2 | 3 | #ifndef DISPLAY_H 4 | #define DISPLAY_H 5 | 6 | void Display_Information( void ); 7 | void Dump_Partition_Information( void ); 8 | void Display_CL_Partition_Table( void ); 9 | void Print_UL( unsigned long number ); 10 | void Print_UL_B( unsigned long number ); 11 | void Print_Centered( int y, const char *text, int style ); 12 | void Display_All_Drives( void ); 13 | void Pause( void ); 14 | 15 | const char *part_type_descr( int id ); 16 | const char *part_type_descr_short( int id ); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /source/fdisk/compat.c: -------------------------------------------------------------------------------- 1 | 2 | #if defined( __WATCOMC__ ) || defined( __GNUC__ ) 3 | 4 | #include "compat.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #ifdef __GNUC__ 11 | #include 12 | #endif 13 | 14 | /* Watcom C does not have this */ 15 | #ifdef __WATCOMC__ 16 | char *searchpath( char *fn ) 17 | { 18 | static char full_path[_MAX_PATH]; 19 | 20 | _searchenv( fn, "PATH", full_path ); 21 | if ( full_path[0] ) { 22 | return full_path; 23 | } 24 | 25 | return NULL; 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /appinfo/fdisk.lsm: -------------------------------------------------------------------------------- 1 | Begin3 2 | Title: Free FDISK 3 | Version: 1.4.4 4 | Entered-date: 2025-04-27 5 | Description: Fixed disk partition tool 6 | Summary: Fixed disk partition tool to create, delete and view hard disk 7 | partitions. 8 | Keywords: fdisk, format, hard drive, partition, fat16, fat32, partition, 9 | mbr 10 | Maintained-by: Bernd Boeckmann 11 | Author: Brian E. Reifsnyder 12 | Bernd Boeckmann 13 | Primary-site: https://github.com/FDOS/fdisk 14 | Alternate-site: 15 | Platforms: DOS, FreeDOS 16 | Copying-policy: GNU General Public License, version 2 17 | End 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # distribution files 2 | fdisk.zip 3 | fdisk.svp 4 | source.zip 5 | bin/fdisk.exe 6 | nls/fdisk.lng 7 | svardos 8 | 9 | # generated files 10 | source/fdisk/*.exe 11 | source/fdisk/bintoc/*.exe 12 | source/fdisk/bintoc/bintoc 13 | source/fdisk/svarlang/*.exe 14 | source/fdisk/svarlang/tlumacz 15 | source/fdisk/utf8tocp/*.exe 16 | source/fdisk/utf8tocp/utf8tocp 17 | source/fdisk/deflang.c 18 | source/fdisk/bootnorm.bin 19 | source/fdisk/bootnorm.c 20 | source/fdisk/fdisk.lng 21 | source/fdisk/svarlang/*.lib 22 | source/fdisk/nls/??.txt 23 | source/fdisk/nls/deflang.c 24 | source/fdisk/nls/out.lng 25 | 26 | # compiler-specific build artifacts 27 | *.o 28 | *.dsk 29 | *.err 30 | *.lnk 31 | *.lst 32 | *.obj 33 | *.map 34 | *.tmp 35 | 36 | # MAC OS junk 37 | .DS_Store 38 | -------------------------------------------------------------------------------- /source/fdisk/kbdinput.h: -------------------------------------------------------------------------------- 1 | #ifndef KBDINPUT_H 2 | #define KBDINPUT_H 3 | 4 | /* Definitions for the input routine */ 5 | enum kbdinput_type { 6 | YN = 0, 7 | NUM = 1, 8 | NUMP = 2, 9 | ESC = 3, 10 | ESCR = 4, 11 | ESCE = 5, 12 | ESCC = 6, 13 | CHAR = 7, 14 | NONE = 8, 15 | CHARNUM = 9, 16 | NUMCHAR = 10, 17 | NUMYN = 11 18 | }; 19 | 20 | unsigned long Input( int size_of_field, int x_position, int y_position, 21 | enum kbdinput_type type, unsigned long min_range, 22 | unsigned long max_range, int return_message, 23 | long default_value, 24 | unsigned long maximum_possible_percentage, 25 | char optional_char_1, char optional_char_2 ); 26 | 27 | #endif /* KBDINPUT_H */ 28 | -------------------------------------------------------------------------------- /source/fdisk/fdiskio.h: -------------------------------------------------------------------------------- 1 | #ifndef FDISKIO_H 2 | #define FDISKIO_H 3 | 4 | #include "compat.h" 5 | 6 | int Test_Flag( int flag_number ); 7 | 8 | int Automatically_Partition_Hard_Drive( void ); 9 | int Clear_Entire_Sector_Zero( void ); 10 | int Clear_Flag( int flag_number ); 11 | int Clear_Partition_Table( void ); 12 | void Clear_Sector_Buffer( void ); 13 | int Load_MBR( int ipl_only ); 14 | /*void Create_BootEasy_MBR( void );*/ 15 | int Create_MBR( void ); 16 | /*int Create_MBR_If_Not_Present( void );*/ 17 | void Load_External_Lookup_Table( void ); 18 | void Process_Fdiskini_File( void ); 19 | int Remove_IPL( void ); 20 | int Save_MBR( void ); 21 | int bool_string_to_int( int *var, const char *bool_text ); 22 | int Set_Flag( int flag_number, int flag_value ); 23 | 24 | #ifdef SMART_MBR 25 | int Create_BootSmart_IPL( void ); 26 | #endif 27 | 28 | #endif /* FIDISKIO_H */ 29 | -------------------------------------------------------------------------------- /source/fdisk/utf8tocp/history.txt: -------------------------------------------------------------------------------- 1 | 2 | utf8tocp history 3 | 4 | 5 | xxxxxxxx 6 | - fixed Euro sign placement in CP808 7 | 8 | 20240918 9 | - conversion is written to a file to avoid platform-specific CR/LF changes 10 | - versioning scheme changed from vx.x.x to date-based YYYYMMDD 11 | - DOS version is compiled with OpenWatcom 1.9 instead of Turbo C 2.01 12 | - relicensed from BSD 2-clause to MIT 13 | 14 | v0.9.5 [10 Dec 2020] 15 | - added the '-d' action 16 | 17 | v0.9.4 [13 Dec 2016] 18 | - fixed CP866 (glyphs 224..239 were corrupted) 19 | 20 | v0.9.3 [15 Aug 2016] 21 | - added support for codepage CP857 ('MS-DOS Turkish') 22 | - fixed CP858 (euro sign was misplaced) 23 | 24 | v0.9.2 [20 Feb 2016] 25 | - UTF-8 BOM markers are handled properly (that is, ignored) 26 | 27 | v0.9.1 [10 May 2015] 28 | - added support for codepage CP1250 29 | - relicensed utf8tocp from GNU GPL to the BSD '2-clause' license 30 | 31 | v0.9 [22 Dec 2013] 32 | - added the -r (reverse operation) feature 33 | - added support for new codepages: CP775, CP808, CP852, CP858, CP866 34 | 35 | v0.8 [15 Dec 2013] 36 | - first public release 37 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build master (Linux) 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | build-watcom: 12 | 13 | runs-on: [self-hosted, watcom] 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: Build with wmake 19 | run: | 20 | cd source/fdisk 21 | wmake 22 | 23 | - name: Build distribution ZIP 24 | run: | 25 | cd source/fdisk 26 | wmake dist dist-svardos 27 | 28 | - name: Upload distribution files 29 | uses: actions/upload-artifact@v4 30 | with: 31 | name: fdisk.zip 32 | path: fdisk.zip 33 | 34 | - name: Upload SvarDOS package 35 | uses: actions/upload-artifact@v4 36 | with: 37 | name: fdisk.svp 38 | path: fdisk.svp 39 | 40 | build-ia16-gcc: 41 | 42 | runs-on: [self-hosted, ia16-gcc] 43 | 44 | steps: 45 | - uses: actions/checkout@v4 46 | 47 | - name: Build with IA16-GCC and GNU Make 48 | run: | 49 | cd source/fdisk 50 | make -f Makefile.gcc 51 | -------------------------------------------------------------------------------- /source/fdisk/utf8tocp/license: -------------------------------------------------------------------------------- 1 | 2 | === MIT LICENSE === 3 | 4 | Copyright (C) 2013-2024 Mateusz Viste 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /source/fdisk/svarlang/version.c: -------------------------------------------------------------------------------- 1 | /* This file is part of the svarlang project and is published under the terms 2 | * of the MIT license. 3 | * 4 | * Copyright (C) 2021-2023 Mateusz Viste 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #include "svarlang.h" 26 | 27 | const char *svarlang_getver(void) { 28 | return SVARLANGVER; 29 | } 30 | -------------------------------------------------------------------------------- /doc/fdisk/contrib.txt: -------------------------------------------------------------------------------- 1 | CONTRIB.TXT 2 | 3 | Thanks to the following people for contributing: 4 | 5 | Name: Contributed: 6 | Brian Reifsneyder original author 7 | Phil Brutsche part.dat idea and null pointer error bug fix 8 | Roland Ronquist ideas, advice, and testing 9 | John Price information on how to modify the program to run on 10 | an 8086/8088 11 | Ralf Quint information on how to break the source into sections, 12 | some code changes, and helped me find information 13 | on how to add LBA support 14 | Phil Marek new command-line parsing code and a variable fix 15 | in pdiskio.cpp 16 | Jim Hall makefile 17 | Tom Ehlert program size reduction, code simplifications, 18 | new bootloader, bug fixes 19 | Wilhelm Spiegl extensive testing 20 | Bernd Boeckmann Open Watcom C and I16-GCC ports, critical bug fixes, 21 | code cleanup, German translation 22 | Mateusz Viste svarlang lib, FDISK lite, code improvements, 23 | Polish translation 24 | Emir SARI Turkish translation 25 | Berki Yenigün French, Turkish translation 26 | Alejandro de Garate Spanish translation 27 | Robert Riebisch German translation fixes 28 | -------------------------------------------------------------------------------- /source/fdisk/cmd.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Program: Free FDISK 3 | // Module: CMD.H 4 | // Module Description: Header File for CMD.C 5 | // Written By: Brian E. Reifsnyder 6 | // Version: 1.2.1 7 | // Copyright: 1998-2001 under the terms of the GNU GPL, Version 2 8 | */ 9 | 10 | /* 11 | ///////////////////////////////////////////////////////////////////////////// 12 | // SPECIAL 13 | ///////////////////////////////////////////////////////////////////////////// 14 | */ 15 | 16 | #ifndef CMD_H 17 | #define CMD_H 18 | 19 | #ifndef SWAP 20 | #define SWAP 1 21 | #endif 22 | 23 | #ifndef MOVE 24 | #define MOVE 2 25 | #endif 26 | 27 | /* 28 | ///////////////////////////////////////////////////////////////////////////// 29 | // PROTOTYPES 30 | ///////////////////////////////////////////////////////////////////////////// 31 | */ 32 | 33 | int Get_Options( char *arguments[], int number_of_arguments ); 34 | 35 | void Command_Line_Clear_Flag( void ); 36 | void Command_Line_Create_Extended_Partition( void ); 37 | void Command_Line_Create_Logical_DOS_Drive( void ); 38 | void Command_Line_Create_Primary_Partition( void ); 39 | void Command_Line_Delete( void ); 40 | void Command_Line_Info( void ); 41 | void Command_Line_Modify( void ); 42 | void Command_Line_Move( void ); 43 | void Command_Line_Set_Flag( void ); 44 | void Command_Line_Status( void ); 45 | void Command_Line_Move( void ); 46 | void Command_Line_Swap( void ); 47 | void Command_Line_Test_Flag( void ); 48 | void Shift_Command_Line_Options( int number_of_places ); 49 | 50 | #endif /* CMD_H */ 51 | -------------------------------------------------------------------------------- /source/fdisk/pcompute.h: -------------------------------------------------------------------------------- 1 | #ifndef PCOMPUTE_H 2 | #define PCOMPUTE_H 3 | 4 | #include "pdiskio.h" 5 | /* 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // PROTOTYPES 8 | ///////////////////////////////////////////////////////////////////////////// 9 | */ 10 | 11 | int LBA_Partition_Type_To_Create( int standard_partition_type ); 12 | int Create_Logical_Drive( int numeric_type, unsigned long size_in_MB ); 13 | int Create_Primary_Partition( int num_type, unsigned long size_in_MB ); 14 | int More_Than_One_Hard_Disk( void ); 15 | int Partition_Type_To_Create( unsigned long size_in_mb, 16 | int requested_partition_type ); 17 | 18 | unsigned long Max_Pri_Free_Space_In_MB( void ); 19 | unsigned long Max_Log_Free_Space_In_MB( void ); 20 | unsigned long Max_Log_Part_Size_In_MB( void ); 21 | unsigned long Max_Pri_Part_Size_In_MB( int type ); 22 | 23 | int Nth_Log_Part_Defined( Partition_Table *pDrive, int num ); 24 | int Deactivate_Active_Partition( void ); 25 | int Delete_Logical_Drive( int logical_drive_number ); 26 | int Delete_Extended_Partition( void ); 27 | int Delete_Primary_Partition( int partition_number ); 28 | void Determine_Free_Space( void ); 29 | void Modify_Extended_Partition_Information( int logical_drive_number ); 30 | int Modify_Partition_Type( int partition_number, int type_number ); 31 | void Modify_Primary_Partition_Information( int logical_drive ); 32 | int Primary_Partition_Slot_Transfer( int transfer_type, int source, 33 | int dest ); 34 | int Set_Active_Partition( int partition_number ); 35 | void Set_Active_Partition_If_None_Is_Active( int partition_number ); 36 | 37 | char drive_letter_or_questionmark( char drive_letter ); 38 | 39 | #endif /* PCOMPUTE_H */ 40 | -------------------------------------------------------------------------------- /source/fdisk/svarlang/history.txt: -------------------------------------------------------------------------------- 1 | 20241010 2 | - improved the MVCOMP compression algorithm (ca. 5% more efficient on text) 3 | - added /nodef to TLUMACZ (skips deflang generation) 4 | - MVCOMP-packed data is loaded to RAM before unpacking (60x faster on an 8086) 5 | - assembly version of the MVCOMP depacker used by default (saves 27 bytes) 6 | 7 | 20240929 8 | - LNG strings may be optionally MVCOMP-compressed (disabled with /nocomp) 9 | - reference language can be excluded from the LNG file (/excref) 10 | 11 | 20240915 12 | - fixed svarlang_strid() when id=0 and string does not exist (Bernd Boeckmann) 13 | 14 | 20240227 15 | - replaced inline _asm by pragma aux (more compact code, open watcom only) 16 | 17 | 20230730 18 | - dropped svarlang_autoload() (replaced by more specialized functions below) 19 | - added svarlang_autoload_exepath() and svarlang_autoload_nlspath() 20 | - svarlang_load() simplified so it takes the target filename as an argument 21 | - file access relies on fopen() when svarlang is compiled with -DWITHSTDIO 22 | - new file format: sorted dictionary for faster lookup (by Bernd Boeckmann) 23 | breaking change! See svarlang.txt for file format specification 24 | 25 | 20230630 26 | - tlumacz.exe warns about empty strings (patch by Bernd Boeckmann) 27 | - tlumacz.exe does not abort when a malformed line is found 28 | 29 | 20230629 30 | - deflang.c has each message on a different line so it is nicer to VCSes 31 | 32 | 20230628 33 | - added support for \e sequences in translation strings 34 | - implemented svarlang_getver() 35 | 36 | 20220314 37 | - added support for flagging strings as being "dirty", eg: ?1.1:Hello, World 38 | 39 | 20220309 40 | - static lib buffer is sized to fit the largest lang block +5% of margin 41 | (was: twice the size of the reference language) 42 | 43 | 20220226 44 | - replaced fopen() and friends by direct DOS calls (smaller memory footprint) 45 | -------------------------------------------------------------------------------- /source/fdisk/ui.h: -------------------------------------------------------------------------------- 1 | #ifndef UI_H 2 | #define UI_H 3 | 4 | #define TEXT_ATTR_NORMAL 0x07 5 | 6 | void Clear_Screen( int type ); 7 | void Print_At( int column, int row, const char *, ... ); 8 | void Color_Print( const char *text ); 9 | void Color_Printf( const char *format, ... ); 10 | void Color_Print_At( int column, int row, const char *, ... ); 11 | void Normal_Print_At( int column, int row, const char *, ... ); 12 | void BlinkPrintAt( int column, int row, const char *format, ... ); 13 | void Position_Cursor( int column, int row ); 14 | 15 | int Standard_Menu( int menu ); 16 | void Warn_Incompatible_Ext( void ); 17 | /*void Display_Label( void );*/ 18 | void Interactive_User_Interface( void ); 19 | void Menu_Routine( void ); 20 | void Exit_Screen( void ); 21 | 22 | int Create_DOS_Partition_Interface( int type ); 23 | int Create_Logical_Drive_Interface( void ); 24 | int Delete_Logical_Drive_Interface( void ); 25 | int Set_Active_Partition_Interface( void ); 26 | int Standard_Menu( int menu ); 27 | 28 | void Ask_User_About_FAT32_Support( void ); 29 | int Inform_About_Trimmed_Disk( void ); 30 | void Change_Current_Fixed_Disk_Drive( void ); 31 | void Delete_Extended_DOS_Partition_Interface( void ); 32 | void Delete_N_DOS_Partition_Interface( void ); 33 | void Delete_Primary_DOS_Partition_Interface( void ); 34 | void Display_Extended_Partition_Information_SS( void ); 35 | void Display_Help_Screen( void ); 36 | void Display_Or_Modify_Logical_Drive_Information( void ); 37 | void Display_Partition_Information( void ); 38 | void Display_Primary_Partition_Information_SS( void ); 39 | void Interactive_User_Interface( void ); 40 | void List_Partition_Types( void ); 41 | void Menu_Routine( void ); 42 | void Modify_Extended_Partition_Information( int logical_drive_number ); 43 | void Modify_Primary_Partition_Information( int logical_drive ); 44 | void Position_Cursor( int row, int column ); 45 | 46 | #endif /* UI_H */ 47 | -------------------------------------------------------------------------------- /source/fdisk/zipfiles.txt: -------------------------------------------------------------------------------- 1 | LICENSE 2 | README.md 3 | bin/fdisk.exe 4 | bin/fdisk.ini 5 | nls/fdisk.lng 6 | appinfo/fdisk.sv 7 | appinfo/fdisk.lsm 8 | appinfo/fdisk.de 9 | appinfo/fdisk.fr 10 | appinfo/fdisk.tr 11 | doc/fdisk/USAGE.md 12 | doc/fdisk/INSTALL.md 13 | doc/fdisk/faq.txt 14 | doc/fdisk/CHANGES.md 15 | doc/fdisk/contrib.txt 16 | doc/fdisk/history.txt 17 | help/fdisk.de 18 | help/fdisk.en 19 | help/fdisk.es 20 | help/fdisk.fr 21 | help/fdisk.nl 22 | help/fdisk.ptb 23 | help/fdisk.tr 24 | help/fdisk.sv 25 | source/fdisk/ansicon.c 26 | source/fdisk/bootnorm.c 27 | source/fdisk/cmd.c 28 | source/fdisk/compat.c 29 | source/fdisk/deflang.c 30 | source/fdisk/display.c 31 | source/fdisk/fdiskio.c 32 | source/fdisk/helpscr.c 33 | source/fdisk/kbdinput.c 34 | source/fdisk/main.c 35 | source/fdisk/pcompute.c 36 | source/fdisk/pdiskio.c 37 | source/fdisk/printf.c 38 | source/fdisk/test.c 39 | source/fdisk/ui.c 40 | source/fdisk/ansicon.h 41 | source/fdisk/cmd.h 42 | source/fdisk/compat.h 43 | source/fdisk/display.h 44 | source/fdisk/fdiskio.h 45 | source/fdisk/helpscr.h 46 | source/fdisk/kbdinput.h 47 | source/fdisk/main.h 48 | source/fdisk/pcompute.h 49 | source/fdisk/pdiskio.h 50 | source/fdisk/printf.h 51 | source/fdisk/ui.h 52 | source/fdisk/bootnorm.asm 53 | source/fdisk/smartmbr.asm 54 | source/fdisk/Makefile 55 | source/fdisk/Makefile.gcc 56 | source/fdisk/zipfiles.txt 57 | source/fdisk/bintoc/bintoc.c 58 | source/fdisk/svarlang/auto_exe.c 59 | source/fdisk/svarlang/auto_nls.c 60 | source/fdisk/svarlang/history.txt 61 | source/fdisk/svarlang/makefile 62 | source/fdisk/svarlang/svarlang.c 63 | source/fdisk/svarlang/svarlang.h 64 | source/fdisk/svarlang/svarlang.txt 65 | source/fdisk/svarlang/version.c 66 | source/fdisk/svarlang/tlumacz.c 67 | source/fdisk/utf8tocp/utf8tocp.c 68 | source/fdisk/nls/de_utf8.txt 69 | source/fdisk/nls/en_utf8.txt 70 | source/fdisk/nls/es_utf8.txt 71 | source/fdisk/nls/fr_utf8.txt 72 | source/fdisk/nls/it_utf8.txt 73 | source/fdisk/nls/pl_utf8.txt 74 | source/fdisk/nls/tr_utf8.txt 75 | -------------------------------------------------------------------------------- /source/fdisk/helpscr.c: -------------------------------------------------------------------------------- 1 | /* 2 | // Program: Free FDISK 3 | // Written By: Brian E. Reifsnyder 4 | // Module: HELPSCR.C 5 | // Module Description: User Interface Code Module 6 | // Version: 1.3.1 7 | // Copyright: 1998-2008 under the terms of the GNU GPL, Version 2 8 | */ 9 | 10 | /* 11 | ///////////////////////////////////////////////////////////////////////////// 12 | // INCLUDES 13 | ///////////////////////////////////////////////////////////////////////////// 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | #include "ansicon.h" 20 | #include "display.h" 21 | #include "helpscr.h" 22 | #include "main.h" 23 | #include "pdiskio.h" 24 | #include "printf.h" 25 | #include "svarlang/svarlang.h" 26 | 27 | /* 28 | ///////////////////////////////////////////////////////////////////////////// 29 | // FUNCTIONS 30 | ///////////////////////////////////////////////////////////////////////////// 31 | */ 32 | 33 | /* Display Help Screens */ 34 | void Display_Help_Screen( void ) 35 | { 36 | char version[40]; 37 | char name[40]; 38 | unsigned char i; 39 | unsigned char linestopause; 40 | unsigned char screenh = con_get_height(); 41 | 42 | if ( !con_is_tty() ) { 43 | flags.do_not_pause_help_information = TRUE; 44 | } 45 | 46 | strcpy( name, FD_NAME ); 47 | 48 | strcpy( version, " V" ); 49 | strcat( version, VERSION ); 50 | 51 | con_printf( "%-30s %30s\n", name, version ); 52 | 53 | /* dump the entire help on screen */ 54 | linestopause = screenh - 1; /* number of lines before screen is full */ 55 | for ( i = 0; i < 250; i++ ) { 56 | const char *s = svarlang_strid( i ); 57 | #ifdef FDISKLITE 58 | if ( i == 1 ) { 59 | continue; /* skip msg "no arg = launch interactive mode" */ 60 | } 61 | #endif 62 | if ( *s == 0 ) { 63 | continue; 64 | } 65 | if ( i == 200 ) { /* special case: COPYLEFT needs to be inserted */ 66 | con_printf( s, COPYLEFT ); 67 | con_putc( '\n' ); 68 | } 69 | else { 70 | con_puts( s ); 71 | } 72 | 73 | /* is it time for a pause? */ 74 | if ( ( flags.do_not_pause_help_information == FALSE ) && 75 | ( --linestopause <= 2 ) ) { 76 | linestopause = screenh; 77 | Pause(); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /source/fdisk/svarlang/auto_exe.c: -------------------------------------------------------------------------------- 1 | /* This file is part of the svarlang project and is published under the terms 2 | * of the MIT license. 3 | * 4 | * Copyright (C) 2021-2023 Mateusz Viste 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #include "svarlang.h" 26 | 27 | int svarlang_autoload_exepath(const char *selfexe, const char *lang) { 28 | unsigned short selflen; 29 | unsigned long self_ext_backup; 30 | unsigned long *self_ext_ptr; 31 | int res; 32 | 33 | /* validate selfexe: must be at least 5 bytes long and 4th char from end must 34 | * be a dot (like "a.exe" or "c:\b.com" or "..\..\test\run.exe") */ 35 | if (!selfexe) return(-200); 36 | for (selflen = 0; selfexe[selflen] != 0; selflen++); 37 | if ((selflen < 5) || (selfexe[selflen - 4] != '.')) return(-200); 38 | 39 | self_ext_ptr = (void *)(selfexe + selflen - 3); /* disregard CONST (I revert original content later, so the caller won't notice */ 40 | 41 | /* copy extension to buffer and replace it with "lng" */ 42 | self_ext_backup = *self_ext_ptr; 43 | 44 | *self_ext_ptr = 0x00474E4Cl; /* "LNG\0" */ 45 | 46 | /* try loading it now */ 47 | res = svarlang_load(selfexe, lang); 48 | 49 | /* restore the original filename and quit */ 50 | *self_ext_ptr = self_ext_backup; 51 | 52 | return(res); 53 | } 54 | -------------------------------------------------------------------------------- /source/fdisk/svarlang/auto_nls.c: -------------------------------------------------------------------------------- 1 | /* This file is part of the svarlang project and is published under the terms 2 | * of the MIT license. 3 | * 4 | * Copyright (C) 2021-2023 Mateusz Viste 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #include "svarlang.h" 26 | 27 | 28 | int svarlang_autoload_pathlist(const char *progname, const char *pathlist, const char *lang) { 29 | char buff[128]; 30 | unsigned short i, ii; 31 | 32 | /* read and validate LANG and pathlist */ 33 | if ((!lang) || (lang[0] == 0) || (!pathlist)) return(-1); 34 | 35 | /* look into every path in NLSPATH */ 36 | while (*pathlist != 0) { 37 | 38 | /* skip any leading ';' separators */ 39 | while (*pathlist == ';') pathlist++; 40 | 41 | if (*pathlist == 0) return(-3); 42 | 43 | /* copy nlspath to buff and remember len */ 44 | for (i = 0; (pathlist[i] != 0) && (pathlist[i] != ';'); i++) buff[i] = pathlist[i]; 45 | pathlist += i; 46 | 47 | /* add a trailing backslash if there is none (non-empty paths empty) */ 48 | if ((i > 0) && (buff[i - 1] != '\\')) buff[i++] = '\\'; 49 | 50 | /* append progname + ".LNG" to the path */ 51 | for (ii = 0; progname[ii] != 0; ii++) buff[i++] = progname[ii]; 52 | buff[i++] = '.'; 53 | buff[i++] = 'L'; 54 | buff[i++] = 'N'; 55 | buff[i++] = 'G'; 56 | buff[i] = 0; 57 | 58 | if (svarlang_load(buff, lang) == 0) return(0); 59 | } 60 | /* failed to load anything */ 61 | return(-4); 62 | } 63 | -------------------------------------------------------------------------------- /doc/fdisk/INSTALL.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | ## Building from source 4 | Free FDISK is confirmed to build with the following compilers: 5 | 6 | - Open Watcom >=v1.9 (DOS, Win32), >=v2 from 2023/07/03 (Linux) 7 | - IA16-GCC and libi86 >= 2023/07/03 (Mac) 8 | 9 | The assembler sources are verified to assemble with: 10 | 11 | - Netwide Assembler NASM version 2.15 12 | 13 | In addition, if you want to build a distribution ZIP file, the following tools 14 | must be installed: 15 | 16 | - Info-ZIP 17 | - UPX 18 | 19 | During the build process, beside the executable _fdisk.exe_, a translation 20 | file _fdisk.lng_ is created. This file contains translations for different 21 | languages. The file must be shipped along with the executable file, either 22 | in the same directory, or in a directory specified by the path variable 23 | `%NLSPATH%`. Otherwise, the software is only displayed in English. 24 | 25 | The translation sources are stored in UTF-8 encoded files in the 26 | `source/fdisk/nls` folder. During build, these files get converted to their 27 | respective DOS code-page and assembled into the _fdisk.lng_ file. 28 | 29 | The whole build process can be triggered by one command, as shown below. 30 | If you want to update the translation file without building the software, 31 | you can invoke _regen.bat_ in the `source/fdisk/nls` directory. However, 32 | you may run into problems if the translation file gets considerably larger. 33 | So whenever there is a chance, trigger the rebuild of _fdisk.lng_ via one 34 | of the given build commands. 35 | 36 | 37 | ### Building with Open Watcom 38 | Open Watcom is the preferred release tool chain. FDISK may be built by calling 39 | Watcom Make in the `source/fdisk` sub directory: 40 | ``` 41 | wmake 42 | ``` 43 | 44 | This builds _fdisk.exe_ and the translation file _fdisk.lng_ in the 45 | `source/fdisk` folder. To build a release version to get rid of the 46 | "NON-RELEASE BUILD" nag, invoke: 47 | 48 | ``` 49 | wmake RELEASE=1 50 | ``` 51 | 52 | To build a LITE release (without UI): 53 | ``` 54 | wmake RELEASE=1 LITE=1 55 | ``` 56 | 57 | You may also build the distribution ZIP file _fdisk.zip_ containing the 58 | executable, translation file, documentation and source code via: 59 | ``` 60 | wmake RELEASE=1 dist 61 | ``` 62 | 63 | ### Building with IA16-GCC 64 | Experimental support is provided for building FDISK with the IA16-GCC 65 | tool chain. To build the software under Mac or Linux, run: 66 | ``` 67 | make -f Makefile.gcc 68 | ``` 69 | 70 | This generates the _fdisk.exe_ file and the translation file _fdisk.lng_. 71 | There is no support for generating distribution ZIP files yet. 72 | 73 | 74 | -------------------------------------------------------------------------------- /source/fdisk/svarlang/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # make instructions to build svarlang and tlumacz.exe with OpenWatcom 3 | # Copyright (C) 2021-2024 Mateusz Viste 4 | # 5 | 6 | ALLBIN = svarlngs.lib svarlngc.lib svarlngm.lib svarlngl.lib tlumacz.exe 7 | all: $(ALLBIN) 8 | 9 | CFLAGS = -q -0 -wx -we -os -s 10 | 11 | # uncomment this if you prefer SvarLANG to use fopen() and friends to handle 12 | # file access instead of raw DOS calls. this might make the program larger if 13 | # it does not use FILE already, but it allows for 100% ANSI C compliancy. 14 | #CFLAGS += -DWITHSTDIO 15 | 16 | # uncomment this if you'd like to enable an assembly version of the mvcomp 17 | # depacker instead of the native C routine. This saves 27 bytes of footprint. 18 | CFLAGS += -DMVUCOMP_ASM 19 | 20 | ALLFILES = auto_exe.c auto_nls.c svarlang.c version.c 21 | 22 | 23 | svarlngs.lib: $(ALLFILES) 24 | wcc $(CFLAGS) -ms -Fo=auto_exe.obj auto_exe.c 25 | wcc $(CFLAGS) -ms -Fo=auto_nls.obj auto_nls.c 26 | wcc $(CFLAGS) -ms -Fo=svarlang.obj svarlang.c 27 | wcc $(CFLAGS) -ms -Fo=version.obj version.c 28 | if exist svarlngs.lib rm -f svarlngs.lib 29 | wlib -q -n svarlngs.lib +auto_exe.obj +auto_nls.obj +svarlang.obj +version.obj 30 | 31 | svarlngc.lib: $(ALLFILES) 32 | wcc $(CFLAGS) -mc -Fo=auto_exe.obj auto_exe.c 33 | wcc $(CFLAGS) -mc -Fo=auto_nls.obj auto_nls.c 34 | wcc $(CFLAGS) -mc -Fo=svarlang.obj svarlang.c 35 | wcc $(CFLAGS) -mc -Fo=version.obj version.c 36 | if exist svarlngc.lib rm -f svarlngc.lib 37 | wlib -q -n svarlngc.lib +auto_exe.obj +auto_nls.obj +svarlang.obj +version.obj 38 | 39 | svarlngm.lib: $(ALLFILES) 40 | wcc $(CFLAGS) -mm -Fo=auto_exe.obj auto_exe.c 41 | wcc $(CFLAGS) -mm -Fo=auto_nls.obj auto_nls.c 42 | wcc $(CFLAGS) -mm -Fo=svarlang.obj svarlang.c 43 | wcc $(CFLAGS) -mm -Fo=version.obj version.c 44 | if exist svarlngm.lib rm -f svarlngm.lib 45 | wlib -q -n svarlngm.lib +auto_exe.obj +auto_nls.obj +svarlang.obj +version.obj 46 | 47 | svarlngl.lib: $(ALLFILES) 48 | wcc $(CFLAGS) -ml -Fo=auto_exe.obj auto_exe.c 49 | wcc $(CFLAGS) -ml -Fo=auto_nls.obj auto_nls.c 50 | wcc $(CFLAGS) -ml -Fo=svarlang.obj svarlang.c 51 | wcc $(CFLAGS) -ml -Fo=version.obj version.c 52 | if exist svarlngl.lib rm -f svarlngl.lib 53 | wlib -q -n svarlngl.lib +auto_exe.obj +auto_nls.obj +svarlang.obj +version.obj 54 | 55 | release: $(ALLBIN) .symbolic 56 | if exist svarlang.zip rm -f svarlang.zip 57 | if exist svrl_src.zip rm -f svrl_src.zip 58 | zip -9rkDX svarlang.zip *.lib *.h *.txt tlumacz.exe 59 | zip -9rkDX svrl_src.zip *.c *.txt *.h makefile 60 | 61 | tlumacz.exe: tlumacz.c 62 | wcl -q -0 -y -cc -wx -mc -lr -we -ox tlumacz.c 63 | rm -f *.obj 64 | 65 | clean: .symbolic 66 | rm -f *.exe 67 | rm -f *.obj 68 | rm -f *.lib 69 | rm -f *.zip 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Free FDISK 2 | Free FDISK is a tool to manage the partitions on disks of up to 3 | 2 TiB in size using a Master Boot Record (MBR) partition table. 4 | 5 | Please note that the software is targeted at IBM-PC compatible systems running 6 | a MS-DOS like operating system, and that it has some limitations 7 | especially when dealing with newer computers. 8 | The most significant is that it can not handle disks partitioned by a 9 | GUID Partition Table (GPT), which is the default on modern UEFI enabled 10 | systems. 11 | 12 | ## Minimum Requirements 13 | - IBM-PC (8088) compatible computer with 256k RAM and disk controller 14 | - MS-DOS 3.0 compatible operating system 15 | - Monochrome (MDA, Hercules...) or color graphics adapter (CGA, EGA, VGA...) 16 | 17 | ## Running FDISK 18 | Binary packages for FDISK are provided via the Github releases page. These 19 | packages contain the executable file _FDISK.EXE_ under the _BIN_ directory. 20 | FDISK is further shipped as part of the base software collection of the 21 | FreeDOS operating system. 22 | 23 | Invoking `FDISK.EXE /?` shows a help screen with available options. 24 | 25 | The program behaviour may be further customized by editing the _FDISK.INI_ 26 | file inside the _BIN_ directory. The available options are commented in the 27 | file. 28 | 29 | FDISK is translated to multiple languages. The translations are stored in the 30 | file _FDISK.LNG_ inside the _NLS_ directory. To make FDISK find its 31 | translation file, either the environment variable _NLSPATH_ must contain 32 | the FDISK.LNG path, or the LNG file has to be copied to the directory 33 | containing FDISK.EXE. 34 | 35 | Further, the display language has to be specified via the _LANG_ environment 36 | variable, like `SET LANG=DE` to set the display language to German. 37 | 38 | If one or more of the above conditions are not met, FDISK is displayed in 39 | English. 40 | 41 | When running FDISK under FreeDOS using the FreeDOS provided FDISK 42 | package, the above should have been setup automatically by the FreeDOS 43 | installer. 44 | 45 | ## Further Documentation 46 | - [Change Log](doc/fdisk/CHANGES.md) 47 | - [Build Instructions](doc/fdisk/INSTALL.md) 48 | - [Command Line Syntax](doc/fdisk/USAGE.md) 49 | 50 | ## Copyright 51 | 52 | This program is Copyright 1998 - 2025 by Brian E. Reifsnyder and The FreeDOS 53 | Project under the terms of the GNU General Public License, version 2 or later. 54 | 55 | This program comes as-is and without warranty of any kind. The author of 56 | this software assumes no responsibility pertaining to the use or mis-use of 57 | this software. By using this software, the operator is understood to be 58 | agreeing to the terms of the above. 59 | 60 | ## Third party credits 61 | FDISK relies on the SvarLANG library for translations, created by 62 | Mateusz Viste. 63 | -------------------------------------------------------------------------------- /source/fdisk/Makefile.gcc: -------------------------------------------------------------------------------- 1 | # This Makefile is for Free FDISK and I16-GCC, Mac (probably Linux as well) 2 | 3 | HOST_CC=cc 4 | HOST_CFLAGS=-Wall -pedantic -O2 5 | 6 | CC=ia16-elf-gcc 7 | LD=ia16-elf-gcc 8 | LIBS = -li86 9 | CFLAGS = -Wall -mcmodel=small -Os 10 | 11 | NASM=nasm 12 | CP=cp 13 | 14 | FDISK_OBJS = main.o cmd.o helpscr.o compat.o pdiskio.o fdiskio.o pcompute.o \ 15 | display.o ui.o kbdinput.o ansicon.o printf.o \ 16 | svarlang/svarlang.o svarlang/auto_exe.o svarlang/auto_nls.o \ 17 | deflang.o bootnorm.o 18 | 19 | fdisk.exe : $(FDISK_OBJS) fdisk.lng 20 | $(LD) -Xlinker -Map=fdisk.map -Os -mcmodel=small -o $@ $(FDISK_OBJS) $(LIBS) 21 | 22 | bootnorm.c : bootnorm.bin bintoc/bintoc 23 | bintoc/bintoc bootnorm.bin bootnorm.c bootnormal_code 24 | 25 | bootnorm.bin : bootnorm.asm 26 | $(NASM) -f bin -o $@ $< 27 | 28 | 29 | svarlang/svarlang.o: svarlang/svarlang.c 30 | $(CC) $(CPPFLAGS) $(CFLAGS) -DWITHSTDIO -c -o $@ $< 31 | 32 | # --- translations ---------------------------------------------------------- 33 | 34 | fdisk.lng : nls/out.lng 35 | $(CP) $< $@ 36 | 37 | deflang.c : nls/deflang.c 38 | $(CP) $< $@ 39 | 40 | nls/deflang.c nls/out.lng : svarlang/tlumacz nls/en.txt nls/de.txt nls/es.txt nls/fr.txt nls/it.txt nls/pl.txt nls/tr.txt 41 | cd nls; ../svarlang/tlumacz /excref en de es fr it pl tr 42 | 43 | nls/out.lng : nls/deflang.c 44 | 45 | nls/en.txt : nls/en_utf8.txt utf8tocp/utf8tocp 46 | utf8tocp/utf8tocp 437 $< $@ 47 | 48 | nls/de.txt : nls/de_utf8.txt utf8tocp/utf8tocp 49 | utf8tocp/utf8tocp 858 $< $@ 50 | 51 | nls/es.txt : nls/es_utf8.txt utf8tocp/utf8tocp 52 | utf8tocp/utf8tocp 858 $< $@ 53 | 54 | nls/fr.txt : nls/fr_utf8.txt utf8tocp/utf8tocp 55 | utf8tocp/utf8tocp 858 $< $@ 56 | 57 | nls/it.txt : nls/it_utf8.txt utf8tocp/utf8tocp 58 | utf8tocp/utf8tocp 858 $< $@ 59 | 60 | nls/pl.txt : nls/pl_utf8.txt utf8tocp/utf8tocp 61 | utf8tocp/utf8tocp maz $< $@ 62 | 63 | nls/tr.txt : nls/tr_utf8.txt utf8tocp/utf8tocp 64 | utf8tocp/utf8tocp 857 $< $@ 65 | 66 | # --- build tools ----------------------------------------------------------- 67 | 68 | bintoc/bintoc : bintoc/bintoc.c 69 | $(HOST_CC) $(HOST_CFLAGS) -o $@ $< 70 | 71 | svarlang/tlumacz : svarlang/tlumacz.c 72 | $(HOST_CC) $(HOST_CFLAGS) -o $@ $< 73 | 74 | utf8tocp/utf8tocp : utf8tocp/utf8tocp.c 75 | $(HOST_CC) $(HOST_CFLAGS) -o $@ $< 76 | 77 | 78 | # --- clean up -------------------------------------------------------------- 79 | 80 | clean: 81 | rm -f *.o *.obj *.OBJ *.bin *.BIN 82 | rm -f *.exe 83 | rm -f *.map *.MAP 84 | rm -f fdisk.lng out.lng 85 | rm -f nls/en.txt nls/de.txt nls/out.lng nls/DEFLANG.C 86 | rm -f bintoc/bintoc bintoc/*.o 87 | rm -f bintoc/*.exe bintoc/*.obj 88 | rm -f bintoc/*.EXE bintoc/*.OBJ 89 | rm -f svarlang/tlumacz svarlang/*.o 90 | rm -f svarlang/*.exe svarlang/*.obj 91 | rm -f svarlang/*.EXE svarlang/*.OBJ 92 | rm -f utf8tocp/utf8tocp utf8tocp/*.o 93 | rm -f utf8tocp/*.exe utf8tocp/*.obj 94 | rm -f utf8tocp/*.EXE utf8tocp/*.OBJ 95 | -------------------------------------------------------------------------------- /doc/fdisk/faq.txt: -------------------------------------------------------------------------------- 1 | FAQ.TXT 2 | 3 | Frequently asked questions: 4 | 5 | 1. What does Free FDISK do? 6 | 7 | Free FDISK partitions a hard disk in order to create space for file 8 | systems. Please see http://www.fdisk.com for more information. 9 | 10 | 2. Why doesn't Free FDISK display my 8.2GB (or greater) hard disk correctly? 11 | 12 | Using a text editor, make sure that the VERSION statement in the 13 | fdisk.ini file is set to one of the following: 14 | 15 | VERSION=W95 Supports large hard disks without 16 | FAT32 partitions. 17 | VERSION=W95B Supports large hard disks with FAT32 18 | partitions. 19 | VERSION=W98 Same as VERSION=W95B 20 | 21 | Also make sure that the fdisk.ini file is located in the same 22 | directory (folder) as Free FDISK. 23 | 24 | Optionally: Set the FFD_VERSION statement in the environment to one of 25 | the versions listed above by adding a "SET" statement to the 26 | c:\autoexec.bat file. i.e. SET FFD_VERSION=W98 27 | 28 | 3. I have a monochrome monitor and there are blank areas on the screen, how 29 | do I fix this? 30 | 31 | Using a text editor, change the MONO statement in the fdisk.ini file 32 | to MONO=ON. 33 | 34 | Optionally: Set the FFD_MONO statement in the environment to ON. 35 | i.e. SET FFD_MONO=ON 36 | 37 | 4. I have Windows 95, Windows 98, or Windows 98 Second Edition and Free FDISK 38 | does not display any or all of my drives or partitions. What do I need to 39 | do to fix this problem? 40 | 41 | Using a text editor, make sure that the VERSION statement in the 42 | fdisk.ini file is set to one of the following: 43 | 44 | VERSION=W95 Supports large hard disks without 45 | FAT32 partitions. 46 | VERSION=W95B Supports large hard disks with FAT32 47 | partitions. 48 | VERSION=W98 Same as VERSION=W95B 49 | 50 | Optionally: Set the FFD_VERSION statement in the environment to one of 51 | the versions listed above by adding a "SET" statement to the 52 | c:\autoexec.bat file. i.e. SET FFD_VERSION=W98 53 | 54 | Also make sure that the fdisk.ini file is located in the same 55 | directory (folder) as Free FDISK. 56 | 57 | 7. Where can I find instructions on how to use Free FDISK? 58 | 59 | Check out the web site at http://www.fdisk.com. 60 | 61 | 6. How do I report a bug? 62 | 63 | Please send all bug reports to reifsnyderb@mindspring.com and 64 | please describe in detail exactly how to reproduce the bug. Also, 65 | please describe what hardware you are running Free FDISK on. Any 66 | bug reports with a description similar to "it doesn't work" will be 67 | deleted. 68 | 69 | Optionally, you can report a bug at http://www.freedos.org. 70 | 71 | -------------------------------------------------------------------------------- /source/fdisk/bintoc/bintoc.c: -------------------------------------------------------------------------------- 1 | /* BINTOC is published under the terms of the MIT license. 2 | * 3 | * Copyright (C) 2023 Bernd Boeckmann 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | #define LINE_ENDING "\r\n" 28 | 29 | unsigned char * 30 | read_file( const char *filename, long *filesize ) 31 | { 32 | FILE *f; 33 | unsigned char *buf; 34 | 35 | f = fopen( filename, "rb" ); 36 | if ( !f ) return NULL; 37 | 38 | fseek( f, 0, SEEK_END ); 39 | *filesize = ftell( f ); 40 | fseek( f, 0, SEEK_SET ); 41 | 42 | buf = malloc( *filesize ); 43 | if ( !buf ) return NULL; 44 | 45 | if ( fread( buf, 1, *filesize, f ) != *filesize ) { 46 | free( buf ); 47 | return NULL; 48 | } 49 | 50 | fclose( f ); 51 | return buf; 52 | } 53 | 54 | 55 | int 56 | write_data_to_c_file( const unsigned char *data, long size, 57 | const char *filename, const char *ident ) 58 | { 59 | FILE *f; 60 | long i; 61 | 62 | f = fopen( filename, "w" ); 63 | if ( !f ) return 0; 64 | 65 | fprintf( f, "const unsigned char %s[%ld] = {" LINE_ENDING, ident, size ); 66 | 67 | for ( i = 0; i < size; i++ ) { 68 | fprintf( f, "%d", data[i] ); 69 | 70 | if ( i != size - 1 ) { 71 | fputs( ",", f ); 72 | } 73 | if ( i % 16 == 15 ) { 74 | fputs( LINE_ENDING, f ); 75 | } 76 | } 77 | fprintf( f, "};" LINE_ENDING ); 78 | fclose( f ); 79 | 80 | return 1; 81 | } 82 | 83 | 84 | int 85 | main( int argc, char **argv ) 86 | { 87 | unsigned char *data; 88 | long size; 89 | 90 | (void) argc; 91 | 92 | if ( !argv[1] || !argv[2] || !argv[3] ) { 93 | return EXIT_FAILURE; 94 | } 95 | 96 | data = read_file( argv[1], &size ); 97 | if ( !data ) { 98 | return EXIT_FAILURE; 99 | } 100 | 101 | if ( !write_data_to_c_file( data, size, argv[2], argv[3] ) ) { 102 | free( data ); 103 | return EXIT_FAILURE; 104 | } 105 | 106 | free( data ); 107 | return EXIT_SUCCESS; 108 | } 109 | -------------------------------------------------------------------------------- /doc/fdisk/USAGE.md: -------------------------------------------------------------------------------- 1 | # Free FDISK Command Line Syntax 2 | ``` 3 | Syntax: FDISK [] [commands]... 4 | no argument Runs in interactive mode 5 | /INFO Displays partition information of 6 | /REBOOT Reboots the Computer 7 | 8 | Commands to create and delete partitions: 9 | is a number for megabytes or MAX for maximum size 10 | or ,100 for to be in percent 11 | is a numeric partition type or FAT-12/16/32 if /SPEC not given 12 | 13 | /PRI: [/SPEC:] Creates a primary partition 14 | /EXT: Creates an extended DOS partition 15 | /LOG: [/SPEC:] Creates a logical drive 16 | /PRIO,/EXTO,/LOGO same as above, but avoids FAT32 17 | /AUTO Automatically partitions the disk 18 | 19 | /DELETE {/PRI[:#] | /EXT | /LOG: Deletes a partition 20 | | /NUM:} ...logical drives start at /NUM=5 21 | /DELETEALL Deletes all partitions from 22 | 23 | Setting active partitions: 24 | /ACTIVATE: Sets active 25 | /DEACTIVATE Deactivates all partitions 26 | 27 | MBR (Master Boot Record) management: 28 | /CLEARMBR Deletes all partitions and boot code 29 | /LOADMBR Loads part. table and code from "boot.mbr" into MBR 30 | /SAVEMBR Saves partition table and code into file "boot.mbr" 31 | 32 | MBR code modifications leaving partitions intact: 33 | /IPL Installs the standard boot code into MBR 34 | ...same as /MBR and /CMBR for compatibility 35 | /SMARTIPL Installs DriveSmart IPL into MBR 36 | /LOADIPL Writes 440 code bytes from "boot.mbr" into MBR 37 | 38 | Advanced partition table modification: 39 | /MODIFY:, Changes partition type to 40 | ...logical drives start at "5" 41 | /MOVE:, Moves primary partitions 42 | /SWAP:<1stpart#>,<2ndpart#> Swaps primary partitions 43 | 44 | For handling flags on a hard disk: 45 | /CLEARFLAG[{:} | /ALL}] Resets or all on 46 | /SETFLAG:[,] Sets to 1 or 47 | /TESTFLAG:[,] Tests for 1 or 48 | 49 | For obtaining information about the hard disk(s): 50 | /STATUS Displays the current partition layout. 51 | /DUMP Dumps partition information from all hard disks(for debugging) 52 | 53 | Interactive user interface switches: 54 | /UI Always starts UI if given as last argument. 55 | /MONO Forces the user interface to run in monochrome mode. 56 | /FPRMT Prompts for FAT32/FAT16 in interactive mode. 57 | /XO Enables extended options. 58 | 59 | Compatibility options: 60 | /X Disables ext. INT 13 and LBA for the following commands 61 | 62 | This program is Copyright 1998 - 2023 by Brian E. Reifsnyder and 63 | The FreeDOS Project under the terms of the GNU General Public License, 64 | version 2. 65 | 66 | This program comes as-is and without warranty of any kind. The author of 67 | this software assumes no responsibility pertaining to the use or mis-use of 68 | this software. By using this software, the operator is understood to be 69 | agreeing to the terms of the above. 70 | ``` 71 | -------------------------------------------------------------------------------- /source/fdisk/svarlang/svarlang.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the svarlang project and is published under the terms 2 | * of the MIT license. 3 | * 4 | * Copyright (C) 2021-2024 Mateusz Viste 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #ifndef SVARLANG_H 26 | #define SVARLANG_H 27 | 28 | /* library version */ 29 | #define SVARLANGVER "20241010" 30 | 31 | /* returns a pointer to a string with the SvarLANG's library version, 32 | * independently of the SVARLANGVER string above. */ 33 | const char *svarlang_getver(void); 34 | 35 | /* loads lang translations from file fname. 36 | * 37 | * only the two first letters of the lang strings are meaningful and they are 38 | * case insensitive. 39 | * 40 | * a typical call would be: svarlang_load("myprog.lng", "PL"); 41 | * 42 | * this function returns 0 on success, non-zero otherwise. It is still possible 43 | * to call svarlang_strid() after a load failure, the previously loaded 44 | * language will be used then, or the default language if no loading has been 45 | * done yet. */ 46 | int svarlang_load(const char *fname, const char *lang); 47 | 48 | /* tries loading lang strings from a file located in the executable's 49 | * directory that is named like the executable but with an *.LNG extension. 50 | * this is certainly the most practical way of loading svarlang. 51 | * selfexe should point to the executable's full filename path (either relative 52 | * or absolute). You may want to pass argv[0] or __argv[0] there. example: 53 | * 54 | * svarlang_autoload_exepath(argv[0], getenv("LANG")); 55 | */ 56 | int svarlang_autoload_exepath(const char *selfexe, const char *lang); 57 | 58 | /* this looks in a list of paths separated by ';' to locate a translation file 59 | * for progname. this might be called by some FreeDOS programs that rely on the 60 | * NLSPATH environment variable for locating strings. example: 61 | * 62 | * svarlang_autoload_pathlist("myprog", getenv("NLSPATH"), getenv("LANG")); 63 | */ 64 | int svarlang_autoload_pathlist(const char *progname, const char *pathlist, const char *lang); 65 | 66 | /* Returns a pointer to the string "id". Does not require svalang_load() to be 67 | * executed, but then it will only return the reference language strings. 68 | * a string id is the concatenation of the CATS-style identifiers, for example 69 | * string 1,0 becomes 0x0100, string 2.10 is 0x020A, etc. 70 | * It NEVER returns NULL, if id not found then an empty string is returned */ 71 | const char *svarlang_strid(unsigned short id); 72 | 73 | 74 | /* a convenience definition to fetch strings by their CATS-style pairs instead 75 | * of the 16-bit id. */ 76 | #define svarlang_str(x, y) svarlang_strid((x << 8) | y) 77 | 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /source/fdisk/printf.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // \author (c) Marco Paland (info@paland.com) 3 | // 2014-2019, PALANDesign Hannover, Germany 4 | // 2023, Bernd Boeckmann, modified for FreeDOS FDISK 5 | // 6 | // \license The MIT License (MIT) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | // \brief Tiny printf, sprintf and snprintf implementation, optimized for speed on 27 | // embedded systems with a very limited resources. 28 | // Use this instead of bloated standard/newlib printf. 29 | // These routines are thread safe and reentrant. 30 | // 31 | /////////////////////////////////////////////////////////////////////////////// 32 | 33 | #ifndef _PRINTF_H_ 34 | #define _PRINTF_H_ 35 | 36 | #include 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** 44 | * Tiny printf implementation 45 | * You have to implement _putchar if you use printf() 46 | * To avoid conflicts with the regular printf() API it is overridden by macro defines 47 | * and internal underscore-appended functions like printf_() are used 48 | * \param format A string that specifies the format of the output 49 | * \return The number of characters that are written into the array, not counting the terminating null character 50 | */ 51 | int con_printf( const char *format, ... ); 52 | 53 | /** 54 | * Tiny sprintf implementation 55 | * Due to security reasons (buffer overflow) YOU SHOULD CONSIDER USING (V)SNPRINTF INSTEAD! 56 | * \param buffer A pointer to the buffer where to store the formatted string. MUST be big enough to store the output! 57 | * \param format A string that specifies the format of the output 58 | * \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character 59 | */ 60 | int con_sprintf( char *buffer, const char *format, ... ); 61 | 62 | /** 63 | * Tiny snprintf/vsnprintf implementation 64 | * \param buffer A pointer to the buffer where to store the formatted string 65 | * \param count The maximum number of characters to store in the buffer, including a terminating null character 66 | * \param format A string that specifies the format of the output 67 | * \param va A value identifying a variable arguments list 68 | * \return The number of characters that COULD have been written into the buffer, not counting the terminating 69 | * null character. A value equal or larger than count indicates truncation. Only when the returned value 70 | * is non-negative and less than count, the string has been completely written. 71 | */ 72 | int con_snprintf( char *buffer, size_t count, const char *format, ... ); 73 | int con_vsnprintf( char *buffer, size_t count, const char *format, 74 | va_list va ); 75 | 76 | /** 77 | * Tiny vprintf implementation 78 | * \param format A string that specifies the format of the output 79 | * \param va A value identifying a variable arguments list 80 | * \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character 81 | */ 82 | int con_vprintf( const char *format, va_list va ); 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif // _PRINTF_H_ 89 | -------------------------------------------------------------------------------- /source/fdisk/svarlang/svarlang.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | SVARLANG.LIB - THE SVARDOS TRANSLATION C LIBRARY 4 | 5 | Copyright (C) 2021-2024 Mateusz Viste 6 | 7 | 8 | 9 | SvarLANG is a library and toolset for enabling SvarDOS applications to easily 10 | support multiple languages. It is part of the SvarDOS project. 11 | 12 | Homepage: http://svardos.org/svarlang/ 13 | 14 | 15 | ### PREPARING TRANSLATION FILES ############################################### 16 | 17 | The translation files must be CATS-style text files in the usual format: 18 | 19 | 1.1:Hello, World! 20 | 1.2:Help screen 21 | 2.0:Type /? for more options 22 | 23 | The files must be named as EN.TXT, DE.TXT, FR.TXT, etc. Then, they must be 24 | converted into SvarLANG's binary format using the TLUMACZ tool: 25 | 26 | tlumacz en fr pl (...) 27 | 28 | The first language provided in the command line is the reference language and 29 | is used both as the default (embedded in the application) language, as well as 30 | to substitute messages missing in other languages. 31 | 32 | TLUMACZ computes two files: 33 | 34 | * OUT.LNG - the binary file that contains all translations 35 | * DEFLANG.C - the default translations that will be embedded into the program 36 | 37 | Then, DEFLANG.C must be compiled and linked to your program along with 38 | SVARLNGx.LIB. From there you will be able to use SvarLANG calls, like this 39 | very basic example: 40 | 41 | svarlang_load("myprogram.lng", "pl"); /* load PL lang from myprogram.lng */ 42 | puts(svarlang_str(2, 0)); /* display the string with id 2.0 */ 43 | 44 | A more practical, real-world example would probably be this one: 45 | 46 | svarlang_autoload_exepath(argv[0], getenv("LANG")); 47 | puts(svarlang_str(2, 0)); 48 | 49 | Read svarlang.h for more information about available functions. 50 | 51 | 52 | ### ESCAPED CHARACTERS ######################################################## 53 | 54 | Translation strings may contain some escaped characters. At this time only the 55 | following escaped characters are supported: \e \r \n \t and \\ 56 | 57 | 58 | ### DIRTY STRINGS ############################################################# 59 | 60 | In the CATS-style source translation, lines may be prefixed with a '?' sign: 61 | 62 | ?1.1:Hello, World! 63 | 64 | Such string is used by tlumacz like any other, but it is also reported on the 65 | command-line with a warning about the line being "dirty" (that is, requiring 66 | to be reviewed by a translator). 67 | 68 | 69 | ### ENVIRONMENT ############################################################### 70 | 71 | The program translation file should be named "PROGNAME.LNG", where PROGNAME 72 | is the program's name. This file should be placed in a well-known location, 73 | typically the program's own directory. 74 | 75 | The %LANG% environment variable usually defines what language should be loaded, 76 | albeit the program can just as well provide its own controls for language 77 | selection and pass this information to svarlang_load() accordingly. 78 | 79 | 80 | ### WHY IS IT BETTER THAN CATS? ############################################### 81 | 82 | The CATS library is heavier and slower, as it embeds a text-file parser. 83 | Translations also take more disk space since each language is stored in a 84 | separate file, leading to cluster waste. Finally, CATS requires default strings 85 | to be part of the application's source code, while SvarLANG keeps all strings 86 | in TXT files and embedds the default one inside the application in an automated 87 | way at compile time. 88 | 89 | There is also a licensing issue: CATS/Kitten libraries are published under the 90 | terms of a viral, corrosive license. SvarLANG, on the other hand, is published 91 | under a truly free, liberal MIT license. 92 | 93 | 94 | ### FILE FORMAT ############################################################### 95 | 96 | File = 97 | magic : Char[4] := "SvL\x1a" (ie. "SvL" followed with a 0x1a char) 98 | ; 0x1a is an end-of-file marker that prevents TYPE garbage 99 | num_strings : U16 100 | languages : array[num_languages] of Language 101 | 102 | Language = 103 | lang_id : Char[2] 104 | len_strings : U16 := SizeOf(strings) 105 | dictionary : StringDict 106 | strings : array[File.num_strings] of StringZ (possibly compressed) 107 | 108 | StringDict = 109 | elements : array[File.num_strings] of DictEntry 110 | ; sorted by DictEntry.Id 111 | 112 | DictEntry = 113 | id : U16 114 | offset : U16 115 | ; relative to Language.strings[0] 116 | 117 | StringZ = array[?] of Char ; zero-terminated string 118 | 119 | 120 | NOTE 1: All numeric values are stored in x86 (little endian) order. 121 | 122 | NOTE 2: A language with compressed strings is flagged with bit 0x8000 set in 123 | lang_id. The strings are then compressed with the MVCOMP algorithm, 124 | see https://mvcomp.sourceforge.io for more details about MVCOMP. 125 | 126 | 127 | ####################################################################### EOF ### 128 | -------------------------------------------------------------------------------- /source/fdisk/pdiskio.h: -------------------------------------------------------------------------------- 1 | #ifndef PDISKIO_H 2 | #define PDISKIO_H 3 | 4 | #define MAX_DISKS 8 5 | #define MAX_LOGICAL_DRIVES 23 6 | 7 | #define SECT_SIZE 512 8 | 9 | #define OS_UNKNOWN 0 10 | #define OS_DOS5 5 11 | #define OS_DOS7 7 12 | #define OS_WIN_ME 8 13 | #define OS_WIN_NT 32 14 | 15 | #define OEM_IBM 0x00 16 | #define OEM_DRDOS 0xee 17 | #define OEM_NOVELL 0xef 18 | #define OEM_FREEDOS 0xfd 19 | 20 | #define DLA_AUTO 0 21 | #define DLA_MSDOS 1 22 | #define DLA_DRDOS 2 /* all primary partitions first, then logicals */ 23 | 24 | extern int os_version; 25 | extern int os_version_minor; 26 | extern int os_oem; 27 | 28 | extern int os_gui_running; 29 | 30 | /* Buffers */ 31 | extern unsigned char sector_buffer[SECT_SIZE]; 32 | 33 | /* Brief partition type table buffer for computing drive letters. */ 34 | extern int brief_partition_table[MAX_DISKS][27]; 35 | 36 | /* Buffer containing drive letters. */ 37 | extern char drive_lettering_buffer[MAX_DISKS][27]; 38 | 39 | #define REL_END_SECT( p ) ( ( p ).rel_sect + ( p ).num_sect - 1 ) 40 | typedef struct Partition { 41 | int active_status; 42 | 43 | int num_type; 44 | char vol_label[13]; 45 | 46 | unsigned long start_cyl; 47 | unsigned long start_head; 48 | unsigned long start_sect; 49 | unsigned long end_cyl; /* inclusive ! */ 50 | unsigned long end_head; /* inclusive ! */ 51 | unsigned long end_sect; /* inclusive ! */ 52 | 53 | unsigned long rel_sect; 54 | unsigned long num_sect; 55 | 56 | unsigned long size_in_MB; 57 | } Partition; 58 | 59 | /* Partition Table Structure...Created 5/6/1999 */ 60 | typedef struct part_table_structure { 61 | 62 | int usable; /* true if drive is found and primary partition coud be read */ 63 | 64 | /* Hard disk Geometry */ 65 | /* total_cyl and total_head are actually not the total but the highest 66 | values as returned by BIOS (zero based!). One has to +1 to get the 67 | total count!!! */ 68 | unsigned long total_cyl; 69 | unsigned long total_head; 70 | unsigned long total_sect; 71 | 72 | int ext_int_13; 73 | int ext_int_13_version; 74 | 75 | /* Pre-computed hard disk sizes */ 76 | unsigned long disk_size_sect; 77 | unsigned long disk_size_mb; 78 | 79 | int ext_usable; /* true if extended partition is compatible */ 80 | int part_values_changed; 81 | 82 | /* Primary Partition Table */ 83 | 84 | /* Specific information that is stored in the partition table. */ 85 | 86 | struct Partition pri_part[4]; 87 | 88 | int pri_part_created[4]; 89 | /* General pre-computed information. */ 90 | unsigned long pri_free_space; 91 | 92 | /* largest free space for primary partition */ 93 | unsigned long free_start_cyl; 94 | unsigned long free_start_head; 95 | unsigned long free_start_sect; 96 | unsigned long free_end_cyl; 97 | 98 | /* Extended Partition Table */ 99 | struct Partition *ptr_ext_part; 100 | 101 | unsigned long ext_size_mb; 102 | unsigned long ext_num_sect; 103 | unsigned long ext_free_space; 104 | 105 | /* largest space for logical drive */ 106 | int log_free_loc; 107 | unsigned long log_start_cyl; 108 | unsigned long log_end_cyl; 109 | 110 | int num_of_log_drives; 111 | int num_of_non_dos_log_drives; 112 | 113 | struct Partition log_drive[MAX_LOGICAL_DRIVES]; 114 | 115 | int log_drive_created[MAX_LOGICAL_DRIVES]; 116 | 117 | int next_ext_exists[MAX_LOGICAL_DRIVES]; 118 | 119 | struct Partition next_ext[MAX_LOGICAL_DRIVES]; 120 | 121 | int size_truncated; /* true if disk size > 32-bit unsigned long */ 122 | } Partition_Table; 123 | 124 | extern Partition_Table part_table[MAX_DISKS]; 125 | 126 | void Determine_DOS_Version( void ); 127 | int Lock_Unlock_Drive( int drive_num, int lock ); 128 | int Read_Partition_Tables( void ); 129 | int Read_Physical_Sectors( int drive, long cylinder, long head, long sector, 130 | int number_of_sectors ); 131 | int Write_Partition_Tables( void ); 132 | int Write_Physical_Sectors( int drive, long cylinder, long head, long sector, 133 | int number_of_sectors ); 134 | 135 | int Determine_Drive_Letters( void ); 136 | int Num_Ext_Part( Partition_Table *pDrive ); 137 | 138 | void Check_For_INT13_Extensions( void ); 139 | void Initialize_LBA_Structures( void ); 140 | 141 | int IsRecognizedFatPartition( unsigned ); 142 | int Is_Dos_Part( int part_type ); 143 | int Is_Ext_Part( int num_type ); 144 | int Is_Supp_Ext_Part( int num_tyoe ); 145 | int Is_Pri_Tbl_Empty( void ); 146 | 147 | /* sets all partition values to zero */ 148 | void Clear_Partition( Partition *p ); 149 | void Copy_Partition( Partition *dst, Partition *src ); 150 | int Delete_EMBR_Chain_Node( Partition_Table *pDrive, 151 | int logical_drive_number ); 152 | 153 | /* LBA<->CHS conversion functions */ 154 | void lba_to_chs( unsigned long lba_value, Partition_Table *pDrive, 155 | unsigned long *cyl, unsigned long *head, 156 | unsigned long *sect ); 157 | unsigned long chs_to_lba( Partition_Table *pDrive, unsigned long cylinder, 158 | unsigned long head, unsigned long sector ); 159 | 160 | void Clear_Sector_Buffer( void ); 161 | void Clear_Extended_Partition_Table( Partition_Table *pDrive ); 162 | 163 | unsigned long Convert_Cyl_To_MB( unsigned long num_cyl, 164 | unsigned long total_heads, 165 | unsigned long total_sect ); 166 | unsigned long Convert_Sect_To_MB( unsigned long num_sect ); 167 | unsigned long Convert_To_Percentage( unsigned long small_num, 168 | unsigned long large_num ); 169 | 170 | #endif /* PDISKIO_H */ 171 | -------------------------------------------------------------------------------- /source/fdisk/main.h: -------------------------------------------------------------------------------- 1 | #ifdef FDISKLITE 2 | #define FD_NAME "Free FDISK (command line only)" 3 | #else 4 | #define FD_NAME "Free FDISK" 5 | #endif 6 | 7 | #define VERSION "1.4.4" 8 | #define COPYLEFT "1998 - 2025" 9 | 10 | #define SIZE_OF_IPL ( 512 - 4 * 16 - 2 - 6 ) 11 | 12 | #define EMULATED_CYLINDERS 15000 13 | //#define EMULATED_CYLINDERS 784 14 | #define EMULATED_HEADS 255 15 | #define EMULATED_SECTORS 63 16 | /* ***** The above 3 values are the physical */ 17 | /* ***** attributes of an emulated hard disk */ 18 | /* ***** See the fdisk.ini file for */ 19 | /* ***** instructions on how to enable this */ 20 | /* ***** feature. */ 21 | 22 | /* 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // types 25 | ///////////////////////////////////////////////////////////////////////////// 26 | */ 27 | 28 | typedef unsigned long ulong; 29 | typedef unsigned int uint; 30 | typedef unsigned short ushort; 31 | typedef unsigned char uchar; 32 | typedef unsigned long _u32; 33 | typedef unsigned short _u16; 34 | typedef unsigned char _u8; 35 | 36 | /* 37 | ///////////////////////////////////////////////////////////////////////////// 38 | // DEFINES 39 | ///////////////////////////////////////////////////////////////////////////// 40 | */ 41 | 42 | #define READ 2 43 | 44 | #define TRUE 1 45 | #define FALSE 0 46 | 47 | #define UNCHANGED 220 48 | #define UNUSED 99 49 | 50 | #define COMP_FOUR 4 51 | #define COMP_FIVE 5 52 | #define COMP_SIX 6 53 | #define COMP_W95 7 54 | #define COMP_W95B 8 55 | #define COMP_W98 9 56 | #define COMP_FD 10 57 | 58 | #define MEG 1048576 59 | 60 | #define PRIMARY 1 61 | #define EXTENDED 2 62 | #define LOGICAL 3 63 | #define SPECIAL 4 64 | 65 | #define LAST 99 66 | 67 | #define PERCENTAGE 1 68 | 69 | #define STANDARD 0 70 | #define TECHNICAL 1 71 | 72 | #define BOLD 1 73 | 74 | #define INTERNAL 0 75 | #define EXTERNAL 1 76 | 77 | #define NOEXTRAS 50 78 | 79 | /* Definitions for the menus */ 80 | #define MM 0x00 /* Main Menu */ 81 | 82 | #define CP 0x10 /* Create PDP or LDD */ 83 | 84 | #define CPDP 0x11 /* Create Primary DOS Partition */ 85 | #define CEDP 0x12 /* Create Extended DOS Partition */ 86 | #define CLDD 0x13 /* Create Logical DOS Drive */ 87 | 88 | #define SAP 0x20 /* Set Active Partition */ 89 | 90 | #define DP 0x30 /* Delete partition or LDD */ 91 | 92 | #define DPDP 0x31 /* Delete Primary DOS Partition */ 93 | #define DEDP 0x32 /* Delete Extended DOS Partition */ 94 | #define DLDD 0x33 /* Delete Logical DOS Drive */ 95 | #define DNDP 0x34 /* Delete Non-DOS Partition */ 96 | 97 | #define DPI 0x40 /* Display Partition Information */ 98 | 99 | #define CD 0x50 /* Change Drive */ 100 | 101 | #define MBR 0x60 /* MBR Functions */ 102 | 103 | #define BMBR 0x61 /* Write standard MBR to drive */ 104 | #define AMBR 0x62 /* Write booteasy MBR to drive */ 105 | #define SMBR 0x63 /* Save MBR to file */ 106 | #define RMBR 0x64 /* Remove MBR from disk */ 107 | 108 | #define EXIT 0x0f /* Code to Exit from Program */ 109 | 110 | #ifdef MAIN 111 | #define MEXTERN 112 | #else 113 | #define MEXTERN extern 114 | #endif 115 | 116 | #include "pdiskio.h" 117 | 118 | /* 119 | ///////////////////////////////////////////////////////////////////////////// 120 | // GLOBAL VARIABLES 121 | ///////////////////////////////////////////////////////////////////////////// 122 | */ 123 | 124 | MEXTERN char filename[256]; 125 | MEXTERN char path[256]; 126 | 127 | MEXTERN int number_of_command_line_options; 128 | 129 | /* 130 | ///////////////////////////////////////////////////////////////////////////// 131 | // GLOBAL STRUCTURES 132 | ///////////////////////////////////////////////////////////////////////////// 133 | */ 134 | 135 | /* Command Line Argument Structure */ 136 | typedef struct arg_structure { 137 | char choice[15]; 138 | unsigned long value; 139 | unsigned int extra_value; 140 | } Arg_Structure; 141 | 142 | /* Flags Structure...Created 5/27/1999 */ 143 | typedef struct flags_structure { 144 | 145 | char language[12]; 146 | 147 | int align_4k; 148 | int allow_4gb_fat16; 149 | int allow_abort; 150 | int del_non_dos_log_drives; 151 | int display_name_description_copyright; 152 | int using_default_drive_number; 153 | int check_for_extra_cylinder; 154 | int do_not_pause_help_information; 155 | int dla; 156 | int drive_number; 157 | int esc; 158 | int extended_options_flag; 159 | ulong flag_sector; 160 | int fprmt; 161 | int fat32; 162 | int lba_marker; // write LBA marker 1023/254/63 if cylinder >1023 163 | int monochrome; 164 | int maximum_drive_number; 165 | int more_than_one_drive; 166 | int no_ipl; 167 | int partitions_have_changed; 168 | int partition_type_lookup_table; 169 | int reboot; 170 | int return_from_iui; 171 | int set_any_pri_part_active; 172 | int total_number_hard_disks; 173 | int version; 174 | int use_ambr; 175 | int use_extended_int_13; 176 | int use_iui; 177 | 178 | int verbose; // more output 179 | int quiet; // less output 180 | unsigned char screen_color; 181 | } Flags; 182 | 183 | /* User Defined C/H/S Settings Structure */ 184 | typedef struct user_defined_chs_settings_structure { 185 | int defined; 186 | unsigned long total_cylinders; 187 | unsigned long total_heads; 188 | unsigned long total_sectors; 189 | } User_Defined_CHS_Settings; 190 | 191 | MEXTERN Arg_Structure arg[20]; 192 | MEXTERN Flags flags; 193 | MEXTERN User_Defined_CHS_Settings user_defined_chs_settings[MAX_DISKS]; 194 | 195 | int Get_Options( char *arguments[], int number_of_arguments ); 196 | 197 | void Reboot_PC( void ); 198 | -------------------------------------------------------------------------------- /source/fdisk/test.c: -------------------------------------------------------------------------------- 1 | #include "compat.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | typedef unsigned long ulong; 11 | typedef unsigned int uint; 12 | typedef unsigned char uchar; 13 | 14 | struct driveParameter { 15 | ulong max_cylinder; 16 | uint heads; 17 | uint sectors; 18 | ulong max_sector; 19 | }; 20 | 21 | int getDriveParameters( int hd, struct driveParameter *dp ) 22 | { 23 | union REGS ir; 24 | 25 | memset( dp, 0, sizeof( *dp ) ); 26 | 27 | ir.h.ah = 0x08; 28 | ir.h.dl = hd | 0x80; 29 | int86( 0x13, &ir, &ir ); 30 | 31 | if ( ir.x.cflag ) { 32 | return ir.h.ah; 33 | } 34 | 35 | dp->max_cylinder = ( ( ir.h.cl >> 6 ) << 8 ) | ir.h.cl; 36 | dp->heads = ir.h.dh; 37 | dp->sectors = ir.h.cl & 0x3f; 38 | 39 | return 0; 40 | } 41 | 42 | #define READ 2 43 | #define WRITE 3 44 | 45 | int ReadWrite_Physical_Sectors_CHS( int drive, int cylinder, int head, 46 | int sector, int number_of_sectors, 47 | void *sector_buffer, int read_or_write ) 48 | { 49 | int error_code; 50 | 51 | error_code = 52 | biosdisk( read_or_write, drive | 0x80, (int)head, (int)cylinder, 53 | (int)sector, number_of_sectors, sector_buffer ); 54 | 55 | return ( error_code ); 56 | } 57 | 58 | struct part_entry { 59 | char bootable; 60 | char chs_start[3]; 61 | char partitiontype; 62 | char chs_end[3]; 63 | ulong start_sect; 64 | ulong num_sect; 65 | }; 66 | 67 | void dump_MBR( char *buffer ) 68 | { 69 | int i; 70 | struct part_entry *P; 71 | 72 | for ( i = 0; i < 4; i++ ) { 73 | P = (struct part_entry *)( buffer + 0x1be + 16 * i ); 74 | 75 | if ( P->partitiontype ) { 76 | printf( "%d: 0x%02x %s sect %8lu-%-8lu size %8lu\n", i, 77 | P->partitiontype, P->bootable == '\x80' ? "A" : " ", 78 | P->start_sect, P->start_sect + P->num_sect - 1, 79 | P->num_sect ); 80 | } 81 | } 82 | printf( "\n" ); 83 | } 84 | 85 | void set_partition_size( int partno, ulong sectorcount, int HD ) 86 | { 87 | char buffer[4096]; 88 | struct part_entry *P; 89 | int error; 90 | 91 | if ( ( error = ReadWrite_Physical_Sectors_CHS( HD, 0, 0, 1, 1, buffer, 92 | READ ) ) != 0 ) { 93 | printf( "error %u reading HD %u\n", error, HD ); 94 | exit( 1 ); 95 | } 96 | 97 | // dump_MBR(buffer); 98 | 99 | if ( partno >= 0 && partno <= 3 ) { 100 | P = (struct part_entry *)( buffer + 0x1be + 16 * partno ); 101 | 102 | P->num_sect = sectorcount; 103 | } 104 | else { 105 | printf( "partno (%u) must be 0..3\n", partno ), exit( 1 ); 106 | } 107 | 108 | dump_MBR( buffer ); 109 | printf( "\n" ); 110 | 111 | if ( ( error = ReadWrite_Physical_Sectors_CHS( HD, 0, 0, 1, 1, buffer, 112 | WRITE ) ) != 0 ) { 113 | printf( "error %u writing HD %u\n", error, HD ); 114 | exit( 1 ); 115 | } 116 | 117 | exit( 0 ); 118 | } 119 | 120 | int check_partition_table( int HD ) 121 | { 122 | 123 | char buffer[4096]; 124 | struct part_entry *Pi, *Pj; 125 | int i, j, error; 126 | 127 | if ( ( error = ReadWrite_Physical_Sectors_CHS( HD, 0, 0, 1, 1, buffer, 128 | READ ) ) != 0 ) { 129 | printf( "error %u reading HD %u\n", error, HD ); 130 | exit( 1 ); 131 | } 132 | 133 | dump_MBR( buffer ); 134 | printf( "\n" ); 135 | 136 | // check for partition overlap 137 | 138 | for ( i = 0; i < 4; i++ ) { 139 | for ( j = 0; j < 4; j++ ) { 140 | if ( i == j ) { 141 | continue; 142 | } 143 | 144 | Pi = (struct part_entry *)( buffer + 0x1be + 16 * i ); 145 | Pj = (struct part_entry *)( buffer + 0x1be + 16 * j ); 146 | 147 | if ( Pi->start_sect <= Pj->start_sect && 148 | Pi->start_sect + Pi->num_sect > Pj->start_sect ) { 149 | printf( "Houston, we have a problem: %d and %d overlap\n", i, j ); 150 | dump_MBR( buffer ); 151 | 152 | { 153 | struct driveParameter dP; 154 | 155 | getDriveParameters( HD, &dP ); 156 | printf( " heads %u sectors %u sectors_per_cyl %u\n", dP.heads, 157 | dP.sectors, ( dP.heads + 1 ) * dP.sectors ); 158 | } 159 | 160 | exit( 1 ); 161 | } 162 | } 163 | } 164 | 165 | exit( 0 ); 166 | 167 | return 0; 168 | } 169 | 170 | int main( int argc, char *argv[] ) 171 | { 172 | int i; 173 | int HD = 0; 174 | uint partno; 175 | ulong sectorcount; 176 | 177 | argc--, argv++; 178 | 179 | for ( i = 0; i < argc; i++ ) { 180 | strupr( argv[i] ); 181 | } 182 | 183 | if ( memcmp( argv[0], "/SETSIZE", 8 ) == 184 | 0 ) /* /SETSIZE:partno:sectorcount:harddisk */ 185 | { 186 | if ( argc >= 4 && sscanf( argv[1], "%u", &partno ) == 1 && 187 | sscanf( argv[2], "%lu", §orcount ) == 1 && 188 | sscanf( argv[3], "%u", &HD ) == 1 ) { 189 | 190 | printf( "SETSIZE:partition %u sectors %lu disk %u \n", partno, 191 | sectorcount, HD ); 192 | 193 | set_partition_size( partno, sectorcount, HD ); 194 | 195 | exit( 0 ); 196 | } 197 | else { 198 | printf( "/SETSIZE:partion(0..3):sectorcount:harddisk(0..7)\n" ); 199 | 200 | exit( 1 ); 201 | } 202 | exit( 0 ); 203 | } 204 | 205 | else if ( memcmp( argv[0], "/CHECK", 6 ) == 0 ) /* /CHECK harddisk */ 206 | { 207 | if ( argc >= 2 && sscanf( argv[1], "%u", &HD ) == 1 ) { 208 | check_partition_table( HD ); 209 | 210 | exit( 0 ); 211 | } 212 | else { 213 | printf( "/CHECK harddisk(0..7)\n" ); 214 | 215 | exit( 1 ); 216 | } 217 | exit( 0 ); 218 | } 219 | 220 | printf( "?? %u:%u:%lu\n", partno, sectorcount, HD ); 221 | 222 | printf( "usage: /SETSIZE partion(0..3) sectorcount harddisk(0..7)\n" ); 223 | printf( " /CHECK harddisk(0..7)\n" ); 224 | 225 | return 0; 226 | } 227 | -------------------------------------------------------------------------------- /source/fdisk/Makefile: -------------------------------------------------------------------------------- 1 | # MAKEFILE FOR Free FDISK 2 | # This file is for Open Watcom 1.9 (DOS or Win32) 3 | # 4 | # Created by Bernd Boeckmann 5 | # 6 | # Additional tools needed to build 7 | # - NASM (tested with version 2.0.15) 8 | # 9 | # Build with: 10 | # wmake -f makefile.wat 11 | # 12 | # To create a ZIP distribution: 13 | # wmake -f makefile.wat dist 14 | 15 | TOOL_CFLAGS = -q -ox -wx 16 | !ifdef __MSDOS__ 17 | TOOL_CC = wcc 18 | TOOL_CFLAGS += -ml 19 | !else 20 | TOOL_CC = wcc386 21 | !endif 22 | 23 | CC = wcc 24 | CFLAGS = -q -0 -bt=dos -wx -we 25 | !ifdef __UNIX__ 26 | CFLAGS += -i=$(%WATCOM)/h 27 | !endif 28 | 29 | AS = nasm 30 | ASFLAGS = -t -f obj 31 | LD = wlink 32 | LDFLAGS = 33 | !ifdef __UNIX__ 34 | SEP=/ 35 | CP = cp 36 | MV = mv 37 | BINTOC = bintoc/bintoc.exe 38 | UTF8TOCP = utf8tocp/utf8tocp.exe 39 | TLUMACZ = ../svarlang/tlumacz.exe 40 | !else 41 | SEP=\ 42 | CP = copy 43 | MV = rename 44 | BINTOC = bintoc\bintoc.exe 45 | UTF8TOCP = utf8tocp\utf8tocp.exe 46 | TLUMACZ = ..\svarlang\tlumacz.exe 47 | !endif 48 | 49 | PACKER = upx 50 | PACKERFLAGS = -qq --best --8086 51 | 52 | 53 | !ifdef DEBUG 54 | CFLAGS += -d2 -mm 55 | !else 56 | CFLAGS += -os -s -ms 57 | !endif 58 | 59 | !ifdef RELEASE 60 | CFLAGS += -DRELEASE=$(RELEASE) 61 | !endif 62 | 63 | objs = main.obj cmd.obj fdiskio.obj pdiskio.obj pcompute.obj compat.obj 64 | objs += helpscr.obj display.obj 65 | objs += 66 | !ifdef LITE 67 | CFLAGS += -DFDISKLITE=1 68 | !else 69 | objs += ui.obj kbdinput.obj 70 | !endif 71 | objs += ansicon.obj printf.obj bootnorm.obj 72 | objs += svarlang.obj auto_exe.obj auto_nls.obj deflang.obj 73 | 74 | !ifdef SMART_MBR 75 | CFLAGS += -DSMART_MBR=1 76 | objs += smartmbr.obj 77 | !endif 78 | 79 | .erase 80 | 81 | all : fdisk.exe 82 | dist : ../../fdisk.zip 83 | dist-svardos: ../../fdisk.svp 84 | 85 | .c.obj : .AUTODEPEND 86 | $(CC) $(CFLAGS) -fo=$*.obj $*.c 87 | 88 | 89 | # --- FDISK ----------------------------------------------------------------- 90 | 91 | fdisk.exe : $(objs) fdisk.lng fdisk.lnk 92 | $(LD) $(LDFLAGS) @fdisk.lnk 93 | 94 | fdisk.lnk : Makefile 95 | @echo NAME $^& >$^@ 96 | @echo SYSTEM DOS >>$^@ 97 | @echo OPTION QUIET >>$^@ 98 | @echo OPTION MAP >>$^@ 99 | !ifdef DEBUG 100 | @echo DEBUG ALL >>$^@ 101 | !endif 102 | @for %i in ($(objs)) do @echo FILE %i >>$^@ 103 | 104 | ../../fdisk.zip : fdisk.exe 105 | -rm -f ../../bin/fdisk.exe 106 | -rm -f ../../fdisk.zip 107 | $(CP) fdisk.exe ..$(SEP)..$(SEP)bin 108 | -rm -f ../../nls/fdisk.lng 109 | -mkdir ..$(SEP)..$(SEP)nls 110 | $(CP) fdisk.lng ..$(SEP)..$(SEP)nls 111 | $(PACKER) $(PACKERFLAGS) ../../bin/fdisk.exe 112 | cd ../.. 113 | zip -9rkDX fdisk.zip -@ < source/fdisk/zipfiles.txt 114 | cd source/fdisk 115 | 116 | ../../fdisk.svp : ../../fdisk.zip 117 | cd ../.. 118 | mkdir svardos 119 | mkdir svardos$(SEP)bin 120 | mkdir svardos$(SEP)appinfo 121 | mkdir svardos$(SEP)doc 122 | mkdir svardos$(SEP)doc$(SEP)fdisk 123 | $(CP) appinfo$(SEP)fdisk.lsm svardos$(SEP)appinfo$(SEP)fdisk.lsm 124 | $(CP) bin$(SEP)fdisk.exe svardos$(SEP)bin 125 | $(CP) nls$(SEP)fdisk.lng svardos$(SEP)bin 126 | $(CP) doc$(SEP)fdisk$(SEP)CHANGES.md svardos$(SEP)doc$(SEP)fdisk$(SEP)CHANGES.MD 127 | $(CP) doc$(SEP)fdisk$(SEP)contrib.txt svardos$(SEP)doc$(SEP)fdisk$(SEP)CONTRIB.TXT 128 | $(CP) LICENSE svardos$(SEP)doc$(SEP)fdisk$(SEP)LICENSE 129 | cd svardos 130 | zip -9rkDX ..$(SEP)fdisk.svp bin$(SEP)fdisk.exe bin$(SEP)fdisk.lng appinfo doc 131 | cd ../source/fdisk 132 | 133 | # --- SVARLANG -------------------------------------------------------------- 134 | 135 | svarlang.obj : svarlang/svarlang.c 136 | *$(CC) $(CFLAGS) -DWITHSTDIO -fo=$^@ $[@ 137 | 138 | auto_exe.obj : svarlang/auto_exe.c 139 | *$(CC) $(CFLAGS) -fo=$^@ $[@ 140 | 141 | auto_nls.obj : svarlang/auto_nls.c 142 | *$(CC) $(CFLAGS) -fo=$^@ $[@ 143 | 144 | # --- BOOTLOADER ------------------------------------------------------------ 145 | 146 | bootnorm.bin : bootnorm.asm 147 | $(AS) bootnorm.asm -o bootnorm.bin 148 | 149 | bootnorm.c : bintoc/bintoc.exe bootnorm.bin 150 | $(BINTOC) bootnorm.bin bootnorm.c bootnormal_code 151 | 152 | 153 | # --- NLS ------------------------------------------------------------------- 154 | 155 | nls/out.lng : svarlang/tlumacz.exe nls/en.txt nls/de.txt nls/es.txt nls/fr.txt nls/it.txt nls/pl.txt nls/tr.txt 156 | @cd nls 157 | $(TLUMACZ) /excref en de es fr it pl tr 158 | @cd .. 159 | 160 | fdisk.lng : nls/out.lng 161 | $(CP) $[@ $^@ 162 | 163 | deflang.c : nls/out.lng 164 | $(CP) nls$(SEP)deflang.c deflang.c 165 | 166 | nls/en.txt : nls/en_utf8.txt utf8tocp/utf8tocp.exe 167 | $(UTF8TOCP) 437 $[@ $^@ 168 | 169 | nls/es.txt : nls/es_utf8.txt utf8tocp/utf8tocp.exe 170 | $(UTF8TOCP) 850 $[@ $^@ 171 | 172 | nls/de.txt : nls/de_utf8.txt utf8tocp/utf8tocp.exe 173 | $(UTF8TOCP) 850 $[@ $^@ 174 | 175 | nls/fr.txt : nls/fr_utf8.txt utf8tocp/utf8tocp.exe 176 | $(UTF8TOCP) 850 $[@ $^@ 177 | 178 | nls/it.txt : nls/it_utf8.txt utf8tocp/utf8tocp.exe 179 | $(UTF8TOCP) 850 $[@ $^@ 180 | 181 | nls/pl.txt : nls/pl_utf8.txt utf8tocp/utf8tocp.exe 182 | $(UTF8TOCP) maz $[@ $^@ 183 | 184 | nls/tr.txt : nls/tr_utf8.txt utf8tocp/utf8tocp.exe 185 | $(UTF8TOCP) 857 $[@ $^@ 186 | 187 | 188 | # --- TOOLS ----------------------------------------------------------------- 189 | 190 | bintoc/bintoc.obj : bintoc/bintoc.c 191 | $(TOOL_CC) $(TOOL_CFLAGS) -fo=$@ $< 192 | 193 | bintoc/bintoc.exe : bintoc/bintoc.obj 194 | $(LD) option quiet name $@ file $< 195 | 196 | svarlang/tlumacz.obj : svarlang/tlumacz.c 197 | $(TOOL_CC) $(TOOL_CFLAGS) -fo=$@ $< 198 | 199 | svarlang/tlumacz.exe : svarlang/tlumacz.obj 200 | $(LD) option quiet name $@ file $< 201 | 202 | utf8tocp/utf8tocp.obj : utf8tocp/utf8tocp.c 203 | $(TOOL_CC) $(TOOL_CFLAGS) -fo=$@ $< 204 | 205 | utf8tocp/utf8tocp.exe : utf8tocp/utf8tocp.obj 206 | $(LD) option quiet name $@ file $< 207 | 208 | 209 | # --- CLEANUP --------------------------------------------------------------- 210 | 211 | clean : .SYMBOLIC 212 | rm -f bootnorm.c 213 | rm -f *.obj 214 | rm -f fdisk.lnk 215 | 216 | clobber : .SYMBOLIC 217 | rm -f *.bak 218 | rm -f *.bin 219 | rm -f *.err 220 | rm -f *.exe 221 | rm -f *.lnk 222 | rm -f *.lst 223 | rm -f *.map 224 | rm -f *.obj 225 | rm -f *.tmp 226 | rm -f *.zip 227 | rm -f *.svp 228 | rm -f *.map 229 | rm -f *.o 230 | rm -f bintoc/bintoc 231 | rm -f bintoc/*.exe 232 | rm -f bintoc/*.obj 233 | rm -f bintoc/*.o 234 | rm -f svarlang/tlumacz 235 | rm -f svarlang/*.exe 236 | rm -f svarlang/*.obj 237 | rm -f svarlang/*.obj 238 | rm -f utf8tocp/utf8tocp 239 | rm -f utf8tocp/*.exe 240 | rm -f utf8tocp/*.obj 241 | rm -f utf8tocp/*.o 242 | 243 | # language files 244 | rm -f deflang.c 245 | rm -f fdisk.lng 246 | rm -f nls/??.txt 247 | rm -f nls/deflang.c 248 | rm -f nls/out.lng 249 | -------------------------------------------------------------------------------- /source/fdisk/clangfmt.cfg: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | # BasedOnStyle: LLVM 4 | AccessModifierOffset: -2 5 | AlignAfterOpenBracket: Align 6 | AlignArrayOfStructures: None 7 | AlignConsecutiveAssignments: 8 | Enabled: false 9 | AcrossEmptyLines: false 10 | AcrossComments: false 11 | AlignCompound: false 12 | PadOperators: true 13 | AlignConsecutiveBitFields: 14 | Enabled: false 15 | AcrossEmptyLines: false 16 | AcrossComments: false 17 | AlignCompound: false 18 | PadOperators: false 19 | AlignConsecutiveDeclarations: 20 | Enabled: false 21 | AcrossEmptyLines: false 22 | AcrossComments: false 23 | AlignCompound: false 24 | PadOperators: false 25 | AlignConsecutiveMacros: 26 | Enabled: true 27 | AcrossEmptyLines: false 28 | AcrossComments: false 29 | AlignCompound: false 30 | PadOperators: false 31 | AlignEscapedNewlines: Right 32 | AlignOperands: Align 33 | AlignTrailingComments: true 34 | AllowAllArgumentsOnNextLine: true 35 | AllowAllParametersOfDeclarationOnNextLine: true 36 | AllowShortEnumsOnASingleLine: true 37 | AllowShortBlocksOnASingleLine: Never 38 | AllowShortCaseLabelsOnASingleLine: false 39 | AllowShortFunctionsOnASingleLine: All 40 | AllowShortLambdasOnASingleLine: All 41 | AllowShortIfStatementsOnASingleLine: Never 42 | AllowShortLoopsOnASingleLine: false 43 | AlwaysBreakAfterDefinitionReturnType: None 44 | AlwaysBreakAfterReturnType: None 45 | AlwaysBreakBeforeMultilineStrings: false 46 | AlwaysBreakTemplateDeclarations: MultiLine 47 | AttributeMacros: 48 | - __capability 49 | BinPackArguments: true 50 | BinPackParameters: true 51 | BraceWrapping: 52 | AfterCaseLabel: false 53 | AfterClass: false 54 | AfterControlStatement: Never 55 | AfterEnum: false 56 | AfterFunction: true 57 | AfterNamespace: false 58 | AfterObjCDeclaration: false 59 | AfterStruct: false 60 | AfterUnion: false 61 | AfterExternBlock: false 62 | BeforeCatch: false 63 | BeforeElse: false 64 | BeforeLambdaBody: false 65 | BeforeWhile: false 66 | IndentBraces: false 67 | SplitEmptyFunction: true 68 | SplitEmptyRecord: true 69 | SplitEmptyNamespace: true 70 | BreakBeforeBinaryOperators: None 71 | BreakBeforeConceptDeclarations: Always 72 | BreakBeforeBraces: Stroustrup 73 | BreakBeforeInheritanceComma: false 74 | BreakInheritanceList: BeforeColon 75 | BreakBeforeTernaryOperators: true 76 | BreakConstructorInitializersBeforeComma: false 77 | BreakConstructorInitializers: BeforeColon 78 | BreakAfterJavaFieldAnnotations: false 79 | BreakStringLiterals: false 80 | ColumnLimit: 78 81 | CommentPragmas: '^ IWYU pragma:' 82 | QualifierAlignment: Leave 83 | CompactNamespaces: false 84 | ConstructorInitializerIndentWidth: 3 85 | ContinuationIndentWidth: 3 86 | Cpp11BracedListStyle: true 87 | DeriveLineEnding: false 88 | DerivePointerAlignment: false 89 | DisableFormat: false 90 | EmptyLineAfterAccessModifier: Never 91 | EmptyLineBeforeAccessModifier: LogicalBlock 92 | ExperimentalAutoDetectBinPacking: false 93 | PackConstructorInitializers: BinPack 94 | BasedOnStyle: '' 95 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 96 | AllowAllConstructorInitializersOnNextLine: true 97 | FixNamespaceComments: true 98 | ForEachMacros: 99 | - foreach 100 | - Q_FOREACH 101 | - BOOST_FOREACH 102 | IfMacros: 103 | - KJ_IF_MAYBE 104 | IncludeBlocks: Preserve 105 | IncludeCategories: 106 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 107 | Priority: 2 108 | SortPriority: 0 109 | CaseSensitive: false 110 | - Regex: '^(<|"(gtest|gmock|isl|json)/)' 111 | Priority: 3 112 | SortPriority: 0 113 | CaseSensitive: false 114 | - Regex: '.*' 115 | Priority: 1 116 | SortPriority: 0 117 | CaseSensitive: false 118 | IncludeIsMainRegex: '(Test)?$' 119 | IncludeIsMainSourceRegex: '' 120 | IndentAccessModifiers: false 121 | IndentCaseLabels: false 122 | IndentCaseBlocks: false 123 | IndentGotoLabels: true 124 | IndentPPDirectives: None 125 | IndentExternBlock: AfterExternBlock 126 | IndentRequiresClause: true 127 | IndentWidth: 3 128 | IndentWrappedFunctionNames: false 129 | InsertBraces: true 130 | InsertTrailingCommas: None 131 | JavaScriptQuotes: Leave 132 | JavaScriptWrapImports: true 133 | KeepEmptyLinesAtTheStartOfBlocks: true 134 | LambdaBodyIndentation: Signature 135 | MacroBlockBegin: '' 136 | MacroBlockEnd: '' 137 | MaxEmptyLinesToKeep: 1 138 | NamespaceIndentation: None 139 | ObjCBinPackProtocolList: Auto 140 | ObjCBlockIndentWidth: 2 141 | ObjCBreakBeforeNestedBlockParam: true 142 | ObjCSpaceAfterProperty: false 143 | ObjCSpaceBeforeProtocolList: true 144 | PenaltyBreakAssignment: 2 145 | PenaltyBreakBeforeFirstCallParameter: 19 146 | PenaltyBreakComment: 300 147 | PenaltyBreakFirstLessLess: 120 148 | PenaltyBreakOpenParenthesis: 0 149 | PenaltyBreakString: 1000 150 | PenaltyBreakTemplateDeclaration: 10 151 | PenaltyExcessCharacter: 1000000 152 | PenaltyReturnTypeOnItsOwnLine: 60 153 | PenaltyIndentedWhitespace: 0 154 | PointerAlignment: Right 155 | PPIndentWidth: -1 156 | ReferenceAlignment: Pointer 157 | ReflowComments: false 158 | RemoveBracesLLVM: false 159 | RequiresClausePosition: OwnLine 160 | SeparateDefinitionBlocks: Leave 161 | ShortNamespaceLines: 1 162 | SortIncludes: CaseSensitive 163 | SortJavaStaticImport: Before 164 | SortUsingDeclarations: true 165 | SpaceAfterCStyleCast: false 166 | SpaceAfterLogicalNot: false 167 | SpaceAfterTemplateKeyword: true 168 | SpaceBeforeAssignmentOperators: true 169 | SpaceBeforeCaseColon: false 170 | SpaceBeforeCpp11BracedList: false 171 | SpaceBeforeCtorInitializerColon: true 172 | SpaceBeforeInheritanceColon: true 173 | SpaceBeforeParens: ControlStatements 174 | SpaceBeforeParensOptions: 175 | AfterControlStatements: true 176 | AfterForeachMacros: true 177 | AfterFunctionDefinitionName: false 178 | AfterFunctionDeclarationName: false 179 | AfterIfMacros: true 180 | AfterOverloadedOperator: false 181 | AfterRequiresInClause: false 182 | AfterRequiresInExpression: false 183 | BeforeNonEmptyParentheses: false 184 | SpaceAroundPointerQualifiers: Default 185 | SpaceBeforeRangeBasedForLoopColon: true 186 | SpaceInEmptyBlock: false 187 | SpaceInEmptyParentheses: false 188 | SpacesBeforeTrailingComments: 1 189 | SpacesInAngles: Never 190 | SpacesInConditionalStatement: false 191 | SpacesInContainerLiterals: true 192 | SpacesInCStyleCastParentheses: false 193 | SpacesInLineCommentPrefix: 194 | Minimum: 1 195 | Maximum: -1 196 | SpacesInParentheses: true 197 | SpacesInSquareBrackets: false 198 | SpaceBeforeSquareBrackets: false 199 | BitFieldColonSpacing: Both 200 | Standard: Latest 201 | StatementAttributeLikeMacros: 202 | - Q_EMIT 203 | StatementMacros: 204 | - Q_UNUSED 205 | - QT_REQUIRE_VERSION 206 | TabWidth: 8 207 | UseCRLF: true 208 | UseTab: Never 209 | WhitespaceSensitiveMacros: 210 | - STRINGIZE 211 | - PP_STRINGIZE 212 | - BOOST_PP_STRINGIZE 213 | - NS_SWIFT_NAME 214 | - CF_SWIFT_NAME 215 | ... 216 | 217 | -------------------------------------------------------------------------------- /source/fdisk/bootnorm.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; MBR boot code installed by Free FDISK 3 | ; to assemble use Netwide Assembler (NASM) 4 | ; 5 | ;----------------------------------------------------------------------- 6 | ; ENTRY (copied from freedos bootsector) 7 | ; 8 | ; IN: DL = boot drive 9 | ;OUT: DL = boot drive 10 | ; 11 | ;----------------------------------------------------------------------- 12 | 13 | TOP_OF_STACK equ 0x7be0 ; right below original boot code 14 | ; with 0x20 bytes of safety margin 15 | BOOTSECT_OFFSET equ 0x7c00 16 | RELOCATED_OFFSET equ 0x0600 17 | PARTTBL_SIZE equ 64 18 | PARTTBL_OFFSET equ 0x1be 19 | MAGIC_OFFSET equ 0x1fe 20 | CODE_SIZE equ 440 21 | WAIT_TICKS equ 54 ; ~3sec on 18.2 ticks per second 22 | 23 | org RELOCATED_OFFSET 24 | 25 | start: 26 | cli 27 | xor ax, ax 28 | mov ss, ax ; initialize stack 29 | mov sp, TOP_OF_STACK ; SS:SP = 0:7be0 30 | sti 31 | cld 32 | mov ds, ax ; do not trust BIOS to have the segment 33 | mov es, ax ; registers initialized to zero 34 | ; move MBR code out of the way to make room for volume boot record 35 | relocate: 36 | mov si, BOOTSECT_OFFSET 37 | mov di, RELOCATED_OFFSET 38 | mov cx, 0x0100 39 | rep movsw 40 | jmp 0:.relocated ; far jump to be sure we get CS right 41 | .relocated: 42 | 43 | fix_bootdrive: 44 | test dl, dl ; is boot drive in DL given by BIOS zero? 45 | jnz .dl_good ; if yes this can be considered a BIOS bug, 46 | mov dl, 0x80 ; because we know we boot from HD 47 | .dl_good: 48 | mov [driveno], dl ; save driveno in case BIOS destroys DL 49 | 50 | ; Test if one of the four primary partitions is active by checking 51 | ; for value 0x80 in the first byte of the entries. 52 | scan_for_active_partition: 53 | mov di, parttbl ; start of partition table 54 | .l: test byte [di], 0x80 ; is partition active? 55 | jnz chainload_bootsect 56 | add di, 0x10 ; next table entry 57 | cmp di, signature ; scanned beyond end of table? 58 | jb .l 59 | .no_active: 60 | mov si, no_active_msg 61 | jmp fatal ; does not return 62 | 63 | ; We found an active partition. Load its boot sector to 0:7c00, 64 | ; test the signature and far jump to 0:7c00 65 | chainload_bootsect: 66 | push di ; save parttbl entry (restore to SI) 67 | call read_boot_sector ; reads one sector 68 | jnc .check_signature ; no read error occured? 69 | mov si, read_error_msg 70 | jmp fatal ; does not return 71 | .check_signature: 72 | cmp word [BOOTSECT_OFFSET+MAGIC_OFFSET], 0xaa55 73 | je handoff_to_volume_bootrecord 74 | mov si, invalid_vbr_sig_msg 75 | jmp fatal ; does not return 76 | 77 | ;----------------------------------------------------------------------------- 78 | handoff_to_volume_bootrecord: 79 | pop si ; restore parttbl entry to SI, to 80 | ; comply with lDOS boot protocol 81 | mov dl, [driveno] 82 | jmp 0:0x7c00 ; far jump to volume boot code 83 | ;----------------------------------------------------------------------------- 84 | 85 | 86 | ;----------------------------------------------------------------------------- 87 | ; read_boot_sector 88 | ; 89 | ; IN : DI--> partition info 90 | ; OUT: CARRY 91 | 92 | read_boot_sector: 93 | .check_lba: 94 | push ds ; temporarly set DS to 0x40 (BIOS data area) 95 | mov ax, 0x40 ; to work around a BIOS bug 96 | mov ds, ax ; https://github.com/FDOS/kernel/issues/156 97 | mov bx, 0x55aa ; magic value shoud be changed after call 98 | mov ah, 0x41 ; query INT 13h LBA capabilities 99 | stc 100 | int 0x13 101 | pop ds 102 | jc .read_chs ; no support if carry set 103 | cmp bx, 0xaa55 ; no support if 55aa not swapped 104 | jne .read_chs 105 | shr cl, 1 ; no support if LBA flag not set 106 | jnc .read_chs 107 | .read_lba: 108 | mov ax, [di + 8] ; copy start sector of partition to DAP 109 | mov [dap.lba_low], ax 110 | mov ax, [di + 10] 111 | mov [dap.lba_high], ax 112 | mov ah, 0x42 ; LBA read function 113 | mov si, dap 114 | jmp short .intcall 115 | .read_chs: 116 | mov ax, 0x0201 ; read one sector 117 | mov bx, 0x7c00 ; to 0:7c00 118 | mov cx, [di + 2] 119 | mov dh, [di + 1] 120 | .intcall: 121 | stc 122 | int 0x13 123 | ret 124 | 125 | 126 | ;----------------------------------------------------------------------------- 127 | ; Fatal error handler. Displays error message, waits ~3 seconds, 128 | ; issues INT18 to give BIOS a change to recover, then 129 | ; waits forever in case INT18 returns 130 | ; IN: DS:SI = ASCIIZ with error message to print 131 | 132 | fatal: 133 | call print ; print error message given in si 134 | mov si, try_next_dev_msg 135 | call print ; and print "try next" message 136 | xor ah, ah 137 | int 1ah ; get system time 138 | mov bx, dx ; store lower word in bx 139 | .wait_few_seconds: 140 | int 1ah 141 | sub dx, bx 142 | cmp dx, WAIT_TICKS ; wait a few seconds to ensure user sees 143 | jb .wait_few_seconds ; the message 144 | .next_boot_device: 145 | int 0x18 ; give BIOS chance to deal with boot failure 146 | .wait_forever: ; we should not land here! 147 | jmp short .wait_forever ; loop forever in case INT 18 returns 148 | 149 | print: 150 | lodsb 151 | test al, al 152 | jz .r 153 | mov bx, 0x7 ; video page 0, default color 154 | mov ah, 0x0E ; print it via TTY mode 155 | int 0x10 156 | jmp print 157 | .r: ret 158 | 159 | read_error_msg: db 'Read error', 0 160 | no_active_msg: db 'No active partition', 0 161 | invalid_vbr_sig_msg: db 'VBR has illegal signature', 0 162 | try_next_dev_msg: db '. Trying next boot device...', 13, 10, 0 163 | 164 | 165 | ;----------------------------------------------------------------------------- 166 | ; Padding bytes, BIOS disk access packet used by ext. INT13 LBA read function, 167 | ; reserved space for partition table and BIOS signature 168 | 169 | DAP_PACKET_SIZE equ 16 170 | PADDING_BYTES equ CODE_SIZE - DAP_PACKET_SIZE - ($ - $$) 171 | 172 | %if PADDING_BYTES < 0 173 | ; Not strictly needed, because this is catched by the times 174 | ; directive below. But this gives a more meaningful error message. 175 | %error "code too large, try to decrease size" 176 | %endif 177 | 178 | ; padding bytes to ensure bootsector is 512 bytes in size 179 | times PADDING_BYTES nop 180 | 181 | ; By prepending the disk access packet to the partition table it is ensured 182 | ; that it is word-aligned. 183 | dap: 184 | .packet_size db 0x10 185 | .reserved1 db 0 186 | .sector_count db 1 187 | .reserved2 db 0 188 | .buf_off dw 0x7c00 189 | .buf_seg dw 0x0000 190 | .lba_low dw 0 191 | .lba_high dw 0 192 | dd 0 193 | .end: 194 | 195 | %if dap.end - dap != DAP_PACKET_SIZE 196 | ; Be sure to get DAP_PACKET_SIZE right. We defined it manually above because 197 | ; times directive needs a defined expression value. 198 | %error "Wrong DAP size" 199 | %endif 200 | 201 | 202 | reserved times 6 db 0 ; bytes 0x440-0x445 may contain operating 203 | ; system specific data 204 | parttbl: 205 | times PARTTBL_SIZE db 0 ; space for partition table 206 | signature: 207 | db 0x55, 0xaa ; BIOS signature 208 | 209 | %if $ - $$ != 512 210 | %error "wrong bootsector size" 211 | %endif 212 | 213 | 214 | absolute RELOCATED_OFFSET 215 | driveno resb 1 ; BIOS drive number to boot from 216 | -------------------------------------------------------------------------------- /bin/fdisk.ini: -------------------------------------------------------------------------------- 1 | ; Initialization file for Free FDISK 2 | ; 3 | ; This file sets various options for Free FDISK as described below. 4 | ; 5 | ; 6 | ; Note: This file is optional. If this file is not found the default 7 | ; settings will be utilized. Blank lines are not allowed 8 | ; in this file. 9 | ; 10 | ; Syntax: 11 | ; 12 | ; ALIGN_4K={ON | OFF} 13 | ; ALLOW_4GB_FAT16={TRUE | FALSE} 14 | ; ALLOW_ABORT={TRUE | FALSE} 15 | ; AMBR={ON | OFF} 16 | ; CHECKEXTRA={TRUE | FALSE} 17 | ; COLORS={0<=N<=127} 18 | ; DEL_ND_LOG={ON | OFF} 19 | ; DLA={0 | 1 | 2} 20 | ; DRIVE=#-####-###-## 21 | ; FLAG_SECTOR={0 | 2<=N<=64 | 256} 22 | ; LBA_MARKER={ON | OFF} 23 | ; MONO={ON | OFF} 24 | ; REBOOT={ON | OFF} 25 | ; SET_ANY_ACT={TRUE | FALSE} 26 | ; VERSION={4 | 5 | 6 | FD | W95 | W95B | W98} 27 | ; WRITE={ON | OFF} 28 | ; XO={ON | OFF} 29 | ; 30 | ; Note: The "=" sign in the above syntax is optional. 31 | ; 32 | ; Description: 33 | ; 34 | ; ALIGN_4K EXPERIMENTAL, leave disabled unless you know that you 35 | ; need it 36 | ; ON Aligns primary and logical partitions to 4Kbytes. 37 | ; * OFF Aligns partitions to cylindes. 38 | ; 39 | ; ALLOW_4GB_FAT16 40 | ; Permits the creation of 4GB FAT16 partitions. 41 | ; Supported by FreeDOS kernel. 42 | ; TRUE 43 | ; * FALSE 44 | ; 45 | ; ALLOW_ABORT 46 | ; TRUE Allows the user to abort Free FDISK without making 47 | ; any changes to the hard disks(s). 48 | ; * FALSE Normal operation. 49 | ; 50 | ; AMBR ON Writes an alternate boot loader from the file "boot.mbr." 51 | ; See the documentation for more details. 52 | ; * OFF Writes BootEasy as the boot loader. 53 | ; 54 | ; CHECKEXTRA Checks for an extra, unreported, cylinder of space near 55 | ; the end of all hard drives. 56 | ; TRUE 57 | ; * FALSE 58 | ; 59 | ; COLORS Changes the screen colors. 23 = grey on blue background 60 | ; on monochrome, colors other than gray are mapped to grey 61 | ; * 7 Light grey on black 62 | ; 0 TO 127 63 | ; 64 | ; DEL_ND_LOG Allows non-dos logical drives to be deleted. 65 | ; TRUE 66 | ; * FALSE 67 | ; 68 | ; DLA Drive letter assignment method. 69 | ; * 0 auto dectect by operating system 70 | ; 1 FreeDOS / Microsoft driver letter assignment 71 | ; one primary per disk (active first), then 72 | ; all logicals sorted by disk and partition table, 73 | ; then all remaining primaries by disk and partition table 74 | ; 2 DR-DOS drive letter assignment 75 | ; all primaries first sorted by disk and partition table, 76 | ; then all logicals by disk and partition table 77 | ; 78 | ; FLAG_SECTOR Sector number where the flags will be located. The 79 | ; default is 2. 80 | ; 0 Disables sector flagging function. 81 | ; 2 - 64 Flag sector. 82 | ; 256 Set the flag sector to the last sector in the first 83 | ; cylinder of the first hard disk. 84 | ; 85 | ; LBA_MARKER 86 | ; * ON Writes special LBA marker values 1023/254/63 into the CHS 87 | ; fields of partition tables if cylinder values exceed the 88 | ; maximum value of 1023. 89 | ; OFF Writes overflowed CHS values into partition tables if 90 | ; cylinder values exceed the maximum value of 1023 91 | ; (behavior of versions prior 1.3.5). 92 | ; 93 | ; MONO ON The menus will be displayed without boldfacing the text 94 | ; for users of monochrome systems. 95 | ; * OFF The menus have boldfaced text. 96 | ; 97 | ; 98 | ; REBOOT ON Free FDISK will reboot the system upon exiting the 99 | ; program if changes were made to any partition table. 100 | ; * OFF Free FDISK will not, under any circumstances, reboot 101 | ; the system. 102 | ; 103 | ; SET_ANY_ACT If set to true, will allow the user to set any primary 104 | ; partition active. Otherwise, it will only set DOS 105 | ; partition types active. 106 | ; * TRUE 107 | ; FALSE 108 | ; 109 | ; VERSION Version number that Free FDISK will emulate while the 110 | ; user is using the interactive setup. 111 | ; 4 Emulates the MS-FDISK that came with MS-DOS 4.xx. 112 | ; 5 Emulates the MS-FDISK that came with MS-DOS 5.xx. 113 | ; 6 Emulates the MS-FDISK that came with MS-DOS 6.xx. 114 | ; W95 Adds support for LBA hard disks. 115 | ; * W95B Same as W95, with the addition of FAT32 support. 116 | ; W98 Same as W95B. 117 | ; FD Setting for FreeDOS, same as W95B. 118 | ; 119 | ; WRITE * ON Changes will be written the the hard disk(s). 120 | ; OFF Changes will not be written to the hard disk(s) and 121 | ; a debugging screen will be displayed. 122 | ; 123 | ; XO ON Extended options will become available in the menus. 124 | ; * OFF Extended options will not be available in the menus. 125 | ; 126 | ; * Designates default settings if the fdisk.ini file does not 127 | ; exist or the statement is absent from the fdisk.ini file. 128 | ; 129 | ; 130 | ; To override the auto-detection of a hard disk with your own drive geometry: 131 | ; (This function could be used if your BIOS does not correctly detect 132 | ; the geometry of your hard disk.) 133 | ; 134 | ; Add the "DRIVE" statement with the syntax of: DRIVE A-BBBB-CCC-DD 135 | ; 136 | ; Where: A Represents the drive number 137 | ; B Represents the number of cylinders 138 | ; C Represents the number of heads 139 | ; D Represents the number of sectors 140 | ; i.e. DRIVE 3-0620-063-64 -> Sets drive 3 to 620 cylinders, 141 | ; 63 heads, and 64 sectors. 142 | ; NOTE: All fields specified in the DRIVE statement MUST be the EXACT 143 | ; number of characters as indicated above. 144 | ; 145 | ; WARNING: If the drive that you are forcing geometry values for 146 | ; does not exist or the values you enter are greater than 147 | ; what is supported by the hard disk, unpredictable problems 148 | ; will occur. 149 | ; 150 | ; Always proceed informational lines with a ";" so that Free FDISK ignores 151 | ; that line. 152 | ; 153 | ; The items and settings below can be separated by equal signs "=" or spaces. 154 | ; 155 | ; Current settings: 156 | ; 157 | 158 | DEL_ND_LOG TRUE 159 | 160 | ; 161 | ; Hard Disk Detection Overrides: 162 | ; (Replace the "#"s with the correct C/H/S values and remove the ";" 163 | ; from the beginning of the line to enable an override.) 164 | ; 165 | ; DRIVE 1-####-###-## 166 | ; DRIVE 2-####-###-## 167 | ; DRIVE 3-####-###-## 168 | ; DRIVE 4-####-###-## 169 | ; DRIVE 5-####-###-## 170 | ; DRIVE 6-####-###-## 171 | ; DRIVE 7-####-###-## 172 | ; DRIVE 8-####-###-## 173 | ; 174 | ; 175 | ; Uncomment the debugging settings, below, if debugging is compiled in. 176 | ; 177 | ; 178 | ; 179 | ; End of file marker follows, do not remove it. 180 | 999 181 | 182 | 183 | -------------------------------------------------------------------------------- /source/fdisk/ansicon.h: -------------------------------------------------------------------------------- 1 | #ifndef ANSICONS_H 2 | #define ANSICONS_H 3 | 4 | /* This file is part of the ANSICON project and is published under the terms 5 | * of the MIT license. 6 | * 7 | * Copyright (C) 2023 Bernd Boeckmann 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a 10 | * copy of this software and associated documentation files (the "Software"), 11 | * to deal in the Software without restriction, including without limitation 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | * and/or sell copies of the Software, and to permit persons to whom the 14 | * Software is furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | * DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | /* This library supports the interpretation of a minimal subset of ANSI 29 | * escape sequences for display output. The supported sequences as of now are: 30 | 31 | C U R S O R F U N C T I O N S 32 | 33 | CUP - Cursor Postion 34 | 35 | ESC [ Pl ; Pc H 36 | 37 | HVP - Horizontal & Vertical Postion 38 | 39 | ESC [ Pl ; Pc f 40 | 41 | CUP and HVP move the cursor to the position specified by 42 | the parameters. The first parameter specifies the line number 43 | and the second parameter specifies the column number. The 44 | default value is one. When no parameters are given the cursor 45 | is moved to the home postion. 46 | 47 | CUU - Cursor Up 48 | 49 | ESC [ Pn A 50 | 51 | Moves the cursor up one line without changing columns. The 52 | value of Pn determines the number of lines moved. The default 53 | value for Pn is one. This sequence is ignored if the cursor 54 | is already on the top line. 55 | 56 | CUD - Cursor Down 57 | 58 | ESC [ Pn B 59 | 60 | Moves the cursor down one line without changing columns. 61 | The value of Pn determines the number of lines moved. The 62 | default value for Pn is one. This sequence is ignored if the 63 | cursor is already on the bottom line. 64 | 65 | CUF - Cursor Forward 66 | 67 | ESC [ Pn C 68 | 69 | Moves the cursor forword one column without changing lines. 70 | The value of Pn determines the number of columns moved. The 71 | default value for Pn is one. This sequence is ignored if the 72 | cursor is already in the rightmost column. 73 | 74 | ESC [ Pn D 75 | 76 | Moves the cursor back one column without changing lines. The 77 | value of Pn determines the number of columns moved. The default 78 | value for Pn is one. This sequence is ignored if the cursor 79 | is already in the leftmost column. 80 | 81 | E R A S I N G 82 | 83 | ED - Erase Display 84 | 85 | ESC [ 2 J 86 | 87 | Erases all of the screen and the cursor goes to the home 88 | position. 89 | 90 | EL - Erase Line 91 | 92 | ESC [ K 93 | 94 | Erases from the cursor to the end of the line and includes 95 | the cursor position. 96 | 97 | M O D E S O F O P E R A T I O N 98 | 99 | SGR - Set Graphics Rendition 100 | 101 | ESC [ Ps ; ... ; Ps m 102 | 103 | Invokes the graphic rendition specified by the parameter(s). 104 | All following characters are rendered according to the 105 | parameter(s) until the next occurence of SGR. 106 | 107 | Parameter Parameter Function 108 | 109 | 0 All Attributes Off 110 | 1 Bold On 111 | 5 Blinking On 112 | 22 Bold Off 113 | 25 Blinking Off 114 | 30 Black foreground (ISO 6429 standard) 115 | 31 Red foreground (ISO 6429 standard) 116 | 32 Green foreground (ISO 6429 standard) 117 | 33 Yellow foreground (ISO 6429 standard) 118 | 34 Blue foreground (ISO 6429 standard) 119 | 35 Magenta foreground (ISO 6429 standard) 120 | 36 Cyan foreground (ISO 6429 standard) 121 | 37 White foregound (ISO 6429 standard) 122 | 40 Black background (ISO 6429 standard) 123 | 41 Red background (ISO 6429 standard) 124 | 42 Green background (ISO 6429 standard) 125 | 43 Yellow background (ISO 6429 standard) 126 | 44 Blue background (ISO 6429 standard) 127 | 45 Magenta background (ISO 6429 standard) 128 | 46 Cyan background (ISO 6429 standard) 129 | 47 White backgound (ISO 6429 standard) 130 | */ 131 | 132 | /* some ESC strings as preprocessor definition */ 133 | #define ESC_ATTR_OFF "\33[0m" 134 | #define ESC_BOLD_ON "\33[1m" 135 | #define ESC_BOLD_OFF "\33[22m" 136 | #define ESC_BLINK_ON 137 | #define ESC_BLINK_OFF 138 | #define ESC_CLRSCR "\33[2J" 139 | #define ESC_CLREOL "\33[K" 140 | 141 | #ifdef __cplusplus 142 | extern "C" { 143 | #endif 144 | 145 | /* con_error variable is non-zero if escape interpreter encountered an error. 146 | * Variable must be reset to zero by user of the lib */ 147 | extern int con_error; 148 | 149 | /* Initialize the console output routines. 150 | * interpret_esc = 0 : interpretation of escape sequences disabled 151 | * interpret_esc = 1 : interpretation of escape sequences enabled */ 152 | void con_init( int interpret_esc ); 153 | int con_is_tty( void ); 154 | 155 | /* Return screen dimensions */ 156 | unsigned con_get_width( void ); 157 | unsigned con_get_height( void ); 158 | 159 | /* keyboard functions */ 160 | int con_readkey( void ); 161 | 162 | /* Display output routines. The functions interpret ANSI escape sequences 163 | * if enabled via con_init(). */ 164 | void con_putc( char c ); 165 | void con_print( const char *s ); 166 | void con_print_at( int x, int y, const char *s ); 167 | void con_puts( const char *s ); /* like con_print with trailing new-line */ 168 | 169 | /* Clear screen and move cursor to home position. */ 170 | void con_clrscr( void ); 171 | /* Clear from current cursor positon to end of line. 172 | * Cursor stays where it is. */ 173 | void con_clreol( void ); 174 | 175 | /* Scrolls the screen. 176 | * n >= 0: scrolls upward n lines 177 | * n < 0 : scrolls downward -n lines 178 | * n = 0 : clear screen WITHOUT returning cursor to home pos */ 179 | void con_scroll( int n ); 180 | 181 | /* Cursor functions. Upper left corner is (1,1). */ 182 | void con_set_cursor_xy( int x, int y ); 183 | void con_get_cursor_xy( int *x, int *y ); 184 | int con_get_cursor_x( void ); 185 | int con_get_cursor_y( void ); 186 | void con_save_cursor_xy( void ); 187 | void con_restore_cursor_xy( void ); 188 | 189 | void con_set_cursor_rel( int dx, int dy ); 190 | /* Enables / disables hardware cursor synchronisation. Can be disabled to 191 | * enhance performance while printing to screen. May be nested. 192 | * con_print* functions implicitly disable it temporarily */ 193 | void con_disable_cursor_sync( void ); 194 | void con_enable_cursor_sync( void ); 195 | /* use to re-sync ANSICON cursor position when changed by other io routines */ 196 | void con_sync_from_hw_cursor( void ); 197 | 198 | /* Text attribute function */ 199 | 200 | /* enables / disables use of text attributes. If disabled, following 201 | functions have no effect */ 202 | void con_enable_attr( int flag ); 203 | void con_reset_attr( void ); 204 | void con_set_textcolor( int color ); 205 | void con_set_backcolor( int color ); 206 | void con_set_bold( int flag ); 207 | int con_get_bold( void ); 208 | void con_set_blinking( int flag ); 209 | 210 | #ifdef __cplusplus 211 | } 212 | #endif 213 | 214 | #endif 215 | -------------------------------------------------------------------------------- /source/fdisk/svarlang/svarlang.c: -------------------------------------------------------------------------------- 1 | /* This file is part of the svarlang project and is published under the terms 2 | * of the MIT license. 3 | * 4 | * Copyright (C) 2021-2024 Mateusz Viste 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | /* if WITHSTDIO is enabled, then remap file operations to use the standard 26 | * stdio amenities */ 27 | #ifdef WITHSTDIO 28 | 29 | #include /* FILE, fopen(), fseek(), etc */ 30 | typedef FILE* FHANDLE; 31 | #define FOPEN(x) fopen(x, "rb") 32 | #define FCLOSE(x) fclose(x) 33 | #define FSEEK(f,b) fseek(f,b,SEEK_CUR) 34 | #define FREAD(f,t,b) fread(t, 1, b, f) 35 | 36 | #else 37 | 38 | #include /* FP_SEG, FP_OFF */ 39 | typedef unsigned short FHANDLE; 40 | 41 | #endif 42 | 43 | 44 | #include "svarlang.h" 45 | 46 | 47 | /* supplied through DEFLANG.C */ 48 | extern char svarlang_mem[]; 49 | extern unsigned short svarlang_dict[]; 50 | extern const unsigned short svarlang_memsz; 51 | extern const unsigned short svarlang_string_count; 52 | 53 | 54 | const char *svarlang_strid(unsigned short id) { 55 | unsigned short left = 0, right = svarlang_string_count - 1, x; 56 | unsigned short v; 57 | 58 | if (svarlang_string_count == 0) return(""); 59 | 60 | while (left <= right) { 61 | x = left + ((right - left ) >> 2); 62 | v = svarlang_dict[x * 2]; 63 | 64 | if (id == v) return(svarlang_mem + svarlang_dict[x * 2 + 1]); 65 | 66 | if (id > v) { 67 | if (x == 65535) goto not_found; 68 | left = x + 1; 69 | } else { 70 | if (x == 0) goto not_found; 71 | right = x - 1; 72 | } 73 | } 74 | 75 | not_found: 76 | return(""); 77 | } 78 | 79 | 80 | /* routines below are simplified (dos-based) versions of the libc FILE-related 81 | * functions. Using them avoids a dependency on FILE, hence makes the binary 82 | * smaller if the application does not need to pull fopen() and friends 83 | * I use pragma aux directives for more compact size. open-watcom only. */ 84 | #ifndef WITHSTDIO 85 | 86 | static unsigned short FOPEN(const char far *s); 87 | 88 | #pragma aux FOPEN = \ 89 | "push ds" \ 90 | "push es" \ 91 | "pop ds" \ 92 | "mov ax, 0x3D00" /* open file, read-only (fname at DS:DX) */ \ 93 | "int 0x21" \ 94 | "jnc DONE" \ 95 | "xor ax, ax" /* return 0 on error */ \ 96 | "DONE:" \ 97 | "pop ds" \ 98 | parm [es dx] \ 99 | value [ax]; 100 | 101 | 102 | static void FCLOSE(unsigned short handle); 103 | 104 | #pragma aux FCLOSE = \ 105 | "mov ah, 0x3E" \ 106 | "int 0x21" \ 107 | modify [ax] /* AX might contain an error code on failure */ \ 108 | parm [bx] 109 | 110 | 111 | static unsigned short FREAD(unsigned short handle, void far *buff, unsigned short bytes); 112 | 113 | #pragma aux FREAD = \ 114 | "push ds" \ 115 | "push es" \ 116 | "pop ds" \ 117 | "mov ah, 0x3F" /* read cx bytes from file handle bx to DS:DX */ \ 118 | "int 0x21" \ 119 | "jnc ERR" \ 120 | "xor ax, ax" /* return 0 on error */ \ 121 | "ERR:" \ 122 | "pop ds" \ 123 | parm [bx] [es dx] [cx] \ 124 | value [ax] 125 | 126 | 127 | static void FSEEK(unsigned short handle, unsigned short bytes); 128 | 129 | #pragma aux FSEEK = \ 130 | "mov ax, 0x4201" /* move file pointer from cur pos + CX:DX */ \ 131 | "xor cx, cx" \ 132 | "int 0x21" \ 133 | parm [bx] [dx] \ 134 | modify [ax cx dx] 135 | 136 | #endif 137 | 138 | 139 | 140 | #ifdef MVUCOMP_ASM 141 | 142 | static void mvucomp_asm(unsigned short bufseg, unsigned short dst, unsigned short src, unsigned short complen); 143 | 144 | #pragma aux mvucomp_asm = \ 145 | " push ds"\ 146 | \ 147 | /* ds:si = compressed stream */ \ 148 | /* es:di = output location */ \ 149 | /* bx = len of compressed stream */ \ 150 | " shr bx, 1" /* convert byte length to number of words */ \ 151 | " cld" /* make sure stosw and friends move forward */ \ 152 | /* set ds = es = bufseg */ \ 153 | " push es"\ 154 | " pop ds"\ 155 | \ 156 | " xor dx, dx" /* literal continuation counter */ \ 157 | \ 158 | " AGAIN:"\ 159 | \ 160 | /* do I have any input? */ \ 161 | " test bx, bx"\ 162 | " jz KONIEC"\ 163 | " dec bx"\ 164 | \ 165 | /* load token */ \ 166 | " lodsw" /* mov ax, [ds:si] + inc si + inc si */ \ 167 | \ 168 | " /* literal continuation? */"\ 169 | " test dx, dx"\ 170 | " jz TRY_BACKREF"\ 171 | " stosw"\ 172 | " dec dx" /* a byte shorter than dec dl */ \ 173 | " jmp AGAIN"\ 174 | \ 175 | /* back ref? */ \ 176 | " TRY_BACKREF:"\ 177 | " test ax, 0xf000"\ 178 | " jz LITERAL_START" /* else it's a literal start */ \ 179 | /* AH = LLLL OOOO AL = OOOO OOOO */ \ 180 | /* copy (ah>>4)+1 bytes from (ax & 0x0FFF)+1 */ \ 181 | /* save regs */ \ 182 | " push si"\ 183 | /* prep DS:SI = source ; ES:DI = destination ; CX = len */ \ 184 | " mov ch, ah" /* this is all about setting CX to the high nibble of AX */ \ 185 | " mov cl, 4" /* using a code as compact as possible. */ \ 186 | " shr ch, cl"\ 187 | " mov cl, ch"\ 188 | " xor ch, ch"\ 189 | " inc cx"\ 190 | " and ax, 0x0fff" /* clear the backref length bits */ \ 191 | " inc ax"\ 192 | " mov si, di"\ 193 | " sub si, ax"\ 194 | " /* do the copy */"\ 195 | " rep movsb" /* copy cx bytes from ds:si to es:di + inc si + inc di */ \ 196 | \ 197 | " /* restore regs */"\ 198 | " pop si"\ 199 | " jmp AGAIN"\ 200 | \ 201 | " LITERAL_START:" /* write al to dst and set literal counter */ \ 202 | /* 0000 UUUU BBBB BBBB */ \ 203 | " stosb" /* mov [es:di], al + inc di */ \ 204 | " mov dl, ah" /* ah high nibble is guaranteed to be zero */ \ 205 | " jmp AGAIN"\ 206 | ""\ 207 | " KONIEC:"\ 208 | " pop ds"\ 209 | modify [ax bx cx dx di si] \ 210 | parm [es] [di] [si] [bx] 211 | 212 | #else 213 | 214 | void mvucomp(char *dst, const unsigned short *src, unsigned short complen) { 215 | unsigned char rawwords = 0; /* number of uncompressible words */ 216 | complen /= 2; /* I'm interested in number of words, not bytes */ 217 | 218 | while (complen != 0) { 219 | unsigned short token; 220 | /* get next mvcomp token */ 221 | token = *src; 222 | src++; 223 | complen--; 224 | 225 | /* token format is LLLL OOOO OOOO OOOO, where: 226 | * OOOO OOOO OOOO is the back reference offset (number of bytes-1 to rewind) 227 | * LLLL is the number of bytes (-1) that have to be copied from the offset. 228 | * 229 | * However, if LLLL is zero then the token's format is different: 230 | * 0000 RRRR BBBB BBBB 231 | * 232 | * The above form occurs when uncompressible data is encountered: 233 | * BBBB BBBB is the literal value of a byte to be copied 234 | * RRRR is the number of RAW (uncompressible) WORDS that follow (possibly 0) 235 | */ 236 | 237 | /* raw word? */ 238 | if (rawwords != 0) { 239 | unsigned short *dst16 = (void *)dst; 240 | *dst16 = token; 241 | dst += 2; 242 | rawwords--; 243 | 244 | /* literal byte? */ 245 | } else if ((token & 0xF000) == 0) { 246 | *dst = token; /* no need for an explicit "& 0xff", dst is a char ptr so token is naturally truncated to lowest 8 bits */ 247 | dst++; 248 | rawwords = token >> 8; /* number of RAW words that are about to follow */ 249 | 250 | /* else it's a backreference */ 251 | } else { 252 | char *src = dst - (token & 0x0FFF) - 1; 253 | token >>= 12; 254 | for (;;) { 255 | *dst = *src; 256 | dst++; 257 | src++; 258 | if (token == 0) break; 259 | token--; 260 | } 261 | } 262 | } 263 | } 264 | 265 | #endif 266 | 267 | 268 | int svarlang_load(const char *fname, const char *lang) { 269 | unsigned short langid; 270 | unsigned short buff16[2]; 271 | FHANDLE fd; 272 | signed char exitcode = 0; 273 | struct { 274 | unsigned long sig; 275 | unsigned short string_count; 276 | } hdr; 277 | 278 | langid = *((unsigned short *)lang); 279 | langid &= 0xDFDF; /* make sure lang is upcase */ 280 | 281 | fd = FOPEN(fname); 282 | if (!fd) return(-1); 283 | 284 | /* read hdr, sig should be "SvL\x1a" (0x1a4c7653) */ 285 | if ((FREAD(fd, &hdr, 6) != 6) || (hdr.sig != 0x1a4c7653L) || (hdr.string_count != svarlang_string_count)) { 286 | exitcode = -2; 287 | goto FCLOSE_AND_EXIT; 288 | } 289 | 290 | for (;;) { 291 | /* read next lang id and string table size in file */ 292 | if (FREAD(fd, buff16, 4) != 4) { 293 | exitcode = -3; 294 | goto FCLOSE_AND_EXIT; 295 | } 296 | 297 | /* is it the lang I am looking for? */ 298 | if ((buff16[0] & 0x7FFF) == langid) break; /* compare without highest bit - it is a flag for compression */ 299 | 300 | /* skip to next lang (in two steps to avoid a potential uint16 overflow) */ 301 | FSEEK(fd, svarlang_string_count * 4); 302 | FSEEK(fd, buff16[1]); 303 | } 304 | 305 | /* load the index (dict) */ 306 | if (FREAD(fd, svarlang_dict, svarlang_string_count * 4) != svarlang_string_count * 4) { 307 | exitcode = -4; 308 | goto FCLOSE_AND_EXIT; 309 | } 310 | 311 | /* is the lang block compressed? then uncompress it */ 312 | if (buff16[0] & 0x8000) { 313 | unsigned short *mvcompptr; 314 | 315 | /* start by loading the entire block at the end of the svarlang mem */ 316 | mvcompptr = (void *)(svarlang_mem + svarlang_memsz - buff16[1]); 317 | if (FREAD(fd, mvcompptr, buff16[1]) != buff16[1]) { 318 | exitcode = -5; 319 | goto FCLOSE_AND_EXIT; 320 | } 321 | 322 | /* uncompress now */ 323 | #ifndef MVUCOMP_ASM 324 | mvucomp(svarlang_mem, mvcompptr, buff16[1]); 325 | #else 326 | mvucomp_asm(FP_SEG(svarlang_mem), FP_OFF(svarlang_mem), FP_OFF(svarlang_mem) + svarlang_memsz - buff16[1], buff16[1]); 327 | #endif 328 | 329 | goto FCLOSE_AND_EXIT; 330 | } 331 | 332 | /* lang block not compressed - load as is */ 333 | if (FREAD(fd, svarlang_mem, buff16[1]) != buff16[1]) { 334 | exitcode = -7; 335 | } 336 | 337 | FCLOSE_AND_EXIT: 338 | 339 | FCLOSE(fd); 340 | return(exitcode); 341 | } 342 | -------------------------------------------------------------------------------- /source/fdisk/smartmbr.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; extremely clever DOS MBR by tom ehlert 3 | ; 4 | ; Copyright 2006 tom ehlert 5 | ; all rights reserved 6 | ; 7 | 8 | 9 | segment SMARTMBR_TEXT class=CODE align=2 10 | 11 | global _smart_mbr 12 | _smart_mbr: 13 | 14 | global _BootSmart_code 15 | _BootSmart_code: 16 | 17 | ;----------------------------------------------------------------------- 18 | ; ENTRY (copied from freedos bootsector) 19 | ; 20 | ; IN: DL = boot drive 21 | ;OUT: DL = boot drive 22 | ; 23 | ;----------------------------------------------------------------------- 24 | align 16 25 | 26 | real_start: 27 | ; 1) whereever we are, we copy ourself 28 | ; 2) to 0:7c00 29 | 30 | call $+3 31 | pop si ; get current location 32 | 33 | 34 | cld 35 | xor ax, ax 36 | mov ds, ax 37 | mov es, ax 38 | mov di, 0x7802 39 | 40 | mov ss, ax ; initialize stack 41 | 42 | mov sp, di 43 | inc di 44 | 45 | 46 | mov cx, 0x0200-3 47 | 48 | 49 | db 0x2e ; CS: copy from current code segment 50 | rep movsb 51 | 52 | jmp word 0x0000:0x7800+ cont-_smart_mbr 53 | 54 | cont: 55 | 56 | 57 | mov ds, ax 58 | mov ss, ax 59 | xor ax,ax 60 | mov es,ax 61 | 62 | call print 63 | db "DriveSmart...",0 64 | 65 | 66 | ; search for active partition 67 | mov bp,0x79be ; start of partition table 68 | test_next_for_active: 69 | test byte [bp],0x80 70 | jne active_partition_found 71 | add bp,0x10 ; next table 72 | cmp bp, 07800h+0x1fe; scanned beyond end of table ?? 73 | jb test_next_for_active 74 | 75 | ;***************************************************************** 76 | call print 77 | db 'no active partition found',0 78 | 79 | WAIT_FOR_REBOOT: 80 | mov ax,0x4c00 81 | int 0x21 82 | hlt 83 | jmp WAIT_FOR_REBOOT 84 | 85 | 86 | ;***************************************************************** 87 | trouble_reading_drive: 88 | call print 89 | db 'read error',0 90 | jmp WAIT_FOR_REBOOT 91 | 92 | ;***************************************************************** 93 | 94 | invalid_partition_code: 95 | call print 96 | db 'signature != 55AA',0 97 | 98 | jmp WAIT_FOR_REBOOT 99 | 100 | 101 | ;***************************************************************** 102 | 103 | active_partition_found: 104 | 105 | call print 106 | db 'loading active partition',0 107 | 108 | call read_boot_sector 109 | 110 | jc trouble_reading_drive 111 | 112 | cmp word [0x7c00+0x1fe],0xaa55 113 | jne invalid_partition_code 114 | 115 | ; call print 116 | ; db '.jump DOS..',0 117 | 118 | ; 119 | 120 | call get_drive_params 121 | jc gogogo 122 | 123 | ; now we patch the new disk geometry into loaded boot sector 124 | 125 | mov si,0x7c00 126 | 127 | mov eax,[bp+8] 128 | mov [si+0x1c],eax ; hidden sectors 129 | 130 | mov [si+0x1a],dx ; heads 131 | mov [si+0x18],bx ; sectors per track 132 | 133 | 134 | 135 | 136 | gogogo: 137 | call print 138 | db 'go',0 139 | 140 | ; jmp WAIT_FOR_REBOOT 141 | 142 | 143 | jmp word 0x0:0x7c00 ; and jump to boot sector code 144 | 145 | 146 | ;***************************** 147 | ; read_boot_sector 148 | ; 149 | ; IN: DI--> partition info 150 | ;OUT:CARRY 151 | ;***************************** 152 | 153 | read_boot_sector: 154 | 155 | int 3 156 | 157 | mov word [0x7c00+0x1fe],0 158 | 159 | ; /* check for LBA support */ 160 | mov bx,0x55aa 161 | mov ah,0x41 162 | mov dl,[bp] 163 | int 0x13 164 | 165 | jc StandardBios ; if (regs.b.x != 0xaa55 || (regs.flags & 0x01)) 166 | cmp bx,0xaa55 ; goto StandardBios; 167 | jne StandardBios 168 | 169 | ; /* if DAP cannot be used, don't use LBA */ 170 | ; if ((regs.c.x & 1) == 0) 171 | ; goto StandardBios; 172 | test cl,1 173 | jz StandardBios 174 | 175 | jmp short LBABios 176 | 177 | 178 | 179 | ;struct _bios_LBA_address_packet /* Used to access a hard disk via LBA */ 180 | ;{ 181 | ; unsigned char packet_size; /* size of this packet...set to 16 */ 182 | ; unsigned char reserved_1; /* set to 0...unused */ 183 | ; unsigned char number_of_blocks; /* 0 < number_of_blocks < 128 */ 184 | ; unsigned char reserved_2; /* set to 0...unused */ 185 | ; UBYTE far *buffer_address; /* addr of transfer buffer */ 186 | ; unsigned long block_address; /* LBA address */ 187 | ; unsigned long block_address_high; /* high bytes of LBA addr...unused */ 188 | ;}; 189 | 190 | _bios_LBA_address_packet: 191 | db 0x10 192 | db 0 193 | db 4 ; read four sectors - why not 194 | db 0 195 | dw 0x7c00 ; fixed boot address for DOS sector 196 | dw 0x0000 197 | _bios_LBA_low dw 0 198 | _bios_LBA_high dw 0 199 | dw 0,0 200 | 201 | 202 | LBABios: 203 | ; copy start adpdress of partition to DAP 204 | mov ax,[bp+8] 205 | mov [0x7800+ (_bios_LBA_low-real_start)],ax 206 | mov ax,[bp+8+2] 207 | mov [0x7800+ (_bios_LBA_high-real_start)],ax 208 | 209 | mov ax,0x4200 ; regs.a.x = LBA_READ; 210 | mov si,0x7800+ (_bios_LBA_address_packet-real_start); regs.si = FP_OFF(&dap); 211 | 212 | int 0x13 213 | ret 214 | 215 | ;***************************************************************** 216 | ; read disk, using standard BIOS 217 | ; 218 | StandardBios: 219 | ; call print 220 | ; db 'standard BIOS',0 221 | 222 | 223 | 224 | call get_drive_params 225 | jnc lba_chs 226 | 227 | ; take dx/cx 228 | 229 | mov cx,[bp+2] ; regs.c.x = 230 | ; ((chs.Cylinder & 0xff) << 8) + ((chs.Cylinder & 0x300) >> 2) + 231 | ; chs.Sector; 232 | ; that was easy ;-) 233 | mov dh,[bp+1] ; regs.d.b.h = chs.Head; 234 | ; regs.es = FP_SEG(buffer); 235 | 236 | 237 | read_normal_bios2: 238 | 239 | mov ax,0x0204 ; regs.a.x = 0x0201; 240 | mov bx,0x7c00 ; regs.b.x = FP_OFF(buffer); 241 | mov dl,[bp] 242 | int 0x13 243 | ret 244 | 245 | 246 | lba_chs: 247 | ; DX heads 248 | ; CX CYL 249 | ; BX sectors 250 | 251 | ; transform LBA into CHS 252 | mov eax, [bp+8] 253 | 254 | movzx esi,bx ; ESI=sectors 255 | movzx edi,dx ; EDI=heads 256 | 257 | xor edx,edx 258 | div esi ; eax = eax/sectors = cylinder 259 | ; edx = sectors 260 | 261 | inc dl ; sectors are 1..63 262 | push dx ; mod --> dh -> sector number to read 263 | 264 | xor edx,edx 265 | div edi ; eax = eax/heads 266 | ; edx = heads 267 | 268 | shr ah,6 269 | 270 | pop cx ; sectors 271 | or cl,ah ; 2 high bits of cyl count 272 | 273 | mov ch,al ; CH = low byte of cyl 274 | mov dh,dl ; DH = head 275 | 276 | jmp read_normal_bios2 277 | 278 | 279 | 280 | 281 | 282 | ;****** PRINT 283 | ; prints text after call to this function. 284 | 285 | print_1char: 286 | xor bx, bx ; video page 0 287 | mov ah, 0x0E ; else print it 288 | int 0x10 ; via TTY mode 289 | print: pop si ; this is the first character 290 | print1: lodsb ; get token 291 | push si ; stack up potential return address 292 | cmp al, 0 ; end of string? 293 | jne print_1char ; until done 294 | ret ; and jump to it 295 | 296 | 297 | ;INT 13 - DISK - GET DRIVE PARAMETERS (PC,XT286,CONV,PS,ESDI,SCSI) 298 | ; AH = 08h 299 | ; DL = drive (bit 7 set for hard disk) 300 | ; ES:DI = 0000h:0000h to guard against BIOS bugs 301 | ;Return: CF set on error 302 | ; AH = status (07h) (see #00234) 303 | ; CF clear if successful 304 | ; AH = 00h 305 | ; AL = 00h on at least some BIOSes 306 | ; BL = drive type (AT/PS2 floppies only) (see #00242) 307 | ; CH = low eight bits of maximum cylinder number 308 | ; CL = maximum sector number (bits 5-0) 309 | ; high two bits of maximum cylinder number (bits 7-6) 310 | ; DH = maximum head number 311 | ; 312 | 313 | ; CH = low eight bits of maximum cylinder number 314 | ; CL = maximum sector number (bits 5-0) 315 | ; high two bits of maximum cylinder number (bits 7-6) 316 | ; DH = maximum head number 317 | 318 | drive_heads dw 0 319 | drive_secpertrack dw 0 320 | 321 | 322 | ; in BP->partition entry 323 | ; out 324 | ; DX heads 325 | ; CX CYL 326 | ; BX sectors 327 | 328 | get_drive_params: 329 | 330 | mov ah,0x08 331 | mov dl,[bp] 332 | int 0x13 333 | jc no_info 334 | 335 | mov bl,cl 336 | and bx,0x3f ; max sector 337 | cbw 338 | 339 | shr cl,6 340 | xchg ch,cl ; max cyl 341 | 342 | inc cx ; cyl count 343 | 344 | mov dl,dh 345 | mov dh,0 346 | inc dx ; total head count 347 | 348 | 349 | mov [drive_heads],dx 350 | mov [drive_secpertrack],bx 351 | 352 | clc 353 | no_info: 354 | ret 355 | 356 | 357 | times 0x1fe-$+$$-0x40 db 0 ; fill up to partition table 358 | 359 | 360 | ; TEST disk 361 | db 0x00,0x01,0x01,0x00,0x06,0xfe,0x3f,0x81,0x3f,0x00,0x00,0x00,0xc3,0xdd,0x1f,0x00 362 | db 0x80,0x00,0x01,0x82,0x06,0xfe,0x7f,0x03,0x02,0xde,0x1f,0x00,0x02,0xde,0x1f,0x00 363 | 364 | ; Toms disk1 365 | ;db 0x80,0x01,0x01,0x00,0x06,0xfe,0x3f,0x81,0x3f,0x00,0x00,0x00,0xc3,0xdd,0x00,0x00 ;T1 366 | ;db 0x80,0x00,0xc1,0xff,0x07,0xfe,0xff,0xff,0x43,0xc0,0xfb,0x00,0xb6,0x50,0xf4,0x04 367 | 368 | ; db 0x80,0x01,0x01,0x00,0x07,0xFE,0x3F,0x81,0x3F,0x00,0x00,0x00,0xC3,0xDD,0x1F,0x00 369 | ; db 0x00,0x00,0x01,0x82,0x0F,0xFE,0xFF,0xFF,0x02,0xDE,0x1F,0x00,0x25,0x09,0xD0,0x01 370 | db 0x00,0x00,0xC1,0xFF,0x07,0xFE,0xFF,0xFF,0x27,0xE7,0xEF,0x01,0x7C,0xE7,0x9B,0x00 371 | db 0x00,0x00,0xC1,0xFF,0x07,0xFE,0xFF,0xFF,0xB3,0x7B,0xCE,0x02,0x12,0x64,0x83,0x06 372 | 373 | times 0x1fe-$+$$ db 0 ; fill up to magic 55 AA 374 | 375 | db 0x55,0xaa 376 | 377 | -------------------------------------------------------------------------------- /doc/fdisk/CHANGES.md: -------------------------------------------------------------------------------- 1 | Free FDISK Change Log 2 | ===================== 3 | 4 | Bug classification: 5 | - CRITICAL: Serve errors potentially leading to data loss. 6 | - HIGH: Errors preventing the program to work. 7 | - MEDIUM: Bugs regarding non-essential features or with work-arounds. 8 | - LOW: Cosmetic bugs, like display issues etc. 9 | 10 | 11 | Version 1.4.4 (2025-04-27) 12 | --------------------------- 13 | Fixes: 14 | - MEDIUM: FAT-16 LBA (partition type 0x0e) were incorrectly displayed as 15 | FAT-32 LBA when displaying logical partitions via the menu. 16 | 17 | 18 | Version 1.4.3 (2025-01-19) 19 | --------------------------- 20 | Fixes: 21 | - LOW: Do not show drive "letters" beyond Z:. This was a display issue 22 | without affecting the actual functionality. 23 | 24 | Changes: 25 | - Allow creation of primary partition despite being out of drive letters, 26 | as the primary might actually get one when created. 27 | 28 | 29 | Version 1.4.2 (2025-01-18) 30 | --------------------------- 31 | Fixes: 32 | - LOW: When displaying or editing logical partitions, only complain about 33 | an unusable extended partition if there is any defined, not when there 34 | is no extended at all (introduced with 1.4.1). 35 | 36 | 37 | Version 1.4.1 (2025-01-18) 38 | --------------------------- 39 | Fixes: 40 | - CRITICAL: Prevent FDISK from accessing and modifying partitions with more 41 | than 23 logicals defined, as it may terminate the EMBR chain after the 42 | 23th logical when writing the tables back or otherwise operate in an 43 | unexpected way. 44 | - MEDIUM: Fix bootloader trying to boot from an active partition 45 | not containing a valid volume boot record instead of showing an 46 | error message. 47 | 48 | Changes: 49 | - Do not automatically activate a created primary partition when 50 | it is created via command line and no other partition is active, as 51 | this turned out to be a backwards incompatible change to FDISK 1.3.4 52 | shipped with FreeDOS 1.3, breaking the installation process if the 53 | BIOS is configured to boot from hard disk first. 54 | - Change boot code installed via /IPL to issue an INT 18 if there is 55 | no bootable partition, either because none is active, or the active 56 | one does not contain a valid BIOS signature. There is a message and 57 | a three second delay before issueing the INT 18. 58 | - Add undocumented /NOIPL command line argument which prevents FDISK 59 | from writing boot code into an implicitly created MBR. IPL area is 60 | filled with zero instead. 61 | - Do not list logical drives via /info for inaccessible extended 62 | partitions. 63 | - Tell user if an extended partition is inaccessible when entering 64 | the delete logical drive UI screen instead of giving a generic 65 | failure message. 66 | 67 | 68 | Version 1.4.0 (2025-01-16) 69 | --------------------------- 70 | Fixes: 71 | - CRITICAL: FDISK would wipe the disk if a logical other than the first is 72 | deleted while there are 23 logical partitions defined for the disk. 73 | - CRITICAL: The number n for command line operations 74 | /del /log:n and /del /num:n did not always reflect the n-th 75 | logical partition shown to the user via /info. This could trick the 76 | user into deleting wrong partitions. 77 | - CRITICAL: Avoid data loss on logical partition creation if there are 78 | already 22 partitions on a single disk and the 23th to be inserted 79 | is not going into the last partition slot. 80 | - HIGH: If there are multiple gaps between the partitions, FDISK would 81 | not find the largest free space but the first. 82 | - HIGH: Prevent the user from creating more drives than drive letters 83 | available. 84 | 85 | Changes: 86 | - Import latest SvarLANG and make use of compressed language file to 87 | safe ~50K disk space. 88 | 89 | 90 | Version 1.3.16 (2024-08-04) 91 | --------------------------- 92 | Changes: 93 | - Use DR-DOS drive letter assignment if running under (E)DR-DOS kernel. 94 | 95 | 96 | Version 1.3.15 (2024-05-26) 97 | --------------------------- 98 | Fixes: 99 | - HIGH: Fix FDISK not modifying partition type via command line /MODIFY 100 | and via UI if FDISK is started in extended options mode /XO. 101 | - HIGH: respect selected video page instead of hardcoding it to zero when 102 | calling INT 10 routines. 103 | 104 | Changes: 105 | - FDISK provided MBR bootloader does not require more than 128k of RAM 106 | anymore. In fact it should run with as low as 64k of RAM (untested). 107 | - Work around Xi8088 and Book8088 BIOS bug (bootloader and FDISK itself). 108 | - Assume BIOS drive number of 0x80 to boot from if BIOS tells us it is 109 | unit 0. This should be an error, because we boot from hard disk. 110 | 111 | 112 | Version 1.3.14 (2024-02-05) 113 | --------------------------- 114 | Fixes: 115 | - HIGH: Prevent querying LBA capabilities via INT13,41 if LBA is disabled 116 | by the user via command line argument /X. This caused some broken 117 | BIOS to crash the system, like BIOS version 0.9.4 of Book8088 and Xi8088. 118 | 119 | 120 | Version 1.3.13 (2024-01-16) 121 | --------------------------- 122 | Changes: 123 | - Do not check for extra cylinders by default. DR-DOS refuses to use 124 | partitions exceeding the BIOS reported disk size, despite being valid. 125 | - Update German translation. 126 | 127 | 128 | Version 1.3.12 (2024-01-13) 129 | --------------------------- 130 | Fixes: 131 | - CRITICAL: Fix a drive letter disagree between DOS and FDISK in cases 132 | involving multiple disks and a mix of active and non-active 133 | primary partitions. 134 | 135 | 136 | Version 1.3.11 (2023-11-20) 137 | --------------------------- 138 | Fixes: 139 | - HIGH: Fix FDISK not writing the partition table of the 8th disk. 140 | 141 | 142 | Version 1.3.10 (2023-11-11) 143 | --------------------------- 144 | Changes: 145 | - Increase compatibility with some older quirky IDE controllers by resetting 146 | the disk system via INT13,0 after failed IO operations. 147 | - Add Italian translation. 148 | - Provide SvarDOS packages as part of new releases. 149 | 150 | 151 | Version 1.3.9 (2023-08-27) 152 | -------------------------- 153 | Changes: 154 | - Reintroduce /SMBR command line argument as alias for /SAVEMBR. 155 | - Add Spanish and Polish translations. 156 | 157 | 158 | Version 1.3.8 (2023-07-24) 159 | -------------------------- 160 | Bugfixes: 161 | - HIGH: Fix a bug preventing FDISK to work if ext. INT 13 support is 162 | reported by the BIOS, but actual support for functions 42, 43 and 48 163 | is non-existant (mainly 486 systems and early LBA support era). 164 | - HIGH: Fix a bug preventing FDISK from working correctly, if BIOS returns 165 | garbage in AH for INT 13 function 2 or 3 and CF is zero (mainly some 166 | buggy XT/AT era INT 13 implementations). 167 | - HIGH: Fix FDISK not returning an error code if partition table can not be 168 | written. (since <= v1.2.1) 169 | - MEDIUM: Fix FDISK not letting the user delete the last existing logical 170 | drive until program is restarted, if the first logical drive in EMBR 171 | chain is not the last to be deleted. (since v1.3.5) 172 | - MEDIUM: Fix FDISK wrongly informing the user that no space in the extended 173 | partition is left after deleting the last logical drive, until program is 174 | restarted. (since v1.3.5) 175 | - LOW: Fix a display bug showing the extended partition a few MB smaller 176 | than it actually is while creating logical partitions. 177 | - LOW: Prevent FDISK from using different rounding schemes for displaying 178 | partition sizes, confusing the user by showing slightly different values 179 | in some situations. 180 | 181 | Changes: 182 | - FDISK is translated to the following languages: 183 | German, French, Turkish, and partially to Polish 184 | - Prohibit deletion of DOS partitions from the Non-DOS partition removal 185 | menu. 186 | - FDISK terminates with an error message if run from OS/2 or Windows NT. 187 | - Program can be build with I16-GCC. 188 | - Support for Borland / Turbo C was dropped. 189 | 190 | 191 | Version 1.3.7 (2023-06-26) 192 | -------------------------- 193 | Changes: 194 | - Reintroduce /AMBR as alias for /LOADIPL, because I saw it being used in 195 | some external tools and documentation. 196 | 197 | 198 | Version 1.3.6 (2023-03-23) 199 | -------------------------- 200 | Bugfixes: 201 | - CRITICAL: Prevent user from specifying multiple disks via command line 202 | leading to commands operating on the wrong disk. 203 | - LOW: Work around AT BIOS bug. It is LOW because it actually does not get 204 | triggered by the current version. 205 | 206 | Other changes: 207 | - Implement /IFEMPTY command for use by the FreeDOS installers. 208 | 209 | 210 | Version 1.3.5 (2023-03-19) 211 | -------------------------- 212 | Bugfixes: 213 | - CRITICAL: Fix FDISK loading wrong CHS head and sector values from MBR if 214 | operating in LBA mode. The previous incorrect behaviuor was hardcoding 215 | them to cylinder boundaries instead of calculating them from LBA address, 216 | resulting in corrupt partition tables especially if used in combination 217 | with other disk utilities (since <= v0.9.9). 218 | - CRITICAL: Fix FDISK creating havoc when encountering extended partition 219 | layouts it is not designed handle: EMBR tables with entries 3 or 4 220 | being present or an EMBR link in entry 1, 3 or 4. Creating and deleting 221 | logical drives is disabled for such layouts. 222 | - CRITICAL: Fix FDISK creating havoc when encountering partition type 0 223 | in the first EMBR table entry in the middle of the EMBR chain. 224 | - CRITICAL: Position and size calculation for new logical drives was broken 225 | if the extended partition was not aligned to cylinder boundaries, leading 226 | to all sorts of problems, including potential data loss. 227 | - CRITICAL: Fix a bug resulting in detecting non-existant extra cylinders 228 | when using ext INT 13 function (since v1.1). 229 | - CRITICAL: Fix a partition location and size calculation error triggered 230 | when creating a new logical partition after deleting the first logical 231 | partition while there are still logical partitions left (since v1.2.1). 232 | - CRITICAL: Fix different calculation errors leading to overlapping 233 | partitions, unnessessary free space between them, or partitions exceeding 234 | the end of the disk resulting from off-by-one and off-by-two errors. 235 | - MEDIUM: Fix a bug where FDISK gets confused which boot sectors to clear 236 | if logical drives are created and deleted during the same program 237 | invocation. 238 | - MEDIUM: Fix a cylinder off by one error in partition type determination. 239 | - MEDIUM: Fix not doing proper error handling for 80% of the functionality. 240 | - LOW: Fix color handling for background colors other than black. 241 | - LOW: Fix various flaws in the input handling routine. 242 | 243 | Other changes: 244 | - Write LBA marker entry 1023/254/63 into CHS partition table entries if 245 | CHS value otherwise would overflow. This may be disabled via config option 246 | LBA_MARKER. 247 | - FDISK contains experimental support for aligning partitions to 4K. This may 248 | be enabled via config option ALIGN_4K. 249 | - Warn if user tries to use FDISK with a disk size of >2TB, because it can 250 | not handle it properly. If the user decides to continue the disk size is 251 | truncated to 2TB, making sure nothing bad happens by some overflowing 252 | values. 253 | - Adapt user interface to handle larger disks. 254 | - Free FDISK now compiles with Open Watcom C. 255 | - Rework command line argument handling. 256 | - /SMBR renamed to /SAVEIPL to avoid confusion of what it does: 257 | saving the boot code and NOT saving the whole MBR including the 258 | partition table. 259 | - /SAVEMBR and /LOADMBR commands save or load a MBR from file. This includes 260 | boot code and primary partitions. 261 | - /CLEARALL command renamed to /CLEARMBR (still available under old name). 262 | - /CLEAR command renamed to /DELETEALL (still available under old name). 263 | - Support MAX quantifier in command line size arguments. 264 | - Make disks n+m, m>0, accessible if disk n is not accessible. 265 | 266 | 267 | Version 1.3.4 (2021-02-20) 268 | -------------------------- 269 | - CRITICAL: when creating logical drives, using 'use maximum size', FDISK 270 | would allow to create an additional partition of size 0, trashing the 271 | complete disk partitioning. hopefully fixed. (Tom Ehlert) 272 | 273 | 274 | Version 1.3.3 (2021-02-09) 275 | -------------------------- 276 | - FIX: FDISK would not show volume labels if the partitions aren't on a 277 | cylinder boundary. (Tom Ehlert) 278 | 279 | 280 | Version 1.3.2 281 | ------------- 282 | 1.3.2 fixes a couple of bugs in 1.3.1 that were detected by Japheth 283 | 284 | - without .INI file, FDISK would simply exit with "Error reading hard disk. 285 | Addressed sector not found." 286 | - FDSIK would create overlapping partitions when other partitions were not 287 | starting on virtual Cylinder boundaries, as windows or linux partitioners 288 | do. 289 | - a bug when a USB memory card reader with empty slot would create 'valid' 290 | drives with 0 sectors, 0 heads 291 | - on GPT partitioned disks, the protection partition was not proper detected 292 | -------------------------------------------------------------------------------- /source/fdisk/display.c: -------------------------------------------------------------------------------- 1 | /* contains UI calls that required by command-line operations */ 2 | 3 | #include 4 | #include 5 | 6 | #include "ansicon.h" 7 | #include "compat.h" 8 | #include "display.h" 9 | #include "main.h" 10 | #include "pcompute.h" 11 | #include "printf.h" 12 | #include "svarlang/svarlang.h" 13 | 14 | /* Pause Routine */ 15 | void Pause( void ) 16 | { 17 | con_putc( '\n' ); 18 | con_print( svarlang_str( 250, 3 ) ); 19 | 20 | /* wait for keypress */ 21 | con_readkey(); 22 | 23 | con_putc( '\r' ); 24 | con_clreol(); 25 | } 26 | 27 | /* Display Information */ 28 | void Display_Information( void ) 29 | { 30 | if ( flags.extended_options_flag == TRUE ) { 31 | con_set_cursor_xy( 1, 1 ); 32 | if ( flags.version == COMP_FOUR ) { 33 | con_print( "4" ); 34 | } 35 | if ( flags.version == COMP_FIVE ) { 36 | con_print( "5" ); 37 | } 38 | if ( flags.version == COMP_SIX ) { 39 | con_print( "6" ); 40 | } 41 | if ( flags.version == COMP_W95 ) { 42 | con_print( "W95" ); 43 | } 44 | if ( flags.version == COMP_W95B ) { 45 | con_print( "W95B" ); 46 | } 47 | if ( flags.version == COMP_W98 ) { 48 | con_print( "W98" ); 49 | } 50 | 51 | if ( flags.partition_type_lookup_table == INTERNAL ) { 52 | con_set_cursor_xy( 6, 1 ); 53 | con_print( "INT" ); 54 | } 55 | else { 56 | con_set_cursor_xy( 6, 1 ); 57 | con_print( "EXT" ); 58 | } 59 | 60 | if ( flags.use_extended_int_13 == TRUE ) { 61 | con_set_cursor_xy( 10, 1 ); 62 | con_print( "LBA" ); 63 | } 64 | 65 | if ( flags.fat32 == TRUE ) { 66 | con_set_cursor_xy( 14, 1 ); 67 | con_print( "FAT32" ); 68 | } 69 | 70 | con_set_cursor_xy( 68, 1 ); 71 | con_printf("DLA%u", flags.dla ); 72 | 73 | if ( flags.use_ambr == TRUE ) { 74 | con_set_cursor_xy( 73, 1 ); 75 | con_print( "AMBR" ); 76 | } 77 | 78 | if ( flags.partitions_have_changed == TRUE ) { 79 | con_set_cursor_xy( 78, 1 ); 80 | con_print( "C" ); 81 | } 82 | 83 | if ( flags.extended_options_flag == TRUE ) { 84 | con_set_cursor_xy( 80, 1 ); 85 | con_print( "X" ); 86 | } 87 | } 88 | 89 | #ifndef RELEASE 90 | con_set_cursor_xy( 1, flags.extended_options_flag ? 2 : 1 ); 91 | con_print( "NON-RELEASE BUILD" ); 92 | con_set_cursor_xy( 61, flags.extended_options_flag ? 2 : 1 ); 93 | con_print( __DATE__ " " __TIME__ ); 94 | #endif 95 | 96 | #ifdef DEBUG 97 | con_set_cursor_xy( 61, 1 ); 98 | con_print( "DEBUG" ); 99 | 100 | if ( debug.write == FALSE ) { 101 | con_set_cursor_xy( 70, 1 ); 102 | con_print( "RO" ); 103 | } 104 | #endif 105 | } 106 | 107 | /* Print Centered Text */ 108 | void Print_Centered( int y, const char *text, int style ) 109 | { 110 | int x = 40 - strlen( text ) / 2; 111 | int was_bold = con_get_bold(); 112 | 113 | con_set_cursor_xy( x + 1, y + 1 ); 114 | 115 | if ( style == BOLD ) { 116 | con_set_bold( 1 ); 117 | } 118 | con_print( text ); 119 | con_set_bold( was_bold ); 120 | } 121 | 122 | /* Print 7 Digit Unsigned Long Values */ 123 | void Print_UL( unsigned long number ) { con_printf( "%7lu", number ); } 124 | 125 | /* Print 7 Digit Unsigned Long Values in bold print */ 126 | void Print_UL_B( unsigned long number ) 127 | { 128 | con_printf( "\33[1m%7lu\33[22m", number ); 129 | } 130 | 131 | /* Dump the partition tables from all drives to screen */ 132 | void Dump_Partition_Information( void ) 133 | { 134 | int index = 0; 135 | //flags.extended_options_flag=TRUE; 136 | 137 | do { 138 | flags.drive_number = index + 128; 139 | Display_CL_Partition_Table(); 140 | index++; 141 | } while ( index + 128 <= flags.maximum_drive_number ); 142 | } 143 | 144 | void Display_CL_Partition_Table( void ) 145 | { 146 | int index = 0; 147 | unsigned long usage = 0; 148 | Partition_Table *pDrive = &part_table[flags.drive_number - 0x80]; 149 | Partition *p; 150 | 151 | Determine_Drive_Letters(); 152 | 153 | /* NLS:Current fixed disk drive: */ 154 | con_printf( "\n%s %1d", svarlang_str( 9, 0 ), 155 | ( flags.drive_number - 127 ) ); 156 | 157 | con_printf( " %lu %s %lu/%03lu/%02lu", pDrive->disk_size_sect, 158 | svarlang_str( 9, 3 ), pDrive->total_cyl + 1, 159 | pDrive->total_head + 1, pDrive->total_sect ); 160 | 161 | if ( !Is_Pri_Tbl_Empty() ) { 162 | /* NLS:Partition Status Mbytes Description [...] */ 163 | con_printf( svarlang_str( 9, 10 ) ); 164 | } 165 | else { 166 | /*NLS:No partitions defined. */ 167 | con_print( "\n\n" ); 168 | con_print( svarlang_str( 9, 4 ) ); 169 | con_print( "\n" ); 170 | } 171 | 172 | index = 0; 173 | do { 174 | p = &pDrive->pri_part[index]; 175 | if ( p->num_type > 0 ) { 176 | /* Drive Letter of Partition */ 177 | if ( IsRecognizedFatPartition( p->num_type ) ) { 178 | con_printf( " %1c:", drive_letter_or_questionmark( drive_lettering_buffer[( flags.drive_number - 128 )][index] ) ); 179 | } 180 | else { 181 | con_print( " " ); 182 | } 183 | 184 | /* Partition Number */ 185 | con_printf( " %1d", ( index + 1 ) ); 186 | 187 | /* Partition Type */ 188 | con_printf( " %3d", ( p->num_type ) ); 189 | 190 | /* Status */ 191 | if ( p->active_status > 0 ) { 192 | con_print( " A" ); 193 | } 194 | else { 195 | con_print( " " ); 196 | } 197 | 198 | /* Mbytes */ 199 | con_print( " " ); 200 | Print_UL( p->size_in_MB ); 201 | 202 | /* Description */ 203 | con_printf( " %-15s", part_type_descr( p->num_type ) ); 204 | 205 | /* Usage */ 206 | usage = Convert_To_Percentage( p->size_in_MB, pDrive->disk_size_mb ); 207 | 208 | con_printf( " %3lu%%", usage ); 209 | 210 | /* Starting Cylinder */ 211 | con_printf( "%6lu/%03lu/%02lu", p->start_cyl, p->start_head, 212 | p->start_sect ); 213 | 214 | /* Ending Cylinder */ 215 | con_printf( " %6lu/%03lu/%02lu", p->end_cyl, p->end_head, 216 | p->end_sect ); 217 | con_putc( '\n' ); 218 | } 219 | 220 | index++; 221 | } while ( index < 4 ); 222 | /* NLS:Largest continious free space for primary partition */ 223 | con_printf( svarlang_str( 9, 5 ), Max_Pri_Free_Space_In_MB() ); 224 | 225 | if ( pDrive->ptr_ext_part && !pDrive->ext_usable ) { 226 | /* NLS:No usable extended partition found. */ 227 | con_print( svarlang_str( 8, 7 ) ); 228 | return; 229 | } 230 | 231 | /* Check to see if there are any drives to display */ 232 | if ( ( brief_partition_table[( flags.drive_number - 128 )][4] > 0 ) || 233 | ( brief_partition_table[( flags.drive_number - 128 )][5] > 0 ) ) { 234 | /* NLS:Contents of Extended DOS Partition: */ 235 | con_printf( svarlang_str( 9, 6 ) ); 236 | /* NLS:Drv Volume Label Mbytes System [...] */ 237 | con_printf( svarlang_str( 9, 11 ) ); 238 | 239 | /* Display information for each Logical DOS Drive */ 240 | index = 4; 241 | do { 242 | p = &pDrive->log_drive[index - 4]; 243 | if ( brief_partition_table[( flags.drive_number - 128 )][index] > 244 | 0 ) { 245 | if ( IsRecognizedFatPartition( brief_partition_table[( 246 | flags.drive_number - 128 )][index] ) ) { 247 | /* Display drive letter */ 248 | con_printf( " %1c:", drive_letter_or_questionmark( drive_lettering_buffer[(flags.drive_number - 128 )][index] ) ); 249 | 250 | /* Display volume label */ 251 | con_printf( " %11s", p->vol_label ); 252 | } 253 | else { 254 | con_printf( " " ); 255 | } 256 | 257 | /* Display size in MB */ 258 | con_print( " " ); 259 | Print_UL( p->size_in_MB ); 260 | 261 | /* Display file system type */ 262 | con_printf( " %-15s", part_type_descr( p->num_type ) ); 263 | 264 | /* Display usage in % */ 265 | usage = 266 | Convert_To_Percentage( p->num_sect, pDrive->ext_num_sect ); 267 | 268 | con_printf( " %3lu%%", usage ); 269 | 270 | /* Starting Cylinder */ 271 | con_printf( "%6lu/%03lu/%02lu", p->start_cyl, p->start_head, 272 | p->start_sect ); 273 | 274 | /* Ending Cylinder */ 275 | con_printf( " %6lu/%03lu/%02lu", p->end_cyl, p->end_head, 276 | p->end_sect ); 277 | con_putc( '\n' ); 278 | } 279 | 280 | index++; 281 | } while ( index < 27 ); 282 | /*NLS:Largest continious free space in extended partition [...] */ 283 | con_printf( svarlang_str( 9, 7 ), Max_Log_Free_Space_In_MB() ); 284 | } 285 | con_putc( '\n' ); 286 | } 287 | 288 | /* Display information for all hard drives */ 289 | void Display_All_Drives( void ) 290 | { 291 | int current_column_offset_of_general_drive_information; 292 | int current_column_offset = 4; 293 | int current_line = 3; 294 | int current_line_of_general_drive_information; 295 | int drive = 1; 296 | int drive_letter_index = 0; 297 | int index; 298 | 299 | long space_used_on_drive_in_MB; 300 | 301 | unsigned long usage; 302 | 303 | Determine_Drive_Letters(); 304 | 305 | con_set_cursor_xy( 3, 3 ); 306 | /* NLS:Disk Drv Mbytes Free Usage */ 307 | con_print( svarlang_str( 9, 12 ) ); 308 | 309 | for ( drive = 1; drive <= flags.maximum_drive_number - 127; drive++ ) { 310 | if ( current_line > 18 ) { 311 | current_line = 3; 312 | current_column_offset = 45; 313 | 314 | con_set_cursor_xy( 44, 3 ); 315 | con_print( svarlang_str( 9, 12 ) ); 316 | } 317 | 318 | /* Print physical drive information */ 319 | current_column_offset_of_general_drive_information = 320 | current_column_offset; 321 | current_line_of_general_drive_information = current_line; 322 | space_used_on_drive_in_MB = 0; 323 | 324 | /* Print drive number */ 325 | con_set_cursor_xy( current_column_offset_of_general_drive_information + 326 | 1, 327 | current_line + 1 ); 328 | con_printf( ESC_BOLD_ON "%d" ESC_BOLD_OFF, drive ); 329 | 330 | /* Print size of drive */ 331 | 332 | if ( !part_table[drive - 1].usable ) { 333 | /* NLS:-------- unusable --------- */ 334 | con_printf( svarlang_str( 9, 8 ) ); 335 | current_line++; 336 | continue; 337 | } 338 | 339 | con_set_cursor_xy( 340 | ( current_column_offset_of_general_drive_information + 11 ), 341 | current_line + 1 ); 342 | Print_UL( part_table[drive - 1].disk_size_mb ); 343 | 344 | /* Get space_used_on_drive_in_MB */ 345 | for ( index = 0; index <= 3; index++ ) { 346 | if ( ( part_table[drive - 1].pri_part[index].num_type != 5 ) && 347 | ( part_table[drive - 1].pri_part[index].num_type != 15 ) && 348 | ( part_table[drive - 1].pri_part[index].num_type != 0 ) ) { 349 | space_used_on_drive_in_MB += 350 | part_table[drive - 1].pri_part[index].size_in_MB; 351 | } 352 | } 353 | 354 | for ( index = 0; index < MAX_LOGICAL_DRIVES; index++ ) { 355 | if ( part_table[drive - 1].log_drive[index].num_type > 0 ) { 356 | space_used_on_drive_in_MB += 357 | part_table[drive - 1].log_drive[index].size_in_MB; 358 | } 359 | } 360 | 361 | /* Print logical drives on disk, if applicable */ 362 | 363 | drive_letter_index = 0; 364 | do { 365 | if ( drive_lettering_buffer[drive - 1][drive_letter_index] > 0 ) { 366 | current_line++; 367 | 368 | if ( current_line > 18 ) { 369 | current_line = 3; 370 | current_column_offset = 45; 371 | 372 | con_set_cursor_xy( 44, 3 ); 373 | con_print( "Disk Drv Mbytes Free Usage" ); 374 | } 375 | 376 | /* Print drive letter of logical drive */ 377 | if ( ( ( drive_lettering_buffer[drive - 1][drive_letter_index] >= 378 | 'C' ) && 379 | ( drive_lettering_buffer[drive - 1][drive_letter_index] <= 380 | 'Z' ) ) || 381 | ( flags.del_non_dos_log_drives == TRUE ) ) { 382 | con_set_cursor_xy( ( current_column_offset + 7 ), 383 | current_line + 1 ); 384 | con_printf( 385 | "%c:", 386 | drive_lettering_buffer[drive - 1][drive_letter_index] ); 387 | } 388 | else { 389 | con_set_cursor_xy( ( current_column_offset + 9 ), 390 | current_line + 1 ); 391 | } 392 | 393 | /* Print size of logical drive */ 394 | con_set_cursor_xy( ( current_column_offset + 11 ), 395 | current_line + 1 ); 396 | 397 | if ( drive_letter_index < 4 ) { 398 | Print_UL( part_table[drive - 1] 399 | .pri_part[drive_letter_index] 400 | .size_in_MB ); 401 | } 402 | else { 403 | 404 | Print_UL( part_table[drive - 1] 405 | .log_drive[( drive_letter_index - 4 )] 406 | .size_in_MB ); 407 | } 408 | } 409 | 410 | drive_letter_index++; 411 | } while ( drive_letter_index < 27 ); 412 | 413 | /* Print amount of free space on drive */ 414 | if ( part_table[drive - 1].disk_size_mb > space_used_on_drive_in_MB ) { 415 | con_set_cursor_xy( 416 | ( current_column_offset_of_general_drive_information + 19 ), 417 | current_line_of_general_drive_information + 1 ); 418 | Print_UL( part_table[drive - 1].disk_size_mb - 419 | space_used_on_drive_in_MB ); 420 | } 421 | 422 | /* Print drive usage percentage */ 423 | if ( space_used_on_drive_in_MB == 0 ) { 424 | usage = 0; 425 | } 426 | else { 427 | usage = Convert_To_Percentage( space_used_on_drive_in_MB, 428 | part_table[drive - 1].disk_size_mb ); 429 | } 430 | 431 | con_set_cursor_xy( 432 | ( current_column_offset_of_general_drive_information + 29 ), 433 | current_line_of_general_drive_information + 1 ); 434 | con_printf( "%3d%%", usage ); 435 | 436 | current_line++; 437 | } 438 | 439 | con_set_cursor_xy( 5, 21 ); 440 | /*NLS:(1 Mbyte = 1048576 bytes) */ 441 | con_print( svarlang_str( 9, 9 ) ); 442 | } 443 | 444 | static struct { 445 | int id; 446 | const char *descr; /* 17 characters max. */ 447 | const char *descr_short; /* 9 characters max. */ 448 | } pt_descr[] = { { 0x00, "Unused" }, 449 | { 0x01, "FAT-12", "FAT12" }, 450 | { 0x04, "FAT-16 <32M", "FAT16" }, 451 | { 0x05, "Extended", "Ext" }, 452 | { 0x06, "FAT-16", "FAT16" }, 453 | { 0x07, "NTFS / HPFS", "NTFS" }, 454 | { 0x0b, "FAT-32", "FAT32" }, 455 | { 0x0c, "FAT-32 LBA", "FAT32 LBA" }, 456 | { 0x0e, "FAT-16 LBA", "FAT16 LBA" }, 457 | { 0x0f, "Extended LBA", "Ext LBA" }, 458 | 459 | { 0x11, "Hid. FAT-12", "H FAT12" }, 460 | { 0x14, "Hid. FAT-16<32M", "H FAT16" }, 461 | { 0x15, "Hid. Extended", "H Ext" }, 462 | { 0x16, "Hid. FAT-16", "H FAT16" }, 463 | { 0x17, "Hid. NTFS/HPFS", "H NTFS" }, 464 | { 0x1b, "Hid. FAT-32", "H FAT32" }, 465 | { 0x1c, "Hid. FAT-32 LBA", "H FAT32 L" }, 466 | { 0x1e, "Hid. FAT-16 LBA", "H FAT16 L" }, 467 | { 0x1f, "Hid. Ext. LBA", "H Ext L" }, 468 | 469 | { 0x82, "Linux Swap", "LinuxSwap" }, 470 | { 0x83, "Linux" }, 471 | 472 | { 0xa5, "BSD" }, 473 | { 0xa6, "OpenBSD" }, 474 | { 0xa9, "NetBSD" }, 475 | 476 | { 0xee, "GPT protective", "GPTprot" }, 477 | { 0xeb, "EFI" }, 478 | 479 | { -1, "Unknown" } }; 480 | 481 | const char *part_type_descr( int id ) 482 | { 483 | int i; 484 | 485 | for ( i = 0; pt_descr[i].id != id && pt_descr[i].id >= 0; i++ ) 486 | ; 487 | return pt_descr[i].descr; 488 | } 489 | 490 | const char *part_type_descr_short( int id ) 491 | { 492 | int i; 493 | 494 | for ( i = 0; pt_descr[i].id != id && pt_descr[i].id >= 0; i++ ) 495 | ; 496 | return ( pt_descr[i].descr_short ) ? pt_descr[i].descr_short 497 | : pt_descr[i].descr; 498 | } 499 | -------------------------------------------------------------------------------- /source/fdisk/ansicon.c: -------------------------------------------------------------------------------- 1 | /* This file is part of the ANSICON project and is published under the terms 2 | * of the MIT license. 3 | * 4 | * Copyright (C) 2023 Bernd Boeckmann 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #ifdef __GNUC__ 31 | #include 32 | #endif 33 | #include "ansicon.h" 34 | 35 | #define CON_MAX_ARG 4 36 | 37 | int con_error; 38 | 39 | static unsigned con_width; 40 | static unsigned con_height; 41 | static unsigned con_size; 42 | static char con_attributes_enabled = 1; 43 | 44 | static int con_curx; 45 | static int con_cury; 46 | 47 | static unsigned char con_textattr; 48 | 49 | static char flag_interpret_esc; 50 | 51 | /* escape sequence arguments */ 52 | static int arg_count; 53 | static int arg[CON_MAX_ARG]; 54 | 55 | static char con_is_device; 56 | static char con_is_monochrome; 57 | static char cursor_sync_disabled; 58 | 59 | static unsigned char vid_page; 60 | static unsigned short __far *vid_mem; 61 | 62 | static void con_get_hw_cursor( int *x, int *y ); 63 | static void con_set_hw_cursor( int x, int y ); 64 | static void con_advance_cursor( void ); 65 | 66 | static int detect_ega( void ) 67 | { 68 | union REGPACK r; 69 | memset( &r, 0, sizeof( union REGPACK ) ); 70 | r.h.ah = 0x12; 71 | r.h.bl = 0x10; 72 | intr( 0x10, &r ); 73 | return r.h.bl != 0x10; 74 | } 75 | 76 | void con_init( int interpret_esc ) 77 | { 78 | union REGPACK r; 79 | unsigned char blinking_enabled; 80 | 81 | flag_interpret_esc = interpret_esc; 82 | 83 | /* detect video mode */ 84 | memset( &r, 0, sizeof( union REGPACK ) ); 85 | r.h.ah = 0xf; 86 | intr( 0x10, &r ); 87 | con_is_monochrome = ( r.h.al == 7 ); 88 | vid_page = r.h.bh; 89 | vid_mem = ( con_is_monochrome ) ? MK_FP( 0xb000, 0 ) : MK_FP( 0xb800, 0 ); 90 | 91 | /* screen size ? */ 92 | con_width = r.h.ah; 93 | if ( detect_ega() ) { 94 | con_height = ( *(unsigned char __far *)MK_FP( 0x40, 0x84 ) ) + 1; 95 | blinking_enabled = 96 | ( *(unsigned char __far *)MK_FP( 0x40, 0x65 ) ) & 0x20; 97 | if ( !blinking_enabled ) { 98 | /* set >=ega blinking bit */ 99 | memset( &r, 0, sizeof( union REGPACK ) ); 100 | r.w.ax = 0x1003; 101 | r.w.bx = 1; 102 | intr( 0x10, &r ); 103 | } 104 | } 105 | else { 106 | con_height = 25; 107 | } 108 | con_size = con_width * con_height; 109 | 110 | /* are we writing to screen or file? */ 111 | memset( &r, 0, sizeof( union REGPACK ) ); 112 | r.w.ax = 0x4400; 113 | r.w.bx = 1; /* stdout handle */ 114 | intr( 0x21, &r ); 115 | con_is_device = ( r.w.dx & 0x80 ) != 0; 116 | 117 | con_reset_attr(); 118 | con_get_hw_cursor( &con_curx, &con_cury ); 119 | cursor_sync_disabled = 0; 120 | } 121 | 122 | unsigned con_get_width( void ) { return con_width; } 123 | 124 | unsigned con_get_height( void ) { return con_height; } 125 | 126 | /* function to disable hardware cursor sync */ 127 | void con_disable_cursor_sync( void ) { cursor_sync_disabled++; } 128 | 129 | int con_is_tty( void ) { return con_is_device; } 130 | 131 | /* function to enable cursor sync */ 132 | void con_enable_cursor_sync( void ) 133 | { 134 | if ( cursor_sync_disabled ) { 135 | cursor_sync_disabled--; 136 | } 137 | 138 | if ( !cursor_sync_disabled ) { 139 | con_set_hw_cursor( con_curx, con_cury ); 140 | } 141 | } 142 | 143 | void con_set_cursor_xy( int x, int y ) 144 | { 145 | if ( x < 1 ) { 146 | x = 1; 147 | } 148 | if ( y < 1 ) { 149 | y = 1; 150 | } 151 | if ( x > con_width ) { 152 | x = con_width; 153 | } 154 | if ( y > con_height ) { 155 | y = con_height; 156 | } 157 | 158 | con_curx = x; 159 | con_cury = y; 160 | 161 | if ( !cursor_sync_disabled ) { 162 | con_set_hw_cursor( con_curx, con_cury ); 163 | } 164 | } 165 | 166 | void con_set_cursor_rel( int dx, int dy ) 167 | { 168 | int x, y; 169 | 170 | x = con_curx + dx; 171 | y = con_cury + dy; 172 | 173 | con_set_cursor_xy( x, y ); 174 | } 175 | 176 | void con_get_cursor_xy( int *x, int *y ) 177 | { 178 | *x = con_curx; 179 | *y = con_cury; 180 | } 181 | 182 | int con_get_cursor_x( void ) { return con_curx; } 183 | 184 | int con_get_cursor_y( void ) { return con_cury; } 185 | 186 | static int curx_save = 1, cury_save = 1; 187 | 188 | void con_save_cursor_xy( void ) 189 | { 190 | curx_save = con_curx; 191 | cury_save = con_cury; 192 | } 193 | 194 | void con_restore_cursor_xy( void ) 195 | { 196 | con_curx = curx_save; 197 | con_cury = cury_save; 198 | } 199 | 200 | static void con_get_hw_cursor( int *x, int *y ) 201 | { 202 | union REGPACK r; 203 | 204 | memset( &r, 0, sizeof( union REGPACK ) ); 205 | r.h.ah = 0x03; 206 | r.h.bh = vid_page; 207 | intr( 0x10, &r ); 208 | 209 | *x = r.h.dl + 1; 210 | *y = r.h.dh + 1; 211 | } 212 | 213 | static void con_set_hw_cursor( int x, int y ) 214 | { 215 | union REGPACK r; 216 | 217 | if ( !con_is_device ) { 218 | return; 219 | } 220 | 221 | memset( &r, 0, sizeof( union REGPACK ) ); 222 | r.h.ah = 0x02; 223 | r.h.bh = vid_page; 224 | r.h.dl = x - 1; 225 | r.h.dh = y - 1; 226 | intr( 0x10, &r ); 227 | } 228 | 229 | void con_sync_from_hw_cursor( void ) 230 | { 231 | con_get_hw_cursor( &con_curx, &con_cury ); 232 | } 233 | 234 | static void con_advance_cursor( void ) 235 | { 236 | int x, y; 237 | 238 | x = con_curx; 239 | y = con_cury; 240 | 241 | if ( x < con_width ) { 242 | x += 1; 243 | } 244 | else { 245 | x = 1; 246 | y += 1; 247 | } 248 | 249 | if ( y > con_height ) { 250 | con_scroll( 1 ); 251 | y = con_height; 252 | } 253 | 254 | con_set_cursor_xy( x, y ); 255 | } 256 | 257 | /* waits for a key press and returns it. 258 | * extended keys are returned ORed with 0x100 */ 259 | int con_readkey( void ) 260 | { 261 | union REGPACK r; 262 | 263 | memset( &r, 0, sizeof( union REGPACK ) ); 264 | r.h.ah = 7; 265 | intr( 0x21, &r ); 266 | if ( r.h.al > 0 ) { 267 | return r.h.al; 268 | } 269 | 270 | memset( &r, 0, sizeof( union REGPACK ) ); 271 | r.h.ah = 7; 272 | intr( 0x21, &r ); 273 | return 0x100 | r.h.al; 274 | } 275 | 276 | static void con_nl( void ) 277 | { 278 | int x, y; 279 | 280 | x = 1; 281 | y = con_cury + 1; 282 | 283 | if ( y > con_height ) { 284 | con_scroll( 1 ); 285 | y = con_height; 286 | } 287 | 288 | con_set_cursor_xy( x, y ); 289 | } 290 | 291 | static void con_cr( void ) { con_set_cursor_xy( 1, con_cury ); } 292 | 293 | static void _con_putc_plain( char c ) 294 | { 295 | union REGPACK r; 296 | unsigned v; 297 | int i, n; 298 | 299 | if ( con_is_device ) { 300 | if ( (unsigned char)c >= 0x20 ) { 301 | /* handle printable characters */ 302 | v = ( con_textattr << 8 ) | (unsigned char)c; 303 | vid_mem[( con_cury - 1 ) * con_width + ( con_curx - 1 )] = v; 304 | 305 | con_advance_cursor(); 306 | } 307 | else { 308 | /* handle control characters */ 309 | switch ( c ) { 310 | case '\n': /* new line */ 311 | con_nl(); 312 | break; 313 | case '\r': /* carrige return */ 314 | con_cr(); 315 | break; 316 | case '\t': 317 | n = 8 - ( con_curx & 7 ); 318 | for ( i = 0; i <= n; i++ ) { 319 | _con_putc_plain( ' ' ); 320 | } 321 | break; 322 | } 323 | } 324 | } 325 | else { 326 | /* writing to file, use DOS calls */ 327 | memset( &r, 0, sizeof( union REGPACK ) ); 328 | if ( c == '\n' ) { 329 | /* hack in a CR befor NL when writing to a file */ 330 | r.h.ah = 2; 331 | r.h.dl = '\r'; 332 | intr( 0x21, &r ); 333 | } 334 | r.h.ah = 2; 335 | r.h.dl = c; 336 | intr( 0x21, &r ); 337 | } 338 | } 339 | 340 | void con_scroll( int n ) 341 | { 342 | int distance; 343 | int last, i; 344 | unsigned v; 345 | 346 | if ( !con_is_device || n == 0 ) { 347 | return; 348 | } 349 | 350 | if ( n > 0 ) { 351 | /* scroll up */ 352 | if ( n > con_height ) { 353 | n = con_height; 354 | } 355 | last = ( con_height - n ) * con_width; 356 | distance = n * con_width; 357 | v = ( con_textattr << 8 ) | ' '; 358 | 359 | _fmemmove( vid_mem, vid_mem + distance, last << 1 ); 360 | for ( i = last; i < con_size; i++ ) { 361 | vid_mem[i] = v; 362 | } 363 | } 364 | } 365 | 366 | void con_clrscr( void ) 367 | { 368 | int i; 369 | unsigned v; 370 | 371 | if ( !con_is_device ) { 372 | return; 373 | } 374 | 375 | v = ( con_textattr << 8 ) | ' '; 376 | 377 | for ( i = 0; i < con_size; i++ ) { 378 | vid_mem[i] = v; 379 | } 380 | 381 | con_set_cursor_xy( 1, 1 ); 382 | } 383 | 384 | void con_clreol( void ) 385 | { 386 | unsigned v; 387 | int x; 388 | 389 | if ( !con_is_device ) { 390 | return; 391 | } 392 | 393 | v = ( con_textattr << 8 ) | ' '; 394 | for ( x = con_curx; x <= con_width; x++ ) { 395 | vid_mem[( con_cury - 1 ) * con_width + ( x - 1 )] = v; 396 | } 397 | } 398 | 399 | void con_enable_attr( int flag ) { con_attributes_enabled = (char)flag; } 400 | 401 | void con_reset_attr( void ) { con_textattr = 7; } 402 | 403 | void con_set_bold( int flag ) 404 | { 405 | if ( !con_attributes_enabled ) { 406 | return; 407 | } 408 | 409 | if ( flag ) { 410 | con_textattr |= 0x08; 411 | } 412 | else { 413 | con_textattr &= 0xf7; 414 | } 415 | } 416 | 417 | int con_get_bold( void ) { return ( con_textattr & 0x08 ) != 0; } 418 | 419 | void con_set_textcolor( int color ) 420 | { 421 | color &= 7; 422 | if ( !con_attributes_enabled ) { 423 | return; 424 | } 425 | if ( con_is_monochrome && color != 0 ) { 426 | color = 7; 427 | } 428 | con_textattr = ( con_textattr & 0xf8 ) | color; 429 | } 430 | 431 | void con_set_backcolor( int color ) 432 | { 433 | color &= 7; 434 | if ( !con_attributes_enabled ) { 435 | return; 436 | } 437 | if ( con_is_monochrome && color != 0 ) { 438 | color = 7; 439 | } 440 | con_textattr = ( con_textattr & 0x8f ) | ( color << 4 ); 441 | } 442 | 443 | void con_set_blinking( int flag ) 444 | { 445 | if ( !con_attributes_enabled ) { 446 | return; 447 | } 448 | con_textattr = ( con_textattr & 0x7f ) | ( ( flag & 1 ) << 7 ); 449 | } 450 | 451 | static int handle_ansi_function( char function ) 452 | { 453 | int i, argi; 454 | 455 | switch ( function ) { 456 | case 'H': /* position cursor */ 457 | case 'f': 458 | if ( arg[0] < 1 ) { 459 | arg[0] = 1; 460 | } 461 | if ( arg[1] < 1 ) { 462 | arg[1] = 1; 463 | } 464 | 465 | if ( con_is_device ) { 466 | con_set_cursor_xy( arg[0], arg[1] ); 467 | } 468 | return 1; 469 | 470 | case 'A': /* cursor up */ 471 | if ( con_is_device ) { 472 | con_set_cursor_rel( 0, arg[0] ); 473 | } 474 | return 1; 475 | 476 | case 'B': /* cursor down */ 477 | if ( arg[0] == -1 ) { 478 | arg[0] = 1; 479 | } 480 | if ( con_is_device ) { 481 | con_set_cursor_rel( 0, arg[0] ); 482 | } 483 | return 1; 484 | 485 | case 'C': /* cursor right */ 486 | if ( arg[0] == -1 ) { 487 | arg[0] = 1; 488 | } 489 | if ( con_is_device ) { 490 | con_set_cursor_rel( arg[0], 0 ); 491 | } 492 | return 1; 493 | 494 | case 'D': /* cursor left */ 495 | if ( con_is_device ) { 496 | con_set_cursor_rel( arg[0], 0 ); 497 | } 498 | return 1; 499 | 500 | case 'J': /* erase display */ 501 | if ( arg_count != 1 || arg[0] != 2 ) { 502 | return 0; 503 | } 504 | if ( con_is_device ) { 505 | con_clrscr(); 506 | } 507 | return 1; 508 | 509 | case 'K': /* erase line */ 510 | if ( con_is_device ) { 511 | con_clreol(); 512 | } 513 | return 1; 514 | 515 | case 'm': /* set text attributes */ 516 | for ( i = 0; i < arg_count; i++ ) { 517 | argi = arg[i]; 518 | if ( argi == 0 ) { 519 | con_reset_attr(); 520 | } 521 | else if ( argi == 1 ) { 522 | con_set_bold( 1 ); 523 | } 524 | else if ( argi == 5 ) { 525 | con_set_blinking( 1 ); 526 | } 527 | else if ( argi == 22 ) { 528 | con_set_bold( 0 ); 529 | } 530 | else if ( argi == 25 ) { 531 | con_set_blinking( 0 ); 532 | } 533 | else if ( argi >= 30 && argi <= 37 ) { 534 | con_set_textcolor( argi - 30 ); 535 | } 536 | else if ( argi >= 40 && argi <= 47 ) { 537 | con_set_backcolor( argi - 40 ); 538 | } 539 | } 540 | return 1; 541 | } 542 | 543 | return 0; 544 | } 545 | 546 | static void _con_putc_ansi( char c ) 547 | { 548 | static enum { S_NONE, S_START, S_START2, S_ARG, S_FINI, S_ERR } state; 549 | 550 | int i; 551 | 552 | switch ( state ) { 553 | case S_NONE: 554 | if ( c == '\33' ) { 555 | /* start of escape sequence, reset internal state */ 556 | arg_count = 0; 557 | for ( i = 0; i < CON_MAX_ARG; i++ ) { 558 | arg[i] = -1; 559 | } 560 | state++; 561 | } 562 | else { 563 | _con_putc_plain( c ); 564 | return; 565 | } 566 | break; 567 | case S_START: 568 | /* skip [ following escape character */ 569 | if ( c == '[' ) { 570 | state++; 571 | } 572 | else { 573 | state = S_ERR; 574 | } 575 | break; 576 | 577 | case S_START2: 578 | /* if first character after [ is no letter (command), it must be a 579 | (possibly empty) numeric argument */ 580 | if ( !isalpha( c ) ) { 581 | arg_count++; 582 | } 583 | state++; 584 | /* fallthrough !! */ 585 | case S_ARG: /* process numeric arguments and command */ 586 | if ( isdigit( c ) ) { 587 | /* numeric argument */ 588 | if ( arg[arg_count - 1] == -1 ) { 589 | arg[arg_count - 1] = 0; 590 | } 591 | arg[arg_count - 1] = 10 * arg[arg_count - 1] + ( c - '0' ); 592 | } 593 | else if ( c == ';' ) { 594 | /* semicolon starts a new (possibly empty) numeric argument */ 595 | if ( arg_count < CON_MAX_ARG - 1 ) { 596 | arg_count++; 597 | } 598 | else { 599 | state = S_ERR; 600 | } 601 | } 602 | else if ( isalpha( c ) ) { 603 | if ( handle_ansi_function( c ) ) { 604 | state = S_FINI; 605 | } 606 | else { 607 | state = S_ERR; 608 | } 609 | } 610 | else { 611 | state = S_ERR; 612 | } 613 | break; 614 | 615 | default: 616 | break; 617 | } 618 | 619 | switch ( state ) { 620 | case S_ERR: 621 | con_error = 1; 622 | state = S_NONE; 623 | break; 624 | 625 | case S_FINI: 626 | state = S_NONE; 627 | 628 | default: 629 | break; 630 | } 631 | } 632 | 633 | void con_print( const char *s ) 634 | { 635 | con_disable_cursor_sync(); 636 | if ( flag_interpret_esc ) { 637 | while ( *s ) { 638 | _con_putc_ansi( *s++ ); 639 | } 640 | } 641 | else { 642 | while ( *s ) { 643 | _con_putc_plain( *s++ ); 644 | } 645 | } 646 | con_enable_cursor_sync(); 647 | } 648 | 649 | void con_puts( const char *s ) 650 | { 651 | con_disable_cursor_sync(); 652 | con_print( s ); 653 | con_putc( '\n' ); 654 | con_enable_cursor_sync(); 655 | } 656 | 657 | void con_print_at( int x, int y, const char *s ) 658 | { 659 | con_disable_cursor_sync(); 660 | con_set_cursor_xy( x, y ); 661 | con_print( s ); 662 | con_enable_cursor_sync(); 663 | } 664 | 665 | void con_putc( char c ) 666 | { 667 | if ( flag_interpret_esc ) { 668 | _con_putc_ansi( c ); 669 | } 670 | else { 671 | _con_putc_plain( c ); 672 | } 673 | } 674 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | fdisk 294 | Copyright (C) 2021 FDOS / Base 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------