Index: soft/giet_vm/giet_kernel/sys_handler.c
===================================================================
--- soft/giet_vm/giet_kernel/sys_handler.c	(revision 760)
+++ soft/giet_vm/giet_kernel/sys_handler.c	(revision 774)
@@ -243,5 +243,5 @@
     &_sys_fat_mmap,                  /* 0x2D */
     &_sys_fat_munmap,                /* 0x2E */
-    &_sys_ukn,                       /* 0x2F */
+    &_sys_fat_dump,                  /* 0x2F */
 
 #if NB_NIC_CHANNELS
@@ -535,5 +535,5 @@
 #if GIET_DEBUG_MMAP
 if ( _get_proctime() > GIET_DEBUG_MMAP )
-_printf("\n[DEBUG MMAP] _sys_fat_mmap() : P[%d,%d,%d] map cluster %d\n"
+_printf("\n[DEBUG MMAP] _sys_fat_mmap() : P[%d,%d,%d] map cluster_id = %d\n"
         " user_vaddr = %x / cache_paddr = %l\n",
         x_id , y_id , p_id , cid , user_vaddr , cache_paddr );
@@ -591,4 +591,180 @@
     return 0;
 }  // end _sys_fat_munmap()
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// This service function is called by the _sys_fat_dump() kernel function.
+// It displays on the calling thread terminal the content of a 512 bytes buffer
+// defined by the <buf> pointer.
+// The <string> , <cluster_id> and <block_id> arguments are only used 
+// to build a meaningful title: <string> is an identifier, <cluster_id> is 
+// the cluster index (in file or FAT), <block_id> is the block index (in cluster).
+///////////////////////////////////////////////////////////////////////////////////
+static void _dump_block( unsigned char* buf,
+                             char*          string,
+                             unsigned int   cluster_id,
+                             unsigned int   block_id )
+{
+    unsigned int line;
+    unsigned int word;
+
+    _user_printf("\n---  %s / cluster_id = %d / block_id = %d ---\n",
+            string , cluster_id , block_id );
+
+    for ( line = 0 ; line < 16 ; line++ )
+    {
+        // display line index 
+        _user_printf("%x : ", line );
+
+        // display 8*4 bytes hexa per line
+        for ( word=0 ; word<8 ; word++ )
+        {
+            unsigned int byte  = (line<<5) + (word<<2);
+            unsigned int hexa  = (buf[byte  ]<<24) |
+                                 (buf[byte+1]<<16) |
+                                 (buf[byte+2]<< 8) |
+                                 (buf[byte+3]      );
+            _user_printf(" %X |", hexa );
+        }
+        _user_printf("\n");
+    }
+} // end _dump_block()  
+
+
+///////////////////////////////////////////////////////////////////////////////////
+// This function implements the giet_fat_dump() system call.
+// It analyse the <type>, <pathname> and <sector_id> arguments to select
+// a 512 bytes sector, and display the sector content on the calling thread TTY.
+// The <type> argument can take the following values :
+// - DUMP_BS   : boot sector
+// - DUMP_FS   : fs_info sector
+// - DUMP_FAT  : fat sector, identified by <sector_id>
+// - DUMP_FILE : file sector, identified by <pathname> and <sector_id>
+// - DUMP_DIR  : directory sector, identified by <pathname> and <sector_id>
+// The <sector_id> argument defines the sector index in the file or in the FAT.
+// For a file or a directory, or for the FAT itself, it uses the kernel File-Caches
+// or Fat-Cache, and the Inode-Tree.
+// For the boot sector, or fs_info sector, it access directly the block device,
+// that is loaded in the FAT descriptor block-buffer.
+///////////////////////////////////////////////////////////////////////////////////
+// Returns 0 in case of success.
+// Returns 1 in case of error.
+///////////////////////////////////////////////////////////////////////////////////
+int _sys_fat_dump( unsigned int type,
+                   char*        pathname,
+                   unsigned int sector_id )
+{
+    unsigned char* buf;                            // pointer on 512 bytes buffer
+    unsigned int   cluster_id = sector_id >> 3;    // cluster index in cache
+    unsigned int   block_id   = sector_id & 0x7;   // cluster index in cache
+    unsigned int   fd_id;                          // file/dir descriptor index
+    
+    if( type == DUMP_BS )            // dump the boot sector
+    {
+        // access block_device
+        buf = _fat.block_buffer; 
+        if ( _fat_ioc_access( 1,                   // descheduling mode
+                              1,                   // read 
+                              0,                   // boot sector lba
+                              (unsigned int)buf,
+                              1 ) )                // one block                    
+        {
+            _printf("\n[FAT ERROR] _sys_fat_dump(): cannot access device for BS\n");
+            return 1;
+        }
+        _fat.block_buffer_lba = 0;
+
+        // dump boot sector
+        _dump_block( buf, "boot sector" , 0 , 0 );
+    }
+    else if ( type == DUMP_FS )     // dump the fs_info sector
+    {
+        // access block_device
+        buf = _fat.block_buffer; 
+        if ( _fat_ioc_access( 1,                  // descheduling mode
+                              1,                  // read 
+                              _fat.fs_info_lba,   // fs_info sector lba
+                              (unsigned int)buf,
+                              1 ) )               // one block                    
+        {
+            _printf("\n[FAT ERROR] _sys_fat_dump(): cannot access device for FS\n");
+            return 1;
+        }
+        _fat.block_buffer_lba = _fat.fs_info_lba;
+
+        // dump fs-info sector
+        _dump_block( buf, "fs_info sector" , 0 , 0 );
+    }
+    else if ( type == DUMP_FAT )    // dump a fat sector
+    {
+        // get pointer on the relevant buffer descriptor in Fat-Cache
+        fat_cache_desc_t*  pdesc;
+        if ( _get_fat_cache_buffer( cluster_id, &pdesc ) )         
+        {
+            _printf("\n[FAT ERROR] _sys_fat_dump(): cannot access Fat-Cache\n");
+            return 1;
+        }
+        buf = pdesc->buffer + (block_id<<9);
+
+        // dump fat sector
+        _dump_block( buf, "fat" , cluster_id , block_id );
+    }
+    else if ( type == DUMP_FILE )    // dump a file sector
+    {
+        // open file 
+        fd_id = _fat_open( pathname , O_RDONLY );
+        if ( fd_id < 0 )
+        {
+            _printf("\n[FAT ERROR] _sys_fat_dump(): cannot open file <%s>\n", pathname );
+            return 1;
+        }
+        fat_inode_t* inode = _fat.fd[fd_id].inode;
+
+        // get pointer on the relevant buffer descriptor in File-Cache
+        fat_cache_desc_t*  pdesc;
+        if ( _get_file_cache_buffer( inode, cluster_id, 0, &pdesc ) )         
+        {
+            _printf("\n[FAT ERROR] _sys_fat_dump(): cannot access file <%s>\n", pathname );
+            return 1;
+        }
+        buf = pdesc->buffer + (block_id<<9);
+
+        // dump file sector
+        _dump_block( buf, pathname , cluster_id , block_id );
+
+        // close file
+        _fat_close( fd_id );
+    }
+    else if ( type == DUMP_DIR )    // dump a directory sector
+    {
+        // open directory 
+        fd_id = _fat_opendir( pathname );
+        if ( fd_id < 0 )
+        {
+            _printf("\n[FAT ERROR] _sys_fat_dump(): cannot open <%s>\n", pathname );
+            return 1;
+        }
+        fat_inode_t* inode = _fat.fd[fd_id].inode;
+
+        // get pointer on the relevant buffer descriptor in File-Cache
+        fat_cache_desc_t*  pdesc;
+        if ( _get_file_cache_buffer( inode, cluster_id, 0, &pdesc ) )         
+        {
+            _printf("\n[FAT ERROR] _sys_fat_dump(): cannot access <%s>\n", pathname );
+            return 1;
+        }
+        buf = pdesc->buffer + (block_id<<9);
+
+        // dump directory sector
+        _dump_block( buf, pathname , cluster_id , block_id );
+
+        // close directory
+        _fat_closedir( fd_id );
+    }
+
+    return 0;
+}  // end sys_fat_dump
 
 
