Index: fs/fat/current/ChangeLog =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/fat/current/ChangeLog,v retrieving revision 1.12 diff -u -r1.12 ChangeLog --- fs/fat/current/ChangeLog 3 Aug 2005 20:40:48 -0000 1.12 +++ fs/fat/current/ChangeLog 4 Aug 2006 09:15:54 -0000 @@ -1,3 +1,11 @@ +2006-08-04 Paul Fine + Andrew Lunn + + * src/fats.c: Added functionality to the fatfs_getinfo() function + to return disk usage information about the filesystem, making this + information accessible through the cyg_fs_getinfo() interface. + * tests/fatfs1.c: Added code to test the disk usage. + 2005-07-30 Andrew Lunn * src/fatfs_supp.c: Correct types to remove compiler warnings. Index: fs/fat/current/src/fatfs.c =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/fat/current/src/fatfs.c,v retrieving revision 1.4 diff -u -r1.4 fatfs.c --- fs/fat/current/src/fatfs.c 11 Nov 2004 19:33:30 -0000 1.4 +++ fs/fat/current/src/fatfs.c 4 Aug 2006 09:15:54 -0000 @@ -1109,6 +1109,22 @@ err = fatfs_get_attrib(mte, dir, name, (cyg_fs_attrib_t*)buf); break; #endif // CYGCFG_FS_FAT_USE_ATTRIBUTES +#if defined(CYGSEM_FILEIO_BLOCK_USAGE) + case FS_INFO_BLOCK_USAGE: { + cyg_uint32 total_clusters; + cyg_uint32 free_clusters; + struct cyg_fs_block_usage *usage = (struct cyg_fs_block_usage *) buf; + fatfs_disk_t *disk = (fatfs_disk_t *) mte->data; + + err = fatfs_get_disk_usage(disk, &total_clusters, &free_clusters); + if (err) + return err; + usage->total_blocks = total_clusters; + usage->free_blocks = free_clusters; + usage->block_size = disk->cluster_size; + break; + } +#endif default: err = EINVAL; break; Index: fs/fat/current/tests/fatfs1.c =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/fat/current/tests/fatfs1.c,v retrieving revision 1.2 diff -u -r1.2 fatfs1.c --- fs/fat/current/tests/fatfs1.c 27 Mar 2005 18:22:01 -0000 1.2 +++ fs/fat/current/tests/fatfs1.c 4 Aug 2006 09:15:54 -0000 @@ -432,6 +432,9 @@ { int err; int existingdirents=-1; +#if defined(CYGSEM_FILEIO_BLOCK_USAGE) + struct cyg_fs_block_usage usage; +#endif CYG_TEST_INIT(); @@ -448,6 +451,16 @@ listdir( "/", true, -1, &existingdirents ); // -------------------------------------------------------------- +#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(": total size: %6lld blocks, %10lld bytes\n", + usage.total_blocks, usage.total_blocks * usage.block_size); + diag_printf(": free size: %6lld blocks, %10lld bytes\n", + usage.free_blocks, usage.free_blocks * usage.block_size); + diag_printf(": block size: %6u bytes\n", usage.block_size); +#endif + // -------------------------------------------------------------- createfile( "/foo", 20257 ); checkfile( "foo" ); @@ -480,6 +493,15 @@ checkfile( "/bar/bundy" ); comparefiles("/fee", "bundy" ); +#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(": total size: %6lld blocks, %10lld bytes\n", + usage.total_blocks, usage.total_blocks * usage.block_size); + diag_printf(": free size: %6lld blocks, %10lld bytes\n", + usage.free_blocks, usage.free_blocks * usage.block_size); + diag_printf(": block size: %6u bytes\n", usage.block_size); +#endif // -------------------------------------------------------------- diag_printf(": unlink fee\n");