31 ASSERT_VOLUME_LOCKED (OFile->Volume);
38 return EFI_OUT_OF_RESOURCES;
41 IFile->Signature = FAT_IFILE_SIGNATURE;
48 if (OFile->Volume->DiskIo2 !=
NULL) {
49 IFile->Handle.
Revision = EFI_FILE_PROTOCOL_REVISION2;
51 IFile->Handle.
Revision = EFI_FILE_PROTOCOL_REVISION;
95 CHAR16 NewFileName[EFI_PATH_STRING_LENGTH];
101 Volume = OFile->Volume;
102 ASSERT_VOLUME_LOCKED (Volume);
103 WriteMode = (BOOLEAN)(OpenMode & EFI_FILE_MODE_WRITE);
104 if (Volume->ReadOnly && WriteMode) {
105 return EFI_WRITE_PROTECTED;
111 Status = OFile->Error;
112 if (EFI_ERROR (Status)) {
119 Status =
FatLocateOFile (&OFile, FileName, Attributes, NewFileName);
120 if (EFI_ERROR (Status)) {
124 if (*NewFileName != 0) {
129 if ((OpenMode & EFI_FILE_MODE_CREATE) == 0) {
130 return EFI_NOT_FOUND;
134 if (EFI_ERROR (Status)) {
138 ASSERT (DirEnt !=
NULL);
140 if (EFI_ERROR (Status)) {
144 OFile = DirEnt->OFile;
145 if (OFile->ODir !=
NULL) {
150 if (EFI_ERROR (Status)) {
160 FileAttributes = OFile->DirEnt->Entry.Attributes;
161 if (((FileAttributes & EFI_FILE_READ_ONLY) != 0) && ((FileAttributes & FAT_ATTRIBUTE_DIRECTORY) == 0) && WriteMode) {
162 return EFI_ACCESS_DENIED;
169 if (EFI_ERROR (Status)) {
173 (*NewIFile)->ReadOnly = (BOOLEAN) !WriteMode;
175 DEBUG ((DEBUG_INFO,
"FSOpen: Open '%S' %r\n", FileName, Status));
205 IN UINT64 Attributes,
218 if (FileName ==
NULL) {
219 return EFI_INVALID_PARAMETER;
226 case EFI_FILE_MODE_READ:
227 case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:
228 case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE:
232 return EFI_INVALID_PARAMETER;
238 if (((OpenMode & EFI_FILE_MODE_CREATE) != 0) && ((Attributes & (EFI_FILE_READ_ONLY | (~EFI_FILE_VALID_ATTR))) != 0)) {
239 return EFI_INVALID_PARAMETER;
242 IFile = IFILE_FROM_FHAND (FHand);
243 OFile = IFile->OFile;
253 if (FHand->Revision < EFI_FILE_PROTOCOL_REVISION2) {
254 return EFI_UNSUPPORTED;
259 return EFI_OUT_OF_RESOURCES;
271 Status =
FatOFileOpen (OFile, &NewIFile, FileName, OpenMode, (UINT8)Attributes);
276 if (!EFI_ERROR (Status)) {
277 *NewHandle = &NewIFile->Handle;
287 if (!EFI_ERROR (Status)) {
326 return FatOpenEx (FHand, NewHandle, FileName, OpenMode, Attributes,
NULL);
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS FatCreateDirEnt(IN FAT_OFILE *OFile, IN CHAR16 *FileName, IN UINT8 Attributes, OUT FAT_DIRENT **PtrDirEnt)
EFI_STATUS FatOpenDirEnt(IN FAT_OFILE *Parent, IN FAT_DIRENT *DirEnt)
EFI_STATUS FatLocateOFile(IN OUT FAT_OFILE **PtrOFile, IN CHAR16 *FileName, IN UINT8 Attributes, OUT CHAR16 *NewFileName)
EFI_STATUS FatCreateDotDirEnts(IN FAT_OFILE *OFile)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID FatDestroyTask(FAT_TASK *Task)
FAT_TASK * FatCreateTask(FAT_IFILE *IFile, EFI_FILE_IO_TOKEN *Token)
EFI_STATUS FatQueueTask(IN FAT_IFILE *IFile, IN FAT_TASK *Task)
EFI_STATUS FatOFileFlush(IN FAT_OFILE *OFile)
VOID FatWaitNonblockingTask(FAT_IFILE *IFile)
VOID FatAcquireLock(VOID)
VOID FatReleaseLock(VOID)
EFI_STATUS FatCleanupVolume(IN FAT_VOLUME *Volume, IN FAT_OFILE *OFile, IN EFI_STATUS EfiStatus, IN FAT_TASK *Task)
#define DEBUG(Expression)
EFI_STATUS FatAllocateIFile(IN FAT_OFILE *OFile, OUT FAT_IFILE **PtrIFile)
EFI_STATUS EFIAPI FatOpenEx(IN EFI_FILE_PROTOCOL *FHand, OUT EFI_FILE_PROTOCOL **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes, IN OUT EFI_FILE_IO_TOKEN *Token)
EFI_STATUS EFIAPI FatOpen(IN EFI_FILE_PROTOCOL *FHand, OUT EFI_FILE_PROTOCOL **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes)
EFI_STATUS FatOFileOpen(IN FAT_OFILE *OFile, OUT FAT_IFILE **NewIFile, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT8 Attributes)