0

I am writing a small apllication that will tell list of attached devices to my linux laptop.There is one utility that is udev that can be used for hot plugging but is their some other way where i can write simple c program where it will tell that these devices are attached to your laptop.or it will pop up message when new devices will be attached and removed.please provide some basic stuff so that i can start my project.thanx in advance.

Srb
  • 219
  • 3
  • 13

1 Answers1

0

As far as I can see, there are two parts to your question. I will answer them separately.

Get a list of current devices

Your source of information would be /sys/ and proc and their sub directories. You can get most information by simply reading the appropriate file from here. For example, trying running utilities such as lsusb using strace and see what files they access - you will see it reads /sys/devices. Also look at lshw and it's source code.

Notification of hardware events

This is where udev comes in. Here are couple of articles I came across they may be helpful: