source: rtems/testsuites/psxtests/psxstat/test.c @ 2317457

4.104.115
Last change on this file since 2317457 was 2317457, checked in by Joel Sherrill <joel.sherrill@…>, on 12/08/09 at 17:52:53

2009-12-08 Joel Sherrill <joel.sherrill@…>

  • include/pmacros.h, psx01/task.c, psx02/init.c, psx02/task.c, psx03/init.c, psx03/task.c, psx04/init.c, psx04/task1.c, psx04/task2.c, psx04/task3.c, psx05/init.c, psx05/task.c, psx05/task2.c, psx05/task3.c, psx06/init.c, psx06/task.c, psx06/task2.c, psx07/init.c, psx08/init.c, psx08/task2.c, psx08/task3.c, psx09/init.c, psx10/init.c, psx10/task.c, psx10/task2.c, psx10/task3.c, psx11/init.c, psx11/task.c, psx12/init.c, psxalarm01/init.c, psxbarrier01/test.c, psxcancel01/init.c, psxchroot01/test.c, psxclock/init.c, psxfile01/test.c, psxfile01/test_cat.c, psxfile01/test_extend.c, psxfile01/test_write.c, psxitimer/init.c, psxkey01/task.c, psxkey02/init.c, psxkey03/init.c, psxmount/test.c, psxmsgq01/init.c, psxmsgq03/init.c, psxmsgq04/init.c, psxreaddir/test.c, psxrwlock01/test.c, psxsem01/init.c, psxsignal01/init.c, psxsignal01/task1.c, psxsignal02/init.c, psxsignal03/init.c, psxsignal05/init.c, psxspin01/test.c, psxspin02/test.c, psxstack01/init.c, psxstat/test.c, psxtime/test.c, psxualarm/init.c: Use rtems_test_assert() consistently instead of system assert(). rtems_test_assert() is designed to integrate into the RTEMS test suite infrastructure.
  • Property mode set to 100644
