source: rtems/testsuites/psxtests/psxstat/test.c @ 042a442

4.104.115
Last change on this file since 042a442 was 042a442, checked in by Chris Johns <chrisj@…>, on 06/02/10 at 00:50:37

2010-06-02 Chris Johns <chrisj@…>

  • psxfile01/test.c, psxmount/test.c, psxreaddir/test.c, psxstat/test.c: Update to the new mount API.
  • Property mode set to 100644
File size: 19.8 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
472  /*
473   * Verify chmod with an invalid type.
474   */
475
476#if 0
477  printf("\n\nPass an invalid mode to chmod should fail with EPERM \n" );
478  status = chmod( Files[0], S_IFREG );
479  rtems_test_assert( status == -1 );
480  rtems_test_assert( errno == EPERM );
481#endif
482
483  /*
484   * Change file to executable then try to chdir to it.
485   */
486
487  status = chmod( Files[0], S_IXUSR );
488  rtems_test_assert( status != -1 );
489
490  printf("chdir to a file should fail with ENOTDIR\n");
491  status = chdir( Files[0] );
492  rtems_test_assert( status == -1 );
493  rtems_test_assert( errno == ENOTDIR );
494
495  /*
496   * Change mode to read/write on a directory.
497   * Verify directory works properly.
498   */
499
500  printf("Verify RWX permission on %s via access\n", Directories[0]);
501  status = access( Directories[0], ( R_OK | W_OK | X_OK )  );
502  rtems_test_assert( status == 0 );
503
504  printf( "chmod of %s to Read/Write\n", Directories[0] );
505  status = chmod( Directories[0], (S_IXGRP | S_IXOTH) );
506  rtems_test_assert( status == 0 );
507
508  printf( "chmod fred should fail with ENOENT\n" );
509  status = chmod( "fred", (S_IXGRP | S_IXOTH) );
510  rtems_test_assert( status == -1 );
511  rtems_test_assert( errno == ENOENT );
512
513  strcpy(longer_name, Directories[0] );
514  strcat(longer_name, "/BADNAME" );
515  printf( "Create under %s should fail with EACCES\n", Directories[0] );
516  status = mkdir( longer_name , S_IRWXU );
517  rtems_test_assert( status == -1 );
518  rtems_test_assert( errno == EACCES );
519
520  printf("chdir to %s should fail with EACCES\n", Directories[4] );
521  status = chdir( Directories[4] );
522  rtems_test_assert( status == -1 );
523  rtems_test_assert( errno == EACCES );
524
525  /*
526   * Check stat with a NULL buffer.
527   */
528
529  printf("Stat with a NULL buffer should fail with EFAULT\n");
530  status = stat( Directories[0], NULL );
531  rtems_test_assert( status == -1 );
532  rtems_test_assert( errno == EFAULT );
533
534  /*
535   * Set current to a directory with no owner permissions.
536   * Verify it works properly.
537   */
538
539  printf( "\n\nchmod of %s to Read/Write\n", Directories[0] );
540  status = chmod( Directories[0], (S_IXGRP | S_IXOTH) );
541  rtems_test_assert( status == 0 );
542
543  printf("mkdir %s should fail with EACCESS\n", longer_name );
544  status = mkdir( longer_name , S_IRWXU );
545  rtems_test_assert( status == -1 );
546  rtems_test_assert( errno == EACCES );
547
548  printf("\n%s Should exist ( access )\n",Directories[0] );
549  status = access( Directories[0], F_OK );
550  rtems_test_assert( status == 0 );
551  printf("\n%s Should have read  permission( access )\n",Directories[0] );
552  status = access( Directories[0], R_OK );
553  rtems_test_assert( status != 0 );
554  printf("\n%s Should have write permission( access )\n",Directories[0] );
555  status = access( Directories[0], W_OK );
556  rtems_test_assert( status != 0 );
557  printf("\n%s Should not have execute permission( access )\n",Directories[0] );
558  status = access( Directories[0], X_OK );
559  rtems_test_assert( status != 0 );
560
561  printf("\nRestore %s to RWX\n",Directories[0] );
562  status = chmod( Directories[0], S_IRWXU );
563  rtems_test_assert( status == 0 );
564
565  printf("chdir to /my_mount_point \n");
566  status = chdir( "/my_mount_point" );
567  rtems_test_assert( status == 0 );
568
569  /*
570   * Remove one of the directories.
571   * Verify links to the removed directory still work.
572   */
573
574  printf( "Remove %s\n", Directories[5] );
575  status = rmdir( Directories[5] );
576  rtems_test_assert( status == 0 );
577
578  stat_a_file( Directories[5] );
579  status = access( Directories[5], F_OK );
580  rtems_test_assert( status != 0 );
581
582  stat_a_file( Links_to_Dirs[5] );
583  status = readlink( Links_to_Dirs[5], longer_name, 3 );
584  rtems_test_assert( status == -1 );
585  rtems_test_assert( errno == EINVAL );
586
587  stat_a_file( Links_to_dirlinks[5] );
588  printf("Chdir to %s\n", Links_to_Dirs[5] );
589  status = chdir( Links_to_Dirs[5] );
590  rtems_test_assert( status == 0 );
591
592  /*
593   * Verify we cannot move up from a node with no parent node.
594   */
595
596  printf("Chdir to .. should fail with ENOENT\n" );
597  status = chdir( ".." );
598  rtems_test_assert( status == -1 );
599  rtems_test_assert( errno == ENOENT );
600
601  /*
602   * Create a subdirectory under the dangling node.
603   */
604
605  printf("mkdir ../t should fail with ENOENT\n" );
606  status = mkdir( "../t" , S_IRWXU );
607  rtems_test_assert( status == -1 );
608  rtems_test_assert( errno == ENOENT );
609
610  printf("mkdir t\n");
611  status = mkdir( "t" , S_IRWXU );
612  rtems_test_assert( status == 0 );
613
614  printf("chdir to /my_mount_point\n");
615  status = chdir( "/my_mount_point" );
616  rtems_test_assert( status == 0 );
617
618  /*
619   * Check rmdir, rmnod, and unlink
620   */
621
622  printf("rmdir %s should fail with ENOTDIR\n", Links_to_Dirs[5] );
623  status = rmdir( Links_to_Dirs[5] );
624  rtems_test_assert( status == -1 );
625  rtems_test_assert( errno == ENOTDIR );
626
627  printf("unlink %s\n", Links_to_Dirs[5] );
628  status = unlink( Links_to_Dirs[5] );
629  rtems_test_assert( status == 0 );
630
631  printf("unlink %s should fail with ENOTEMPTY\n", Links_to_dirlinks[5] );
632  status = unlink(  Links_to_dirlinks[5] );
633  rtems_test_assert( status == -1 );
634  rtems_test_assert( errno == ENOTEMPTY );
635
636  strcpy( longer_name,  Links_to_dirlinks[5] );
637  strcat( longer_name, "/t");
638  printf("rmdir %s\n", longer_name );
639  status = rmdir( longer_name );
640  rtems_test_assert( status == 0 );
641
642  printf("unlink %s\n", Links_to_Dirs[5]);
643  status = unlink( Links_to_dirlinks[5] );
644  rtems_test_assert( status == 0 );
645
646  status = chdir( Directories[0] );
647  status = mkdir ( "my_mount_point", S_IRWXU );
648  rtems_test_assert( status == 0 );
649
650  printf("Attempting to mount IMFS file system at /dir1/my_mount_point \n");
651  status = mount(
652    "null",
653    "/my_mount_point/dir1/my_mount_point",
654    "imfs",
655     RTEMS_FILESYSTEM_READ_WRITE,
656     NULL );
657  rtems_test_assert( status == 0 );
658
659  printf("rmdir /dir1/my_mount_point should fail with EBUSY\n");
660  status = rmdir ("/my_mount_point/dir1/my_mount_point" );
661  rtems_test_assert( status == -1 );
662  rtems_test_assert( errno == EBUSY );
663
664  printf( "Unmount /my_mount_point/dir1/my_mount_point\n");
665  status = unmount( "/my_mount_point/dir1/my_mount_point" );
666  rtems_test_assert( status == 0 );
667
668  /*
669   * Verify write permission is checked.
670   */
671
672  printf("chmod of %s to group and other execute\n", Files[0] );
673  status = chmod (Files[0], (S_IXGRP | S_IXOTH) );
674  rtems_test_assert( status == 0 );
675
676  printf("Open %s for write should fail with EACCES\n", Files[0] );
677  fd = open (Files[0], O_WRONLY);
678  rtems_test_assert( fd == -1 );
679  rtems_test_assert( errno == EACCES );
680
681  printf("chmod of %s to User Execute and Read\n", Directories[3] );
682  status = chmod (Directories[3], (S_IXUSR | S_IRUSR) );
683  rtems_test_assert( status == 0 );
684  strcpy(longer_name, Directories[3] );
685  strcat(longer_name, "/NewFile" );
686  printf("Mkdir of %s should fail with EACCES\n",longer_name );
687  status = mkdir( longer_name, S_IRWXU );
688  rtems_test_assert( status != 0 );
689  rtems_test_assert( errno == EACCES );
690
691  printf("Making too many hard links.\n" );
692  make_too_many_links( );
693
694  printf( "pass fstat a null pointer should fail with EFAULT\n");
695  status = fstat( fd, NULL );
696  rtems_test_assert( status == -1 );
697  rtems_test_assert( errno == EFAULT);
698
699  /*
700   * The current directory MUST be restored at the end of this test.
701   */
702
703  printf("chdir to /my_mount_point \n");
704  status = chdir( "/my_mount_point" );
705  rtems_test_assert( status == 0 );
706
707}
708
709void Show_Time(void)
710{
711  rtems_time_of_day time;
712  rtems_status_code status;
713
714  status = rtems_clock_get_tod( &time );
715  printf("--->Current Time: ");
716  print_time( " - rtems_clock_get_tod - ", &time, "\n" );
717}
718
719/*
720 *  main entry point to the test
721 */
722
723#if defined(__rtems__)
724int test_main(void)
725#else
726int main(
727  int    argc,
728  char **argv
729)
730#endif
731{
732  rtems_status_code status;
733  rtems_time_of_day time;
734
735  puts( "\n\n*** STAT TEST 01 ***" );
736
737  build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
738  status = rtems_clock_set( &time );
739  Show_Time();
740
741  /*
742   * Create and mount another version of the filesyste.
743   * This allows expected node id's to be consistant across
744   * platforms and bsp's.
745   */
746
747  status = mkdir("/my_mount_point",  S_IRWXU );
748  rtems_test_assert( status == 0 );
749  status = mount(
750    "null",
751    "my_mount_point",
752    "imfs",
753     RTEMS_FILESYSTEM_READ_WRITE,
754     NULL );
755  rtems_test_assert( status == 0 );
756  status = chdir( "/my_mount_point" );
757  rtems_test_assert( status == 0 );
758  status = mkdir("dev",  S_IRWXU );
759  rtems_test_assert( status == 0 );
760
761
762  /*
763   *  Create the files and directories for the test.
764   */
765
766  make_multiple_directories( Directories );
767  make_multiple_files( Files );
768  make_multiple_links( Directories,    Links_to_Dirs );
769  make_multiple_links( Files,          Links_to_Files );
770
771  status = rtems_task_wake_after( TIMEOUT_VALUE );
772  make_multiple_links( Links_to_Dirs,  Links_to_dirlinks );
773  status = rtems_task_wake_after( TIMEOUT_VALUE );
774  make_multiple_links( Links_to_Files, Links_to_filelinks );
775
776  status = rtems_task_wake_after( TIMEOUT_VALUE );
777
778  /*
779   *  Now go through all the absolute path.
780   */
781
782  puts( "Doing the stat() on all the good absolute paths" );
783  stat_multiple_files( Good_absolute_paths );
784
785  /*
786   *  run through the relative paths.
787   */
788
789  puts( "\nDoing the stat() on all the good relative paths" );
790  stat_multiple_files( Good_relative_paths );
791
792  /*
793   * Change directory and releative paths are now bad.
794   */
795
796  puts("\nchdir to dev");
797  chdir("dev");
798  puts("\nstat relative paths that are now bad");
799  stat_multiple_files( Good_relative_paths );
800
801  /*
802   * Change directory to the link directory and follow links.
803   */
804
805  puts("\nchdir to ../links");
806  chdir("../links");
807  puts("Doing the stat() on good links\n");
808  stat_multiple_files( Links_to_Dirs );
809  stat_multiple_files( Links_to_Files );
810  stat_multiple_files( Links_to_dirlinks  );
811  stat_multiple_files( Links_to_filelinks );
812
813  /*
814   * Chmod on dir1/dir1.  This allows the error path to be hit.
815   */
816
817  printf( "chmod of %s to Read/Write\n", Directories[4] );
818  chmod( Directories[4], (S_IROTH|S_IWOTH) );
819  puts( "\nDoing the stat() on all the bad paths" );
820
821  stat_multiple_files( Bad_paths );
822  make_multiple_bad_files( Bad_paths );
823
824  printf( "Return %s to RWX\n", Directories[4] );
825  chmod( Directories[4], S_IRWXU );
826
827
828  /*
829   * Check out symbolic links.
830   */
831
832  make_multiple_symlinks();
833  make_many_symlinks( "/symlinks", 10 );
834
835  status = rtems_task_wake_after( TIMEOUT_VALUE );
836  Cause_faults();
837
838  status = rtems_task_wake_after( TIMEOUT_VALUE );
839  chown_multiple_files( Files );
840
841  status = rtems_task_wake_after( TIMEOUT_VALUE );
842  chown_multiple_files( Links_to_Dirs );
843
844  puts( "\n\n*** END OF STAT TEST 01 ***" );
845  rtems_test_exit(0);
846}
Note: See TracBrowser for help on using the repository browser.