/*++\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
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
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
// 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
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
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
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
}\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
}\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
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
}\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
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
}\r
\r
Status = gBS->AllocatePool (EfiBootServicesData, OldInfoSize,\r
- (VOID **)&OldFileInfo);\r
+ (VOID **)&OldFileInfo);\r
\r
if (EFI_ERROR (Status)) {\r
goto Done;\r
} 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
\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
}\r
\r
UnixStatus = PrivateFile->UnixThunk->Chmod (NewFileName, NewAttr);\r
-\r
if (UnixStatus != 0) {\r
Status = EFI_DEVICE_ERROR;\r
}\r