I did a  simple break apart of a path into map-name and directory.

fs0:\MdeModulePkg

So FileSystem was "fs0:" and Dir was "\MdeModulePkg" and the resulting working 
directory was: "fs0:\\\\MdeModulePkg" (with escape characters)..

It seems the culprit is in EfiShellSetCurDir:

    if (DirectoryName != NULL) {
      //
      // change current dir on that file system
      //

      if (MapListItem->CurrentDirectoryPath != NULL) {
        FreePool(MapListItem->CurrentDirectoryPath);
        DEBUG_CODE(MapListItem->CurrentDirectoryPath = NULL;);
      }
//      ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || 
(MapListItem->CurrentDirectoryPath != NULL));
//      MapListItem->CurrentDirectoryPath = 
StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, FileSystem, 0);
      ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || 
(MapListItem->CurrentDirectoryPath != NULL));
      MapListItem->CurrentDirectoryPath = 
StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
      ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || 
(MapListItem->CurrentDirectoryPath != NULL));
      MapListItem->CurrentDirectoryPath = 
StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
      if (MapListItem->CurrentDirectoryPath != NULL && 
MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] 
== L'\\') {
        ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || 
(MapListItem->CurrentDirectoryPath != NULL));
        
MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] 
= CHAR_NULL;
      }
    }
  }

I checked with the Shell Specification and it doesn't mention this sort of 
pre-pending behavior. It also doesn't allow relative paths, so I would expect 
that all directory names passed in must be in the form \. The only exception to 
this rule seems to be FS0:\

I'm not sure what to do here, because I don't think the current behavior makes 
sense.

Tim



_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to