+ if (strcmp(optarg, "symlink") == 0) {
+ query = SYMLINK;
+ break;
+ }
+
+ if (strcmp(optarg, "owner") == 0) {
+ query = OWNER;
+ break;
+ }
+
+ if (strcmp(optarg, "group") == 0) {
+ query = GROUP;
+ break;
+ }
+
+ if (strcmp(optarg, "path") == 0) {
+ query = PATH;
+ break;
+ }
+
+ printf("unknown query type\n");
+ return -EINVAL;
+
+ case 'r':
+ root = 1;
+ break;
+
+ case 'd':
+ retval = udevdb_open_ro();
+ if (retval != 0) {
+ printf("unable to open udev database\n");
+ return -EACCES;
+ }
+ retval = udevdb_call_foreach(print_record);
+ udevdb_exit();
+ return retval;
+
+ case 'V':
+ printf("udev, version %s\n", UDEV_VERSION);
+ return 0;
+
+ case 'h':
+ retval = 0;
+ case '?':
+ default:
+ goto help;
+ }
+ }
+
+ /* process options */
+ if (query != NONE) {
+ retval = udevdb_open_ro();
+ if (retval != 0) {
+ printf("unable to open udev database\n");
+ return -EACCES;
+ }
+
+ if (path[0] != '\0') {
+ retval = udevdb_get_dev(path, &dev);
+ if (retval != 0) {
+ printf("device not found in database\n");
+ goto exit;
+ }
+ goto print;
+ }
+
+ if (name[0] != '\0') {
+ retval = udevdb_get_dev_byname(name, path, &dev);
+ if (retval != 0) {
+ printf("device not found in database\n");
+ goto exit;
+ }
+ goto print;
+ }
+
+ printf("query needs device path(-p) or node name(-n) specified\n");