BaseTools: Clean up source files
1. Do not use tab characters 2. No trailing white space in one line 3. All files must end with CRLF Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
@ -3,15 +3,15 @@ Reading/writing MBR/DBR.
|
||||
NOTE:
|
||||
If we write MBR to disk, we just update the MBR code and the partition table wouldn't be over written.
|
||||
If we process DBR, we will patch MBR to set first partition active if no active partition exists.
|
||||
|
||||
Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
@ -166,16 +166,16 @@ Return:
|
||||
);
|
||||
if (VolumeHandle == INVALID_HANDLE_VALUE) {
|
||||
fprintf (
|
||||
stderr,
|
||||
"error E0005: CreateFile failed: Volume = %s, LastError = 0x%lx\n",
|
||||
VolumeAccessPath,
|
||||
stderr,
|
||||
"error E0005: CreateFile failed: Volume = %s, LastError = 0x%lx\n",
|
||||
VolumeAccessPath,
|
||||
GetLastError ()
|
||||
);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Get Disk Number. It should fail when operating on floppy. That's ok
|
||||
// Get Disk Number. It should fail when operating on floppy. That's ok
|
||||
// because Disk Number is only needed when operating on Hard or USB disk.
|
||||
//
|
||||
// To direct write to disk:
|
||||
@ -183,13 +183,13 @@ Return:
|
||||
// for floppy: use path = \\.\X:, where X can be A or B
|
||||
//
|
||||
Success = DeviceIoControl(
|
||||
VolumeHandle,
|
||||
VolumeHandle,
|
||||
IOCTL_STORAGE_GET_DEVICE_NUMBER,
|
||||
NULL,
|
||||
0,
|
||||
&StorageDeviceNumber,
|
||||
NULL,
|
||||
0,
|
||||
&StorageDeviceNumber,
|
||||
sizeof(StorageDeviceNumber),
|
||||
&BytesReturned,
|
||||
&BytesReturned,
|
||||
NULL
|
||||
);
|
||||
//
|
||||
@ -207,7 +207,7 @@ Return:
|
||||
DriveInfo->DiskNumber = StorageDeviceNumber.DeviceNumber;
|
||||
}
|
||||
CloseHandle(VolumeHandle);
|
||||
|
||||
|
||||
//
|
||||
// Fill in the type string
|
||||
//
|
||||
@ -241,7 +241,7 @@ Routine Description:
|
||||
{
|
||||
UINT Index;
|
||||
DRIVE_INFO DriveInfo;
|
||||
|
||||
|
||||
UINT Mask = GetLogicalDrives();
|
||||
|
||||
for (Index = 0; Index < MAX_DRIVE; Index++) {
|
||||
@ -258,9 +258,9 @@ Routine Description:
|
||||
} else {
|
||||
fprintf (
|
||||
stdout,
|
||||
"%c: - DiskNum: %u, Type: %s\n",
|
||||
"%c: - DiskNum: %u, Type: %s\n",
|
||||
DriveInfo.VolumeLetter,
|
||||
(unsigned) DriveInfo.DiskNumber,
|
||||
(unsigned) DriveInfo.DiskNumber,
|
||||
DriveInfo.DriveType->Description
|
||||
);
|
||||
}
|
||||
@ -301,7 +301,7 @@ Return:
|
||||
|
||||
DbrOffset = 0;
|
||||
HasMbr = FALSE;
|
||||
|
||||
|
||||
SetFilePointer(DiskHandle, 0, NULL, FILE_BEGIN);
|
||||
if (!ReadFile (DiskHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {
|
||||
return -1;
|
||||
@ -359,12 +359,12 @@ Return:
|
||||
}
|
||||
|
||||
/**
|
||||
* Get window file handle for input/ouput disk/file.
|
||||
*
|
||||
* Get window file handle for input/ouput disk/file.
|
||||
*
|
||||
* @param PathInfo
|
||||
* @param ProcessMbr
|
||||
* @param FileHandle
|
||||
*
|
||||
*
|
||||
* @return ERROR_STATUS
|
||||
*/
|
||||
ERROR_STATUS
|
||||
@ -384,11 +384,11 @@ GetFileHandle (
|
||||
|
||||
*FileHandle = CreateFile(
|
||||
PathInfo->PhysicalPath,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OpenFlag,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OpenFlag,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL
|
||||
);
|
||||
if (*FileHandle == INVALID_HANDLE_VALUE) {
|
||||
@ -419,19 +419,19 @@ GetFileHandle (
|
||||
}
|
||||
|
||||
/**
|
||||
Writing or reading boot sector or MBR according to the argument.
|
||||
|
||||
Writing or reading boot sector or MBR according to the argument.
|
||||
|
||||
@param InputInfo PATH_INFO instance for input path
|
||||
@param OutputInfo PATH_INFO instance for output path
|
||||
@param ProcessMbr TRUE is to process MBR, otherwise, processing boot sector
|
||||
|
||||
|
||||
@return ERROR_STATUS
|
||||
**/
|
||||
ERROR_STATUS
|
||||
ProcessBsOrMbr (
|
||||
PATH_INFO *InputInfo,
|
||||
PATH_INFO *OutputInfo,
|
||||
BOOL ProcessMbr
|
||||
BOOL ProcessMbr
|
||||
)
|
||||
{
|
||||
BYTE DiskPartition[0x200] = {0};
|
||||
@ -462,14 +462,14 @@ ProcessBsOrMbr (
|
||||
|
||||
//
|
||||
// Read boot sector from source disk/file
|
||||
//
|
||||
//
|
||||
if (!ReadFile (InputHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {
|
||||
Status = ErrorFileReadWrite;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (InputInfo->Type == PathUsb) {
|
||||
// Manually set BS_DrvNum to 0x80 as window's format.exe has a bug which will clear this field discarding USB disk's MBR.
|
||||
// Manually set BS_DrvNum to 0x80 as window's format.exe has a bug which will clear this field discarding USB disk's MBR.
|
||||
// offset of BS_DrvNum is 0x24 for FAT12/16
|
||||
// 0x40 for FAT32
|
||||
//
|
||||
@ -509,7 +509,7 @@ ProcessBsOrMbr (
|
||||
|
||||
//
|
||||
// Write boot sector to taget disk/file
|
||||
//
|
||||
//
|
||||
if (!WriteFile (OutputHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {
|
||||
Status = ErrorFileReadWrite;
|
||||
goto Done;
|
||||
@ -555,7 +555,7 @@ PrintUsage (
|
||||
)
|
||||
{
|
||||
printf ("Usage: GenBootSector [options] --cfg-file CFG_FILE\n\n\
|
||||
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.\n\n\
|
||||
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.\n\n\
|
||||
Utility to retrieve and update the boot sector or MBR.\n\n\
|
||||
optional arguments:\n\
|
||||
-h, --help Show this help message and exit\n\
|
||||
@ -601,7 +601,7 @@ GetPathInfo (
|
||||
//
|
||||
if (IsLetter(PathInfo->Path[0]) && (PathInfo->Path[1] == ':') && (PathInfo->Path[2] == '\0')) {
|
||||
VolumeLetter = PathInfo->Path[0];
|
||||
if ((VolumeLetter == 'A') || (VolumeLetter == 'a') ||
|
||||
if ((VolumeLetter == 'A') || (VolumeLetter == 'a') ||
|
||||
(VolumeLetter == 'B') || (VolumeLetter == 'b')) {
|
||||
PathInfo->Type = PathFloppy;
|
||||
sprintf (PathInfo->PhysicalPath, FloppyPathTemplate, VolumeLetter);
|
||||
@ -628,8 +628,8 @@ GetPathInfo (
|
||||
return ErrorPath;
|
||||
}
|
||||
|
||||
return ErrorSuccess;
|
||||
}
|
||||
return ErrorSuccess;
|
||||
}
|
||||
|
||||
//
|
||||
// Check the path length
|
||||
@ -660,7 +660,7 @@ GetPathInfo (
|
||||
PathInfo->PhysicalPath[sizeof (PathInfo->PhysicalPath) / sizeof (PathInfo->PhysicalPath[0]) - 1] = 0;
|
||||
|
||||
return ErrorSuccess;
|
||||
}
|
||||
}
|
||||
|
||||
INT
|
||||
main (
|
||||
@ -682,14 +682,14 @@ main (
|
||||
AppName = *argv;
|
||||
argv ++;
|
||||
argc --;
|
||||
|
||||
|
||||
ProcessMbr = FALSE;
|
||||
|
||||
if (argc == 0) {
|
||||
PrintUsage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Parse command line
|
||||
//
|
||||
@ -697,23 +697,23 @@ main (
|
||||
if ((stricmp (argv[Index], "-l") == 0) || (stricmp (argv[Index], "--list") == 0)) {
|
||||
ListDrive ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ((stricmp (argv[Index], "-m") == 0) || (stricmp (argv[Index], "--mbr") == 0)) {
|
||||
ProcessMbr = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ((stricmp (argv[Index], "-i") == 0) || (stricmp (argv[Index], "--input") == 0)) {
|
||||
InputPathInfo.Path = argv[Index + 1];
|
||||
InputPathInfo.Input = TRUE;
|
||||
if (InputPathInfo.Path == NULL) {
|
||||
Error (NULL, 0, 1003, "Invalid option value", "Input file name can't be NULL");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (InputPathInfo.Path[0] == '-') {
|
||||
Error (NULL, 0, 1003, "Invalid option value", "Input file is missing");
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
++Index;
|
||||
continue;
|
||||
@ -725,33 +725,33 @@ main (
|
||||
if (OutputPathInfo.Path == NULL) {
|
||||
Error (NULL, 0, 1003, "Invalid option value", "Output file name can't be NULL");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (OutputPathInfo.Path[0] == '-') {
|
||||
Error (NULL, 0, 1003, "Invalid option value", "Output file is missing");
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
++Index;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ((stricmp (argv[Index], "-h") == 0) || (stricmp (argv[Index], "--help") == 0)) {
|
||||
PrintUsage ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (stricmp (argv[Index], "--version") == 0) {
|
||||
Version ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ((stricmp (argv[Index], "-v") == 0) || (stricmp (argv[Index], "--verbose") == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ((stricmp (argv[Index], "-q") == 0) || (stricmp (argv[Index], "--quiet") == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ((stricmp (argv[Index], "-d") == 0) || (stricmp (argv[Index], "--debug") == 0)) {
|
||||
EfiStatus = AsciiStringToUint64 (argv[Index + 1], FALSE, &LogLevel);
|
||||
if (EFI_ERROR (EfiStatus)) {
|
||||
@ -774,7 +774,7 @@ main (
|
||||
Error (NULL, 0, 1000, "Unknown option", "%s", argv[Index]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (InputPathInfo.Path == NULL) {
|
||||
Error (NULL, 0, 1001, "Missing options", "Input file is missing");
|
||||
return 1;
|
||||
@ -784,7 +784,7 @@ main (
|
||||
Error (NULL, 0, 1001, "Missing options", "Output file is missing");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (GetPathInfo(&InputPathInfo) != ErrorSuccess) {
|
||||
Error (NULL, 0, 1003, "Invalid option value", "Input file can't be found.");
|
||||
return 1;
|
||||
@ -794,7 +794,7 @@ main (
|
||||
Error (NULL, 0, 1003, "Invalid option value", "Output file can't be found.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Process DBR (Patch or Read)
|
||||
//
|
||||
@ -802,19 +802,19 @@ main (
|
||||
|
||||
if (Status == ErrorSuccess) {
|
||||
fprintf (
|
||||
stdout,
|
||||
"%s %s: successful!\n",
|
||||
(OutputPathInfo.Type != PathFile) ? "Write" : "Read",
|
||||
stdout,
|
||||
"%s %s: successful!\n",
|
||||
(OutputPathInfo.Type != PathFile) ? "Write" : "Read",
|
||||
ProcessMbr ? "MBR" : "DBR"
|
||||
);
|
||||
return 0;
|
||||
} else {
|
||||
fprintf (
|
||||
stderr,
|
||||
stderr,
|
||||
"%s: %s %s: failed - %s (LastError: 0x%lx)!\n",
|
||||
(Status == ErrorNoMbr) ? "WARNING" : "ERROR",
|
||||
(OutputPathInfo.Type != PathFile) ? "Write" : "Read",
|
||||
ProcessMbr ? "MBR" : "DBR",
|
||||
(OutputPathInfo.Type != PathFile) ? "Write" : "Read",
|
||||
ProcessMbr ? "MBR" : "DBR",
|
||||
ErrorStatusDesc[Status],
|
||||
GetLastError ()
|
||||
);
|
||||
|
Reference in New Issue
Block a user