Index: trunk/kernel/fs/vfs.c
===================================================================
--- trunk/kernel/vfs/vfs.c	(revision 406)
+++ trunk/kernel/fs/vfs.c	(revision 407)
@@ -156,6 +156,6 @@
     error_t            error;
 
-    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter / dentry_xp = %l\n",
-    __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , dentry_xp );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] enter / dentry = %x in cluster %x\n",
+__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, GET_PTR(dentry_xp), GET_CXY(dentry_xp) );
  
     // check fs type and get pointer on context
@@ -229,6 +229,6 @@
     remote_spinlock_init( XPTR( local_cxy , &inode->main_lock ) );
 
-    vfs_dmsg("\n[INFO] %s : core[%x,%d] exit / inode_xp = %l / dentry_xp = %l\n",
-    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy,inode), dentry_xp );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] exit / inode = %x in cluster %x\n",
+__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy );
  
     // return extended pointer on inode
@@ -262,6 +262,6 @@
                         xptr_t        child_xp )
 {
-    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",
-    __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / cycle %d\n",
+__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
 
     error_t error = 0;
@@ -292,6 +292,6 @@
     }
 
-    vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / cycle %d\n",
-    __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / cycle %d\n",
+__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
 
     return error;
@@ -413,6 +413,6 @@
 
     // display inode header
-    printk("\n*** inode <%s> / inode_xp = %l / dentry_xp = %l ***\n",
-           name , inode_xp , dentry_xp );
+    printk("\n***** inode <%s> [%x in cluster %x]\n",
+           name , GET_PTR(inode_xp) , GET_CXY(inode_xp) );
 
     // display children from xhtab
@@ -435,6 +435,6 @@
 	kmem_req_t       req;        // request to kernel memory allocator
 
-    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / parent inode = %x / cycle %d\n",
-    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, parent, hal_time_stamp() );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / parent inode = %x / cycle %d\n",
+__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, parent, hal_time_stamp() );
 
     // get pointer on context
@@ -484,6 +484,6 @@
     *dentry_xp = XPTR( local_cxy , dentry );
 
-    vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / dentry = %l / cycle %d\n",
-    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, *dentry_xp, hal_time_stamp() );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / dentry = %x in cluster %x / cycle %d\n",
+__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, dentry, local_cxy , hal_time_stamp() );
 
     return 0;
@@ -586,11 +586,11 @@
 //////////////////////////////////////////////////////////////////////////////////////////
 
-////////////////////////////////////
-error_t vfs_open( xptr_t     cwd_xp,
-		          char     * path,
-		          uint32_t   flags,
-                  uint32_t   mode, 
-		          xptr_t   * new_file_xp,
-                  uint32_t * new_file_id )
+//////////////////////////////////////
+error_t vfs_open( process_t * process,
+		          char      * path,
+		          uint32_t    flags,
+                  uint32_t    mode, 
+		          xptr_t    * new_file_xp,
+                  uint32_t  * new_file_id )
 {
     error_t       error;
@@ -603,6 +603,6 @@
     uint32_t      file_id;      // created file descriptor index in reference fd_array
 
-    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",
-    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, (uint32_t)hal_time_stamp() );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / cycle %d\n",
+__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, (uint32_t)hal_time_stamp() );
 
     // compute lookup working mode
@@ -614,6 +614,6 @@
     // compute attributes for the created file
     file_attr = 0;
-    if( (flags & O_RDONLY ) == 0 )  file_attr |= FD_ATTR_READ_ENABLE;
-    if( (flags & O_WRONLY ) == 0 )  file_attr |= FD_ATTR_WRITE_ENABLE;
+    if( (flags & O_RDONLY ) == 0 )  file_attr |= FD_ATTR_WRITE_ENABLE;
+    if( (flags & O_WRONLY ) == 0 )  file_attr |= FD_ATTR_READ_ENABLE;
     if( (flags & O_SYNC   )      )  file_attr |= FD_ATTR_SYNC;
     if( (flags & O_APPEND )      )  file_attr |= FD_ATTR_APPEND;
@@ -621,5 +621,5 @@
 
     // get extended pointer on target inode
-    error = vfs_lookup( cwd_xp , path , lookup_mode , &inode_xp );
+    error = vfs_lookup( process->vfs_cwd_xp , path , lookup_mode , &inode_xp );
 
     if( error ) return error;
@@ -629,4 +629,7 @@
     inode_ptr = (vfs_inode_t *)GET_PTR( inode_xp );
     
+vfs_dmsg("\n[DBG] %s : core[%x,%d] found inode for <%s> in cluster %x / cycle %d\n",
+__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, inode_cxy , (uint32_t)hal_time_stamp() );
+
     // create a new file descriptor in cluster containing inode
     if( inode_cxy == local_cxy )      // target cluster is local
@@ -641,11 +644,12 @@
     if( error )  return error;
 
-    // allocate and register a new file descriptor index in reference cluster fd_array
-    error = process_fd_register( file_xp , &file_id );
+    // allocate and register a new file descriptor index in reference process
+    error = process_fd_register( process , file_xp , &file_id );
 
     if( error ) return error;
 
-    vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / file_xp = %l / cycle %d\n",
-    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, file_xp, hal_time_stamp() );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / file = %x in cluster %x / cycle %d\n",
+__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path,
+GET_PTR(file_xp), GET_CXY(file_xp), hal_time_stamp() );
 
     // success
@@ -656,11 +660,12 @@
 }  // end vfs_open()
 
-////////////////////////////////////////////
-error_t vfs_user_move( bool_t   to_buffer,
-                       xptr_t   file_xp,
-                       void   * buffer,
-                       uint32_t size )
-{
-    assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ , "file_xp == XPTR_NULL" );
+//////////////////////////////////////
+int vfs_user_move( bool_t   to_buffer,
+                   xptr_t   file_xp,
+                   void   * buffer,
+                   uint32_t size )
+{
+    assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ , 
+    "file_xp == XPTR_NULL" );
 
     cxy_t              file_cxy;     // remote file descriptor cluster 
@@ -678,40 +683,35 @@
     inode_type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type   ) );
    
-    // action depends on inode type
-    if( inode_type == INODE_TYPE_FILE )
-    {
-        // get mapper pointer and file offset from file descriptor
-        file_offset = hal_remote_lw( XPTR( file_cxy , &file_ptr->offset ) );
-        mapper = (mapper_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) );
-
-        // move data between mapper and buffer
-        if( file_cxy == local_cxy )
-        {
-            error = mapper_move_user( mapper,
-                                      to_buffer,
-                                      file_offset,
-                                      buffer,
-                                      size );
-        }
-        else
-        {
-            rpc_mapper_move_buffer_client( file_cxy,
-                                           mapper,
-                                           to_buffer,
-                                           true,          // user buffer
-                                           file_offset,
-                                           (uint64_t)(intptr_t)buffer,
-                                           size,
-                                           &error );
-        } 
-
-        if( error ) return -1;
-        else        return 0;
-    }
-    else 
-    {
-        printk("\n[ERROR] in %s : inode is not a file", __FUNCTION__ );
-        return -1;
-    }
+    assert( (inode_type == INODE_TYPE_FILE) , __FUNCTION__ ,
+    "inode type is not INODE_TYPE_FILE" );
+
+    // get mapper pointer and file offset from file descriptor
+    file_offset = hal_remote_lw( XPTR( file_cxy , &file_ptr->offset ) );
+    mapper = (mapper_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) );
+
+    // move data between mapper and buffer
+    if( file_cxy == local_cxy )
+    {
+        error = mapper_move_user( mapper,
+                                  to_buffer,
+                                  file_offset,
+                                  buffer,
+                                  size );
+    }
+    else
+    {
+        rpc_mapper_move_buffer_client( file_cxy,
+                                       mapper,
+                                       to_buffer,
+                                       true,          // user buffer
+                                       file_offset,
+                                       (uint64_t)(intptr_t)buffer,
+                                       size,
+                                       &error );
+    } 
+
+    if( error ) return -1;
+    else        return size;
+
 }  // end vfs_user_move()
 
@@ -905,9 +905,9 @@
     panic("not implemented");
     return 0;
-}  // vfs_unlink()
-
-///////////////////////////////////////
-error_t vfs_stat( xptr_t       file_xp,
-                  vfs_stat_t * k_stat )
+} 
+
+////////////////////////////////////////
+error_t vfs_stat( xptr_t        file_xp,
+                  struct stat * k_stat )
 {
     panic("not implemented");
@@ -915,7 +915,7 @@
 }
 
