Chapter 26. Automounter

Where removable media is supported by the filesystem and the hardware device driver (currently only the FAT filesystem and the eCosPro USB mass storage device driver have this support) it is possible to configure an automounter which will automatically mount any filesystems found on any device that is inserted. It will also automatically unmount the filesystem when the device is removed.

The automounter is controlled by a number of configuration options:


This option enables the eCos automounter. It is only active if there are device drivers present that are capable of dealing with removable media.

Default value: 0


Any automounted filesystems will be mounted under this root directory.

Default value: "/auto"


This option is a list of device names of the devices that will be monitored by the automounter. Each entry is two strings within braces, with separate entries separated by commas. The first string gives the device name, the second the stub for making the mount point name under the automount root. The name of the filesystem root will be manufactured by appending the disk number and partition number to the name stub, separated by underscores. For example with the default values typical filesystem root names might be: "/auto/usb_0_1" or "/auto/usb_1_2".

Default value: { "/dev/usbmass/", "usb" }

The Automounter also defines a callback that may be used by applications to receive notifications that new filesystems have been mounted or unmounted. The fileio.h header contains the following definitions if the automounter is enabled:

typedef void cyg_automount_handler( int event, char *mountpoint, CYG_ADDRWORD data );

__externC int cyg_automount_register_handler( char *devname, cyg_automount_handler *handler, CYG_ADDRWORD data );

The function cyg_automount_register_handler() causes the callback handler to be registered. The devname identifies the device to which the callback will be attached, it should match one of the device names defined in CYGDAT_IO_FILEIO_AUTOMOUNT_DEVICES. The handler argument is the callback function and data is a user defined data value.

When the handler is called, the event argument indicates the event being notified, CYG_AUTOMOUNT_MOUNT or CYG_AUTOMOUNT_UMOUNT. The mountpoint argument is the name of the root of the filesystem being notified, it will be composed as described above from CYGDAT_IO_FILEIO_AUTOMOUNT_ROOT and the stub part of the relevant CYGDAT_IO_FILEIO_AUTOMOUNT_DEVICES entry. The data argument is the data value passed in from cyg_automount_register_handler().

The handler will be called by the automounter just after the filesystem has been mounted, or just before it is unmounted. Application code should avoid running too much code in the handler and offload long running tasks to another thread. This is because the handler is called directly from the automounter thread and while it is executing, no other automount operations can be run.

Documentation license for this page: Open Publication License