Role of device drivers and mcd

Device drivers enable communication with attached devices by supporting system calls such as open(), read(), and write(). Publishers use these same system calls to obtain information from drivers on the devices that they manage. Another system service, mcd, uses the drivers to mount device filesystems.

How drivers are started

For devices that are always physically present, such as SD card readers, their drivers are launched during system startup and run continuously.

For devices connected through standard hardware interfaces, notably USB storage devices, their drivers are started and stopped by system services when the devices are added and removed. For instance, the usblauncher publisher launches drivers for USB devices when they're attached.

How publishers communicate with drivers

Drivers create entries in /dev for attached devices. For example, a USB driver creates a file named /dev/umass0 (or something similar) when the user inserts a USB stick. The same driver will delete that object when the user removes the USB stick.

Drivers don't send data to publishers. Instead, the publishers monitor specific device paths and when they detect state changes to the devices represented by those paths, the publishers invoke the operating system to learn which drivers manage those paths. Then, the publishers communicate with those drivers to retrieve new or updated device details, which they publish to PPS objects.

In the command lines that start the publishers, you must supply the list of device paths to monitor. Depending on the publisher type, these paths must refer to either individual /dev entries or to directories containing device objects of a given hardware type. For more details, see the usage pages for individual publishers.

The exception to this design is the usblauncher utility. Because it launches drivers in addition to publishing device information, usblauncher doesn't need to find new driver processes to retrieve device information. For an explanation of the alternative design that this utility uses, see "../../com.qnx.doc.dev_pub.ref_guide/topic/usblauncher.html".

How device filesystems are mounted

If you're using usblauncher for device publishing, you can configure that utility to mount the filesystems of USB devices; this way, you don't need to use a separate service to mount filesystems (unless you also need to mount non-USB devices).

To mount non-USB devices, you must use the Media Content Detector (mcd) service, which is included with the product. The mcd service monitors the /dev directory. When an object is added, mcd mounts the filesystem of the newly attached device based on the rules in its mountpoint file (/etc/mcd.mnt by default). See the mcd entry in the Utilities Reference for information on the mount rules.

To mount a device's filesystem, mcd sends a mount request to the appropriate device driver. The driver manages the paths of both the mountpoint (e.g., /fs/usb0) and the device object (e.g., /dev/umass0).