- enum {
- ADD,
- REMOVE,
- UDEVSTART,
- } act_type;
-
- dbg("version %s", UDEV_VERSION);
- logging_init("udev");
- udev_init_config();
-
- if (strstr(argv[0], "udevstart") || (argv[1] != NULL && strstr(argv[1], "udevstart"))) {
- act_type = UDEVSTART;
- } else {
- const char *action = getenv("ACTION");
- const char *devpath = getenv("DEVPATH");
- const char *subsystem = 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;
- }