source: rtems/testsuites/fstests/fsdosfsname01/init.c @ 89bff5a

5
Last change on this file since 89bff5a was 06331e4, checked in by Sebastian Huber <sebastian.huber@…>, on 11/27/18 at 10:56:01

dosfs: Fix device identifier

Update #3358.

  • Property mode set to 100644
File size: 36.5 KB
Line 
1/*
2 * Copyright (c) 2012, 2013 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19
20#include "tmacros.h"
21
22#include <errno.h>
23#include <fcntl.h>
24#include <dirent.h>
25
26#include <bsp.h>
27#include <rtems/io.h>
28#include <rtems/libio.h>
29#include <rtems/dosfs.h>
30#include <rtems/ramdisk.h>
31#include <rtems/libcsupport.h>
32#include <rtems/userenv.h>
33#include "image.h"
34#include "image_bin_le_singlebyte.h"
35#include "image_bin_le_multibyte.h"
36#include "files.h"
37
38#include <errno.h>
39
40const char rtems_test_name[] = "FSDOSFSNAME 1";
41
42#define PRINT_DISK_IMAGE 0
43
44#define MOUNT_DIR "/mnt"
45#define MOUNT_DIR_SIZE 4
46#define START_DIR_SIZE 4
47#define RAMDISK_PATH "/dev/rda"
48#define BLOCK_NUM 47
49#define BLOCK_SIZE 512
50#define VOLUME_LABEL "MyDisk"
51
52#define NUMBER_OF_DIRECTORIES 8
53#define NUMBER_OF_FILES 13
54#define NUMBER_OF_DIRECTORIES_INVALID 25
55#define NUMBER_OF_DIRECTORIES_DUPLICATED 3
56#define NUMBER_OF_MULTIBYTE_NAMES_DUPLICATED 2
57#define NUMBER_OF_FILES_DUPLICATED 2
58#define NUMBER_OF_NAMES_MULTIBYTE 10
59#define MAX_NAME_LENGTH ( 255 + 1 )
60#define MAX_NAME_LENGTH_INVALID ( 255 + 2 )
61#define MAX_DUPLICATES_PER_NAME 3
62static const char UTF8_BOM[] = {0xEF, 0xBB, 0xBF};
63#define UTF8_BOM_SIZE 3 /* Size of the UTF-8 byte-order-mark */
64
65#define BLOCK_SIZE 512
66
67static rtems_resource_snapshot            before_mount;
68
69static const msdos_format_request_param_t rqdata = {
70  .OEMName             = "RTEMS",
71  .VolLabel            = VOLUME_LABEL,
72  .sectors_per_cluster = 2,
73  .fat_num             = 0,
74  .files_per_root_dir  = 0,
75  .media               = 0,
76  .quick_format        = true,
77  .skip_alignment      = 0,
78  .info_level          = 0
79};
80
81static const char                         DIRECTORY_NAMES[NUMBER_OF_DIRECTORIES]
82[MAX_NAME_LENGTH] = {
83  "a dir",
84  "Shortdir",
85  "shrtdir",
86  "shrt.dir",
87  "long_conventional_dir",
88  "long_conventional.dir",
89  "LongConventionalDir",
90  "This is a directory name with with 255 characters. The following numbers are aligned in that way, that the character 0 is the mentioned one. xxxxxx150xxxxxxx160xxxxxxx170xxxxxxx180xxxxxxx190xxxxxxx200xxxxxxx210xxxxxxx220xxxxxxx230xxxxxxx240xxxxxxx250xxxxx"
91};
92
93static const char DIRECTORY_NAMES_INVALID[
94  NUMBER_OF_DIRECTORIES_INVALID][MAX_NAME_LENGTH_INVALID] = {
95  "This is a directory name with with 256 characters. The following numbers are aligned in that way, that the character 0 is the mentioned one. xxxxxx150xxxxxxx160xxxxxxx170xxxxxxx180xxxxxxx190xxxxxxx200xxxxxxx210xxxxxxx220xxxxxxx230xxxxxxx240xxxxxxx250xxxxxx",
96  ".",
97  "..",
98  "...",
99  " ",
100  "... ...",
101  " ... ",
102  "",
103  "*",
104  "/",
105  ":",
106  "<",
107  ">",
108  "?",
109  "\\",
110  "|",
111  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
112    10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
113    20, 21, 22, 23, 24, 25, 26, 17, 28, 29, 30, 31},
114  {127},
115  "э*_тП ЎлОММПе ОЌя",
116  "э:_тП ЎлОММПе ОЌя",
117  "э<_тП ЎлОММПе ОЌя",
118  "э>_тП ЎлОММПе ОЌя",
119  "э?_тП ЎлОММПе ОЌя",
120  "э|_тП ЎлОММПе ОЌя"
121};
122
123static const char NAMES_MULTIBYTE[
124  NUMBER_OF_NAMES_MULTIBYTE][MAX_NAME_LENGTH] = {
125  "đây là một tên tập tin dài",
126  "Bu uzun bir dosya adı",
127  "هذا هو اسم Ù…لف طويل",
128  "αυτό είΜαι έΜα Όεγάλο όΜοΌα αρχείου",
129  "этП ЎлОММПе ОЌя",
130  "гэта ЎПўгае іЌя",
131  "тПва е ЎългП ОЌе Ма файла",
132  "这是䞀䞪长文件名",
133  "shrtname",
134  "long_conventional_name"
135};
136
137static const char NAMES_MULTIBYTE_IN_CODEPAGE_FORMAT[
138  NUMBER_OF_NAMES_MULTIBYTE][MAX_NAME_LENGTH] = {
139  "_\2030005~1._t",
140  "bu0008~1.bir",
141  "__000b~1.__",
142  "__000f~1.__",
143  "__0012~1.___",
144  "__0015~1.___",
145  "__0018~1.___",
146  "__001a~1",
147  "shrtname",
148  "long_conventional_name"
149};
150
151static const char FILE_NAMES[NUMBER_OF_FILES][
152  MAX_NAME_LENGTH] = {
153  "a file",
154  "shrtfile",
155  "ShrtFle",
156  "The quick brown.fox",
157  "long_conventional_file",
158  "This is a filename with with 255 characters. The following numbers are aligned in that way, that the character 0 is the mentioned one. xx140xxxxxxx150xxxxxxx160xxxxxxx170xxxxxxx180xxxxxxx190xxxxxxx200xxxxxxx210xxxxxxx220xxxxxxx230xxxxxxx240xxxxxxx250xxxxx",
159  "+",
160  ",",
161  "a.a",
162  ";",
163  "=",
164  "[",
165  "]"
166};
167
168typedef struct {
169  char name[MAX_NAME_LENGTH];
170  unsigned int number_of_duplicates;
171  char name_duplicates[MAX_DUPLICATES_PER_NAME][MAX_NAME_LENGTH];
172} name_duplicates;
173
174static const name_duplicates DIRECTORY_DUPLICATES[
175  NUMBER_OF_DIRECTORIES_DUPLICATED] = {
176  {
177    "shrtdir",
178    3,
179    {
180      "shrtdir",
181      "SHRTDIR",
182      "Shrtdir"
183    }
184  },
185  {
186    "Kurzdir",
187    3,
188    {
189      "kurzdir",
190      "KURZDIR",
191      "Kurzdir"
192    }
193  },
194  {
195    "long_conventional_dir",
196    3,
197    {
198      "long_conventional_dir",
199      "LONG_CONVENTIONAL_DIR",
200      "Long_conventional_dir"
201    }
202  }
203};
204
205static const name_duplicates MULTIBYTE_DUPLICATES[
206  NUMBER_OF_MULTIBYTE_NAMES_DUPLICATED] = {
207  {
208    /* The angstroem encoded differently. These encodings might become short entries */
209    {0xc3, 0x85}, /* '̊A' */
210    2,
211    {
212      {0xc3, 0x85}, /* '̊A' */
213      {0xe2, 0x84, 0xab} /* 'Å' */
214    }
215  },
216
217  /* Again the angstroem encoded differently,
218   * but this time with additional characters in order to enforce a long entry. */
219  {
220    {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', 0xc3,
221     0x85},
222    2,
223    {
224      {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', 0xc3,
225       0x85},
226      {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', 0xe2,
227       0x84, 0xab}
228    }
229  }
230};
231
232
233static const name_duplicates FILES_DUPLICATES[NUMBER_OF_FILES_DUPLICATED] = {
234  {
235    "shrtfile",
236    3,
237    {
238      "shrtfile",
239      "SHRTFILE",
240      "Shrtfile"
241    }
242  },
243  {
244    "long_conventional_file",
245    3,
246    {
247      "long_conventional_file",
248      "LONG_CONVENTIONAL_FILE",
249      "Long_conventional_file"
250    }
251  }
252};
253
254static int path_is_directory( const char *path )
255{
256  struct stat s_buf;
257
258
259  if ( stat( path, &s_buf ) )
260    return 0;
261
262  return S_ISDIR( s_buf.st_mode );
263}
264
265static void delete_folder_tree( const char *directory_name )
266{
267  DIR           *dp;
268  struct dirent *ep;
269  char           p_buf[1024] = {0};
270  int            rc          = 0;
271
272
273  dp = opendir( directory_name );
274  rtems_test_assert( dp != NULL );
275
276  while ( ( ep = readdir( dp ) ) != NULL && rc == 0 ) {
277    if ( 0 != strcmp( ".", ep->d_name )
278         && 0 != strcmp( "..", ep->d_name ) ) {
279      snprintf( p_buf, sizeof( p_buf ), "%s/%s", directory_name, ep->d_name );
280
281      if ( path_is_directory( p_buf ) ) {
282        delete_folder_tree( p_buf );
283        rc = rmdir( p_buf );
284        rtems_test_assert( rc == 0 );
285        rewinddir( dp );
286      } else {
287        rc = unlink( p_buf );
288        rtems_test_assert( rc == 0 );
289        rewinddir( dp );
290      }
291    }
292  }
293
294  rc = closedir( dp );
295  rtems_test_assert( rc == 0 );
296}
297
298static void mount_device( const char *start_dir,
299  const rtems_dosfs_mount_options    *mount_opts )
300{
301  int rc;
302
303  rc = mount(
304    RAMDISK_PATH,
305    MOUNT_DIR,
306    "dosfs",
307    RTEMS_FILESYSTEM_READ_WRITE,
308    mount_opts );
309  rtems_test_assert( rc == 0 );
310
311  rc = mkdir( start_dir, S_IRWXU | S_IRWXG | S_IRWXO );
312  rtems_test_assert( rc == 0 || ( rc == -1 && errno == EEXIST ) );
313}
314
315static void mount_device_with_defaults( const char *start_dir )
316{
317  int rc;
318
319
320  rc = msdos_format( RAMDISK_PATH, &rqdata );
321  rtems_test_assert( rc == 0 );
322
323  rtems_resource_snapshot_take( &before_mount );
324
325  mount_device( start_dir, NULL );
326}
327
328static void mount_device_with_iconv(
329  const char                *start_dir,
330  rtems_dosfs_mount_options *mount_opts
331)
332{
333  int                       rc;
334
335  rc = msdos_format( RAMDISK_PATH, &rqdata );
336  rtems_test_assert( rc == 0 );
337
338  rtems_resource_snapshot_take( &before_mount );
339
340  mount_opts->converter = rtems_dosfs_create_utf8_converter( "CP850" );
341  rtems_test_assert( mount_opts->converter != NULL );
342
343  mount_device( start_dir, mount_opts );
344}
345
346static void unmount_and_close_device( void )
347{
348  int                     rc;
349  rtems_resource_snapshot now;
350  bool                    are_resources_freed;
351
352
353  delete_folder_tree( MOUNT_DIR );
354
355  rc = unmount( MOUNT_DIR );
356  rtems_test_assert( rc == 0 );
357
358  are_resources_freed = rtems_resource_snapshot_check( &before_mount );
359
360  if ( !are_resources_freed )
361    rtems_resource_snapshot_take( &now );
362
363  rtems_test_assert( are_resources_freed );
364}
365
366/*
367 * Simply create a few directories. These tests should all succeed
368 */
369static void test_creating_directories(
370  const char        *start_dir,
371  const char        *directories,
372  const unsigned int number_of_directories )
373{
374  unsigned int   index;
375  int            rc;
376  char           dirname[MAX_NAME_LENGTH + strlen( start_dir ) + 1];
377  DIR           *dirp;
378  struct dirent *dp;
379
380
381  for ( index = 0; index < number_of_directories; ++index ) {
382    snprintf( dirname, sizeof( dirname ), "%s/%s", start_dir, directories
383              + ( index * MAX_NAME_LENGTH ) );
384    rc = mkdir( dirname, S_IRWXU | S_IRWXG | S_IRWXO );
385    rtems_test_assert( rc == 0 );
386  }
387
388  dirp = opendir( start_dir );
389  rtems_test_assert( NULL != dirp );
390
391  index = 0;
392  dp    = readdir( dirp );
393  rtems_test_assert( dp != NULL );
394  rtems_test_assert( 0 == strcmp( ".", dp->d_name ) );
395
396  dp = readdir( dirp );
397  rtems_test_assert( dp != NULL );
398  rtems_test_assert( 0 == strcmp( "..", dp->d_name ) );
399
400  dp = readdir( dirp );
401  rtems_test_assert( dp != NULL );
402
403  while ( dp != NULL ) {
404    rtems_test_assert( 0
405                       == strcmp( directories + ( index * MAX_NAME_LENGTH ),
406                                  dp->d_name ) );
407    ++index;
408    dp = readdir( dirp );
409  }
410
411  rtems_test_assert( number_of_directories == index );
412
413  rc = closedir( dirp );
414  rtems_test_assert( rc == 0 );
415}
416
417/*
418 * Try creating directories with invalid names.
419 */
420static void test_creating_invalid_directories( void )
421{
422  unsigned int index;
423  int          rc;
424  char         dirname[MAX_NAME_LENGTH_INVALID + MOUNT_DIR_SIZE + 1];
425
426
427  for ( index = 0; index < NUMBER_OF_DIRECTORIES_INVALID; ++index ) {
428    snprintf( dirname,
429              sizeof( dirname ),
430              "%s/%s",
431              MOUNT_DIR,
432              DIRECTORY_NAMES_INVALID[index] );
433    rc = mkdir( dirname, S_IRWXU | S_IRWXG | S_IRWXO );
434    rtems_test_assert( rc == -1 );
435  }
436}
437
438/*
439 * Try creating directories which do already exist
440 * (although names may have different capitalization/encoding)
441 */
442static void test_creating_duplicate_directories(
443  const char            *start_dir,
444  const name_duplicates *duplicates,
445  const unsigned int     number_of_duplicates )
446{
447  unsigned int index_dir;
448  unsigned int index_duplicate;
449  int          rc;
450  char         dirname[MAX_NAME_LENGTH + MOUNT_DIR_SIZE + START_DIR_SIZE + 2];
451
452
453  for ( index_dir = 0; index_dir < number_of_duplicates; ++index_dir ) {
454    snprintf( dirname, sizeof( dirname ), "%s/%s", start_dir,
455              duplicates[index_dir].name );
456    rc = mkdir( dirname, S_IRWXU | S_IRWXG | S_IRWXO );
457    rtems_test_assert( rc == 0 );
458
459    for ( index_duplicate = 0;
460          index_duplicate < duplicates[index_dir].number_of_duplicates;
461          ++index_duplicate ) {
462      snprintf( dirname, sizeof( dirname ), "%s/%s", start_dir,
463                duplicates[index_dir].name_duplicates[index_duplicate] );
464      errno = 0;
465      rc = mkdir( dirname, S_IRWXU | S_IRWXG | S_IRWXO );
466      rtems_test_assert( rc == -1 );
467      rtems_test_assert( errno == EEXIST );
468    }
469  }
470}
471
472/*
473 * Try creating and opening files with valid names
474 */
475static void test_handling_files(
476  const char        *dirname,
477  const char        *file_names,
478  const unsigned int number_of_files )
479{
480  unsigned int index;
481  int          rc;
482  char         filename[MAX_NAME_LENGTH * 2 + MOUNT_DIR_SIZE + START_DIR_SIZE
483                        + 4];
484  int          fd;
485
486
487  for ( index = 0; index < number_of_files; ++index ) {
488    snprintf(
489      filename,
490      sizeof( filename ) - 1,
491      "%s/%s",
492      dirname,
493      file_names + index * MAX_NAME_LENGTH );
494    fd = open( filename,
495               O_RDWR | O_CREAT,
496               S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
497    rtems_test_assert( fd >= 0 );
498
499    rc = close( fd );
500    rtems_test_assert( rc == 0 );
501
502    /* See if the file still exists and can be found */
503    fd = open( filename, O_RDWR );
504    rtems_test_assert( fd >= 0 );
505
506    rc = close( fd );
507    rtems_test_assert( rc == 0 );
508  }
509}
510
511/*
512 * Try to find (and open) all of the file names from an
513 * array in a given directory
514 */
515static void test_finding_files(
516  const char        *dirname,
517  const char        *file_names,
518  const unsigned int number_of_files )
519{
520  int            rc;
521  DIR           *dir_stream;
522  struct dirent *dp;
523  int            fd;
524  unsigned int   index_file;
525  char           filename[MAX_NAME_LENGTH * 2 + MOUNT_DIR_SIZE
526                          + START_DIR_SIZE + 4];
527
528
529  dir_stream = opendir( dirname );
530  rtems_test_assert( dir_stream != NULL );
531
532  dp = readdir( dir_stream );
533  rtems_test_assert( dp != NULL );
534  rtems_test_assert( 0 == strcmp( ".", dp->d_name ) );
535
536  dp = readdir( dir_stream );
537  rtems_test_assert( dp != NULL );
538  rtems_test_assert( 0 == strcmp( "..", dp->d_name ) );
539
540  dp         = readdir( dir_stream );
541  rtems_test_assert( dp != NULL );
542  index_file = 0;
543
544  while ( dp != NULL ) {
545    rtems_test_assert( 0 == strcmp(
546                         file_names + index_file * MAX_NAME_LENGTH,
547                         dp->d_name ) );
548
549    snprintf(
550      filename,
551      sizeof( filename ) - 1,
552      "%s/%s",
553      dirname,
554      file_names + index_file * MAX_NAME_LENGTH );
555
556    /* See if the file still exists and can be found */
557    fd = open( filename, O_RDWR );
558    rtems_test_assert( fd >= 0 );
559
560    rc = close( fd );
561    rtems_test_assert( rc == 0 );
562
563    ++index_file;
564    dp = readdir( dir_stream );
565  }
566
567  rtems_test_assert( number_of_files == index_file );
568
569  rc = closedir( dir_stream );
570  rtems_test_assert( rc == 0 );
571}
572
573/*
574 * Try opening files which do already exist (with different capitalization in their names)
575 */
576static void test_duplicated_files( const char *dirname,
577  const name_duplicates                       *files_duplicated,
578  const unsigned int                           number_of_files_duplicated )
579{
580  unsigned int index_file;
581  unsigned int index_duplicate;
582  int          rc;
583  char         filename[MAX_NAME_LENGTH + strlen( dirname ) + 1];
584  int          fd;
585
586
587  for ( index_file = 0; index_file < number_of_files_duplicated;
588        ++index_file ) {
589    snprintf( filename,
590              sizeof( filename ) - 1,
591              "%s/%s",
592              dirname,
593              files_duplicated[index_file].name );
594    fd = open( filename,
595               O_RDWR | O_CREAT,
596               S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
597    rtems_test_assert( fd >= 0 );
598
599    rc = close( fd );
600    rtems_test_assert( rc == 0 );
601
602    for ( index_duplicate = 0;
603          index_duplicate < files_duplicated[index_file].number_of_duplicates;
604          ++index_duplicate ) {
605      snprintf( filename,
606                sizeof( filename ) - 1,
607                "%s/%s",
608                dirname,
609                files_duplicated[index_file].name_duplicates[index_duplicate] );
610      fd = open( filename, O_RDWR );
611      rtems_test_assert( fd >= 0 );
612
613      rc = close( fd );
614      rtems_test_assert( rc == 0 );
615
616      errno = 0;
617      fd = open( filename, O_RDWR | O_CREAT | O_EXCL );
618      rtems_test_assert( fd == -1 );
619      rtems_test_assert( errno == EEXIST );
620    }
621
622    rc = remove( filename );
623    rtems_test_assert( rc == 0 );
624  }
625}
626
627/*
628 * Open and read existing valid directories
629 */
630static void test_handling_directories(
631  const char        *start_dir,
632  const char        *directory_names,
633  const unsigned int number_of_directories,
634  const char        *file_names,
635  const unsigned int number_of_files )
636{
637  unsigned int   index_directory;
638  unsigned int   index_file;
639  int            rc;
640  DIR           *dir_stream;
641  char           dirname[MAX_NAME_LENGTH * 2];
642  struct dirent *dp;
643
644
645  for ( index_directory = 0;
646        index_directory < number_of_directories;
647        ++index_directory ) {
648    snprintf(
649      dirname,
650      sizeof( dirname ) - 1,
651      "%s/%s",
652      start_dir,
653      directory_names + index_directory * MAX_NAME_LENGTH );
654
655    test_handling_files(
656      dirname,
657      file_names,
658      number_of_files );
659
660    dir_stream = opendir( dirname );
661    rtems_test_assert( dir_stream != NULL );
662
663    dp = readdir( dir_stream );
664    rtems_test_assert( dp != NULL );
665    rtems_test_assert( 0 == strcmp( ".", dp->d_name ) );
666
667    dp = readdir( dir_stream );
668    rtems_test_assert( dp != NULL );
669    rtems_test_assert( 0 == strcmp( "..", dp->d_name ) );
670
671    dp         = readdir( dir_stream );
672    rtems_test_assert( dp != NULL );
673    index_file = 0;
674
675    while ( dp != NULL ) {
676      rtems_test_assert( 0 == strcmp(
677                           file_names + index_file * MAX_NAME_LENGTH,
678                           dp->d_name ) );
679      ++index_file;
680      dp = readdir( dir_stream );
681    }
682
683    rtems_test_assert( number_of_files == index_file );
684
685    rc = closedir( dir_stream );
686    rtems_test_assert( rc == 0 );
687  }
688}
689
690/*
691 * Try to find all sub-directories from an array
692 * in a given start directory.
693 * In addition try to find and open files
694 * in these sub-directories.
695 */
696static void test_finding_directories(
697  const char        *start_dir,
698  const char        *directory_names,
699  const unsigned int number_of_directories,
700  const char        *file_names,
701  const unsigned int number_of_files )
702{
703  unsigned int   index_directory;
704  int            rc;
705  DIR           *dir_stream;
706  struct dirent *dp;
707  char           dirname[MAX_NAME_LENGTH * 2];
708
709
710  dir_stream = opendir( start_dir );
711  rtems_test_assert( dir_stream != NULL );
712
713  dp = readdir( dir_stream );
714  rtems_test_assert( dp != NULL );
715  rtems_test_assert( 0 == strcmp( ".", dp->d_name ) );
716
717  dp = readdir( dir_stream );
718  rtems_test_assert( dp != NULL );
719  rtems_test_assert( 0 == strcmp( "..", dp->d_name ) );
720
721  dp              = readdir( dir_stream );
722  rtems_test_assert( dp != NULL );
723  index_directory = 0;
724
725  while ( dp != NULL ) {
726    rtems_test_assert( 0 == strcmp(
727                         directory_names + index_directory * MAX_NAME_LENGTH,
728                         dp->d_name ) );
729
730    snprintf(
731      dirname,
732      sizeof( dirname ) - 1,
733      "%s/%s",
734      start_dir,
735      directory_names + index_directory * MAX_NAME_LENGTH );
736
737    test_finding_files(
738      dirname,
739      file_names,
740      number_of_files );
741
742    ++index_directory;
743    dp = readdir( dir_stream );
744  }
745
746  rtems_test_assert( number_of_directories == index_directory );
747
748  rc = closedir( dir_stream );
749  rtems_test_assert( rc == 0 );
750}
751
752#if (PRINT_DISK_IMAGE != 0)
753static void print_image(
754  const char* include_guard,
755  const char* image_name
756)
757{
758  #define                   BYTES_PER_ROW     8
759  int                       rc;
760  int                       fd;
761  ssize_t                   bytes_read;
762  uint8_t                   buf[BLOCK_SIZE];
763  unsigned int              index_block;
764  unsigned int              index_row;
765  unsigned int              index_column;
766  unsigned int              index_buf;
767#ifdef SHOW_LINE_NUMBERS
768  size_t                    index_row_start = 1;
769#endif /* SWOW_LINE_NUMBERS */
770  size_t                    bytes_written   = 0;
771  const size_t              DISK_SIZE       = BLOCK_SIZE * BLOCK_NUM;
772  const unsigned int        ROWS_PER_BLOCK  = BLOCK_SIZE / BYTES_PER_ROW;
773
774  printf ("/*\n"
775          " *  Declarations for C structure representing a disk image\n"
776          " *\n"
777          " *  WARNING: Automatically generated by init.c -- do not edit!\n"
778          " */\n"
779          "#ifndef %s\n"
780          "#define %s\n"
781          "\n"
782          "#include <sys/types.h>\n"
783          "\n"
784          "#ifdef __cplusplus\n"
785          "extern \"C\" {\n"
786          "#endif /* __cplusplus */\n"
787          "\n"
788          "static unsigned char %s[] = {\n",
789          include_guard,
790          include_guard,
791          image_name);
792  fd = open( RAMDISK_PATH, O_RDWR );
793  rtems_test_assert( fd >= 0 );
794
795  for ( index_block = 0; index_block < BLOCK_NUM; ++index_block )
796  {
797    bytes_read = read( fd, &buf[0], BLOCK_SIZE );
798    rtems_test_assert( bytes_read = BLOCK_SIZE );
799
800    index_buf = 0;
801
802    for ( index_row = 0; index_row < ROWS_PER_BLOCK; ++index_row )
803    {
804      printf( "  " );
805      for ( index_column = 0;
806            index_column < BYTES_PER_ROW;
807            ++index_column ) {
808        printf("0x%02x", buf[index_buf]);
809        ++bytes_written;
810        ++index_buf;
811        if ( bytes_written < DISK_SIZE ) {
812          printf (", ");
813        } else {
814          printf ("  ");
815        }
816      }
817#ifdef SHOW_LINE_NUMBERS
818      printf( "/* %6u - %6u */", index_row_start, bytes_written );
819      index_row_start = bytes_written + 1;
820#endif /* SWOW_LINE_NUMBERS */
821      printf( "\n" );
822    }
823  }
824
825  rc = close( fd );
826  rtems_test_assert( rc == 0 );
827
828  printf ("};\n"
829          "#ifdef __cplusplus\n"
830          "}\n"
831          "#endif /* __cplusplus */\n"
832          "\n"
833          "#endif /* %s */\n",
834          include_guard);
835}
836#else /* PRINT_DISK_IMAGE */
837static void print_image(
838  const char* include_guard,
839  const char* image_name
840)
841{
842  /* Nothing to be done */
843}
844#endif /* PRINT_DISK_IMAGE */
845
846
847static void compare_files(
848  const char *file0,
849  const char *file1
850)
851{
852  struct stat  stat_buf[2];
853  int          fd[2];
854  unsigned int index;
855  uint8_t      buf[2];
856  ssize_t      bytes_read;
857  int          rc;
858
859  rc = stat( file0 , &stat_buf[0] );
860  rtems_test_assert( rc == 0 );
861  rc = stat( file1 , &stat_buf[1] );
862  rtems_test_assert( rc == 0 );
863
864  rtems_test_assert( stat_buf[0].st_size == stat_buf[1].st_size );
865
866  fd[0] = open( file0, O_RDONLY );
867  rtems_test_assert( fd[0] > 0 );
868  fd[1] = open( file1, O_RDONLY );
869  rtems_test_assert( fd[1] > 0 );
870
871  for ( index = 0; index < stat_buf[0].st_size; ++index ) {
872    bytes_read = read( fd[0], &buf[0], 1 );
873    rtems_test_assert( bytes_read == 1 );
874    bytes_read = read( fd[1], &buf[1], 1 );
875    rtems_test_assert( bytes_read == 1 );
876    rtems_test_assert( buf[0] == buf[1] );
877  }
878  rc = close( fd[0] );
879  rtems_test_assert( rc == 0 );
880  rc = close( fd[1] );
881  rtems_test_assert( rc == 0 );
882}
883
884static void compare_directories(
885  const char *dir0,
886  const char *dir1)
887{
888  int                       rc;
889  DIR                      *dir_stream[2];
890  struct dirent            *dp;
891  struct stat               stat_buf[2];
892  char                     *path[2];
893  const unsigned int        PATH_LENGTH = 1024;
894
895  path[0] = calloc( PATH_LENGTH, sizeof(char) );
896  rtems_test_assert( path[0] != NULL );
897  path[1] = calloc( PATH_LENGTH, sizeof(char) );
898  rtems_test_assert( path[1] != NULL );
899
900  dir_stream[0] = opendir( dir0 );
901  rtems_test_assert( dir_stream[0] != NULL );
902
903  dir_stream[1] = opendir( dir1 );
904  rtems_test_assert( dir_stream[1] != NULL );
905
906  dp = readdir( dir_stream[0] );
907  rtems_test_assert( dp != NULL );
908
909  while ( dp != NULL ) {
910    rc = snprintf(path[0], PATH_LENGTH, "%s/%s", dir0, dp->d_name);
911    rtems_test_assert( rc < PATH_LENGTH );
912    rtems_test_assert( rc >= 0 );
913    rc = snprintf(path[1], PATH_LENGTH, "%s/%s", dir1, dp->d_name);
914    rtems_test_assert( rc < PATH_LENGTH );
915    rtems_test_assert( rc >= 0 );
916
917    rc = stat( path[0] , &stat_buf[0] );
918    rtems_test_assert( rc == 0 );
919
920    if (   ( strcmp( dp->d_name, "."  ) != 0)
921        && ( strcmp( dp->d_name, ".." ) != 0) ) {
922      if ( S_ISDIR( stat_buf[0].st_mode ) ) {
923        compare_directories( path[0], path[1] );
924      } else {
925        compare_files( path[0], path[1] );
926      }
927    }
928
929    dp = readdir( dir_stream[0] );
930
931  }
932  rc = closedir( dir_stream[0] );
933  rtems_test_assert( rc == 0 );
934
935  rc = closedir( dir_stream[1] );
936  rtems_test_assert( rc == 0 );
937
938  free (path[0]);
939  free (path[1]);
940}
941
942static void compare_image(
943  const char                      *mount_dir,
944  const char                      *dev,
945  const rtems_dosfs_mount_options *mount_opts )
946{
947  #define MOUNT_DIR2 "/mnt2"
948  int                       rc;
949
950  rc = mount_and_make_target_path(
951    dev,
952    MOUNT_DIR2,
953    RTEMS_FILESYSTEM_TYPE_DOSFS,
954    RTEMS_FILESYSTEM_READ_WRITE,
955    mount_opts );
956  rtems_test_assert( rc == 0 );
957
958  compare_directories(mount_dir, MOUNT_DIR2);
959
960  rc = unmount( MOUNT_DIR2 );
961  rtems_test_assert( rc == 0 );
962
963  rc = rmdir( MOUNT_DIR2 );
964  rtems_test_assert( rc == 0 );
965
966}
967/*
968 * Test the compatibility with a genuine MS Windows FAT file system.
969 */
970static void test_compatibility( void )
971{
972  int                       rc;
973  char                      diskpath[] = "/dev/rdd";
974  rtems_dosfs_mount_options mount_opts;
975  FILE                     *fp;
976  int                       buffer;
977  unsigned int              index_file = 0;
978  unsigned int              index_char;
979  unsigned int              offset;
980  char                      content_buf[MAX_NAME_LENGTH + strlen( MOUNT_DIR )
981                                        + 1];
982  char                      file_path[MAX_NAME_LENGTH + strlen( MOUNT_DIR )
983                                      + 1];
984  DIR                      *dir_stream;
985  struct dirent            *dp;
986
987
988  mount_opts.converter = rtems_dosfs_create_utf8_converter( "CP850" );
989  rtems_test_assert( mount_opts.converter != NULL );
990
991  rc = mount_and_make_target_path(
992    diskpath,
993    MOUNT_DIR,
994    RTEMS_FILESYSTEM_TYPE_DOSFS,
995    RTEMS_FILESYSTEM_READ_WRITE,
996    &mount_opts );
997  rtems_test_assert( rc == 0 );
998
999  dir_stream = opendir( MOUNT_DIR );
1000  rtems_test_assert( dir_stream != NULL );
1001
1002  dp = readdir( dir_stream );
1003  rtems_test_assert( dp != NULL );
1004
1005  while ( dp != NULL ) {
1006    index_char = 0;
1007
1008    size_t len = strlen( filenames[index_file] );
1009
1010    if ( filenames[index_file][len - 1] == '.' )
1011      rtems_test_assert( ( len - 1 ) == dp->d_namlen );
1012    else
1013      rtems_test_assert( len == dp->d_namlen );
1014
1015    rtems_test_assert( 0
1016                       == memcmp( &filenames[index_file][0], &dp->d_name[0],
1017                                  dp->d_namlen ) );
1018
1019    snprintf( file_path, sizeof( file_path ), "%s/%s", MOUNT_DIR,
1020              filenames[index_file] );
1021    fp = fopen( file_path, "r" );
1022    rtems_test_assert( fp != NULL );
1023
1024    /* These files should contain their own file names. */
1025    while ( ( buffer = fgetc( fp ) ) != EOF ) {
1026      content_buf[index_char] = buffer;
1027      ++index_char;
1028    }
1029
1030    if ( 0 == strncmp( content_buf, UTF8_BOM, UTF8_BOM_SIZE ) )
1031      offset = UTF8_BOM_SIZE;
1032    else
1033      offset = 0;
1034
1035    rtems_test_assert( 0
1036                       == memcmp( filenames[index_file],
1037                                  &content_buf[offset],
1038                                  index_char - offset ) );
1039
1040    rc = fclose( fp );
1041    rtems_test_assert( rc == 0 );
1042
1043    ++index_file;
1044    dp = readdir( dir_stream );
1045  }
1046
1047  rtems_test_assert( index_file == FILES_FILENAMES_NUMBER_OF );
1048
1049  rc = closedir( dir_stream );
1050  rtems_test_assert( rc == 0 );
1051
1052  rc = unmount( MOUNT_DIR );
1053  rtems_test_assert( rc == 0 );
1054}
1055
1056static void test_end_of_string_matches( void )
1057{
1058  int rc;
1059
1060  rc = mkdir( MOUNT_DIR "/lib.beam", S_IRWXU | S_IRWXG | S_IRWXO );
1061  rtems_test_assert( rc == 0 );
1062
1063  errno = 0;
1064  rc = unlink( MOUNT_DIR "/proc_lib.beam" );
1065  rtems_test_assert( rc == -1 );
1066  rtems_test_assert( errno == ENOENT );
1067
1068  rc = unlink( MOUNT_DIR "/lib.beam" );
1069  rtems_test_assert( rc == 0 );
1070}
1071
1072static void test_end_of_string_matches_2( void )
1073{
1074  int rc;
1075  int fd;
1076
1077  fd = open( MOUNT_DIR "/ets.beam", O_RDWR | O_CREAT,
1078             S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
1079  rtems_test_assert( fd >= 0 );
1080  rc = close( fd );
1081  rtems_test_assert( rc == 0 );
1082
1083  fd = open( MOUNT_DIR "/sets.beam", O_RDWR | O_CREAT,
1084             S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
1085  rtems_test_assert( fd >= 0 );
1086  rc = close( fd );
1087  rtems_test_assert( rc == 0 );
1088
1089  rc = unlink( MOUNT_DIR "/sets.beam" );
1090  rtems_test_assert( rc == 0 );
1091
1092  rc = unlink( MOUNT_DIR "/ets.beam" );
1093  rtems_test_assert( rc == 0 );
1094}
1095
1096static void test_full_8_3_name( void )
1097{
1098  int rc;
1099
1100  rc = mkdir( MOUNT_DIR "/txtvsbin.txt", S_IRWXU | S_IRWXG | S_IRWXO );
1101  rtems_test_assert( rc == 0 );
1102
1103  rc = unlink( MOUNT_DIR "/txtvsbin.txt" );
1104  rtems_test_assert( rc == 0 );
1105}
1106
1107static void test_dir_with_same_name_as_volume_label( void )
1108{
1109  int  rc;
1110  DIR *dirp;
1111
1112  rc = mkdir( MOUNT_DIR "/" VOLUME_LABEL, S_IRWXU | S_IRWXG | S_IRWXO );
1113  rtems_test_assert( rc == 0 );
1114
1115  dirp = opendir( MOUNT_DIR "/" VOLUME_LABEL );
1116  rtems_test_assert( NULL != dirp );
1117
1118  rc = closedir( dirp );
1119  rtems_test_assert( rc == 0 );
1120
1121  rc = unlink( MOUNT_DIR "/" VOLUME_LABEL );
1122  rtems_test_assert( rc == 0 );
1123}
1124
1125static void test_file_with_same_name_as_volume_label( void )
1126{
1127  int rc;
1128  int fd;
1129
1130  fd = open( MOUNT_DIR "/" VOLUME_LABEL, O_RDWR | O_CREAT,
1131             S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
1132  rtems_test_assert( fd >= 0 );
1133
1134  rc = close( fd );
1135  rtems_test_assert( rc == 0 );
1136
1137  fd = open( MOUNT_DIR "/" VOLUME_LABEL, O_RDWR );
1138  rtems_test_assert( fd >= 0 );
1139
1140  rc = close( fd );
1141  rtems_test_assert( rc == 0 );
1142
1143  rc = unlink( MOUNT_DIR "/" VOLUME_LABEL );
1144  rtems_test_assert( rc == 0 );
1145}
1146
1147static void test_getcwd( void )
1148{
1149  const char *dir_path = MOUNT_DIR "/somedir";
1150  char cwd_buf[128];
1151  char *cwd;
1152  int rc;
1153  rtems_status_code sc;
1154
1155  sc = rtems_libio_set_private_env();
1156  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
1157
1158  cwd = getcwd( cwd_buf, sizeof( cwd_buf ) );
1159  rtems_test_assert( cwd != NULL );
1160  rtems_test_assert( strcmp( cwd, "/" ) == 0 );
1161
1162  rc = mkdir( dir_path, S_IRWXU | S_IRWXG | S_IRWXO );
1163  rtems_test_assert( rc == 0 );
1164
1165  rc = chdir( dir_path );
1166  rtems_test_assert( rc == 0 );
1167
1168  cwd = getcwd( cwd_buf, sizeof( cwd_buf ) );
1169  rtems_test_assert( cwd != NULL );
1170  rtems_test_assert( strcmp( cwd, dir_path ) == 0 );
1171
1172  rc = chdir( "/" );
1173  rtems_test_assert( rc == 0 );
1174
1175  rc = unlink( dir_path );
1176  rtems_test_assert( rc == 0 );
1177
1178  cwd = getcwd( cwd_buf, sizeof( cwd_buf ) );
1179  rtems_test_assert( cwd != NULL );
1180  rtems_test_assert( strcmp( cwd, "/" ) == 0 );
1181
1182  rtems_libio_use_global_env();
1183}
1184
1185static void test_special_cases( void )
1186{
1187  test_end_of_string_matches();
1188  test_end_of_string_matches_2();
1189  test_full_8_3_name();
1190  test_file_with_same_name_as_volume_label();
1191  test_dir_with_same_name_as_volume_label();
1192  test_getcwd();
1193}
1194
1195/*
1196 * Main test method
1197 */
1198static void test( void )
1199{
1200  int  rc;
1201  char start_dir[MOUNT_DIR_SIZE + START_DIR_SIZE + 2];
1202  rtems_dosfs_mount_options mount_opts[2];
1203
1204  rc = mkdir( MOUNT_DIR, S_IRWXU | S_IRWXG | S_IRWXO );
1205  rtems_test_assert( rc == 0 );
1206
1207  snprintf( start_dir, sizeof( start_dir ), "%s/%s", MOUNT_DIR, "strt" );
1208
1209  /*
1210   * Tests with code page 850 compatible directory and file names
1211   * and the code page 850 backwards compatible default mode mode of the
1212   * FAT file system
1213   */
1214  mount_device_with_defaults( start_dir );
1215
1216  test_creating_duplicate_directories(
1217    &start_dir[0],
1218    &DIRECTORY_DUPLICATES[0],
1219    NUMBER_OF_DIRECTORIES_DUPLICATED );
1220
1221  unmount_and_close_device();
1222
1223  mount_device_with_defaults( start_dir );
1224
1225  test_duplicated_files(
1226    MOUNT_DIR,
1227    FILES_DUPLICATES,
1228    NUMBER_OF_FILES_DUPLICATED );
1229
1230  unmount_and_close_device();
1231
1232  mount_device_with_defaults( start_dir );
1233
1234  test_creating_invalid_directories();
1235
1236  test_creating_directories(
1237    &start_dir[0],
1238    &DIRECTORY_NAMES[0][0],
1239    NUMBER_OF_DIRECTORIES );
1240
1241  test_handling_directories(
1242    &start_dir[0],
1243    &DIRECTORY_NAMES[0][0],
1244    NUMBER_OF_DIRECTORIES,
1245    &FILE_NAMES[0][0],
1246    NUMBER_OF_FILES );
1247
1248  compare_image(
1249    MOUNT_DIR,
1250    "/dev/rdb",
1251    NULL);
1252
1253  test_special_cases();
1254
1255  rc = unmount( MOUNT_DIR );
1256  rtems_test_assert( rc == 0 );
1257
1258  /*
1259   * Again tests with code page 850 compatible directory and file names
1260   * but with multibyte string compatible conversion methods which use
1261   * iconv and utf8proc
1262   */
1263  mount_opts[0].converter = rtems_dosfs_create_utf8_converter( "CP850" );
1264  rtems_test_assert( mount_opts[0].converter != NULL );
1265
1266  rc                     = mount(
1267    RAMDISK_PATH,
1268    MOUNT_DIR,
1269    "dosfs",
1270    RTEMS_FILESYSTEM_READ_WRITE,
1271    &mount_opts );
1272  rtems_test_assert( rc == 0 );
1273
1274  test_finding_directories(
1275    &start_dir[0],
1276    &DIRECTORY_NAMES[0][0],
1277    NUMBER_OF_DIRECTORIES,
1278    &FILE_NAMES[0][0],
1279    NUMBER_OF_FILES );
1280  unmount_and_close_device();
1281
1282  mount_device_with_iconv( start_dir, &mount_opts[0] );
1283  test_creating_invalid_directories();
1284
1285  test_creating_duplicate_directories(
1286    &start_dir[0],
1287    &DIRECTORY_DUPLICATES[0],
1288    NUMBER_OF_DIRECTORIES_DUPLICATED );
1289
1290  unmount_and_close_device();
1291
1292  mount_device_with_iconv( start_dir, &mount_opts[0] );
1293
1294  test_duplicated_files(
1295    MOUNT_DIR,
1296    FILES_DUPLICATES,
1297    NUMBER_OF_FILES_DUPLICATED );
1298
1299  unmount_and_close_device();
1300
1301  mount_device_with_iconv( start_dir, &mount_opts[0] );
1302
1303  test_creating_directories(
1304    &start_dir[0],
1305    &DIRECTORY_NAMES[0][0],
1306    NUMBER_OF_DIRECTORIES );
1307
1308  test_handling_directories(
1309    &start_dir[0],
1310    &DIRECTORY_NAMES[0][0],
1311    NUMBER_OF_DIRECTORIES,
1312    &FILE_NAMES[0][0],
1313    NUMBER_OF_FILES );
1314
1315  mount_opts[1].converter = rtems_dosfs_create_utf8_converter( "CP850" );
1316  rtems_test_assert( mount_opts[1].converter != NULL );
1317
1318  compare_image(
1319    MOUNT_DIR,
1320    "/dev/rdb",
1321    &mount_opts[1]);
1322
1323  test_special_cases();
1324
1325  rc = unmount( MOUNT_DIR );
1326  rtems_test_assert( rc == 0 );
1327
1328  print_image(
1329      "IMAGE_BIN_LE_SINGLEBYTE_H_",
1330      "IMAGE_BIN_LE_SINGLEBYTE");
1331
1332  rc = mount(
1333    RAMDISK_PATH,
1334    MOUNT_DIR,
1335    "dosfs",
1336    RTEMS_FILESYSTEM_READ_WRITE,
1337    NULL );
1338  rtems_test_assert( rc == 0 );
1339
1340  unmount_and_close_device();
1341
1342
1343  /*
1344   * Tests with multibyte directory and file names and
1345   * with multibyte string compatible conversion methods which use
1346   * iconv and utf8proc
1347   */
1348  mount_device_with_iconv( start_dir, &mount_opts[0] );
1349
1350  test_creating_duplicate_directories(
1351    &start_dir[0],
1352    &MULTIBYTE_DUPLICATES[0],
1353    NUMBER_OF_MULTIBYTE_NAMES_DUPLICATED );
1354
1355  unmount_and_close_device();
1356
1357  mount_device_with_iconv( start_dir, &mount_opts[0] );
1358
1359  test_duplicated_files(
1360    MOUNT_DIR,
1361    &MULTIBYTE_DUPLICATES[0],
1362    NUMBER_OF_MULTIBYTE_NAMES_DUPLICATED );
1363
1364  unmount_and_close_device();
1365
1366  mount_device_with_iconv( start_dir, &mount_opts[0] );
1367
1368  test_creating_directories(
1369    &start_dir[0],
1370    &NAMES_MULTIBYTE[0][0],
1371    NUMBER_OF_NAMES_MULTIBYTE );
1372
1373  test_handling_directories(
1374    &start_dir[0],
1375    &NAMES_MULTIBYTE[0][0],
1376    NUMBER_OF_NAMES_MULTIBYTE,
1377    &NAMES_MULTIBYTE[0][0],
1378    NUMBER_OF_NAMES_MULTIBYTE );
1379
1380  mount_opts[1].converter = rtems_dosfs_create_utf8_converter( "CP850" );
1381  rtems_test_assert( mount_opts[1].converter != NULL );
1382
1383  compare_image(
1384    MOUNT_DIR,
1385    "/dev/rdc",
1386    &mount_opts[1]);
1387
1388  test_special_cases();
1389
1390  rc = unmount( MOUNT_DIR );
1391  rtems_test_assert( rc == 0 );
1392
1393  print_image(
1394    "IMAGE_BIN_LE_MULTIBYTE_H_",
1395    "IMAGE_BIN_LE_MULTIBYTE");
1396
1397  rc = mount(
1398    RAMDISK_PATH,
1399    MOUNT_DIR,
1400    "dosfs",
1401    RTEMS_FILESYSTEM_READ_WRITE,
1402    NULL );
1403  rtems_test_assert( rc == 0 );
1404
1405  test_finding_directories(
1406    &start_dir[0],
1407    &NAMES_MULTIBYTE_IN_CODEPAGE_FORMAT[0][0],
1408    NUMBER_OF_NAMES_MULTIBYTE,
1409    &NAMES_MULTIBYTE_IN_CODEPAGE_FORMAT[0][0],
1410    NUMBER_OF_NAMES_MULTIBYTE );
1411
1412  unmount_and_close_device();
1413
1414  test_compatibility();
1415}
1416
1417static void Init( rtems_task_argument arg )
1418{
1419  TEST_BEGIN();
1420
1421  test();
1422
1423  TEST_END();
1424  rtems_test_exit( 0 );
1425}
1426
1427rtems_ramdisk_config rtems_ramdisk_configuration [] = {
1428  { .block_size = BLOCK_SIZE, .block_num = BLOCK_NUM },
1429  { .block_size = BLOCK_SIZE, .block_num = BLOCK_NUM, .location = &IMAGE_BIN_LE_SINGLEBYTE[0] },
1430  { .block_size = BLOCK_SIZE, .block_num = BLOCK_NUM, .location = &IMAGE_BIN_LE_MULTIBYTE[0] },
1431  { .block_size = BLOCK_SIZE, .block_num = sizeof( image_bin ) / BLOCK_SIZE, .location = image_bin }
1432};
1433
1434size_t rtems_ramdisk_configuration_size = RTEMS_ARRAY_SIZE(rtems_ramdisk_configuration);
1435
1436#define CONFIGURE_INIT_TASK_STACK_SIZE ( 1024 * 64 )
1437#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
1438#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
1439#define CONFIGURE_MAXIMUM_SEMAPHORES (2 * RTEMS_DOSFS_SEMAPHORES_PER_INSTANCE)
1440#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 2
1441#define CONFIGURE_APPLICATION_EXTRA_DRIVERS RAMDISK_DRIVER_TABLE_ENTRY
1442
1443#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
1444
1445#define CONFIGURE_FILESYSTEM_DOSFS
1446
1447/* 2 RAM disk device files + 2 mount_dir + stdin + stdout + stderr +
1448 * 2 for open directories/files  + 4 * 2 for recursive tree compares*/
1449#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS ( 7 + 2 + ( 4 * 2 ) )
1450
1451#define CONFIGURE_MAXIMUM_TASKS 1
1452
1453#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
1454
1455#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
1456
1457#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
1458
1459#define CONFIGURE_INIT
1460
1461#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.