Index: trunk/kernel/fs/vfs.c
===================================================================
--- trunk/kernel/fs/vfs.c	(revision 673)
+++ trunk/kernel/fs/vfs.c	(revision 683)
@@ -48,5 +48,5 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////
-//           Extern variables         
+//           Extern global variables         
 //////////////////////////////////////////////////////////////////////////////////////////
 
@@ -54,4 +54,5 @@
 extern chdev_directory_t  chdev_dir;                  // allocated in kernel_init.c  
 extern char *             lock_type_str[];            // allocated in kernel_init.c
+extern process_t          process_zero;               // allocated in kernel_init.c
   
 ///////////////////////////////////////////////////////////////////////////////////////////
@@ -186,5 +187,4 @@
     uint32_t           inum;         // inode identifier (to be allocated)
     vfs_ctx_t        * ctx;          // file system context 
-	kmem_req_t         req;          // request to kernel memory allocator
     error_t            error;
 
@@ -192,4 +192,6 @@
 uint32_t       cycle      = (uint32_t)hal_get_cycles();
 thread_t *     this       = CURRENT_THREAD;
+pid_t          pid        = this->process->pid;
+trdid_t        trdid      = this->trdid;
 #endif
 
@@ -202,7 +204,6 @@
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] / illegal FS type\n",
-__FUNCTION__ , this->process->pid , this->trdid );
+printk("\n[ERROR] in %s : thread[%x,%x] / illegal FS type / cycle %d\n",
+__FUNCTION__ , pid , trdid, cycle );
 #endif
         return -1;
@@ -220,7 +221,6 @@
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inum\n",
-__FUNCTION__ , this->process->pid , this->trdid );
+printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inum / cycle %d\n",
+__FUNCTION__ , pid , trdid, cycle );
 #endif
         return -1;
@@ -234,7 +234,6 @@
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate mapper\n",
-__FUNCTION__ , this->process->pid , this->trdid );
+printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate mapper / cycle %d\n",
+__FUNCTION__ , pid , trdid, cycle );
 #endif
         vfs_ctx_inum_release( XPTR( cxy , ctx ) , inum );
@@ -244,18 +243,14 @@
     mapper_ptr = GET_PTR( mapper_xp );
 
-    // allocate one page for VFS inode descriptor
-    // because the embedded "children" xhtab footprint
-	req.type   = KMEM_PPM;
-	req.order  = 0;
-    req.flags  = AF_KERNEL | AF_ZERO;
-	inode_ptr  = kmem_remote_alloc( cxy , &req );
-
+    // allocate memory for inode descriptor
+	inode_ptr  = kmem_remote_alloc( cxy,
+                                    bits_log2(sizeof(vfs_inode_t)),
+                                    AF_ZERO );
     if( inode_ptr == NULL )
     {
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inode\n",
-__FUNCTION__ , this->process->pid , this->trdidi );
+printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inode / cycle %d\n",
+__FUNCTION__ , pid , trdid, cycle );
 #endif
         vfs_ctx_inum_release( XPTR( cxy , ctx ) , inum );
@@ -297,5 +292,5 @@
 if( DEBUG_VFS_INODE_CREATE < cycle )
 printk("\n[%s] thread[%x,%x] created inode (%x,%x) / ctx %x / fs_type %d / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, cxy, inode_ptr, ctx, ctx->type, cycle );
+__FUNCTION__, pid, trdid, cxy, inode_ptr, ctx, ctx->type, cycle );
 #endif
  
@@ -318,8 +313,7 @@
 
     // release memory allocated for inode descriptor
-	kmem_req_t req;
-	req.type  = KMEM_PPM;
-	req.ptr   = inode_ptr;
-	kmem_remote_free( inode_cxy , &req );
+	kmem_remote_free( inode_cxy,
+                      inode_ptr,
+                      bits_log2(sizeof(vfs_inode_t)) );
 
 }  // end vfs_inode_destroy()
@@ -447,8 +441,11 @@
     uint32_t   size   = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->size ) );
 
-#if DEBUG_VFS_INODE_LOAD_ALL
-char       name[CONFIG_VFS_MAX_NAME_LENGTH];
+#if DEBUG_VFS_INODE_LOAD_ALL || DEBUG_VFS_ERROR
 uint32_t   cycle = (uint32_t)hal_get_cycles();
 thread_t * this  = CURRENT_THREAD;
+#endif
+
+#if DEBUG_VFS_INODE_LOAD_ALL
+char name[CONFIG_VFS_MAX_NAME_LENGTH];
 vfs_inode_get_name( inode_xp , name );
 if( DEBUG_VFS_INODE_LOAD_ALL < cycle )
@@ -458,5 +455,5 @@
 
     // compute number of pages
-    uint32_t npages = size >> CONFIG_PPM_PAGE_SHIFT;
+    uint32_t npages = size >> CONFIG_PPM_PAGE_ORDER;
     if( (size & CONFIG_PPM_PAGE_MASK) || (size == 0) ) npages++;
 
@@ -468,5 +465,13 @@
         page_xp = mapper_get_page( XPTR( inode_cxy , mapper ), page_id );
 
-        if( page_xp == XPTR_NULL ) return -1;
+        if( page_xp == XPTR_NULL )
+        {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate memory for mapper / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, cycle );
+#endif
+            return -1;
+        }
     }
 
@@ -534,5 +539,4 @@
                            xptr_t        * dentry_xp )
 {
-	kmem_req_t       req;            // request to kernel memory allocator
     vfs_ctx_t      * ctx = NULL;     // context descriptor
     vfs_dentry_t   * dentry_ptr;     // dentry descriptor (to be allocated)
@@ -557,7 +561,6 @@
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] / undefined fs_type %d\n",
-__FUNCTION__ , this->process->pid, this->trdid, fs_type );
+printk("\n[ERROR] in %s : thread[%x,%x] / undefined fs_type %d / cycle %d\n",
+__FUNCTION__ , this->process->pid, this->trdid, fs_type, cycle );
 #endif
         return -1;
