]> git.kernelconcepts.de Git - karo-tx-redboot.git/blobdiff - packages/fs/rom/v2_0/tests/romfs1.c
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / fs / rom / v2_0 / tests / romfs1.c
index 1d32bb0421c0703c8dbf65a98b8304c90cf97e4c..d4c7b7046d3c2ca5cf12b9a62fad72bbbf8b866b 100644 (file)
@@ -56,6 +56,7 @@
 #include <pkgconf/io_fileio.h>
 #include <pkgconf/isoinfra.h>
 #include <pkgconf/system.h>
+#include <pkgconf/fs_rom.h>
 
 #include <unistd.h>
 #include <fcntl.h>
@@ -91,11 +92,11 @@ MTAB_ENTRY( romfs_mte1,
 //==========================================================================
 
 #define SHOW_RESULT( _fn, _res ) \
-diag_printf("<FAIL>: " #_fn "() returned %d %s\n", _res, _res<0?strerror(errno):"");
+  diag_printf("<FAIL>: " #_fn "() returned %d %s\n", (int)_res, _res<0?strerror(errno):"");
 
 #define CHKFAIL_TYPE( _fn, _res, _type ) { \
 if ( _res != -1 ) \
-    diag_printf("<FAIL>: " #_fn "() returned %d (expected -1)\n", _res); \
+  diag_printf("<FAIL>: " #_fn "() returned %d (expected -1)\n", (int)_res); \
 else if ( errno != _type ) \
     diag_printf("<FAIL>: " #_fn "() failed with errno %d (%s),\n    expected %d (%s)\n", errno, strerror(errno), _type, strerror(_type) ); \
 }
@@ -142,6 +143,9 @@ static void listdir( char *name, int statp )
             break;
 
         diag_printf("<INFO>: entry %14s",entry->d_name);
+#ifdef CYGPKG_FS_ROM_RET_DIRENT_DTYPE
+        diag_printf(" d_type %2x", entry->d_type);
+#endif
         if( statp )
         {
             char fullname[PATH_MAX];
@@ -166,9 +170,13 @@ static void listdir( char *name, int statp )
             }
             else
             {
-                diag_printf(" [mode %08x ino %08x nlink %d size %d]",
+                diag_printf(" [mode %08x ino %08x nlink %d size %ld]",
                             sbuf.st_mode,sbuf.st_ino,sbuf.st_nlink,sbuf.st_size);
             }
+#ifdef CYGPKG_FS_ROM_RET_DIRENT_DTYPE
+            if ((entry->d_type & S_IFMT) != (sbuf.st_mode & S_IFMT))
+              CYG_TEST_FAIL("File mode's don't match between dirent and stat");
+#endif
         }
 
         diag_printf("\n");
@@ -286,6 +294,9 @@ int main( int argc, char **argv )
 {
     int err;
     char address[16];
+#if defined(CYGSEM_FILEIO_BLOCK_USAGE)
+    struct cyg_fs_block_usage usage;
+#endif
 
     CYG_TEST_INIT();
 
@@ -377,6 +388,17 @@ int main( int argc, char **argv )
     CHKFAIL_TYPE( umount, err, EINVAL );
 #endif
 
+#if defined(CYGSEM_FILEIO_BLOCK_USAGE)
+    err = cyg_fs_getinfo("/", FS_INFO_BLOCK_USAGE, &usage, sizeof(usage));
+    if( err < 0 ) SHOW_RESULT( cyg_fs_getinfo, err );
+    diag_printf("<INFO>: total size: %6lld blocks, %10lld bytes\n",
+               usage.total_blocks, usage.total_blocks * usage.block_size); 
+    diag_printf("<INFO>: free size:  %6lld blocks, %10lld bytes\n",
+               usage.free_blocks, usage.free_blocks * usage.block_size); 
+    diag_printf("<INFO>: block size: %6u bytes\n", usage.block_size);
+#endif
+    // --------------------------------------------------------------
+
     err = umount( "/" );
     if( err < 0 ) SHOW_RESULT( umount, err );