Comment 1 for bug 1406988

Revision history for this message
Martin Pitt (pitti) wrote :

Note that umockdev isn't good enough for simulating the actual behaviour of storage devices, the SCSI/mount/etc. actions are just too complex. If you merely want to *detect* the appearance/disappearance of storage devices (i. e. the /sys/block/*) bits, it's fine of course, but you could never mount it.

The best tool that we currently have to simulate storage devices is the "scsi_debug" kernel module. Loading it will give you a RAM backed /dev/sdb (or whatever) block device which by and large looks like a normal SCSI disk. There are options to set different sizes, SCSI types (https://en.wikipedia.org/wiki/SCSI_Peripheral_Device_Type), failure modes etc., just unfortunately there is no particular SCSI type for "SD card".

udisks' integration tests use that, so you can see how it looks like in setup_vdev() here: http://cgit.freedesktop.org/udisks/tree/src/tests/integration-test#n365

This also shows how to write a temporary udev rule in /run/udev/rules.d that matches on the scsi_debug block device and thus can set arbitrary udev properties on it. That might be useful to fake the SD card harder; I don't know what filemanager-app uses to detect the device type, but on the standard Ubuntu desktop we use udev rule to flag those with ENV{ID_DRIVE_FLASH_SD}="1" (which you could set in above udev rule), udisks2 picks that up and exports that as "block device type" to the desktop (usually via gvfs, but I suppose we don't use that on the phone).