Index: c/src/tests/psxtests/ChangeLog
===================================================================
--- c/src/tests/psxtests/ChangeLog	(revision 87fb080d750838e14cb0ce5fbc3c5462aee4dafa)
+++ c/src/tests/psxtests/ChangeLog	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -1,2 +1,10 @@
+2001-05-25	Joel Sherrill <joel@OARcorp.com>
+
+ 	* Added once version of psxchroot01 test for user review.
+	* psxchroot01: New directory.
+	* psxchroot01/Makefile.am, psxchroot01/main.c, psxchroot01/test.c,
+	psxchroot01/psxchroot01.scn, psxchroot01/.cvsignore: New files.
+	* configure.in, Makefile.am: Modified to reflect above.
+
 2001-05-10	Ralf Corsepius	<corsepiu@faw.uni-ulm.de>
 
Index: c/src/tests/psxtests/Makefile.am
===================================================================
--- c/src/tests/psxtests/Makefile.am	(revision 87fb080d750838e14cb0ce5fbc3c5462aee4dafa)
+++ c/src/tests/psxtests/Makefile.am	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -11,5 +11,5 @@
     psx09 psx10 psx11 psx12 psxtime psxtimer psxcancel psxmsgq01 psxsem01
 
-POSIX_FILES_DIRS = psxfile01 psxreaddir psxstat psxmount psx13
+POSIX_FILES_DIRS = psxfile01 psxreaddir psxstat psxmount psx13 psxchroot01
 
 UNUSED_DIRS =
Index: c/src/tests/psxtests/configure.in
===================================================================
--- c/src/tests/psxtests/configure.in	(revision 87fb080d750838e14cb0ce5fbc3c5462aee4dafa)
+++ c/src/tests/psxtests/configure.in	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -54,4 +54,5 @@
 psx13/Makefile
 psxcancel/Makefile
+psxchroot01/Makefile
 psxfile01/Makefile
 psxhdrs/Makefile
