void on_deferred_hotplug_usb(void) { int plug_modem = 0; int unplug_modem = 0; if (nvram_match("usb_hotplug_ms", "1")) { nvram_set_int_temp("usb_hotplug_ms", 0); try_start_usb_apps(); nvram_set_int_temp("usb_opt_start", 0); } if (nvram_match("usb_unplug_lp", "1")) { nvram_set_int_temp("usb_unplug_lp", 0); if (!usb_port_module_used("usblp")) stop_usb_printer_spoolers(); } if (nvram_match("usb_hotplug_lp", "1")) { nvram_set_int_temp("usb_hotplug_lp", 0); try_start_usb_printer_spoolers(); } if (nvram_match("usb_unplug_md", "1")) { nvram_set_int_temp("usb_unplug_md", 0); if (nvram_get_int("modem_rule") > 0) unplug_modem = 1; } if (nvram_match("usb_hotplug_md", "1")) { plug_modem = 1; nvram_set_int_temp("usb_hotplug_md", 0); } if (unplug_modem) { try_wan_reconnect(1, 0); } if (plug_modem && !unplug_modem) { try_start_usb_modem_to_wan(); } }
int mdev_lp_main(int argc, char **argv) { int isLock; const char *device_name, *action; if(argc != 3){ printf("Usage: %s [device_name] [action]\n", argv[0]); return 0; } device_name = argv[1]; action = argv[2]; usb_dbg("(%s): action=%s.\n", device_name, action); if(get_device_type_by_device(device_name) != DEVICE_TYPE_PRINTER){ usb_dbg("(%s): The device is not a printer.\n", device_name); return 0; } // Check Lock. if((isLock = file_lock((char *)device_name)) == -1){ usb_dbg("(%s): Can't set the file lock!\n", device_name); return 0; } // If remove the device? if(!check_hotplug_action(action)){ int ports_used_usblp = usb_port_module_used("usblp"); if (!ports_used_usblp) stop_usb_printer_spoolers(); file_unlock(isLock); return 0; } notify_rc("on_hotplug_usb_printer"); usb_dbg("(%s): Success!\n", device_name); file_unlock(isLock); return 1; }