+ enum {
+ ADD,
+ REMOVE,
+ UDEVSTART,
+ } act_type;
+
+ dbg("version %s", UDEV_VERSION);
+
+ main_argv = argv;
+ main_envp = envp;
+
+ logging_init("udev");
+
+ udev_init_config();
+
+ if (strstr(argv[0], "udevstart")) {
+ act_type = UDEVSTART;
+ } else {
+ const char *action = get_action();
+ const char *devpath = get_devpath();
+ const char *subsystem = get_subsystem(main_argv[1]);
+
+ if (!action) {
+ dbg("no action?");
+ goto exit;
+ }
+ if (strcmp(action, "add") == 0) {
+ act_type = ADD;
+ } else if (strcmp(action, "remove") == 0) {
+ act_type = REMOVE;
+ } else {
+ dbg("no action '%s' for us", action);
+ goto exit;
+ }
+
+ if (!devpath) {
+ dbg("no devpath?");
+ goto exit;
+ }
+ dbg("looking at '%s'", devpath);
+
+ /* we only care about class devices and block stuff */
+ if (!strstr(devpath, "class") && !strstr(devpath, "block")) {
+ dbg("not a block or class device");
+ goto exit;
+ }
+
+ if (!subsystem) {
+ dbg("no subsystem");
+ goto exit;
+ }
+
+ udev_set_values(&udev, devpath, subsystem);
+
+ /* skip blacklisted subsystems */
+ if (udev.type != 'n' && subsystem_expect_no_dev(subsystem)) {
+ dbg("don't care about '%s' devices", subsystem);
+ goto exit;
+ };