#include<main.h>
int main(int argc, char **argv) {
- struct udev *monitor; //, *dev;
- struct udev_enumerate *enumerate;
- struct udev_list_entry *devices, *dev_list_entry;
- const char *path;
+ struct udev *udev;
+ struct udev_monitor *monitor;
+ int fd;
- monitor = udev_new();
- if(NULL==monitor) { return EXIT_FAILURE; }
+ udev = udev_new();
+ if(NULL==udev) { return EXIT_FAILURE; }
- enumerate = udev_enumerate_new(monitor);
+ monitor = udev_monitor_new_from_netlink(udev, "udev");
+ if(NULL==monitor) { return EXIT_FAILURE; }
- udev_enumerate_add_match_subsystem(enumerate, "usb");
- udev_enumerate_add_nomatch_sysattr(enumerate, "bDeviceClass", "09");
- udev_enumerate_add_nomatch_sysattr(enumerate, "bInterfaceNumber", NULL);
- udev_enumerate_scan_devices(enumerate);
-
- devices = udev_enumerate_get_list_entry(enumerate);
-
- udev_list_entry_foreach(dev_list_entry, devices) {
- path = udev_list_entry_get_name(dev_list_entry);
-// dev = udev_device_new_from_syspath(monitor, path);
+ if(udev_monitor_filter_add_match_subsystem_devtype(monitor,"block","disk")<0) { return EXIT_FAILURE; }
- printf("found: %s\n",path);
+ while(1) {
+ fd = udev_monitor_get_fd(monitor);
+ if(fd<0) { return EXIT_FAILURE; }
}
- udev_unref(monitor);
+ udev_unref(udev);
return EXIT_SUCCESS;
}