3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 UnixSimpleFileSystem.h
18 Produce Simple File System abstractions for a directory on your PC using Unix APIs.
19 The configuration of what devices to mount or emulate comes from
20 environment variables.
24 #ifndef _UNIX_SIMPLE_FILE_SYSTEM_H_
25 #define _UNIX_SIMPLE_FILE_SYSTEM_H_
29 #define UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('L', 'X', 'f', 's')
33 EFI_UNIX_THUNK_PROTOCOL
*UnixThunk
;
34 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem
;
37 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
38 } UNIX_SIMPLE_FILE_SYSTEM_PRIVATE
;
40 #define UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \
42 UNIX_SIMPLE_FILE_SYSTEM_PRIVATE, \
44 UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \
47 #define UNIX_EFI_FILE_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('l', 'o', 'f', 's')
51 EFI_UNIX_THUNK_PROTOCOL
*UnixThunk
;
52 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFileSystem
;
56 BOOLEAN IsRootDirectory
;
57 BOOLEAN IsDirectoryPath
;
58 BOOLEAN IsOpenedByRead
;
60 struct dirent
*Dirent
;
61 } UNIX_EFI_FILE_PRIVATE
;
63 #define UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \
65 UNIX_EFI_FILE_PRIVATE, \
67 UNIX_EFI_FILE_PRIVATE_SIGNATURE \
71 // Global Protocol Variables
73 extern EFI_DRIVER_BINDING_PROTOCOL gUnixSimpleFileSystemDriverBinding
;
74 extern EFI_COMPONENT_NAME_PROTOCOL gUnixSimpleFileSystemComponentName
;
77 // Driver Binding protocol member functions
81 UnixSimpleFileSystemDriverBindingSupported (
82 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
83 IN EFI_HANDLE ControllerHandle
,
84 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
90 Check to see if the driver supports a given controller.
94 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
96 ControllerHandle - EFI handle of the controller to test.
98 RemainingDevicePath - Pointer to remaining portion of a device path.
102 EFI_SUCCESS - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver
105 EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by
106 the driver specified by This.
108 EFI_ACCESS_DENIED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by
109 a different driver or an application that requires exclusive access.
111 EFI_UNSUPPORTED - The device specified by ControllerHandle and RemainingDevicePath is not supported by the
112 driver specified by This.
119 UnixSimpleFileSystemDriverBindingStart (
120 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
121 IN EFI_HANDLE ControllerHandle
,
122 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
128 Starts a device controller or a bus controller.
132 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
134 ControllerHandle - EFI handle of the controller to start.
136 RemainingDevicePath - Pointer to remaining portion of a device path.
140 EFI_SUCCESS - The device or bus controller has been started.
142 EFI_DEVICE_ERROR - The device could not be started due to a device failure.
144 EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
151 UnixSimpleFileSystemDriverBindingStop (
152 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
153 IN EFI_HANDLE ControllerHandle
,
154 IN UINTN NumberOfChildren
,
155 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
161 TODO: Add function description
165 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
167 ControllerHandle - A handle to the device to be stopped.
169 NumberOfChildren - The number of child device handles in ChildHandleBuffer.
171 ChildHandleBuffer - An array of child device handles to be freed.
175 EFI_SUCCESS - The device has been stopped.
177 EFI_DEVICE_ERROR - The device could not be stopped due to a device failure.
183 // Simple File System protocol member functions
187 UnixSimpleFileSystemOpenVolume (
188 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*This
,
195 Open the root directory on a volume.
199 This - A pointer to the volume to open.
201 Root - A pointer to storage for the returned opened file handle of the root directory.
205 EFI_SUCCESS - The volume was opened.
207 EFI_UNSUPPORTED - The volume does not support the requested file system type.
209 EFI_NO_MEDIA - The device has no media.
211 EFI_DEVICE_ERROR - The device reported an error.
213 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
215 EFI_ACCESS_DENIED - The service denied access to the file.
217 EFI_OUT_OF_RESOURCES - The file volume could not be opened due to lack of resources.
219 EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
226 UnixSimpleFileSystemOpen (
228 OUT EFI_FILE
**NewHandle
,
237 Open a file relative to the source file location.
241 This - A pointer to the source file location.
243 NewHandle - Pointer to storage for the new file handle.
245 FileName - Pointer to the file name to be opened.
247 OpenMode - File open mode information.
249 Attributes - File creation attributes.
253 EFI_SUCCESS - The file was opened.
255 EFI_NOT_FOUND - The file could not be found in the volume.
257 EFI_NO_MEDIA - The device has no media.
259 EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
261 EFI_DEVICE_ERROR - The device reported an error.
263 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
265 EFI_WRITE_PROTECTED - The volume or file is write protected.
267 EFI_ACCESS_DENIED - The service denied access to the file.
269 EFI_OUT_OF_RESOURCES - Not enough resources were available to open the file.
271 EFI_VOLUME_FULL - There is not enough space left to create the new file.
278 UnixSimpleFileSystemClose (
285 Close the specified file handle.
289 This - Pointer to a returned opened file handle.
293 EFI_SUCCESS - The file handle has been closed.
300 UnixSimpleFileSystemDelete (
307 Close and delete a file.
311 This - Pointer to a returned opened file handle.
315 EFI_SUCCESS - The file handle was closed and deleted.
317 EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted.
324 UnixSimpleFileSystemRead (
326 IN OUT UINTN
*BufferSize
,
333 Read data from a file.
337 This - Pointer to a returned open file handle.
339 BufferSize - On input, the size of the Buffer. On output, the number of bytes stored in the Buffer.
341 Buffer - Pointer to the first byte of the read Buffer.
345 EFI_SUCCESS - The data was read.
347 EFI_NO_MEDIA - The device has no media.
349 EFI_DEVICE_ERROR - The device reported an error.
351 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
353 EFI_BUFFER_TOO_SMALL - The supplied buffer size was too small to store the current directory entry.
354 *BufferSize has been updated with the size needed to complete the request.
361 UnixSimpleFileSystemWrite (
363 IN OUT UINTN
*BufferSize
,
370 Write data to a file.
374 This - Pointer to an opened file handle.
376 BufferSize - On input, the number of bytes in the Buffer to write to the file. On output, the number of bytes
377 of data written to the file.
379 Buffer - Pointer to the first by of data in the buffer to write to the file.
383 EFI_SUCCESS - The data was written to the file.
385 EFI_UNSUPPORTED - Writes to an open directory are not supported.
387 EFI_NO_MEDIA - The device has no media.
389 EFI_DEVICE_ERROR - The device reported an error.
391 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
393 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
395 EFI_ACCESS_DENIED - The file was opened read-only.
397 EFI_VOLUME_FULL - The volume is full.
404 UnixSimpleFileSystemSetPosition (
412 Set a file's current position.
416 This - Pointer to an opened file handle.
418 Position - The byte position from the start of the file to set.
422 EFI_SUCCESS - The file position has been changed.
424 EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories.
431 UnixSimpleFileSystemGetPosition (
439 Get a file's current position.
443 This - Pointer to an opened file handle.
445 Position - Pointer to storage for the current position.
449 EFI_SUCCESS - The file position has been reported.
451 EFI_UNSUPPORTED - Not valid for directories.
458 UnixSimpleFileSystemGetInfo (
460 IN EFI_GUID
*InformationType
,
461 IN OUT UINTN
*BufferSize
,
468 Return information about a file or volume.
472 This - Pointer to an opened file handle.
474 InformationType - GUID describing the type of information to be returned.
476 BufferSize - On input, the size of the information buffer. On output, the number of bytes written to the
479 Buffer - Pointer to the first byte of the information buffer.
483 EFI_SUCCESS - The requested information has been written into the buffer.
485 EFI_UNSUPPORTED - The InformationType is not known.
487 EFI_NO_MEDIA - The device has no media.
489 EFI_DEVICE_ERROR - The device reported an error.
491 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
493 EFI_BUFFER_TOO_SMALL - The buffer size was too small to contain the requested information. The buffer size has
494 been updated with the size needed to complete the requested operation.
501 UnixSimpleFileSystemSetInfo (
503 IN EFI_GUID
*InformationType
,
511 Set information about a file or volume.
515 This - Pointer to an opened file handle.
517 InformationType - GUID identifying the type of information to set.
519 BufferSize - Number of bytes of data in the information buffer.
521 Buffer - Pointer to the first byte of data in the information buffer.
525 EFI_SUCCESS - The file or volume information has been updated.
527 EFI_UNSUPPORTED - The information identifier is not recognised.
529 EFI_NO_MEDIA - The device has no media.
531 EFI_DEVICE_ERROR - The device reported an error.
533 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
535 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
537 EFI_ACCESS_DENIED - The file was opened read-only.
539 EFI_VOLUME_FULL - The volume is full.
541 EFI_BAD_BUFFER_SIZE - The buffer size is smaller than the type indicated by InformationType.
548 UnixSimpleFileSystemFlush (
555 Flush all modified data to the media.
559 This - Pointer to an opened file handle.
563 EFI_SUCCESS - The data has been flushed.
565 EFI_NO_MEDIA - The device has no media.
567 EFI_DEVICE_ERROR - The device reported an error.
569 EFI_VOLUME_CORRUPTED - The file system structures have been corrupted.
571 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
573 EFI_ACCESS_DENIED - The file was opened read-only.
575 EFI_VOLUME_FULL - The volume is full.
580 #endif /* _UNIX_SIMPLE_FILE_SYSTEM_H_ */
582 /* eof - UnixSimpleFileSystem.h */