AC_PROG_CC
# Checks for libraries.
-AC_CHECK_LIB([udev],[udev_new])
+AC_CHECK_LIB([systemd],[sd_device_enumerator_new])
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h])
#include<main.h>
+static int detect_usbs();
+static int on_event();
+
int main(int argc, char **argv) {
- struct udev *udev;
- struct udev_monitor *monitor;
- int fd;
+ if(detect_usbs()<0) { return EXIT_FAILURE; }
- udev = udev_new();
- if(NULL==udev) { return EXIT_FAILURE; }
-
- monitor = udev_monitor_new_from_netlink(udev, "udev");
- if(NULL==monitor) { return EXIT_FAILURE; }
+ return EXIT_SUCCESS;
+}
- if(udev_monitor_filter_add_match_subsystem_devtype(monitor,"block","disk")<0) { return EXIT_FAILURE; }
+static int detect_usbs() {
+ sd_device_monitor *monitor;
- while(1) {
- fd = udev_monitor_get_fd(monitor);
- if(fd<0) { return EXIT_FAILURE; }
- }
+ if(sd_device_monitor_new(&monitor)<0) { return -1; }
- udev_unref(udev);
+ if(sd_device_monitor_filter_add_match_subsystem_devtype(monitor,"block","disk")!=0) { return -1; }
- return EXIT_SUCCESS;
+ if(sd_device_monitor_filter_update(monitor)!=0) { return -1; }
+
+ if(sd_device_monitor_start(monitor,&on_event,NULL)!=0) { return -1; }
+
+ while(1) { }
+
+ return 1;
+}
+
+static int on_event(sd_device_monitor *monitor, sd_device *dev, void *userdata) {
+ printf("event?\n");
+ return -1;
}