- retval = udevdb_get_dev(path, &dev);
- if (retval == 0) {
- switch(query) {
- case NAME:
- if (root)
- strfieldcpy(result, udev_root);
- strncat(result, dev.name, sizeof(result));
- break;
-
- case SYMLINK:
- strfieldcpy(result, dev.symlink);
- break;
-
- case GROUP:
- strfieldcpy(result, dev.group);
- break;
-
- case OWNER:
- strfieldcpy(result, dev.owner);
- break;
-
- default:
- break;
- }
- printf("%s\n", result);
- } else {
- printf("device not found in udev database\n");
- }
- udevdb_exit();
- return retval;
- }
-
- if (root) {
- printf("%s\n", udev_root);
- return 0;
- }
-
-help:
- printf("Usage: [-pqrdVh]\n"
- " -q TYPE query database for the specified value:\n"
- " 'name' name of device node\n"
- " 'symlink' pointing to node\n"
- " 'owner' of node\n"
- " 'group' of node\n"
- " -p PATH sysfs device path used for query\n"
- " -r print udev root\n"
- " -d dump whole database\n"
- " -V print udev version\n"
- " -h print this help text\n"
- "\n");
- return retval;
-}
-
-static char *subsystem_blacklist[] = {
- "net",
- "scsi_host",
- "scsi_device",
- "usb_host",
- "pci_bus",
- "",
-};
-
-static inline int udev_hotplug(int argc, char **argv)
-{
- char *action;
- char *devpath;
- char *subsystem;
- int retval = -EINVAL;
- int i;
-
- subsystem = argv[1];
-
- devpath = get_devpath();
- 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;
- }
-
- /* skip blacklisted subsystems */
- i = 0;
- while (subsystem_blacklist[i][0] != '\0') {
- if (strcmp(subsystem, subsystem_blacklist[i]) == 0) {
- dbg("don't care about '%s' devices", subsystem);
- goto exit;