]> git.proxmox.com Git - mirror_edk2.git/blob - EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.h
Fix component name bugs when input Controller Name is invalid
[mirror_edk2.git] / EdkUnixPkg / Dxe / UnixThunk / Bus / SimpleFileSystem / UnixSimpleFileSystem.h
1 /*++
2
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
8
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.
11
12 Module Name:
13
14 UnixSimpleFileSystem.h
15
16 Abstract:
17
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.
21
22 --*/
23
24 #ifndef _UNIX_SIMPLE_FILE_SYSTEM_H_
25 #define _UNIX_SIMPLE_FILE_SYSTEM_H_
26
27
28
29 #define UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('L', 'X', 'f', 's')
30
31 typedef struct {
32 UINTN Signature;
33 EFI_UNIX_THUNK_PROTOCOL *UnixThunk;
34 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;
35 CHAR8 *FilePath;
36 CHAR16 *VolumeLabel;
37 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
38 } UNIX_SIMPLE_FILE_SYSTEM_PRIVATE;
39
40 #define UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \
41 CR (a, \
42 UNIX_SIMPLE_FILE_SYSTEM_PRIVATE, \
43 SimpleFileSystem, \
44 UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \
45 )
46
47 #define UNIX_EFI_FILE_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('l', 'o', 'f', 's')
48
49 typedef struct {
50 UINTN Signature;
51 EFI_UNIX_THUNK_PROTOCOL *UnixThunk;
52 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
53 EFI_FILE EfiFile;
54 INTN fd;
55 DIR *Dir;
56 BOOLEAN IsRootDirectory;
57 BOOLEAN IsDirectoryPath;
58 BOOLEAN IsOpenedByRead;
59 char *FileName;
60 struct dirent *Dirent;
61 } UNIX_EFI_FILE_PRIVATE;
62
63 #define UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \
64 CR (a, \
65 UNIX_EFI_FILE_PRIVATE, \
66 EfiFile, \
67 UNIX_EFI_FILE_PRIVATE_SIGNATURE \
68 )
69
70 //
71 // Global Protocol Variables
72 //
73 extern EFI_DRIVER_BINDING_PROTOCOL gUnixSimpleFileSystemDriverBinding;
74 extern EFI_COMPONENT_NAME_PROTOCOL gUnixSimpleFileSystemComponentName;
75
76 //
77 // Driver Binding protocol member functions
78 //
79 EFI_STATUS
80 EFIAPI
81 UnixSimpleFileSystemDriverBindingSupported (
82 IN EFI_DRIVER_BINDING_PROTOCOL *This,
83 IN EFI_HANDLE ControllerHandle,
84 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
85 )
86 /*++
87
88 Routine Description:
89
90 Check to see if the driver supports a given controller.
91
92 Arguments:
93
94 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
95
96 ControllerHandle - EFI handle of the controller to test.
97
98 RemainingDevicePath - Pointer to remaining portion of a device path.
99
100 Returns:
101
102 EFI_SUCCESS - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver
103 specified by This.
104
105 EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by
106 the driver specified by This.
107
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.
110
111 EFI_UNSUPPORTED - The device specified by ControllerHandle and RemainingDevicePath is not supported by the
112 driver specified by This.
113
114 --*/
115 ;
116
117 EFI_STATUS
118 EFIAPI
119 UnixSimpleFileSystemDriverBindingStart (
120 IN EFI_DRIVER_BINDING_PROTOCOL *This,
121 IN EFI_HANDLE ControllerHandle,
122 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
123 )
124 /*++
125
126 Routine Description:
127
128 Starts a device controller or a bus controller.
129
130 Arguments:
131
132 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
133
134 ControllerHandle - EFI handle of the controller to start.
135
136 RemainingDevicePath - Pointer to remaining portion of a device path.
137
138 Returns:
139
140 EFI_SUCCESS - The device or bus controller has been started.
141
142 EFI_DEVICE_ERROR - The device could not be started due to a device failure.
143
144 EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
145
146 --*/
147 ;
148
149 EFI_STATUS
150 EFIAPI
151 UnixSimpleFileSystemDriverBindingStop (
152 IN EFI_DRIVER_BINDING_PROTOCOL *This,
153 IN EFI_HANDLE ControllerHandle,
154 IN UINTN NumberOfChildren,
155 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
156 )
157 /*++
158
159 Routine Description:
160
161 TODO: Add function description
162
163 Arguments:
164
165 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
166
167 ControllerHandle - A handle to the device to be stopped.
168
169 NumberOfChildren - The number of child device handles in ChildHandleBuffer.
170
171 ChildHandleBuffer - An array of child device handles to be freed.
172
173 Returns:
174
175 EFI_SUCCESS - The device has been stopped.
176
177 EFI_DEVICE_ERROR - The device could not be stopped due to a device failure.
178
179 --*/
180 ;
181
182 //
183 // Simple File System protocol member functions
184 //
185 EFI_STATUS
186 EFIAPI
187 UnixSimpleFileSystemOpenVolume (
188 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
189 OUT EFI_FILE **Root
190 )
191 /*++
192
193 Routine Description:
194
195 Open the root directory on a volume.
196
197 Arguments:
198
199 This - A pointer to the volume to open.
200
201 Root - A pointer to storage for the returned opened file handle of the root directory.
202
203 Returns:
204
205 EFI_SUCCESS - The volume was opened.
206
207 EFI_UNSUPPORTED - The volume does not support the requested file system type.
208
209 EFI_NO_MEDIA - The device has no media.
210
211 EFI_DEVICE_ERROR - The device reported an error.
212
213 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
214
215 EFI_ACCESS_DENIED - The service denied access to the file.
216
217 EFI_OUT_OF_RESOURCES - The file volume could not be opened due to lack of resources.
218
219 EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
220
221 --*/
222 ;
223
224 EFI_STATUS
225 EFIAPI
226 UnixSimpleFileSystemOpen (
227 IN EFI_FILE *This,
228 OUT EFI_FILE **NewHandle,
229 IN CHAR16 *FileName,
230 IN UINT64 OpenMode,
231 IN UINT64 Attributes
232 )
233 /*++
234
235 Routine Description:
236
237 Open a file relative to the source file location.
238
239 Arguments:
240
241 This - A pointer to the source file location.
242
243 NewHandle - Pointer to storage for the new file handle.
244
245 FileName - Pointer to the file name to be opened.
246
247 OpenMode - File open mode information.
248
249 Attributes - File creation attributes.
250
251 Returns:
252
253 EFI_SUCCESS - The file was opened.
254
255 EFI_NOT_FOUND - The file could not be found in the volume.
256
257 EFI_NO_MEDIA - The device has no media.
258
259 EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
260
261 EFI_DEVICE_ERROR - The device reported an error.
262
263 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
264
265 EFI_WRITE_PROTECTED - The volume or file is write protected.
266
267 EFI_ACCESS_DENIED - The service denied access to the file.
268
269 EFI_OUT_OF_RESOURCES - Not enough resources were available to open the file.
270
271 EFI_VOLUME_FULL - There is not enough space left to create the new file.
272
273 --*/
274 ;
275
276 EFI_STATUS
277 EFIAPI
278 UnixSimpleFileSystemClose (
279 IN EFI_FILE *This
280 )
281 /*++
282
283 Routine Description:
284
285 Close the specified file handle.
286
287 Arguments:
288
289 This - Pointer to a returned opened file handle.
290
291 Returns:
292
293 EFI_SUCCESS - The file handle has been closed.
294
295 --*/
296 ;
297
298 EFI_STATUS
299 EFIAPI
300 UnixSimpleFileSystemDelete (
301 IN EFI_FILE *This
302 )
303 /*++
304
305 Routine Description:
306
307 Close and delete a file.
308
309 Arguments:
310
311 This - Pointer to a returned opened file handle.
312
313 Returns:
314
315 EFI_SUCCESS - The file handle was closed and deleted.
316
317 EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted.
318
319 --*/
320 ;
321
322 EFI_STATUS
323 EFIAPI
324 UnixSimpleFileSystemRead (
325 IN EFI_FILE *This,
326 IN OUT UINTN *BufferSize,
327 OUT VOID *Buffer
328 )
329 /*++
330
331 Routine Description:
332
333 Read data from a file.
334
335 Arguments:
336
337 This - Pointer to a returned open file handle.
338
339 BufferSize - On input, the size of the Buffer. On output, the number of bytes stored in the Buffer.
340
341 Buffer - Pointer to the first byte of the read Buffer.
342
343 Returns:
344
345 EFI_SUCCESS - The data was read.
346
347 EFI_NO_MEDIA - The device has no media.
348
349 EFI_DEVICE_ERROR - The device reported an error.
350
351 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
352
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.
355
356 --*/
357 ;
358
359 EFI_STATUS
360 EFIAPI
361 UnixSimpleFileSystemWrite (
362 IN EFI_FILE *This,
363 IN OUT UINTN *BufferSize,
364 IN VOID *Buffer
365 )
366 /*++
367
368 Routine Description:
369
370 Write data to a file.
371
372 Arguments:
373
374 This - Pointer to an opened file handle.
375
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.
378
379 Buffer - Pointer to the first by of data in the buffer to write to the file.
380
381 Returns:
382
383 EFI_SUCCESS - The data was written to the file.
384
385 EFI_UNSUPPORTED - Writes to an open directory are not supported.
386
387 EFI_NO_MEDIA - The device has no media.
388
389 EFI_DEVICE_ERROR - The device reported an error.
390
391 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
392
393 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
394
395 EFI_ACCESS_DENIED - The file was opened read-only.
396
397 EFI_VOLUME_FULL - The volume is full.
398
399 --*/
400 ;
401
402 EFI_STATUS
403 EFIAPI
404 UnixSimpleFileSystemSetPosition (
405 IN EFI_FILE *This,
406 IN UINT64 Position
407 )
408 /*++
409
410 Routine Description:
411
412 Set a file's current position.
413
414 Arguments:
415
416 This - Pointer to an opened file handle.
417
418 Position - The byte position from the start of the file to set.
419
420 Returns:
421
422 EFI_SUCCESS - The file position has been changed.
423
424 EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories.
425
426 --*/
427 ;
428
429 EFI_STATUS
430 EFIAPI
431 UnixSimpleFileSystemGetPosition (
432 IN EFI_FILE *This,
433 OUT UINT64 *Position
434 )
435 /*++
436
437 Routine Description:
438
439 Get a file's current position.
440
441 Arguments:
442
443 This - Pointer to an opened file handle.
444
445 Position - Pointer to storage for the current position.
446
447 Returns:
448
449 EFI_SUCCESS - The file position has been reported.
450
451 EFI_UNSUPPORTED - Not valid for directories.
452
453 --*/
454 ;
455
456 EFI_STATUS
457 EFIAPI
458 UnixSimpleFileSystemGetInfo (
459 IN EFI_FILE *This,
460 IN EFI_GUID *InformationType,
461 IN OUT UINTN *BufferSize,
462 OUT VOID *Buffer
463 )
464 /*++
465
466 Routine Description:
467
468 Return information about a file or volume.
469
470 Arguments:
471
472 This - Pointer to an opened file handle.
473
474 InformationType - GUID describing the type of information to be returned.
475
476 BufferSize - On input, the size of the information buffer. On output, the number of bytes written to the
477 information buffer.
478
479 Buffer - Pointer to the first byte of the information buffer.
480
481 Returns:
482
483 EFI_SUCCESS - The requested information has been written into the buffer.
484
485 EFI_UNSUPPORTED - The InformationType is not known.
486
487 EFI_NO_MEDIA - The device has no media.
488
489 EFI_DEVICE_ERROR - The device reported an error.
490
491 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
492
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.
495
496 --*/
497 ;
498
499 EFI_STATUS
500 EFIAPI
501 UnixSimpleFileSystemSetInfo (
502 IN EFI_FILE *This,
503 IN EFI_GUID *InformationType,
504 IN UINTN BufferSize,
505 IN VOID *Buffer
506 )
507 /*++
508
509 Routine Description:
510
511 Set information about a file or volume.
512
513 Arguments:
514
515 This - Pointer to an opened file handle.
516
517 InformationType - GUID identifying the type of information to set.
518
519 BufferSize - Number of bytes of data in the information buffer.
520
521 Buffer - Pointer to the first byte of data in the information buffer.
522
523 Returns:
524
525 EFI_SUCCESS - The file or volume information has been updated.
526
527 EFI_UNSUPPORTED - The information identifier is not recognised.
528
529 EFI_NO_MEDIA - The device has no media.
530
531 EFI_DEVICE_ERROR - The device reported an error.
532
533 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
534
535 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
536
537 EFI_ACCESS_DENIED - The file was opened read-only.
538
539 EFI_VOLUME_FULL - The volume is full.
540
541 EFI_BAD_BUFFER_SIZE - The buffer size is smaller than the type indicated by InformationType.
542
543 --*/
544 ;
545
546 EFI_STATUS
547 EFIAPI
548 UnixSimpleFileSystemFlush (
549 IN EFI_FILE *This
550 )
551 /*++
552
553 Routine Description:
554
555 Flush all modified data to the media.
556
557 Arguments:
558
559 This - Pointer to an opened file handle.
560
561 Returns:
562
563 EFI_SUCCESS - The data has been flushed.
564
565 EFI_NO_MEDIA - The device has no media.
566
567 EFI_DEVICE_ERROR - The device reported an error.
568
569 EFI_VOLUME_CORRUPTED - The file system structures have been corrupted.
570
571 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
572
573 EFI_ACCESS_DENIED - The file was opened read-only.
574
575 EFI_VOLUME_FULL - The volume is full.
576
577 --*/
578 ;
579
580 #endif /* _UNIX_SIMPLE_FILE_SYSTEM_H_ */
581
582 /* eof - UnixSimpleFileSystem.h */