Index: c/src/exec/libcsupport/src/libio.c
===================================================================
--- c/src/exec/libcsupport/src/libio.c	(revision eaf0e8eb0a142c091132d5865d118dfc417e8820)
+++ c/src/exec/libcsupport/src/libio.c	(revision 77c81fd2a1dedce6aad36204cf9ddbaf794c4f2f)
@@ -47,5 +47,4 @@
 rtems_id           rtems_libio_semaphore;
 rtems_libio_t     *rtems_libio_iops;
-rtems_libio_t     *rtems_libio_last_iop;
 rtems_libio_t     *rtems_libio_iop_freelist;
 
@@ -237,4 +236,5 @@
       rtems_semaphore_delete(iop->sem);
 
+    iop->flags &= ~LIBIO_FLAGS_OPEN;
     iop->data1 = rtems_libio_iop_freelist;
     rtems_libio_iop_freelist = iop;
@@ -260,4 +260,5 @@
   rtems_libio_t     *iop;
   int                result = 0;
+  int                i;
 
   rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
@@ -267,5 +268,5 @@
    */         
      
-  for ( iop=rtems_libio_iops ; iop <= rtems_libio_last_iop ; iop++ ) {
+  for (iop=rtems_libio_iops,i=0; i <= rtems_libio_number_iops; iop++, i++){
         
     if ((iop->flags & LIBIO_FLAGS_OPEN) != 0) {
@@ -303,4 +304,5 @@
   rtems_libio_t     *iop;
   int                result=0;
+  int                i;
 
   rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
@@ -310,6 +312,5 @@
    */
   
-  for ( iop=rtems_libio_iops ; iop <= rtems_libio_last_iop ; iop++ ) {
-  
+ for (iop=rtems_libio_iops,i=0; i <= rtems_libio_number_iops; iop++, i++){ 
     if ((iop->flags & LIBIO_FLAGS_OPEN) != 0) {
   
Index: c/src/lib/libc/libio.c
===================================================================
--- c/src/lib/libc/libio.c	(revision eaf0e8eb0a142c091132d5865d118dfc417e8820)
+++ c/src/lib/libc/libio.c	(revision 77c81fd2a1dedce6aad36204cf9ddbaf794c4f2f)
@@ -47,5 +47,4 @@
 rtems_id           rtems_libio_semaphore;
 rtems_libio_t     *rtems_libio_iops;
-rtems_libio_t     *rtems_libio_last_iop;
 rtems_libio_t     *rtems_libio_iop_freelist;
 
@@ -237,4 +236,5 @@
       rtems_semaphore_delete(iop->sem);
 
+    iop->flags &= ~LIBIO_FLAGS_OPEN;
     iop->data1 = rtems_libio_iop_freelist;
     rtems_libio_iop_freelist = iop;
@@ -260,4 +260,5 @@
   rtems_libio_t     *iop;
   int                result = 0;
+  int                i;
 
   rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
@@ -267,5 +268,5 @@
    */         
      
-  for ( iop=rtems_libio_iops ; iop <= rtems_libio_last_iop ; iop++ ) {
+  for (iop=rtems_libio_iops,i=0; i <= rtems_libio_number_iops; iop++, i++){
         
     if ((iop->flags & LIBIO_FLAGS_OPEN) != 0) {
@@ -303,4 +304,5 @@
   rtems_libio_t     *iop;
   int                result=0;
+  int                i;
 
   rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
@@ -310,6 +312,5 @@
    */
   
-  for ( iop=rtems_libio_iops ; iop <= rtems_libio_last_iop ; iop++ ) {
-  
+ for (iop=rtems_libio_iops,i=0; i <= rtems_libio_number_iops; iop++, i++){ 
     if ((iop->flags & LIBIO_FLAGS_OPEN) != 0) {
   
Index: cpukit/libcsupport/src/libio.c
===================================================================
--- cpukit/libcsupport/src/libio.c	(revision eaf0e8eb0a142c091132d5865d118dfc417e8820)
+++ cpukit/libcsupport/src/libio.c	(revision 77c81fd2a1dedce6aad36204cf9ddbaf794c4f2f)
@@ -47,5 +47,4 @@
 rtems_id           rtems_libio_semaphore;
 rtems_libio_t     *rtems_libio_iops;
-rtems_libio_t     *rtems_libio_last_iop;
 rtems_libio_t     *rtems_libio_iop_freelist;
 
@@ -237,4 +236,5 @@
       rtems_semaphore_delete(iop->sem);
 
+    iop->flags &= ~LIBIO_FLAGS_OPEN;
     iop->data1 = rtems_libio_iop_freelist;
     rtems_libio_iop_freelist = iop;
@@ -260,4 +260,5 @@
   rtems_libio_t     *iop;
   int                result = 0;
+  int                i;
 
   rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
@@ -267,5 +268,5 @@
    */         
      
-  for ( iop=rtems_libio_iops ; iop <= rtems_libio_last_iop ; iop++ ) {
+  for (iop=rtems_libio_iops,i=0; i <= rtems_libio_number_iops; iop++, i++){
         
     if ((iop->flags & LIBIO_FLAGS_OPEN) != 0) {
@@ -303,4 +304,5 @@
   rtems_libio_t     *iop;
   int                result=0;
+  int                i;
 
   rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
@@ -310,6 +312,5 @@
    */
   
-  for ( iop=rtems_libio_iops ; iop <= rtems_libio_last_iop ; iop++ ) {
-  
+ for (iop=rtems_libio_iops,i=0; i <= rtems_libio_number_iops; iop++, i++){ 
     if ((iop->flags & LIBIO_FLAGS_OPEN) != 0) {
   
