Problem with mounting a device second time.

Sebastian Huber sebastian.huber at
Thu Apr 19 06:44:32 UTC 2012

On 04/19/2012 08:10 AM, ali nasir wrote:
> What we do is the following:
> 1. With the SD card inserted, we write a set of files (4 to 5 files) on the card. After all the fwrite(..) has returned, we call the ioctl for the RTEMS_BLKIO_SYNCDEV to ensure that the data is written to the card.

You should close all files before the ioctl to make sure that all buffers of 
the IO library are flushed.

> 2. We then unmount the card by calling the below set of functions:
> unmount
> rmdir
> rtems_bdbuf_syncdev
> rtems_disk_delete
> rtems_bdbuf_purge_dev
> rtems_io_unregister_driver
> When we step in in the rtems_disk_delete function, the free_disk_device() is not called as the dd->uses equals 1.

This means someone is still using this disk.  You should figure out this user.

> 3. After this, if we insert the second card, after removing the first, then the second card fails in the create_phys by returning 12

Yes, this is because the first disk is still in use.

> 4. When we do not call the ioctl for the RTEMS_BLKIO_SYNCDEV, then we are succesfully able to unmount and also mount the second card.

Is the unmount() not successful if you do the ioctl?

> Should we remove the call to the ioctl for the RTEMS_BLKIO_SYNCDEV? or is there some other solution to the problem?
> Please guide.

The solution is to track down the remaining disk user.

Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber at
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

More information about the users mailing list