- static const char short_options[] = "dp:q:rVh";
- int option;
- int retval = -EINVAL;
- struct udevice dev;
- int root = 0;
- enum query_type query = NONE;
- char result[NAME_SIZE] = "";
- char path[NAME_SIZE] = "";
-
- /* get command line options */
- while (1) {
- option = getopt(argc, argv, short_options);
- if (option == -1)
- break;
-
- dbg("option '%c'", option);
- switch (option) {
- case 'p':
- dbg("udev path: %s\n", optarg);
- strfieldcpy(path, optarg);
- break;
-
- case 'q':
- dbg("udev query: %s\n", optarg);
-
- if (strcmp(optarg, "name") == 0) {
- query = NAME;
- break;
- }
-
- if (strcmp(optarg, "symlink") == 0) {
- query = SYMLINK;
- break;
- }
-
- if (strcmp(optarg, "owner") == 0) {
- query = OWNER;
- break;
- }
-
- if (strcmp(optarg, "group") == 0) {
- query = GROUP;
- break;
- }
-
- printf("unknown query type\n");
- return -EINVAL;
-
- case 'r':
- root = 1;