Problem with mounting a device second time.

Sebastian Huber sebastian.huber at
Wed Apr 18 11:09:33 UTC 2012

On 04/18/2012 12:47 PM, ali nasir wrote:
> Hi,
> We are facing some problems with mounting an sdcard the second time after removing the first one, on the RTEMS 4.10.1, for eg if a device /dev/sdc01 is mounted on /mnt/sdcard and we unmount this device, then we cannot mount the same device again. However, if we try to mount /dev/sdc02 on mnt/sdcard, then this works.
> If we try to mount the same device again, the create_phys returns error 12 (RTEMS_RESOURCE_IN_USE).

This probably means that the first disk with this name is not deleted.  It is 
somehow still in use.  The rtems_disk_delete() only marks the disk as deleted. 
  It is actually deleted once the reference count reaches zero.  Do you have 
logical disks as well?

> Note that this error comes when we have done some write operation on the previously inserted card. If we do not do any write operation on the previous device, then we are able to mount the second card with the same device name (/dev/sdc01)
> The unmount of the card is performed using the following calls in the sequence, with the card inserted:
> unmount
> rmdir
> rtems_bdbuf_syncdev
> rtems_disk_delete

You should step with the debugger through rtems_disk_delete and verify that it 
calls actually free_disk_device() with the physical disk.

> rtems_bdbuf_purge_dev
> rtems_io_unregister_driver
> The above sequence is taken from the disk_detach_worker from the media.c file
> Can we use the media manager with the RTEMS 4.10.1 or 4.10.2? Is there an example how to use the media manger? Can the media manager solve the above mentioned problem?

It is possible to back port the media manager to RTEMS 4.10, but the file 
system and block device support for unmount() is pretty poor and dangerous in 
RTEMS 4.10 and below.  Most problems are fixed with this commit:

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