]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EFI_FILE_PROTOCOL spec conformance bug fix.
authorRuiyu Ni <ruiyu.ni@intel.com>
Wed, 28 Jan 2015 08:58:38 +0000 (08:58 +0000)
committerJordan Justen <jordan.l.justen@intel.com>
Thu, 7 Apr 2016 06:22:43 +0000 (23:22 -0700)
1. Write() should return Unsupported instead of WriteProtected when operating above a directory in read-only media.
2. SetInfo() should return Unsupported instead of WriteProtected when operating above a directory using a undefined GUID in read-only media.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Jin <eric.jin@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(based on FatPkg commit 8ff136aaa3fff82d81514fd3091961ec4a63c873)

[jordan.l.justen@intel.com: Use script to relicense to 2-clause BSD]
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Acked-by: Mark Doran <mark.doran@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
FatPkg/EnhancedFatDxe/Info.c
FatPkg/EnhancedFatDxe/ReadWrite.c

index ae85cce85976096ce3300142275485572e2d8040..858b3f4a3e00a12b8a48ac7aff7f42f3e0ce4f88 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available\r
 under the terms and conditions of the BSD License which accompanies this\r
 distribution. The full text of the license may be found at\r
@@ -528,20 +528,16 @@ Returns:
     //\r
     Status = EFI_UNSUPPORTED;\r
     if (IsSet) {\r
-      if (Volume->ReadOnly) {\r
-        Status = EFI_WRITE_PROTECTED;\r
-      } else {\r
-        if (CompareGuid (Type, &gEfiFileInfoGuid)) {\r
-          Status = FatSetFileInfo (Volume, IFile, OFile, *BufferSize, Buffer);\r
-        }\r
+      if (CompareGuid (Type, &gEfiFileInfoGuid)) {\r
+        Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetFileInfo (Volume, IFile, OFile, *BufferSize, Buffer);\r
+      }\r
 \r
-        if (CompareGuid (Type, &gEfiFileSystemInfoGuid)) {\r
-          Status = FatSetVolumeInfo (Volume, *BufferSize, Buffer);\r
-        }\r
+      if (CompareGuid (Type, &gEfiFileSystemInfoGuid)) {\r
+        Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetVolumeInfo (Volume, *BufferSize, Buffer);\r
+      }\r
 \r
-        if (CompareGuid (Type, &gEfiFileSystemVolumeLabelInfoIdGuid)) {\r
-          Status = FatSetVolumeLabelInfo (Volume, *BufferSize, Buffer);\r
-        }\r
+      if (CompareGuid (Type, &gEfiFileSystemVolumeLabelInfoIdGuid)) {\r
+        Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetVolumeLabelInfo (Volume, *BufferSize, Buffer);\r
       }\r
     } else {\r
       if (CompareGuid (Type, &gEfiFileInfoGuid)) {\r
index 4621817c93d2562490142c6b3a7502f8d4be8cce..9afb6bff89e06f4f7bf4354cd3321c98f1c28296 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available\r
 under the terms and conditions of the BSD License which accompanies this\r
 distribution. The full text of the license may be found at\r
@@ -250,6 +250,13 @@ Returns:
   Volume = OFile->Volume;\r
   Task   = NULL;\r
 \r
+  //\r
+  // Write to a directory is unsupported\r
+  //\r
+  if ((OFile->ODir != NULL) && (IoMode == WRITE_DATA)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
   if (OFile->Error == EFI_NOT_FOUND) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
@@ -296,16 +303,10 @@ Returns:
   if (!EFI_ERROR (Status)) {\r
     if (OFile->ODir != NULL) {\r
       //\r
-      // Access a directory\r
+      // Read a directory is supported\r
       //\r
-      Status = EFI_UNSUPPORTED;\r
-      if (IoMode == READ_DATA) {\r
-        //\r
-        // Read a directory is supported\r
-        //\r
-        Status = FatIFileReadDir (IFile, BufferSize, Buffer);\r
-      }\r
-\r
+      ASSERT (IoMode == READ_DATA);\r
+      Status = FatIFileReadDir (IFile, BufferSize, Buffer);\r
       OFile = NULL;\r
     } else {\r
       //\r