1 /* This FileX test concentrates on the basic first/next entry find operations.  */
2 
3 #ifndef FX_STANDALONE_ENABLE
4 #include   "tx_api.h"
5 #endif
6 #include   "fx_api.h"
7 #include   "fx_utility.h"
8 #include   "fx_ram_driver_test.h"
9 #include   <stdio.h>
10 
11 #define     DEMO_STACK_SIZE         4096
12 #define     CACHE_SIZE              16*128
13 
14 /* Define the ThreadX and FileX object control blocks...  */
15 
16 #ifndef FX_STANDALONE_ENABLE
17 static TX_THREAD                ftest_0;
18 #endif
19 static FX_MEDIA                 ram_disk;
20 
21 
22 /* Define the counters used in the test application...  */
23 
24 #ifndef FX_STANDALONE_ENABLE
25 static UCHAR                  *ram_disk_memory;
26 static UCHAR                  *cache_buffer;
27 #else
28 static UCHAR                  cache_buffer[CACHE_SIZE];
29 #endif
30 static CHAR                   name[256];
31 
32 
33 /* Define thread prototypes.  */
34 
35 void    filex_directory_first_next_find_application_define(void *first_unused_memory);
36 static void    ftest_0_entry(ULONG thread_input);
37 
38 VOID  _fx_ram_driver(FX_MEDIA *media_ptr);
39 void  test_control_return(UINT status);
40 
41 
42 
43 /* Define what the initial system looks like.  */
44 
45 #ifdef CTEST
test_application_define(void * first_unused_memory)46 void test_application_define(void *first_unused_memory)
47 #else
48 void    filex_directory_first_next_find_application_define(void *first_unused_memory)
49 #endif
50 {
51 
52 #ifndef FX_STANDALONE_ENABLE
53 UCHAR    *pointer;
54 
55 
56     /* Setup the working pointer.  */
57     pointer =  (UCHAR *) first_unused_memory;
58 
59     /* Create the main thread.  */
60     tx_thread_create(&ftest_0, "thread 0", ftest_0_entry, 0,
61             pointer, DEMO_STACK_SIZE,
62             4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
63 
64     pointer =  pointer + DEMO_STACK_SIZE;
65 
66     /* Setup memory for the RAM disk and the sector cache.  */
67     cache_buffer =  pointer;
68     pointer =  pointer + CACHE_SIZE;
69     ram_disk_memory =  pointer;
70 
71 #endif
72 
73     /* Initialize the FileX system.  */
74     fx_system_initialize();
75 #ifdef FX_STANDALONE_ENABLE
76     ftest_0_entry(0);
77 #endif
78 }
79 
80 
81 
82 /* Define the test threads.  */
83 
ftest_0_entry(ULONG thread_input)84 static void    ftest_0_entry(ULONG thread_input)
85 {
86 
87 UINT        status;
88 CHAR        *path_ptr;
89 UINT        attributes;
90 ULONG       size;
91 ULONG       temp;
92 UINT        year;
93 UINT        month;
94 UINT        day;
95 UINT        hour;
96 UINT        minute;
97 UINT        second;
98 FX_LOCAL_PATH local_path;
99 UINT        i;
100 // A file name whose first byte is 0xe5.
101 UCHAR       specified_ascii_name[] = { 0xe5, 'a', 'b', 'c', 0};
102 
103     FX_PARAMETER_NOT_USED(thread_input);
104 
105     /* Print out some test information banners.  */
106     printf("FileX Test:   Directory first/next entry find test...................");
107 
108     /* Format the media.  This needs to be done before opening it!  */
109     status =  fx_media_format(&ram_disk,
110                             _fx_ram_driver,         // Driver entry
111                             ram_disk_memory,        // RAM disk memory pointer
112                             cache_buffer,           // Media buffer pointer
113                             CACHE_SIZE,             // Media buffer size
114                             "MY_RAM_DISK",          // Volume Name
115                             1,                      // Number of FATs
116                             32,                     // Directory Entries
117                             0,                      // Hidden sectors
118                             512,                    // Total sectors
119                             128,                    // Sector size
120                             1,                      // Sectors per cluster
121                             1,                      // Heads
122                             1);                     // Sectors per track
123 
124     /* Determine if the format had an error.  */
125     if (status)
126     {
127 
128         printf("ERROR!\n");
129         test_control_return(1);
130     }
131 
132     /* Attempt to get the next entry before the media is opened to generate an error */
133     status = fx_directory_next_entry_find(&ram_disk, "/A0");
134     if (status != FX_MEDIA_NOT_OPEN)
135     {
136         printf("ERROR!\n");
137         test_control_return(2);
138     }
139 
140     /* Attempt to get the next full entry before the media is opened to generate an error */
141     status = fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
142                 &size, &year, &month, &day, &hour, &minute, &second);
143     if (status != FX_MEDIA_NOT_OPEN)
144     {
145         printf("ERROR!\n");
146         test_control_return(3);
147     }
148 
149     /* Attempt to get the first entry before the media is opened to generate an error */
150     status = fx_directory_first_entry_find(&ram_disk, "/A0");
151     if (status != FX_MEDIA_NOT_OPEN)
152     {
153         printf("ERROR!\n");
154         test_control_return(4);
155     }
156 
157     /* Attempt to get the first full entry before the media is opened to generate an error */
158     status = fx_directory_first_full_entry_find(&ram_disk, name, &attributes,
159                 &size, &year, &month, &day, &hour, &minute, &second);
160     if (status != FX_MEDIA_NOT_OPEN)
161     {
162         printf("ERROR!\n");
163         test_control_return(5);
164     }
165 
166     /* Open the ram_disk.  */
167     status =  fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, CACHE_SIZE);
168 
169     /* Check the status.  */
170     if (status != FX_SUCCESS)
171     {
172 
173         /* Error, return error code.  */
174         printf("ERROR!\n");
175         test_control_return(6);
176     }
177 
178 /* Only run this if error checking is enabled */
179 #ifndef FX_DISABLE_ERROR_CHECKING
180     /* send null pointer to generate an error */
181     status = fx_directory_first_entry_find(FX_NULL, "/A0");
182     if (status != FX_PTR_ERROR)
183     {
184         printf("ERROR!\n");
185         test_control_return(6);
186     }
187 
188     /* send null pointer to generate an error */
189     status = fx_directory_first_full_entry_find(FX_NULL, name, &attributes,
190                 &size, &year, &month, &day, &hour, &minute, &second);
191     if (status != FX_PTR_ERROR)
192     {
193         printf("ERROR!\n");
194         test_control_return(7);
195     }
196 #endif /* FX_DISABLE_ERROR_CHECKING */
197 
198     /* Create a hiearchy of files and sub-directories.   */
199     status =   fx_file_create(&ram_disk,      "RootFile01");
200     status +=  fx_file_create(&ram_disk,      "RootFile02");
201     status +=  fx_directory_create(&ram_disk, "RootDir03");
202     status +=  fx_directory_create(&ram_disk, "RootDir04");
203     status +=  fx_directory_create(&ram_disk, "RootDir05");
204     status +=  fx_directory_create(&ram_disk, "RootDir06");
205     status +=  fx_directory_create(&ram_disk, "RootDir07");
206     status +=  fx_directory_create(&ram_disk, "RootDir08");
207     status +=  fx_file_create(&ram_disk,      "RootFile09");
208     status +=  fx_file_create(&ram_disk,      "RootFile10");
209     status +=  fx_directory_create(&ram_disk, "RootDir11");
210     status +=  fx_directory_create(&ram_disk, "RootDir12");
211     status +=  fx_directory_create(&ram_disk, "RootDir13");
212     status +=  fx_directory_create(&ram_disk, "RootDir14");
213     status +=  fx_file_create(&ram_disk,      "RootFile15");
214 
215     /* Create the sub-directories for RootDir03.  */
216     status +=  fx_directory_create(&ram_disk, "/RootDir03/RootDir03_SubDir01");
217     status +=  fx_file_create(&ram_disk,      "/RootDir03/RootDir03_File02");
218     status +=  fx_directory_create(&ram_disk, "/RootDir03/RootDir03_SubDir03");
219     status +=  fx_file_create(&ram_disk,      "/RootDir03/RootDir03_File04");
220     status +=  fx_directory_create(&ram_disk, "/RootDir03/RootDir03_SubDir05");
221     status +=  fx_file_create(&ram_disk,      "/RootDir03/RootDir03_File06");
222     status +=  fx_directory_create(&ram_disk, "/RootDir03/RootDir03_SubDir07");
223     status +=  fx_file_create(&ram_disk,      "/RootDir03/RootDir03_File08");
224 
225     /* Create the sub-directories for RootDir04.  */
226     status +=  fx_file_create(&ram_disk,      "/RootDir04/RootDir04_File01");
227     status +=  fx_file_create(&ram_disk,      "/RootDir04/RootDir04_File02");
228     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir03");
229     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04");
230     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir05");
231     status +=  fx_file_create(&ram_disk,      "/RootDir04/RootDir04_File06");
232     status +=  fx_file_create(&ram_disk,      "/RootDir04/RootDir04_File07");
233     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir08");
234 
235     /* Create the sub-directories for RootDir05.  */
236     status +=  fx_file_create(&ram_disk,      "/RootDir05/RootDir05_File02");
237     status +=  fx_file_create(&ram_disk,      "/RootDir05/RootDir05_File03");
238     status +=  fx_file_create(&ram_disk,      "/RootDir05/RootDir05_File04");
239     status +=  fx_directory_create(&ram_disk, "/RootDir05/RootDir05_SubDir05");
240     status +=  fx_directory_create(&ram_disk, "/RootDir05/RootDir05_SubDir06");
241     status +=  fx_directory_create(&ram_disk, "/RootDir05/RootDir05_SubDir07");
242     status +=  fx_file_create(&ram_disk,      "/RootDir05/RootDir05_File08");
243     status +=  fx_directory_create(&ram_disk, "/RootDir05/RootDir05_SubDir09");
244 
245     /* Create the sub-directories for RootDir06.  */
246     status +=  fx_directory_create(&ram_disk, "/RootDir06/RootDir06_SubDir01");
247     status +=  fx_directory_create(&ram_disk, "/RootDir06/RootDir06_SubDir02");
248     status +=  fx_directory_create(&ram_disk, "/RootDir06/RootDir06_SubDir03");
249     status +=  fx_file_create(&ram_disk,      "/RootDir06/RootDir06_File04");
250     status +=  fx_file_create(&ram_disk,      "/RootDir06/RootDir06_File05");
251     status +=  fx_file_create(&ram_disk,      "/RootDir06/RootDir06_File06");
252     status +=  fx_file_create(&ram_disk,      "/RootDir06/RootDir06_File07");
253     status +=  fx_directory_create(&ram_disk, "/RootDir06/RootDir06_SubDir08");
254 
255     /* Create the sub-directories for RootDir07.  */
256     status +=  fx_directory_create(&ram_disk, "/RootDir07/RootDir07_SubDir01");
257     status +=  fx_directory_create(&ram_disk, "/RootDir07/RootDir07_SubDir02");
258     status +=  fx_directory_create(&ram_disk, "/RootDir07/RootDir07_SubDir03");
259     status +=  fx_directory_create(&ram_disk, "/RootDir07/RootDir07_SubDir04");
260     status +=  fx_file_create(&ram_disk,      "/RootDir07/RootDir07_File05");
261     status +=  fx_file_create(&ram_disk,      "/RootDir07/RootDir07_File06");
262     status +=  fx_file_create(&ram_disk,      "/RootDir07/RootDir07_File07");
263     status +=  fx_file_create(&ram_disk,      "/RootDir07/RootDir07_File08");
264 
265     /* Create the sub-directories for RootDir08.  */
266     status +=  fx_file_create(&ram_disk,      "/RootDir08/RootDir08_File01");
267     status +=  fx_file_create(&ram_disk,      "/RootDir08/RootDir08_File02");
268     status +=  fx_file_create(&ram_disk,      "/RootDir08/RootDir08_File03");
269     status +=  fx_file_create(&ram_disk,      "/RootDir08/RootDir08_File04");
270     status +=  fx_directory_create(&ram_disk, "/RootDir08/RootDir08_SubDir05");
271     status +=  fx_directory_create(&ram_disk, "/RootDir08/RootDir08_SubDir06");
272     status +=  fx_directory_create(&ram_disk, "/RootDir08/RootDir08_SubDir07");
273     status +=  fx_directory_create(&ram_disk, "/RootDir08/RootDir08_SubDir08");
274 
275     /* Create the sub-directories for RootDir11.  */
276     status +=  fx_file_create(&ram_disk,      "/RootDir11/RootDir11_File01");
277     status +=  fx_file_create(&ram_disk,      "/RootDir11/RootDir11_File02");
278     status +=  fx_directory_create(&ram_disk, "/RootDir11/RootDir11_SubDir03");
279     status +=  fx_directory_create(&ram_disk, "/RootDir11/RootDir11_SubDir04");
280     status +=  fx_file_create(&ram_disk,      "/RootDir11/RootDir11_File05");
281     status +=  fx_file_create(&ram_disk,      "/RootDir11/RootDir11_File06");
282     status +=  fx_directory_create(&ram_disk, "/RootDir11/RootDir11_SubDir07");
283     status +=  fx_directory_create(&ram_disk, "/RootDir11/RootDir11_SubDir08");
284 
285     /* Create the sub-directories for RootDir12.  */
286     status +=  fx_file_create(&ram_disk,      "/RootDir12/RootDir12_File01");
287     status +=  fx_file_create(&ram_disk,      "/RootDir12/RootDir12_File02");
288     status +=  fx_directory_create(&ram_disk, "/RootDir12/RootDir12_SubDir03");
289     status +=  fx_directory_create(&ram_disk, "/RootDir12/RootDir12_SubDir04");
290     status +=  fx_file_create(&ram_disk,      "/RootDir12/RootDir12_File05");
291     status +=  fx_file_create(&ram_disk,      "/RootDir12/RootDir12_File06");
292     status +=  fx_directory_create(&ram_disk, "/RootDir12/RootDir12_SubDir07");
293     status +=  fx_directory_create(&ram_disk, "/RootDir12/RootDir12_SubDir08");
294 
295     /* Create the sub-directories for RootDir13.  */
296     status +=  fx_file_create(&ram_disk,      "/RootDir13/RootDir13_File01");
297     status +=  fx_file_create(&ram_disk,      "/RootDir13/RootDir13_File02");
298     status +=  fx_directory_create(&ram_disk, "/RootDir13/RootDir13_SubDir03");
299     status +=  fx_directory_create(&ram_disk, "/RootDir13/RootDir13_SubDir04");
300     status +=  fx_file_create(&ram_disk,      "/RootDir13/RootDir13_File05");
301     status +=  fx_file_create(&ram_disk,      "/RootDir13/RootDir13_File06");
302     status +=  fx_directory_create(&ram_disk, "/RootDir13/RootDir13_SubDir07");
303     status +=  fx_directory_create(&ram_disk, "/RootDir13/RootDir13_SubDir08");
304 
305     /* Create the Sub-sub directories under RootDir04.  */
306     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir03/RootDir04_SubDir03_SubSubDir01");
307     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir03/RootDir04_SubDir03_SubSubDir02");
308     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir03/RootDir04_SubDir03_SubSubDir03");
309     status +=  fx_file_create(&ram_disk,      "/RootDir04/RootDir04_SubDir03/RootDir04_SubDir03_SubSubFile04");
310 
311     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir01");
312     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir02");
313     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir03");
314     status +=  fx_file_create(&ram_disk,      "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubFile04");
315 
316     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir05/RootDir04_SubDir05_SubSubDir01");
317     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir05/RootDir04_SubDir05_SubSubDir02");
318     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir05/RootDir04_SubDir05_SubSubDir03");
319     status +=  fx_file_create(&ram_disk,      "/RootDir04/RootDir04_SubDir05/RootDir04_SubDir05_SubSubFile04");
320 
321     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir08/RootDir04_SubDir08_SubSubDir01");
322     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir08/RootDir04_SubDir08_SubSubDir02");
323     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir08/RootDir04_SubDir08_SubSubDir03");
324     status +=  fx_file_create(&ram_disk,      "/RootDir04/RootDir04_SubDir05/RootDir04_SubDir08_SubSubFile04");
325 
326     /* Create the sub-sub-sub directories under RootDir04.  */
327     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir01/RootDir04_SubDir04_SubSubDir01_SubSubSubDir01");
328     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir01/RootDir04_SubDir04_SubSubDir01_SubSubSubDir02");
329     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir01/RootDir04_SubDir04_SubSubDir01_SubSubSubDir03");
330     status +=  fx_file_create(&ram_disk,      "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir01/RootDir04_SubDir04_SubSubDir01_SubSubSubFile04");
331 
332     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir02/RootDir04_SubDir04_SubSubDir01_SubSubSubDir01");
333     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir02/RootDir04_SubDir04_SubSubDir01_SubSubSubDir02");
334     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir02/RootDir04_SubDir04_SubSubDir01_SubSubSubDir03");
335     status +=  fx_file_create(&ram_disk,      "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir02/RootDir04_SubDir04_SubSubDir01_SubSubSubFile04");
336 
337     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir03/RootDir04_SubDir04_SubSubDir01_SubSubSubDir01");
338     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir03/RootDir04_SubDir04_SubSubDir01_SubSubSubDir02");
339     status +=  fx_directory_create(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir03/RootDir04_SubDir04_SubSubDir01_SubSubSubDir03");
340     status +=  fx_file_create(&ram_disk,      "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir03/RootDir04_SubDir04_SubSubDir01_SubSubSubFile04");
341 
342     /* Get the current path. This should be / or NULL.   */
343     status +=  fx_directory_default_get(&ram_disk, &path_ptr);
344 
345     /* Check the status.  */
346     if ((status != FX_SUCCESS) || (path_ptr[0]))
347     {
348 
349         /* Error getting the path.  Return to caller.  */
350         printf("ERROR!\n");
351         test_control_return(8);
352     }
353 
354     /* Set the current path. This should be / or NULL.   */
355     status =  fx_directory_default_set(&ram_disk, "/");
356 
357     /* Check the status.  */
358     if (status != FX_SUCCESS)
359     {
360 
361         /* Error setting the path.  Return to caller.  */
362         printf("ERROR!\n");
363         test_control_return(9);
364     }
365 
366 /* Only run this if error checking is enabled */
367 #ifndef FX_DISABLE_ERROR_CHECKING
368     /* send null pointer to generate an error */
369     status = fx_directory_next_entry_find(FX_NULL, name);
370     if (status != FX_PTR_ERROR)
371     {
372         printf("ERROR!\n");
373         test_control_return(10);
374     }
375 #endif /* FX_DISABLE_ERROR_CHECKING */
376 
377     /* Pickup the first entry in the root directory.  */
378     status =  fx_directory_first_entry_find(&ram_disk, name);
379     if (strcmp(name, "RootFile01"))
380         status++;
381     status += fx_directory_next_entry_find(&ram_disk, name);
382     if (strcmp(name, "RootFile02"))
383         status++;
384     status += fx_directory_next_entry_find(&ram_disk, name);
385     if (strcmp(name, "RootDir03"))
386         status++;
387     status += fx_directory_next_entry_find(&ram_disk, name);
388     if (strcmp(name, "RootDir04"))
389         status++;
390     status += fx_directory_next_entry_find(&ram_disk, name);
391     if (strcmp(name, "RootDir05"))
392         status++;
393     status += fx_directory_next_entry_find(&ram_disk, name);
394     if (strcmp(name, "RootDir06"))
395         status++;
396     status += fx_directory_next_entry_find(&ram_disk, name);
397     if (strcmp(name, "RootDir07"))
398         status++;
399     status += fx_directory_next_entry_find(&ram_disk, name);
400     if (strcmp(name, "RootDir08"))
401         status++;
402     status += fx_directory_next_entry_find(&ram_disk, name);
403     if (strcmp(name, "RootFile09"))
404         status++;
405     status += fx_directory_next_entry_find(&ram_disk, name);
406     if (strcmp(name, "RootFile10"))
407         status++;
408     status += fx_directory_next_entry_find(&ram_disk, name);
409     if (strcmp(name, "RootDir11"))
410         status++;
411     status += fx_directory_next_entry_find(&ram_disk, name);
412     if (strcmp(name, "RootDir12"))
413         status++;
414     status += fx_directory_next_entry_find(&ram_disk, name);
415     if (strcmp(name, "RootDir13"))
416         status++;
417     status += fx_directory_next_entry_find(&ram_disk, name);
418     if (strcmp(name, "RootDir14"))
419         status++;
420     status += fx_directory_next_entry_find(&ram_disk, name);
421     if (strcmp(name, "RootFile15"))
422         status++;
423 
424     /* Determine if the test was successful.  */
425     if (status != FX_SUCCESS)
426     {
427 
428         printf("ERROR!\n");
429         test_control_return(11);
430     }
431 
432     /* Now read one past the number of entries in order to get an error condition.  */
433     status += fx_directory_next_entry_find(&ram_disk, name);
434 
435     /* Determine if the test was successful.  */
436     if (status != FX_NO_MORE_ENTRIES)
437     {
438 
439         printf("ERROR!\n");
440         test_control_return(12);
441     }
442 
443     /* Now test the full directory entry services.  */
444 
445 /* Only run this if error checking is enabled */
446 #ifndef FX_DISABLE_ERROR_CHECKING
447     /* send null pointer to generate an error */
448     status = fx_directory_next_full_entry_find(FX_NULL, name, &attributes,
449                 &size, &year, &month, &day, &hour, &minute, &second);
450     if (status != FX_PTR_ERROR)
451     {
452         printf("ERROR!\n");
453         test_control_return(13);
454     }
455 #endif /* FX_DISABLE_ERROR_CHECKING */
456 
457     /* Pickup the first entry in the root directory.  */
458     status =  fx_directory_first_full_entry_find(&ram_disk, name, &attributes,
459                 &size, &year, &month, &day, &hour, &minute, &second);
460     if (strcmp(name, "RootFile01"))
461         status++;
462     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
463                 &size, &year, &month, &day, &hour, &minute, &second);
464     if (strcmp(name, "RootFile02"))
465         status++;
466     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
467                 &size, &year, &month, &day, &hour, &minute, &second);
468     if (strcmp(name, "RootDir03"))
469         status++;
470     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
471                 &size, &year, &month, &day, &hour, &minute, &second);
472     if (strcmp(name, "RootDir04"))
473         status++;
474     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
475                 &size, &year, &month, &day, &hour, &minute, &second);
476     if (strcmp(name, "RootDir05"))
477         status++;
478     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
479                 &size, &year, &month, &day, &hour, &minute, &second);
480     if (strcmp(name, "RootDir06"))
481         status++;
482     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
483                 &size, &year, &month, &day, &hour, &minute, &second);
484     if (strcmp(name, "RootDir07"))
485         status++;
486     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
487                 &size, &year, &month, &day, &hour, &minute, &second);
488     if (strcmp(name, "RootDir08"))
489         status++;
490     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
491                 &size, &year, &month, &day, &hour, &minute, &second);
492     if (strcmp(name, "RootFile09"))
493         status++;
494     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
495                 &size, &year, &month, &day, &hour, &minute, &second);
496     if (strcmp(name, "RootFile10"))
497         status++;
498     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
499                 &size, &year, &month, &day, &hour, &minute, &second);
500     if (strcmp(name, "RootDir11"))
501         status++;
502     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
503                 &size, &year, &month, &day, &hour, &minute, &second);
504     if (strcmp(name, "RootDir12"))
505         status++;
506     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
507                 &size, &year, &month, &day, &hour, &minute, &second);
508     if (strcmp(name, "RootDir13"))
509         status++;
510     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
511                 &size, &year, &month, &day, &hour, &minute, &second);
512     if (strcmp(name, "RootDir14"))
513         status++;
514     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
515                 &size, &year, &month, &day, &hour, &minute, &second);
516     if (strcmp(name, "RootFile15"))
517         status++;
518 
519     /* Determine if the test was successful.  */
520     if (status != FX_SUCCESS)
521     {
522 
523         printf("ERROR!\n");
524         test_control_return(14);
525     }
526 
527     /* Now read one past the number of entries in order to get an error condition.  */
528     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
529                 &size, &year, &month, &day, &hour, &minute, &second);
530 
531     /* Determine if the test was successful.  */
532     if (status != FX_NO_MORE_ENTRIES)
533     {
534 
535         printf("ERROR!\n");
536         test_control_return(15);
537     }
538 
539     /* Okay, now postion to the deepest sub-directory and ensure that the directory first/next
540        operations work properly there as well.  */
541 
542     /* Set the current path. This should be / or NULL.   */
543     status =  fx_directory_default_set(&ram_disk, "/RootDir04/RootDir04_SubDir04/RootDir04_SubDir04_SubSubDir02");
544 
545     /* Check the status.  */
546     if (status != FX_SUCCESS)
547     {
548 
549         /* Error setting the path.  Return to caller.  */
550         printf("ERROR!\n");
551         test_control_return(16);
552     }
553 
554     /* Pickup the first entry in this sub-sub directory.  */
555     status =  fx_directory_first_entry_find(&ram_disk, name);
556     if (strcmp(name, "."))
557         status++;
558     status =  fx_directory_next_entry_find(&ram_disk, name);
559     if (strcmp(name, ".."))
560         status++;
561     status =  fx_directory_next_entry_find(&ram_disk, name);
562     if (strcmp(name, "RootDir04_SubDir04_SubSubDir01_SubSubSubDir01"))
563         status++;
564     status += fx_directory_next_entry_find(&ram_disk, name);
565     if (strcmp(name, "RootDir04_SubDir04_SubSubDir01_SubSubSubDir02"))
566         status++;
567     status += fx_directory_next_entry_find(&ram_disk, name);
568     if (strcmp(name, "RootDir04_SubDir04_SubSubDir01_SubSubSubDir03"))
569         status++;
570     status += fx_directory_next_entry_find(&ram_disk, name);
571     if (strcmp(name, "RootDir04_SubDir04_SubSubDir01_SubSubSubFile04"))
572         status++;
573 
574     /* Determine if the test was successful.  */
575     if (status != FX_SUCCESS)
576     {
577 
578         printf("ERROR!\n");
579         test_control_return(17);
580     }
581 
582     /* Now read one past the number of entries in order to get an error condition.  */
583     status += fx_directory_next_entry_find(&ram_disk, name);
584 
585     /* Determine if the test was successful.  */
586     if (status != FX_NO_MORE_ENTRIES)
587     {
588 
589         printf("ERROR!\n");
590         test_control_return(18);
591     }
592 
593     /* Now do the same thing but with the full find first/next.  */
594 
595 /*  pick up the first full entry with a local path defined to get to all of the code */
596 #ifndef FX_NO_LOCAL_PATH
597     status  =  fx_directory_local_path_set(&ram_disk, &local_path, "/RootDir04/RootDir04_SubDir03");
598     status +=  fx_directory_first_full_entry_find(&ram_disk, name, &attributes,
599                 &size, &year, &month, &day, &hour, &minute, &second);
600     if (strcmp(name, "."))
601         status++;
602     status +=  fx_directory_local_path_clear(&ram_disk);
603     status +=  fx_directory_local_path_set(&ram_disk, &local_path, "/");
604     status +=  fx_directory_first_full_entry_find(&ram_disk, name, &attributes,
605                 &size, &year, &month, &day, &hour, &minute, &second);
606     status +=  fx_directory_local_path_clear(&ram_disk);
607 
608     if (status != FX_SUCCESS)
609     {
610         printf("ERROR!\n");
611         test_control_return(19);
612     }
613 #endif
614 
615     /* Pickup the first entry in this sub-sub directory.  */
616     status =  fx_directory_first_full_entry_find(&ram_disk, name, &attributes,
617                 &size, &year, &month, &day, &hour, &minute, &second);
618     if (strcmp(name, "."))
619         status++;
620     status =  fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
621                 &size, &year, &month, &day, &hour, &minute, &second);
622     if (strcmp(name, ".."))
623         status++;
624     status =  fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
625                 &size, &year, &month, &day, &hour, &minute, &second);
626     if (strcmp(name, "RootDir04_SubDir04_SubSubDir01_SubSubSubDir01"))
627         status++;
628     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
629                 &size, &year, &month, &day, &hour, &minute, &second);
630     if (strcmp(name, "RootDir04_SubDir04_SubSubDir01_SubSubSubDir02"))
631         status++;
632     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
633                 &size, &year, &month, &day, &hour, &minute, &second);
634     if (strcmp(name, "RootDir04_SubDir04_SubSubDir01_SubSubSubDir03"))
635         status++;
636     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
637                 &size, &year, &month, &day, &hour, &minute, &second);
638     if (strcmp(name, "RootDir04_SubDir04_SubSubDir01_SubSubSubFile04"))
639         status++;
640 
641     /* Determine if the test was successful.  */
642     if (status != FX_SUCCESS)
643     {
644 
645         printf("ERROR!\n");
646         test_control_return(20);
647     }
648 
649     /* Now read one past the number of entries in order to get an error condition.  */
650     status += fx_directory_next_full_entry_find(&ram_disk, name, &attributes,
651                 &size, &year, &month, &day, &hour, &minute, &second);
652 
653     /* Determine if the test was successful.  */
654     if (status != FX_NO_MORE_ENTRIES)
655     {
656 
657         printf("ERROR!\n");
658         test_control_return(21);
659     }
660 
661     /* Close the media.  */
662     status =  fx_media_close(&ram_disk);
663 
664     /* Determine if the test was successful.  */
665     if (status != FX_SUCCESS)
666     {
667 
668         printf("ERROR!\n");
669         test_control_return(22);
670     }
671 
672     /* Format the media.  This needs to be done before opening it!  */
673     status =  fx_media_format(&ram_disk,
674                             _fx_ram_driver,         // Driver entry
675                             ram_disk_memory,        // RAM disk memory pointer
676                             cache_buffer,           // Media buffer pointer
677                             CACHE_SIZE,             // Media buffer size
678                             "MY_RAM_DISK",          // Volume Name
679                             1,                      // Number of FATs
680                             32,                     // Directory Entries
681                             0,                      // Hidden sectors
682                             4096,                   // Total sectors
683                             128,                    // Sector size
684                             1,                      // Sectors per cluster
685                             1,                      // Heads
686                             1);                     // Sectors per track
687 
688     /* Determine if the format had an error.  */
689     if (status)
690     {
691 
692         printf("ERROR!\n");
693         test_control_return(23);
694     }
695 
696     /* Open the ram_disk - 1 sector cache.  */
697     status =  fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
698 
699     /* Check the status.  */
700     if (status != FX_SUCCESS)
701     {
702 
703         /* Error, return error code.  */
704         printf("ERROR!\n");
705         test_control_return(24);
706     }
707 
708     /* Call first entry find with nothing in the root directory.  */
709     status =  fx_directory_first_entry_find(&ram_disk, name);
710 
711     /* This should return no more entries.  */
712     if (status != FX_NO_MORE_ENTRIES)
713     {
714         printf("ERROR!\n");
715         test_control_return(25);
716     }
717 
718     /* Create a directory structure that we can traverse.  */
719     status =  fx_directory_create(&ram_disk, "\\SUB1");
720     status += fx_file_create(&ram_disk, "\\SUB1\\TEST.TXT");
721     status += fx_file_create(&ram_disk, "\\SUB1\\TEST1.TXT");
722     status += fx_file_create(&ram_disk, "\\SUB1\\TEST2.TXT");
723     status += fx_file_create(&ram_disk, "\\SUB1\\TEST3.TXT");
724     status += fx_file_create(&ram_disk, "\\SUB1\\TEST4.TXT");
725     status += fx_file_create(&ram_disk, "\\SUB1\\TEST5.TXT");
726     status += fx_file_create(&ram_disk, "\\SUB1\\TEST6.TXT");
727     status += fx_file_create(&ram_disk, "\\SUB1\\TEST7.TXT");
728     status += fx_file_create(&ram_disk, "\\SUB1\\TEST8.TXT");
729     status += fx_file_create(&ram_disk, "\\SUB1\\TEST9.TXT");
730     status += fx_file_create(&ram_disk, "\\SUB1\\TEST10.TXT");
731     status += fx_file_create(&ram_disk, "\\SUB1\\TEST11.TXT");
732     status += fx_file_create(&ram_disk, "\\SUB1\\TEST12.TXT");
733     status += fx_file_create(&ram_disk, "\\SUB1\\TEST13.TXT");
734     status += fx_file_create(&ram_disk, "\\SUB1\\TEST14.TXT");
735     status += fx_file_create(&ram_disk, "\\SUB1\\TEST15.TXT");
736     status += fx_file_delete(&ram_disk, "\\SUB1\\TEST7.TXT");       /* Leave a free hole in the directory.  */
737     status += fx_directory_default_set(&ram_disk, "\\SUB1");
738     /* See if we can add a 255 character name.  */
739     for (i = 0; i < 256; i++)
740     {
741         name[i] =  'a';
742     }
743     name[255] = 0;
744 
745     /* Create a max length named file in this sub-directory.  */
746     status +=  fx_file_create(&ram_disk, name);
747 
748     /* Check for any errors.  */
749     if (status != FX_SUCCESS)
750     {
751         printf("ERROR!\n");
752         test_control_return(26);
753     }
754 
755     /* Now get the first entry... with a cluster of 0 error first.  Note this calls next entry find inside.  */
756     _fx_utility_fat_entry_read_error_request = 10001;
757     status = fx_directory_first_entry_find(&ram_disk, name);
758     _fx_utility_fat_entry_read_error_request =  0;
759 
760     /* This should return no more entries.  */
761     if (status != FX_FAT_READ_ERROR)
762     {
763         printf("ERROR!\n");
764         test_control_return(27);
765     }
766 
767     /* Now get the first entry... with a cluster equal to itself first.  Note this calls next entry find inside.  */
768     _fx_utility_fat_entry_read_error_request = 30001;
769     status = fx_directory_first_entry_find(&ram_disk, name);
770     _fx_utility_fat_entry_read_error_request =  0;
771 
772     /* This should return no more entries.  */
773     if (status != FX_FAT_READ_ERROR)
774     {
775         printf("ERROR!\n");
776         test_control_return(28);
777     }
778 
779     /* Now get the first entry... with an I/O error on the FAT read.  Note this calls next entry find inside.  */
780     _fx_utility_fat_entry_read_error_request = 1;
781     status = fx_directory_first_entry_find(&ram_disk, name);
782     _fx_utility_fat_entry_read_error_request =  0;
783 
784     /* This should return no more entries.  */
785     if (status != FX_IO_ERROR)
786     {
787         printf("ERROR!\n");
788         test_control_return(29);
789     }
790 
791     /* Now get the first entry... with a smaller value of total clusters.  Note this calls next entry find inside.  */
792     temp =  ram_disk.fx_media_total_clusters;
793     ram_disk.fx_media_total_clusters =  1;
794     status = fx_directory_first_entry_find(&ram_disk, name);
795     ram_disk.fx_media_total_clusters =  temp;
796 
797     /* This should return no more entries.  */
798     if (status != FX_FAT_READ_ERROR)
799     {
800         printf("ERROR!\n");
801         test_control_return(30);
802     }
803 
804     /* Now get the first entry... successfully.  Note this calls next entry find inside.  */
805     status = fx_directory_first_entry_find(&ram_disk, name);    /* TEST.TXT  */
806 
807     /* Check for any errors.  */
808     if (status != FX_SUCCESS)
809     {
810         printf("ERROR!\n");
811         test_control_return(31);
812     }
813 
814     /* Now flush everything out.  */
815     fx_media_flush(&ram_disk);
816     _fx_utility_FAT_flush(&ram_disk);
817     _fx_utility_logical_sector_flush(&ram_disk, 1, 60000, FX_TRUE);
818     for (i = 0; i < FX_MAX_FAT_CACHE; i++)
819     {
820         ram_disk.fx_media_fat_cache[i].fx_fat_cache_entry_cluster =  0;
821         ram_disk.fx_media_fat_cache[i].fx_fat_cache_entry_value =  0;
822     }
823 
824     /* Now get the first entry... with an I/O error on the directory read.  Note this calls next entry find inside.  */
825     _fx_utility_logical_sector_read_error_request = 1;
826     status = fx_directory_next_entry_find(&ram_disk, name);
827     _fx_utility_logical_sector_read_error_request = 0;
828 
829     /* This should return no more entries.  */
830     if (status != FX_IO_ERROR)
831     {
832         printf("ERROR!\n");
833         test_control_return(32);
834     }
835 
836     /* Now get all the directory entires.   */
837     status =  fx_directory_next_entry_find(&ram_disk, name);    /* .          */
838     status =  fx_directory_next_entry_find(&ram_disk, name);    /* ..          */
839     status =  fx_directory_next_entry_find(&ram_disk, name);    /* TEST1.TXT  */
840     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST2.TXT  */
841     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST3.TXT  */
842     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST4.TXT  */
843     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST5.TXT  */
844     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST6.TXT  */
845     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST8.TXT  */
846     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST9.TXT  */
847     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST10.TXT  */
848     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST11.TXT  */
849     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST12.TXT  */
850     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST13.TXT  */
851     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST14.TXT  */
852     status += fx_directory_next_entry_find(&ram_disk, name);    /* TEST15.TXT  */
853     status += fx_directory_next_entry_find(&ram_disk, name);    /* 255 character file name....  */
854 
855     /* Check for any errors.  */
856     if (status != FX_SUCCESS)
857     {
858         printf("ERROR!\n");
859         test_control_return(33);
860     }
861 
862     /* Now make another request to get the FX_NO_MORE_ENTRIES error.  */
863     status =  fx_directory_next_entry_find(&ram_disk, name);    /* END of Directory! */
864 
865     /* This should return no more entries.  */
866     if (status != FX_NO_MORE_ENTRIES)
867     {
868         printf("ERROR!\n");
869         test_control_return(34);
870     }
871 
872     /* Now make another request to get the FX_NO_MORE_ENTRIES error, but artifically move the current entry ahead.  */
873     temp =  ram_disk.fx_media_default_path.fx_path_current_entry;
874     ram_disk.fx_media_default_path.fx_path_current_entry =  100;
875     status =  fx_directory_next_entry_find(&ram_disk, name);    /* END of Directory! */
876     ram_disk.fx_media_default_path.fx_path_current_entry =  temp;
877 
878     /* This should return no more entries.  */
879     if (status != FX_NO_MORE_ENTRIES)
880     {
881         printf("ERROR!\n");
882         test_control_return(35);
883     }
884 
885     /* Now create enough sub-directories to exceed the maximum path.  */
886     status =  fx_directory_create(&ram_disk, "subdirectory1");
887     status += fx_directory_default_set(&ram_disk, "subdirectory1");
888     status += fx_directory_create(&ram_disk, "subdirectory2");
889     status += fx_directory_default_set(&ram_disk, "subdirectory2");
890     status += fx_directory_create(&ram_disk, "subdirectory3");
891     status += fx_directory_default_set(&ram_disk, "subdirectory3");
892     status += fx_directory_create(&ram_disk, "subdirectory4");
893     status += fx_directory_default_set(&ram_disk, "subdirectory4");
894     status += fx_directory_create(&ram_disk, "subdirectory5");
895     status += fx_directory_default_set(&ram_disk, "subdirectory5");
896     status += fx_directory_create(&ram_disk, "subdirectory6");
897     status += fx_directory_default_set(&ram_disk, "subdirectory6");
898     status += fx_directory_create(&ram_disk, "subdirectory7");
899     status += fx_directory_default_set(&ram_disk, "subdirectory7");
900     status += fx_directory_create(&ram_disk, "subdirectory8");
901     status += fx_directory_default_set(&ram_disk, "subdirectory8");
902     status += fx_directory_create(&ram_disk, "subdirectory9");
903     status += fx_directory_default_set(&ram_disk, "subdirectory9");
904     status += fx_directory_create(&ram_disk, "subdirectory10");
905     status += fx_directory_default_set(&ram_disk, "subdirectory10");
906     status += fx_directory_create(&ram_disk, "subdirectory11");
907     status += fx_directory_default_set(&ram_disk, "subdirectory11");
908     status += fx_directory_create(&ram_disk, "subdirectory12");
909     status += fx_directory_default_set(&ram_disk, "subdirectory12");
910     status += fx_directory_create(&ram_disk, "subdirectory13");
911     status += fx_directory_default_set(&ram_disk, "subdirectory13");
912     status += fx_directory_create(&ram_disk, "subdirectory14");
913     status += fx_directory_default_set(&ram_disk, "subdirectory14");
914     status += fx_directory_create(&ram_disk, "subdirectory15");
915     status += fx_directory_default_set(&ram_disk, "subdirectory15");
916     status += fx_directory_create(&ram_disk, "subdirectory16");
917     status += fx_directory_default_set(&ram_disk, "subdirectory16");
918     status += fx_directory_create(&ram_disk, "subdirectory17");
919     status += fx_directory_default_set(&ram_disk, "subdirectory17");
920     status += fx_directory_create(&ram_disk, "subdirectory18");
921     status += fx_directory_default_set(&ram_disk, "subdirectory18");
922     status += fx_directory_create(&ram_disk, "subdirectory19");
923     status += fx_directory_default_set(&ram_disk, "subdirectory19");
924     status += fx_directory_create(&ram_disk, "subdirectory20");
925     status += fx_directory_default_set(&ram_disk, "subdirectory20");
926     status += fx_directory_create(&ram_disk, "subdirectory21");
927     status += fx_directory_default_set(&ram_disk, "subdirectory21");
928     status += fx_directory_create(&ram_disk, "subdirectory22");
929     status += fx_directory_default_set(&ram_disk, "subdirectory22");
930     status += fx_directory_create(&ram_disk, "subdirectory23");
931     status += fx_directory_default_set(&ram_disk, "subdirectory23");
932     status += fx_directory_create(&ram_disk, "subdirectory24");
933     status += fx_directory_default_set(&ram_disk, "subdirectory24");
934     status += fx_directory_create(&ram_disk, "subdirectory25");
935     status += fx_directory_default_set(&ram_disk, "subdirectory25");
936     status += fx_directory_create(&ram_disk, "subdirectory26");
937     status += fx_directory_default_set(&ram_disk, "subdirectory26");
938     status += fx_directory_create(&ram_disk, "subdirectory27");
939     status += fx_directory_default_set(&ram_disk, "subdirectory27");
940     status += fx_directory_create(&ram_disk, "subdirectory28");
941     status += fx_directory_default_set(&ram_disk, "subdirectory28");
942     status += fx_directory_create(&ram_disk, "subdirectory29");
943     status += fx_directory_default_set(&ram_disk, "subdirectory29");
944     status += fx_directory_first_entry_find(&ram_disk, name);    /* Should be . */
945     status += fx_directory_next_entry_find(&ram_disk, name);     /* Should be .. */
946 
947     /* Check for any errors.  */
948     if (status != FX_SUCCESS)
949     {
950         printf("ERROR!\n");
951         test_control_return(36);
952     }
953 
954     /* Close the media.  */
955     status =  fx_media_close(&ram_disk);
956 
957     /* Determine if the test was successful.  */
958     if (status != FX_SUCCESS)
959     {
960 
961         printf("ERROR!\n");
962         test_control_return(37);
963     }
964 
965     /* Format the media.  This needs to be done before opening it!  */
966     status =  fx_media_format(&ram_disk,
967                             _fx_ram_driver,         // Driver entry
968                             ram_disk_memory,        // RAM disk memory pointer
969                             cache_buffer,           // Media buffer pointer
970                             CACHE_SIZE,             // Media buffer size
971                             "MY_RAM_DISK",          // Volume Name
972                             1,                      // Number of FATs
973                             32,                     // Directory Entries
974                             0,                      // Hidden sectors
975                             4096,                   // Total sectors
976                             128,                    // Sector size
977                             1,                      // Sectors per cluster
978                             1,                      // Heads
979                             1);                     // Sectors per track
980 
981     /* Determine if the format had an error.  */
982     if (status)
983     {
984 
985         printf("ERROR!\n");
986         test_control_return(38);
987     }
988 
989     /* Open the ram_disk - 1 sector cache.  */
990     status =  fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
991 
992     /* Check the status.  */
993     if (status != FX_SUCCESS)
994     {
995 
996         /* Error, return error code.  */
997         printf("ERROR!\n");
998         test_control_return(39);
999     }
1000 
1001     /* Call first entry find with nothing in the root directory.  */
1002     status =  fx_directory_first_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);
1003 
1004     /* This should return no more entries.  */
1005     if (status != FX_NO_MORE_ENTRIES)
1006     {
1007         printf("ERROR!\n");
1008         test_control_return(40);
1009     }
1010 
1011     /* Create a directory structure that we can traverse.  */
1012     status =  fx_directory_create(&ram_disk, "\\SUB1");
1013     status += fx_file_create(&ram_disk, "\\SUB1\\TEST.TXT");
1014     status += fx_file_create(&ram_disk, "\\SUB1\\TEST1.TXT");
1015     status += fx_file_create(&ram_disk, "\\SUB1\\TEST2.TXT");
1016     status += fx_file_create(&ram_disk, "\\SUB1\\TEST3.TXT");
1017     status += fx_file_create(&ram_disk, "\\SUB1\\TEST4.TXT");
1018     status += fx_file_create(&ram_disk, "\\SUB1\\TEST5.TXT");
1019     status += fx_file_create(&ram_disk, "\\SUB1\\TEST6.TXT");
1020     status += fx_file_create(&ram_disk, "\\SUB1\\TEST7.TXT");
1021     status += fx_file_create(&ram_disk, "\\SUB1\\TEST8.TXT");
1022     status += fx_file_create(&ram_disk, "\\SUB1\\TEST9.TXT");
1023     status += fx_file_create(&ram_disk, "\\SUB1\\TEST10.TXT");
1024     status += fx_file_create(&ram_disk, "\\SUB1\\TEST11.TXT");
1025     status += fx_file_create(&ram_disk, "\\SUB1\\TEST12.TXT");
1026     status += fx_file_create(&ram_disk, "\\SUB1\\TEST13.TXT");
1027     status += fx_file_create(&ram_disk, "\\SUB1\\TEST14.TXT");
1028     status += fx_file_create(&ram_disk, "\\SUB1\\TEST15.TXT");
1029     status += fx_file_delete(&ram_disk, "\\SUB1\\TEST7.TXT");       /* Leave a free hole in the directory.  */
1030     status += fx_directory_default_set(&ram_disk, "\\SUB1");
1031     /* See if we can add a 255 character name.  */
1032     for (i = 0; i < 256; i++)
1033     {
1034         name[i] =  'a';
1035     }
1036     name[255] = 0;
1037 
1038     /* Create a max length named file in this sub-directory.  */
1039     status +=  fx_file_create(&ram_disk, name);
1040 
1041     /* Check for any errors.  */
1042     if (status != FX_SUCCESS)
1043     {
1044         printf("ERROR!\n");
1045         test_control_return(41);
1046     }
1047 
1048     /* Now get the first entry... with a cluster of 0 error first.  Note this calls next entry find inside.  */
1049     _fx_utility_fat_entry_read_error_request = 10001;
1050     status = fx_directory_first_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &minute, FX_NULL);
1051     _fx_utility_fat_entry_read_error_request =  0;
1052 
1053     /* This should return no more entries.  */
1054     if (status != FX_FAT_READ_ERROR)
1055     {
1056         printf("ERROR!\n");
1057         test_control_return(42);
1058     }
1059 
1060     /* Now get the first entry... with a cluster equal to itself first.  Note this calls next entry find inside.  */
1061     _fx_utility_fat_entry_read_error_request = 30001;
1062     status = fx_directory_first_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);
1063     _fx_utility_fat_entry_read_error_request =  0;
1064 
1065     /* This should return no more entries.  */
1066     if (status != FX_FAT_READ_ERROR)
1067     {
1068         printf("ERROR!\n");
1069         test_control_return(43);
1070     }
1071 
1072     /* Now get the first entry... with an I/O error on the FAT read.  Note this calls next entry find inside.  */
1073     _fx_utility_fat_entry_read_error_request = 1;
1074     status = fx_directory_first_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);
1075     _fx_utility_fat_entry_read_error_request =  0;
1076 
1077     /* This should return no more entries.  */
1078     if (status != FX_IO_ERROR)
1079     {
1080         printf("ERROR!\n");
1081         test_control_return(44);
1082     }
1083 
1084     /* Now get the first entry... with a smaller value of total clusters.  Note this calls next entry find inside.  */
1085     temp =  ram_disk.fx_media_total_clusters;
1086     ram_disk.fx_media_total_clusters =  1;
1087     status = fx_directory_first_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);
1088     ram_disk.fx_media_total_clusters =  temp;
1089 
1090     /* This should return no more entries.  */
1091     if (status != FX_FAT_READ_ERROR)
1092     {
1093         printf("ERROR!\n");
1094         test_control_return(45);
1095     }
1096 
1097     /* Now get the first entry... successfully.  Note this calls next entry find inside.  */
1098     status = fx_directory_first_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST.TXT  */
1099 
1100     /* Check for any errors.  */
1101     if (status != FX_SUCCESS)
1102     {
1103         printf("ERROR!\n");
1104         test_control_return(46);
1105     }
1106 
1107     /* Now flush everything out.  */
1108     fx_media_flush(&ram_disk);
1109     _fx_utility_FAT_flush(&ram_disk);
1110     _fx_utility_logical_sector_flush(&ram_disk, 1, 60000, FX_TRUE);
1111     for (i = 0; i < FX_MAX_FAT_CACHE; i++)
1112     {
1113         ram_disk.fx_media_fat_cache[i].fx_fat_cache_entry_cluster =  0;
1114         ram_disk.fx_media_fat_cache[i].fx_fat_cache_entry_value =  0;
1115     }
1116 
1117     /* Now get the first entry... with an I/O error on the directory read.  Note this calls next entry find inside.  */
1118     _fx_utility_logical_sector_read_error_request = 1;
1119     status = fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);
1120     _fx_utility_logical_sector_read_error_request = 0;
1121 
1122     /* This should return no more entries.  */
1123     if (status != FX_IO_ERROR)
1124     {
1125         printf("ERROR!\n");
1126         test_control_return(47);
1127     }
1128 
1129     /* Now get all the directory entires.   */
1130     status =  fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* .          */
1131     status =  fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &minute, FX_NULL);    /* ..         */
1132     status =  fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST1.TXT  */
1133     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST2.TXT  */
1134     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST3.TXT  */
1135     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST4.TXT  */
1136     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST5.TXT  */
1137     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST6.TXT  */
1138     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST8.TXT  */
1139     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST9.TXT  */
1140     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST10.TXT  */
1141     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST11.TXT  */
1142     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST12.TXT  */
1143     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST13.TXT  */
1144     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST14.TXT  */
1145     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* TEST15.TXT  */
1146     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* 255 character file name....  */
1147 
1148     /* Check for any errors.  */
1149     if (status != FX_SUCCESS)
1150     {
1151         printf("ERROR!\n");
1152         test_control_return(48);
1153     }
1154 
1155     /* Now make another request to get the FX_NO_MORE_ENTRIES error.  */
1156     status =  fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* END of Directory! */
1157 
1158     /* This should return no more entries.  */
1159     if (status != FX_NO_MORE_ENTRIES)
1160     {
1161         printf("ERROR!\n");
1162         test_control_return(49);
1163     }
1164 
1165     /* Now make another request to get the FX_NO_MORE_ENTRIES error, but artifically move the current entry ahead.  */
1166     temp =  ram_disk.fx_media_default_path.fx_path_current_entry;
1167     ram_disk.fx_media_default_path.fx_path_current_entry =  100;
1168     status =  fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* END of Directory! */
1169     ram_disk.fx_media_default_path.fx_path_current_entry =  temp;
1170 
1171     /* This should return no more entries.  */
1172     if (status != FX_NO_MORE_ENTRIES)
1173     {
1174         printf("ERROR!\n");
1175         test_control_return(50);
1176     }
1177 
1178     /* Now create enough sub-directories to exceed the maximum path.  */
1179     status =  fx_directory_create(&ram_disk, "subdirectory1");
1180     status += fx_directory_default_set(&ram_disk, "subdirectory1");
1181 
1182     // Create the file whose name's first byte is 0xe5.
1183     status = fx_file_create(&ram_disk, (CHAR *)specified_ascii_name);
1184 
1185     status += fx_directory_create(&ram_disk, "subdirectory2");
1186     status += fx_directory_default_set(&ram_disk, "subdirectory2");
1187     status += fx_directory_create(&ram_disk, "subdirectory3");
1188     status += fx_directory_default_set(&ram_disk, "subdirectory3");
1189     status += fx_directory_create(&ram_disk, "subdirectory4");
1190     status += fx_directory_default_set(&ram_disk, "subdirectory4");
1191     status += fx_directory_create(&ram_disk, "subdirectory5");
1192     status += fx_directory_default_set(&ram_disk, "subdirectory5");
1193     status += fx_directory_create(&ram_disk, "subdirectory6");
1194     status += fx_directory_default_set(&ram_disk, "subdirectory6");
1195     status += fx_directory_create(&ram_disk, "subdirectory7");
1196     status += fx_directory_default_set(&ram_disk, "subdirectory7");
1197     status += fx_directory_create(&ram_disk, "subdirectory8");
1198     status += fx_directory_default_set(&ram_disk, "subdirectory8");
1199     status += fx_directory_create(&ram_disk, "subdirectory9");
1200     status += fx_directory_default_set(&ram_disk, "subdirectory9");
1201     status += fx_directory_create(&ram_disk, "subdirectory10");
1202     status += fx_directory_default_set(&ram_disk, "subdirectory10");
1203     status += fx_directory_create(&ram_disk, "subdirectory11");
1204     status += fx_directory_default_set(&ram_disk, "subdirectory11");
1205     status += fx_directory_create(&ram_disk, "subdirectory12");
1206     status += fx_directory_default_set(&ram_disk, "subdirectory12");
1207     status += fx_directory_create(&ram_disk, "subdirectory13");
1208     status += fx_directory_default_set(&ram_disk, "subdirectory13");
1209     status += fx_directory_create(&ram_disk, "subdirectory14");
1210     status += fx_directory_default_set(&ram_disk, "subdirectory14");
1211     status += fx_directory_create(&ram_disk, "subdirectory15");
1212     status += fx_directory_default_set(&ram_disk, "subdirectory15");
1213     status += fx_directory_create(&ram_disk, "subdirectory16");
1214     status += fx_directory_default_set(&ram_disk, "subdirectory16");
1215     status += fx_directory_create(&ram_disk, "subdirectory17");
1216     status += fx_directory_default_set(&ram_disk, "subdirectory17");
1217     status += fx_directory_create(&ram_disk, "subdirectory18");
1218     status += fx_directory_default_set(&ram_disk, "subdirectory18");
1219     status += fx_directory_create(&ram_disk, "subdirectory19");
1220     status += fx_directory_default_set(&ram_disk, "subdirectory19");
1221     status += fx_directory_create(&ram_disk, "subdirectory20");
1222     status += fx_directory_default_set(&ram_disk, "subdirectory20");
1223     status += fx_directory_create(&ram_disk, "subdirectory21");
1224     status += fx_directory_default_set(&ram_disk, "subdirectory21");
1225     status += fx_directory_create(&ram_disk, "subdirectory22");
1226     status += fx_directory_default_set(&ram_disk, "subdirectory22");
1227     status += fx_directory_create(&ram_disk, "subdirectory23");
1228     status += fx_directory_default_set(&ram_disk, "subdirectory23");
1229     status += fx_directory_create(&ram_disk, "subdirectory24");
1230     status += fx_directory_default_set(&ram_disk, "subdirectory24");
1231     status += fx_directory_create(&ram_disk, "subdirectory25");
1232     status += fx_directory_default_set(&ram_disk, "subdirectory25");
1233     status += fx_directory_create(&ram_disk, "subdirectory26");
1234     status += fx_directory_default_set(&ram_disk, "subdirectory26");
1235     status += fx_directory_create(&ram_disk, "subdirectory27");
1236     status += fx_directory_default_set(&ram_disk, "subdirectory27");
1237     status += fx_directory_create(&ram_disk, "subdirectory28");
1238     status += fx_directory_default_set(&ram_disk, "subdirectory28");
1239     status += fx_directory_create(&ram_disk, "subdirectory29");
1240     status += fx_directory_default_set(&ram_disk, "subdirectory29");
1241     status += fx_directory_first_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);    /* Should be . */
1242     status += fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);     /* Should be .. */
1243 
1244     /* Check for any errors.  */
1245     if (status != FX_SUCCESS)
1246     {
1247         printf("ERROR!\n");
1248         test_control_return(51);
1249     }
1250 
1251     /* Close the media.  */
1252     status =  fx_media_close(&ram_disk);
1253 
1254     /* Determine if the test was successful.  */
1255     if (status != FX_SUCCESS)
1256     {
1257 
1258         printf("ERROR!\n");
1259         test_control_return(52);
1260     }
1261     /* Format the media.  This needs to be done before opening it!  */
1262     status =  fx_media_format(&ram_disk,
1263                             _fx_ram_driver,         // Driver entry
1264                             ram_disk_memory,        // RAM disk memory pointer
1265                             cache_buffer,           // Media buffer pointer
1266                             CACHE_SIZE,             // Media buffer size
1267                             "MY_RAM_DISK",          // Volume Name
1268                             1,                      // Number of FATs
1269                             32,                     // Directory Entries
1270                             0,                      // Hidden sectors
1271                             4096,                   // Total sectors
1272                             128,                    // Sector size
1273                             1,                      // Sectors per cluster
1274                             1,                      // Heads
1275                             1);                     // Sectors per track
1276 
1277     /* Open the ram_disk.  */
1278     status +=  fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, CACHE_SIZE);
1279     return_value_if_fail(status == FX_SUCCESS, 53);
1280 
1281     status = fx_file_create(&ram_disk, (CHAR *)specified_ascii_name);
1282     return_value_if_fail(status == FX_SUCCESS, 54);
1283 
1284     specified_ascii_name[1]++;
1285     status = fx_file_create(&ram_disk, (CHAR *)specified_ascii_name);
1286     return_value_if_fail(status == FX_SUCCESS, 55);
1287 
1288     // Test the file whose name's first byte is 0xe5.
1289     status = fx_directory_first_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);
1290 
1291     /* Now get all the directory entires.   */
1292     status +=  fx_directory_next_full_entry_find(&ram_disk, name, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, FX_NULL, &second);
1293     return_value_if_fail(status == FX_SUCCESS, 56);
1294 
1295     // Try fx_directory_first_entry_find this time.
1296     status = fx_directory_first_entry_find(&ram_disk, name);
1297     return_value_if_fail(status == FX_SUCCESS, 57);
1298 
1299     // Try fx_media_volume_set this time.
1300     status = fx_media_volume_set(&ram_disk, (CHAR *)specified_ascii_name);
1301     return_value_if_fail(status == FX_SUCCESS, 58);
1302 
1303     printf("SUCCESS!\n");
1304     test_control_return(0);
1305 }
1306 
1307