Index: trunk/kernel/syscalls/sys_display.c
===================================================================
--- trunk/kernel/syscalls/sys_display.c	(revision 438)
+++ trunk/kernel/syscalls/sys_display.c	(revision 440)
@@ -2,5 +2,5 @@
  * sys_display.c - display the current state of a kernel structure on TXT0
  *
- * Author    Alain Greiner (2016,2017)
+ * Author    Alain Greiner (2016,2017,2018)
  *  
  * Copyright (c) UPMC Sorbonne Universites
@@ -38,9 +38,13 @@
 {
 
+    error_t     error;
+    vseg_t    * vseg;
+
+    thread_t  * this    = CURRENT_THREAD;
+    process_t * process = this->process;
+
 #if DEBUG_SYS_DISPLAY
 uint64_t    tm_start;
 uint64_t    tm_end;
-thread_t  * this;
-this     = CURRENT_THREAD;
 tm_start = hal_get_cycles();
 if( DEBUG_SYS_DISPLAY < tm_start )
@@ -49,17 +53,23 @@
 #endif
 
+    ////////////////////////////
     if( type == DISPLAY_STRING )
     {
-        paddr_t   paddr;
         char      kbuf[256];
         uint32_t  length;
 
         char    * string = (char *)arg0;
- 
+
         // check string in user space
-        if( vmm_v2p_translate( false , string , &paddr ) )
-        {
-            printk("\n[ERROR] in %s : string buffer %x unmapped\n",
-            __FUNCTION__ , string );
+        error = vmm_get_vseg( process , (intptr_t)arg0 , &vseg );
+
+        if( error )
+        {
+
+#if DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : string buffer %x unmapped / thread %x / process %x\n",
+__FUNCTION__ , (intptr_t)arg0 , this->trdid , process->pid );
+#endif
+            this->errno = EINVAL;
             return -1;
         }
@@ -67,17 +77,23 @@
         // ckeck string length
         length = hal_strlen_from_uspace( string );
+
         if( length >= 256 )
         {
-            printk("\n[ERROR] in %s : string length %d too large\n",
-            __FUNCTION__ , length );
-            return -1;
-        }
-
-        // copy string in kernel space
+
+#if DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : string length %d too large / thread %x / process %x\n",
+__FUNCTION__ , length , this->trdid , process->pid );
+#endif
+            this->errno = EINVAL;
+            return -1;
+        }
+
+        // copy string to kernel space
         hal_strcpy_from_uspace( kbuf , string , 256 );
 
         // print message on TXT0 kernel terminal
-        printk("\n[USER] %s / cycle %d\n", kbuf, (uint32_t)hal_get_cycles() );
-    }
+        printk("\n%s / cycle %d\n", kbuf, (uint32_t)hal_get_cycles() );
+    }
+    //////////////////////////////
     else if( type == DISPLAY_VMM )
     {
@@ -89,6 +105,10 @@
 	    if( process_xp == XPTR_NULL )
         {
-            printk("\n[ERROR] in %s : undefined PID %x\n",
-            __FUNCTION__ , pid );
+
+#if DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : undefined pid argument %d / thread %x / process %x\n",
+__FUNCTION__ , pid , this->trdid , process->pid );
+#endif
+            this->errno = EINVAL;
             return -1;
         }
@@ -108,4 +128,5 @@
         }
     }
+    ////////////////////////////////
     else if( type == DISPLAY_SCHED )
     {
@@ -113,17 +134,25 @@
         lid_t lid = (lid_t)arg1;
 
-        // check cluster argument
+        // check cxy argument
 	    if( cluster_is_undefined( cxy ) ) 
         {
-            printk("\n[ERROR] in %s : undefined cluster identifier %x\n",
-            __FUNCTION__ , cxy );
-            return -1;
-        }
-
-        // check core argument
+
+#if DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : illegal cxy argument %x / thread %x / process %x\n",
+__FUNCTION__ , cxy , this->trdid , process->pid );
+#endif
+            this->errno = EINVAL;
+            return -1;
+        }
+
+        // check lid argument
         if( lid >= LOCAL_CLUSTER->cores_nr )
         {
-            printk("\n[ERROR] in %s : undefined local index %d\n",
-            __FUNCTION__ , lid );
+
+#if DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : illegal lid argument %x / thread %x / process %x\n",
+__FUNCTION__ , lid , this->trdid , process->pid );
+#endif
+            this->errno = EINVAL;
             return -1;
         }
@@ -138,13 +167,18 @@
         }
     }
+    ////////////////////////////////////////////
     else if( type == DISPLAY_CLUSTER_PROCESSES )
     {
         cxy_t cxy = (cxy_t)arg0;
 
-        // check cluster argument
+        // check cxy argument
 	    if( cluster_is_undefined( cxy ) )
         {
-            printk("\n[ERROR] in %s : undefined cluster identifier %x\n",
-            __FUNCTION__ , cxy );
+
+#if DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : illegal cxy argument %x / thread %x / process %x\n",
+__FUNCTION__ , cxy , this->trdid , process->pid );
+#endif
+            this->errno = EINVAL;
             return -1;
         }
@@ -152,4 +186,5 @@
         cluster_processes_display( cxy );
     }
+    ////////////////////////////////////////
     else if( type == DISPLAY_TXT_PROCESSES )
     {
@@ -159,6 +194,10 @@
 	    if( txt_id >= LOCAL_CLUSTER->nb_txt_channels )
         {
-            printk("\n[ERROR] in %s : undefined TXT channel %x\n",
-            __FUNCTION__ , txt_id );
+
+#if DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : illegal txt_id argument %d / thread %x / process %x\n",
+__FUNCTION__ , txt_id , this->trdid , process->pid );
+#endif
+            this->errno = EINVAL;
             return -1;
         }
@@ -166,18 +205,23 @@
         process_txt_display( txt_id );
     }
+    //////////////////////////////
     else if( type == DISPLAY_VFS )
     {
-        // call kernel function
-        process_t * process = CURRENT_THREAD->process;
         vfs_display( process->vfs_root_xp );
     }
+    ////////////////////////////////
     else if( type == DISPLAY_CHDEV )
     {
         chdev_dir_display();
     }
+    ////
     else 
     {
-        printk("\n[ERROR] in %s : undefined display type %x\n",
-        __FUNCTION__ , type );
+
+#if DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : undefined display type %x / thread %x / process %x\n",
+        __FUNCTION__ , type , this->trdid , process->pid );
+#endif
+        this->errno = EINVAL;
         return -1;
     }