@@ -570,16 +573,13 @@
 
     // allocate memory for dentry descriptor
-	req.type   = KMEM_KCM;
-	req.order  = bits_log2( sizeof(vfs_dentry_t) );
-    req.flags  = AF_KERNEL | AF_ZERO;
-	dentry_ptr = kmem_remote_alloc( cxy , &req );
-
+	dentry_ptr = kmem_remote_alloc( cxy,
+                                    bits_log2(sizeof(vfs_dentry_t)),
+                                    AF_ZERO );
     if( dentry_ptr == NULL ) 
     {
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate dentry descriptor\n",
-__FUNCTION__ , this->process->pid, this->trdid );
+printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate dentry descriptor / cycle %d\n",
+__FUNCTION__ , this->process->pid, this->trdid, cycle );
 #endif
         return -1;
@@ -616,8 +616,7 @@
   
     // release memory allocated to dentry
-	kmem_req_t req;
-	req.type  = KMEM_KCM;
-	req.ptr   = dentry_ptr;
-	kmem_remote_free( dentry_cxy , &req );
+	kmem_remote_free( dentry_cxy,
+                      dentry_ptr,
+                      bits_log2(sizeof(vfs_dentry_t)) );
 
 }  // end vfs_dentry_destroy()
@@ -634,5 +633,4 @@
 {
     vfs_file_t   * file_ptr;
-	kmem_req_t     req;
     uint32_t       type;
     mapper_t     * mapper;
@@ -644,7 +642,10 @@
     cxy_t         inode_cxy = GET_CXY( inode_xp );
 
+#if DEBUG_VFS_FILE_CREATE || DEBUG_VFS_ERROR
+thread_t * this  = CURRENT_THREAD;
+uint32_t   cycle = (uint32_t)hal_get_cycles();
+#endif
+
 #if DEBUG_VFS_FILE_CREATE
-thread_t * this = CURRENT_THREAD;
-uint32_t cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_VFS_FILE_CREATE < cycle )
 printk("\n[%s] thread[%x,%x] enter for inode (%x,%x) / cycle %d\n",
@@ -653,10 +654,17 @@
 
     // allocate memory for new file descriptor
-	req.type  = KMEM_KCM;
-	req.order = bits_log2( sizeof(vfs_file_t) );
-    req.flags = AF_KERNEL | AF_ZERO;
-	file_ptr  = kmem_remote_alloc( inode_cxy , &req );
-
-    if( file_ptr == NULL ) return -1;
+	file_ptr  = kmem_remote_alloc( inode_cxy,
+                                   bits_log2(sizeof(vfs_file_t)),
+                                   AF_ZERO );
+
+    if( file_ptr == NULL )
+    {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] / cannot allocate memory / cycle %d\n",
+__FUNCTION__ , this->process->pid, this->trdid, cycle );
+#endif
+        return -1;
+    }
 
     // get type, ctx, mapper, and buffer from inode descriptor
@@ -718,8 +726,7 @@
 
     // release file descriptor
-	kmem_req_t req;
-	req.type  = KMEM_KCM;
-	req.ptr   = file_ptr;
-	kmem_remote_free( file_cxy , &req );
+	kmem_remote_free( file_cxy,
+                      file_ptr,
+                      bits_log2(sizeof(vfs_file_t)) );
 
 #if DEBUG_VFS_FILE_DESTROY
@@ -775,12 +782,19 @@
     xptr_t         lock_xp;        // extended pointer on Inode Tree lock 
 
+#if DEBUG_VFS_OPEN || DEBUG_VFS_ERROR
+uint32_t    cycle   = (uint32_t)hal_get_cycles();
+thread_t  * this    = CURRENT_THREAD;
+pid_t       pid     = this->process->pid; 
+trdid_t     trdid   = this->trdid;
+#endif
+
     if( mode != 0 )
     {
-        printk("\n[ERROR] in %s : the mode parameter is not supported yet\n" );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : the mode parameter is not supported yet\n" );
+#endif
         return -1;
     }
-
-    thread_t  * this    = CURRENT_THREAD;
-    process_t * process = this->process;
 
     // compute lookup working mode
@@ -790,12 +804,8 @@
     if( (flags & O_EXCL   )      )  lookup_mode |= VFS_LOOKUP_EXCL;
  
-#if DEBUG_VFS_OPEN || DEBUG_VFS_ERROR
-uint32_t cycle = (uint32_t)hal_get_cycles();
-#endif
-
 #if DEBUG_VFS_OPEN
 if( DEBUG_VFS_OPEN < cycle )
 printk("\n[%s] thread[%x,%x] enter for <%s> / root_inode (%x,%x) / cycle %d\n",
-__FUNCTION__, process->pid, this->trdid, path, GET_CXY(root_xp), GET_PTR(root_xp), cycle );
+__FUNCTION__, pid, trdid, path, GET_CXY(root_xp), GET_PTR(root_xp), cycle );
 #endif
 
@@ -809,5 +819,5 @@
 
     // build extended pointer on lock protecting Inode Tree
-    vfs_root_xp  = process->vfs_root_xp;
+    vfs_root_xp  = process_zero.vfs_root_xp;
     vfs_root_ptr = GET_PTR( vfs_root_xp );
     vfs_root_cxy = GET_CXY( vfs_root_xp );
@@ -831,7 +841,6 @@
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] cannot get inode <%s>\n",
-__FUNCTION__ , process->pid, this->trdid , path );
+printk("\n[ERROR] in %s : thread[%x,%x] cannot get inode <%s> / cycle %d\n",
+__FUNCTION__ , pid, trdid , path , cycle );
 #endif
         return -1;
@@ -843,8 +852,7 @@
     
 #if (DEBUG_VFS_OPEN & 1)
-cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_VFS_OPEN < cycle )
 printk("\n[%s] thread[%x,%x] found inode(%x,%x) for <%s>\n",
-__FUNCTION__, process->pid, this->trdid, inode_cxy, inode_ptr, path );
+__FUNCTION__, pid, trdid, inode_cxy, inode_ptr, path );
 #endif
 
