I am writing a C++ application for Linux where I want to detect that a user has attached or removed a storage device to the system and based on the event do something. How can this be achieved ?
I tried using the libudev library and was able to detect the same even though the documentation is not helpful at all. The documentation mentions that libudev is not suggested to be used in new projects and should be replaced with sd-device. From the documentation for sd-device I could not figure our how can I detect the above events.
One other solution I had explored was by monitoring the ‘/dev’ folder but it doesn’t seem to be a good option.
Any help will be appreciated.