OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [tests/] [psxtests/] [psxstat/] [test.c] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.