Forced unmount

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Oct 14 14:49:50 UTC 2009


Hi,

suppose you have a file system mounted that resides on an USB-Stick and now an
evil user removes the stick without doing a proper unmount.  You need a way to
force the unmount if you detect that someone has removed the stick.  Currently
the unmount checks if some files are open in the corresponding file system.  If
there are open files then the unmount fails with a busy error status.  Now we
have two options:

	1. Close all open files.
	2. Modify the file handles such that further operations result in an
	   error and such that a close is possible.

Variant 1. may result in unexpected behavior due to file descriptor recycling.
 How to do variant 2.?  I would simply replace the handlers in the
rtems_libio_tt stucture of the files with proper handlers for this purpose.
Afterwards I would close the file with the original close handler.

We need also a function name for the forced unmount.  Name proposals:

rtems_status_code rtems_unmount(const char *mount_point, bool force);

int unmount_forced(const char *mount_point, bool force);

static inline unmount(const char *mount_point)
{
  unmount_forced(mount_point, false);
}

-- 
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 embedded-brains.de
PGP     : Public key available on request.

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



More information about the users mailing list