source: rtems/testsuites/fstests/support/fstest_support.c @ 858e013f

4.115
Last change on this file since 858e013f was 858e013f, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 1, 2011 at 8:54:15 PM

2011-08-01 Xiang Cui <medivhc@…>

  • Makefile.am, configure.ac, fslink/fslink.doc, fslink/test.c, fssymlink/test.c, imfs_fslink/Makefile.am, imfs_fssymlink/Makefile.am, imfs_support/fs_config.h, imfs_support/fs_support.c, mdosfs_support/fs_config.h, mdosfs_support/fs_support.c, mimfs_fslink/Makefile.am, mimfs_fssymlink/Makefile.am, mimfs_support/fs_config.h, mimfs_support/fs_support.c, mrfs_fslink/Makefile.am, mrfs_fssymlink/Makefile.am, mrfs_support/fs_config.h, mrfs_support/fs_support.c, support/fstest.h, support/fstest_support.c, support/fstest_support.h, support/ramdisk_support.c, support/ramdisk_support.h: Submit correct tarball of current work.
  • fs01/init.c, fsfchx/fsfchx.doc, fsfchx/init.c, fsfile01/fsfile01.doc, fsfile01/test.c, fsfile01/test_cat.c, fsfile01/test_extend.c, fsfile01/test_write.c, fsfile02/fsfile02.doc, fsfile02/init.c, fsfstest/fs-test.c, fsfstest/fsfstest.doc, fsimfs01/fsimfs01.doc, fsimfs01/init.c, fsimfs02/fsimfs02.doc, fsimfs02/init.c, fsmkdir/fsmkdir.doc, fsmkdir/test.c, fsopen/fsopen.doc, fsopen/test.c, fsrdwrv/fsrdwrv.doc, fsrdwrv/test.c, fsreaddir/fsreaddir.doc, fsreaddir/test.c, fsrename/fsrename.doc, fsrename/test.c, fsrmdir/test.c, fsrwfile/fsrwfile.doc, fsrwfile/init.c, fsstat/fsstat.doc, fsstat/test.c, fstruncate/fstruncate.doc, fstruncate/test.c, imfs_fs01/.cvsignore, imfs_fs01/Makefile.am, imfs_fs01/imfs_fs01.scn, imfs_fsfchx/.cvsignore, imfs_fsfchx/Makefile.am, imfs_fsfile01/.cvsignore, imfs_fsfile01/Makefile.am, imfs_fsfile02/.cvsignore, imfs_fsfile02/Makefile.am, imfs_fsfstest/.cvsignore, imfs_fsfstest/Makefile.am, imfs_fsimfs01/.cvsignore, imfs_fsimfs01/Makefile.am, imfs_fsimfs02/.cvsignore, imfs_fsimfs02/Makefile.am, imfs_fslink/.cvsignore, imfs_fsmkdir/.cvsignore, imfs_fsmkdir/Makefile.am, imfs_fsopen/.cvsignore, imfs_fsopen/Makefile.am, imfs_fsrdwrv/.cvsignore, imfs_fsrdwrv/Makefile.am, imfs_fsreaddir/.cvsignore, imfs_fsreaddir/Makefile.am, imfs_fsrename/.cvsignore, imfs_fsrename/Makefile.am, imfs_fsrmdir/.cvsignore, imfs_fsrmdir/Makefile.am, imfs_fsrwfile/.cvsignore, imfs_fsrwfile/Makefile.am, imfs_fsstat/.cvsignore, imfs_fsstat/Makefile.am, imfs_fssymlink/.cvsignore, imfs_fstruncate/.cvsignore, imfs_fstruncate/Makefile.am, mdosfs_fsfchx/.cvsignore, mdosfs_fsfchx/Makefile.am, mdosfs_fsfile01/.cvsignore, mdosfs_fsfile01/Makefile.am, mdosfs_fsfile02/.cvsignore, mdosfs_fsfile02/Makefile.am, mdosfs_fsfstest/.cvsignore, mdosfs_fsfstest/Makefile.am, mdosfs_fsimfs01/.cvsignore, mdosfs_fsimfs01/Makefile.am, mdosfs_fsimfs02/.cvsignore, mdosfs_fsimfs02/Makefile.am, mdosfs_fslink/.cvsignore, mdosfs_fslink/Makefile.am, mdosfs_fsmkdir/.cvsignore, mdosfs_fsmkdir/Makefile.am, mdosfs_fsopen/.cvsignore, mdosfs_fsopen/Makefile.am, mdosfs_fsrdwrv/.cvsignore, mdosfs_fsrdwrv/Makefile.am, mdosfs_fsreaddir/.cvsignore, mdosfs_fsreaddir/Makefile.am, mdosfs_fsrename/.cvsignore, mdosfs_fsrename/Makefile.am, mdosfs_fsrmdir/.cvsignore, mdosfs_fsrmdir/Makefile.am, mdosfs_fsrwfile/.cvsignore, mdosfs_fsrwfile/Makefile.am, mdosfs_fsstat/.cvsignore, mdosfs_fsstat/Makefile.am, mdosfs_fssymlink/.cvsignore, mdosfs_fssymlink/Makefile.am, mdosfs_fstruncate/.cvsignore, mdosfs_fstruncate/Makefile.am, mimfs_fs01/.cvsignore, mimfs_fs01/Makefile.am, mimfs_fs01/mimfs_fs01.scn, mimfs_fsfchx/.cvsignore, mimfs_fsfchx/Makefile.am, mimfs_fsfile01/.cvsignore, mimfs_fsfile01/Makefile.am, mimfs_fsfile02/.cvsignore, mimfs_fsfile02/Makefile.am, mimfs_fsfstest/.cvsignore, mimfs_fsfstest/Makefile.am, mimfs_fsimfs01/.cvsignore, mimfs_fsimfs01/Makefile.am, mimfs_fsimfs02/.cvsignore, mimfs_fsimfs02/Makefile.am, mimfs_fslink/.cvsignore, mimfs_fsmkdir/.cvsignore, mimfs_fsmkdir/Makefile.am, mimfs_fsopen/.cvsignore, mimfs_fsopen/Makefile.am, mimfs_fsrdwrv/.cvsignore, mimfs_fsrdwrv/Makefile.am, mimfs_fsreaddir/.cvsignore, mimfs_fsreaddir/Makefile.am, mimfs_fsrename/.cvsignore, mimfs_fsrename/Makefile.am, mimfs_fsrmdir/.cvsignore, mimfs_fsrmdir/Makefile.am, mimfs_fsrwfile/.cvsignore, mimfs_fsrwfile/Makefile.am, mimfs_fsstat/.cvsignore, mimfs_fsstat/Makefile.am, mimfs_fssymlink/.cvsignore, mimfs_fstruncate/.cvsignore, mimfs_fstruncate/Makefile.am, mrfs_fsfchx/.cvsignore, mrfs_fsfchx/Makefile.am, mrfs_fsfile01/.cvsignore, mrfs_fsfile01/Makefile.am, mrfs_fsfile02/.cvsignore, mrfs_fsfile02/Makefile.am, mrfs_fsfstest/.cvsignore, mrfs_fsfstest/Makefile.am, mrfs_fsimfs01/.cvsignore, mrfs_fsimfs01/Makefile.am, mrfs_fsimfs02/.cvsignore, mrfs_fsimfs02/Makefile.am, mrfs_fslink/.cvsignore, mrfs_fsmkdir/.cvsignore, mrfs_fsmkdir/Makefile.am, mrfs_fsopen/.cvsignore, mrfs_fsopen/Makefile.am, mrfs_fsrdwrv/.cvsignore, mrfs_fsrdwrv/Makefile.am, mrfs_fsreaddir/.cvsignore, mrfs_fsreaddir/Makefile.am, mrfs_fsrename/.cvsignore, mrfs_fsrename/Makefile.am, mrfs_fsrmdir/.cvsignore, mrfs_fsrmdir/Makefile.am, mrfs_fsrwfile/.cvsignore, mrfs_fsrwfile/Makefile.am, mrfs_fsstat/.cvsignore, mrfs_fsstat/Makefile.am, mrfs_fssymlink/.cvsignore, mrfs_fstruncate/.cvsignore, mrfs_fstruncate/Makefile.am: Removed.
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id Exp $
10 */
11
12#include <stdio.h> 
13#include <errno.h> 
14#include <fcntl.h> 
15#include <string.h> 
16#include <unistd.h> 
17#include <sys/stat.h> 
18#include <sys/types.h> 
19
20#include "rtems.h"
21
22#include "fstest_support.h"
23#include "fs_config.h"
24
25#include "fstest.h"
26
27#define TEMP_DIR "waterbuffalo" 
28
29
30/* Break out of a chroot() environment in C */ 
31void break_out_of_chroot(void)
32{
33
34  int dir_fd;       /* File descriptor to directory */ 
35  struct stat sbuf; /* The stat() buffer */ 
36  chdir("/");
37
38  if (stat(TEMP_DIR,&sbuf)<0) { 
39    if (errno==ENOENT) { 
40      if (mkdir(TEMP_DIR,0755)<0) { 
41        fprintf(stderr,"Failed to create %s - %s\n", TEMP_DIR, 
42            strerror(errno)); 
43        exit(1); 
44      } 
45    } else { 
46      fprintf(stderr,"Failed to stat %s - %s\n", TEMP_DIR, 
47          strerror(errno)); 
48      exit(1); 
49    } 
50  } else if (!S_ISDIR(sbuf.st_mode)) { 
51    fprintf(stderr,"Error - %s is not a directory!\n",TEMP_DIR); 
52    exit(1); 
53  } 
54
55  if ((dir_fd=open(".",O_RDONLY))<0) { 
56    fprintf(stderr,"Failed to open \".\" for reading - %s\n", strerror(errno)); 
57    exit(1); 
58  } 
59
60  if (chroot(TEMP_DIR)<0) { 
61    fprintf(stderr,"Failed to chroot to %s - %s\n",TEMP_DIR, 
62        strerror(errno)); 
63    exit(1); 
64  } 
65
66  if (fchdir(dir_fd)<0) { 
67    fprintf(stderr,"Failed to fchdir - %s\n", 
68        strerror(errno)); 
69    exit(1); 
70  } 
71  close(dir_fd); 
72  chdir(".."); 
73  chroot("."); 
74
75}
76
77
78/*
79 *  Main entry point of every filesystem test
80 */
81
82rtems_task Init(
83    rtems_task_argument ignored)
84{
85  int rc=0;
86  puts( "\n\n*** FILE SYSTEM TEST ( " FILESYSTEM " ) ***" );
87
88  puts( "Initializing filesystem " FILESYSTEM );
89  test_initialize_filesystem();
90  rc=chdir(BASE_FOR_TEST);
91  rtems_test_assert(rc==0);
92
93  rc=chroot(BASE_FOR_TEST);
94  rtems_test_assert(rc==0);
95
96  test();
97
98  break_out_of_chroot();
99  chdir("/");
100
101  puts( "\n\nShutting down filesystem " FILESYSTEM );
102  test_shutdown_filesystem();
103
104  puts( "*** END OF FILE SYSTEM TEST ( " FILESYSTEM " ) ***" );
105  rtems_test_exit(0);
106
107}
Note: See TracBrowser for help on using the repository browser.