@@ -852,11 +860,18 @@
     error = vfs_file_create( inode_xp , file_attr , &file_xp );
 
-    if( error )  return error;
+    if( error )
+    {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create file descriptor for <%s> / cycle %d\n",
+__FUNCTION__ , pid, trdid , path , cycle );
+#endif
+        return error;
+    }
 
 #if (DEBUG_VFS_OPEN & 1)
-cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_VFS_OPEN < cycle )
 printk("\n[%s] thread[%x,%x] created file descriptor (%x,%x) for <%s>\n",
-__FUNCTION__, process->pid, this->trdid, GET_CXY(file_xp), GET_PTR(file_xp), path );
+__FUNCTION__, pid, trdid, GET_CXY(file_xp), GET_PTR(file_xp), path );
 #endif
 
@@ -864,5 +879,13 @@
     error = process_fd_register( process_xp , file_xp , &file_id );
 
-    if( error ) return error;
+    if( error )
+    {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot register file descriptor for <%s> / cycle %d\n",
+__FUNCTION__ , pid, trdid , path , cycle );
+#endif
+        return error;
+    }
 
     // get new file descriptor cluster and local pointer
@@ -891,5 +914,5 @@
 if( DEBUG_VFS_OPEN < cycle )
 printk("\n[%s] thread[%x,%x] exit for <%s> / fdid %d / file(%x,%x) / cycle %d\n",
-__FUNCTION__, process->pid, this->trdid, path, file_id,
+__FUNCTION__, pid, trdid, path, file_id,
 GET_CXY( file_xp ), GET_PTR( file_xp ), cycle );
 #endif
@@ -997,7 +1020,6 @@
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s thread[%x,%x] cannot move data",
-__FUNCTION__, this->process->pid, this->trdid );
+printk("\n[ERROR] in %s thread[%x,%x] cannot move data / cycle %d",
+__FUNCTION__, this->process->pid, this->trdid, cycle );
 #endif
         return -1;
@@ -1008,5 +1030,4 @@
 
 #if DEBUG_VFS_USER_MOVE
-cycle = (uint32_t)hal_get_cycles();
 if( cycle > DEBUG_VFS_USER_MOVE )
 {
@@ -1032,5 +1053,4 @@
     cxy_t              file_cxy;     // remote file descriptor cluster 
     vfs_file_t       * file_ptr;     // remote file descriptor local pointer
-    vfs_file_type_t   inode_type;   // remote file type
     uint32_t           file_offset;  // current offset in file
     mapper_t         * mapper_ptr;   // remote mapper local pointer
@@ -1041,13 +1061,12 @@
 assert( __FUNCTION__, (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL" );
 
+#if DEBUG_VFS_KERNEL_MOVE || DEBUG_VFS_ERROR
+uint32_t      cycle      = (uint32_t)hal_get_cycles();
+thread_t    * this       = CURRENT_THREAD;
+#endif
+
     // get cluster and local pointer on remote file descriptor
     file_cxy  = GET_CXY( file_xp );
     file_ptr  = GET_PTR( file_xp );
-
-    // get inode type from remote file descriptor
-    inode_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type   ) );
-
-// check inode type
-assert( __FUNCTION__, (inode_type == FILE_TYPE_REG), "bad file type" );
 
     // get mapper pointers and file offset from file descriptor
@@ -1064,12 +1083,15 @@
     if( error ) 
     {
-        printk("\n[ERROR] in %s : cannot move data", __FUNCTION__ );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] / cannot move data / cycle %d\n",
+__FUNCTION__ , this->process->pid , this->trdid , cycle );
+#endif
         return -1;
+
     }
 
 #if DEBUG_VFS_KERNEL_MOVE
 char          name[CONFIG_VFS_MAX_NAME_LENGTH];
-uint32_t      cycle      = (uint32_t)hal_get_cycles();
-thread_t    * this       = CURRENT_THREAD;
 cxy_t         buffer_cxy = GET_CXY( buffer_xp );
 void        * buffer_ptr = GET_PTR( buffer_xp );
@@ -1109,4 +1131,9 @@
 assert( __FUNCTION__, (new_offset != NULL )  , "new_offset == NULL" );
 
+#if DEBUG_VFS_LSEEK || DEBUG_VFS_ERROR
+uint32_t   cycle = (uint32_t)hal_get_cycles();
+thread_t * this  = CURRENT_THREAD;
+#endif
+
     // get cluster and local pointer on remote file descriptor
     file_cxy = GET_CXY( file_xp );
@@ -1138,5 +1165,9 @@
     else
     {
-        printk("\n[ERROR] in %s : illegal whence value\n", __FUNCTION__ );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] / undefined whence value / cycle %d",
+__FUNCTION__ , this->process->pid , this->trdid , cycle );
+#endif
         remote_rwlock_wr_release( lock_xp );
         return -1;
@@ -1191,9 +1222,12 @@
     cluster_t * cluster = LOCAL_CLUSTER;
 
+#if DEBUG_VFS_CLOSE || DEBUG_VFS_ERROR
+uint32_t  cycle = (uint32_t)hal_get_cycles();
+#endif
+
     // get file name
     vfs_file_get_name( file_xp , name );
     
 #if DEBUG_VFS_CLOSE
-uint32_t cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_VFS_CLOSE < cycle )
 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n",
@@ -1215,6 +1249,9 @@
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot synchronise dirty pages for <%s>\n",
-        __FUNCTION__, name ); 
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] / cannot synchronise dirty pages for <%s> / cycle %d\n",
+__FUNCTION__ , this->process->pid , this->trdid , name , cycle );
+#endif
         return -1;
     }
@@ -1222,5 +1259,5 @@
 #if DEBUG_VFS_CLOSE 
 if( DEBUG_VFS_CLOSE < cycle )
-printk("\n[%s] thread[%x,%x] synchronised mapper of <%s> to device\n",
+printk("\n[%s] thread[%x,%x] synchronised <%s> mapper to device\n",
 __FUNCTION__, process->pid, this->trdid, name );
 #endif
@@ -1259,6 +1296,9 @@
         if( error )
         {
-            printk("\n[ERROR] in %s : cannot update size in parent\n",
-            __FUNCTION__ ); 
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] / cannot update size in parent / cycle %d\n",
+__FUNCTION__ , this->process->pid , this->trdid , cycle );
+#endif
             return -1;
         }
@@ -1277,6 +1317,9 @@
         if( error )
         {
-            printk("\n[ERROR] in %s : cannot synchronise parent mapper to device\n",
-            __FUNCTION__ ); 
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] / cannot synchronise  mapper & device / cycle %d\n",
+__FUNCTION__ , this->process->pid , this->trdid , cycle );
+#endif
             return -1;
         }
@@ -1367,4 +1410,8 @@
     char           last_name[CONFIG_VFS_MAX_NAME_LENGTH];
 
+#if DEBUG_VFS_MKDIR || DEBUG_VFS_ERROR
+uint32_t  cycle = (uint32_t)hal_get_cycles();
+#endif
+
     thread_t  * this    = CURRENT_THREAD;
     process_t * process = this->process;
@@ -1373,5 +1420,4 @@
 char root_name[CONFIG_VFS_MAX_NAME_LENGTH];
 vfs_inode_get_name( root_xp , root_name );
-uint32_t   cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_VFS_MKDIR < cycle )
 printk("\n[%s] thread[%x,%x] enter / root <%s> / path <%s> / cycle %d\n",
@@ -1396,7 +1442,10 @@
     if( error )
     {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot get parent inode for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path , cycle );
+#endif
         remote_rwlock_wr_release( lock_xp );
-        printk("\n[ERROR] in %s : cannot get parent inode for <%s>\n",
-        __FUNCTION__, path );
         return -1;
     }
@@ -1423,7 +1472,10 @@
     if( error )
     {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry in cluster %x for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, parent_cxy, path , cycle );
+#endif
         remote_rwlock_wr_release( lock_xp );
-        printk("\n[ERROR] in %s : cannot create new dentry in cluster %x for <%s>\n",
-        __FUNCTION__, parent_cxy, path );
         return -1;
     }
@@ -1457,7 +1509,10 @@
     if( error )
     {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode in cluster %x for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, parent_cxy, path , cycle );
+#endif
         remote_rwlock_wr_release( lock_xp );
-        printk("\n[ERROR] in %s : cannot create new inode in cluster %x for <%s>\n",
-         __FUNCTION__ , inode_cxy , path );
         vfs_dentry_destroy( dentry_xp );
         return -1;
@@ -1504,8 +1559,11 @@
     if( error )
     {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create <.> & <..> dentries for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path , cycle );
+#endif
+        vfs_remove_child_from_parent( dentry_xp );
         remote_rwlock_wr_release( lock_xp );
-        printk("\n[ERROR] in %s : cannot create new inode in cluster %x for <%s>\n",
-        __FUNCTION__ , inode_cxy , path );
-        vfs_dentry_destroy( dentry_xp );
         return -1;
     }
@@ -1520,6 +1578,10 @@
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot update parent directory for <%s>\n",
-        __FUNCTION__, path );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot update parent directory for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path , cycle );
+#endif
+        vfs_remove_child_from_parent( dentry_xp );
         return -1;
     }
@@ -1527,5 +1589,5 @@
 #if(DEBUG_VFS_MKDIR & 1)
 if( DEBUG_VFS_MKDIR < cycle )
-printk("\n[%s] thread[%x,%x] updated parent dir (mapper and IOC) for <%s>\n",
+printk("\n[%s] thread[%x,%x] created <%s> dir (Inode-Tree, Mapper and IOC)\n",
 __FUNCTION__, process->pid, this->trdid, path );
 #endif
@@ -1565,4 +1627,8 @@
     char           new_name[CONFIG_VFS_MAX_NAME_LENGTH];
 
+#if DEBUG_VFS_LINK || DEBUG_VFS_ERROR
+uint32_t  cycle = (uint32_t)hal_get_cycles();
+#endif
+
     thread_t  * this    = CURRENT_THREAD;
     process_t * process = this->process;
@@ -1573,5 +1639,4 @@
 vfs_inode_get_name( old_root_xp , old_root_name );
 vfs_inode_get_name( new_root_xp , new_root_name );
-uint32_t   cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_VFS_LINK < cycle )
 printk("\n[%s] thread[%x,%x] enter / old_root <%s> / old_path <%s> / "
@@ -1598,7 +1663,10 @@
     if( error )
     {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot get target inode for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, old_path , cycle );
+#endif
         remote_rwlock_wr_release( lock_xp );
-        printk("\n[ERROR] in %s : cannot get target inode for <%s>\n",
-        __FUNCTION__, old_path );
         return -1;
     }
@@ -1619,7 +1687,10 @@
     if( error )
     {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot get parent inode for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, new_path , cycle );
+#endif
         remote_rwlock_wr_release( lock_xp );
-        printk("\n[ERROR] in %s : cannot get parent inode for <%s>\n",
-        __FUNCTION__, new_path );
         return -1;
     }
@@ -1655,7 +1726,10 @@
         if( error )
         {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create new dentry for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, new_path , cycle );
+#endif
             remote_rwlock_wr_release( lock_xp );
-            printk("\n[ERROR] in %s : cannot create new dentry for <%s>\n",
-            __FUNCTION__, new_path );
             return -1;
         }
@@ -1696,6 +1770,9 @@
         if( error )
         {
-            printk("\n[ERROR] in %s : cannot update new parent directory for <%s>\n",
-            __FUNCTION__, new_path );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot update parent directory for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, new_path , cycle );
+#endif
             return -1;
         }
