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