X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkUnixPkg%2FDxe%2FUnixThunk%2FBus%2FBlockIo%2FUnixBlockIo.c;h=1425531cf8986dea46c87deff0d9586c1947ad96;hp=81dd20661b8430b56a2e265fe2e3fc2e1375aee2;hb=caea5554abdc29d7774bdd0ec4852be09d5a1630;hpb=61fb1657e5b2b37a2ec5c879f6fa7689100f0d54 diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c index 81dd20661b..1425531cf8 100644 --- a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c +++ b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c @@ -60,8 +60,8 @@ Abstract: --*/ -#include -#include +#include +#include #include "UnixBlockIo.h" // @@ -318,7 +318,7 @@ EFI_DRIVER_BINDING_PROTOCOL gUnixBlockIoDriverBinding = { UnixBlockIoDriverBindingSupported, UnixBlockIoDriverBindingStart, UnixBlockIoDriverBindingStop, - 0x10, + 0xa, NULL, NULL }; @@ -372,7 +372,7 @@ Returns: // // Check the GUID to see if this is a handle type the driver supports // - if (CompareGuid (UnixIo->TypeGuid, &gEfiUnixVirtualDisksGuid) ) { + if (CompareGuid (UnixIo->TypeGuid, &gEfiUnixVirtualDisksGuid) ) { Status = EFI_SUCCESS; } } @@ -420,7 +420,7 @@ Returns: BOOLEAN WriteProtected; UINTN NumberOfBlocks; UINTN BlockSize; - INTN i; + INTN i; // // Grab the protocols we need @@ -446,47 +446,47 @@ Returns: } Status = EFI_NOT_FOUND; - // Extract filename. + // Extract filename. Str = UnixIo->EnvString; - i = 0; - while (*Str && *Str != ':') - Buffer[i++] = *Str++; - Buffer[i] = 0; + i = 0; + while (*Str && *Str != ':') + Buffer[i++] = *Str++; + Buffer[i] = 0; if (*Str != ':') { goto Done; } Str++; - RemovableMedia = FALSE; - WriteProtected = TRUE; - NumberOfBlocks = 0; - BlockSize = 512; - do { + RemovableMedia = FALSE; + WriteProtected = TRUE; + NumberOfBlocks = 0; + BlockSize = 512; + do { if (*Str == 'R' || *Str == 'F') { RemovableMedia = (BOOLEAN) (*Str == 'R'); Str++; - } + } if (*Str == 'O' || *Str == 'W') { WriteProtected = (BOOLEAN) (*Str == 'O'); - Str++; - } - if (*Str == 0) - break; - if (*Str != ';') - goto Done; - Str++; - + Str++; + } + if (*Str == 0) + break; + if (*Str != ';') + goto Done; + Str++; + NumberOfBlocks = Atoi (Str); Str = GetNextElementPastTerminator (Str, ';'); - if (NumberOfBlocks == 0) - break; - + if (NumberOfBlocks == 0) + break; + BlockSize = Atoi (Str); - if (BlockSize != 0) + if (BlockSize != 0) Str = GetNextElementPastTerminator (Str, ';'); - } while (0); - + } while (0); + // // If we get here the variable is valid so do the work. // @@ -693,10 +693,10 @@ Returns: Private->Filename[Index] = 0; - Private->Mode = (ReadOnly ? O_RDONLY : O_RDWR); + Private->Mode = (ReadOnly ? O_RDONLY : O_RDWR); Private->NumberOfBlocks = NumberOfBlocks; - Private->fd = -1; + Private->fd = -1; Private->ControllerNameTable = NULL; @@ -780,19 +780,19 @@ Returns: // // If the device is already opened, close it // - if (Private->fd >= 0) { + if (Private->fd >= 0) { BlockIo->Reset (BlockIo, FALSE); } // // Open the device // - Private->fd = Private->UnixThunk->Open - (Private->Filename, Private->Mode, 0644); + Private->fd = Private->UnixThunk->Open + (Private->Filename, Private->Mode, 0644); - if (Private->fd < 0) { - DEBUG ((EFI_D_INFO, "PlOpenBlock: Could not open %s\n", - Private->Filename)); + if (Private->fd < 0) { + DEBUG ((EFI_D_INFO, "PlOpenBlock: Could not open %s\n", + Private->Filename)); BlockIo->Media->MediaPresent = FALSE; Status = EFI_NO_MEDIA; goto Done; @@ -834,12 +834,12 @@ Returns: // // first set it to 0 // - Private->UnixThunk->FTruncate (Private->fd, 0); + Private->UnixThunk->FTruncate (Private->fd, 0); // // then set it to the needed file size (OS will zero fill it) // - Private->UnixThunk->FTruncate (Private->fd, EndOfFile); + Private->UnixThunk->FTruncate (Private->fd, EndOfFile); } DEBUG ((EFI_D_INIT, "%HPlOpenBlock: opened %s%N\n", Private->Filename)); @@ -878,13 +878,13 @@ Returns: --*/ { return EFI_DEVICE_ERROR; - -#if 0 + +#if 0 EFI_BLOCK_IO_PROTOCOL *BlockIo; EFI_STATUS Status; BOOLEAN ReinstallBlockIoFlag; - + BlockIo = &Private->BlockIo; switch (Private->UnixThunk->GetLastError ()) { @@ -928,7 +928,7 @@ Returns: } return Status; -#endif +#endif } STATIC @@ -1017,7 +1017,7 @@ Returns: // Seek to End of File // DistanceToMove = MultU64x32 (Lba, BlockSize); - Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, SEEK_SET); + Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, SEEK_SET); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_INIT, "WriteBlocks: SetFilePointer failed\n")); @@ -1062,7 +1062,7 @@ UnixBlockIoReadBlocks ( --*/ { UNIX_BLOCK_IO_PRIVATE *Private; - ssize_t len; + ssize_t len; EFI_STATUS Status; Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This); @@ -1072,9 +1072,9 @@ UnixBlockIoReadBlocks ( return Status; } - len = Private->UnixThunk->Read (Private->fd, Buffer, BufferSize); + len = Private->UnixThunk->Read (Private->fd, Buffer, BufferSize); if (len != BufferSize) { - DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed.\n")); + DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed.\n")); return UnixBlockIoError (Private); } @@ -1121,7 +1121,7 @@ UnixBlockIoWriteBlocks ( --*/ { UNIX_BLOCK_IO_PRIVATE *Private; - ssize_t len; + ssize_t len; EFI_STATUS Status; Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This); @@ -1131,9 +1131,9 @@ UnixBlockIoWriteBlocks ( return Status; } - len = Private->UnixThunk->Write (Private->fd, Buffer, BufferSize); + len = Private->UnixThunk->Write (Private->fd, Buffer, BufferSize); if (len != BufferSize) { - DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed.\n")); + DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed.\n")); return UnixBlockIoError (Private); } @@ -1198,7 +1198,7 @@ UnixBlockIoResetBlock ( if (Private->fd >= 0) { Private->UnixThunk->Close (Private->fd); - Private->fd = -1; + Private->fd = -1; } return EFI_SUCCESS; @@ -1272,15 +1272,15 @@ This function extends the capability of SetFilePointer to accept 64 bit paramete // TODO: MoveMethod - add argument and description to function comment { EFI_STATUS Status; - off_t res; + off_t res; - res = Private->UnixThunk->Lseek(Private->fd, DistanceToMove, MoveMethod); - if (res == -1) { + res = Private->UnixThunk->Lseek(Private->fd, DistanceToMove, MoveMethod); + if (res == -1) { Status = EFI_INVALID_PARAMETER; } if (NewFilePointer != NULL) { - *NewFilePointer = res; + *NewFilePointer = res; } return Status;