add dumpbs option to sys

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1083 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Kenneth J Davis 2005-01-01 15:30:56 +00:00
parent 2c6ba2f90e
commit ebecfcb6b0
3 changed files with 55 additions and 1 deletions

View File

@ -55,6 +55,16 @@ Switches (FreeDOS specific):
[image or bs] file, if exists only the 1st 512 bytes will be
overwritten.
<b>/DUMPBS <i>[path]filename</i></b>
The original boot sector is written to <i>[path]filename</i> and
then exits. The filename may refer to any [image or bs] file,
if exists only the 1st 512 bytes will be overwritten.
Note: /backupbs is intented to provide a backup of existing
boot sector in case one wishes to restore it later (see /restorbs),
whereas /dumpbs is intended only as a convenient method to
obtain current boot sector (such as for debugging purposes or
alternate installation scenerios).
<b>/RESTORBS <i>[path]filename</i></b>
Restores original boot sector (<i>[path]filename</i>) and exits.
The boot sector specified is written with no modifications.

View File

@ -36,6 +36,7 @@ SYS [source] dest: [bootsect] [{option}]
/SKFN filename : set KERNEL.SYS input file and /OEM:FD
/SCFN filename : sets COMMAND.COM input file
/BACKUPBS [path]filename : save current bs before overwriting
/DUMPBS [path]filename : save current bs and exit
/RESTORBS [path]filename : overwrite bs and exit
SYS CONFIG /help

View File

@ -30,7 +30,7 @@
/* #define DDEBUG */
#define WITHOEMCOMPATBS /* include support for OEM MS/PC DOS 3.??-6.x */
#define SYS_VERSION "v3.5"
#define SYS_VERSION "v3.5a"
#include <stdlib.h>
#include <dos.h>
@ -325,6 +325,7 @@ typedef struct SYSOptions {
} SYSOptions;
void dumpBS(const char *, int);
void restoreBS(const char *, int);
void put_boot(SYSOptions *opts);
BOOL check_space(COUNT, ULONG);
@ -464,6 +465,14 @@ void initOptions(int argc, char *argv[], SYSOptions *opts)
{
opts->bsFileOrig = argv[argno];
}
else if (memicmp(argp, "DUMPBS", 6) == 0) /* save current bs and exit */
{
if (drivearg)
dumpBS(argv[argno], (BYTE)(toupper(*(argv[drivearg])) - 'A'));
else
printf("%s: unspecified drive, unable to obtain boot sector\n", pgm);
exit(1);
}
else if (memicmp(argp, "RESTORBS", 8) == 0) /* overwrite bs and exit */
{
if (drivearg)
@ -1001,6 +1010,7 @@ void correct_bpb(struct bootsectortype *default_bpb,
oldboot->bsHiddenSecs = default_bpb->bsHiddenSecs;
}
/* reads in boot sector (1st SEC_SIZE bytes) from file */
void readBS(const char *bsFile, UBYTE *bootsector)
{
@ -1093,6 +1103,39 @@ void saveBS(const char *bsFile, UBYTE *bootsector)
} /* if write boot sector file */
}
/* write drive's boot record unmodified to bsFile */
void dumpBS(const char *bsFile, int drive)
{
UBYTE bootsector[SEC_SIZE];
if (bsFile == NULL)
{
printf("%s: missing filename to dump boot sector to\n", pgm);
exit(1);
}
/* lock drive */
generic_block_ioctl(drive + 1, 0x84a, NULL);
reset_drive(drive);
/* suggestion: allow reading from a boot sector or image file here */
if (MyAbsReadWrite(drive, 1, 0, bootsector, 0) != 0)
{
printf("%s: failed to read boot sector for drive %c:\n", pgm, drive + 'A');
exit(1);
}
reset_drive(drive);
/* unlock_drive */
generic_block_ioctl(drive + 1, 0x86a, NULL);
saveBS(bsFile, bootsector);
}
void put_boot(SYSOptions *opts)
{
#ifdef WITHFAT32