[FREELDR]: Small code style fixes; add a comment about the extra PXE check case in PcDiskGetBootPath. Fix also its return value.

svn path=/trunk/; revision=65973
This commit is contained in:
Hermès Bélusca-Maïto 2015-01-04 16:43:42 +00:00
parent 6c0accfe86
commit 7e2cc1475e
2 changed files with 32 additions and 14 deletions

View file

@ -389,12 +389,19 @@ PcDiskGetCacheableBlockCount(UCHAR DriveNumber)
BOOLEAN BOOLEAN
PcDiskGetBootPath(char *BootPath, unsigned Size) PcDiskGetBootPath(char *BootPath, unsigned Size)
{ {
if (PxeInit()) // FIXME: Keep it there, or put it in DiskGetBootPath?
// Or, abstract the notion of network booting to make
// sense for other platforms than the PC (and this idea
// already exists), then we would need to check whether
// we were booting from network (and: PC --> PXE, etc...)
// and if so, set the correct ARC path. But then this new
// logic could be moved back to DiskGetBootPath...
if (PxeInit())
{ {
strcpy(BootPath, "net(0)"); strcpy(BootPath, "net(0)");
return 0; return TRUE;
} }
return DiskGetBootPath(BootPath, Size); return DiskGetBootPath(BootPath, Size);
} }
/* EOF */ /* EOF */

View file

@ -102,10 +102,7 @@ BOOLEAN FsReadFile(PFILE FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID
// //
// Check for success // Check for success
// //
if (ret == ESUCCESS) return (ret == ESUCCESS);
return TRUE;
else
return FALSE;
} }
ULONG FsGetFileSize(PFILE FileHandle) ULONG FsGetFileSize(PFILE FileHandle)
@ -156,10 +153,10 @@ VOID FsSetFilePointer(PFILE FileHandle, ULONG NewFilePointer)
*/ */
ULONG FsGetNumPathParts(PCSTR Path) ULONG FsGetNumPathParts(PCSTR Path)
{ {
size_t i; size_t i;
ULONG num; ULONG num;
for (i=0,num=0; i<strlen(Path); i++) for (i = 0, num = 0; i < strlen(Path); i++)
{ {
if ((Path[i] == '\\') || (Path[i] == '/')) if ((Path[i] == '\\') || (Path[i] == '/'))
{ {
@ -181,12 +178,12 @@ ULONG FsGetNumPathParts(PCSTR Path)
*/ */
VOID FsGetFirstNameFromPath(PCHAR Buffer, PCSTR Path) VOID FsGetFirstNameFromPath(PCHAR Buffer, PCSTR Path)
{ {
size_t i; size_t i;
// Copy all the characters up to the end of the // Copy all the characters up to the end of the
// string or until we hit a '\' character // string or until we hit a '\' character
// and put them in Buffer // and put them in Buffer
for (i=0; i<strlen(Path); i++) for (i = 0; i < strlen(Path); i++)
{ {
if ((Path[i] == '\\') || (Path[i] == '/')) if ((Path[i] == '\\') || (Path[i] == '/'))
{ {
@ -276,8 +273,10 @@ ARC_STATUS ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
/* Count number of "()", which needs to be replaced by "(0)" */ /* Count number of "()", which needs to be replaced by "(0)" */
Count = 0; Count = 0;
for (p = Path; p != FileName; p++) for (p = Path; p != FileName; p++)
{
if (*p == '(' && *(p + 1) == ')') if (*p == '(' && *(p + 1) == ')')
Count++; Count++;
}
/* Duplicate device name, and replace "()" by "(0)" (if required) */ /* Duplicate device name, and replace "()" by "(0)" (if required) */
Length = FileName - Path + Count; Length = FileName - Path + Count;
@ -294,14 +293,17 @@ ARC_STATUS ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
} }
} }
else else
{
DeviceName = Path; DeviceName = Path;
}
/* Search for the device */ /* Search for the device */
pEntry = DeviceListHead.Flink;
if (OpenMode == OpenReadOnly || OpenMode == OpenWriteOnly) if (OpenMode == OpenReadOnly || OpenMode == OpenWriteOnly)
DeviceOpenMode = OpenMode; DeviceOpenMode = OpenMode;
else else
DeviceOpenMode = OpenReadWrite; DeviceOpenMode = OpenReadWrite;
pEntry = DeviceListHead.Flink;
while (pEntry != &DeviceListHead) while (pEntry != &DeviceListHead)
{ {
pDevice = CONTAINING_RECORD(pEntry, DEVICE, ListEntry); pDevice = CONTAINING_RECORD(pEntry, DEVICE, ListEntry);
@ -312,10 +314,13 @@ ARC_STATUS ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
{ {
/* Search some room for the device */ /* Search some room for the device */
for (DeviceId = 0; DeviceId < MAX_FDS; DeviceId++) for (DeviceId = 0; DeviceId < MAX_FDS; DeviceId++)
{
if (!FileData[DeviceId].FuncTable) if (!FileData[DeviceId].FuncTable)
break; break;
}
if (DeviceId == MAX_FDS) if (DeviceId == MAX_FDS)
return EMFILE; return EMFILE;
/* Try to open the device */ /* Try to open the device */
FileData[DeviceId].FuncTable = pDevice->FuncTable; FileData[DeviceId].FuncTable = pDevice->FuncTable;
ret = pDevice->FuncTable->Open(pDevice->Prefix, DeviceOpenMode, &DeviceId); ret = pDevice->FuncTable->Open(pDevice->Prefix, DeviceOpenMode, &DeviceId);
@ -376,8 +381,10 @@ ARC_STATUS ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
/* Search some room for the device */ /* Search some room for the device */
for (i = 0; i < MAX_FDS; i++) for (i = 0; i < MAX_FDS; i++)
{
if (!FileData[i].FuncTable) if (!FileData[i].FuncTable)
break; break;
}
if (i == MAX_FDS) if (i == MAX_FDS)
return EMFILE; return EMFILE;
@ -468,4 +475,8 @@ VOID FsInit(VOID)
FileData[i].DeviceId = (ULONG)-1; FileData[i].DeviceId = (ULONG)-1;
InitializeListHead(&DeviceListHead); InitializeListHead(&DeviceListHead);
// FIXME: Retrieve the current boot device with MachDiskGetBootPath
// and store it somewhere in order to not call again and again this
// function.
} }