Index: c/src/tests/psxtests/psxchroot01/.cvsignore
===================================================================
--- c/src/tests/psxtests/psxchroot01/.cvsignore	(revision 6287b5773f610368df70df3127586b9440e7b802)
+++ c/src/tests/psxtests/psxchroot01/.cvsignore	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
Index: c/src/tests/psxtests/psxchroot01/Makefile.am
===================================================================
--- c/src/tests/psxtests/psxchroot01/Makefile.am	(revision 6287b5773f610368df70df3127586b9440e7b802)
+++ c/src/tests/psxtests/psxchroot01/Makefile.am	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -0,0 +1,40 @@
+##
+## $Id$
+##
+
+AUTOMAKE_OPTIONS = foreign 1.4
+
+TEST = psxchroot01
+
+MANAGERS = all
+
+C_FILES = main.c test.c
+C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
+
+DOCTYPES = scn
+DOCS = $(DOCTYPES:%=$(TEST).%)
+
+SRCS = $(DOCS) $(C_FILES) $(H_FILES)
+OBJS = $(C_O_FILES)
+
+PRINT_SRCS = $(DOCS)
+
+PGM = ${ARCH}/$(TEST).exe
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../../../../automake/compile.am
+include $(RTEMS_ROOT)/make/leaf.cfg
+include $(top_srcdir)/psxtests.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+${PGM}: $(OBJS) $(LINK_FILES)
+	$(make-exe)
+
+all-local: $(ARCH) $(TMPINSTALL_FILES)
+
+EXTRA_DIST = $(C_FILES) $(DOCS)
+
+include $(top_srcdir)/../../../../automake/local.am
Index: c/src/tests/psxtests/psxchroot01/main.c
===================================================================
--- c/src/tests/psxtests/psxchroot01/main.c	(revision 6287b5773f610368df70df3127586b9440e7b802)
+++ c/src/tests/psxtests/psxchroot01/main.c	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -0,0 +1,34 @@
+/*
+ *  Simple test program -- simplified version of sample test hello.
+ */
+
+#define TEST_INIT
+
+#include <bsp.h>
+
+void test_main( void );
+
+rtems_task Init(
+  rtems_task_argument ignored
+)
+{
+  test_main();
+  exit( 0 );
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 10
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <confdefs.h>
+
+/* end of file */
Index: c/src/tests/psxtests/psxchroot01/psxchroot01.scn
===================================================================
--- c/src/tests/psxtests/psxchroot01/psxchroot01.scn	(revision 6287b5773f610368df70df3127586b9440e7b802)
+++ c/src/tests/psxtests/psxchroot01/psxchroot01.scn	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -0,0 +1,3 @@
+*** CHROOT TEST ***
+FILL ME IN ONCE TEST IS SATISFACTORY
+*** END OF CHROOT TEST ***
Index: c/src/tests/psxtests/psxchroot01/test.c
===================================================================
--- c/src/tests/psxtests/psxchroot01/test.c	(revision 6287b5773f610368df70df3127586b9440e7b802)
+++ c/src/tests/psxtests/psxchroot01/test.c	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -0,0 +1,122 @@
+/*
+ *  This is a native test to explore how the readdir() family works.
+ *  Newlib supports the following readdir() family members:
+ *
+ *    closedir()   - 
+ *    readdir()    - 
+ *    scandir()    - 
+ *    opendir()    - 
+ *    rewinddir()  - 
+ *    telldir()    - BSD not in POSIX 
+ *    seekdir()    - BSD not in POSIX
+ *
+ *
+ *  seekdir() takes an offset which is a byte offset.  The Linux
+ *  implementation of this appears to seek to the ((off/DIRENT_SIZE) + 1)
+ *  record where DIRENT_SIZE seems to be 12 bytes.
+ *
+ *
+ *
+ *  $Id$
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <string.h>
+#include <assert.h>
+#include <unistd.h>
+#include <errno.h>
+#include <rtems/libio.h>
+
+void touch( char *file )
+{
+  int fd;
+
+  assert( file );
+
+  fd = open( file, O_RDWR|O_CREAT, 0777 );
+  assert( fd != -1 );
+  close( fd );
+}
+
+int fileexists( char *file )
+{
+  int         status;
+  struct stat statbuf;
+
+  assert( file );
+
+  status = stat( file, &statbuf );
+
+  if ( status == -1 ) {
+    /* printf( ": %s\n", strerror( errno ) ); */
+    return 0;
+  }
+  return 1;
+}
+
+#if defined(__rtems__)
+int test_main(void)
+#else
+int main(
+  int argc,
+  char **argv
+)
+#endif
+{
+  int fd;
+  int i;
+  int status;
+  struct stat s;
+
+/*
+ *  This test is the C equivalent of this sequence.
+#mkdir /one
+#mkdir /one/one
+#touch /one/one.test
+#touch /one/two/two.test
+#chroot /one
+#if !fileexits(/one/one.test) echo "FAIL"
+#if fileexits(/two/two.test) echo "SUCCESSFUL"
+#rtems_set_private_env() ! reset at the global environment
+#if !fileexits(/one/one.test) echo "SUCESSFUL"
+#if fileexits(/two/two.test) echo "FAIL"
+*/
+
+  printf( "\n\n*** CHROOT01 TEST ***\n" );
+
+  status = mkdir( "/one", 0777);
+  assert( status == 0 );
+
+  status = mkdir( "/one/one", 0777);
+  assert( status == 0 );
+
+  status = mkdir( "/one/two", 0777);
+  assert( status == 0 );
+
+  touch( "/one/one.test" );
+  touch( "/one/two/two.test" );
+ 
+  status = chroot( "/one" );
+  assert( status == 0 );
+
+  status = fileexists( "/one/one.test" );
+  printf( "%s on /one/one.test\n", (!status) ? "SUCCESS" : "FAILURE" );
+   
+  status = fileexists( "/two/two.test" );
+  printf( "%s on /two/two.test\n", (status) ? "SUCCESS" : "FAILURE" );
+
+  puts( "Reset the private environment" );
+  rtems_libio_set_private_env();
+   
+  status = fileexists( "/one/one.test" );
+  printf( "%s on /one/one.test\n", (!status) ? "SUCCESS" : "FAILURE" );
+
+  status = fileexists( "/two/two.test" );
+  printf( "%s on /two/two.test\n", (status) ? "SUCCESS" : "FAILURE" );
+
+  printf( "*** END OF CHROOT01 TEST ***\n" );
+  exit(0);
+}
+
Index: testsuites/psxtests/ChangeLog
===================================================================
--- testsuites/psxtests/ChangeLog	(revision 87fb080d750838e14cb0ce5fbc3c5462aee4dafa)
+++ testsuites/psxtests/ChangeLog	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -1,2 +1,10 @@
+2001-05-25	Joel Sherrill <joel@OARcorp.com>
+
+ 	* Added once version of psxchroot01 test for user review.
+	* psxchroot01: New directory.
+	* psxchroot01/Makefile.am, psxchroot01/main.c, psxchroot01/test.c,
+	psxchroot01/psxchroot01.scn, psxchroot01/.cvsignore: New files.
+	* configure.in, Makefile.am: Modified to reflect above.
+
 2001-05-10	Ralf Corsepius	<corsepiu@faw.uni-ulm.de>
 
