Index: trunk/kernel/fs/devfs.c
===================================================================
--- trunk/kernel/fs/devfs.c	(revision 598)
+++ trunk/kernel/fs/devfs.c	(revision 602)
@@ -86,9 +86,10 @@
 
 /////////////////////////////////////////////////
-void devfs_global_init( xptr_t   parent_inode_xp,
+void devfs_global_init( xptr_t   root_inode_xp,
                         xptr_t * devfs_dev_inode_xp,
                         xptr_t * devfs_external_inode_xp )
 {
     error_t  error;
+    xptr_t   unused_xp;   // required by vfs_add_child_in_parent()
 
     // creates DEVFS "dev" inode in cluster 0
@@ -96,8 +97,8 @@
                                      INODE_TYPE_DIR,
                                      FS_TYPE_DEVFS,
-                                     parent_inode_xp,
+                                     root_inode_xp,
                                      "dev",
-                                     NULL,
-                                     devfs_dev_inode_xp ); 
+                                     &unused_xp,
+                                     devfs_dev_inode_xp );
 
     assert( (error == 0) , "cannot create <dev>\n" );
@@ -117,6 +118,6 @@
                                      *devfs_dev_inode_xp,
                                      "external",
-                                     NULL,
-                                     devfs_external_inode_xp ); 
+                                     &unused_xp,
+                                     devfs_external_inode_xp );
 
     assert( (error == 0) , "cannot create <external>\n" );
@@ -129,5 +130,5 @@
 #endif
 
-} 
+}  // end devfs_global_init()
 
 ///////////////////////////////////////////////////
@@ -141,5 +142,8 @@
     chdev_t     * chdev_ptr;
     xptr_t        inode_xp;
+    cxy_t         inode_cxy;
+    vfs_inode_t * inode_ptr;
     uint32_t      channel;
+    xptr_t        unused_xp;    // required by add_child_in_parent()
 
     // create "internal" directory 
@@ -150,5 +154,5 @@
                              devfs_dev_inode_xp,
                              node_name,
-                             NULL,
+                             &unused_xp,
                              devfs_internal_inode_xp );
 #if DEBUG_DEVFS_INIT 
