问题
what Linux library should i use to get asynchronous notifications of added usb devices? I'd like my program to work on any Linux device so I'll need to use a library that isn't specific to one Linux version
回答1:
If you are using 'C' then I would suggest using the notification features of libudev. Here is a good link with example 'C' code.
libudev Document
Hope that helps.
--Jim
回答2:
You need to include what language you are using before we can talk libraries, but if you want to just hook into a shell and parse infos you can use udevadm. You also will have to consider user mode, versus kernel mode, and you will most likely have to run your program or in kernel mode to be able to listen for this type of event.
来源:https://stackoverflow.com/questions/9891535/best-way-in-linux-to-get-usb-device-added-notifications-in-c