@@ -1710,9 +1787,10 @@
     else
     {
-        // release the lock protecting Inode Tree
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] / unsupported inode type %s / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, vfs_inode_type_str( inode_type ), cycle );
+#endif
         remote_rwlock_wr_release( lock_xp );
-
-        printk("\n[ERROR] in %s : unsupported inode type %s\n",
-        __FUNCTION__ , vfs_inode_type_str( inode_type ) );
         return -1;
     }
@@ -1746,9 +1824,12 @@
     char              parent_name[CONFIG_VFS_MAX_NAME_LENGTH];  // name of parent directory
 
+#if DEBUG_VFS_UNLINK || DEBUG_VFS_ERROR
+uint32_t  cycle = (uint32_t)hal_get_cycles();
+#endif
+
     thread_t  * this    = CURRENT_THREAD;
     process_t * process = this->process;
 
 #if DEBUG_VFS_UNLINK
-uint32_t   cycle = (uint32_t)hal_get_cycles();
 char root_name[CONFIG_VFS_MAX_NAME_LENGTH];
 vfs_inode_get_name( root_xp , root_name );
@@ -1775,7 +1856,10 @@
     if( error ) 
     {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot get parent inode for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path , cycle );
+#endif
         remote_rwlock_wr_release( lock_xp );
-        printk("\n[ERROR] in %s : cannot get parent inode for <%s> in <%s>\n",
-        __FUNCTION__, child_name, path );
         return -1;
     }
@@ -1824,6 +1908,10 @@
         if( error )
         {
-            printk("\n[ERROR] in %s : cannot create inode <%s> in Inode Tree\n",
-            __FUNCTION__ , child_name );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create node <%s> in Inode_Tree / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, cycle );
+#endif
+            remote_rwlock_wr_release( lock_xp );
             return -1;
         }
@@ -1839,6 +1927,10 @@
         if ( error ) 
         {
-            printk("\n[ERROR] in %s : cannot get entry <%s> in parent <%s> mapper\n",
-            __FUNCTION__ , child_name, parent_name );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot get dentry  <%s> in parent <%s> mapper / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, child_name, parent_name, cycle );
+#endif
+            remote_rwlock_wr_release( lock_xp );
             return -1;
         }
@@ -1861,5 +1953,5 @@
     }
 
-    // At this point the Inode Tree contains the target dentry and child inode
+    // At this point the Inode-Tree contains the parent dentry and child inode
     // we can safely remove this dentry from both the parent mapper, and the Inode Tree.
 
@@ -1897,7 +1989,10 @@
             if( inode_children != 0 )
             {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot remove <%s> inode that has children / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, cycle );
+#endif
                 remote_rwlock_wr_release( lock_xp );
-                printk("\n[ERROR] in %s : cannot remove <%s> inode that has children\n",
-                __FUNCTION__, path );
                 return -1;
             }
@@ -1908,7 +2003,10 @@
             if( error )
             {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot update FAT mapper to remove <s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, cycle );
+#endif
                 remote_rwlock_wr_release( lock_xp );
-                printk("\n[ERROR] in %s : cannot update FAT mapper to remove <%s> inode\n",
-                __FUNCTION__ , path );
                 return -1;
             }
@@ -1927,7 +2025,10 @@
         if( error )
         {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot update parent directory on IOC for <s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, cycle );
+#endif
             remote_rwlock_wr_release( lock_xp );
-            printk("\n[ERROR] in %s : cannot update dentry on device for <%s>\n",
-            __FUNCTION__ , path );
             return -1;
         }
@@ -1979,7 +2080,10 @@
     else
     {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] unsupported inode type %d for <s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, vfs_inode_type_str( inode_type ), path, cycle );
+#endif
         remote_rwlock_wr_release( lock_xp );
-        printk("\n[ERROR] in %s : unsupported inode type %s\n",
-        __FUNCTION__ , vfs_inode_type_str( inode_type ) );
         return -1;
     }
@@ -2004,4 +2108,8 @@
     process_t * process = this->process;
 
+#if DEBUG_VFS_STAT || DEBUG_VFS_ERROR
+uint32_t  cycle = (uint32_t)hal_get_cycles();
+#endif
+
     // build extended pointer on lock protecting Inode Tree (in VFS root inode)
     vfs_root_xp  = process->vfs_root_xp;
@@ -2025,6 +2133,9 @@
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot found inode <%s>\n",
-        __FUNCTION__ , path );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot found inode <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, cycle );
+#endif
         return -1;
     }
@@ -2050,10 +2161,7 @@
 
 #if DEBUG_VFS_STAT
-uint32_t cycle  = (uint32_t)hal_get_cycles();
 if( DEBUG_VFS_STAT < cycle )
-printk("\n[%s] thread[%x,%x] set stat %x for inode %x in cluster %x / cycle %d\n"
-       " %s / inum %d / size %d\n",
-__FUNCTION__, process->pid, this->trdid, st, inode_ptr, inode_cxy, cycle,
-vfs_inode_type_str( type ), inum, size );
+printk("\n[%s] thread[%x,%x] set stat for <%s> / %s / inum %d / size %d / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, vfs_inode_type_str( type ), inum, size, cycle );
 #endif
 
@@ -2084,9 +2192,6 @@
     process_t * process = this->process;
 
-#if DEBUG_VFS_CHDIR
-uint32_t cycle = (uint32_t)hal_get_cycles();
-if( DEBUG_VFS_CHDIR < cycle )
-printk("\n[%s] thread[%x,%x] enter for path <%s> / cycle %d\n",
-__FUNCTION__, process->pid, this->trdid, path, cycle );
+#if DEBUG_VFS_CHDIR || DEBUG_VFS_ERROR
+uint32_t  cycle = (uint32_t)hal_get_cycles();
 #endif
 
@@ -2112,6 +2217,9 @@
     if( error ) 
     {
-        printk("\n[ERROR] in %s : <%s> not found\n",
-        __FUNCTION__, path );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot found inode <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, cycle );
+#endif
         return -1;
     }
