- if (command == NULL || command[0] == '\0')
- goto err_unknown;
-
- /* udevadm itself needs to strip its name from the passed options */
- if (strcmp(command, "adm") == 0) {
- command = argv[1];
- argv++;
- argc--;
- }
-
- if (command == NULL)
- goto err_unknown;
-
- /* allow command to be specified as an option */
- if (strncmp(command, "--", 2) == 0)
- command += 2;
-
- /* find and execute command */
- for (cmd = cmds; cmd->name != NULL; cmd++) {
- if (strcmp(cmd->name, command) == 0) {
- debug = cmd->debug;
- rc = cmd->cmd(argc, argv, envp);
+ for (i = 0; cmds[i].cmd != NULL; i++) {
+ if (strcmp(cmds[i].name, command) == 0) {
+ char path[128];
+ char prog[512];
+ ssize_t len;
+
+ snprintf(path, sizeof(path), "/proc/%lu/exe", (unsigned long) getppid());
+ len = readlink(path, prog, sizeof(prog));
+ if (len > 0) {
+ prog[len] = '\0';
+ fprintf(stderr, "the program '%s' called '%s', it should use 'udevadm %s <options>', "
+ "this will stop working in a future release\n", prog, argv[0], command);
+ info("the program '%s' called '%s', it should use 'udevadm %s <options>', "
+ "this will stop working in a future release\n", prog, argv[0], command);
+ }
+ debug = cmds[i].debug;
+ rc = cmds[i].cmd(argc, argv);