\r
if (!EFI_ERROR(Status)) {\r
Handle1 = ConvertShellHandleToEfiFileProtocol(ShellHandle);\r
- //\r
- // chop off the begining part before the file system part...\r
- //\r
- ///@todo BlockIo?\r
- Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid,\r
- &DevicePath,\r
- &Handle);\r
- if (!EFI_ERROR(Status)) {\r
+ if (Handle1 != NULL) {\r
//\r
- // To access as a file system, the file path should only\r
- // contain file path components. Follow the file path nodes\r
- // and find the target file\r
+ // chop off the begining part before the file system part...\r
//\r
- for ( FilePathNode = (FILEPATH_DEVICE_PATH *)DevicePath\r
- ; !IsDevicePathEnd (&FilePathNode->Header)\r
- ; FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header)\r
- ){\r
- SHELL_FREE_NON_NULL(AlignedNode);\r
- AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePathNode), FilePathNode);\r
- //\r
- // For file system access each node should be a file path component\r
- //\r
- if (DevicePathType (&FilePathNode->Header) != MEDIA_DEVICE_PATH ||\r
- DevicePathSubType (&FilePathNode->Header) != MEDIA_FILEPATH_DP\r
- ) {\r
- Status = EFI_UNSUPPORTED;\r
- break;\r
- }\r
-\r
- //\r
- // Open this file path node\r
- //\r
- Handle2 = Handle1;\r
- Handle1 = NULL;\r
-\r
+ ///@todo BlockIo?\r
+ Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid,\r
+ &DevicePath,\r
+ &Handle);\r
+ if (!EFI_ERROR(Status)) {\r
//\r
- // if this is the last node in the DevicePath always create (if that was requested).\r
+ // To access as a file system, the file path should only\r
+ // contain file path components. Follow the file path nodes\r
+ // and find the target file\r
//\r
- if (IsDevicePathEnd ((NextDevicePathNode (&FilePathNode->Header)))) {\r
- Status = Handle2->Open (\r
- Handle2,\r
- &Handle1,\r
- AlignedNode->PathName,\r
- OpenMode,\r
- Attributes\r
- );\r
- } else {\r
-\r
+ for ( FilePathNode = (FILEPATH_DEVICE_PATH *)DevicePath\r
+ ; !IsDevicePathEnd (&FilePathNode->Header)\r
+ ; FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header)\r
+ ){\r
+ SHELL_FREE_NON_NULL(AlignedNode);\r
+ AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePathNode), FilePathNode);\r
//\r
- // This is not the last node and we dont want to 'create' existing\r
- // directory entries...\r
+ // For file system access each node should be a file path component\r
//\r
+ if (DevicePathType (&FilePathNode->Header) != MEDIA_DEVICE_PATH ||\r
+ DevicePathSubType (&FilePathNode->Header) != MEDIA_FILEPATH_DP\r
+ ) {\r
+ Status = EFI_UNSUPPORTED;\r
+ break;\r
+ }\r
\r
//\r
- // open without letting it create\r
- // prevents error on existing files/directories\r
+ // Open this file path node\r
//\r
- Status = Handle2->Open (\r
- Handle2,\r
- &Handle1,\r
- AlignedNode->PathName,\r
- OpenMode &~EFI_FILE_MODE_CREATE,\r
- Attributes\r
- );\r
+ Handle2 = Handle1;\r
+ Handle1 = NULL;\r
+\r
//\r
- // if above failed now open and create the 'item'\r
- // if OpenMode EFI_FILE_MODE_CREATE bit was on (but disabled above)\r
+ // if this is the last node in the DevicePath always create (if that was requested).\r
//\r
- if ((EFI_ERROR (Status)) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)) {\r
+ if (IsDevicePathEnd ((NextDevicePathNode (&FilePathNode->Header)))) {\r
Status = Handle2->Open (\r
Handle2,\r
&Handle1,\r
OpenMode,\r
Attributes\r
);\r
+ } else {\r
+\r
+ //\r
+ // This is not the last node and we dont want to 'create' existing\r
+ // directory entries...\r
+ //\r
+\r
+ //\r
+ // open without letting it create\r
+ // prevents error on existing files/directories\r
+ //\r
+ Status = Handle2->Open (\r
+ Handle2,\r
+ &Handle1,\r
+ AlignedNode->PathName,\r
+ OpenMode &~EFI_FILE_MODE_CREATE,\r
+ Attributes\r
+ );\r
+ //\r
+ // if above failed now open and create the 'item'\r
+ // if OpenMode EFI_FILE_MODE_CREATE bit was on (but disabled above)\r
+ //\r
+ if ((EFI_ERROR (Status)) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)) {\r
+ Status = Handle2->Open (\r
+ Handle2,\r
+ &Handle1,\r
+ AlignedNode->PathName,\r
+ OpenMode,\r
+ Attributes\r
+ );\r
+ }\r
}\r
- }\r
- //\r
- // Close the last node\r
- //\r
- ShellInfoObject.NewEfiShellProtocol->CloseFile (Handle2);\r
+ //\r
+ // Close the last node\r
+ //\r
+ ShellInfoObject.NewEfiShellProtocol->CloseFile (Handle2);\r
\r
- //\r
- // If there's been an error, stop\r
- //\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
- } // for loop\r
+ //\r
+ // If there's been an error, stop\r
+ //\r
+ if (EFI_ERROR (Status)) {\r
+ break;\r
+ }\r
+ } // for loop\r
+ }\r
}\r
}\r
SHELL_FREE_NON_NULL(AlignedNode);\r
ShellInfoNode->FullName = NewFullName;\r
}\r
}\r
- if (Directory && !EFI_ERROR(Status)){\r
+ if (Directory && !EFI_ERROR(Status) && ShellInfoNode->FullName != NULL && ShellInfoNode->FileName != NULL){\r
//\r
// should be a directory\r
//\r
//\r
//\r
//\r
- ASSERT_EFI_ERROR(Status);\r
if (EFI_ERROR(Status)) {\r
break;\r
}\r
return (Status);\r
}\r
\r
- //\r
- // Get the map name(s) for each one.\r
- //\r
- for ( LoopVar = 0\r
- ; LoopVar < BufferSize / sizeof(EFI_HANDLE)\r
- ; LoopVar ++\r
- ){\r
- if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {\r
- Deleted = TRUE;\r
+ if (HandleBuffer != NULL) {\r
+ //\r
+ // Get the map name(s) for each one.\r
+ //\r
+ for ( LoopVar = 0\r
+ ; LoopVar < BufferSize / sizeof(EFI_HANDLE)\r
+ ; LoopVar ++\r
+ ){\r
+ if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {\r
+ Deleted = TRUE;\r
+ }\r
}\r
}\r
-\r
//\r
// Look up all BlockIo in the platform\r
//\r
return (Status);\r
}\r
\r
- //\r
- // Get the map name(s) for each one.\r
- //\r
- for ( LoopVar = 0\r
- ; LoopVar < BufferSize / sizeof(EFI_HANDLE)\r
- ; LoopVar ++\r
- ){\r
+ if (HandleBuffer != NULL) {\r
//\r
- // Skip any that were already done...\r
+ // Get the map name(s) for each one.\r
//\r
- if (gBS->OpenProtocol(\r
- HandleBuffer[LoopVar],\r
- &gEfiDevicePathProtocolGuid,\r
- NULL,\r
- gImageHandle,\r
- NULL,\r
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL) == EFI_SUCCESS) {\r
- continue;\r
- }\r
- if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {\r
- Deleted = TRUE;\r
+ for ( LoopVar = 0\r
+ ; LoopVar < BufferSize / sizeof(EFI_HANDLE)\r
+ ; LoopVar ++\r
+ ){\r
+ //\r
+ // Skip any that were already done...\r
+ //\r
+ if (gBS->OpenProtocol(\r
+ HandleBuffer[LoopVar],\r
+ &gEfiDevicePathProtocolGuid,\r
+ NULL,\r
+ gImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL) == EFI_SUCCESS) {\r
+ continue;\r
+ }\r
+ if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {\r
+ Deleted = TRUE;\r
+ }\r
}\r
}\r
- FreePool(HandleBuffer);\r
+ SHELL_FREE_NON_NULL(HandleBuffer);\r
if (!Deleted) {\r
return (EFI_NOT_FOUND);\r
}\r