"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/main.c" between
ms-sys-2.4.1.tar.gz and ms-sys-2.6.0.tar.gz

About: ms-sys writes Microsoft compatible boot records.

main.c  (ms-sys-2.4.1):main.c  (ms-sys-2.6.0)
/****************************************************************** /******************************************************************
Copyright (C) 2009 Henrik Carlqvist Copyright (C) 2009-2016 Henrik Carlqvist
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
skipping to change at line 25 skipping to change at line 25
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
******************************************************************/ ******************************************************************/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "fat12.h" #include "fat12.h"
#include "fat16.h" #include "fat16.h"
#include "fat16fd.h"
#include "fat32.h" #include "fat32.h"
#include "fat32fd.h"
#include "fat32nt.h"
#include "fat32pe.h"
#include "ntfs.h" #include "ntfs.h"
#include "oem_id.h"
#include "br.h" #include "br.h"
#include "identify.h" #include "identify.h"
#include "nls.h" #include "nls.h"
#include "partition_info.h" #include "partition_info.h"
#define VERSION "2.4.1" #define VERSION "2.6.0"
void print_help(const char *szCommand); void print_help(const char *szCommand);
void print_version(void); void print_version(void);
int parse_switches(int argc, char **argv, int *piBr, int parse_switches(int argc, char **argv, int *piBr,
int *pbForce, int *pbPrintVersion, int *pbForce, int *pbPrintVersion,
int *pbKeepLabel, int *pbWritePartitionInfo, int *piHeads); int *pbKeepLabel, int *pbWritePartitionInfo, int *piHeads,
char **pszOemId,
int *pbWriteWindowsDiskSignature,
uint32_t *tWindowsDiskSignature);
int isnumber(const char *szString); int isnumber(const char *szString);
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
FILE *fp; FILE *fp;
int iBr = NO_WRITING; int iBr = NO_WRITING;
int bForce = 0; int bForce = 0;
int bPrintVersion = 0; int bPrintVersion = 0;
int bKeepLabel = 1; int bKeepLabel = 1;
int bWritePartitionInfo = 0; int bWritePartitionInfo = 0;
int iHeads = -1; int iHeads = -1;
char *szOemId = NULL;
int bWriteWindowsDiskSignature = 0;
uint32_t tWindowsDiskSignature = 0x0;
int iRet = 0; int iRet = 0;
nls_init(); nls_init();
if(parse_switches(argc, argv, &iBr, &bForce, &bPrintVersion, if(parse_switches(argc, argv, &iBr, &bForce, &bPrintVersion,
&bKeepLabel, &bWritePartitionInfo, &iHeads)) &bKeepLabel, &bWritePartitionInfo, &iHeads,
&szOemId,
&bWriteWindowsDiskSignature, &tWindowsDiskSignature))
{ {
print_help(argv[0]); print_help(argv[0]);
return 0; return 0;
} }
if(bPrintVersion) if(bPrintVersion)
{ {
print_version(); print_version();
if(argc < 3) if(argc < 3)
return 0; return 0;
} }
fp=fopen(argv[argc-1], (iBr || bWritePartitionInfo) ? "r+b" : "rb"); fp=fopen(argv[argc-1],
(iBr || bWritePartitionInfo || szOemId || bWriteWindowsDiskSignature)
?
"r+b" : "rb");
if(!fp) if(!fp)
{ {
printf(_("Unable to open %s, %s\n"), argv[argc-1], strerror(errno)); printf(_("Unable to open %s, %s\n"), argv[argc-1], strerror(errno));
return 1; return 1;
} }
if(iBr == AUTO_BR) if(iBr == AUTO_BR)
{ {
iBr = smart_select(fp); iBr = smart_select(fp);
if(!iBr) if(!iBr)
printf(_("Unable to automaticly select boot record for %s\n"), printf(_("Unable to automaticly select boot record for %s\n"),
argv[argc-1]); argv[argc-1]);
} }
if(iBr && !bForce) if(iBr && !bForce)
{ {
if( ! sanity_check(fp, argv[argc-1], iBr, 1) ) if( ! sanity_check(fp, argv[argc-1], iBr, 1) )
{ {
fclose(fp); fclose(fp);
return 1; return 1;
} }
} }
if(szOemId && !bForce)
{
if( ! ok_to_write_oem_id(fp, argv[argc-1], 1) )
{
fclose(fp);
return 1;
}
}
if(bWriteWindowsDiskSignature && !bForce)
{
if( ! sanity_check(fp, argv[argc-1], MBR_ZERO, 1) )
{
fclose(fp);
return 1;
}
}
if( bWritePartitionInfo ) if( bWritePartitionInfo )
{ {
if( !iBr && !bForce) if( !iBr && !bForce)
{ {
if( ! sanity_check(fp, argv[argc-1], FAT32_BR, 1) ) if( ! sanity_check(fp, argv[argc-1], FAT32_BR, 1) )
{ {
fclose(fp); fclose(fp);
return 1; return 1;
} }
} }
if( write_partition_start_sector_number(fp) ) if( write_partition_start_sector_number(fp) )
{ {
printf(_("Start sector %ld (nr of hidden sectors) successfully written t o %s\n"), printf(_("Start sector %ld (nr of hidden sectors) successfully written t o %s\n"),
partition_start_sector(fp), partition_start_sector(fp),
argv[argc-1]); argv[argc-1]);
if( write_partition_physical_disk_drive_id(fp) ) if( write_partition_physical_disk_drive_id_fat32(fp) )
{ {
printf(_("Physical disk drive id 0x80 (C:) successfully written to %s \n"), printf(_("Physical disk drive id 0x80 (C:) successfully written to %s \n"),
argv[argc-1]); argv[argc-1]);
if( write_partition_number_of_heads(fp, iHeads)) if( write_partition_number_of_heads(fp, iHeads))
{ {
printf(_("Number of heads (%d) successfully written to %s\n"), printf(_("Number of heads (%d) successfully written to %s\n"),
iHeads != -1 ? iHeads : partition_number_of_heads(fp), iHeads != -1 ? iHeads : partition_number_of_heads(fp),
argv[argc-1]); argv[argc-1]);
} }
else else
skipping to change at line 139 skipping to change at line 162
printf(_("Failed writing start sector to %s, this is only possible to do with\n"), printf(_("Failed writing start sector to %s, this is only possible to do with\n"),
argv[argc-1]); argv[argc-1]);
printf(_("real partitions!\n")); printf(_("real partitions!\n"));
iRet = 1; iRet = 1;
} }
} }
switch(iBr) switch(iBr)
{ {
case NO_WRITING: case NO_WRITING:
{ {
if( ! bWritePartitionInfo ) if( (!bWritePartitionInfo) && (!szOemId) && (!bWriteWindowsDiskSignature ) )
{ {
diagnose(fp, argv[argc-1]); diagnose(fp, argv[argc-1]);
} }
break; break;
} }
case MBR_WIN7: case MBR_WIN7:
{ {
if(write_win7_mbr(fp)) if(write_win7_mbr(fp))
printf(_("Windows 7 master boot record successfully written to %s\n" ), printf(_("Windows 7 master boot record successfully written to %s\n" ),
argv[argc-1]); argv[argc-1]);
skipping to change at line 217 skipping to change at line 240
} }
} }
break; break;
case MBR_SYSLINUX: case MBR_SYSLINUX:
{ {
if(write_syslinux_mbr(fp)) if(write_syslinux_mbr(fp))
printf(_("Syslinux master boot record successfully written to %s\n"), printf(_("Syslinux master boot record successfully written to %s\n"),
argv[argc-1]); argv[argc-1]);
else else
{ {
printf(_("Failed writing syslinux master boot record to %s\n"), printf(_("Failed writing Syslinux master boot record to %s\n"),
argv[argc-1]); argv[argc-1]);
iRet = 1; iRet = 1;
} }
} }
break; break;
case MBR_GPT_SYSLINUX: case MBR_GPT_SYSLINUX:
{ {
if(write_syslinux_gpt_mbr(fp)) if(write_syslinux_gpt_mbr(fp))
printf(_("Syslinux GPT master boot record successfully written to %s\ n"), printf(_("Syslinux GPT master boot record successfully written to %s\ n"),
argv[argc-1]); argv[argc-1]);
else else
{ {
printf(_("Failed writing syslinux GPT master boot record to %s\n"), printf(_("Failed writing Syslinux GPT master boot record to %s\n"),
argv[argc-1]);
iRet = 1;
}
}
break;
case MBR_RUFUS:
{
if(write_rufus_mbr(fp))
printf(_("Rufus master boot record successfully written to %s\n"),
argv[argc-1]);
else
{
printf(_("Failed writing Rufus master boot record to %s\n"),
argv[argc-1]);
iRet = 1;
}
}
break;
case MBR_REACTOS:
{
if(write_reactos_mbr(fp))
printf(_("ReactOS master boot record successfully written to %s\n"),
argv[argc-1]);
else
{
printf(_("Failed writing ReactOS master boot record to %s\n"),
argv[argc-1]);
iRet = 1;
}
}
break;
case MBR_KOLIBRIOS:
{
if(write_kolibrios_mbr(fp))
printf(_("KolibriOS master boot record successfully written to %s\n")
,
argv[argc-1]);
else
{
printf(_("Failed writing KolibriOS master boot record to %s\n"),
argv[argc-1]);
iRet = 1;
}
}
break;
case MBR_GRUB4DOS:
{
if(write_grub4dos_mbr(fp))
printf(_("Grub4DOS master boot record successfully written to %s\n"),
argv[argc-1]);
else
{
printf(_("Failed writing Grub4DOS master boot record to %s\n"),
argv[argc-1]);
iRet = 1;
}
}
break;
case MBR_GRUB2:
{
if(write_grub2_mbr(fp))
printf(_("GRUB 2 master boot record successfully written to %s\n"),
argv[argc-1]);
else
{
printf(_("Failed writing GRUB2 master boot record to %s\n"),
argv[argc-1]); argv[argc-1]);
iRet = 1; iRet = 1;
} }
} }
break; break;
case MBR_ZERO: case MBR_ZERO:
{ {
if(write_zero_mbr(fp)) if(write_zero_mbr(fp))
printf(_("Empty (zeroed) master boot record successfully written to % s\n"), printf(_("Empty (zeroed) master boot record successfully written to % s\n"),
argv[argc-1]); argv[argc-1]);
skipping to change at line 288 skipping to change at line 376
printf(_("FAT16 FreeDOS boot record successfully written to %s\n"), printf(_("FAT16 FreeDOS boot record successfully written to %s\n"),
argv[argc-1]); argv[argc-1]);
else else
{ {
printf(_("Failed writing FAT16 FreeDOS boot record to %s\n"), printf(_("Failed writing FAT16 FreeDOS boot record to %s\n"),
argv[argc-1]); argv[argc-1]);
iRet = 1; iRet = 1;
} }
} }
break; break;
case FAT16ROS_BR:
{
if(write_fat_16_ros_br(fp, bKeepLabel))
printf(_("FAT16 ReactOS boot record successfully written to %s\n"),
argv[argc-1]);
else
{
printf(_("Failed writing FAT16 ReactOS boot record to %s\n"),
argv[argc-1]);
iRet = 1;
}
}
break;
case FAT32NT_BR: case FAT32NT_BR:
{ {
if(write_fat_32_nt_br(fp, bKeepLabel)) if(write_fat_32_nt_br(fp, bKeepLabel))
printf(_("FAT32 NT boot record successfully written to %s\n"), printf(_("FAT32 NT boot record successfully written to %s\n"),
argv[argc-1]); argv[argc-1]);
else else
{ {
printf(_("Failed writing FAT32 NT boot record to %s\n"), printf(_("Failed writing FAT32 NT boot record to %s\n"),
argv[argc-1]); argv[argc-1]);
iRet = 1; iRet = 1;
skipping to change at line 327 skipping to change at line 428
printf(_("FAT32 FreeDOS boot record successfully written to %s\n"), printf(_("FAT32 FreeDOS boot record successfully written to %s\n"),
argv[argc-1]); argv[argc-1]);
else else
{ {
printf(_("Failed writing FAT32 FreeDOS boot record to %s\n"), printf(_("Failed writing FAT32 FreeDOS boot record to %s\n"),
argv[argc-1]); argv[argc-1]);
iRet = 1; iRet = 1;
} }
} }
break; break;
case FAT32KOS_BR:
{
if(write_fat_32_kos_br(fp, bKeepLabel))
printf(
_("FAT32 KolibriOS boot record successfully written to %s\n"),
argv[argc-1]);
else
{
printf(_("Failed writing FAT32 KolibriOS boot record to %s\n"),
argv[argc-1]);
iRet = 1;
}
}
break;
case FAT32ROS_BR:
{
if(write_fat_32_ros_br(fp, bKeepLabel))
printf(_("FAT32 ReactOS boot record successfully written to %s\n"),
argv[argc-1]);
else
{
printf(_("Failed writing FAT32 ReactOS boot record to %s\n"),
argv[argc-1]);
iRet = 1;
}
}
break;
case FAT32_BR: case FAT32_BR:
{ {
if(write_fat_32_br(fp, bKeepLabel)) if(write_fat_32_br(fp, bKeepLabel))
printf(_("FAT32 DOS boot record successfully written to %s\n"), printf(_("FAT32 DOS boot record successfully written to %s\n"),
argv[argc-1]); argv[argc-1]);
else else
{ {
printf(_("Failed writing FAT32 DOS boot record to %s\n"), printf(_("Failed writing FAT32 DOS boot record to %s\n"),
argv[argc-1]); argv[argc-1]);
iRet = 1; iRet = 1;
skipping to change at line 359 skipping to change at line 487
iRet = 1; iRet = 1;
} }
} }
break; break;
default: default:
{ {
printf(_("Whoops, internal error, unknown boot record\n")); printf(_("Whoops, internal error, unknown boot record\n"));
} }
break; break;
} }
if(szOemId)
{
if(write_oem_id(fp, szOemId))
printf(_("OEM ID '%s' successfully written to %s\n"),
szOemId, argv[argc-1]);
else
{
printf(_("Failed writing OEM ID to %s\n"),
argv[argc-1]);
iRet = 1;
}
}
if(bWriteWindowsDiskSignature)
{
if(write_windows_disk_signature(fp, tWindowsDiskSignature))
printf(_("Windows Disk Signature 0x%08x successfully written to %s\n"),
tWindowsDiskSignature, argv[argc-1]);
else
{
printf(_("Failed writing Windows Disk Signature to %s\n"),
argv[argc-1]);
iRet = 1;
}
}
fclose(fp); fclose(fp);
return iRet; return iRet;
} /* main */ } /* main */
void print_help(const char *szCommand) void print_help(const char *szCommand)
{ {
printf(_("Usage:\n\t%s [options] [device]\nOptions:\n"), szCommand); printf(_("Usage:\n\t%s [options] [device]\nOptions:\n"), szCommand);
printf( printf(
_(" -1, --fat12 Write a FAT12 floppy boot record to device\n")); _(" -1, --fat12 Write a FAT12 floppy boot record to device\n"));
printf( printf(
_(" -2, --fat32nt Write a FAT32 partition NT boot record to device\n") ); _(" -2, --fat32nt Write a FAT32 partition NT boot record to device\n" ));
printf( printf(
_(" -e, --fat32pe Write a FAT32 partition PE boot record to device\n") ); _(" -e, --fat32pe Write a FAT32 partition PE boot record to device\n" ));
printf( printf(
_(" -3, --fat32 Write a FAT32 partition DOS boot record to device\n" )); _(" -3, --fat32 Write a FAT32 partition DOS boot record to device\n "));
printf( printf(
_(" -4, --fat32free Write a FAT32 partition FreeDOS boot record to devic e\n")); _(" -4, --fat32free Write a FAT32 partition FreeDOS boot record to devi ce\n"));
printf( printf(
_(" -5, --fat16free Write a FAT16 partition FreeDOS boot record to devic e\n")); _(" -5, --fat16free Write a FAT16 partition FreeDOS boot record to devi ce\n"));
printf( printf(
_(" -6, --fat16 Write a FAT16 partition DOS boot record to device\n" )); _(" -6, --fat16 Write a FAT16 partition DOS boot record to device\n "));
printf( printf(
_(" -n, --ntfs Write a NTFS partition Windows 7 boot record to devi _(" -n, --ntfs Write a NTFS partition Windows 7 boot record to dev
ce\n")); ice\n"));
printf(
_(" -o, --fat16ros Write a FAT16 partition ReactOS boot record to devi
ce\n"));
printf(
_(" -c, --fat32ros Write a FAT32 partition ReactOS boot record to devi
ce\n"));
printf(
_(" -q, --fat32kos Write a FAT32 partition KolibriOS boot record to de
vice\n"));
printf( printf(
_(" -l, --wipelabel Reset partition disk label in boot record\n")); _(" -l, --wipelabel Reset partition disk label in boot record\n"));
printf( printf(
_(" -p, --partition Write partition info (hidden sectors, heads and dri ve id)\n")); _(" -p, --partition Write partition info (hidden sectors, heads and dri ve id)\n"));
printf( printf(
_(" to boot record\n")); _(" to boot record\n"));
printf( printf(
_(" -H, --heads <n> Manually set number of heads if partition info is w ritten\n")); _(" -H, --heads <n> Manually set number of heads if partition info is w ritten\n"));
printf( printf(
_(" -B, --bps <n> Manually set number of bytes per sector (default 51
2)\n"));
printf(
_(" -O, --writeoem <s> Write OEM ID string <s> to file system\n"));
printf(
_(" -S, --writewds <x> Write Windows Disk Signature hexadecimal <x> t
o MBR\n"));
printf(
_(" -7, --mbr7 Write a Windows 7 MBR to device\n")); _(" -7, --mbr7 Write a Windows 7 MBR to device\n"));
printf( printf(
_(" -i, --mbrvista Write a Windows Vista MBR to device\n")); _(" -i, --mbrvista Write a Windows Vista MBR to device\n"));
printf( printf(
_(" -m, --mbr Write a Windows 2000/XP/2003 MBR to device\n")); _(" -m, --mbr Write a Windows 2000/XP/2003 MBR to device\n"));
printf( printf(
_(" -9, --mbr95b Write a Windows 95B/98/98SE/ME MBR to device\n")); _(" -9, --mbr95b Write a Windows 95B/98/98SE/ME MBR to device\n"));
printf( printf(
_(" -d, --mbrdos Write a DOS/Windows NT MBR to device\n")); _(" -d, --mbrdos Write a DOS/Windows NT MBR to device\n"));
printf( printf(
_(" -s, --mbrsyslinux Write a syslinux MBR to device\n")); _(" -s, --mbrsyslinux Write a Syslinux MBR to device\n"));
printf(
_(" -t, --mbrgptsyslinux Write a Syslinux GPT MBR to device\n"));
printf(
_(" -a, --mbrreactos Write a ReactOS MBR to device\n"));
printf(
_(" -k, --mbrkolibrios Write a KolibriOS MBR to device\n"));
printf(
_(" -r, --mbrrufus Write a Rufus MBR to device\n"));
printf(
_(" -g, --mbrgrub4dos Write a Grub4Dos MBR to device\n"));
printf( printf(
_(" -t, --mbrgptsyslinux Write a syslinux GPT MBR to device\n")); _(" -b, --mbrgrub2 Write a Grub 2 MBR to device\n"));
printf( printf(
_(" -z, --mbrzero Write an empty (zeroed) MBR to device\n")); _(" -z, --mbrzero Write an empty (zeroed) MBR to device\n"));
printf( printf(
_(" -f, --force Force writing of boot record\n")); _(" -f, --force Force writing of boot record\n"));
printf( printf(
_(" -h, --help Display this help and exit\n")); _(" -h, --help Display this help and exit\n"));
printf( printf(
_(" -v, --version Show program version\n")); _(" -v, --version Show program version\n"));
printf( printf(
_(" -w, --write Write automatically selected boot record to device\n\n")) _(" -w, --write Write automatically selected boot record to device\
; n\n"));
printf(_(" Default Inspect current boot record\n\n")); printf(
_(" Default Inspect current boot record\n\n"));
printf( printf(
_("Warning: Writing the wrong kind of boot record to a device might\n")); _("Warning: Writing the wrong kind of boot record to a device might\n"));
printf( printf(
_("destroy partition information or file system!\n\n")); _("destroy partition information or file system!\n\n"));
} /* print_help */ } /* print_help */
void print_version(void) void print_version(void)
{ {
printf(_("ms-sys version %s\n"), VERSION); printf(_("ms-sys version %s\n"), VERSION);
printf(_("Written by Henrik Carlqvist\n\n")); printf(_("Written by Henrik Carlqvist\n\n"));
printf(_("Copyright (C) 2009-2015 Free Software Foundation, Inc.\n")); printf(_("Copyright (C) 2009-2016 Free Software Foundation, Inc.\n"));
printf(_("This is free software; see the source for copying conditions. Ther e is NO\n")); printf(_("This is free software; see the source for copying conditions. Ther e is NO\n"));
printf(_("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n")); printf(_("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"));
} /* print_version */ } /* print_version */
int parse_switches(int argc, char **argv, int *piBr, int parse_switches(int argc, char **argv, int *piBr,
int *pbForce, int *pbPrintVersion, int *pbForce, int *pbPrintVersion, int *pbKeepLabel,
int *pbKeepLabel, int *pbWritePartitionInfo, int *pbWritePartitionInfo, int *piHeads,
int *piHeads) char **pszOemId,
int *pbWriteWindowsDiskSignature,
uint32_t *ptWindowsDiskSignature)
{ {
int bHelp = 0; int bHelp = 0;
int i; int i;
*piBr = NO_WRITING; *piBr = NO_WRITING;
*pbForce = 0; *pbForce = 0;
*pbPrintVersion = 0; *pbPrintVersion = 0;
*pbKeepLabel = 1; *pbKeepLabel = 1;
*pbWritePartitionInfo = 0; *pbWritePartitionInfo = 0;
*piHeads = -1; *piHeads = -1;
*pbWriteWindowsDiskSignature = 0;
*ptWindowsDiskSignature = 0;
if(argc < 2) if(argc < 2)
return 1; return 1;
/* Don't parse the device */ /* Don't parse the device */
argc--; argc--;
if(( ! strcmp("-h", argv[argc])) || if(( ! strcmp("-h", argv[argc])) ||
( ! strcmp("--help", argv[argc]))) ( ! strcmp("--help", argv[argc])))
bHelp = 1; bHelp = 1;
else if(( ! strcmp("-v", argv[argc])) || else if(( ! strcmp("-v", argv[argc])) ||
( ! strcmp("--version", argv[argc]))) ( ! strcmp("--version", argv[argc])))
skipping to change at line 468 skipping to change at line 647
if( ! strcmp("--fat12", argv[argc])) if( ! strcmp("--fat12", argv[argc]))
*piBr = FAT12_BR; *piBr = FAT12_BR;
else if( ! strcmp("--fat32nt", argv[argc])) else if( ! strcmp("--fat32nt", argv[argc]))
*piBr = FAT32NT_BR; *piBr = FAT32NT_BR;
else if( ! strcmp("--fat32pe", argv[argc])) else if( ! strcmp("--fat32pe", argv[argc]))
*piBr = FAT32PE_BR; *piBr = FAT32PE_BR;
else if( ! strcmp("--fat32", argv[argc])) else if( ! strcmp("--fat32", argv[argc]))
*piBr = FAT32_BR; *piBr = FAT32_BR;
else if( ! strcmp("--fat32free", argv[argc])) else if( ! strcmp("--fat32free", argv[argc]))
*piBr = FAT32FD_BR; *piBr = FAT32FD_BR;
else if( ! strcmp("--fat32ros", argv[argc]))
*piBr = FAT32ROS_BR;
else if( ! strcmp("--fat32kos", argv[argc]))
*piBr = FAT32KOS_BR;
else if( ! strcmp("--fat16ros", argv[argc]))
*piBr = FAT16ROS_BR;
else if( ! strcmp("--fat16free", argv[argc])) else if( ! strcmp("--fat16free", argv[argc]))
*piBr = FAT16FD_BR; *piBr = FAT16FD_BR;
else if( ! strcmp("--fat16", argv[argc])) else if( ! strcmp("--fat16", argv[argc]))
*piBr = FAT16_BR; *piBr = FAT16_BR;
else if( ! strcmp("--ntfs", argv[argc])) else if( ! strcmp("--ntfs", argv[argc]))
*piBr = NTFS_BR; *piBr = NTFS_BR;
else if( ! strcmp("--force", argv[argc])) else if( ! strcmp("--force", argv[argc]))
*pbForce = 1; *pbForce = 1;
else if( ! strcmp("--wipelabel", argv[argc])) else if( ! strcmp("--wipelabel", argv[argc]))
*pbKeepLabel = 0; *pbKeepLabel = 0;
else if( ! strcmp("--partition", argv[argc])) else if( ! strcmp("--partition", argv[argc]))
*pbWritePartitionInfo = 1; *pbWritePartitionInfo = 1;
else if( ! strcmp("--mbr7", argv[argc])) else if( ! strcmp("--mbr7", argv[argc]))
*piBr = MBR_WIN7; *piBr = MBR_WIN7;
else if( ! strcmp("--mbrvista", argv[argc])) else if( ! strcmp("--mbrvista", argv[argc]))
*piBr = MBR_VISTA; *piBr = MBR_VISTA;
else if( ! strcmp("--mbr", argv[argc])) else if( ! strcmp("--mbr", argv[argc]))
*piBr = MBR_2000; *piBr = MBR_2000;
else if( ! strcmp("--mbr95b", argv[argc])) else if( ! strcmp("--mbr95b", argv[argc]))
*piBr = MBR_95B; *piBr = MBR_95B;
else if( ! strcmp("--mbrdos", argv[argc])) else if( ! strcmp("--mbrdos", argv[argc]))
*piBr = MBR_DOS; *piBr = MBR_DOS;
else if( ! strcmp("--mbrsyslinux", argv[argc])) else if( ! strcmp("--mbrsyslinux", argv[argc]))
*piBr = MBR_SYSLINUX; *piBr = MBR_SYSLINUX;
else if( ! strcmp("--mbrgptsyslinux", argv[argc])) else if( ! strcmp("--mbrgptsyslinux", argv[argc]))
*piBr = MBR_GPT_SYSLINUX; *piBr = MBR_GPT_SYSLINUX;
else if( ! strcmp("--mbrrufus", argv[argc]))
*piBr = MBR_RUFUS;
else if( ! strcmp("--mbrreactos", argv[argc]))
*piBr = MBR_REACTOS;
else if( ! strcmp("--mbrkolibrios", argv[argc]))
*piBr = MBR_KOLIBRIOS;
else if( ! strcmp("--mbrgrub4dos", argv[argc]))
*piBr = MBR_GRUB4DOS;
else if( ! strcmp("--mbrgrub2", argv[argc]))
*piBr = MBR_GRUB2;
else if( ! strcmp("--mbrzero", argv[argc])) else if( ! strcmp("--mbrzero", argv[argc]))
*piBr = MBR_ZERO; *piBr = MBR_ZERO;
else if( ! strcmp("--write", argv[argc])) else if( ! strcmp("--write", argv[argc]))
*piBr = AUTO_BR; *piBr = AUTO_BR;
else if( ! strcmp("--version", argv[argc])) else if( ! strcmp("--version", argv[argc]))
*pbPrintVersion = 1; *pbPrintVersion = 1;
else if( (argv[argc][0] == '-') && (argv[argc][1] != '-') && !argv[argc][2 ]) else if( (argv[argc][0] == '-') && (argv[argc][1] != '-') && !argv[argc][2 ])
{ {
for(i=1; argv[argc][i]; i++) for(i=1; argv[argc][i]; i++)
{ {
switch(argv[argc][i]) switch(argv[argc][i])
{ {
case 'a':
*piBr = MBR_REACTOS;
break;
case '1': case '1':
*piBr = FAT12_BR; *piBr = FAT12_BR;
break; break;
case '2': case '2':
*piBr = FAT32NT_BR; *piBr = FAT32NT_BR;
break; break;
case 'e': case 'e':
*piBr = FAT32PE_BR; *piBr = FAT32PE_BR;
break; break;
case '3': case '3':
skipping to change at line 527 skipping to change at line 725
break; break;
case '4': case '4':
*piBr = FAT32FD_BR; *piBr = FAT32FD_BR;
break; break;
case '5': case '5':
*piBr = FAT16FD_BR; *piBr = FAT16FD_BR;
break; break;
case '6': case '6':
*piBr = FAT16_BR; *piBr = FAT16_BR;
break; break;
case 'o':
*piBr = FAT16ROS_BR;
break;
case 'c':
*piBr = FAT32ROS_BR;
break;
case 'q':
*piBr = FAT32KOS_BR;
break;
case 'n': case 'n':
*piBr = NTFS_BR; *piBr = NTFS_BR;
break; break;
case 'f': case 'f':
*pbForce = 1; *pbForce = 1;
break; break;
case 'l': case 'l':
*pbKeepLabel = 0; *pbKeepLabel = 0;
break; break;
case 'p': case 'p':
*pbWritePartitionInfo = 1; *pbWritePartitionInfo = 1;
break; break;
case '7': case '7':
*piBr = MBR_WIN7; *piBr = MBR_WIN7;
break; break;
case 'i': case 'i':
*piBr = MBR_VISTA; *piBr = MBR_VISTA;
break; break;
case 'm': case 'm':
*piBr = MBR_2000; *piBr = MBR_2000;
break; break;
case '9': case '9':
*piBr = MBR_95B; *piBr = MBR_95B;
break; break;
case 'd': case 'd':
*piBr = MBR_DOS; *piBr = MBR_DOS;
break; break;
case 'r':
*piBr = MBR_RUFUS;
break;
case 's': case 's':
*piBr = MBR_SYSLINUX; *piBr = MBR_SYSLINUX;
break; break;
case 't': case 't':
*piBr = MBR_GPT_SYSLINUX; *piBr = MBR_GPT_SYSLINUX;
break; break;
case 'g':
*piBr = MBR_GRUB4DOS;
break;
case 'b':
*piBr = MBR_GRUB2;
break;
case 'k':
*piBr = MBR_KOLIBRIOS;
break;
case 'z': case 'z':
*piBr = MBR_ZERO; *piBr = MBR_ZERO;
break; break;
case 'w': case 'w':
*piBr = AUTO_BR; *piBr = AUTO_BR;
break; break;
case 'v': case 'v':
*pbPrintVersion = 1; *pbPrintVersion = 1;
break; break;
default: default:
bHelp=1; bHelp=1;
break; break;
} }
} }
} }
else if((!strcmp("--heads", argv[argc-1]) || !strcmp("-H", argv[argc-1])) && else if((!strcmp("--heads", argv[argc-1]) || !strcmp("-H", argv[argc-1])) &&
isnumber(argv[argc])) isnumber(argv[argc]))
*piHeads = atoi(argv[argc--]); *piHeads = atoi(argv[argc--]);
else if((!strcmp("--bps", argv[argc-1]) || !strcmp("-B", argv[argc-1])) &&
isnumber(argv[argc]))
set_bytes_per_sector(strtoul(argv[argc--], NULL, 0));
else if((!strcmp("--writeoem", argv[argc-1]) || !strcmp("-O", argv[argc-1]
)))
*pszOemId = argv[argc--];
else if((!strcmp("--writewds", argv[argc-1]) || !strcmp("-S", argv[argc-1]
)))
{
*pbWriteWindowsDiskSignature = 1;
*ptWindowsDiskSignature = strtoul(argv[argc--], NULL, 16);
}
else else
bHelp = 1; bHelp = 1;
} }
return bHelp; return bHelp;
} /* parse_switches */ } /* parse_switches */
int isnumber(const char *szString) int isnumber(const char *szString)
{ {
int bRet = (szString && *szString); int bRet = (szString && *szString);
while(bRet && *szString) while(bRet && *szString)
 End of changes. 42 change blocks. 
39 lines changed or deleted 277 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)