]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.c
Clear the direction flag in interrupt/exception handlers' assembly entry code before...
[mirror_edk2.git] / UnixPkg / UnixSimpleFileSystemDxe / UnixSimpleFileSystem.c
index e39a18978fbfd05b71be55ee3b3e875511fb976a..e697b99a38d6d0be5b865a9a94831344ca06071f 100644 (file)
@@ -1,7 +1,7 @@
 /*++\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -350,9 +350,9 @@ Done:
     if (Private != NULL) {\r
 \r
       if (Private->VolumeLabel != NULL)\r
-       gBS->FreePool (Private->VolumeLabel);\r
+  gBS->FreePool (Private->VolumeLabel);\r
       if (Private->FilePath != NULL)\r
-       gBS->FreePool (Private->FilePath);\r
+  gBS->FreePool (Private->FilePath);\r
       FreeUnicodeStringTable (Private->ControllerNameTable);\r
 \r
       gBS->FreePool (Private);\r
@@ -836,7 +836,7 @@ OpenRoot:
       NewPrivateFile->IsDirectoryPath = FALSE;\r
     }\r
   } else {\r
-    struct stat finfo;\r
+    STAT_FIX finfo;\r
     int res = NewPrivateFile->UnixThunk->Stat (NewPrivateFile->FileName, &finfo);\r
     if (res == 0 && S_ISDIR(finfo.st_mode))\r
       NewPrivateFile->IsDirectoryPath = TRUE;\r
@@ -862,7 +862,7 @@ OpenRoot:
       // Create a directory\r
       //\r
       if (NewPrivateFile->UnixThunk->MkDir (NewPrivateFile->FileName, 0777) != 0) {\r
-       INTN LastError;\r
+  INTN LastError;\r
 \r
         LastError = PrivateFile->UnixThunk->GetErrno ();\r
         if (LastError != EEXIST) {\r
@@ -897,9 +897,9 @@ OpenRoot:
        0666);\r
     if (NewPrivateFile->fd < 0) {\r
       if (PrivateFile->UnixThunk->GetErrno () == ENOENT) {\r
-       Status = EFI_NOT_FOUND;\r
+  Status = EFI_NOT_FOUND;\r
       } else {\r
-       Status = EFI_ACCESS_DENIED;\r
+  Status = EFI_ACCESS_DENIED;\r
       }\r
     }\r
   }\r
@@ -1107,7 +1107,7 @@ Returns:
   struct tm *tm;\r
   tm = UnixThunk->GmTime (&SystemTime);\r
   Time->Year   = tm->tm_year;\r
-  Time->Month  = tm->tm_mon;\r
+  Time->Month  = tm->tm_mon + 1;\r
   Time->Day    = tm->tm_mday;\r
   Time->Hour   = tm->tm_hour;\r
   Time->Minute = tm->tm_min;\r
@@ -1151,10 +1151,10 @@ Returns:
   UINTN                       NameSize;\r
   UINTN                       ResultSize;\r
   EFI_FILE_INFO               *Info;\r
-  CHAR8                      *RealFileName;\r
-  CHAR8                      *TempPointer;\r
+  CHAR8                       *RealFileName;\r
+  CHAR8                       *TempPointer;\r
   CHAR16                      *BufferFileName;\r
-  struct stat                 buf;\r
+  STAT_FIX                    buf;\r
 \r
   if (FileName != NULL) {\r
     RealFileName = FileName;\r
@@ -1184,7 +1184,7 @@ Returns:
   }\r
   if (PrivateFile->UnixThunk->Stat (\r
           FileName == NULL ? PrivateFile->FileName : FileName,\r
-         &buf) < 0)\r
+    &buf) < 0)\r
     return EFI_DEVICE_ERROR;\r
 \r
   Status  = EFI_SUCCESS;\r
@@ -1285,9 +1285,9 @@ Returns:
     }\r
 \r
     Res = PrivateFile->UnixThunk->Read (\r
-                                        PrivateFile->fd,\r
-                                        Buffer,\r
-                                        *BufferSize);\r
+           PrivateFile->fd,\r
+           Buffer,\r
+           *BufferSize);\r
     if (Res < 0) {\r
       Status = EFI_DEVICE_ERROR;\r
       goto Done;\r
@@ -1336,14 +1336,14 @@ Returns:
   if (EFI_ERROR (Status)) {\r
     goto Done;\r
   }\r
-                 \r
+      \r
   AsciiStrCpy(FullFileName, PrivateFile->FileName);\r
   AsciiStrCat(FullFileName, "/");\r
   AsciiStrCat(FullFileName, PrivateFile->Dirent->d_name);\r
   Status = UnixSimpleFileSystemFileInfo (PrivateFile,\r
-                                         FullFileName,\r
-                                         BufferSize,\r
-                                         Buffer);\r
+            FullFileName,\r
+            BufferSize,\r
+            Buffer);\r
   gBS->FreePool (FullFileName);\r
 \r
   PrivateFile->Dirent = NULL;\r
@@ -1423,9 +1423,9 @@ Returns:
   }\r
 \r
   Res = PrivateFile->UnixThunk->Write (\r
-                                       PrivateFile->fd,\r
-                                       Buffer,\r
-                                       *BufferSize);\r
+          PrivateFile->fd,\r
+          Buffer,\r
+          *BufferSize);\r
   if (Res == (UINTN)-1) {\r
     Status = EFI_DEVICE_ERROR;\r
     goto Done;\r
@@ -1724,7 +1724,7 @@ Returns:
   UINTN                             OldInfoSize;\r
   EFI_TPL                           OldTpl;\r
   mode_t                            NewAttr;\r
-  struct stat                       OldAttr;\r
+  STAT_FIX                          OldAttr;\r
   CHAR8                             *OldFileName;\r
   CHAR8                             *NewFileName;\r
   CHAR8                             *CharPointer;\r
@@ -1850,7 +1850,7 @@ Returns:
   }\r
 \r
   Status = gBS->AllocatePool (EfiBootServicesData, OldInfoSize,\r
-                             (VOID **)&OldFileInfo);\r
+            (VOID **)&OldFileInfo);\r
 \r
   if (EFI_ERROR (Status)) {\r
     goto Done;\r
@@ -1895,7 +1895,7 @@ Returns:
   } else {\r
     Status = gBS->AllocatePool (\r
                     EfiBootServicesData,\r
-                    AsciiStrLen (PrivateFile->FileName) + 1 + StrLen (NewFileInfo->FileName) + 1,\r
+                    AsciiStrLen (PrivateFile->FileName) + 2 + StrLen (NewFileInfo->FileName) + 1,\r
                     (VOID **)&NewFileName\r
                     );\r
 \r
@@ -1905,8 +1905,11 @@ Returns:
 \r
     AsciiStrCpy (NewFileName, PrivateRoot->FilePath);\r
     AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName);\r
-    while (AsciiFilePtr > NewFileName && AsciiFilePtr[-1] != '/') {\r
-      AsciiFilePtr--;\r
+    if ((AsciiFilePtr[-1] != '/') && (NewFileInfo->FileName[0] != '/')) {\r
+      // make sure there is a / between Root FilePath and NewFileInfo Filename\r
+      AsciiFilePtr[0] = '/';      \r
+      AsciiFilePtr[1] = '\0';\r
+      AsciiFilePtr++;\r
     }\r
     UnicodeFilePtr = NewFileInfo->FileName;\r
   }\r
@@ -2091,7 +2094,6 @@ Returns:
   }\r
 \r
   UnixStatus = PrivateFile->UnixThunk->Chmod (NewFileName, NewAttr);\r
-\r
   if (UnixStatus != 0) {\r
     Status    = EFI_DEVICE_ERROR;\r
   }\r