File size: 19.9 KB
Line 
1/*
2 *  This test exercises stat() via fstat() and generates as many of the
3 *  path evaluation cases as possible.
4 *
5 *  COPYRIGHT (c) 1989-2009.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#include <tmacros.h>
16#include <sys/stat.h>
17#include <fcntl.h>
18#include <limits.h>
19#include <stdio.h>
20#include <unistd.h>
21#include <errno.h>
22#include <string.h>
23#include <rtems.h>
24#include <rtems/libio.h>
25#include <rtems/imfs.h>
26#include <pmacros.h>
27
28#define MAXSYMLINK 5   /* There needs to be a better way of getting this. */
29#define TIMEOUT_VALUE  ( 5 * rtems_clock_get_ticks_per_second() )
30
31
32/*
33 *  List of files which should exist.
34 */
35
36char *Files[] = {
37  "/////my_mount_point/dir1/\\//file1\\\\//",
38  "/my_mount_point/dir1/file2",
39  "/my_mount_point/dir1/file3",
40  "/my_mount_point/dir1/file4",
41  "/my_mount_point/dir1/dir1/file1",
42  "../../..//my_mount_point/dir1/./././dir1/ file1",
43  "main.c",
44  0
45};
46
47/*
48 *  List of directories which should exist.
49 */
50
51char *Directories[] = {
52  "/my_mount_point/dir1",
53  "/my_mount_point/dir2",
54  "/my_mount_point/dir3",
55  "/my_mount_point/dir4",
56  "/my_mount_point/dir1/dir1",
57  "/./././my_mount_point/dir1/ dir1",
58  "/./././my_mount_point/links",
59  "///my_mount_point/dir1/dir1/../../dir1/../symlinks/////",
60  0
61};
62
63char *Links_to_Dirs[]= {
64  "dir1/dir1/../../links/dir1",
65  "links/dir2",
66  "links/dir3",
67  "links/dir4",
68  "links/dir1_dir1",
69  "links/dir1_ dir1",
70  "links/../links/../links/links",
71  0
72};
73
74char *Links_to_Files[]= {
75  "links/dir1_file1",
76  "links/dir1_file2",
77  "links/dir1_file3",
78  "links/dir1_file4",
79  "links/dir1_dir1_f1",
80  "links/dir1_dir1 f1",
81  0
82};
83
84char *Links_to_dirlinks[]= {
85  "links/links/links/links_dir1",
86  "links//links_dir2",
87  "links//links_dir3",
88  "links//links_dir4",
89  "links//links_dir1_d1",
90  "links//links_dir1 d1",
91  "links//links_links",
92  0
93};
94
95char *Links_to_filelinks[]= {
96  "links///links_d1_file1",
97  "links///links_d1_file2",
98  "links///links_d1_file3",
99  "links///links_d1_file4",
100  "links///links_d1_d1_f1",
101  "links///links_r1_d1 f1",
102  0
103};
104
105char *SymLinks[]= {
106  "/my_mount_point/symlinks/a_file_symlink",
107  "/my_mount_point/symlinks/a_dir_symlink",
108  "/my_mount_point/symlinks/a_link_symlink",
109  "../symlinks/no_file",
110  "/my_mount_point/symlinks/a_dir_symlink/a_file_symlink",
111  0
112};
113
114/*
115 *  List of absolute paths to stat.
116 */
117
118char *Good_absolute_paths[] = {
119  "/my_mount_point/dev",
120  "////my_mount_point/dir1/\\//file1\\\\//",
121  "/my_mount_point/dir1/\\\\/file2",
122  "/my_mount_point/dir1/file3/////\\\\\\",
123  "/my_mount_point/dir1/file4",
124  "/my_mount_point/dir1/dir1/file1",
125  "/my_mount_point/dir1/dir1/ file1",
126  "/my_mount_point/dir1",
127  "/my_mount_point/dir2//////\\",
128  "/my_mount_point/dir3",
129  "/my_mount_point/dir4",
130  "/my_mount_point/dir1/dir1",
131  "/my_mount_point/dir1/ dir1///\\\\",
132  "/my_mount_point/\\/\\/\\/\\/\\/\\/links\\/\\/\\/\\/\\/\\",
133  0
134};
135
136
137char *Bad_paths[] = {
138  "/my_mount_point/links/ENAMETOOLONG__________________________",
139  "/my_mount_point/dir1/file4/NOTADIR",
140  "/my_mount_point/dir1/dir1/EACCES__",
141  0
142};
143
144/*
145 *  List of relative paths to stat.
146 */
147
148char *Good_relative_paths[] = {
149  "dev",
150  "dir1/\\//file1\\\\//",
151  "dir1/\\\\/file2",
152  "dir1/file3/////\\\\\\",
153  "dir1/file4",
154  "dir1/dir1/file1",
155  "dir1/dir1/ file1",
156  "dir1",
157  "dir2//////\\",
158  "dir3",
159  "dir4",
160  "dir1/dir1",
161  "dir1/ dir1///\\\\",
162  "main.c",
163  0
164};
165
166/*
167 *  Do a stat on a single file and report the status.
168 */
169
170void stat_a_file(
171  const char *file
172)
173{
174  int         status;
175  struct stat statbuf;
176  int         major1;
177  int         minor1;
178  int         major2;
179  int         minor2;
180
181
182  rtems_test_assert( file );
183
184  printf( "stat( %s ) returned ", file );
185  fflush( stdout );
186
187  status = stat( file, &statbuf );
188
189  if ( status == -1 ) {
190    printf( ": %s\n", strerror( errno ) );
191  } else {
192
193    rtems_filesystem_split_dev_t( statbuf.st_dev, major1, minor1 );
194    rtems_filesystem_split_dev_t( statbuf.st_rdev, major2, minor2 );
195
196
197    printf("\n...st_dev     (0x%x:0x%x)\n", major1, minor1 );
198    printf(  "...st_ino     %" PRIxino_t "\n", statbuf.st_ino );
199    printf(  "...st_mode    %o\n", (unsigned int) statbuf.st_mode );
200    printf(  "...st_nlink   %x\n", statbuf.st_nlink );
201    printf(  "...st_uid     %d\n", statbuf.st_uid );
202    printf(  "...st_gid     %d\n", statbuf.st_gid );
203    printf(  "...st_rdev    (0x%x:0x%x)\n", major2, minor2 );
204    printf(  "...st_size    %" PRIdoff_t "\n", statbuf.st_size );
205    printf(  "...st_atime   %s", ctime( &statbuf.st_atime ) );
206    printf(  "...st_mtime   %s", ctime( &statbuf.st_mtime ) );
207    printf(  "...st_ctime   %s", ctime( &statbuf.st_ctime ) );
208    printf(  "...st_blksize %" PRIxblksize_t "\n", statbuf.st_blksize );
209    printf(  "...st_blocks  %" PRIxblkcnt_t "\n", statbuf.st_blocks );
210  }
211}
212
213/*
214 *  stat() multiple files at a time
215 */
216
217void stat_multiple_files(
218  char **files
219)
220{
221  int    i;
222
223  i = 0;
224  while ( files[i] ) {
225    stat_a_file( files[i] );
226    i++;
227  }
228}
229
230/*
231 *  chown() multiple files at a time
232 */
233void chown_multiple_files(
234  char **files
235)
236{
237  int    i;
238  uid_t  st_uid;
239  gid_t  st_gid;
240
241  st_uid = geteuid();
242  st_gid = getegid();
243
244  i = 0;
245  while ( files[i] ) {
246    printf("Change group of %s\n", files[i]);
247    chown( files[i], st_uid, (st_gid+1) );
248    stat_a_file( files[i] );
249
250    printf("Change owner of %s\n", files[i]);
251    chown( files[i], (st_uid+1), st_gid );
252    stat_a_file( files[i] );
253    i++;
254  }
255
256}
257
258
259
260/*
261 *  mknod() multiple files at a time
262 */
263
264void make_multiple_files(
265  char **files
266)
267{
268  int    i;
269  int    status;
270
271  i = 0;
272  while ( files[i] ) {
273    printf( "Making file %s\n", files[i] );
274    status = mknod( files[i], ( S_IFREG | S_IROTH|S_IWOTH ), 0LL );
275    rtems_test_assert( !status );
276    i++;
277  }
278  puts( "" );
279}
280
281void make_multiple_bad_files(
282  char **files
283)
284{
285  int    i;
286  int    status;
287
288  i = 0;
289  while ( files[i] ) {
290    printf( "Making file %s ", files[i] );
291    status = mknod( files[i], ( S_IFREG | S_IROTH|S_IWOTH ), 0LL );
292    rtems_test_assert( status );
293    printf( ": %s\n", strerror( errno ) );
294    i++;
295  }
296  puts( "" );
297}
298
299void make_multiple_links(
300  char **existing,
301  char **new
302)
303{
304  int    i;
305  int    status;
306
307  i = 0;
308  while ( new[i] && existing[i] ) {
309    printf( "Making file %s\n", new[i] );
310    status = link( existing[i], new[i] );
311    rtems_test_assert( !status );
312    i++;
313  }
314  puts( "" );
315
316  status = link( "fred", "bob" );
317  rtems_test_assert( status == -1 );
318
319  status = link( existing[1], "doug/bob" );
320  rtems_test_assert( status == -1 );
321}
322
323
324void make_too_many_links(void)
325{
326  int    i;
327  int    status;
328  char   name [20];
329
330  status = mkdir("/dummy", S_IRWXU );
331  rtems_test_assert( status == 0 );
332
333  for (i=1; i<= LINK_MAX; i++) {
334
335    sprintf(name,"/LinkName%d",i);
336    printf( "Making file %s\n", name );
337    status = link("/dummy" , name );
338    if( i < LINK_MAX )
339       rtems_test_assert( !status );
340    else
341       rtems_test_assert( status == -1 );
342
343  }
344}
345
346
347void make_a_symlink(
348  char *existing,
349  char *new
350)
351{
352  int    status;
353  char   buf[100];
354  int    len;
355
356  memset( buf, 0, 100 );
357
358  printf( "Making file %s\n", new );
359  status = symlink( existing, new );
360  rtems_test_assert( !status );
361
362  printf( "Verify with readlink\n");
363  status = readlink( new, buf, 100 );
364  len = strlen( existing );
365  rtems_test_assert ( status == len );
366
367  status = readlink( new, buf, 3 );
368  len = strlen( existing );
369  if (len < 3 )
370    rtems_test_assert( status == len );
371  else
372    rtems_test_assert( status == 3 );
373
374  status = strcmp( existing, buf );
375  rtems_test_assert( !status );
376}
377
378void make_multiple_symlinks(void)
379{
380 int  status;
381
382 make_a_symlink( Files[0],             SymLinks[0] );
383 make_a_symlink( Directories[0],       SymLinks[1] );
384 make_a_symlink( Links_to_dirlinks[0], SymLinks[2] );
385 make_a_symlink( "No_File",            SymLinks[3] );
386 make_a_symlink( SymLinks[1],          SymLinks[4] );
387 make_a_symlink( "//my_mount_point/links","/my_mount_point/symlinks/links" );
388
389 stat_a_file( SymLinks[0] );
390 stat_a_file( SymLinks[1] );
391 stat_a_file( SymLinks[2] );
392 stat_a_file( SymLinks[3] );
393 stat_a_file( SymLinks[4] );
394
395 status = symlink(  "//links", "bob/frank" );
396 rtems_test_assert (status == -1);
397
398}
399/*
400void make_too_many_symlinks()
401{
402  int  i, status;
403  char name1[8];
404
405  for (i=1; i <= MAXSYMLINK; i++) {
406    sprintf( name1, "SymLink%d", i );
407    status = symlink( "/dummy", name1 );
408    if( i < MAXSYMLINK )
409       rtems_test_assert( !status );
410    else
411       rtems_test_assert( status == -1 );
412  }
413}
414*/
415void make_many_symlinks(
416  char  *real_file,
417  int    link_count
418)
419{
420  int  i;
421  char name1[5];
422  char name2[5];
423  char *link_file;
424
425  link_file = real_file;
426  for (i=1; i < link_count; i++) {
427    sprintf( name1, "%d", i );
428    make_a_symlink( link_file, name1 );
429    strcpy( name2, name1 );
430    link_file = name2;
431  }
432
433  for (i=1; i < link_count; i++) {
434    sprintf( name1, "%d", i );
435    stat_a_file( name1 );
436  }
437
438}
439
440/*
441 *  mkdir() multiple directories at a time
442 */
443
444void make_multiple_directories(
445  char **files
446)
447{
448  int    i;
449  int    status;
450
451  i = 0;
452  while ( files[i] ) {
453    printf( "Making directory %s\n", files[i] );
454    status = mkdir( files[i], S_IRWXU );
455    rtems_test_assert( !status );
456    i++;
457  }
458  puts( "" );
459}
460
461/*
462 * Cause faults.
463 */
464
465
466void Cause_faults(void)
467{
468  int                                   fd;
469  int                                   status;
470  char                                  longer_name[100];
471  rtems_filesystem_mount_table_entry_t *mt_entry;
472
473  /*
474   * Verify chmod with an invalid type.
475   */
476
477#if 0
478  printf("\n\nPass an invalid mode to chmod should fail with EPERM \n" );
479  status = chmod( Files[0], S_IFREG );
480  rtems_test_assert( status == -1 );
481  rtems_test_assert( errno == EPERM );
482#endif
483
484  /*
485   * Change file to executable then try to chdir to it.
486   */
487
488  status = chmod( Files[0], S_IXUSR );
489  rtems_test_assert( status != -1 );
490
491  printf("chdir to a file should fail with ENOTDIR\n");
492  status = chdir( Files[0] );
493  rtems_test_assert( status == -1 );
494  rtems_test_assert( errno == ENOTDIR );
495
496  /*
497   * Change mode to read/write on a directory.
498   * Verify directory works properly.
499   */
500
501  printf("Verify RWX permission on %s via access\n", Directories[0]);
502  status = access( Directories[0], ( R_OK | W_OK | X_OK )  );
503  rtems_test_assert( status == 0 );
504
505  printf( "chmod of %s to Read/Write\n", Directories[0] );
506  status = chmod( Directories[0], (S_IXGRP | S_IXOTH) );
507  rtems_test_assert( status == 0 );
508
509  printf( "chmod fred should fail with ENOENT\n" );
510  status = chmod( "fred", (S_IXGRP | S_IXOTH) );
511  rtems_test_assert( status == -1 );
512  rtems_test_assert( errno == ENOENT );
513
514  strcpy(longer_name, Directories[0] );
515  strcat(longer_name, "/BADNAME" );
516  printf( "Create under %s should fail with EACCES\n", Directories[0] );
517  status = mkdir( longer_name , S_IRWXU );
518  rtems_test_assert( status == -1 );
519  rtems_test_assert( errno == EACCES );
520
521  printf("chdir to %s should fail with EACCES\n", Directories[4] );
522  status = chdir( Directories[4] );
523  rtems_test_assert( status == -1 );
524  rtems_test_assert( errno == EACCES );
525
526  /*
527   * Check stat with a NULL buffer.
528   */
529
530  printf("Stat with a NULL buffer should fail with EFAULT\n");
531  status = stat( Directories[0], NULL );
532  rtems_test_assert( status == -1 );
533  rtems_test_assert( errno == EFAULT );
534
535  /*
536   * Set current to a directory with no owner permissions.
537   * Verify it works properly.
538   */
539
540  printf( "\n\nchmod of %s to Read/Write\n", Directories[0] );
541  status = chmod( Directories[0], (S_IXGRP | S_IXOTH) );
542  rtems_test_assert( status == 0 );
543
544  printf("mkdir %s should fail with EACCESS\n", longer_name );
545  status = mkdir( longer_name , S_IRWXU );
546  rtems_test_assert( status == -1 );
547  rtems_test_assert( errno == EACCES );
548
549  printf("\n%s Should exist ( access )\n",Directories[0] );
550  status = access( Directories[0], F_OK );
551  rtems_test_assert( status == 0 );
552  printf("\n%s Should have read  permission( access )\n",Directories[0] );
553  status = access( Directories[0], R_OK );
554  rtems_test_assert( status != 0 );
555  printf("\n%s Should have write permission( access )\n",Directories[0] );
556  status = access( Directories[0], W_OK );
557  rtems_test_assert( status != 0 );
558  printf("\n%s Should not have execute permission( access )\n",Directories[0] );
559  status = access( Directories[0], X_OK );
560  rtems_test_assert( status != 0 );
561
562  printf("\nRestore %s to RWX\n",Directories[0] );
563  status = chmod( Directories[0], S_IRWXU );
564  rtems_test_assert( status == 0 );
565
566  printf("chdir to /my_mount_point \n");
567  status = chdir( "/my_mount_point" );
568  rtems_test_assert( status == 0 );
569
570  /*
571   * Remove one of the directories.
572   * Verify links to the removed directory still work.
573   */
574
575  printf( "Remove %s\n", Directories[5] );
576  status = rmdir( Directories[5] );
577  rtems_test_assert( status == 0 );
578
579  stat_a_file( Directories[5] );
580  status = access( Directories[5], F_OK );
581  rtems_test_assert( status != 0 );
582
583  stat_a_file( Links_to_Dirs[5] );
584  status = readlink( Links_to_Dirs[5], longer_name, 3 );
585  rtems_test_assert( status == -1 );
586  rtems_test_assert( errno == EINVAL );
587
588  stat_a_file( Links_to_dirlinks[5] );
589  printf("Chdir to %s\n", Links_to_Dirs[5] );
590  status = chdir( Links_to_Dirs[5] );
591  rtems_test_assert( status == 0 );
592
593  /*
594   * Verify we cannot move up from a node with no parent node.
595   */
596
597  printf("Chdir to .. should fail with ENOENT\n" );
598  status = chdir( ".." );
599  rtems_test_assert( status == -1 );
600  rtems_test_assert( errno == ENOENT );
601
602  /*
603   * Create a subdirectory under the dangling node.
604   */
605
606  printf("mkdir ../t should fail with ENOENT\n" );
607  status = mkdir( "../t" , S_IRWXU );
608  rtems_test_assert( status == -1 );
609  rtems_test_assert( errno == ENOENT );
610
611  printf("mkdir t\n");
612  status = mkdir( "t" , S_IRWXU );
613  rtems_test_assert( status == 0 );
614
615  printf("chdir to /my_mount_point\n");
616  status = chdir( "/my_mount_point" );
617  rtems_test_assert( status == 0 );
618
619  /*
620   * Check rmdir, rmnod, and unlink
621   */
622
623  printf("rmdir %s should fail with ENOTDIR\n", Links_to_Dirs[5] );
624  status = rmdir( Links_to_Dirs[5] );
625  rtems_test_assert( status == -1 );
626  rtems_test_assert( errno == ENOTDIR );
627
628  printf("unlink %s\n", Links_to_Dirs[5] );
629  status = unlink( Links_to_Dirs[5] );
630  rtems_test_assert( status == 0 );
631
632  printf("unlink %s should fail with ENOTEMPTY\n", Links_to_dirlinks[5] );
633  status = unlink(  Links_to_dirlinks[5] );
634  rtems_test_assert( status == -1 );
635  rtems_test_assert( errno == ENOTEMPTY );
636
637  strcpy( longer_name,  Links_to_dirlinks[5] );
638  strcat( longer_name, "/t");
639  printf("rmdir %s\n", longer_name );
640  status = rmdir( longer_name );
641  rtems_test_assert( status == 0 );
642
643  printf("unlink %s\n", Links_to_Dirs[5]);
644  status = unlink( Links_to_dirlinks[5] );
645  rtems_test_assert( status == 0 );
646
647  status = chdir( Directories[0] );
648  status = mkdir ( "my_mount_point", S_IRWXU );
649  rtems_test_assert( status == 0 );
650
651  printf("Attempting to mount IMFS file system at /dir1/my_mount_point \n");
652  status = mount(
653     &mt_entry,
654     &IMFS_ops,
655     RTEMS_FILESYSTEM_READ_WRITE,
656     NULL,
657     "/my_mount_point/dir1/my_mount_point" );
658  rtems_test_assert( status == 0 );
659
660  printf("rmdir /dir1/my_mount_point should fail with EBUSY\n");
661  status = rmdir ("/my_mount_point/dir1/my_mount_point" );
662  rtems_test_assert( status == -1 );
663  rtems_test_assert( errno == EBUSY );
664
665  printf( "Unmount /my_mount_point/dir1/my_mount_point\n");
666  status = unmount( "/my_mount_point/dir1/my_mount_point" );
667  rtems_test_assert( status == 0 );
668
669  /*
670   * Verify write permission is checked.
671   */
672
673  printf("chmod of %s to group and other execute\n", Files[0] );
674  status = chmod (Files[0], (S_IXGRP | S_IXOTH) );
675  rtems_test_assert( status == 0 );
676
677  printf("Open %s for write should fail with EACCES\n", Files[0] );
678  fd = open (Files[0], O_WRONLY);
679  rtems_test_assert( fd == -1 );
680  rtems_test_assert( errno == EACCES );
681
682  printf("chmod of %s to User Execute and Read\n", Directories[3] );
683  status = chmod (Directories[3], (S_IXUSR | S_IRUSR) );
684  rtems_test_assert( status == 0 );
685  strcpy(longer_name, Directories[3] );
686  strcat(longer_name, "/NewFile" );
687  printf("Mkdir of %s should fail with EACCES\n",longer_name );
688  status = mkdir( longer_name, S_IRWXU );
689  rtems_test_assert( status != 0 );
690  rtems_test_assert( errno == EACCES );
691
692  printf("Making too many hard links.\n" );
693  make_too_many_links( );
694
695  printf( "pass fstat a null pointer should fail with EFAULT\n");
696  status = fstat( fd, NULL );
697  rtems_test_assert( status == -1 );
698  rtems_test_assert( errno == EFAULT);
699
700  /*
701   * The current directory MUST be restored at the end of this test.
702   */
703
704  printf("chdir to /my_mount_point \n");
705  status = chdir( "/my_mount_point" );
706  rtems_test_assert( status == 0 );
707
708}
709
710void Show_Time(void)
711{
712  rtems_time_of_day time;
713  rtems_status_code status;
714
715  status = rtems_clock_get_tod( &time );
716  printf("--->Current Time: ");
717  print_time( " - rtems_clock_get_tod - ", &time, "\n" );
718}
719
720/*
721 *  main entry point to the test
722 */
723
724#if defined(__rtems__)
725int test_main(void)
726#else
727int main(
728  int    argc,
729  char **argv
730)
731#endif
732{
733  rtems_status_code                    status;
734  rtems_time_of_day                    time;
735  rtems_filesystem_mount_table_entry_t *mt_entry;
736
737  puts( "\n\n*** STAT TEST 01 ***" );
738
739  build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
740  status = rtems_clock_set( &time );
741  Show_Time();
742
743  /*
744   * Create and mount another version of the filesyste.
745   * This allows expected node id's to be consistant across
746   * platforms and bsp's.
747   */
748
749  status = mkdir("/my_mount_point",  S_IRWXU );
750  rtems_test_assert( status == 0 );
751  status = mount(
752     &mt_entry,
753     &IMFS_ops,
754     RTEMS_FILESYSTEM_READ_WRITE,
755     NULL,
756     "my_mount_point" );
757  rtems_test_assert( status == 0 );
758  status = chdir( "/my_mount_point" );
759  rtems_test_assert( status == 0 );
760  status = mkdir("dev",  S_IRWXU );
761  rtems_test_assert( status == 0 );
762
763
764  /*
765   *  Create the files and directories for the test.
766   */
767
768  make_multiple_directories( Directories );
769  make_multiple_files( Files );
770  make_multiple_links( Directories,    Links_to_Dirs );
771  make_multiple_links( Files,          Links_to_Files );
772
773  status = rtems_task_wake_after( TIMEOUT_VALUE );
774  make_multiple_links( Links_to_Dirs,  Links_to_dirlinks );
775  status = rtems_task_wake_after( TIMEOUT_VALUE );
776  make_multiple_links( Links_to_Files, Links_to_filelinks );
777
778  status = rtems_task_wake_after( TIMEOUT_VALUE );
779
780  /*
781   *  Now go through all the absolute path.
782   */
783
784  puts( "Doing the stat() on all the good absolute paths" );
785  stat_multiple_files( Good_absolute_paths );
786
787  /*
788   *  run through the relative paths.
789   */
790
791  puts( "\nDoing the stat() on all the good relative paths" );
792  stat_multiple_files( Good_relative_paths );
793
794  /*
795   * Change directory and releative paths are now bad.
796   */
797
798  puts("\nchdir to dev");
799  chdir("dev");
800  puts("\nstat relative paths that are now bad");
801  stat_multiple_files( Good_relative_paths );
802
803  /*
804   * Change directory to the link directory and follow links.
805   */
806
807  puts("\nchdir to ../links");
808  chdir("../links");
809  puts("Doing the stat() on good links\n");
810  stat_multiple_files( Links_to_Dirs );
811  stat_multiple_files( Links_to_Files );
812  stat_multiple_files( Links_to_dirlinks  );
813  stat_multiple_files( Links_to_filelinks );
814
815  /*
816   * Chmod on dir1/dir1.  This allows the error path to be hit.
817   */
818
819  printf( "chmod of %s to Read/Write\n", Directories[4] );
820  chmod( Directories[4], (S_IROTH|S_IWOTH) );
821  puts( "\nDoing the stat() on all the bad paths" );
822
823  stat_multiple_files( Bad_paths );
824  make_multiple_bad_files( Bad_paths );
825
826  printf( "Return %s to RWX\n", Directories[4] );
827  chmod( Directories[4], S_IRWXU );
828
829
830  /*
831   * Check out symbolic links.
832   */
833
834  make_multiple_symlinks();
835  make_many_symlinks( "/symlinks", 10 );
836
837  status = rtems_task_wake_after( TIMEOUT_VALUE );
838  Cause_faults();
839
840  status = rtems_task_wake_after( TIMEOUT_VALUE );
841  chown_multiple_files( Files );
842
843  status = rtems_task_wake_after( TIMEOUT_VALUE );
844  chown_multiple_files( Links_to_Dirs );
845
846  puts( "\n\n*** END OF STAT TEST 01 ***" );
847  rtems_test_exit(0);
848}
Note: See TracBrowser for help on using the repository browser.