-////////////////////////////////////////////
-error_t vfs_readdir( xptr_t         file_xp,
-                     vfs_dirent_t * k_dirent )
+/////////////////////////////////////////////
+error_t vfs_readdir( xptr_t          file_xp,
+                     struct dirent * k_dirent )
 {
     panic("not implemented");
@@ -1094,7 +1094,7 @@
 
     // display inode
-    nolock_printk("%s%s <%s> : inode = %l / mapper = %l / dentry = %l\n",
+    nolock_printk("%s%s <%s> : inode = %x / mapper = %x / cluster %x\n",
                   indent_str[indent], vfs_inode_type_str( inode_type ), name,
-                  inode_xp , XPTR( inode_cxy , mapper_ptr ) , dentry_xp );
+                  inode_ptr , mapper_ptr , inode_cxy );
 
     // scan directory entries  
@@ -1171,5 +1171,5 @@
 
     // get pointers on TXT0 chdev
-    xptr_t    txt0_xp  = chdev_dir.txt[0];
+    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
     cxy_t     txt0_cxy = GET_CXY( txt0_xp );
     chdev_t * txt0_ptr = GET_PTR( txt0_xp );
@@ -1338,6 +1338,6 @@
     process = this->process;
 
-    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",
-    __FUNCTION__ , local_cxy , this->core->lid , pathname , hal_time_stamp() );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / cycle %d\n",
+__FUNCTION__ , local_cxy , this->core->lid , pathname , hal_time_stamp() );
 
     // get extended pointer on first inode to search
@@ -1362,6 +1362,6 @@
         vfs_get_name_from_path( current , name , &next , &last );
 
-        vfs_dmsg("\n[INFO] %s : core[%x,%d] look for <%s> / last = %d\n",
-        __FUNCTION__ , local_cxy , this->core->lid , name , last );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] look for <%s> / last = %d\n",
+__FUNCTION__ , local_cxy , this->core->lid , name , last );
 
         // search a child dentry matching name in parent inode
@@ -1380,6 +1380,7 @@
         if (found == false ) // child node not found in inode tree 
         {
-            vfs_dmsg("\n[INFO] %s : core[%x,%d] miss <%s> => load it\n",
-            __FUNCTION__ , local_cxy , this->core->lid , name );
+
+vfs_dmsg("\n[DBG] %s : core[%x,%d] miss <%s> => load it\n",
+__FUNCTION__ , local_cxy , this->core->lid , name );
 
             // release lock on parent inode
@@ -1405,5 +1406,5 @@
             if( error )
             {
-                printk("\n[ERROR] in %s : no memory for inode %s in path %s\n",
+                printk("\n[ERROR] in %s : no memory for inode <%s> in path <%s>\n",
                 __FUNCTION__ , name , pathname );
                 return ENOMEM;
@@ -1428,6 +1429,6 @@
             if ( error )
             {
-                printk("\n[ERROR] in %s : core[%x,%d] / <%s> not found in parent\n",
-                __FUNCTION__ , local_cxy , this->core->lid , name );
+                printk("\n[ERROR] in %s : core[%x,%d] / <%s> node not found in <%s>\n",
+                __FUNCTION__ , local_cxy , this->core->lid , name , pathname );
                 return ENOENT;
             }
@@ -1464,10 +1465,11 @@
             vfs_inode_lock( parent_xp );
 
-            vfs_dmsg("\n[INFO] %s : core[%x,%d] created node <%s>\n",
-            __FUNCTION__ , local_cxy , this->core->lid , name );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] created node <%s>\n",
+__FUNCTION__ , local_cxy , this->core->lid , name );
+
         }
 
-        vfs_dmsg("\n[INFO] %s : core[%x,%d] found <%s> / parent = %l / child = %l\n",
-        __FUNCTION__ , local_cxy , this->core->lid , name , parent_xp , child_xp );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] found <%s> / inode = %x in cluster %x\n",
+__FUNCTION__ , local_cxy , this->core->lid , name , GET_PTR(child_xp) , GET_CXY(child_xp) );
 
         // TODO check access rights here [AG]
@@ -1494,6 +1496,6 @@
     vfs_inode_unlock( parent_xp );
 
-    vfs_dmsg("\n[INFO] %s : exit <%s> found / inode = %l\n",
-                 __FUNCTION__ , pathname , child_xp );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / inode = %x in cluster %x\n",
+__FUNCTION__,local_cxy,this->core->lid,pathname,GET_PTR(child_xp),GET_CXY(child_xp) );
 
     // return searched pointer
