Index: /soft/giet_vm/giet_fat32/fat32.c
===================================================================
--- /soft/giet_vm/giet_fat32/fat32.c	(revision 259)
+++ /soft/giet_vm/giet_fat32/fat32.c	(revision 260)
@@ -1309,4 +1309,33 @@
 
 /////////////////////////////////////////////////////////////////////////////////
+// Return stats of a file identified by "fd". 
+// (Only the file_size in sectors for this moment)
+/////////////////////////////////////////////////////////////////////////////////
+// Returns file size (on sectors) on success, -1 on failure.
+/////////////////////////////////////////////////////////////////////////////////
+int _fat_fstat( unsigned int fd_id )
+{
+    unsigned int file_size    = 0;
+    unsigned int file_sectors = 0;
+
+    if( (fd_id < GIET_OPEN_FILES_MAX) )
+    {
+        file_size = fat.fd[fd_id].file_size;
+
+        if ( file_size & 0x1FF ) file_sectors = (file_size >> 9) + 1;
+        else                     file_sectors = (file_size >> 9); 
+
+        return file_sectors;
+    }
+    else
+    {
+        _tty_get_lock( 0 );
+        _puts("\n[FAT ERROR] in _fat_fstat() : illegal file descriptor index\n");
+        _tty_release_lock( 0 );
+        return -1;
+    } 
+} // end _fat_fstat()
+
+/////////////////////////////////////////////////////////////////////////////////
 // Close the file identified by the file_descriptor index. 
 /////////////////////////////////////////////////////////////////////////////////
Index: /soft/giet_vm/giet_fat32/fat32.h
===================================================================
--- /soft/giet_vm/giet_fat32/fat32.h	(revision 259)
+++ /soft/giet_vm/giet_fat32/fat32.h	(revision 260)
@@ -174,4 +174,6 @@
                        unsigned int offset );     // offset sector in file
 
+extern int _fat_fstat( unsigned int fd_id );      // file descriptor index
+
 extern int _fat_close( unsigned int fd_id );      // file descriptor index
 
Index: /soft/giet_vm/giet_kernel/sys_handler.c
===================================================================
--- /soft/giet_vm/giet_kernel/sys_handler.c	(revision 259)
+++ /soft/giet_vm/giet_kernel/sys_handler.c	(revision 260)
@@ -67,6 +67,6 @@
     &_fat_user_write,      /* 0x22 */
     &_fat_user_lseek,      /* 0x23 */
-    &_fat_close,           /* 0x24 */
-    &_sys_ukn,             /* 0x25 */
+    &_fat_fstat,           /* 0x24 */
+    &_fat_close,           /* 0x25 */
     &_sys_ukn,             /* 0x26 */
     &_sys_ukn,             /* 0x27 */
Index: /soft/giet_vm/giet_libs/stdio.c
===================================================================
--- /soft/giet_vm/giet_libs/stdio.c	(revision 259)
+++ /soft/giet_vm/giet_libs/stdio.c	(revision 260)
@@ -744,4 +744,18 @@
                      0 );
 }
+
+///////////////////////////////////////////////////////////////////////////////////
+// giet_fat_fstat()
+///////////////////////////////////////////////////////////////////////////////////
+// Return stats of a file identified by "fd". 
+// (Only the file_size in sectors for this moment)
+///////////////////////////////////////////////////////////////////////////////////
+int giet_fat_fstat( unsigned int fd )
+{
+    return sys_call( SYSCALL_FAT_FSTAT,
+                     fd,
+                     0, 0, 0 );
+}
+
 ///////////////////////////////////////////////////////////////////////////////////
 // giet_fat_close()
Index: /soft/giet_vm/giet_libs/stdio.h
===================================================================
--- /soft/giet_vm/giet_libs/stdio.h	(revision 259)
+++ /soft/giet_vm/giet_libs/stdio.h	(revision 260)
@@ -50,5 +50,6 @@
 #define SYSCALL_FAT_WRITE         0x22
 #define SYSCALL_FAT_LSEEK         0x23
-#define SYSCALL_FAT_CLOSE         0x24
+#define SYSCALL_FAT_FSTAT         0x24
+#define SYSCALL_FAT_CLOSE         0x25
 
 //////////////////////////////////////////////////////////////////////////////////
@@ -182,4 +183,6 @@
                            unsigned int whence );
 
+extern int giet_fat_fstat( unsigned int fd );
+
 extern int giet_fat_close( unsigned int fd );
 
