[En-Nut-Discussion] How to get free memory space on SD Memory card

Ole Reinhardt ole.reinhardt at embedded-it.de
Wed Apr 30 17:43:52 CEST 2008


Hello,

> we implemented Ethernut 1.3H with SD-Memory card (256MB)(managed by Ethernut PHATFS) in our measuring devices. The measured data can be stored on the SD-Card. The web-pages of the internal web server are stored on the SD-Card too. Now, the operator wants to see how many memory space is available to store measured data.
> I did not found how to get the free memory space on the SD memory card. The SD memory card is installed in the unit, it is not available to put it temporary in an external memory card reader.

Good question. Perhaps this might help you:

Try a ioctl on the block device:

BLKPAR_INFO info;
MmCardIOCtl(&devNplMmc0, NUTBLKDEV_INFO, &info);

You'll retrieve now the number of blocks and the size of one block in 

info.par_nblks;
info.par_blksz;

So you know how large your device is.

Next you could iterate over all your files and sum up the filesizes.

Add some extra space for filesystem management information and now fully
filled blocks. This will give you a way to estimate how many space you
still have!

At least it's a quite expensive operation to iterate over all files and
not an exact value how much space is still free. 

Is there any better way to obtain free space?

Regards,

Ole Reinhardt


-- 
 _____________________________________________________________
|                                                             |
| Embedded-IT          Hard- und Softwarelösungen             |
|                                                             |
| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
| 57076 Siegen         eMail:    ole.reinhardt at embedded-it.de |
| Germany              Web:         http://www.embedded-it.de |
|                      UstID / VAT:       DE198944716         |
|_____________________________________________________________|




More information about the En-Nut-Discussion mailing list