@@ -1593,6 +1595,6 @@
     parent_ptr = (vfs_inode_t *)GET_PTR( parent_xp );
 
-    vfs_dmsg("\n[INFO] %s : enter for <%s> / core[%x,%d] / child_cxy = %x / parent_xp = %l\n",
-    __FUNCTION__ , name , local_cxy , CURRENT_THREAD->core->lid , child_cxy , parent_xp );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / child_cxy = %x / parent_cxy = %x\n",
+__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , child_cxy , parent_cxy );
 
     // 1. create dentry
@@ -1604,6 +1606,7 @@
                                    &dentry_xp );
 
-        vfs_dmsg("\n[INFO] %s : dentry <%s> created in local cluster %x\n",
-        __FUNCTION__ , name , local_cxy );
+vfs_dmsg("\n[DBG] %s : dentry <%s> created in local cluster %x\n",
+__FUNCTION__ , name , local_cxy );
+
     }
     else                               // parent cluster is remote
@@ -1616,6 +1619,7 @@
                                       &error );
 
-        vfs_dmsg("\n[INFO] %s : dentry <%s> created in remote cluster %x\n",
-        __FUNCTION__ , name , parent_cxy );
+vfs_dmsg("\n[DBG] %s : dentry <%s> created in remote cluster %x\n",
+__FUNCTION__ , name , parent_cxy );
+
     }
                                       
@@ -1623,5 +1627,5 @@
     {
         printk("\n[ERROR] in %s : cannot create dentry in cluster %x\n",
-               __FUNCTION__ , parent_cxy );
+        __FUNCTION__ , parent_cxy );
         return ENOMEM;
     }
@@ -1645,6 +1649,7 @@
                                   &inode_xp );
 
-        vfs_dmsg("\n[INFO] %s : inode %l created in local cluster %x\n",
-                 __FUNCTION__ , inode_xp , local_cxy );
+vfs_dmsg("\n[DBG] %s : inode %x created in local cluster %x\n",
+__FUNCTION__ , GET_PTR(inode_xp) , local_cxy );
+
     }
     else                              // child cluster is remote
@@ -1662,6 +1667,7 @@
                                      &error );
 
-        vfs_dmsg("\n[INFO] %s : inode %l created in remote cluster %x\n",
-                 __FUNCTION__ , inode_xp , child_cxy );
+vfs_dmsg("\n[DBG] %s : inode %x created in remote cluster %x\n",
+__FUNCTION__ , GET_PTR(inode_xp) , child_cxy );
+
     }
                                      
@@ -1682,6 +1688,6 @@
     hal_remote_swd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) , inode_xp );
 
-    vfs_dmsg("\n[INFO] %s : exit in cluster %x for <%s>\n",
-    __FUNCTION__ , local_cxy , name );
+vfs_dmsg("\n[DBG] %s : exit in cluster %x for <%s>\n",
+__FUNCTION__ , local_cxy , name );
 
     // success : return extended pointer on child inode
@@ -1707,6 +1713,6 @@
     assert( (mapper != NULL) , __FUNCTION__ , "no mapper for page\n" );
 
-    vfs_dmsg("\n[DMSG] %s : enters for page %d / inode_cxy = %x / inode_ptr = %x\n",
-    __FUNCTION__ , page->index , local_cxy , mapper->inode );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] enters for page %d / mapper = %x / inode = %x\n",
+__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid , page->index , mapper, mapper->inode );
 
     // get FS type
@@ -1733,6 +1739,6 @@
     }
 
-    vfs_dmsg("\n[DMSG] %s : exit for page %d / inode_cxy = %x / inode_ptr = %x\n",
-    __FUNCTION__ , page->index , local_cxy , mapper->inode );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for page %d / mapper = %x / inode = %x\n",
+__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, page->index, mapper, mapper->inode );
 
     return error;
@@ -1753,6 +1759,6 @@
     assert( (mapper != NULL) , __FUNCTION__ , "mapper pointer is NULL\n" );
 
-    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for inode %l / cycle %d\n",
-    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy , inode) );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for inode %x in cluster %x/ cycle %d\n",
+__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy , hal_time_stamp() );
 
     // compute number of pages
@@ -1770,6 +1776,6 @@
     }
 
-    vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for inode %l / cycle %d\n",
-    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy , inode) );
+vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for inode %x in cluster %x / cycle %d\n",
+__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy , hal_time_stamp() );
 
     return 0;
