* [ECOS] CYGSEM_FILEIO_BLOCK_USAGE, was Re: reading size and used space on compact flash (CF) card?
@ 2012-07-02 21:41 Ken Yee
0 siblings, 0 replies; only message in thread
From: Ken Yee @ 2012-07-02 21:41 UTC (permalink / raw)
To: ecos-discuss
So after a bit more hacking, I finally got this to work :-)
The problem was that in ecos/packages/fs/fat/fatfs.c, the code still uses this old #define CYGSEM_FILEIO_BLOCK_USAGE so it was always returning EINVAL. Here are the fixes to get it to work w/ the new DISK_USAGE rename that is generated by configtool:
//#if defined(CYGSEM_FILEIO_BLOCK_USAGE)
// case FS_INFO_BLOCK_USAGE: {
#if defined(CYGSEM_FILEIO_INFO_DISK_USAGE)
case FS_INFO_DISK_USAGE: {
cyg_uint32 total_clusters;
cyg_uint32 free_clusters;
// struct cyg_fs_block_usage *usage = (struct cyg_fs_block_usage *) buf;
struct cyg_fs_disk_usage *usage = (struct cyg_fs_disk_usage *) buf;
And the code that uses the official ecos APIs is to read space/usage, etc is:
struct cyg_fs_disk_usage usage;
int err = cyg_fs_getinfo(path, FS_INFO_DISK_USAGE, &usage, sizeof(usage));
if ( err == 0 ) {
uint64_t blksize, totalblocks, freeblks;
totalblocks = usage.total_blocks;
freeblks = usage.free_blocks;
blksize = usage.block_size;
diskSize = totalblocks*blksize;
freeSpace = freeblks*blksize;
usedSpace = diskSize - freeSpace;
return true;
}
And wow, it's slow....2min 20sec to get free space on a 32MB card on an ancient Atmel 14MHz AT91 processor :-P
ken
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-07-02 21:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-02 21:41 [ECOS] CYGSEM_FILEIO_BLOCK_USAGE, was Re: reading size and used space on compact flash (CF) card? Ken Yee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).