]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsDir.c
ArmPlatformPkg/BootMonFs: eliminate deprecated string functions
[mirror_edk2.git] / ArmPlatformPkg / FileSystem / BootMonFs / BootMonFsDir.c
index 835cdae18a3872c4530ebd5f3c54d239ed399721..64ea0ec68048d677ff25e21ea3290428c64f9f4e 100644 (file)
@@ -28,6 +28,8 @@ OpenBootMonFsOpenVolume (
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
+  Instance->RootFile->Info->Attribute = EFI_FILE_READ_ONLY | EFI_FILE_DIRECTORY;\r
+\r
   *Root = &Instance->RootFile->File;\r
 \r
   return EFI_SUCCESS;\r
@@ -114,6 +116,8 @@ BootMonFsOpenDirectory (
 \r
   return EFI_UNSUPPORTED;\r
 }\r
+\r
+STATIC\r
 EFI_STATUS\r
 GetFileSystemVolumeLabelInfo (\r
   IN BOOTMON_FS_INSTANCE *Instance,\r
@@ -178,6 +182,7 @@ ComputeFreeSpace (
   return MediaSize - (FileSizeSum + (Media->BlockSize + NumFiles));\r
 }\r
 \r
+STATIC\r
 EFI_STATUS\r
 GetFilesystemInfo (\r
   IN BOOTMON_FS_INSTANCE *Instance,\r
@@ -199,26 +204,19 @@ GetFilesystemInfo (
   return Status;\r
 }\r
 \r
+STATIC\r
 EFI_STATUS\r
 GetFileInfo (\r
-  IN BOOTMON_FS_INSTANCE *Instance,\r
-  IN BOOTMON_FS_FILE     *File,\r
-  IN OUT UINTN           *BufferSize,\r
-  OUT VOID               *Buffer\r
+  IN BOOTMON_FS_INSTANCE  *Instance,\r
+  IN BOOTMON_FS_FILE      *File,\r
+  IN OUT UINTN            *BufferSize,\r
+  OUT VOID                *Buffer\r
   )\r
 {\r
-  EFI_FILE_INFO   *Info;\r
-  UINTN           ResultSize;\r
-  UINTN           NameSize;\r
-  UINTN           Index;\r
+  EFI_FILE_INFO  *Info;\r
+  UINTN          ResultSize;\r
 \r
-  if (File == Instance->RootFile) {\r
-    NameSize = 0;\r
-    ResultSize = SIZE_OF_EFI_FILE_INFO + sizeof (CHAR16);\r
-  } else {\r
-    NameSize   = AsciiStrLen (File->HwDescription.Footer.Filename) + 1;\r
-    ResultSize = SIZE_OF_EFI_FILE_INFO + (NameSize * sizeof (CHAR16));\r
-  }\r
+  ResultSize = SIZE_OF_EFI_FILE_INFO + StrSize (File->Info->FileName);\r
 \r
   if (*BufferSize < ResultSize) {\r
     *BufferSize = ResultSize;\r
@@ -227,24 +225,10 @@ GetFileInfo (
 \r
   Info = Buffer;\r
 \r
-  // Zero out the structure\r
-  ZeroMem (Info, ResultSize);\r
-\r
-  // Fill in the structure\r
+  CopyMem (Info, File->Info, ResultSize);\r
+  // Size of the information\r
   Info->Size = ResultSize;\r
 \r
-  if (File == Instance->RootFile) {\r
-    Info->Attribute    = EFI_FILE_READ_ONLY | EFI_FILE_DIRECTORY;\r
-    Info->FileName[0]  = L'\0';\r
-  } else {\r
-    Info->FileSize     = BootMonFsGetImageLength (File);\r
-    Info->PhysicalSize = BootMonFsGetPhysicalSize (File);\r
-\r
-    for (Index = 0; Index < NameSize; Index++) {\r
-      Info->FileName[Index] = File->HwDescription.Footer.Filename[Index];\r
-    }\r
-  }\r
-\r
   *BufferSize = ResultSize;\r
 \r
   return EFI_SUCCESS;\r
@@ -297,171 +281,251 @@ GetBootMonFsFileInfo (
   return Status;\r
 }\r
 \r
+/**\r
+  Set the name of a file.\r
+\r
+  This is a helper function for SetFileInfo().\r
+\r
+  @param[in]  Instance  A pointer to the description of the volume\r
+                        the file belongs to.\r
+  @param[in]  File      A pointer to the description of the file.\r
+  @param[in]  FileName  A pointer to the new name of the file.\r
+\r
+  @retval  EFI_SUCCESS        The name was set.\r
+  @retval  EFI_ACCESS_DENIED  An attempt is made to change the name of a file\r
+                              to a file that is already present.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 SetFileName (\r
-  IN  BOOTMON_FS_FILE *File,\r
-  IN  CHAR16          *FileNameUnicode\r
+  IN  BOOTMON_FS_INSTANCE  *Instance,\r
+  IN  BOOTMON_FS_FILE      *File,\r
+  IN  CONST CHAR16         *FileName\r
   )\r
 {\r
-  CHAR8                 *FileNameAscii;\r
-  UINT16                 SavedChar;\r
-  UINTN                  FileNameSize;\r
-  BOOTMON_FS_FILE       *SameFile;\r
-  EFI_STATUS             Status;\r
+  CHAR8            AsciiFileName[MAX_NAME_LENGTH];\r
+  BOOTMON_FS_FILE  *SameFile;\r
 \r
-  // EFI Shell inserts '\' in front of the filename that must be stripped\r
-  if (FileNameUnicode[0] == L'\\') {\r
-    FileNameUnicode++;\r
+  // If the file path start with a \ strip it. The EFI Shell may\r
+  // insert a \ in front of the file name.\r
+  if (FileName[0] == L'\\') {\r
+    FileName++;\r
   }\r
-  //\r
-  // Convert Unicode into Ascii\r
-  //\r
-  SavedChar = L'\0';\r
-  FileNameSize = StrLen (FileNameUnicode) + 1;\r
-  FileNameAscii = AllocatePool (FileNameSize * sizeof (CHAR8));\r
-  if (FileNameAscii == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  // If Unicode string is too long then truncate it.\r
-  if (FileNameSize > MAX_NAME_LENGTH) {\r
-    SavedChar = FileNameUnicode[MAX_NAME_LENGTH - 1];\r
-    FileNameUnicode[MAX_NAME_LENGTH - 1] = L'\0';\r
-  }\r
-  UnicodeStrToAsciiStr (FileNameUnicode, FileNameAscii);\r
-  // If the unicode string was truncated then restore its original content.\r
-  if (SavedChar != L'\0') {\r
-    FileNameUnicode[MAX_NAME_LENGTH - 1] = SavedChar;\r
-  }\r
-\r
-  // If we're changing the file name\r
-  if (AsciiStrCmp (FileNameAscii, File->HwDescription.Footer.Filename) == 0) {\r
-    // No change to filename.\r
-    Status = EFI_SUCCESS;\r
-  } else if (!(File->OpenMode & EFI_FILE_MODE_WRITE)) {\r
-    // You can only change the filename if you open the file for write.\r
-    Status = EFI_ACCESS_DENIED;\r
-  } else if (BootMonGetFileFromAsciiFileName (\r
-                File->Instance,\r
-                File->HwDescription.Footer.Filename,\r
-                &SameFile) != EFI_NOT_FOUND) {\r
+\r
+  UnicodeStrToAsciiStrS (FileName, AsciiFileName, MAX_NAME_LENGTH);\r
+\r
+  if (BootMonGetFileFromAsciiFileName (\r
+        File->Instance,\r
+        AsciiFileName,\r
+        &SameFile\r
+        ) != EFI_NOT_FOUND) {\r
     // A file with that name already exists.\r
-    Status = EFI_ACCESS_DENIED;\r
+    return EFI_ACCESS_DENIED;\r
   } else {\r
     // OK, change the filename.\r
-    AsciiStrCpy (FileNameAscii, File->HwDescription.Footer.Filename);\r
-    Status = EFI_SUCCESS;\r
+    AsciiStrToUnicodeStrS (AsciiFileName, File->Info->FileName,\r
+      (File->Info->Size - SIZE_OF_EFI_FILE_INFO) / sizeof (CHAR16));\r
+    return EFI_SUCCESS;\r
   }\r
-\r
-  FreePool (FileNameAscii);\r
-  return Status;\r
 }\r
 \r
-// Set the file's size (NB "size", not "physical size"). If the change amounts\r
-// to an increase, simply do a write followed by a flush.\r
-// (This is a helper function for SetFileInfo.)\r
+/**\r
+  Set the size of a file.\r
+\r
+  This is a helper function for SetFileInfo().\r
+\r
+  @param[in]  Instance  A pointer to the description of the volume\r
+                        the file belongs to.\r
+  @param[in]  File      A pointer to the description of the file.\r
+  @param[in]  NewSize   The requested new size for the file.\r
+\r
+  @retval  EFI_SUCCESS           The size was set.\r
+  @retval  EFI_OUT_OF_RESOURCES  An allocation needed to process the request failed.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 SetFileSize (\r
-  IN BOOTMON_FS_INSTANCE *Instance,\r
-  IN BOOTMON_FS_FILE     *BootMonFsFile,\r
-  IN UINTN                NewSize\r
+  IN BOOTMON_FS_INSTANCE  *Instance,\r
+  IN BOOTMON_FS_FILE      *BootMonFsFile,\r
+  IN UINTN                 NewSize\r
   )\r
 {\r
-  UINT64             StoredPosition;\r
-  EFI_STATUS         Status;\r
-  EFI_FILE_PROTOCOL *File;\r
-  CHAR8              Buffer;\r
-  UINTN              BufferSize;\r
-  UINT32             OldSize;\r
-\r
-  OldSize = BootMonFsFile->HwDescription.Region[0].Size;\r
-\r
-  if (OldSize == NewSize) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Buffer = 0;\r
-  BufferSize = sizeof (Buffer);\r
+  EFI_STATUS              Status;\r
+  UINT32                  OldSize;\r
+  LIST_ENTRY              *RegionToFlushLink;\r
+  LIST_ENTRY              *NextRegionToFlushLink;\r
+  BOOTMON_FS_FILE_REGION  *Region;\r
+  EFI_FILE_PROTOCOL       *File;\r
+  CHAR8                   *Buffer;\r
+  UINTN                   BufferSize;\r
+  UINT64                  StoredPosition;\r
 \r
-  File = &BootMonFsFile->File;\r
+  OldSize = BootMonFsFile->Info->FileSize;\r
 \r
-  if (!(BootMonFsFile->OpenMode & EFI_FILE_MODE_WRITE)) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
+  //\r
+  // In case of file truncation, force the regions waiting for writing to\r
+  // not overflow the new size of the file.\r
+  //\r
+  if (NewSize < OldSize) {\r
+    for (RegionToFlushLink = GetFirstNode (&BootMonFsFile->RegionToFlushLink);\r
+         !IsNull (&BootMonFsFile->RegionToFlushLink, RegionToFlushLink);\r
+         )\r
+    {\r
+      NextRegionToFlushLink = GetNextNode (&BootMonFsFile->RegionToFlushLink, RegionToFlushLink);\r
+      Region = (BOOTMON_FS_FILE_REGION*)RegionToFlushLink;\r
+      if (Region->Offset > NewSize) {\r
+        RemoveEntryList (RegionToFlushLink);\r
+        FreePool (Region->Buffer);\r
+        FreePool (Region);\r
+      } else {\r
+        Region->Size = MIN (Region->Size, NewSize - Region->Offset);\r
+      }\r
+      RegionToFlushLink = NextRegionToFlushLink;\r
+    }\r
 \r
-  if (NewSize <= OldSize) {\r
-    OldSize = NewSize;\r
-  } else {\r
+  } else if (NewSize > OldSize) {\r
     // Increasing a file's size is potentially complicated as it may require\r
     // moving the image description on media. The simplest way to do it is to\r
     // seek past the end of the file (which is valid in UEFI) and perform a\r
     // Write.\r
+    File = &BootMonFsFile->File;\r
 \r
     // Save position\r
     Status = File->GetPosition (File, &StoredPosition);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
-\r
-    Status = File->SetPosition (File, NewSize - 1);\r
+    // Set position at the end of the file\r
+    Status = File->SetPosition (File, OldSize);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
-    Status = File->Write (File, &BufferSize, &Buffer);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
+\r
+    BufferSize = NewSize - OldSize;\r
+    Buffer = AllocateZeroPool (BufferSize);\r
+    if (Buffer == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
     }\r
 \r
-    // Restore saved position\r
-    Status = File->SetPosition (File, NewSize - 1);\r
+    Status = File->Write (File, &BufferSize, Buffer);\r
+    FreePool (Buffer);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
 \r
-    Status = File->Flush (File);\r
+    // Restore saved position\r
+    Status = File->SetPosition (File, StoredPosition);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
   }\r
+\r
+  BootMonFsFile->Info->FileSize = NewSize;\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Set information about a file.\r
+\r
+  @param[in]  Instance  A pointer to the description of the volume\r
+                        the file belongs to.\r
+  @param[in]  File      A pointer to the description of the file.\r
+  @param[in]  Info      A pointer to the file information to write.\r
+\r
+  @retval  EFI_SUCCESS           The information was set.\r
+  @retval  EFI_ACCESS_DENIED     An attempt is being made to change the\r
+                                 EFI_FILE_DIRECTORY Attribute.\r
+  @retval  EFI_ACCESS_DENIED     The file was opened in read-only mode and an\r
+                                 attempt is being made to modify a field other\r
+                                 than Attribute.\r
+  @retval  EFI_ACCESS_DENIED     An attempt is made to change the name of a file\r
+                                 to a file that is already present.\r
+  @retval  EFI_WRITE_PROTECTED   An attempt is being made to modify a read-only\r
+                                 attribute.\r
+  @retval  EFI_OUT_OF_RESOURCES  An allocation needed to process the request\r
+                                 failed.\r
+\r
+**/\r
+STATIC\r
 EFI_STATUS\r
 SetFileInfo (\r
-  IN BOOTMON_FS_INSTANCE *Instance,\r
-  IN BOOTMON_FS_FILE     *File,\r
-  IN UINTN                BufferSize,\r
-  IN EFI_FILE_INFO       *Info\r
+  IN BOOTMON_FS_INSTANCE  *Instance,\r
+  IN BOOTMON_FS_FILE      *File,\r
+  IN EFI_FILE_INFO        *Info\r
   )\r
 {\r
-  EFI_STATUS             Status;\r
+  EFI_STATUS  Status;\r
+  BOOLEAN     FileSizeIsDifferent;\r
+  BOOLEAN     FileNameIsDifferent;\r
+  BOOLEAN     TimeIsDifferent;\r
 \r
-  Status = EFI_SUCCESS;\r
+  //\r
+  // A directory can not be changed to a file and a file can\r
+  // not be changed to a directory.\r
+  //\r
+  if ((Info->Attribute & EFI_FILE_DIRECTORY)      !=\r
+      (File->Info->Attribute & EFI_FILE_DIRECTORY)  ) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
 \r
-  // Note that a call to this function on a file opened read-only is only\r
-  // invalid if it actually changes fields, so  we don't immediately fail if the\r
-  // OpenMode is wrong.\r
-  // Also note that the only fields supported are filename and size, others are\r
-  // ignored.\r
+  FileSizeIsDifferent = (Info->FileSize != File->Info->FileSize);\r
+  FileNameIsDifferent = (StrnCmp (\r
+                           Info->FileName,\r
+                           File->Info->FileName,\r
+                           MAX_NAME_LENGTH - 1\r
+                           ) != 0);\r
+  //\r
+  // Check if the CreateTime, LastAccess or ModificationTime\r
+  // have been changed. The file system does not support file\r
+  // timestamps thus the three times in "File->Info" are\r
+  // always equal to zero. The following comparison actually\r
+  // checks if all three times are still equal to 0 or not.\r
+  //\r
+  TimeIsDifferent = CompareMem (\r
+                      &Info->CreateTime,\r
+                      &File->Info->CreateTime,\r
+                      3 * sizeof (EFI_TIME)\r
+                      ) != 0;\r
 \r
-  if (File != Instance->RootFile) {\r
-    if (!(File->OpenMode & EFI_FILE_MODE_WRITE)) {\r
+  //\r
+  // For a file opened in read-only mode, only the Attribute field can be\r
+  // modified. The root directory open mode is forced to read-only at opening\r
+  // thus the following test protects the root directory to be somehow modified.\r
+  //\r
+  if (File->OpenMode == EFI_FILE_MODE_READ) {\r
+    if (FileSizeIsDifferent || FileNameIsDifferent || TimeIsDifferent) {\r
       return EFI_ACCESS_DENIED;\r
     }\r
+  }\r
+\r
+  if (TimeIsDifferent) {\r
+    return EFI_WRITE_PROTECTED;\r
+  }\r
 \r
-    Status = SetFileName (File, Info->FileName);\r
+  if (FileSizeIsDifferent) {\r
+    Status = SetFileSize (Instance, File, Info->FileSize);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
+  }\r
 \r
-    // Update file size\r
-    Status = SetFileSize (Instance, File, Info->FileSize);\r
+  //\r
+  // Note down in RAM the Attribute field but we can not\r
+  // ask to store it in flash for the time being.\r
+  //\r
+  File->Info->Attribute = Info->Attribute;\r
+\r
+  if (FileNameIsDifferent) {\r
+    Status = SetFileName (Instance, File, Info->FileName);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
   }\r
-  return Status;\r
+\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 EFIAPI\r
@@ -477,11 +541,17 @@ BootMonFsGetInfo (
   BOOTMON_FS_FILE     *File;\r
   BOOTMON_FS_INSTANCE *Instance;\r
 \r
-  File = BOOTMON_FS_FILE_FROM_FILE_THIS (This);\r
-  if (File == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
+  if ((This == NULL)                         ||\r
+      (InformationType == NULL)              ||\r
+      (BufferSize == NULL)                   ||\r
+      ((Buffer == NULL) && (*BufferSize > 0))  ) {\r
+    return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  File = BOOTMON_FS_FILE_FROM_FILE_THIS (This);\r
+  if (File->Info == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
   Instance = File->Instance;\r
 \r
   // If the instance has not been initialized yet then do it ...\r
@@ -509,6 +579,37 @@ BootMonFsGetInfo (
   return Status;\r
 }\r
 \r
+/**\r
+  Set information about a file or a volume.\r
+\r
+  @param[in]  This             A pointer to the EFI_FILE_PROTOCOL instance that\r
+                               is the file handle the information is for.\r
+  @param[in]  InformationType  The type identifier for the information being set :\r
+                               EFI_FILE_INFO_ID or EFI_FILE_SYSTEM_INFO_ID or\r
+                               EFI_FILE_SYSTEM_VOLUME_LABEL_ID\r
+  @param[in]  BufferSize       The size, in bytes, of Buffer.\r
+  @param[in]  Buffer           A pointer to the data buffer to write. The type of the\r
+                               data inside the buffer is indicated by InformationType.\r
+\r
+  @retval  EFI_SUCCESS            The information was set.\r
+  @retval  EFI_UNSUPPORTED        The InformationType is not known.\r
+  @retval  EFI_DEVICE_ERROR       The last issued semi-hosting operation failed.\r
+  @retval  EFI_ACCESS_DENIED      An attempt is made to change the name of a file\r
+                                  to a file that is already present.\r
+  @retval  EFI_ACCESS_DENIED      An attempt is being made to change the\r
+                                  EFI_FILE_DIRECTORY Attribute.\r
+  @retval  EFI_ACCESS_DENIED      InformationType is EFI_FILE_INFO_ID and\r
+                                  the file was opened in read-only mode and an\r
+                                  attempt is being made to modify a field other\r
+                                  than Attribute.\r
+  @retval  EFI_WRITE_PROTECTED    An attempt is being made to modify a read-only\r
+                                  attribute.\r
+  @retval  EFI_BAD_BUFFER_SIZE    The size of the buffer is lower than that indicated by\r
+                                  the data inside the buffer.\r
+  @retval  EFI_OUT_OF_RESOURCES   A allocation needed to process the request failed.\r
+  @retval  EFI_INVALID_PARAMETER  At least one of the parameters is invalid.\r
+\r
+**/\r
 EFIAPI\r
 EFI_STATUS\r
 BootMonFsSetInfo (\r
@@ -518,28 +619,56 @@ BootMonFsSetInfo (
   IN VOID               *Buffer\r
   )\r
 {\r
-  EFI_STATUS           Status;\r
-  BOOTMON_FS_FILE     *File;\r
-  BOOTMON_FS_INSTANCE *Instance;\r
+  BOOTMON_FS_FILE       *File;\r
+  EFI_FILE_INFO         *Info;\r
+  EFI_FILE_SYSTEM_INFO  *SystemInfo;\r
+\r
+  if ((This == NULL)            ||\r
+      (InformationType == NULL) ||\r
+      (Buffer == NULL)             ) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
 \r
   File = BOOTMON_FS_FILE_FROM_FILE_THIS (This);\r
-  if (File == NULL) {\r
-    return EFI_DEVICE_ERROR;\r
+  if (File->Info == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  Instance = File->Instance;\r
+  if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {\r
+    Info = Buffer;\r
+    if (Info->Size < (SIZE_OF_EFI_FILE_INFO + StrSize (Info->FileName))) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+    if (BufferSize < Info->Size) {\r
+      return EFI_BAD_BUFFER_SIZE;\r
+    }\r
+    return (SetFileInfo (File->Instance, File, Info));\r
+  }\r
 \r
-  if (CompareGuid (InformationType, &gEfiFileInfoGuid) != 0) {\r
-    Status = SetFileInfo (Instance, File, BufferSize, (EFI_FILE_INFO *) Buffer);\r
-  } else {\r
-    // The only writable field in the other two information types\r
-    // (i.e. EFI_FILE_SYSTEM_INFO and EFI_FILE_SYSTEM_VOLUME_LABEL) is the\r
-    // filesystem volume label. This can be retrieved with GetInfo, but it is\r
-    // hard-coded into this driver, not stored on media.\r
-    Status = EFI_UNSUPPORTED;\r
+  //\r
+  // The only writable field in the other two information types\r
+  // (i.e. EFI_FILE_SYSTEM_INFO and EFI_FILE_SYSTEM_VOLUME_LABEL) is the\r
+  // filesystem volume label. This can be retrieved with GetInfo, but it is\r
+  // hard-coded into this driver, not stored on media.\r
+  //\r
+\r
+  if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {\r
+    SystemInfo = Buffer;\r
+    if (SystemInfo->Size <\r
+        (SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (SystemInfo->VolumeLabel))) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+    if (BufferSize < SystemInfo->Size) {\r
+      return EFI_BAD_BUFFER_SIZE;\r
+    }\r
+    return EFI_WRITE_PROTECTED;\r
   }\r
 \r
-  return Status;\r
+  if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {\r
+    return EFI_WRITE_PROTECTED;\r
+  }\r
+\r
+  return EFI_UNSUPPORTED;\r
 }\r
 \r
 EFIAPI\r