@@ -2124,6 +2232,9 @@
     if( inode_type != FILE_TYPE_DIR )
     {
-        printk("\n[ERROR] in %s : <%s> is not a directory\n",
-        __FUNCTION__, path );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] / <%s> is not a directory / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, cycle );
+#endif
         return -1;
     }
@@ -2146,9 +2257,7 @@
 
 #if DEBUG_VFS_CHDIR
-cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_VFS_CHDIR < cycle )
-printk("\n[%s] thread[%x,%x] exit : inode (%x,%x) / &cwd_xp (%x,%x) / cycle %d\n",
-__FUNCTION__, process->pid, this->trdid, inode_cxy, inode_ptr, 
-GET_CXY(cwd_xp_xp), GET_PTR(cwd_xp_xp), cycle );
+printk("\n[%s] thread[%x,%x] set new cwd <%s> / inode_xp (%x,%x) / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, inode_cxy, inode_ptr, cycle ); 
 #endif
 
@@ -2163,11 +2272,29 @@
 {
     error_t           error;
-    xptr_t            inode_xp;     // extended pointer on target inode
-    cxy_t             inode_cxy;    // inode cluster identifier       
-    vfs_inode_t     * inode_ptr;    // inode local pointer
-
-// check lookup working mode
-assert( __FUNCTION__, (rights == 0), "access rights non implemented yet" );
- 
+    xptr_t            vfs_root_xp;        // extended pointer on VFS root inode
+    vfs_inode_t     * vfs_root_ptr;       // local_pointer on VFS root inode
+    cxy_t             vfs_root_cxy;       // VFS root inode cluster identifier
+    xptr_t            main_lock_xp;       // extended pointer on lock protecting Inode Tree
+    xptr_t            inode_xp;           // extended pointer on target inode
+    cxy_t             inode_cxy;          // inode cluster identifier       
+    vfs_inode_t     * inode_ptr;          // inode local pointer
+    vfs_file_type_t   inode_type;         // inode type    
+
+    thread_t  * this    = CURRENT_THREAD;
+    process_t * process = this->process;
+
+#if DEBUG_VFS_CHMOD || DEBUG_VFS_ERROR
+uint32_t  cycle = (uint32_t)hal_get_cycles();
+#endif
+
+    // build extended pointer on lock protecting Inode Tree (in VFS root inode)
+    vfs_root_xp  = process->vfs_root_xp;
+    vfs_root_ptr = GET_PTR( vfs_root_xp );
+    vfs_root_cxy = GET_CXY( vfs_root_xp );
+    main_lock_xp = XPTR( vfs_root_cxy , &vfs_root_ptr->main_lock );
+
+    // take lock protecting Inode Tree in read mode
+    remote_rwlock_rd_acquire( main_lock_xp );
+
     // get extended pointer on target inode
     error = vfs_lookup( cwd_xp,
@@ -2177,5 +2304,16 @@
                         NULL );
 
-    if( error ) return error;
+    // release lock protecting Inode Tree in read mode
+    remote_rwlock_rd_release( main_lock_xp );
+
+    if( error ) 
+    {
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot found inode <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, cycle );
+#endif
+        return -1;
+    }
 
     // get inode cluster and local pointer
@@ -2184,12 +2322,18 @@
     
     // get inode type from remote inode
-    // inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) );
+    inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) );
 
     // TODO finalize implementation
 
-assert( __FUNCTION__, false , "not implemented" );
+assert( __FUNCTION__, false , "not fully implemented" );
 
     // set inode rights in remote inode
     hal_remote_s32( XPTR( inode_cxy , &inode_ptr->rights ) , rights );
+
+#if DEBUG_VFS_CHMOD
+if( DEBUG_VFS_CHMOD < cycle )
+printk("\n[%s] thread[%x,%x] set access rights %x for <%s> / inode_xp (%x,%x) / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, rights, path, inode_cxy, inode_ptr, cycle ); 
+#endif
 
     return 0;
@@ -2212,4 +2356,8 @@
     thread_t    * this    = CURRENT_THREAD;
     process_t   * process = this->process;
+
+#if DEBUG_VFS_MKFIFO || DEBUG_VFS_ERROR
+uint32_t  cycle = (uint32_t)hal_get_cycles();
+#endif
 
     // build extended pointer on lock protecting Inode Tree
@@ -2230,6 +2378,10 @@
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot get parent inode for <%s> path\n",
-        __FUNCTION__ , path );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot found parent inode for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, cycle );
+#endif
+        remote_rwlock_wr_release( vfs_lock_xp );
         return -1;
     }
@@ -2259,6 +2411,10 @@
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot create fifo inode for <%s> path\n",
-        __FUNCTION__ , path );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create fifo inode for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, cycle );
+#endif
+        remote_rwlock_wr_release( vfs_lock_xp );
         return -1;
     }
@@ -2270,6 +2426,11 @@
     if( pipe == NULL )
     {
-        printk("\n[ERROR] in %s : cannot create pipe for <%s> path\n",
-        __FUNCTION__ , path );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create pipe for <%s> / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, cycle );
+#endif
+        vfs_remove_child_from_parent( fifo_dentry_xp );
+        remote_rwlock_wr_release( vfs_lock_xp );
         return -1;
     }
@@ -2282,4 +2443,10 @@
     // release the lock protecting the Inode-Tree from write mode
     remote_rwlock_wr_release( vfs_lock_xp );
+
+#if DEBUG_VFS_MKDIR
+if( DEBUG_VFS_MKDIR < cycle )
+printk("\n[%s] thread[%x,%x] creared fifo <%s> / inode_xp [%x,%x] / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, path, fifo_cxy, fifo_inode_ptr, cycle ); 
+#endif
 
     return 0;
@@ -2746,7 +2913,6 @@
 
 #if DEBUG_VFS_ERROR  
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode <%s> in path <%s>\n",
-__FUNCTION__ , process->pid, this->trdid, name, pathname );
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode <%s> in path <%s> / cycle %d\n",
+__FUNCTION__ , process->pid, this->trdid, name, pathname, cycle );
 #endif
                     return -1;
