49#define FSW_EFI_STRINGIFY(x) #x
51#define FSW_EFI_DRIVER_NAME(t) L"Fsw " FSW_EFI_STRINGIFY(t) L" File System Driver"
56 IN EFI_HANDLE ControllerHandle,
57 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath);
59 IN EFI_HANDLE ControllerHandle,
60 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath);
62 IN EFI_HANDLE ControllerHandle,
63 IN UINTN NumberOfChildren,
64 IN EFI_HANDLE *ChildHandleBuffer);
68 OUT CHAR16 **DriverName);
70 IN EFI_HANDLE ControllerHandle,
71 IN EFI_HANDLE ChildHandle OPTIONAL,
73 OUT CHAR16 **ControllerName);
85 OUT EFI_FILE **NewFileHandle);
88 IN OUT UINTN *BufferSize,
91 OUT UINT64 *Position);
96 OUT EFI_FILE **NewHandle,
99 IN UINT64 Attributes);
101 IN OUT UINTN *BufferSize,
107 IN EFI_GUID *InformationType,
108 IN OUT UINTN *BufferSize,
112 IN OUT UINTN *BufferSize,
118 IN OUT UINTN *BufferSize);
163 IN EFI_SYSTEM_TABLE *SystemTable)
173 EFI_NATIVE_INTERFACE,
175 if (EFI_ERROR (Status)) {
182 EFI_NATIVE_INTERFACE,
184 if (EFI_ERROR (Status)) {
199 IN EFI_HANDLE ControllerHandle,
200 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
208 Status =
BS->OpenProtocol(ControllerHandle,
211 This->DriverBindingHandle,
213 EFI_OPEN_PROTOCOL_BY_DRIVER);
214 if (EFI_ERROR(Status))
218 BS->CloseProtocol(ControllerHandle,
220 This->DriverBindingHandle,
224 Status =
BS->OpenProtocol(ControllerHandle,
227 This->DriverBindingHandle,
229 EFI_OPEN_PROTOCOL_TEST_PROTOCOL);
247 IN EFI_HANDLE ControllerHandle,
248 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
251 EFI_BLOCK_IO *BlockIo;
256 Print(L
"fsw_efi_DriverBinding_Start\n");
260 Status =
BS->OpenProtocol(ControllerHandle,
263 This->DriverBindingHandle,
265 EFI_OPEN_PROTOCOL_GET_PROTOCOL);
266 if (EFI_ERROR(Status)) {
267 Print(L
"Fsw ERROR: OpenProtocol(BlockIo) returned %x\n", Status);
271 Status =
BS->OpenProtocol(ControllerHandle,
274 This->DriverBindingHandle,
276 EFI_OPEN_PROTOCOL_BY_DRIVER);
277 if (EFI_ERROR(Status)) {
278 Print(L
"Fsw ERROR: OpenProtocol(DiskIo) returned %x\n", Status);
285 Volume->
Handle = ControllerHandle;
287 Volume->
MediaId = BlockIo->Media->MediaId;
295 if (!EFI_ERROR(Status)) {
297 Volume->
FileSystem.Revision = EFI_FILE_IO_INTERFACE_REVISION;
299 Status =
BS->InstallMultipleProtocolInterfaces(&ControllerHandle,
302 if (EFI_ERROR(Status))
303 Print(L
"Fsw ERROR: InstallMultipleProtocolInterfaces returned %x\n", Status);
307 if (EFI_ERROR(Status)) {
308 if (Volume->
vol != NULL)
312 BS->CloseProtocol(ControllerHandle,
314 This->DriverBindingHandle,
332 IN EFI_HANDLE ControllerHandle,
333 IN UINTN NumberOfChildren,
334 IN EFI_HANDLE *ChildHandleBuffer)
337 EFI_FILE_IO_INTERFACE *FileSystem;
341 Print(L
"fsw_efi_DriverBinding_Stop\n");
345 Status =
BS->OpenProtocol(ControllerHandle,
347 (VOID **) &FileSystem,
348 This->DriverBindingHandle,
350 EFI_OPEN_PROTOCOL_GET_PROTOCOL);
351 if (EFI_ERROR(Status))
352 return EFI_UNSUPPORTED;
358 Status =
BS->UninstallMultipleProtocolInterfaces(ControllerHandle,
361 if (EFI_ERROR(Status)) {
362 Print(L
"Fsw ERROR: UninstallMultipleProtocolInterfaces returned %x\n", Status);
366 Print(L
"fsw_efi_DriverBinding_Stop: protocol uninstalled successfully\n");
370 if (Volume->
vol != NULL)
375 Status =
BS->CloseProtocol(ControllerHandle,
377 This->DriverBindingHandle,
391 OUT CHAR16 **DriverName)
393 if (Language == NULL || DriverName == NULL)
394 return EFI_INVALID_PARAMETER;
396 if (Language[0] ==
'e' && Language[1] ==
'n' && Language[2] ==
'g' && Language[3] == 0) {
400 return EFI_UNSUPPORTED;
409 IN EFI_HANDLE ControllerHandle,
410 IN EFI_HANDLE ChildHandle OPTIONAL,
412 OUT CHAR16 **ControllerName)
414 return EFI_UNSUPPORTED;
447 if (EFI_ERROR(Status))
460 switch (fsw_status) {
464 return EFI_VOLUME_CORRUPTED;
468 return EFI_UNSUPPORTED;
470 return EFI_NOT_FOUND;
472 return EFI_VOLUME_CORRUPTED;
474 return EFI_DEVICE_ERROR;
492 Print(L
"fsw_efi_FileSystem_OpenVolume\n");
506 OUT EFI_FILE **NewHandle,
509 IN UINT64 Attributes)
516 return EFI_UNSUPPORTED;
529 Print(L
"fsw_efi_FileHandle_Close\n");
547 Status = This->Close(This);
548 if (Status == EFI_SUCCESS) {
550 Status = EFI_WARN_DELETE_FAILURE;
562 IN OUT UINTN *BufferSize,
571 return EFI_UNSUPPORTED;
580 IN OUT UINTN *BufferSize,
584 return EFI_WRITE_PROTECTED;
593 OUT UINT64 *Position)
600 return EFI_UNSUPPORTED;
617 return EFI_UNSUPPORTED;
626 IN EFI_GUID *InformationType,
627 IN OUT UINTN *BufferSize,
641 IN EFI_GUID *InformationType,
646 return EFI_WRITE_PROTECTED;
657 return EFI_WRITE_PROTECTED;
667 OUT EFI_FILE **NewFileHandle)
674 if (EFI_ERROR(Status))
679 return EFI_UNSUPPORTED;
692 if (EFI_ERROR(Status)) {
719 IN OUT UINTN *BufferSize,
726 Print(L
"fsw_efi_file_read %d bytes\n", *BufferSize);
729 buffer_size = (
fsw_u32) *BufferSize;
732 *BufferSize = buffer_size;
742 OUT UINT64 *Position)
744 *Position = File->shand.pos;
756 if (Position == 0xFFFFFFFFFFFFFFFFULL)
757 File->shand.pos = File->shand.dnode->size;
759 File->shand.pos = Position;
772 OUT EFI_FILE **NewHandle,
775 IN UINT64 Attributes)
784 Print(L
"fsw_efi_dir_open: '%s'\n", FileName);
787 if (OpenMode != EFI_FILE_MODE_READ)
788 return EFI_WRITE_PROTECTED;
791 lookup_path.
len = (int) StrLen(FileName);
793 lookup_path.
data = FileName;
798 if (EFI_ERROR(Status))
805 if (EFI_ERROR(Status))
821 IN OUT UINTN *BufferSize,
829 Print(L
"fsw_efi_dir_read...\n");
835 if (Status == EFI_NOT_FOUND) {
839 Print(L
"...no more entries\n");
843 if (EFI_ERROR(Status))
866 return EFI_UNSUPPORTED;
873 IN OUT UINTN *BufferSize) {
876 EFI_DEVICE_PATH_PROTOCOL *devicePathProtocol;
881 Print(L
"fsw_efi_bless_info.1\n");
886 return EFI_NOT_FOUND;
890 RequiredSize = (PathStr.
len + 1) *
sizeof(UINT16);
891 if ((PathChars = AllocatePool(RequiredSize)) == NULL) {
893 return EFI_OUT_OF_RESOURCES;
897 PathChars[PathStr.
len] = 0;
901 Print(L
"fsw_efi_bless_info.2 type=%d, res=%s\n", BlessType, PathChars);
904 devicePathProtocol = FileDevicePath(Volume->Handle, PathChars);
907 RequiredSize = GetDevicePathSize(devicePathProtocol);
908 if (*BufferSize < RequiredSize)
909 Status = EFI_BUFFER_TOO_SMALL;
912 Status = EFI_SUCCESS;
915 *BufferSize = RequiredSize;
916 FreePool(devicePathProtocol);
928 IN EFI_GUID *InformationType,
929 IN OUT UINTN *BufferSize,
934 EFI_FILE_SYSTEM_INFO *FSInfo;
940 Print(L
"fsw_efi_dnode_getinfo: FILE_INFO\n");
947 Print(L
"fsw_efi_dnode_getinfo: FILE_SYSTEM_INFO\n");
952 if (*BufferSize < RequiredSize) {
953 *BufferSize = RequiredSize;
954 return EFI_BUFFER_TOO_SMALL;
958 FSInfo = (EFI_FILE_SYSTEM_INFO *)
Buffer;
959 FSInfo->Size = RequiredSize;
960 FSInfo->ReadOnly = TRUE;
967 if (EFI_ERROR(Status))
973 *BufferSize = RequiredSize;
974 Status = EFI_SUCCESS;
978 Print(L
"fsw_efi_dnode_getinfo: FILE_SYSTEM_VOLUME_LABEL\n");
983 if (*BufferSize < RequiredSize) {
984 *BufferSize = RequiredSize;
985 return EFI_BUFFER_TOO_SMALL;
992 *BufferSize = RequiredSize;
993 Status = EFI_SUCCESS;
1001 Status = EFI_UNSUPPORTED;
1015 EFI_FILE_INFO *FileInfo = (EFI_FILE_INFO *)sb->
host_data;
1033 EFI_FILE_INFO *FileInfo = (EFI_FILE_INFO *)sb->
host_data;
1035 if ((posix_mode &
S_IWUSR) == 0)
1036 FileInfo->Attribute |= EFI_FILE_READ_ONLY;
1045 IN OUT UINTN *BufferSize,
1049 EFI_FILE_INFO *FileInfo;
1056 if (EFI_ERROR(Status))
1063 if (*BufferSize < RequiredSize) {
1067 Print(L
"...BUFFER TOO SMALL\n");
1069 *BufferSize = RequiredSize;
1070 return EFI_BUFFER_TOO_SMALL;
1075 FileInfo = (EFI_FILE_INFO *)
Buffer;
1082 if (EFI_ERROR (Status))
1087 if (EFI_ERROR(Status)) {
1095 FileInfo->Size = RequiredSize;
1096 FileInfo->FileSize = dno->
size;
1097 FileInfo->Attribute = 0;
1099 FileInfo->Attribute |= EFI_FILE_DIRECTORY;
1108 if (EFI_ERROR(Status))
1113 *BufferSize = RequiredSize;
1115 Print(L
"...returning '%s'\n", FileInfo->FileName);
EFI_GUID gAppleBlessedOsxFolderInfoGuid
A global variable storing the GUID of the APPLE_BLESSED_OSX_FOLDER_INFO_GUID.
EFI_GUID gAppleBlessedSystemFileInfoGuid
A global variable storing the GUID of the APPLE_BLESSED_SYSTEM_FILE_INFO_GUID.
EFI_GUID gAppleBlessedSystemFolderInfoGuid
A global variable storing the GUID of the APPLE_BLESSED_SYSTEM_FOLDER_INFO_GUID.
OC_TYPING_BUFFER_ENTRY Buffer[OC_TYPING_BUFFER_SIZE]
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_GUID gEfiFileInfoGuid
EFI_GUID gEfiFileSystemInfoGuid
EFI_GUID gEfiDriverBindingProtocolGuid
EFI_GUID gEfiSimpleFileSystemProtocolGuid
EFI_GUID gEfiComponentNameProtocolGuid
EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid
EFI_GUID gEfiBlockIoProtocolGuid
EFI_GUID gEfiDiskIoProtocolGuid
#define FSW_MSG_DEBUGV(params)
fsw_status_t fsw_shandle_read(struct fsw_shandle *shand, fsw_u32 *buffer_size_inout, void *buffer_in)
fsw_status_t fsw_dnode_stat(struct fsw_dnode *dno, struct fsw_dnode_stat *sb)
fsw_status_t fsw_dnode_fill(struct fsw_dnode *dno)
fsw_status_t fsw_dnode_dir_read(struct fsw_shandle *shand, struct fsw_dnode **child_dno_out)
void fsw_shandle_close(struct fsw_shandle *shand)
fsw_status_t fsw_dnode_lookup_path(struct fsw_dnode *dno, struct fsw_string *lookup_path, char separator, struct fsw_dnode **child_dno_out)
fsw_status_t fsw_shandle_open(struct fsw_dnode *dno, struct fsw_shandle *shand)
fsw_status_t fsw_volume_stat(struct fsw_volume *vol, struct fsw_volume_stat *sb)
fsw_status_t fsw_get_bless_info(struct fsw_volume *vol, int type, struct fsw_string *out_path)
fsw_status_t fsw_dnode_resolve(struct fsw_dnode *dno, struct fsw_dnode **target_dno_out)
fsw_status_t fsw_mount(void *host_data, struct fsw_host_table *host_table, struct fsw_fstype_table *fstype_table, struct fsw_volume **vol_out)
void fsw_unmount(struct fsw_volume *vol)
void fsw_dnode_release(struct fsw_dnode *dno)
void fsw_strfree(struct fsw_string *s)
#define FSW_FSTYPE_TABLE_NAME(t)
@ BLESSED_TYPE_SYSTEM_FILE
@ BLESSED_TYPE_SYSTEM_FOLDER
@ BLESSED_TYPE_OSX_FOLDER
EFI_COMPONENT_NAME_PROTOCOL fsw_efi_ComponentName_table
EFI_DRIVER_BINDING_PROTOCOL fsw_efi_DriverBinding_table
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Start(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI fsw_efi_FileSystem_OpenVolume(IN EFI_FILE_IO_INTERFACE *This, OUT EFI_FILE **Root)
#define FSW_EFI_DRIVER_NAME(t)
EFI_STATUS EFIAPI fsw_efi_ComponentName_GetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
EFI_STATUS EFIAPI fsw_efi_FileHandle_SetPosition(IN EFI_FILE *This, IN UINT64 Position)
EFI_STATUS EFIAPI fsw_efi_FileHandle_Delete(IN EFI_FILE *This)
EFI_STATUS fsw_efi_dir_read(IN FSW_FILE_DATA *File, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS fsw_efi_bless_info(IN FSW_VOLUME_DATA *Volume, IN UINT32 type, OUT VOID *Buffer, IN OUT UINTN *BufferSize)
EFI_STATUS EFIAPI fsw_efi_main(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
fsw_status_t fsw_efi_read_block(struct fsw_volume *vol, fsw_u32 phys_bno, void *buffer)
EFI_STATUS fsw_efi_dnode_to_FileHandle(IN struct fsw_dnode *dno, OUT EFI_FILE **NewFileHandle)
void fsw_efi_change_blocksize(struct fsw_volume *vol, fsw_u32 old_phys_blocksize, fsw_u32 old_log_blocksize, fsw_u32 new_phys_blocksize, fsw_u32 new_log_blocksize)
EFI_STATUS EFIAPI fsw_efi_FileHandle_Open(IN EFI_FILE *This, OUT EFI_FILE **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes)
EFI_STATUS EFIAPI fsw_efi_FileHandle_Flush(IN EFI_FILE *This)
EFI_STATUS EFIAPI fsw_efi_ComponentName_GetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
EFI_STATUS fsw_efi_file_getpos(IN FSW_FILE_DATA *File, OUT UINT64 *Position)
EFI_STATUS EFIAPI fsw_efi_FileHandle_GetPosition(IN EFI_FILE *This, OUT UINT64 *Position)
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Supported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS fsw_efi_dir_setpos(IN FSW_FILE_DATA *File, IN UINT64 Position)
EFI_STATUS fsw_efi_map_status(fsw_status_t fsw_status, FSW_VOLUME_DATA *Volume)
EFI_STATUS EFIAPI fsw_efi_FileHandle_GetInfo(IN EFI_FILE *This, IN EFI_GUID *InformationType, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI fsw_efi_FileHandle_Read(IN EFI_FILE *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI fsw_efi_FileHandle_Write(IN EFI_FILE *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS fsw_efi_dnode_fill_FileInfo(IN FSW_VOLUME_DATA *Volume, IN struct fsw_dnode *dno, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI fsw_efi_FileHandle_Close(IN EFI_FILE *This)
EFI_STATUS fsw_efi_dir_open(IN FSW_FILE_DATA *File, OUT EFI_FILE **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes)
struct fsw_host_table fsw_efi_host_table
EFI_STATUS fsw_efi_dnode_getinfo(IN FSW_FILE_DATA *File, IN EFI_GUID *InformationType, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Stop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI fsw_efi_FileHandle_SetInfo(IN EFI_FILE *This, IN EFI_GUID *InformationType, IN UINTN BufferSize, IN VOID *Buffer)
EFI_STATUS fsw_efi_file_setpos(IN FSW_FILE_DATA *File, IN UINT64 Position)
EFI_STATUS fsw_efi_file_read(IN FSW_FILE_DATA *File, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
UINTN fsw_efi_strsize(struct fsw_string *s)
#define FSW_EFI_FILE_TYPE_FILE
#define FSW_FILE_FROM_FILE_HANDLE(a)
#define FSW_VOLUME_DATA_SIGNATURE
VOID fsw_efi_strcpy(CHAR16 *Dest, struct fsw_string *src)
#define FSW_EFI_FILE_TYPE_DIR
VOID fsw_efi_decode_time(OUT EFI_TIME *EfiTime, IN UINT32 UnixTime)
#define FSW_VOLUME_FROM_FILE_SYSTEM(a)
#define FSW_FILE_DATA_SIGNATURE
#define EFI_FILE_HANDLE_REVISION
#define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO
#define SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO
EFI_FILE FileHandle
Published EFI protocol interface structure.
UINTN Type
File type used for dispatchinng.
struct fsw_shandle shand
FSW handle for this file.
UINT64 Signature
Used to identify this structure.
EFI_DISK_IO * DiskIo
The Disk I/O protocol we use for disk access.
UINT32 MediaId
The media ID from the Block I/O protocol.
UINT64 Signature
Used to identify this structure.
EFI_FILE_IO_INTERFACE FileSystem
Published EFI protocol interface structure.
struct fsw_volume * vol
FSW volume structure.
EFI_STATUS LastIOStatus
Last status from Disk I/O.
EFI_HANDLE Handle
The device handle the protocol is attached to.
void(* store_attr_posix)(struct fsw_dnode_stat *sb, fsw_u16 posix_mode)
Callbock for storing a Posix-style file mode.
void(* store_time_posix)(struct fsw_dnode_stat *sb, int which, fsw_u32 posix_time)
Callback for storing a Posix-style timestamp.
void * host_data
Hook for a host-specific data structure.
fsw_u64 used_bytes
Bytes actually used by the file on disk.
fsw_u64 size
Data size in bytes.
void * data
Data pointer (may be NULL if type is EMPTY or len is zero)
int len
Length in characters.
int size
Total data size in bytes.
int type
Encoding of the string - empty, ISO-8859-1, UTF8, UTF16.
fsw_u64 free_bytes
Bytes still available for storing file data.
fsw_u64 total_bytes
Total size of data area size in bytes.
fsw_u32 phys_blocksize
Block size for disk access / file system structures.
struct fsw_string label
Volume label.
fsw_u32 log_blocksize
Block size for logical file data.
void * host_data
Hook for a host-specific data structure.
struct DNODESTRUCTNAME * root
Root directory dnode.