@@ -164,5 +168,5 @@
     if( chdev_xp != XPTR_NULL)
     {
-        chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
+        chdev_ptr = GET_PTR( chdev_xp );
         vfs_add_child_in_parent( local_cxy,
                                  INODE_TYPE_DEV,
@@ -170,6 +174,12 @@
                                  *devfs_internal_inode_xp,
                                  chdev_ptr->name,
-                                 GET_PTR( chdev_xp ),
+                                 &unused_xp,
                                  &inode_xp );
+
+        // update child inode "extend" field
+        inode_cxy = GET_CXY( inode_xp );
+        inode_ptr = GET_PTR( inode_xp );
+        hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
+        
 #if DEBUG_DEVFS_INIT
 cycle = (uint32_t)hal_get_cycles();
@@ -184,8 +194,8 @@
     for( channel = 0 ; channel < LOCAL_CLUSTER->cores_nr ; channel++ )
     {
-        chdev_xp = chdev_dir.dma[channel];
+        chdev_xp  = chdev_dir.dma[channel];
         if( chdev_xp != XPTR_NULL)
         {
-            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
+            chdev_ptr = GET_PTR( chdev_xp );
             vfs_add_child_in_parent( local_cxy,
                                      INODE_TYPE_DEV,
@@ -193,6 +203,12 @@
                                      *devfs_internal_inode_xp,
                                      chdev_ptr->name,
-                                     GET_PTR( chdev_xp ),
+                                     &unused_xp,
                                      &inode_xp );
+
+            // update child inode "extend" field
+            inode_cxy = GET_CXY( inode_xp );
+            inode_ptr = GET_PTR( inode_xp );
+            hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
+        
 #if DEBUG_DEVFS_INIT
 cycle = (uint32_t)hal_get_cycles();
@@ -209,5 +225,5 @@
     {
         chdev_cxy = GET_CXY( chdev_xp );
-        chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
+        chdev_ptr = GET_PTR( chdev_xp );
         if( chdev_cxy == local_cxy )
         {
@@ -217,6 +233,12 @@
                                      devfs_external_inode_xp,
                                      chdev_ptr->name,
-                                     GET_PTR( chdev_xp ),
+                                     &unused_xp,
                                      &inode_xp );
+
+            // update child inode "extend" field
+            inode_cxy = GET_CXY( inode_xp );
+            inode_ptr = GET_PTR( inode_xp );
+            hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
+        
 #if DEBUG_DEVFS_INIT
 cycle = (uint32_t)hal_get_cycles();
@@ -233,5 +255,5 @@
     {
         chdev_cxy = GET_CXY( chdev_xp );
-        chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
+        chdev_ptr = GET_PTR( chdev_xp );
         if( chdev_cxy == local_cxy )
         {
@@ -241,6 +263,12 @@
                                      devfs_external_inode_xp,
                                      chdev_ptr->name,
-                                     GET_PTR( chdev_xp ),
+                                     &unused_xp,
                                      &inode_xp );
+
+            // update child inode "extend" field
+            inode_cxy = GET_CXY( inode_xp );
+            inode_ptr = GET_PTR( inode_xp );
+            hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
+        
 #if DEBUG_DEVFS_INIT
 cycle = (uint32_t)hal_get_cycles();
@@ -256,4 +284,136 @@
     {
         chdev_xp = chdev_dir.txt_rx[channel];
+        if( chdev_xp != XPTR_NULL )
+        {
+            chdev_cxy = GET_CXY( chdev_xp );
+            chdev_ptr = GET_PTR( chdev_xp );
+            if( chdev_cxy == local_cxy )
+            {
+                vfs_add_child_in_parent( local_cxy,
+                                         INODE_TYPE_DEV,
+                                         FS_TYPE_DEVFS,
+                                         devfs_external_inode_xp,
+                                         chdev_ptr->name,
+                                         &unused_xp,
+                                         &inode_xp );
+
+                // update child inode "extend" field
+                inode_cxy = GET_CXY( inode_xp );
+                inode_ptr = GET_PTR( inode_xp );
+                hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
+        
+#if DEBUG_DEVFS_INIT
+cycle = (uint32_t)hal_get_cycles();
+if( DEBUG_DEVFS_INIT < cycle )
+printk("\n[%s] thread[%x,%x] created <txt_rx[%d]> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
+#endif
+            }
+        }
+    }
+
+    // create a TXT_TX inode in each cluster containing a TXT_TX chdev
+    for( channel = 0 ; channel < CONFIG_MAX_TXT_CHANNELS ; channel++ )
+    {
+        chdev_xp = chdev_dir.txt_tx[channel];
+        if( chdev_xp != XPTR_NULL )
+        {
+            chdev_cxy = GET_CXY( chdev_xp );
+            chdev_ptr = GET_PTR( chdev_xp );
+            if( chdev_cxy == local_cxy )
+            {
+                vfs_add_child_in_parent( local_cxy,
+                                         INODE_TYPE_DEV,
+                                         FS_TYPE_DEVFS,
+                                         devfs_external_inode_xp,
+                                         chdev_ptr->name,
+                                         &unused_xp,
+                                         &inode_xp );
+
+                // update child inode "extend" field
+                inode_cxy = GET_CXY( inode_xp );
+                inode_ptr = GET_PTR( inode_xp );
+                hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
+        
+#if DEBUG_DEVFS_INIT 
+cycle = (uint32_t)hal_get_cycles();
+if( DEBUG_DEVFS_INIT < cycle )
+printk("\n[%s] thread[%x,%x] created <txt_tx[%d]> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
+#endif
+            }
+        }
+    }
+
+    // create an IOC inode in each cluster containing an IOC chdev 
+    for( channel = 0 ; channel < CONFIG_MAX_IOC_CHANNELS ; channel++ )
+    {
+        chdev_xp = chdev_dir.ioc[channel];
+        if( chdev_xp != XPTR_NULL )
+        {
+            chdev_cxy = GET_CXY( chdev_xp );
+            chdev_ptr = GET_PTR( chdev_xp );
+            if( chdev_cxy == local_cxy )
+            {
+                vfs_add_child_in_parent( local_cxy,
+                                         INODE_TYPE_DEV,
+                                         FS_TYPE_DEVFS,
+                                         devfs_external_inode_xp,
+                                         chdev_ptr->name,
+                                         &unused_xp,
+                                         &inode_xp );
+
+                // update child inode "extend" field
+                inode_cxy = GET_CXY( inode_xp );
+                inode_ptr = GET_PTR( inode_xp );
+                hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
+        
+#if DEBUG_DEVFS_INIT
+cycle = (uint32_t)hal_get_cycles();
+if( DEBUG_DEVFS_INIT < cycle )
+printk("\n[%s] thread[%x,%x] created <ioc[%d]> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
+#endif
+            }
+        }
+    }
+
+    // create a FBF inode in each cluster containing a FBF chdev
+    for( channel = 0 ; channel < CONFIG_MAX_FBF_CHANNELS ; channel++ )
+    {
+        chdev_xp = chdev_dir.fbf[channel];
+        if( chdev_xp != XPTR_NULL )
+        {
+            chdev_cxy = GET_CXY( chdev_xp );
+            chdev_ptr = GET_PTR( chdev_xp );
+            if( chdev_cxy == local_cxy )
+            {
+                vfs_add_child_in_parent( local_cxy,
+                                         INODE_TYPE_DEV,
+                                         FS_TYPE_DEVFS,
+                                         devfs_external_inode_xp,
+                                         chdev_ptr->name,
+                                         &unused_xp,
+                                         &inode_xp );
+
+                // update child inode "extend" field
+                inode_cxy = GET_CXY( inode_xp );
+                inode_ptr = GET_PTR( inode_xp );
+                hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
+        
+#if DEBUG_DEVFS_INIT
+cycle = (uint32_t)hal_get_cycles();
+if( DEBUG_DEVFS_INIT < cycle )
+printk("\n[%s] thread[%x,%x] created <fbf[%d]> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
+#endif
+            }
+        }
+    }
+
+    // create a NIC_RX inode in each cluster containing a NIC_RX chdev 
+    for( channel = 0 ; channel < CONFIG_MAX_NIC_CHANNELS ; channel++ )
+    {
+        chdev_xp = chdev_dir.nic_rx[channel];
         if( chdev_xp != XPTR_NULL )
         {
@@ -267,10 +427,10 @@
                                          devfs_external_inode_xp,
                                          chdev_ptr->name,
-                                         GET_PTR( chdev_xp ),
+                                         &unused_xp,
                                          &inode_xp );
 #if DEBUG_DEVFS_INIT
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[%s] thread[%x,%x] created <txt_rx[%d]> inode in cluster %x\n",
+printk("\n[%s] thread[%x,%x] created <nic_rx[%d]> inode in cluster %x\n",
 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
 #endif
@@ -279,12 +439,12 @@
     }
 
-    // create a TXT_TX inode in each cluster containing a TXT_TX chdev
-    for( channel = 0 ; channel < CONFIG_MAX_TXT_CHANNELS ; channel++ )
-    {
-        chdev_xp = chdev_dir.txt_tx[channel];
+    // create a NIC_TX inode in each cluster containing a NIC_TX chdev 
+    for( channel = 0 ; channel < CONFIG_MAX_NIC_CHANNELS ; channel++ )
+    {
+        chdev_xp = chdev_dir.nic_tx[channel];
         if( chdev_xp != XPTR_NULL )
         {
             chdev_cxy = GET_CXY( chdev_xp );
-            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
+            chdev_ptr = GET_PTR( chdev_xp );
             if( chdev_cxy == local_cxy )
             {
@@ -294,114 +454,12 @@
                                          devfs_external_inode_xp,
                                          chdev_ptr->name,
-                                         GET_PTR( chdev_xp ),
+                                         &unused_xp,
                                          &inode_xp );
-#if DEBUG_DEVFS_INIT 
-cycle = (uint32_t)hal_get_cycles();
-if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[%s] thread[%x,%x] created <txt_tx[%d]> inode in cluster %x\n",
-__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
-#endif
-            }
-        }
-    }
-
-    // create an IOC inode in each cluster containing an IOC chdev 
-    for( channel = 0 ; channel < CONFIG_MAX_IOC_CHANNELS ; channel++ )
-    {
-        chdev_xp = chdev_dir.ioc[channel];
-        if( chdev_xp != XPTR_NULL )
-        {
-            chdev_cxy = GET_CXY( chdev_xp );
-            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
-            if( chdev_cxy == local_cxy )
-            {
-                vfs_add_child_in_parent( local_cxy,
-                                         INODE_TYPE_DEV,
-                                         FS_TYPE_DEVFS,
-                                         devfs_external_inode_xp,
-                                         chdev_ptr->name,
-                                         GET_PTR( chdev_xp ),
-                                         &inode_xp );
-#if DEBUG_DEVFS_INIT
-cycle = (uint32_t)hal_get_cycles();
-if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[%s] thread[%x,%x] created <ioc[%d]> inode in cluster %x\n",
-__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
-#endif
-            }
-        }
-    }
-
-    // create a FBF inode in each cluster containing a FBF chdev
-    for( channel = 0 ; channel < CONFIG_MAX_FBF_CHANNELS ; channel++ )
-    {
-        chdev_xp = chdev_dir.fbf[channel];
-        if( chdev_xp != XPTR_NULL )
-        {
-            chdev_cxy = GET_CXY( chdev_xp );
-            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
-            if( chdev_cxy == local_cxy )
-            {
-                vfs_add_child_in_parent( local_cxy,
-                                         INODE_TYPE_DEV,
-                                         FS_TYPE_DEVFS,
-                                         devfs_external_inode_xp,
-                                         chdev_ptr->name,
-                                         GET_PTR( chdev_xp ),
-                                         &inode_xp );
-#if DEBUG_DEVFS_INIT
-cycle = (uint32_t)hal_get_cycles();
-if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[%s] thread[%x,%x] created <fbf[%d]> inode in cluster %x\n",
-__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
-#endif
-            }
-        }
-    }
-
-    // create a NIC_RX inode in each cluster containing a NIC_RX chdev 
-    for( channel = 0 ; channel < CONFIG_MAX_NIC_CHANNELS ; channel++ )
-    {
-        chdev_xp = chdev_dir.nic_rx[channel];
-        if( chdev_xp != XPTR_NULL )
-        {
-            chdev_cxy = GET_CXY( chdev_xp );
-            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
-            if( chdev_cxy == local_cxy )
-            {
-                vfs_add_child_in_parent( local_cxy,
-                                         INODE_TYPE_DEV,
-                                         FS_TYPE_DEVFS,
-                                         devfs_external_inode_xp,
-                                         chdev_ptr->name,
-                                         GET_PTR( chdev_xp ),
-                                         &inode_xp );
-#if DEBUG_DEVFS_INIT
-cycle = (uint32_t)hal_get_cycles();
-if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[%s] thread[%x,%x] created <nic_rx[%d]> inode in cluster %x\n",
-__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
-#endif
-            }
-        }
-    }
-
-    // create a NIC_TX inode in each cluster containing a NIC_TX chdev 
-    for( channel = 0 ; channel < CONFIG_MAX_NIC_CHANNELS ; channel++ )
-    {
-        chdev_xp = chdev_dir.nic_tx[channel];
-        if( chdev_xp != XPTR_NULL )
-        {
-            chdev_cxy = GET_CXY( chdev_xp );
-            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
-            if( chdev_cxy == local_cxy )
-            {
-                vfs_add_child_in_parent( local_cxy,
-                                         INODE_TYPE_DEV,
-                                         FS_TYPE_DEVFS,
-                                         devfs_external_inode_xp,
-                                         chdev_ptr->name,
-                                         GET_PTR( chdev_xp ),
-                                         &inode_xp );
+
+                // update child inode "extend" field
+                inode_cxy = GET_CXY( inode_xp );
+                inode_ptr = GET_PTR( inode_xp );
+                hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
+        
 #if DEBUG_DEVFS_INIT
 cycle = (uint32_t)hal_get_cycles();
@@ -462,4 +520,5 @@
     channel = hal_remote_l32( XPTR( chdev_cxy , &chdev_ptr->channel ) );
 
+// Only TXT devices are associated to a pseudo-file
 assert( ( func == DEV_FUNC_TXT ) , __FUNCTION__, "illegal device func_type");
 
