One of my udev rules runs a script on removal of USB storage devices. This script performs some general cleanup and removes the mount point directory for the storage device. The issue is that I want to be able to trigger this logic programmatically from my C++ application (as opposed to when a usb flash drive is hot swap removed, which seems to be too late).
The correct way to achieve this seems to be directly adding the event on the udev event queue. I am able to achieve the desired action using udevadm but do not see an equivalent API say in the libudev library.
udevadm trigger --action=remove --property-match=DEVNAME=/dev/sda1
Is there some way to achieve this by accessing udev over dbus? Is there a library which will allow me to do this? Is this ultimately not how udev should work and should I be unmounting & cleaning up block devices in my application instead of having udev do it?