clyfe
clyfe

Reputation: 23770

Listen for harware change events from the linux kernel or udev

I need to run some code on storage device mounting and unmounting.
How can i listen for these events on linux?

Upvotes: 4

Views: 5734

Answers (2)

Praveen S
Praveen S

Reputation: 10393

You have to listen to the "uevent" signal. Attach a callback to this signal and wait for the notification.

Upvotes: 2

user355252
user355252

Reputation:

You can use libudev or the more convenient, glib based gudev to monitor udev events in C.

Upvotes: 6

Related Questions