summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-09-03 21:59:21 +0200
committerKay Sievers <kay.sievers@vrfy.org>2008-09-03 21:59:21 +0200
commit742f4cad0d7c4af0a5d27ac6597be7410fa127e6 (patch)
tree4abec6b4d4a73a956dc2a4d4b05dbe2bff3a9c79
parent2b725651e5b77e88a314d34b8cf8e375514b400f (diff)
udevadm: print warning to stderr if udevadm is called by symlink
-rw-r--r--TODO4
-rw-r--r--udev/udevadm.c63
2 files changed, 36 insertions, 31 deletions
diff --git a/TODO b/TODO
index 20ed648d06..1dccb901f5 100644
--- a/TODO
+++ b/TODO
@@ -3,7 +3,9 @@ These things would be nice to have:
o rework rules to a match-action list, instead of a rules array
These things will change in future udev versions:
- o --device-id-of-file will print '5:8' instead of '5 8'
These things are deprecated and scheduled for removal in a future udev version:
o DEVTYPE for disks is set by the kernel, remove it from the rules
+ o "udevadm control" commands will only accept the --<command> syntax
+ o symlink names to udevadm will no longer be resolved to old command names
+
diff --git a/udev/udevadm.c b/udev/udevadm.c
index cb356c5252..863bc467f0 100644
--- a/udev/udevadm.c
+++ b/udev/udevadm.c
@@ -120,49 +120,52 @@ static const struct command cmds[] = {
int main(int argc, char *argv[])
{
- const char *command;
+ const char *command = argv[1];
+ int i;
const char *pos;
- const struct command *cmd;
int rc;
- /* get binary or symlink name */
- pos = strrchr(argv[0], '/');
+ /* find command */
+ if (command != NULL)
+ for (i = 0; cmds[i].cmd != NULL; i++) {
+ if (strcmp(cmds[i].name, command) == 0) {
+ debug = cmds[i].debug;
+ rc = cmds[i].cmd(argc-1, &argv[1]);
+ goto out;
+ }
+ }
+
+ /* try to find compat link, will be removed in a future release */
+ command = argv[0];
+ pos = strrchr(command, '/');
if (pos != NULL)
command = &pos[1];
- else
- command = argv[0];
- /* the trailing part of the binary or symlink name is the command */
+ /* the trailing part of the binary or link name is the command */
if (strncmp(command, "udev", 4) == 0)
command = &command[4];
- 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);
+ 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);
goto out;
}
}
-err_unknown:
fprintf(stderr, "unknown command, try help\n\n");
rc = 2;
out: