best way in linux to get usb device added notifications in c

假如想象 提交于 2019-12-07 06:22:42

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!