diff packages/fs/fat/current/src/fatfs.c @ 2262:c393118a9636

* 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.
author asl
date Fri, 04 Aug 2006 09:22:04 +0000
parents 7858ca9e2cfe
children fe481a165385
line wrap: on
line diff
--- a/packages/fs/fat/current/src/fatfs.c
+++ b/packages/fs/fat/current/src/fatfs.c
@@ -1109,6 +1109,22 @@ fatfs_getinfo(cyg_mtab_entry *mte,
             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;