@@ -2777,7 +2943,6 @@
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] cannot add dentry <%s> in parent dir\n",
-__FUNCTION__, process->pid, this->trdid, name );
+printk("\n[ERROR] in %s : thread[%x,%x] cannot add dentry <%s> in parent dir / cycle %d\n",
+__FUNCTION__, process->pid, this->trdid, name, cycle );
 #endif
                             vfs_remove_child_from_parent( dentry_xp );
@@ -2795,7 +2960,6 @@
 
 #if DEBUG_VFS_ERROR      
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] cannot found node <%s> in parent for <%s>\n",
-__FUNCTION__ , process->pid, this->trdid, name, pathname );
+printk("\n[ERROR] in %s : thread[%x,%x] cannot found node <%s> in parent for <%s> / cycle %d\n",
+__FUNCTION__ , process->pid, this->trdid, name, pathname, cycle );
 #endif
                         vfs_remove_child_from_parent( dentry_xp );
@@ -2810,7 +2974,6 @@
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s>  %\n",
-__FUNCTION__ , process->pid, this->trdid, pathname );
+printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s> / cycle %d\n",
+__FUNCTION__ , process->pid, this->trdid, pathname, cycle );
 #endif
                        return -1;
@@ -2831,7 +2994,6 @@
                         {
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] cannot load <%s> from device\n",
-__FUNCTION__ , process->pid, this->trdid, name );
+printk("\n[ERROR] in %s : thread[%x,%x] cannot load <%s> from device / cycle %d\n",
+__FUNCTION__ , process->pid, this->trdid, name, cycle );
 #endif
                             vfs_remove_child_from_parent( dentry_xp );
@@ -2864,7 +3026,6 @@
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s>\n",
-__FUNCTION__ , process->pid, this->trdid, pathname );
+printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s> / cycle %d\n",
+__FUNCTION__ , process->pid, this->trdid, pathname, cycle );
 #endif
                 return -1;
@@ -2946,7 +3107,11 @@
     xptr_t          children_entry_xp; // extended pointer on dentry "children" field
 
+#if DEBUG_VFS_ADD_SPECIAL || DEBUG_VFS_ERROR
+uint32_t    cycle   = (uint32_t)hal_get_cycles();
+thread_t  * this    = CURRENT_THREAD;
+process_t * process = this->process;
+#endif
+
 #if DEBUG_VFS_ADD_SPECIAL
-uint32_t   cycle = (uint32_t)hal_get_cycles();
-thread_t * this  = CURRENT_THREAD;
 char child_name[CONFIG_VFS_MAX_NAME_LENGTH];
 char parent_name[CONFIG_VFS_MAX_NAME_LENGTH];
@@ -2955,5 +3120,5 @@
 if( DEBUG_VFS_ADD_SPECIAL < cycle )
 printk("\n[%s] thread[%x,%x] enter for child <%s> in parent <%s> / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, child_name, parent_name, cycle );
+__FUNCTION__, process->pid, this->trdid, child_name, parent_name, cycle );
 #endif
 
@@ -2973,6 +3138,9 @@
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot create dentry <.> in cluster %x\n",
-        __FUNCTION__ , child_cxy );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <.> in cluster %x / cycle %d\n",
+__FUNCTION__ , process->pid, this->trdid, child_cxy, cycle );
+#endif
         return -1;
     }
@@ -2982,8 +3150,7 @@
 
 #if(DEBUG_VFS_ADD_SPECIAL & 1)
-cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_VFS_ADD_SPECIAL < cycle )
 printk("\n[%s] thread[%x,%x] created dentry <.> (%x,%x) / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, child_cxy, dentry_ptr, cycle );
+__FUNCTION__, process->pid, this->trdid, child_cxy, dentry_ptr, cycle );
 #endif
 
@@ -2996,6 +3163,9 @@
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot register dentry <.> in xhtab\n",
-        __FUNCTION__ );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <.> in xhtab / cycle %d\n",
+__FUNCTION__ , process->pid, this->trdid, cycle );
+#endif
         return -1;
     }
@@ -3009,5 +3179,5 @@
 if( DEBUG_VFS_ADD_SPECIAL < cycle )
 printk("\n[%s] thread[%x,%x] linked dentry <.> to parent and child inodes / cycle %d\n", 
-__FUNCTION__, this->process->pid, this->trdid, cycle ); 
+__FUNCTION__, process->pid, this->trdid, cycle ); 
 #endif
 
@@ -3020,6 +3190,9 @@
         if( error )
         {
-            printk("\n[ERROR] in %s : cannot introduce dentry <..> in mapper %x\n",
-            __FUNCTION__ );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <.> in mapper / cycle %d\n",
+__FUNCTION__ , process->pid, this->trdid, cycle );
+#endif
             return -1;
         }
@@ -3029,5 +3202,5 @@
 if( DEBUG_VFS_ADD_SPECIAL < cycle )
 printk("\n[%s] thread[%x,%x] registered dentry <.> in child mapper / cycle %d\n", 
-__FUNCTION__, this->process->pid, this->trdid, cycle ); 
+__FUNCTION__, process->pid, this->trdid, cycle ); 
 #endif
 
@@ -3041,6 +3214,9 @@
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot create dentry <..> in cluster %x\n",
-        __FUNCTION__ , child_cxy );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <..> in cluster %x / cycle %d\n",
+__FUNCTION__ , process->pid, this->trdid, child_cxy, cycle );
+#endif
         return -1;
     }
@@ -3053,5 +3229,5 @@
 if( DEBUG_VFS_ADD_SPECIAL < cycle )
 printk("\n[%s] thread[%x,%x] created dentry <..> (%x,%x) / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, child_cxy, dentry_ptr, cycle );
+__FUNCTION__, process->pid, this->trdid, child_cxy, dentry_ptr, cycle );
 #endif
 