Index: testsuites/psxtests/Makefile.am
===================================================================
--- testsuites/psxtests/Makefile.am	(revision 87fb080d750838e14cb0ce5fbc3c5462aee4dafa)
+++ testsuites/psxtests/Makefile.am	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -11,5 +11,5 @@
     psx09 psx10 psx11 psx12 psxtime psxtimer psxcancel psxmsgq01 psxsem01
 
-POSIX_FILES_DIRS = psxfile01 psxreaddir psxstat psxmount psx13
+POSIX_FILES_DIRS = psxfile01 psxreaddir psxstat psxmount psx13 psxchroot01
 
 UNUSED_DIRS =
Index: testsuites/psxtests/psxchroot01/.cvsignore
===================================================================
--- testsuites/psxtests/psxchroot01/.cvsignore	(revision 6287b5773f610368df70df3127586b9440e7b802)
+++ testsuites/psxtests/psxchroot01/.cvsignore	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
Index: testsuites/psxtests/psxchroot01/Makefile.am
===================================================================
--- testsuites/psxtests/psxchroot01/Makefile.am	(revision 6287b5773f610368df70df3127586b9440e7b802)
+++ testsuites/psxtests/psxchroot01/Makefile.am	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -0,0 +1,40 @@
+##
+## $Id$
+##
+
+AUTOMAKE_OPTIONS = foreign 1.4
+
+TEST = psxchroot01
+
+MANAGERS = all
+
+C_FILES = main.c test.c
+C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
+
+DOCTYPES = scn
+DOCS = $(DOCTYPES:%=$(TEST).%)
+
+SRCS = $(DOCS) $(C_FILES) $(H_FILES)
+OBJS = $(C_O_FILES)
+
+PRINT_SRCS = $(DOCS)
+
+PGM = ${ARCH}/$(TEST).exe
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../../../../automake/compile.am
+include $(RTEMS_ROOT)/make/leaf.cfg
+include $(top_srcdir)/psxtests.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+${PGM}: $(OBJS) $(LINK_FILES)
+	$(make-exe)
+
+all-local: $(ARCH) $(TMPINSTALL_FILES)
+
+EXTRA_DIST = $(C_FILES) $(DOCS)
+
+include $(top_srcdir)/../../../../automake/local.am
Index: testsuites/psxtests/psxchroot01/main.c
===================================================================
--- testsuites/psxtests/psxchroot01/main.c	(revision 6287b5773f610368df70df3127586b9440e7b802)
+++ testsuites/psxtests/psxchroot01/main.c	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -0,0 +1,34 @@
+/*
+ *  Simple test program -- simplified version of sample test hello.
+ */
+
+#define TEST_INIT
+
+#include <bsp.h>
+
+void test_main( void );
+
+rtems_task Init(
+  rtems_task_argument ignored
+)
+{
+  test_main();
+  exit( 0 );
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 10
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <confdefs.h>
+
+/* end of file */
Index: testsuites/psxtests/psxchroot01/psxchroot01.scn
===================================================================
--- testsuites/psxtests/psxchroot01/psxchroot01.scn	(revision 6287b5773f610368df70df3127586b9440e7b802)
+++ testsuites/psxtests/psxchroot01/psxchroot01.scn	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -0,0 +1,3 @@
+*** CHROOT TEST ***
+FILL ME IN ONCE TEST IS SATISFACTORY
+*** END OF CHROOT TEST ***
Index: testsuites/psxtests/psxchroot01/test.c
===================================================================
--- testsuites/psxtests/psxchroot01/test.c	(revision 6287b5773f610368df70df3127586b9440e7b802)
+++ testsuites/psxtests/psxchroot01/test.c	(revision 6287b5773f610368df70df3127586b9440e7b802)
@@ -0,0 +1,122 @@
+/*
+ *  This is a native test to explore how the readdir() family works.
+ *  Newlib supports the following readdir() family members:
+ *
+ *    closedir()   - 
+ *    readdir()    - 
+ *    scandir()    - 
+ *    opendir()    - 
+ *    rewinddir()  - 
+ *    telldir()    - BSD not in POSIX 
+ *    seekdir()    - BSD not in POSIX
+ *
+ *
+ *  seekdir() takes an offset which is a byte offset.  The Linux
+ *  implementation of this appears to seek to the ((off/DIRENT_SIZE) + 1)
+ *  record where DIRENT_SIZE seems to be 12 bytes.
+ *
+ *
+ *
+ *  $Id$
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <string.h>
+#include <assert.h>
+#include <unistd.h>
+#include <errno.h>
+#include <rtems/libio.h>
+
+void touch( char *file )
+{
+  int fd;
+
+  assert( file );
+
+  fd = open( file, O_RDWR|O_CREAT, 0777 );
+  assert( fd != -1 );
+  close( fd );
+}
+
+int fileexists( char *file )
+{
+  int         status;
+  struct stat statbuf;
+
+  assert( file );
+
+  status = stat( file, &statbuf );
+
+  if ( status == -1 ) {
+    /* printf( ": %s\n", strerror( errno ) ); */
+    return 0;
+  }
+  return 1;
+}
+
+#if defined(__rtems__)
+int test_main(void)
+#else
+int main(
+  int argc,
+  char **argv
+)
+#endif
+{
+  int fd;
+  int i;
+  int status;
+  struct stat s;
+
+/*
+ *  This test is the C equivalent of this sequence.
+#mkdir /one
+#mkdir /one/one
+#touch /one/one.test
+#touch /one/two/two.test
+#chroot /one
+#if !fileexits(/one/one.test) echo "FAIL"
+#if fileexits(/two/two.test) echo "SUCCESSFUL"
+#rtems_set_private_env() ! reset at the global environment
+#if !fileexits(/one/one.test) echo "SUCESSFUL"
+#if fileexits(/two/two.test) echo "FAIL"
+*/
+
+  printf( "\n\n*** CHROOT01 TEST ***\n" );
+
+  status = mkdir( "/one", 0777);
+  assert( status == 0 );
+
+  status = mkdir( "/one/one", 0777);
+  assert( status == 0 );
+
+  status = mkdir( "/one/two", 0777);
+  assert( status == 0 );
+
+  touch( "/one/one.test" );
+  touch( "/one/two/two.test" );
+ 
+  status = chroot( "/one" );
+  assert( status == 0 );
+
+  status = fileexists( "/one/one.test" );
+  printf( "%s on /one/one.test\n", (!status) ? "SUCCESS" : "FAILURE" );
+   
+  status = fileexists( "/two/two.test" );
+  printf( "%s on /two/two.test\n", (status) ? "SUCCESS" : "FAILURE" );
+
+  puts( "Reset the private environment" );
+  rtems_libio_set_private_env();
+   
+  status = fileexists( "/one/one.test" );
+  printf( "%s on /one/one.test\n", (!status) ? "SUCCESS" : "FAILURE" );
+
+  status = fileexists( "/two/two.test" );
+  printf( "%s on /two/two.test\n", (status) ? "SUCCESS" : "FAILURE" );
+
+  printf( "*** END OF CHROOT01 TEST ***\n" );
+  exit(0);
+}
+
