Index: trunk/kernel/libk/elf.c
===================================================================
--- trunk/kernel/libk/elf.c	(revision 441)
+++ trunk/kernel/libk/elf.c	(revision 457)
@@ -23,5 +23,5 @@
 
 #include <kernel_config.h>
-#include <hal_types.h>
+#include <hal_kernel_types.h>
 #include <hal_special.h>
 #include <hal_uspace.h>
@@ -210,7 +210,7 @@
 } // end elf_segments_register()
 
-///////////////////////////////////////////////
-error_t elf_load_process( char      * pathname,
-                          process_t * process)
+//////////////////////////////////////////////
+error_t elf_load_process( xptr_t      file_xp,
+                          process_t * process )
 {
 	kmem_req_t   req;              // kmem request for program header
@@ -218,35 +218,18 @@
 	void       * segs_base;        // pointer on buffer for segment descriptors array
 	uint32_t     segs_size;        // size of buffer for segment descriptors array
-	xptr_t       file_xp;          // extended pointer on created file descriptor
-	uint32_t     file_id;          // file descriptor index (unused)
+    char         name[CONFIG_VFS_MAX_NAME_LENGTH];
 	error_t      error;
 
+    // get file name for error reporting and debug
+    cxy_t         file_cxy = GET_CXY( file_xp );
+    vfs_file_t  * file_ptr = GET_PTR( file_xp );
+    vfs_inode_t * inode    = hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) );
+    vfs_inode_get_name( XPTR( file_cxy , inode ) , name );
+    
 #if DEBUG_ELF_LOAD
-uint32_t cycle = (uint32_t)hal_get_cycles();
-if( DEBUG_ELF_LOAD < cycle )
-printk("\n[DBG] %s : thread %d enter for <%s> / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD, pathname, cycle );
-#endif
-
-    // avoid GCC warning
-	file_xp = XPTR_NULL;  
-	file_id = -1;
-
-	// open file
-	error = vfs_open( process,
-	                  pathname,
-	                  O_RDONLY,
-	                  0,
-	                  &file_xp,
-	                  &file_id );
-	if( error )
-	{
-		printk("\n[ERROR] in %s : failed to open file <%s>\n", __FUNCTION__ , pathname );
-		return -1;
-	}
-
-#if (DEBUG_ELF_LOAD & 1)
-if( DEBUG_ELF_LOAD < cycle )
-printk("\n[DBG] %s : open file <%s>\n", __FUNCTION__, pathname );
+uint32_t      cycle = (uint32_t)hal_get_cycles();
+if( DEBUG_ELF_LOAD < cycle )
+printk("\n[DBG] %s : thread %d in process %x enter for <%s> / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD->trdid, process->pid, name, cycle );
 #endif
 
@@ -257,6 +240,5 @@
 	if( error )
 	{
-		printk("\n[ERROR] in %s : cannot get header for <%s>\n", __FUNCTION__ , pathname );
-		vfs_close( file_xp , file_id );
+		printk("\n[ERROR] in %s : cannot get header for <%s>\n", __FUNCTION__ , name );
 		return -1;
 	}
@@ -264,5 +246,5 @@
 #if (DEBUG_ELF_LOAD & 1)
 if( DEBUG_ELF_LOAD < cycle )
-printk("\n[DBG] %s : loaded elf header for <%s>\n", __FUNCTION__ , pathname );
+printk("\n[DBG] %s : loaded elf header for <%s>\n", __FUNCTION__ , name );
 #endif
 
@@ -270,5 +252,4 @@
 	{
 		printk("\n[ERROR] in %s : no segments found\n", __FUNCTION__ );
-		vfs_close( file_xp , file_id );
 		return -1;
 	}
@@ -286,5 +267,4 @@
 	{
 		printk("\n[ERROR] in %s : no memory for segment descriptors\n", __FUNCTION__ );
-		vfs_close( file_xp , file_id );
 		return -1;
 	}
@@ -296,5 +276,4 @@
 	{
 		printk("\n[ERROR] in %s : cannot seek for descriptors array\n", __FUNCTION__ );
-		vfs_close( file_xp , file_id );
 		req.ptr = segs_base;
 		kmem_free( &req );
@@ -304,5 +283,5 @@
 #if (DEBUG_ELF_LOAD & 1)
 if( DEBUG_ELF_LOAD < cycle )
-printk("\n[DBG] %s : segments array allocated for <%s>\n", __FUNCTION__ , pathname );
+printk("\n[DBG] %s : segments array allocated for <%s>\n", __FUNCTION__ , name );
 #endif
 
@@ -316,5 +295,4 @@
 	{
 		printk("\n[ERROR] in %s : cannot read segments descriptors\n", __FUNCTION__ );
-		vfs_close( file_xp , file_id );
 		req.ptr = segs_base;
 		kmem_free( &req );
@@ -324,5 +302,5 @@
 #if (DEBUG_ELF_LOAD & 1)
 if( DEBUG_ELF_LOAD < cycle )
-printk("\n[DBG] %s loaded segments descriptors for <%s>\n", __FUNCTION__ , pathname );
+printk("\n[DBG] %s loaded segments descriptors for <%s>\n", __FUNCTION__ , name );
 #endif
 
@@ -334,5 +312,4 @@
 	if( error )
 	{
-		vfs_close( file_xp , file_id );
 		req.ptr = segs_base;
 		kmem_free( &req );
@@ -353,6 +330,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_ELF_LOAD < cycle )
-printk("\n[DBG] %s : thread %d exit for <%s> / entry_point %x / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD, pathname, header.e_entry, cycle );
+printk("\n[DBG] %s : thread %x in process %x exit for <%s> / entry_point %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD->trdid, process->pid, name, header.e_entry, cycle );
 #endif
 