@@ -3059,9 +3235,14 @@
     children_xhtab_xp = XPTR( child_cxy , &child_ptr->children );
     children_entry_xp = XPTR( child_cxy , &dentry_ptr->children );
+
     error = xhtab_insert( children_xhtab_xp , ".." , children_entry_xp );
+
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot register dentry <..> in xhtab\n",
-        __FUNCTION__ );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <..> in xhtab / cycle %d\n",
+__FUNCTION__ , process->pid, this->trdid, cycle );
+#endif
         return -1;
     }
@@ -3077,5 +3258,5 @@
 if( DEBUG_VFS_ADD_SPECIAL < cycle )
 printk("\n[%s] thread[%x,%x] linked dentry <..> to parent and child inodes / cycle %d\n", 
-__FUNCTION__, this->process->pid, this->trdid, cycle ); 
+__FUNCTION__, process->pid, this->trdid, cycle ); 
 #endif
 
@@ -3088,6 +3269,9 @@
         if( error )
         {
-            printk("\n[ERROR] in %s : cannot introduce dentry <..> in mapper %x\n",
-            __FUNCTION__ );
+
+#if DEBUG_VFS_ERROR
+printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <..> in mapper / cycle %d\n",
+__FUNCTION__ , process->pid, this->trdid, cycle );
+#endif
             return -1;
         }
@@ -3097,5 +3281,5 @@
 if( DEBUG_VFS_ADD_SPECIAL < cycle )
 printk("\n[%s] thread[%x,%x] registered dentry <..> in child mapper / cycle %d\n", 
-__FUNCTION__, this->process->pid, this->trdid, cycle ); 
+__FUNCTION__, process->pid, this->trdid, cycle ); 
 #endif
 
@@ -3106,5 +3290,5 @@
 if( DEBUG_VFS_ADD_SPECIAL < cycle )
 printk("\n[%s] thread[%x,%x] exit for child <%s> in parent <%s> / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, child_name, parent_name, cycle );
+__FUNCTION__, process->pid, this->trdid, child_name, parent_name, cycle );
 #endif
 
@@ -3139,5 +3323,8 @@
 
 #if DEBUG_VFS_GET_PATH
-uint32_t cycle = (uint32_t)hal_get_cycles();
+uint32_t    cycle   = (uint32_t)hal_get_cycles();
+#endif
+
+#if DEBUG_VFS_GET_PATH
 if( DEBUG_VFS_GET_PATH < cycle )
 printk("\n[%s] thread[%x,%x] enter : inode (%x,%x) / cycle %d\n",
@@ -3296,7 +3483,6 @@
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <%s> in cluster %x\n",
-__FUNCTION__ , this->process->pid, this->trdid , name , parent_cxy );
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <%s> in cluster %x / cycle %d\n",
+__FUNCTION__ , this->process->pid, this->trdid , name , parent_cxy, cycle );
 #endif
         return -1;
@@ -3330,7 +3516,6 @@
 
 #if DEBUG_VFS_ERROR
-if( DEBUG_VFS_ERROR < cycle )
-printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode in cluster %x\n",
-__FUNCTION__ , this->process->pid , this->trdid , child_cxy );
+printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode in cluster %x / cycle %d\n",
+__FUNCTION__ , this->process->pid , this->trdid , child_cxy, cycle );
 #endif
  
@@ -3428,5 +3613,4 @@
 
 #if DEBUG_VFS_REMOVE_CHILD
-if( DEBUG_VFS_REMOVE_CHILD < cycle )
 printk("\n[%s] thread[%x,%x] enter for dentry[%x,%x] / inode[%x,%x] / cycle %d\n",
 __FUNCTION__, this->process->pid, this->trdid,
@@ -3441,13 +3625,12 @@
     if( error )
     { 
-        printk("\n[WARNING] in %s] thread[%x,%x] cannot remove dentry %s from parent dir\n",
-        __FUNCTION__, this->process->pid, this->trdid, dentry_name ); 
-    }
-
-#if DEBUG_VFS_REMOVE_CHILD
-cycle = (uint32_t)hal_get_cycles();
+        printk("\n[WARNING] in %s : thread[%x,%x] cannot remove dentry <%s> from parent\n",
+        __FUNCTION__ , this->process->pid , this->trdid , dentry_name );
+    }
+
+#if(DEBUG_VFS_REMOVE_CHILD & 1)
 if( DEBUG_VFS_REMOVE_CHILD < cycle )
-printk("\n[%s] thread[%x,%x] removed dentry from parent inode / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, cycle );
+printk("\n[%s] thread[%x,%x] removed dentry from parent inode\n",
+__FUNCTION__, this->process->pid, this->trdid );
 #endif
 
@@ -3458,9 +3641,8 @@
     links = hal_remote_atomic_add( XPTR( child_cxy , &child_inode_ptr->links ) , -1 );
 
-#if DEBUG_VFS_REMOVE_CHILD
-cycle = (uint32_t)hal_get_cycles();
+#if(DEBUG_VFS_REMOVE_CHILD & 1)
 if( DEBUG_VFS_REMOVE_CHILD < cycle )
-printk("\n[%s] thread[%x,%x] removed dentry from child inode / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, cycle );
+printk("\n[%s] thread[%x,%x] removed dentry from child inode\n",
+__FUNCTION__, this->process->pid, this->trdid );
 #endif
 
@@ -3723,12 +3905,5 @@
 assert( __FUNCTION__, (array != NULL) , "child pointer is NULL");
 assert( __FUNCTION__, (detailed == false) , "detailed argument not supported\n");
-
-    // check inode type
-    if( inode->type != FILE_TYPE_DIR )
-    {
-        printk("\n[ERROR] in %s : target inode is not a directory\n",
-        __FUNCTION__ );
-        return -1;
-    }
+assert( __FUNCTION__, (inode->type == FILE_TYPE_DIR), "inode is not a directory\n");
 
     // get parent inode FS type
