add directory Minix
This commit is contained in:
138
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/CALCULAT.CPP
Normal file
138
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/CALCULAT.CPP
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module calculat.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/calculat.cpp 1.4 1995/01/19 00:00:49 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include "hdstruct.h"
|
||||
#include "fipsspec.h"
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Some calculations */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void fips_partition_table::calculate_new_root
|
||||
(
|
||||
dword new_start_cylinder,
|
||||
partition *partition,
|
||||
const drive_geometry &geometry
|
||||
)
|
||||
{
|
||||
for (int i = 0; i < 3; i++) if (!partition_info[i].system)
|
||||
// move DOS partitions to the beginning of the partition table
|
||||
{
|
||||
for (int j = i + 1; j < 4; j++) if
|
||||
(
|
||||
(partition_info[j].system == 1) ||
|
||||
(partition_info[j].system == 4) ||
|
||||
(partition_info[j].system == 6)
|
||||
)
|
||||
{
|
||||
struct partition_info tmppart = partition_info[i];
|
||||
partition_info[i] = partition_info[j];
|
||||
partition_info[j] = tmppart;
|
||||
|
||||
if (partition->number == j) partition->number = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int partition_no = partition->number;
|
||||
partition->partition_info = &partition_info[partition_no];
|
||||
|
||||
for (i=0;i<4;i++) if (!partition_info[i].system) break;
|
||||
// search for first empty slot
|
||||
|
||||
struct partition_info *newpart = &partition_info[i];
|
||||
struct partition_info *oldpart = &partition_info[partition_no];
|
||||
|
||||
newpart->bootable = 0;
|
||||
|
||||
newpart->start_sector_abs =
|
||||
new_start_cylinder *
|
||||
geometry.heads *
|
||||
geometry.sectors;
|
||||
|
||||
newpart->no_of_sectors_abs =
|
||||
oldpart->start_sector_abs +
|
||||
oldpart->no_of_sectors_abs -
|
||||
newpart->start_sector_abs;
|
||||
|
||||
if
|
||||
(
|
||||
(newpart->no_of_sectors_abs > 0xffff) ||
|
||||
(newpart->start_sector_abs > 0xffff)
|
||||
)
|
||||
{
|
||||
newpart->system = 6;
|
||||
}
|
||||
else if
|
||||
(
|
||||
newpart->no_of_sectors_abs >= 20740
|
||||
)
|
||||
{
|
||||
newpart->system = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
newpart->system = 1;
|
||||
}
|
||||
|
||||
oldpart->no_of_sectors_abs =
|
||||
newpart->start_sector_abs -
|
||||
oldpart->start_sector_abs;
|
||||
|
||||
if
|
||||
(
|
||||
(oldpart->no_of_sectors_abs > 0xffff) ||
|
||||
(oldpart->start_sector_abs > 0xffff)
|
||||
)
|
||||
{
|
||||
oldpart->system = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldpart->system = 4;
|
||||
}
|
||||
|
||||
correct_physical (geometry);
|
||||
}
|
||||
|
||||
|
||||
void fips_bpb::calculate_new_boot (const partition_info &partition_info)
|
||||
{
|
||||
if ((partition_info.no_of_sectors_abs > 0xffff) || (partition_info.start_sector_abs > 0xffff))
|
||||
{
|
||||
no_of_sectors = 0;
|
||||
no_of_sectors_long = partition_info.no_of_sectors_abs;
|
||||
}
|
||||
else
|
||||
{
|
||||
no_of_sectors_long = 0;
|
||||
no_of_sectors = partition_info.no_of_sectors_abs;
|
||||
}
|
||||
}
|
||||
361
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/CHECK.CPP
Normal file
361
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/CHECK.CPP
Normal file
@@ -0,0 +1,361 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module check.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/check.cpp 1.4 1995/01/19 00:20:41 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "hdstruct.h"
|
||||
#include "global.h"
|
||||
#include "fipsspec.h"
|
||||
#include "input.h"
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Consistency check of root sector / partition table */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void fips_partition_table::correct_physical (const drive_geometry &geometry)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (partition_info[i].system)
|
||||
{
|
||||
physical_sector_no start
|
||||
(
|
||||
partition_info[i].start_sector_abs,
|
||||
geometry
|
||||
);
|
||||
|
||||
partition_info[i].start_cylinder = start.cylinder;
|
||||
partition_info[i].start_head = start.head;
|
||||
partition_info[i].start_sector = start.sector;
|
||||
// recalculate 'physical' start sector
|
||||
|
||||
physical_sector_no end
|
||||
(
|
||||
partition_info[i].start_sector_abs
|
||||
+ partition_info[i].no_of_sectors_abs
|
||||
- 1,
|
||||
geometry
|
||||
);
|
||||
|
||||
partition_info[i].end_cylinder = end.cylinder;
|
||||
partition_info[i].end_head = end.head;
|
||||
partition_info[i].end_sector = end.sector;
|
||||
// recalculate 'physical' end sector
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fips_harddrive::check (boolean final_check)
|
||||
{
|
||||
int i,j,k;
|
||||
boolean bootable = false;
|
||||
boolean do_correct = false;
|
||||
|
||||
byte *root_sector = harddrive::root_sector->data;
|
||||
partition_info *parts = partition_table().partition_info;
|
||||
|
||||
int order[4] = {-1,-1,-1,-1};
|
||||
|
||||
printx ("\nChecking root sector ... ");
|
||||
|
||||
if ((root_sector[510] != 0x55) || (root_sector[511] != 0xaa))
|
||||
error ("Invalid root sector signature: %02X %02X", root_sector[510], root_sector[511]);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (parts[i].bootable == 0x80)
|
||||
{
|
||||
if (bootable)
|
||||
{
|
||||
warning (false, "More than one active partition");
|
||||
|
||||
printx ("Continue (y/n)? ");
|
||||
if (ask_yes_no () == 'n') exit (-1);
|
||||
}
|
||||
else bootable = true;
|
||||
}
|
||||
else if (parts[i].bootable != 0)
|
||||
{
|
||||
warning (false, "Invalid active flag: partition %u: %02Xh",i+1,parts[i].bootable);
|
||||
// must be 0 or 80h
|
||||
|
||||
printx ("Do you want to set the flag to zero (y/n)? ");
|
||||
if (ask_yes_no () == 'y') parts[i].bootable = 0;
|
||||
}
|
||||
|
||||
if (parts[i].system)
|
||||
{
|
||||
if ((parts[i].start_sector == 0) || (parts[i].start_sector > geometry.sectors))
|
||||
{
|
||||
if (final_check)
|
||||
error ("Calculation error: Invalid start sector partition %u: %u", i + 1, parts[i].start_sector);
|
||||
|
||||
infomsg ("Partition table inconsistency");
|
||||
do_correct = true;
|
||||
}
|
||||
|
||||
if ((parts[i].end_sector == 0) || (parts[i].end_sector > geometry.sectors))
|
||||
{
|
||||
if (final_check)
|
||||
error ("Calculation error: Invalid end sector partition %u: %u", i + 1, parts[i].end_sector);
|
||||
|
||||
if (!do_correct)
|
||||
{
|
||||
infomsg ("Partition table inconsistency");
|
||||
do_correct = true;
|
||||
}
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
(parts[i].start_head > (geometry.heads - 1)) ||
|
||||
|
||||
(parts[i].end_head > (geometry.heads - 1)) ||
|
||||
|
||||
(parts[i].start_sector_abs !=
|
||||
(parts[i].start_cylinder * geometry.heads * geometry.sectors +
|
||||
parts[i].start_head * geometry.sectors + parts[i].start_sector - 1)) ||
|
||||
// physical start sector does not match logical start sector
|
||||
|
||||
((parts[i].start_sector_abs + parts[i].no_of_sectors_abs - 1) !=
|
||||
(parts[i].end_cylinder * geometry.heads * geometry.sectors +
|
||||
parts[i].end_head * geometry.sectors + parts[i].end_sector - 1))
|
||||
// physical end sector does not match logical end sector
|
||||
)
|
||||
{
|
||||
if (final_check)
|
||||
error ("Calculation error: Inconsistent table entry for partition %u", i + 1);
|
||||
|
||||
if (!do_correct)
|
||||
{
|
||||
infomsg ("Partition table inconsistency");
|
||||
do_correct = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < 4; j++) // insert partition in ordered table
|
||||
{
|
||||
if (order[j] == -1)
|
||||
{
|
||||
order[j] = i;
|
||||
break;
|
||||
}
|
||||
else if (parts[i].start_sector_abs < parts[order[j]].start_sector_abs)
|
||||
{
|
||||
for (k=3;k>j;k--) order[k] = order[k-1];
|
||||
order[j] = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // system = 0
|
||||
{
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
if (root_sector[0x1be + 16 * i + j] != 0)
|
||||
{
|
||||
warning (false, "Invalid partition entry: partition %u", i+1);
|
||||
printx ("Do you want to delete this entry (y/n)? ");
|
||||
if (ask_yes_no () == 'y')
|
||||
{
|
||||
parts[i].bootable = 0;
|
||||
parts[i].start_head = 0;
|
||||
parts[i].start_cylinder = 0;
|
||||
parts[i].start_sector = 0;
|
||||
parts[i].end_head = 0;
|
||||
parts[i].end_cylinder = 0;
|
||||
parts[i].end_sector = 0;
|
||||
parts[i].start_sector_abs = 0;
|
||||
parts[i].no_of_sectors_abs = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (do_correct)
|
||||
{
|
||||
pr_partition_table.correct_physical (geometry);
|
||||
printx ("\nPartition table adapted to the current drive geometry:\n\n");
|
||||
pr_partition_table.print();
|
||||
}
|
||||
|
||||
if (!bootable && number == 0x80) warning (true, "No active partition");
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if ((k = order[i]) != -1) // valid partition
|
||||
{
|
||||
if ((parts[k].end_sector != geometry.sectors) || (parts[k].end_head != (geometry.heads - 1)))
|
||||
warning (true, "Partition does not end on cylinder boundary: partition %u", k + 1);
|
||||
|
||||
if (i != 0) if ((parts[k].start_sector != 1) || (parts[k].start_head != 0))
|
||||
warning (true, "Partition does not begin on cylinder boundary: partition %u", k + 1);
|
||||
|
||||
if (i < 3) if ((j = order[i + 1]) != -1) // following valid partition
|
||||
{
|
||||
if ((parts[k].start_sector_abs + parts[k].no_of_sectors_abs) > parts[j].start_sector_abs)
|
||||
error ("Overlapping partitions: %u and %u", k + 1, j + 1);
|
||||
|
||||
if ((parts[k].start_sector_abs + parts[k].no_of_sectors_abs) < parts[j].start_sector_abs)
|
||||
warning (true, "Free space between partitions: %u and %u", k + 1, j + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printx ("OK\n");
|
||||
}
|
||||
|
||||
|
||||
void fips_partition::check (void)
|
||||
{
|
||||
printx ("Checking boot sector ... ");
|
||||
|
||||
byte *boot_sector = partition::boot_sector->data;
|
||||
|
||||
if (boot_sector[0] == 0xeb)
|
||||
{
|
||||
if (boot_sector[2] != 0x90)
|
||||
error ("Invalid jump instruction in boot sector: %02X %02X %02X", boot_sector[0], boot_sector[1], boot_sector[2]);
|
||||
}
|
||||
else if (boot_sector[0] != 0xe9)
|
||||
error ("Invalid jump instruction in boot sector: %02X %02X %02X", boot_sector[0], boot_sector[1], boot_sector[2]);
|
||||
|
||||
if ((boot_sector[510] != 0x55) || (boot_sector[511] != 0xaa))
|
||||
error ("Invalid boot sector: %02X %02X", boot_sector[510], boot_sector[511]);
|
||||
|
||||
if (bpb().bytes_per_sector != 512)
|
||||
error ("Can't handle number of bytes per sector: %u",bpb().bytes_per_sector);
|
||||
|
||||
switch (bpb().sectors_per_cluster)
|
||||
{
|
||||
case 1:case 2:case 4:case 8:case 16:case 32:case 64:case 128: break;
|
||||
default:
|
||||
error ("Number of sectors per cluster must be a power of 2: actually it is %u",bpb().sectors_per_cluster);
|
||||
}
|
||||
|
||||
if (bpb().reserved_sectors != 1)
|
||||
{
|
||||
warning (false, "Number of reserved sectors should be 1: actually it is %u",bpb().reserved_sectors);
|
||||
if (ask_correction () == 'y') bpb().reserved_sectors = 1;
|
||||
}
|
||||
|
||||
if (bpb().no_of_fats != 2)
|
||||
error ("Partition must have 2 FATs: actually it has %u",bpb().no_of_fats);
|
||||
|
||||
if (bpb().no_of_rootdir_entries % 16)
|
||||
{
|
||||
warning (false, "Number of root directory entries must be multiple of 16: actually it is %u",bpb().no_of_rootdir_entries);
|
||||
|
||||
printx ("Do you want to set the number to the next multiple of 16 (y/n)? ");
|
||||
if (ask_yes_no () == 'y')
|
||||
bpb().no_of_rootdir_entries += (16 - bpb().no_of_rootdir_entries % 16);
|
||||
}
|
||||
|
||||
if (bpb().no_of_rootdir_entries == 0)
|
||||
error ("Number of root directory entries must not be zero");
|
||||
|
||||
if (bpb().media_descriptor != 0xf8)
|
||||
{
|
||||
warning (false, "Wrong media descriptor byte in boot sector: %02X",bpb().media_descriptor);
|
||||
if (ask_correction () == 'y') bpb().media_descriptor = 0xf8;
|
||||
}
|
||||
|
||||
if (bpb().sectors_per_fat > 256)
|
||||
{
|
||||
warning (false, "FAT too large: %u sectors",bpb().sectors_per_fat);
|
||||
|
||||
printx ("Continue (y/n)? ");
|
||||
if (ask_yes_no () == 'n') exit (-1);
|
||||
}
|
||||
|
||||
if (bpb().sectors_per_fat < (info().no_of_clusters + 1) / 256 + 1)
|
||||
{
|
||||
warning (false, "FAT too small: %u sectors (should be %u)",bpb().sectors_per_fat, (unsigned int) ((info().no_of_clusters + 1) / 256 + 1));
|
||||
|
||||
printx ("Continue (y/n)? ");
|
||||
if (ask_yes_no () == 'n') exit (-1);
|
||||
}
|
||||
|
||||
if (bpb().sectors_per_track != drive->geometry.sectors)
|
||||
{
|
||||
warning (false, "Sectors per track incorrect: %u instead of %u",bpb().sectors_per_track,(int) drive->geometry.sectors);
|
||||
if (ask_correction () == 'y') bpb().sectors_per_track = drive->geometry.sectors;
|
||||
}
|
||||
|
||||
if (bpb().drive_heads != drive->geometry.heads)
|
||||
{
|
||||
warning (false, "Number of drive heads incorrect: %u instead of %u",bpb().drive_heads,(int) drive->geometry.heads);
|
||||
if (ask_correction () == 'y') bpb().drive_heads = drive->geometry.heads;
|
||||
}
|
||||
|
||||
if (bpb().hidden_sectors != partition_info->start_sector_abs)
|
||||
error ("Number of hidden sectors incorrect: %lu instead of %lu",bpb().hidden_sectors,partition_info->start_sector_abs);
|
||||
|
||||
if (info().no_of_clusters <= 4084)
|
||||
error ("12-bit FAT not supported: number of clusters is %u",(int) info().no_of_clusters);
|
||||
|
||||
if (bpb().no_of_sectors)
|
||||
{
|
||||
if (partition_info->no_of_sectors_abs > 0xffff)
|
||||
error ("Number of sectors (short) must be zero");
|
||||
|
||||
if (bpb().no_of_sectors != partition_info->no_of_sectors_abs)
|
||||
error ("Number of sectors (short) does not match partition info:\n%u instead of %lu",bpb().no_of_sectors,partition_info->no_of_sectors_abs);
|
||||
|
||||
if (partition_info->system != 4)
|
||||
{
|
||||
warning (true, "Wrong system indicator byte: %u instead of 4",partition_info->system);
|
||||
if (ask_correction () == 'y') partition_info->system = 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bpb().no_of_sectors_long != partition_info->no_of_sectors_abs)
|
||||
error ("Number of sectors (long) does not match partition info:\n%lu instead of %lu",bpb().no_of_sectors_long,partition_info->no_of_sectors_abs);
|
||||
|
||||
if (bpb().signature != 0x29)
|
||||
{
|
||||
warning (false, "Wrong signature: %02Xh",bpb().signature);
|
||||
if (ask_correction () == 'y') bpb().signature = 0x29;
|
||||
}
|
||||
|
||||
if (partition_info->system != 6)
|
||||
{
|
||||
warning (true, "Wrong system indicator byte: %u instead of 6",partition_info->system);
|
||||
if (ask_correction () == 'y') partition_info->system = 6;
|
||||
}
|
||||
}
|
||||
|
||||
printx ("OK\n");
|
||||
}
|
||||
138
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/CMDL_ARG.CPP
Normal file
138
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/CMDL_ARG.CPP
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module cmdl_arg.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/cmdl_arg.cpp 1.4 1995/01/19 00:00:51 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "getopt.h"
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Replacement for atoi */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
static int atoint (char *string)
|
||||
{
|
||||
long int value = 0;
|
||||
while (isdigit (*string))
|
||||
{
|
||||
value = value * 10 + (*string - '0');
|
||||
if (value > 32767) return (-1);
|
||||
string++;
|
||||
}
|
||||
if (*string != '\0') return (-1);
|
||||
return (int) value;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Usage instructions */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
static void usage (void)
|
||||
{
|
||||
printf ("\nFIPS [-t] [-d] [-h|-?] [-n<num>]:\n\n");
|
||||
printf ("-t : test mode (no writes to disk)\n");
|
||||
printf ("-d : debug mode\n");
|
||||
printf ("-h/-? : this help page\n");
|
||||
printf ("-n<num> : select drive <num> - valid values: 128 to 255\n");
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Process commandline parameters */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void evaluate_argument_vector (int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
|
||||
opterr = 0;
|
||||
|
||||
while ((c = getopt (argc, argv, ":htdn:")) >= 0)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 't':
|
||||
global.test_mode = true;
|
||||
break;
|
||||
case 'd':
|
||||
global.debug_mode = true;
|
||||
break;
|
||||
case 'h':
|
||||
usage ();
|
||||
exit (1);
|
||||
case 'n':
|
||||
global.drive_number_cmdline = atoint (optarg);
|
||||
|
||||
if
|
||||
(
|
||||
global.drive_number_cmdline < 0x80
|
||||
|| global.drive_number_cmdline > 0xff
|
||||
)
|
||||
{
|
||||
fprintf
|
||||
(
|
||||
stderr,
|
||||
"\nInvalid argument: %s\n",
|
||||
optarg
|
||||
);
|
||||
|
||||
usage ();
|
||||
exit (-1);
|
||||
}
|
||||
break;
|
||||
case ':':
|
||||
fprintf
|
||||
(
|
||||
stderr,
|
||||
"\nSwitch %c requires an argument\n",
|
||||
optopt
|
||||
);
|
||||
usage ();
|
||||
exit (-1);
|
||||
case '?':
|
||||
if (optopt != '?')
|
||||
fprintf
|
||||
(
|
||||
stderr,
|
||||
"\nInvalid Commandline Parameter: %s\n",
|
||||
argv[optind - 1]
|
||||
);
|
||||
|
||||
usage ();
|
||||
exit (-1);
|
||||
} /* switch */
|
||||
|
||||
} /* while */
|
||||
}
|
||||
267
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/DISK_IO.CPP
Normal file
267
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/DISK_IO.CPP
Normal file
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module disk_io.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/disk_io.cpp 1.4 1995/01/19 00:00:51 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include "disk_io.h"
|
||||
#include <dos.h>
|
||||
#include <bios.h>
|
||||
|
||||
#define DISK_INT 0x13
|
||||
|
||||
#define RESET_DISK 0
|
||||
#define READ_SECTOR 2
|
||||
#define WRITE_SECTOR 3
|
||||
#define VERIFY_SECTOR 4
|
||||
#define GET_DRIVE_PARAMS 8
|
||||
#define GET_DISK_TYPE 0x15
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Bios call to get the number of drives attached */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
int get_no_of_drives (void)
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
regs.h.ah = GET_DRIVE_PARAMS;
|
||||
regs.h.dl = 0x80;
|
||||
int86 (DISK_INT, ®s, ®s);
|
||||
|
||||
if (regs.h.ah != 0) return (1); // will be checked again
|
||||
return (regs.h.dl);
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Calculates physical sector number (Head, Cylinder, Sector). */
|
||||
/* Log_sector is absolute logical sector number (0 = master boot record). */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
physical_sector_no::physical_sector_no
|
||||
(
|
||||
dword logical_sector,
|
||||
const drive_geometry &geometry
|
||||
)
|
||||
{
|
||||
cylinder =
|
||||
logical_sector
|
||||
/ (geometry.heads * geometry.sectors);
|
||||
|
||||
head =
|
||||
(
|
||||
logical_sector
|
||||
- (cylinder * geometry.heads * geometry.sectors)
|
||||
)
|
||||
/ geometry.sectors;
|
||||
|
||||
sector =
|
||||
logical_sector
|
||||
- (cylinder * geometry.heads * geometry.sectors)
|
||||
- (head * geometry.sectors)
|
||||
+ 1;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Bios call get_drive_geometry, returns error status in var errorcode */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void physical_drive::get_geometry (void)
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
regs.h.ah = GET_DRIVE_PARAMS;
|
||||
regs.h.dl = number;
|
||||
int86 (DISK_INT, ®s, ®s);
|
||||
|
||||
if ((errorcode = regs.h.ah) != 0) return;
|
||||
|
||||
geometry.heads = (dword) regs.h.dh + 1;
|
||||
geometry.sectors = (dword) regs.h.cl & 0x3f;
|
||||
geometry.cylinders =
|
||||
(
|
||||
(dword) regs.h.ch
|
||||
| (((dword) regs.h.cl << 2) & 0x300)
|
||||
) + 1;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Bios call reset_drive, returns error status in var errorcode */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void physical_drive::reset (void)
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
regs.h.ah = RESET_DISK;
|
||||
regs.h.dl = number;
|
||||
int86 (DISK_INT, ®s, ®s);
|
||||
|
||||
errorcode = regs.h.ah;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Initialization physical_drive, requires drive number. */
|
||||
/* Calls get_drive_geometry, errorcode contains return status */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
physical_drive::physical_drive (int number)
|
||||
{
|
||||
physical_drive::number = number;
|
||||
get_geometry ();
|
||||
};
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Initialization physical_drive with physical_drive object */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
physical_drive::physical_drive (physical_drive &pd)
|
||||
{
|
||||
number = pd.number;
|
||||
errorcode = pd.errorcode;
|
||||
geometry = pd.geometry;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Assignment operator for physical drive */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void physical_drive::operator= (physical_drive &pd)
|
||||
{
|
||||
number = pd.number;
|
||||
errorcode = pd.errorcode;
|
||||
geometry = pd.geometry;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Read sector */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
int physical_drive::read_sector (struct sector *sector, dword sector_number)
|
||||
{
|
||||
physical_sector_no p (sector_number, geometry);
|
||||
|
||||
boolean done = false;
|
||||
|
||||
for (int i=0; i<3; i++)
|
||||
{
|
||||
if (biosdisk
|
||||
(
|
||||
READ_SECTOR,
|
||||
number,
|
||||
p.head,
|
||||
p.cylinder,
|
||||
p.sector,
|
||||
1,
|
||||
sector->data
|
||||
) == 0)
|
||||
{
|
||||
done=true;
|
||||
break;
|
||||
}
|
||||
|
||||
reset ();
|
||||
}
|
||||
|
||||
if (!done) return (-1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Write sector with verify */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
int physical_drive::write_sector (struct sector *sector, dword sector_number)
|
||||
{
|
||||
physical_sector_no p (sector_number,geometry);
|
||||
|
||||
boolean done = false;
|
||||
|
||||
for (int i=0; i<3; i++)
|
||||
{
|
||||
if (biosdisk
|
||||
(
|
||||
WRITE_SECTOR,
|
||||
number,
|
||||
p.head,
|
||||
p.cylinder,
|
||||
p.sector,
|
||||
1,
|
||||
sector->data
|
||||
) == 0)
|
||||
{
|
||||
done=true;
|
||||
break;
|
||||
}
|
||||
|
||||
reset ();
|
||||
}
|
||||
|
||||
if (!done) return (-1);
|
||||
|
||||
if (biosdisk
|
||||
(
|
||||
VERIFY_SECTOR,
|
||||
number,
|
||||
p.head,
|
||||
p.cylinder,
|
||||
p.sector,
|
||||
1,
|
||||
sector->data
|
||||
|
||||
) != 0) return (-1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Bios call get_disk_type - returns 0 if drive not present. */
|
||||
/* Valid drive numbers: 0 - 255, result: 1 - floppy without disk change */
|
||||
/* detection, 2 - floppy with disk change detection, 3 - harddisk */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
int get_disk_type (int drive_number)
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
regs.h.ah = GET_DISK_TYPE;
|
||||
regs.h.dl = drive_number;
|
||||
int86 (DISK_INT, ®s, ®s);
|
||||
|
||||
if (regs.x.cflag) return 0;
|
||||
return (regs.h.ah); // disk type
|
||||
}
|
||||
138
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/DISK_IO.H
Normal file
138
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/DISK_IO.H
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module disk_io.h
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/disk_io.h 1.4 1995/01/19 00:01:25 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#ifndef DISK_IO_H
|
||||
#define DISK_IO_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Structure to hold information about the drive geometry */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
struct drive_geometry
|
||||
{
|
||||
dword heads;
|
||||
dword cylinders;
|
||||
dword sectors;
|
||||
};
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Low level structure physical_drive, contains drive number and geometry, */
|
||||
/* as well as low level sector read and write routines */
|
||||
/* Geometry is determined on initialization, errorcode contains error */
|
||||
/* number after call to get_geometry() and reset(). */
|
||||
/* Initialization requires number (e.g. physical_drive drive1 (0x80);). */
|
||||
/* */
|
||||
/* Read and write are called max. 3 times in case of failure, return code */
|
||||
/* contains 0 if successful. Sector CRC is verified after write. */
|
||||
/* sector_number is absolute logical sector number (0 = master boot record)*/
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
class physical_drive
|
||||
{
|
||||
protected:
|
||||
virtual void get_geometry (void);
|
||||
|
||||
public:
|
||||
// constructors & operators
|
||||
|
||||
physical_drive (int number);
|
||||
physical_drive (physical_drive &pd);
|
||||
void operator= (physical_drive &pd);
|
||||
|
||||
// public data
|
||||
|
||||
int number;
|
||||
int errorcode;
|
||||
drive_geometry geometry;
|
||||
|
||||
// functions
|
||||
|
||||
virtual void reset (void);
|
||||
|
||||
int read_sector (struct sector* sector, dword sector_number);
|
||||
int write_sector (struct sector* sector, dword sector_number);
|
||||
};
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Physical_sector_no holds and calculates physical sector number (Head, */
|
||||
/* Cylinder, Sector). Number is calculated on initialization. Log_sector */
|
||||
/* is absolute logical sector number (0 = master boot record). Usage: */
|
||||
/* physical_sector_no mbr (0,geometry); */
|
||||
/* physical_sector_no mbr (0,0,1); */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
struct physical_sector_no
|
||||
{
|
||||
// public data
|
||||
|
||||
dword head;
|
||||
dword cylinder;
|
||||
dword sector;
|
||||
|
||||
// constructors
|
||||
|
||||
physical_sector_no (dword logical_sector, const drive_geometry &geometry);
|
||||
physical_sector_no (dword head, dword cylinder, dword sector)
|
||||
{
|
||||
physical_sector_no::head = head;
|
||||
physical_sector_no::cylinder = cylinder;
|
||||
physical_sector_no::sector = sector;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Structure sector - contains only sector data */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
struct sector
|
||||
{
|
||||
byte data[512];
|
||||
};
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Prototype for bios call get_disk_type - returns 0 if drive not present. */
|
||||
/* Valid drive numbers: 0 - 255, result: 1 - floppy without disk change */
|
||||
/* detection, 2 - floppy with disk change detection, 3 - harddisk */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
int get_disk_type (int drive_number);
|
||||
|
||||
/* Bios call get_no_of_drives */
|
||||
|
||||
int get_no_of_drives (void);
|
||||
|
||||
#endif
|
||||
161
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/FAT.CPP
Normal file
161
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/FAT.CPP
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module fat.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/fat.cpp 1.4 1995/01/19 00:00:51 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "logdr_st.h"
|
||||
#include "global.h"
|
||||
#include "fat.h"
|
||||
#include "input.h"
|
||||
|
||||
|
||||
fat::fat (class logical_drive *logical_drive,int number)
|
||||
{
|
||||
fat::logical_drive = logical_drive;
|
||||
fat::number = number;
|
||||
buffer = new sector;
|
||||
start_sector = (number == 1) ? logical_drive->info().start_fat1 : logical_drive->info().start_fat2;
|
||||
sector_in_buffer = -1;
|
||||
}
|
||||
|
||||
|
||||
dword fat16::next_cluster (dword cluster_number)
|
||||
{
|
||||
dword sector = cluster_number / 256;
|
||||
int offset = (cluster_number % 256) * 2;
|
||||
|
||||
if (sector != sector_in_buffer)
|
||||
{
|
||||
read_sector (sector);
|
||||
}
|
||||
|
||||
return ((dword) buffer->data[offset] | ((dword) buffer->data[offset + 1] << 8));
|
||||
}
|
||||
|
||||
|
||||
void fat::read_sector (dword sector)
|
||||
{
|
||||
if (logical_drive->read_sector (sector + start_sector,buffer))
|
||||
if (number == 1)
|
||||
error ("Error reading FAT 1");
|
||||
else
|
||||
error ("Error reading FAT 2");
|
||||
|
||||
sector_in_buffer = sector;
|
||||
}
|
||||
|
||||
|
||||
void fat16::check_against (class fat16 *fat2)
|
||||
{
|
||||
printx ("Checking FAT ... ");
|
||||
|
||||
for (int i=0;i<logical_drive->bpb().sectors_per_fat;i++)
|
||||
{
|
||||
read_sector (i);
|
||||
fat2->read_sector (i);
|
||||
|
||||
for (int j=0;j<512;j++) if (buffer->data[j] != fat2->buffer->data[j])
|
||||
error ("FAT copies differ: FAT 1 -> %02Xh, FAT 2 -> %02Xh in sector %u, byte %u",buffer->data[j],fat2->buffer->data[j],i,j);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
if (buffer->data[0] != 0xf8)
|
||||
{
|
||||
warning (false, "Wrong media descriptor byte in FAT: %02Xh",buffer->data[0]);
|
||||
|
||||
printx ("Continue (y/n)? ");
|
||||
if (ask_yes_no () == 'n') exit (-1);
|
||||
}
|
||||
|
||||
if ((buffer->data[1] != 0xff) || (buffer->data[2] != 0xff) || (buffer->data[3] != 0xff))
|
||||
warning (true, "Wrong FAT entries 1 & 2: %02X %02X %02X %02X",buffer->data[0],buffer->data[1],buffer->data[2],buffer->data[3]);
|
||||
}
|
||||
}
|
||||
printx ("OK\n");
|
||||
}
|
||||
|
||||
|
||||
void fat16::check_empty (dword new_start_sector)
|
||||
{
|
||||
dword first_cluster = (new_start_sector - logical_drive->info().start_data) / logical_drive->bpb().sectors_per_cluster + 2;
|
||||
|
||||
dword last_cluster = logical_drive->info().no_of_clusters + 1;
|
||||
|
||||
if (last_cluster > ((dword) 256 * logical_drive->bpb().sectors_per_fat - 1)) last_cluster = (dword) 256 * logical_drive->bpb().sectors_per_fat - 1;
|
||||
|
||||
printx ("First Cluster: %lu\nLast Cluster: %lu\n\n",first_cluster,last_cluster);
|
||||
printx ("Testing if empty ... ");
|
||||
|
||||
for (dword i=first_cluster;i <= last_cluster;i++)
|
||||
{
|
||||
dword fat_entry = next_cluster (i);
|
||||
|
||||
if (fat_entry != 0) if (fat_entry != 0xfff7)
|
||||
{
|
||||
if (fat_entry == 0xffff)
|
||||
{
|
||||
error ("New partition not empty: cluster %lu ( FAT entry: <EOF> )",i);
|
||||
}
|
||||
else
|
||||
{
|
||||
error ("New partition not empty: cluster %lu ( FAT entry: %lu )",i,fat_entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printx ("OK\n");
|
||||
}
|
||||
|
||||
|
||||
dword fat16::min_free_cluster (void)
|
||||
{
|
||||
dword first_cluster = 2;
|
||||
|
||||
dword last_cluster = logical_drive->info().no_of_clusters + 1;
|
||||
|
||||
if (last_cluster > ((dword) 256 * logical_drive->bpb().sectors_per_fat - 1)) last_cluster = (dword) 256 * logical_drive->bpb().sectors_per_fat - 1;
|
||||
|
||||
printx ("Searching for free space ... ");
|
||||
|
||||
dword i;
|
||||
|
||||
for (i=last_cluster;i >= first_cluster;i--)
|
||||
{
|
||||
dword fat_entry = next_cluster (i);
|
||||
|
||||
if (fat_entry != 0) if (fat_entry != 0xfff7)
|
||||
{
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
printx ("OK\n\n");
|
||||
return (i);
|
||||
}
|
||||
65
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/FAT.H
Normal file
65
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/FAT.H
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module fat.h
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/fat.h 1.4 1995/01/19 00:01:25 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#ifndef FAT_H
|
||||
#define FAT_H
|
||||
|
||||
#include "types.h"
|
||||
#include "disk_io.h"
|
||||
#include "logdr_st.h"
|
||||
|
||||
class fat
|
||||
{
|
||||
protected:
|
||||
logical_drive *logical_drive;
|
||||
int number;
|
||||
dword start_sector;
|
||||
sector *buffer;
|
||||
dword sector_in_buffer;
|
||||
void read_sector (dword sector);
|
||||
public:
|
||||
virtual dword next_cluster (dword cluster_number) = 0;
|
||||
|
||||
fat (class logical_drive *logical_drive,int number);
|
||||
~fat (void) { delete buffer; }
|
||||
};
|
||||
|
||||
class fat16:public fat
|
||||
{
|
||||
public:
|
||||
dword next_cluster (dword cluster_number);
|
||||
void check_empty (dword new_start_cluster);
|
||||
void check_against (class fat16 *fat2);
|
||||
dword min_free_cluster (void);
|
||||
|
||||
fat16 (class logical_drive *logical_drive,int number):fat (logical_drive,number) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
285
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/FIPSSPEC.CPP
Normal file
285
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/FIPSSPEC.CPP
Normal file
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module fipsspec.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/fipsspec.cpp 1.4 1995/01/19 00:00:53 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include <dos.h>
|
||||
|
||||
#include "fipsspec.h"
|
||||
#include "global.h"
|
||||
#include "input.h"
|
||||
|
||||
#define FIRST_CHECK false
|
||||
#define FINAL_CHECK true
|
||||
|
||||
#define DISK_INT 0x13
|
||||
|
||||
#define RESET_DISK 0
|
||||
#define GET_DRIVE_PARAMS 8
|
||||
|
||||
void fips_bpb::print (void)
|
||||
{
|
||||
printx ("Bytes per sector: %u\n",bytes_per_sector);
|
||||
printx ("Sectors per cluster: %u\n",sectors_per_cluster);
|
||||
printx ("Reserved sectors: %u\n",reserved_sectors);
|
||||
printx ("Number of FATs: %u\n",no_of_fats);
|
||||
printx ("Number of rootdirectory entries: %u\n",no_of_rootdir_entries);
|
||||
printx ("Number of sectors (short): %u\n",no_of_sectors);
|
||||
printx ("Media descriptor byte: %02Xh\n",media_descriptor);
|
||||
printx ("Sectors per FAT: %u\n",sectors_per_fat);
|
||||
printx ("Sectors per track: %u\n",sectors_per_track);
|
||||
printx ("Drive heads: %u\n",drive_heads);
|
||||
printx ("Hidden sectors: %lu\n",hidden_sectors);
|
||||
printx ("Number of sectors (long): %lu\n",no_of_sectors_long);
|
||||
printx ("Physical drive number: %02Xh\n",phys_drive_no);
|
||||
printx ("Signature: %02Xh\n\n",signature);
|
||||
}
|
||||
|
||||
void fips_partition_table::print (void)
|
||||
{
|
||||
printx (" | | Start | | End | Start |Number of|\n");
|
||||
printx ("Part.|bootable|Head Cyl. Sector|System|Head Cyl. Sector| Sector |Sectors | MB\n");
|
||||
printx ("-----+--------+----------------+------+----------------+--------+---------+----\n");
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
printx ("%u | %s |%4u %4u %4u| %02Xh|%4u %4u %4u|%8lu| %8lu|%4lu\n",i+1,
|
||||
partition_info[i].bootable ? "yes" : " no",
|
||||
partition_info[i].start_head,partition_info[i].start_cylinder,partition_info[i].start_sector,
|
||||
partition_info[i].system,partition_info[i].end_head,partition_info[i].end_cylinder,partition_info[i].end_sector,
|
||||
partition_info[i].start_sector_abs,partition_info[i].no_of_sectors_abs,partition_info[i].no_of_sectors_abs / 2048);
|
||||
}
|
||||
}
|
||||
|
||||
void fips_harddrive::get_geometry (void)
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
regs.h.ah = GET_DRIVE_PARAMS;
|
||||
regs.h.dl = number;
|
||||
int86 (DISK_INT,®s,®s);
|
||||
if (global.debug_mode)
|
||||
{
|
||||
fprintf (global.debugfile,"\nRegisters after call to int 13h 08h (drive %02Xh):\n\n",number);
|
||||
fprintf (global.debugfile," 00 sc/cl hd\n");
|
||||
fprintf (global.debugfile,"al ah bl bh cl ch dl dh si di cflgs flags\n");
|
||||
hexwrite ((byte *) ®s,16,global.debugfile);
|
||||
}
|
||||
if ((errorcode = regs.h.ah) != 0) return;
|
||||
geometry.heads = (dword) regs.h.dh + 1;
|
||||
geometry.sectors = (dword) regs.h.cl & 0x3f;
|
||||
geometry.cylinders = ((dword) regs.h.ch | (((dword) regs.h.cl << 2) & 0x300)) + 1;
|
||||
|
||||
if (global.debug_mode)
|
||||
{
|
||||
fprintf (global.debugfile, "\nGeometry reported by BIOS:\n");
|
||||
fprintf
|
||||
(
|
||||
global.debugfile,
|
||||
"%ld cylinders, %ld heads, %ld sectors\n",
|
||||
geometry.cylinders,
|
||||
geometry.heads,
|
||||
geometry.sectors
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void fips_harddrive::reset (void)
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
regs.h.ah = RESET_DISK;
|
||||
regs.h.dl = number;
|
||||
int86 (DISK_INT,®s,®s);
|
||||
if (global.debug_mode)
|
||||
{
|
||||
fprintf (global.debugfile,"\nRegisters after call to int 13h 00h (drive %02Xh):\n\n",number);
|
||||
fprintf (global.debugfile,"al ah bl bh cl ch dl dh si di cflgs flags\n");
|
||||
hexwrite ((byte *) ®s,16,global.debugfile);
|
||||
}
|
||||
errorcode = regs.h.ah;
|
||||
}
|
||||
|
||||
void fips_logdrive_info::put_debug_info (void)
|
||||
{
|
||||
fprintf (global.debugfile,"Calculated Partition Characteristica:\n\n");
|
||||
fprintf (global.debugfile,"Start of FAT 1: %lu\n",start_fat1);
|
||||
fprintf (global.debugfile,"Start of FAT 2: %lu\n",start_fat2);
|
||||
fprintf (global.debugfile,"Start of Rootdirectory: %lu\n",start_rootdir);
|
||||
fprintf (global.debugfile,"Start of Data: %lu\n",start_data);
|
||||
fprintf (global.debugfile,"Number of Clusters: %lu\n",no_of_clusters);
|
||||
}
|
||||
|
||||
dword fips_partition::min_cylinder (fat16 fat, drive_geometry geometry)
|
||||
{
|
||||
dword new_part_min_sector =
|
||||
info().start_data
|
||||
+ (dword) 4085
|
||||
* bpb().sectors_per_cluster;
|
||||
|
||||
dword new_part_min_cylinder =
|
||||
(
|
||||
new_part_min_sector
|
||||
+ partition_info->start_sector_abs
|
||||
- 1
|
||||
)
|
||||
/ (geometry.heads * geometry.sectors)
|
||||
+ 1;
|
||||
|
||||
if (new_part_min_cylinder > partition_info->end_cylinder)
|
||||
error ("Partition too small - can't split");
|
||||
|
||||
dword min_free_cluster = fat.min_free_cluster ();
|
||||
dword min_free_sector =
|
||||
info().start_data
|
||||
+ (min_free_cluster - 2)
|
||||
* (dword) bpb().sectors_per_cluster;
|
||||
|
||||
dword min_free_cylinder =
|
||||
(
|
||||
min_free_sector
|
||||
+ partition_info->start_sector_abs
|
||||
- 1
|
||||
)
|
||||
/ (geometry.heads * geometry.sectors)
|
||||
+ 1;
|
||||
|
||||
if (min_free_cylinder > partition_info->end_cylinder)
|
||||
error ("Last cylinder is not free");
|
||||
|
||||
if (new_part_min_cylinder < min_free_cylinder)
|
||||
new_part_min_cylinder = min_free_cylinder;
|
||||
|
||||
return (new_part_min_cylinder);
|
||||
}
|
||||
|
||||
|
||||
boolean fips_partition::split (fips_harddrive hd)
|
||||
{
|
||||
if (read_boot_sector ())
|
||||
error ("Error reading boot sector");
|
||||
|
||||
if (global.debug_mode)
|
||||
{
|
||||
fprintf
|
||||
(
|
||||
global.debugfile,
|
||||
"\nBoot sector drive %02Xh, partition %u:\n\n",
|
||||
hd.number,
|
||||
number + 1
|
||||
);
|
||||
|
||||
hexwrite
|
||||
(
|
||||
boot_sector->data,
|
||||
512,
|
||||
global.debugfile
|
||||
);
|
||||
}
|
||||
|
||||
get_bpb ();
|
||||
|
||||
printx ("\nBoot sector:\n\n");
|
||||
print_bpb ();
|
||||
|
||||
get_info ();
|
||||
if (global.debug_mode)
|
||||
write_info_debugfile ();
|
||||
|
||||
check ();
|
||||
|
||||
fat16 fat1 (this,1);
|
||||
fat16 fat2 (this,2);
|
||||
|
||||
fat1.check_against (&fat2);
|
||||
|
||||
dword new_part_min_cylinder =
|
||||
min_cylinder (fat2, hd.geometry);
|
||||
|
||||
if (ask_if_save()) save_root_and_boot(&hd,this);
|
||||
|
||||
dword new_start_cylinder =
|
||||
ask_for_new_start_cylinder
|
||||
(
|
||||
partition_info->start_cylinder,
|
||||
new_part_min_cylinder,
|
||||
partition_info->end_cylinder,
|
||||
hd.geometry.heads * hd.geometry.sectors
|
||||
);
|
||||
|
||||
fat2.check_empty
|
||||
(
|
||||
new_start_cylinder
|
||||
* hd.geometry.heads
|
||||
* hd.geometry.sectors
|
||||
- partition_info->start_sector_abs
|
||||
);
|
||||
|
||||
hd.calculate_new_root (new_start_cylinder, this);
|
||||
|
||||
hd.put_partition_table();
|
||||
hd.get_partition_table();
|
||||
|
||||
printx ("\nNew partition table:\n\n");
|
||||
hd.print_partition_table ();
|
||||
|
||||
hd.check (FINAL_CHECK);
|
||||
|
||||
if (ask_if_continue () == false)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
calculate_new_boot ();
|
||||
|
||||
put_bpb ();
|
||||
get_bpb ();
|
||||
|
||||
printx ("\nNew boot sector:\n\n");
|
||||
print_bpb ();
|
||||
|
||||
get_info ();
|
||||
if (global.debug_mode)
|
||||
write_info_debugfile ();
|
||||
|
||||
check();
|
||||
|
||||
if (!global.test_mode)
|
||||
{
|
||||
ask_for_write_permission ();
|
||||
|
||||
if (hd.write_root_sector ())
|
||||
error ("Error writing root sector");
|
||||
|
||||
if (write_boot_sector ())
|
||||
error ("Error writing boot sector");
|
||||
|
||||
printx ("Repartitioning complete\n");
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
120
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/FIPSSPEC.H
Normal file
120
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/FIPSSPEC.H
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module fipsspec.h
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/fipsspec.h 1.4 1995/01/19 00:01:26 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#ifndef FIPSSPEC_H
|
||||
#define FIPSSPEC_H
|
||||
|
||||
#include "logdr_st.h"
|
||||
#include "hdstruct.h"
|
||||
#include "primpart.h"
|
||||
#include "fat.h"
|
||||
#include "disk_io.h"
|
||||
|
||||
class fips_bpb:public bios_parameter_block
|
||||
{
|
||||
public:
|
||||
void print (void);
|
||||
void calculate_new_boot (const partition_info &partition_info);
|
||||
};
|
||||
|
||||
class fips_partition_table:public partition_table
|
||||
{
|
||||
public:
|
||||
void print (void);
|
||||
void calculate_new_root (dword new_start_cylinder,partition *partition,const drive_geometry &geometry);
|
||||
void correct_physical (const drive_geometry &geometry);
|
||||
int select (void);
|
||||
};
|
||||
|
||||
class fips_harddrive:public harddrive
|
||||
{
|
||||
fips_partition_table pr_partition_table;
|
||||
protected:
|
||||
void get_geometry (void);
|
||||
public:
|
||||
void reset (void);
|
||||
class partition_table &partition_table() { return pr_partition_table; }
|
||||
void print_partition_table (void) { pr_partition_table.print(); }
|
||||
void calculate_new_root (dword new_start_cylinder, partition *partition)
|
||||
{
|
||||
pr_partition_table.calculate_new_root (new_start_cylinder,partition,geometry);
|
||||
}
|
||||
void check (boolean final_check);
|
||||
|
||||
fips_harddrive (int number)
|
||||
:harddrive (number)
|
||||
{
|
||||
get_geometry ();
|
||||
// to write register info to debugfile
|
||||
}
|
||||
|
||||
fips_harddrive (fips_harddrive &hd):harddrive (hd)
|
||||
{
|
||||
harddrive::operator= (hd);
|
||||
// in constructor of base class virtual functions are not yet
|
||||
// accessible => assign again so that partition_table() is
|
||||
// copied correctly
|
||||
}
|
||||
|
||||
void operator= (fips_harddrive &hd)
|
||||
{
|
||||
harddrive::operator= (hd);
|
||||
}
|
||||
};
|
||||
|
||||
class fips_logdrive_info:public logical_drive_info
|
||||
{
|
||||
public:
|
||||
void put_debug_info (void);
|
||||
};
|
||||
|
||||
class fips_partition:public partition
|
||||
{
|
||||
fips_bpb pr_bpb;
|
||||
fips_logdrive_info pr_info;
|
||||
public:
|
||||
bios_parameter_block &bpb() { return pr_bpb; }
|
||||
logical_drive_info &info() { return pr_info; }
|
||||
|
||||
void print_bpb (void) { pr_bpb.print(); }
|
||||
void write_info_debugfile (void) { pr_info.put_debug_info(); }
|
||||
void calculate_new_boot (void)
|
||||
{
|
||||
pr_bpb.calculate_new_boot (*partition_info);
|
||||
}
|
||||
void check (void);
|
||||
|
||||
fips_partition (class fips_harddrive *drive,int number):partition(drive,number) {}
|
||||
|
||||
dword min_cylinder (fat16 fat, drive_geometry geometry);
|
||||
boolean split (fips_harddrive hd);
|
||||
};
|
||||
|
||||
#endif
|
||||
205
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/GETOPT.C
Normal file
205
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/GETOPT.C
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* $Header$
|
||||
*
|
||||
* Copyright (C) 1994 Arno Schaefer
|
||||
*
|
||||
* AU: Auswertung der Kommandozeile, der POSIX-Version von getopt ()
|
||||
* nachempfunden.
|
||||
*
|
||||
* PO: ANSI C
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
|
||||
/* Globale Variablen */
|
||||
|
||||
char *optarg;
|
||||
int optind = 1;
|
||||
int opterr = 1;
|
||||
int optopt;
|
||||
|
||||
static char *nextarg = NULL;
|
||||
|
||||
|
||||
/* Funktion */
|
||||
|
||||
int getopt (int argc, char *argv[], char *optstring)
|
||||
|
||||
/*
|
||||
* AU: Auswertung der Kommandozeile
|
||||
*
|
||||
* VB: argc und argv sind die Parameter, die an main () uebergeben werden.
|
||||
* optstring ist ein String, der die Zeichen enthaelt, die als
|
||||
* Optionen erkannt werden. Wenn ein Zeichen von einem Doppelpunkt
|
||||
* gefolgt wird, hat die Option ein Argument, das direkt auf das Zeichen
|
||||
* folgt oder durch Space davon getrennt ist. Gueltige Optionszeichen
|
||||
* sind alle druckbaren Zeichen ausser '?', ' ' und ':'.
|
||||
*
|
||||
* optind ist der Index auf das naechste Element von argv[], das
|
||||
* bearbeitet wird.
|
||||
*
|
||||
* opterr ist ein Flag, das festlegt, ob bei Fehlern Fehlermeldungen
|
||||
* ausgegeben werden.
|
||||
*
|
||||
* optarg ist ein Zeiger auf das Argument, wenn eine Option ein
|
||||
* Argument hat.
|
||||
*
|
||||
* optopt enthaelt bei Fehlern das Optionszeichen, das den Fehler aus-
|
||||
* geloest hat.
|
||||
*
|
||||
* NB: Rueckgabewert ist das jeweils naechste Optionszeichen, oder -1 am
|
||||
* Ende der Optionsliste.
|
||||
*
|
||||
* Die Optionsliste ist zu Ende, wenn argv[optind] NULL ist, oder
|
||||
* argv[optind] nicht mit '-' (oder '/') beginnt, oder argv[optind]
|
||||
* ein einzelnes "-" ist. In diesem Fall wird optind nicht erhoeht.
|
||||
* Das Ende der Optionsliste kann mit "--" erzwungen werden, dann ist
|
||||
* argv[optind] das erste Argument nach "--".
|
||||
*
|
||||
* FB: Ein '?' wird zurueckgegeben, wenn ein Optionszeichen nicht in
|
||||
* optstring enthalten war oder ein ungueltiges Optionszeichen
|
||||
* uebergeben wurde ('?' oder ':'). Ausserdem bei einem fehlenden
|
||||
* Argument, wenn das erste Zeichen von optstring kein ':' ist.
|
||||
*
|
||||
* Ein ':' wird zurueckgegeben bei einem fehlenden Argument, wenn
|
||||
* das erste Zeichen von optstring ein ':' ist.
|
||||
*/
|
||||
|
||||
{
|
||||
char *search;
|
||||
|
||||
optarg = NULL;
|
||||
|
||||
if (nextarg == NULL)
|
||||
{
|
||||
nextarg = argv[optind];
|
||||
|
||||
if (nextarg == NULL)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#ifdef __MSDOS__
|
||||
if (*nextarg != '-' && *nextarg != '/')
|
||||
#else
|
||||
if (*nextarg != '-')
|
||||
#endif
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
nextarg++;
|
||||
|
||||
} /* if */
|
||||
|
||||
optopt = *nextarg++;
|
||||
|
||||
if (optopt == 0)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
optind++;
|
||||
|
||||
if (optopt == '-' && *nextarg == 0)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (optopt == ':' || optopt == '?')
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
fprintf
|
||||
(
|
||||
stderr,
|
||||
"%s: illegal option -- %c\n",
|
||||
argv[0],
|
||||
optopt
|
||||
);
|
||||
}
|
||||
|
||||
return ('?');
|
||||
|
||||
} /* if */
|
||||
|
||||
search = strchr (optstring, optopt);
|
||||
|
||||
if (search == NULL)
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
fprintf
|
||||
(
|
||||
stderr,
|
||||
"%s: illegal option -- %c\n",
|
||||
argv[0],
|
||||
optopt
|
||||
);
|
||||
}
|
||||
|
||||
return ('?');
|
||||
|
||||
} /* if */
|
||||
|
||||
if (*nextarg == 0)
|
||||
{
|
||||
nextarg = NULL;
|
||||
}
|
||||
|
||||
if (search[1] != ':')
|
||||
{
|
||||
if (nextarg != NULL)
|
||||
{
|
||||
optind--;
|
||||
}
|
||||
|
||||
return (optopt);
|
||||
}
|
||||
|
||||
if (nextarg != NULL)
|
||||
{
|
||||
optarg = nextarg;
|
||||
nextarg = NULL;
|
||||
return (optopt);
|
||||
}
|
||||
|
||||
optarg = argv[optind];
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
fprintf
|
||||
(
|
||||
stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
argv[0],
|
||||
optopt
|
||||
);
|
||||
|
||||
} /* if */
|
||||
|
||||
if (optstring[0] == ':')
|
||||
{
|
||||
return (':');
|
||||
}
|
||||
else
|
||||
{
|
||||
return ('?');
|
||||
}
|
||||
|
||||
} /* if */
|
||||
|
||||
else
|
||||
{
|
||||
optind++;
|
||||
}
|
||||
|
||||
return (optopt);
|
||||
|
||||
} /* getopt () */
|
||||
29
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/GETOPT.H
Normal file
29
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/GETOPT.H
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* $Header$
|
||||
*
|
||||
* Copyright (C) 1994 Arno Schaefer
|
||||
*
|
||||
* AU: Prototypen und externe Variablen fuer getopt ()
|
||||
*
|
||||
* PO: ANSI C
|
||||
*/
|
||||
|
||||
#ifndef GETOPT_H
|
||||
#define GETOPT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
extern int opterr;
|
||||
extern int optopt;
|
||||
|
||||
int getopt (int argc, char *argv[], char *optstring);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
257
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/GLOBAL.CPP
Normal file
257
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/GLOBAL.CPP
Normal file
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module global.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/global.cpp 1.4 1995/01/19 00:00:52 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <conio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "global.h"
|
||||
|
||||
#define CTRL_C 3
|
||||
|
||||
global_vars global;
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Initialization of global variables */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
global_vars::global_vars (void)
|
||||
{
|
||||
test_mode = false;
|
||||
verbose_mode = true;
|
||||
debug_mode = false;
|
||||
|
||||
drive_number_cmdline = 0;
|
||||
}
|
||||
|
||||
global_vars::~global_vars (void)
|
||||
{
|
||||
if (debug_mode) fclose (debugfile);
|
||||
}
|
||||
|
||||
void exit_function (void)
|
||||
{
|
||||
printx ("\nBye!\n");
|
||||
}
|
||||
|
||||
void global_vars::open_debugfile (int argc,char *argv[])
|
||||
{
|
||||
if ((debugfile = fopen ("fipsinfo.dbg","wt")) == NULL)
|
||||
{
|
||||
global.debug_mode = false;
|
||||
warning (true, "Can't open debug file");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (debugfile,"FIPS debug file\n\n");
|
||||
fprintf (debugfile,"The command was: ");
|
||||
while (argc--) fprintf (debugfile,argc ? "%s " : "%s", *argv++);
|
||||
fprintf (debugfile,"\n\nTranscript of session:\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Replacement for printf - prints to screen and debugfile */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void printx (char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap,fmt);
|
||||
vprintf (fmt,ap);
|
||||
if (global.debug_mode) vfprintf (global.debugfile,fmt,ap);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Replacement for getch - exit when CTRL-C is pressed */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
int getx (void)
|
||||
{
|
||||
int character = getch();
|
||||
if (character == CTRL_C)
|
||||
{
|
||||
printx ("\n");
|
||||
exit (0);
|
||||
}
|
||||
return (character);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Copyright notice and version number */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void notice (void)
|
||||
{
|
||||
printx ("\nFIPS version " FIPS_VERSION ", Copyright (C) 1993/94 Arno Schaefer\n\n");
|
||||
printx ("DO NOT use FIPS in a multitasking environment like Windows, OS/2, Desqview,\n");
|
||||
printx ("Novell Task manager or the Linux DOS emulator: boot from a DOS boot disk first.\n\n");
|
||||
printx ("If you use OS/2 or a disk compressor, read the relevant sections in FIPS.DOC.\n\n");
|
||||
printx ("FIPS comes with ABSOLUTELY NO WARRANTY, see file COPYING for details\n");
|
||||
printx ("This is free software, and you are welcome to redistribute it\n");
|
||||
printx ("under certain conditions; again see file COPYING for details.\n");
|
||||
|
||||
printx ("\nPress any Key\n");
|
||||
getx();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Hexdump binary data into a file */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void hexwrite (byte *buffer,int number,FILE *file)
|
||||
{
|
||||
for (int i=0;i<number;i++)
|
||||
{
|
||||
fprintf (file,"%02X ",*(buffer+i));
|
||||
if ((i+1)%16 == 0) fprintf (file,"\n");
|
||||
else if ((i+1)%8 == 0) fprintf (file,"- ");
|
||||
}
|
||||
fprintf (file,"\n");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Error Handling */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
static void print_verbose_message (char *message)
|
||||
{
|
||||
char line[256];
|
||||
int length = 0;
|
||||
FILE *error_msg_file;
|
||||
|
||||
fprintf (stderr,"\n");
|
||||
if (global.debug_mode) fprintf (global.debugfile,"\n");
|
||||
|
||||
if ((error_msg_file = fopen ("errors.txt","rt")) == NULL)
|
||||
{
|
||||
fprintf (stderr,"File ERRORS.TXT not found - no verbose messages available\n");
|
||||
if (global.debug_mode) fprintf (global.debugfile,"File ERRORS.TXT not found - no verbose messages available\n");
|
||||
global.verbose_mode = false;
|
||||
return;
|
||||
}
|
||||
|
||||
while (message[length] != 0 && message[length] != ':') length++;
|
||||
|
||||
fgets (line,255,error_msg_file);
|
||||
while (strncmp(message,line,length)) if (fgets (line,255,error_msg_file) == NULL) return;
|
||||
fgets (line,255,error_msg_file);
|
||||
while (!strncmp(" ",line,2))
|
||||
{
|
||||
fprintf (stderr,"%s",line+2);
|
||||
if (global.debug_mode) fprintf (global.debugfile,"%s",line+2);
|
||||
if (fgets (line,255,error_msg_file) == NULL) return;
|
||||
}
|
||||
fclose (error_msg_file);
|
||||
}
|
||||
|
||||
void error (char *message,...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap,message);
|
||||
|
||||
fprintf (stderr,"\nError: ");
|
||||
vfprintf (stderr,message,ap);
|
||||
fprintf (stderr,"\n");
|
||||
|
||||
if (global.debug_mode)
|
||||
{
|
||||
fprintf (global.debugfile,"\nError: ");
|
||||
vfprintf (global.debugfile,message,ap);
|
||||
fprintf (global.debugfile,"\n");
|
||||
}
|
||||
|
||||
va_end (ap);
|
||||
|
||||
if (global.verbose_mode) print_verbose_message (message);
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
void warning (boolean wait_key, char *message,...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap,message);
|
||||
|
||||
fprintf (stderr,"\nWarning: ");
|
||||
vfprintf (stderr,message,ap);
|
||||
fprintf (stderr,"\n");
|
||||
|
||||
if (global.debug_mode)
|
||||
{
|
||||
fprintf (global.debugfile,"\nWarning: ");
|
||||
vfprintf (global.debugfile,message,ap);
|
||||
fprintf (global.debugfile,"\n");
|
||||
}
|
||||
|
||||
va_end (ap);
|
||||
|
||||
if (global.verbose_mode) print_verbose_message (message);
|
||||
|
||||
if (wait_key)
|
||||
{
|
||||
fprintf (stderr,"\nPress any key\n");
|
||||
if (global.debug_mode) fprintf (global.debugfile,"\nPress any key\n");
|
||||
|
||||
getx ();
|
||||
}
|
||||
}
|
||||
|
||||
void infomsg (char *message,...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap,message);
|
||||
|
||||
fprintf (stderr,"\nInfo: ");
|
||||
vfprintf (stderr,message,ap);
|
||||
fprintf (stderr,"\n");
|
||||
|
||||
if (global.debug_mode)
|
||||
{
|
||||
fprintf (global.debugfile,"\nInfo: ");
|
||||
vfprintf (global.debugfile,message,ap);
|
||||
fprintf (global.debugfile,"\n");
|
||||
}
|
||||
|
||||
va_end (ap);
|
||||
|
||||
if (global.verbose_mode) print_verbose_message (message);
|
||||
|
||||
fprintf (stderr,"\nPress any key\n");
|
||||
if (global.debug_mode) fprintf (global.debugfile,"\nPress any key\n");
|
||||
|
||||
getx ();
|
||||
}
|
||||
70
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/GLOBAL.H
Normal file
70
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/GLOBAL.H
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module disk_io.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/global.h 1.4 1995/01/19 00:01:25 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#ifndef GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "hdstruct.h"
|
||||
#include "primpart.h"
|
||||
|
||||
struct global_vars
|
||||
{
|
||||
boolean test_mode;
|
||||
boolean verbose_mode;
|
||||
boolean debug_mode;
|
||||
|
||||
int drive_number_cmdline;
|
||||
|
||||
FILE *debugfile;
|
||||
void open_debugfile (int argc,char *argv[]);
|
||||
|
||||
global_vars (void);
|
||||
~global_vars (void);
|
||||
};
|
||||
|
||||
extern global_vars global;
|
||||
|
||||
void printx (char *fmt,...);
|
||||
int getx (void);
|
||||
void error (char *message,...);
|
||||
void warning (boolean wait_key, char *message,...);
|
||||
void infomsg (char *message,...);
|
||||
|
||||
void hexwrite (byte *buffer,int number,FILE *file);
|
||||
|
||||
void exit_function (void);
|
||||
void notice (void);
|
||||
void evaluate_argument_vector (int argc,char *argv[]);
|
||||
void save_root_and_boot (harddrive *drive,partition *partition);
|
||||
|
||||
#endif
|
||||
154
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/HDSTRUCT.CPP
Normal file
154
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/HDSTRUCT.CPP
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module hdstruct.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/hdstruct.cpp 1.4 1995/01/19 00:20:01 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include "types.h"
|
||||
#include "hdstruct.h"
|
||||
|
||||
root_sector::root_sector (root_sector &rs)
|
||||
{
|
||||
drive = rs.drive;
|
||||
for (int i=0; i<512; i++) data[i] = rs.data[i];
|
||||
}
|
||||
|
||||
void root_sector::operator= (root_sector &rs)
|
||||
{
|
||||
drive = rs.drive;
|
||||
for (int i=0; i<512; i++) data[i] = rs.data[i];
|
||||
}
|
||||
|
||||
void harddrive::operator= (harddrive &hd)
|
||||
{
|
||||
physical_drive::operator= (hd);
|
||||
*root_sector = *(hd.root_sector);
|
||||
partition_table () = hd.partition_table ();
|
||||
}
|
||||
|
||||
void harddrive::get_partition_table (void)
|
||||
{
|
||||
partition_table().get (root_sector);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
class partition_info* p
|
||||
= &(partition_table().partition_info[i]);
|
||||
|
||||
if (p->system == 0) continue;
|
||||
|
||||
while
|
||||
(
|
||||
p->start_sector_abs
|
||||
> (
|
||||
(p->start_cylinder + 1000UL)
|
||||
* geometry.heads
|
||||
* geometry.sectors
|
||||
+ p->start_head
|
||||
* geometry.sectors
|
||||
+ p->start_sector
|
||||
- 1
|
||||
)
|
||||
)
|
||||
{
|
||||
p->start_cylinder += 1024; // more than 1024 cylinders
|
||||
}
|
||||
|
||||
while
|
||||
(
|
||||
(p->start_sector_abs + p->no_of_sectors_abs - 1)
|
||||
> (
|
||||
(p->end_cylinder + 1000UL)
|
||||
* geometry.heads
|
||||
* geometry.sectors
|
||||
+ p->end_head
|
||||
* geometry.sectors
|
||||
+ p->end_sector
|
||||
- 1
|
||||
)
|
||||
)
|
||||
{
|
||||
p->end_cylinder += 1024; // more than 1024 cylinders
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Extract Partition Table from root sector */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void partition_table::get (root_sector *root_sector)
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
class partition_info *p = &partition_info[i];
|
||||
byte *pi = &(root_sector->data[0x1be+16*i]);
|
||||
|
||||
p->bootable = *pi;
|
||||
p->start_head = *(pi+1);
|
||||
p->start_cylinder = *(pi+3) | ((*(pi+2) << 2) & 0x300);
|
||||
p->start_sector = *(pi+2) & 0x3f;
|
||||
p->system = *(pi+4);
|
||||
p->end_head = *(pi+5);
|
||||
p->end_cylinder = *(pi+7) | ((*(pi+6) << 2) & 0x300);
|
||||
p->end_sector = *(pi+6) & 0x3f;
|
||||
p->start_sector_abs = (dword) *(pi+8) | ((dword) *(pi+9) << 8) | ((dword) *(pi+10) << 16) | ((dword) *(pi+11) << 24);
|
||||
p->no_of_sectors_abs = (dword) *(pi+12) | ((dword) *(pi+13) << 8) | ((dword) *(pi+14) << 16) | ((dword) *(pi+15) << 24);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Write Partition Table back into root sector */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void partition_table::put (root_sector *root_sector)
|
||||
{
|
||||
for (int i=0; i<4; i++)
|
||||
{
|
||||
class partition_info p = partition_info[i];
|
||||
byte *pi = &(root_sector->data[0x1be+16*i]);
|
||||
|
||||
*pi = p.bootable;
|
||||
*(pi+1) = p.start_head;
|
||||
*(pi+2) = ((p.start_cylinder >> 2) & 0xc0) | (p.start_sector & 0x3f);
|
||||
*(pi+3) = p.start_cylinder & 0xff;
|
||||
*(pi+4) = p.system;
|
||||
*(pi+5) = p.end_head;
|
||||
*(pi+6) = ((p.end_cylinder >> 2) & 0xc0) | (p.end_sector & 0x3f);
|
||||
*(pi+7) = p.end_cylinder & 0xff;
|
||||
*(pi+8) = p.start_sector_abs & 0xff;
|
||||
*(pi+9) = (p.start_sector_abs >> 8) & 0xff;
|
||||
*(pi+10) = (p.start_sector_abs >> 16) & 0xff;
|
||||
*(pi+11) = (p.start_sector_abs >> 24) & 0xff;
|
||||
*(pi+12) = p.no_of_sectors_abs & 0xff;
|
||||
*(pi+13) = (p.no_of_sectors_abs >> 8) & 0xff;
|
||||
*(pi+14) = (p.no_of_sectors_abs >> 16) & 0xff;
|
||||
*(pi+15) = (p.no_of_sectors_abs >> 24) & 0xff;
|
||||
}
|
||||
}
|
||||
144
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/HDSTRUCT.H
Normal file
144
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/HDSTRUCT.H
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module hdstruct.h
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/hdstruct.h 1.4 1995/01/19 00:01:26 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#ifndef HDSTRUCT_H
|
||||
#define HDSTRUCT_H
|
||||
|
||||
#include "types.h"
|
||||
#include "disk_io.h"
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Class root_sector - derived from structure sector */
|
||||
/* Must be initialized with a pointer to a physical_drive object */
|
||||
/* Read() and Write() read/write sector 0 of physical drive */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
class root_sector:public sector
|
||||
{
|
||||
physical_drive *drive;
|
||||
public:
|
||||
// constructors and operators
|
||||
|
||||
root_sector (physical_drive *drive) { root_sector::drive = drive; }
|
||||
root_sector (root_sector &rs);
|
||||
void operator= (root_sector &rs);
|
||||
|
||||
|
||||
// functions
|
||||
|
||||
int read (void) { return drive->read_sector (this, 0); }
|
||||
int write (void) { return drive->write_sector (this, 0); }
|
||||
};
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Partition Info Structure */
|
||||
/* Each entry in the partition table contains this information */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
struct partition_info
|
||||
{
|
||||
byte bootable; // 80h or 0
|
||||
byte start_head; // location of first sector (boot_sector)
|
||||
word start_cylinder;
|
||||
byte start_sector;
|
||||
byte system; // 1 = 12-bit FAT
|
||||
// 4 = 16-bit FAT & 16-bit sector number
|
||||
// 6 = 16-bit FAT & 32-bit sector number (BIGDOS)
|
||||
byte end_head; // location of last sector
|
||||
word end_cylinder;
|
||||
byte end_sector;
|
||||
dword start_sector_abs; // = start_cylinder * heads * sectors
|
||||
// + start_head * sectors + start_sector - 1
|
||||
dword no_of_sectors_abs; // = end_cylinder * heads * sectors + end_head * sectors
|
||||
// + end_sector - start_sector_abs
|
||||
};
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Partition Table Structure */
|
||||
/* The partition table consists of 4 entries for the 4 possible partitions */
|
||||
/* Get() reads the partition table from the root_sector, put() writes the */
|
||||
/* data back into the root_sector buffer */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
struct partition_table
|
||||
{
|
||||
partition_info partition_info[4];
|
||||
void get (root_sector *root_sector);
|
||||
void put (root_sector *root_sector);
|
||||
};
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Harddrive Class, derived from physical_drive */
|
||||
/* Represents one physical harddrive. Must be initialized with the drive */
|
||||
/* number (0x80 for 1st HDD). Contains the root_sector and partition table. */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
class harddrive:public physical_drive
|
||||
{
|
||||
partition_table pr_partition_table;
|
||||
|
||||
public:
|
||||
// constructors, destructors, operators
|
||||
|
||||
harddrive (int number):physical_drive (number)
|
||||
{
|
||||
root_sector = new class root_sector (this);
|
||||
}
|
||||
harddrive (harddrive &hd):physical_drive (hd)
|
||||
{
|
||||
root_sector = new class root_sector (*(hd.root_sector));
|
||||
partition_table () = hd.partition_table ();
|
||||
}
|
||||
void operator= (harddrive &hd);
|
||||
~harddrive (void) { delete root_sector; }
|
||||
|
||||
// public data
|
||||
|
||||
root_sector *root_sector;
|
||||
|
||||
// member access functions
|
||||
|
||||
virtual partition_table &partition_table() { return pr_partition_table; }
|
||||
|
||||
// functions
|
||||
|
||||
int read_root_sector (void) { return (root_sector->read ()); }
|
||||
int write_root_sector (void) { return (root_sector->write ()); }
|
||||
|
||||
void get_partition_table (void); // extract pt data from root sector
|
||||
void put_partition_table (void) // put pt data into root sector
|
||||
{partition_table().put (root_sector);}
|
||||
};
|
||||
|
||||
#endif
|
||||
114
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/HOST_OS.CPP
Normal file
114
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/HOST_OS.CPP
Normal file
@@ -0,0 +1,114 @@
|
||||
// host_os.cpp host operating system classes
|
||||
// dave mccaldon (d.mccalden@staffordshire.ac.uk)
|
||||
|
||||
#include "host_os.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dos.h>
|
||||
|
||||
char *msdos_info (void)
|
||||
{
|
||||
return ("MS-DOS version %d.%d");
|
||||
};
|
||||
|
||||
char *dosemu_info (void)
|
||||
{
|
||||
return ("Linux dosemu version %d.%d");
|
||||
};
|
||||
|
||||
char *mswindows_info (void)
|
||||
{
|
||||
return ("MS-Windows version %d.%d");
|
||||
};
|
||||
|
||||
char *desqview_info (void)
|
||||
{
|
||||
return ("Desq-View version %d.%d");
|
||||
};
|
||||
|
||||
host_os::host_os (void)
|
||||
{
|
||||
status = NOT_OK;
|
||||
if (mswindows_detect () == true) format = mswindows_info;
|
||||
// else if (dosemu_detect () == true) format = dosemu_info;
|
||||
else if (desqview_detect () == true) format = desqview_info;
|
||||
else
|
||||
{
|
||||
status = OK;
|
||||
msdos_version ();
|
||||
format = msdos_info;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char *host_os::information( char *p )
|
||||
{
|
||||
if( p == NULL )
|
||||
p = (char *) malloc( strlen( format() ) + 12 );
|
||||
sprintf( p, format(), ver_major, ver_minor );
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void host_os::msdos_version()
|
||||
{
|
||||
ver_major = _osmajor; // borlandc constants
|
||||
ver_minor = _osminor;
|
||||
}
|
||||
|
||||
boolean host_os::mswindows_detect()
|
||||
{
|
||||
union REGS r;
|
||||
|
||||
r.x.ax = 0x1600;
|
||||
int86( 0x2F, &r, &r );
|
||||
if( r.h.al & 0x7F )
|
||||
{
|
||||
ver_major = r.h.al;
|
||||
ver_minor = r.h.ah;
|
||||
return (true);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
boolean host_os::dosemu_detect()
|
||||
{
|
||||
union REGS r;
|
||||
|
||||
// this is slightly more difficult than just calling the dosemu
|
||||
// interrupt (0xE5), we need to check if the interrupt has a
|
||||
// handler, as DOS and BIOS don't establish a default handler
|
||||
|
||||
if( getvect( 0xE5 ) == NULL )
|
||||
return (false);
|
||||
r.x.ax = 0;
|
||||
int86( 0xE5, &r, &r );
|
||||
if( r.x.ax == 0xAA55 ) // check signature
|
||||
{
|
||||
ver_major = r.h.bh;
|
||||
ver_minor = r.h.bl;
|
||||
return (true);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
boolean host_os::desqview_detect()
|
||||
{
|
||||
union REGS r;
|
||||
|
||||
r.x.ax = 0x2B01; // AL=01 => get desqview version
|
||||
r.x.cx = 0x4445; // CX = 'DE'
|
||||
r.x.dx = 0x5351; // DX = 'SQ'
|
||||
int86( 0x21, &r, &r );
|
||||
if( r.h.al != 0xFF )
|
||||
{
|
||||
ver_major = r.h.bh;
|
||||
ver_minor = r.h.bl;
|
||||
return (true);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
34
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/HOST_OS.H
Normal file
34
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/HOST_OS.H
Normal file
@@ -0,0 +1,34 @@
|
||||
// host_os.h host operating system classes
|
||||
// dave mccaldon (d.mccalden@staffordshire.ac.uk)
|
||||
|
||||
#ifndef HOST_OS_H
|
||||
#define HOST_OS_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define NOT_OK 0 // NOT_OK for FIPS to run
|
||||
#define OK 1 // OK for FIPS to run
|
||||
#define UNKNOWN 2
|
||||
|
||||
|
||||
class host_os
|
||||
{
|
||||
public:
|
||||
host_os(); // constructor
|
||||
virtual int ok () { return status; };
|
||||
virtual char *information( char * );
|
||||
|
||||
protected:
|
||||
char* (*format)();
|
||||
|
||||
void msdos_version ();
|
||||
boolean mswindows_detect ();
|
||||
boolean dosemu_detect ();
|
||||
boolean desqview_detect ();
|
||||
|
||||
int status; // status value
|
||||
int ver_major; // major version number
|
||||
int ver_minor; // minor version number
|
||||
};
|
||||
|
||||
#endif
|
||||
232
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/INPUT.CPP
Normal file
232
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/INPUT.CPP
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module input.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/input.cpp 1.4 1995/01/19 00:00:54 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include "types.h"
|
||||
#include "disk_io.h"
|
||||
#include "global.h"
|
||||
#include "input.h"
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* User Input */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
static void wait_for_key (void)
|
||||
{
|
||||
printx ("\nPress any Key\n");
|
||||
getx();
|
||||
}
|
||||
|
||||
|
||||
int ask_for_drive_number (void)
|
||||
|
||||
/*
|
||||
* Find Disk Drives - if more than one, ask for drive number. If no drive
|
||||
* was found, issue warning, try drive 0x80 anyway
|
||||
*/
|
||||
|
||||
{
|
||||
int drives_found = 0;
|
||||
int drive_table[] = {0,0,0,0,0,0,0,0,0};
|
||||
|
||||
int no_of_drives = get_no_of_drives ();
|
||||
|
||||
for (int i=0x80; i < 0x80 + no_of_drives; i++)
|
||||
{
|
||||
if (get_disk_type (i) == 3)
|
||||
{
|
||||
drive_table[drives_found++] = i;
|
||||
if (drives_found == 9)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (drives_found == 0)
|
||||
{
|
||||
warning (false, "No compatible hard disk found");
|
||||
ask_if_continue ();
|
||||
|
||||
return (0x80);
|
||||
}
|
||||
|
||||
if (drives_found == 1)
|
||||
return (drive_table[0]);
|
||||
|
||||
printx ("Which Drive (");
|
||||
|
||||
for (i=0; i<drives_found; i++)
|
||||
printx ("%u=0x%02X/", i+1, drive_table[i]);
|
||||
printx ("\b)? ");
|
||||
|
||||
while (true)
|
||||
{
|
||||
i = getx ();
|
||||
|
||||
if (i >= '1' && i <= '9')
|
||||
if (drive_table[i - '1'] != 0) break;
|
||||
}
|
||||
|
||||
printx ("%c\n",i);
|
||||
return (drive_table[i - '1']);
|
||||
}
|
||||
|
||||
|
||||
int ask_for_partition_number (partition_info parts[])
|
||||
{
|
||||
int number_of_partitions = (parts[0].system != 0) + (parts[1].system != 0) +
|
||||
(parts[2].system != 0) + (parts[3].system != 0);
|
||||
|
||||
if (number_of_partitions == 0)
|
||||
error ("No valid partition found");
|
||||
|
||||
if (number_of_partitions == 4)
|
||||
error ("No free partition");
|
||||
|
||||
if (number_of_partitions == 1)
|
||||
{
|
||||
wait_for_key();
|
||||
for (int i = 0; i < 4; i++) if (parts[i].system) return i;
|
||||
}
|
||||
|
||||
printx ("\nWhich Partition do you want to split (");
|
||||
|
||||
for (int i = 0; i < 4; i++) if (parts[i].system) printx ("%u/", i + 1);
|
||||
printx ("\b)? ");
|
||||
|
||||
while (true)
|
||||
{
|
||||
i = getx ();
|
||||
if (isdigit (i)) if (('0' < i) && (i <= '4')) if (parts[i - '1'].system) break;
|
||||
}
|
||||
printx ("%c\n", i);
|
||||
return (i - '1');
|
||||
}
|
||||
|
||||
|
||||
dword ask_for_new_start_cylinder (int start_cylinder, int min_cylinder, int max_cylinder, int sectors_per_cylinder)
|
||||
{
|
||||
int akt_cylinder = min_cylinder;
|
||||
|
||||
printx ("\nEnter start cylinder for new partition (%u - %u):\n\n",min_cylinder,max_cylinder);
|
||||
printx ("Use the cursor keys to choose the cylinder, <enter> to continue\n\n");
|
||||
printx ("Old partition Cylinder New Partition\n");
|
||||
|
||||
while (true)
|
||||
{
|
||||
double oldsize = (akt_cylinder - start_cylinder) * (double) sectors_per_cylinder / 2048;
|
||||
double newsize = (max_cylinder - akt_cylinder + 1) * (double) sectors_per_cylinder / 2048;
|
||||
|
||||
printf (" %6.1f MB %4u %6.1f MB\r", oldsize, akt_cylinder, newsize);
|
||||
|
||||
int input = getx ();
|
||||
if (input == '\r')
|
||||
{
|
||||
printx (" %6.1f MB %4u %6.1f MB\n\n", oldsize, akt_cylinder, newsize);
|
||||
return (akt_cylinder);
|
||||
}
|
||||
else if (input != 0) continue;
|
||||
|
||||
input = getx ();
|
||||
switch (input)
|
||||
{
|
||||
case 75:
|
||||
if (akt_cylinder > min_cylinder) akt_cylinder--;
|
||||
break;
|
||||
case 77:
|
||||
if (akt_cylinder < max_cylinder) akt_cylinder++;
|
||||
break;
|
||||
case 72:
|
||||
if (akt_cylinder - 10 >= min_cylinder) akt_cylinder -= 10;
|
||||
break;
|
||||
case 80:
|
||||
if (akt_cylinder + 10 <= max_cylinder) akt_cylinder += 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char ask_yes_no (void)
|
||||
{
|
||||
int character;
|
||||
do character = getx(); while ((character != 'y') && (character != 'n'));
|
||||
printx ("%c\n",character);
|
||||
return (character);
|
||||
}
|
||||
|
||||
char ask_correction (void)
|
||||
{
|
||||
printx ("Do you want to correct this (y/n) ");
|
||||
return (ask_yes_no ());
|
||||
}
|
||||
|
||||
|
||||
void ask_for_write_permission (void)
|
||||
{
|
||||
printx ("\nReady to write new partition scheme to disk\n");
|
||||
printx ("Do you want to proceed (y/n)? ");
|
||||
|
||||
if (ask_yes_no () == 'n') exit (0);
|
||||
}
|
||||
|
||||
boolean ask_if_continue (void)
|
||||
{
|
||||
printx ("\nDo you want to continue or reedit the partition table (c/r)? ");
|
||||
|
||||
int character;
|
||||
do character = getx(); while ((character != 'c') && (character != 'r'));
|
||||
printx ("%c\n",character);
|
||||
if (character == 'r') return (false);
|
||||
return (true);
|
||||
}
|
||||
|
||||
boolean ask_if_save (void)
|
||||
{
|
||||
int character;
|
||||
|
||||
printx ("Do you want to make a backup copy of your root and boot sector before\nproceeding (y/n)? ");
|
||||
if (ask_yes_no () == 'n') return (false);
|
||||
|
||||
printx ("Do you have a bootable floppy disk in drive A: as described in the\ndocumentation (y/n)? ");
|
||||
if (ask_yes_no () == 'n')
|
||||
{
|
||||
printx ("Please read the file FIPS.DOC!\n");
|
||||
exit (0);
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
void ask_if_proceed (void)
|
||||
{
|
||||
printx ("Do you want to proceed (y/n)? ");
|
||||
|
||||
if (ask_yes_no () == 'n') exit (0);
|
||||
}
|
||||
47
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/INPUT.H
Normal file
47
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/INPUT.H
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module input.h
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/input.h 1.4 1995/01/19 00:01:27 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
#include "types.h"
|
||||
#include "hdstruct.h"
|
||||
|
||||
int ask_for_drive_number (void);
|
||||
int ask_for_partition_number (partition_info parts[]);
|
||||
dword ask_for_new_start_cylinder (int start_cylinder, int min_cylinder,int max_cylinder, int sectors_per_cylinder);
|
||||
void ask_for_write_permission (void);
|
||||
boolean ask_if_continue (void);
|
||||
boolean ask_if_save (void);
|
||||
void ask_if_proceed (void);
|
||||
char ask_yes_no (void);
|
||||
char ask_correction (void);
|
||||
|
||||
#endif
|
||||
126
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/LOGDR_ST.CPP
Normal file
126
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/LOGDR_ST.CPP
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module logdr_st.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/logdr_str.cpp 1.4 1995/01/19 00:00:54 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "types.h"
|
||||
#include "logdr_st.h"
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Extract Bios Parameter Block from boot sector */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void bios_parameter_block::get (boot_sector *boot_sector)
|
||||
{
|
||||
byte *bp = boot_sector->data;
|
||||
|
||||
memcpy (jump_instruction,bp,3);
|
||||
memcpy (oem_name,bp+3,8);
|
||||
oem_name[8]=0;
|
||||
bytes_per_sector = *(bp+0xb) | (*(bp+0xc) << 8);
|
||||
sectors_per_cluster = *(bp+0xd);
|
||||
reserved_sectors = *(bp+0xe) | (*(bp+0xf) << 8);
|
||||
no_of_fats = *(bp+0x10);
|
||||
no_of_rootdir_entries = *(bp+0x11) | (*(bp+0x12) << 8);
|
||||
no_of_sectors = *(bp+0x13) | (*(bp+0x14) << 8);
|
||||
media_descriptor = *(bp+0x15);
|
||||
sectors_per_fat = *(bp+0x16) | (*(bp+0x17) << 8);
|
||||
sectors_per_track = *(bp+0x18) | (*(bp+0x19) << 8);
|
||||
drive_heads = *(bp+0x1a) | (*(bp+0x1b) << 8);
|
||||
hidden_sectors = (dword) *(bp+0x1c) | ((dword) *(bp+0x1d) << 8) | ((dword) *(bp+0x1e) << 16) | ((dword) *(bp+0x1f) << 24);
|
||||
no_of_sectors_long = (dword) *(bp+0x20) | ((dword) *(bp+0x21) << 8) | ((dword) *(bp+0x22) << 16) | ((dword) *(bp+0x23) << 24);
|
||||
phys_drive_no = *(bp+0x24);
|
||||
signature = *(bp+0x26);
|
||||
serial_number = (dword) *(bp+0x27) | ((dword) *(bp+0x28) << 8) | ((dword) *(bp+0x29) << 16) | ((dword) *(bp+0x2a) << 24);
|
||||
memcpy (volume_label,bp+0x2b,11);
|
||||
volume_label[11] = 0;
|
||||
memcpy (file_system_id,bp+0x36,8);
|
||||
file_system_id[8] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Write Bios Parameter Block back into boot sector */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void bios_parameter_block::put (boot_sector *boot_sector)
|
||||
{
|
||||
byte *bp = boot_sector->data;
|
||||
|
||||
memcpy (bp,jump_instruction,3);
|
||||
memcpy (bp+3,oem_name,8);
|
||||
*(bp+0xb) = bytes_per_sector & 0xff;
|
||||
*(bp+0xc) = (bytes_per_sector >> 8) & 0xff;
|
||||
*(bp+0xd) = sectors_per_cluster;
|
||||
*(bp+0xe) = reserved_sectors & 0xff;
|
||||
*(bp+0xf) = (reserved_sectors >> 8) & 0xff;
|
||||
*(bp+0x10) = no_of_fats;
|
||||
*(bp+0x11) = no_of_rootdir_entries & 0xff;
|
||||
*(bp+0x12) = (no_of_rootdir_entries >> 8) & 0xff;
|
||||
*(bp+0x13) = no_of_sectors & 0xff;
|
||||
*(bp+0x14) = (no_of_sectors >> 8) & 0xff;
|
||||
*(bp+0x15) = media_descriptor;
|
||||
*(bp+0x16) = sectors_per_fat & 0xff;
|
||||
*(bp+0x17) = (sectors_per_fat >> 8) & 0xff;
|
||||
*(bp+0x18) = sectors_per_track & 0xff;
|
||||
*(bp+0x19) = (sectors_per_track >> 8) & 0xff;
|
||||
*(bp+0x1a) = drive_heads & 0xff;
|
||||
*(bp+0x1b) = (drive_heads >> 8) & 0xff;
|
||||
*(bp+0x1c) = hidden_sectors & 0xff;
|
||||
*(bp+0x1d) = (hidden_sectors >> 8) & 0xff;
|
||||
*(bp+0x1e) = (hidden_sectors >> 16) & 0xff;
|
||||
*(bp+0x1f) = (hidden_sectors >> 24) & 0xff;
|
||||
*(bp+0x20) = no_of_sectors_long & 0xff;
|
||||
*(bp+0x21) = (no_of_sectors_long >> 8) & 0xff;
|
||||
*(bp+0x22) = (no_of_sectors_long >> 16) & 0xff;
|
||||
*(bp+0x23) = (no_of_sectors_long >> 24) & 0xff;
|
||||
*(bp+0x24) = phys_drive_no;
|
||||
*(bp+0x26) = signature;
|
||||
*(bp+0x27) = serial_number & 0xff;
|
||||
*(bp+0x28) = (serial_number >> 8) & 0xff;
|
||||
*(bp+0x29) = (serial_number >> 16) & 0xff;
|
||||
*(bp+0x2a) = (serial_number >> 24) & 0xff;
|
||||
memcpy (bp+0x2b,volume_label,11);
|
||||
memcpy (bp+0x36,file_system_id,8);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Extract some misc. drive parameters from BPB */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void logical_drive_info::get (const bios_parameter_block &bpb)
|
||||
{
|
||||
start_fat1 = bpb.reserved_sectors;
|
||||
start_fat2 = start_fat1 + bpb.sectors_per_fat;
|
||||
start_rootdir = start_fat2 + bpb.sectors_per_fat;
|
||||
if (bpb.no_of_rootdir_entries == 0) start_data = start_rootdir;
|
||||
else start_data = start_rootdir + (bpb.no_of_rootdir_entries - 1) / 16 + 1;
|
||||
if (bpb.sectors_per_cluster == 0) no_of_clusters = 0;
|
||||
else no_of_clusters = ((bpb.no_of_sectors ? bpb.no_of_sectors : bpb.no_of_sectors_long) - start_data) / bpb.sectors_per_cluster;
|
||||
};
|
||||
|
||||
174
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/LOGDR_ST.H
Normal file
174
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/LOGDR_ST.H
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module logdr_st.h
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/logdr_st.h 1.4 1995/01/19 00:01:27 schaefer Exp $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#ifndef LOGDR_ST_H
|
||||
#define LOGDR_ST_H
|
||||
|
||||
#include "types.h"
|
||||
#include "disk_io.h"
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Class boot_sector - derived from structure sector */
|
||||
/* Must be initialized with pointer to logical drive object */
|
||||
/* Read() and write() read/write sector 0 of logical drive */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
class boot_sector:public sector
|
||||
{
|
||||
class logical_drive *logical_drive;
|
||||
public:
|
||||
// constructor
|
||||
|
||||
boot_sector (class logical_drive *logical_drive)
|
||||
{ boot_sector::logical_drive = logical_drive; }
|
||||
|
||||
|
||||
// functions
|
||||
|
||||
int read (void);
|
||||
int write (void);
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* Bios Parameter Block structure */
|
||||
/* This is not exactly the BPB as understood by DOS, because it contains */
|
||||
/* the additional fields that are in the boot_sector like jump_instruction, */
|
||||
/* oem_name etc. Get() extracts info from the boot_sector, put() writes the */
|
||||
/* info back into the boot_sector buffer. */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
struct bios_parameter_block
|
||||
{
|
||||
byte jump_instruction[3]; // EB xx 90 or E9 xx xx
|
||||
char oem_name[9];
|
||||
word bytes_per_sector; // usually 512
|
||||
byte sectors_per_cluster; // may differ
|
||||
word reserved_sectors; // usually 1 (boot_sector)
|
||||
byte no_of_fats; // usually 2
|
||||
word no_of_rootdir_entries; // usually 512 for HDs (?), 224 for
|
||||
// HD-Floppies, 112 for DD-Floppies
|
||||
word no_of_sectors; // 0 on BIGDOS partitions
|
||||
byte media_descriptor; // usually F8h
|
||||
word sectors_per_fat; // depends on partition size
|
||||
word sectors_per_track; // depends on drive
|
||||
word drive_heads; // dto.
|
||||
dword hidden_sectors; // first sector of partition or 0 for FDs
|
||||
dword no_of_sectors_long; // number of sectors on BIGDOS partitions
|
||||
byte phys_drive_no; // usually 80h
|
||||
byte signature; // usually 29h
|
||||
dword serial_number; // random
|
||||
char volume_label[12];
|
||||
char file_system_id[9];
|
||||
|
||||
void get (boot_sector *boot_sector);
|
||||
void put (boot_sector *boot_sector);
|
||||
};
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Some miscellaneous figures about the drive */
|
||||
/* Get() extracts this info from the BPB */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
struct logical_drive_info
|
||||
{
|
||||
dword start_fat1;
|
||||
dword start_fat2;
|
||||
dword start_rootdir;
|
||||
dword start_data;
|
||||
dword no_of_clusters;
|
||||
|
||||
virtual void get (const bios_parameter_block &bpb);
|
||||
};
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Abstract Class logical_drive. This can be any DOS drive that allows */
|
||||
/* direct reading and writing of sectors, like Harddisk Partitions, Floppy */
|
||||
/* disks or Ramdisks */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
class logical_drive
|
||||
{
|
||||
// private data
|
||||
|
||||
struct bios_parameter_block pr_bpb;
|
||||
struct logical_drive_info pr_info;
|
||||
|
||||
public:
|
||||
|
||||
// public data
|
||||
|
||||
class boot_sector *boot_sector;
|
||||
|
||||
// member access functions
|
||||
|
||||
virtual bios_parameter_block &bpb() { return pr_bpb; }
|
||||
virtual logical_drive_info &info() { return pr_info; }
|
||||
|
||||
// functions
|
||||
|
||||
virtual int read_sector (dword number,sector *sector) = 0;
|
||||
virtual int write_sector (dword number,sector *sector) = 0;
|
||||
// pure virtual functions
|
||||
|
||||
int read_boot_sector (void) { return (boot_sector->read ()); }
|
||||
int write_boot_sector (void) { return (boot_sector->write ()); }
|
||||
|
||||
void get_bpb (void) { bpb().get (boot_sector); }
|
||||
void put_bpb (void) { bpb().put (boot_sector); }
|
||||
|
||||
void get_info (void) { info().get (bpb ()); }
|
||||
};
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Function to read boot_sector from logical drive */
|
||||
/* It must be in the header file because it is inline */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
inline int boot_sector::read (void)
|
||||
{
|
||||
return logical_drive->read_sector (0,this);
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Function to write boot_sector to logical drive */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
inline int boot_sector::write (void)
|
||||
{
|
||||
return logical_drive->write_sector (0,this);
|
||||
}
|
||||
|
||||
#endif
|
||||
171
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/MAIN.CPP
Normal file
171
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/MAIN.CPP
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module main.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/main.cpp 1.4 1995/01/19 00:00:55 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "logdr_st.h"
|
||||
#include "global.h"
|
||||
#include "input.h"
|
||||
#include "fat.h"
|
||||
#include "fipsspec.h"
|
||||
#include "host_os.h"
|
||||
|
||||
|
||||
#define FIRST_CHECK false
|
||||
#define FINAL_CHECK true
|
||||
|
||||
|
||||
extern unsigned _stklen = 20000U;
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
// *********************************************************
|
||||
// Initialize Program
|
||||
// *********************************************************
|
||||
|
||||
evaluate_argument_vector (argc, argv);
|
||||
|
||||
atexit (exit_function);
|
||||
|
||||
if (global.debug_mode)
|
||||
global.open_debugfile (argc,argv);
|
||||
|
||||
notice ();
|
||||
|
||||
host_os os;
|
||||
char infostring[256];
|
||||
|
||||
if (os.ok () != OK)
|
||||
{
|
||||
printx ("\nWARNING: FIPS has detected that it is running under %s\n"
|
||||
"FIPS should not be used under a multitasking OS. If possible, boot from a DOS\n"
|
||||
"disk and then run FIPS. Read FIPS.DOC for more information.\n\n",
|
||||
os.information (infostring));
|
||||
|
||||
ask_if_proceed ();
|
||||
}
|
||||
|
||||
|
||||
// *********************************************************
|
||||
// Select Drive
|
||||
// *********************************************************
|
||||
|
||||
int drive_number;
|
||||
|
||||
if (global.drive_number_cmdline != 0)
|
||||
drive_number = global.drive_number_cmdline;
|
||||
else
|
||||
drive_number = ask_for_drive_number ();
|
||||
|
||||
fips_harddrive harddrive (drive_number); // reads geometry
|
||||
|
||||
if (harddrive.errorcode)
|
||||
error
|
||||
(
|
||||
"Error reading drive geometry: Errorcode %u",
|
||||
harddrive.errorcode
|
||||
);
|
||||
|
||||
harddrive.reset ();
|
||||
|
||||
if (harddrive.errorcode)
|
||||
{
|
||||
warning
|
||||
(
|
||||
false,
|
||||
"Drive initialization failure: Errorcode %u",
|
||||
harddrive.errorcode
|
||||
);
|
||||
|
||||
ask_if_proceed ();
|
||||
}
|
||||
|
||||
|
||||
// *********************************************************
|
||||
// Select partition
|
||||
// *********************************************************
|
||||
|
||||
if (harddrive.read_root_sector () != 0)
|
||||
error ("Error reading root sector");
|
||||
|
||||
if (global.debug_mode)
|
||||
{
|
||||
fprintf
|
||||
(
|
||||
global.debugfile,
|
||||
"\nRoot sector drive %02Xh:\n\n",
|
||||
drive_number
|
||||
);
|
||||
|
||||
hexwrite (harddrive.root_sector->data, 512, global.debugfile);
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
fips_harddrive hd = harddrive;
|
||||
|
||||
hd.get_partition_table();
|
||||
|
||||
printx ("\nPartition table:\n\n");
|
||||
hd.print_partition_table ();
|
||||
|
||||
hd.check (FIRST_CHECK);
|
||||
|
||||
int partition_number =
|
||||
ask_for_partition_number
|
||||
(
|
||||
hd.partition_table().partition_info
|
||||
);
|
||||
|
||||
int system = hd.partition_table()
|
||||
.partition_info[partition_number].system;
|
||||
|
||||
switch (system)
|
||||
{
|
||||
case 5:
|
||||
error ("Can't split extended partitions");
|
||||
break;
|
||||
case 1: case 4: case 6:
|
||||
{
|
||||
fips_partition* partition =
|
||||
new fips_partition (&hd, partition_number);
|
||||
|
||||
if (partition->split (hd) == true)
|
||||
return (0);
|
||||
|
||||
delete partition;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error ("Unknown file system: %02Xh", system);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
83
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/PRIMPART.H
Normal file
83
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/PRIMPART.H
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module hdstruct.h
|
||||
|
||||
RCS - Header:
|
||||
$Id$
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Partition Class, derived from logical_drive and raw_partition */
|
||||
/* Represents one primary DOS partition. Read_sector() and write_sector() */
|
||||
/* are instances of the virtual functions in the logical_drive class */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PRIMPART_H
|
||||
#define PRIMPART_H
|
||||
|
||||
#include "types.h"
|
||||
#include "disk_io.h"
|
||||
#include "logdr_st.h"
|
||||
#include "hdstruct.h"
|
||||
|
||||
class partition:public logical_drive
|
||||
{
|
||||
public:
|
||||
int number;
|
||||
physical_drive *drive;
|
||||
partition_info *partition_info;
|
||||
|
||||
int read_sector (dword number, sector *sector)
|
||||
{
|
||||
return (drive->read_sector
|
||||
(
|
||||
sector,
|
||||
partition_info->start_sector_abs
|
||||
+ number
|
||||
));
|
||||
}
|
||||
int write_sector (dword number, sector *sector)
|
||||
{
|
||||
return (drive->write_sector
|
||||
(
|
||||
sector,
|
||||
partition_info->start_sector_abs
|
||||
+ number
|
||||
));
|
||||
}
|
||||
|
||||
partition (class harddrive *drive, int number)
|
||||
{
|
||||
partition::number = number;
|
||||
partition::drive = drive;
|
||||
partition_info =
|
||||
&(drive->partition_table().partition_info[number]);
|
||||
|
||||
boot_sector = new class boot_sector (this);
|
||||
}
|
||||
~partition (void) { delete boot_sector; }
|
||||
};
|
||||
|
||||
#endif
|
||||
68
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/SAVE.CPP
Normal file
68
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/SAVE.CPP
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module save.cpp
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/save.cpp 1.4 1995/01/19 00:01:24 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#include "global.h"
|
||||
#include "hdstruct.h"
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Save root- and boot sector to floppy disk */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void save_root_and_boot (harddrive *drive,partition *partition)
|
||||
{
|
||||
FILE *save_file;
|
||||
|
||||
char *filename = "a:\\rootboot.000";
|
||||
|
||||
while (access (filename,0) == 0)
|
||||
{
|
||||
if (++filename[14] > '9')
|
||||
error ("Too many save files on disk");
|
||||
}
|
||||
|
||||
if ((save_file = fopen (filename,"wb")) == NULL)
|
||||
error ("Can't open file: %s",filename);
|
||||
|
||||
printx ("\nWriting file %s\n", filename);
|
||||
|
||||
if (fwrite (drive->root_sector->data,1,512,save_file) != 512)
|
||||
error ("Error writing file: %s",filename);
|
||||
if (fwrite (partition->boot_sector->data,1,512,save_file) != 512)
|
||||
error ("Error writing file: %s",filename);
|
||||
if (fputc (drive->number,save_file) != drive->number)
|
||||
error ("Error writing file: %s",filename);
|
||||
if (fputc (partition->number,save_file) != partition->number)
|
||||
error ("Error writing file: %s",filename);
|
||||
|
||||
if (fclose (save_file))
|
||||
error ("Error closing file: %s",filename);
|
||||
}
|
||||
40
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/TYPES.H
Normal file
40
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/TYPES.H
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
FIPS - the First nondestructive Interactive Partition Splitting program
|
||||
|
||||
Module disk_io.h
|
||||
|
||||
RCS - Header:
|
||||
$Header: c:/daten/fips/source/main/RCS/types.h 1.4 1995/01/19 00:01:28 schaefer Exp schaefer $
|
||||
|
||||
Copyright (C) 1993 Arno Schaefer
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
schaefer@rbg.informatik.th-darmstadt.de
|
||||
*/
|
||||
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned int word;
|
||||
typedef unsigned long dword;
|
||||
|
||||
typedef enum {false,true} boolean;
|
||||
|
||||
#endif
|
||||
1
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/VERSION.H
Normal file
1
Minix/CD-ROM-2.0/DOSUTILS/FIPS/SOURCE/VERSION.H
Normal file
@@ -0,0 +1 @@
|
||||
#define FIPS_VERSION "1.5"
|
||||
Reference in New Issue
Block a user