udevadm.c revision 6d837a5348e7b38cb122405290b7bc3c17d069aa
220a21d38f675eb835f5758e3d23e896573aa5eaLennart Poettering * Copyright (C) 2007-2009 Kay Sievers <kay.sievers@vrfy.org>
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering * This program is free software: you can redistribute it and/or modify
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering * it under the terms of the GNU General Public License as published by
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering * the Free Software Foundation, either version 2 of the License, or
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering * (at your option) any later version.
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering * This program is distributed in the hope that it will be useful,
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering * but WITHOUT ANY WARRANTY; without even the implied warranty of
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering * GNU General Public License for more details.
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering * You should have received a copy of the GNU General Public License
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering * along with this program. If not, see <http://www.gnu.org/licenses/>.
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poetteringstatic void log_fn(struct udev *udev, int priority,
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering const char *file, int line, const char *fn,
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering int (*cmd)(struct udev *udev, int argc, char *argv[]);
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poetteringstatic int version(struct udev *udev, int argc, char *argv[])
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poetteringstatic int help(struct udev *udev, int argc, char *argv[])
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering printf("Usage: udevadm [--help] [--version] [--debug] COMMAND [COMMAND OPTIONS]\n");
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering for (cmd = cmds; cmd->name != NULL; cmd++)
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering printf(" %-12s %s\n", cmd->name, cmd->help);
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering .help = "query sysfs or the udev database",
43c71255b3db02916f4f70afa18bab196c6f4a45Lennart Poettering .help = "request events from the kernel",
d27893efdf652c6d85ea590fa0b7c2b88f817083Lennart Poettering .help = "wait for the event queue to finish",
8b7d0494a3fe35209d4db0d1b9e065e7e5cc9875Jason St. Johnstatic int run_command(struct udev *udev, const struct command *cmd, int argc, char *argv[])
1e190502e78cea1f8bcb62e6d390305c89e41e6aZbigniew Jędrzejewski-Szmek return cmd->cmd(udev, argc, argv);
dfb08b058401d56c395f4f2d20ff214d31a277e5Zbigniew Jędrzejewski-Szmek option = getopt_long(argc, argv, "+dhV", options, NULL);
dfb08b058401d56c395f4f2d20ff214d31a277e5Zbigniew Jędrzejewski-Szmek if (udev_get_log_priority(udev) < LOG_INFO)
dfb08b058401d56c395f4f2d20ff214d31a277e5Zbigniew Jędrzejewski-Szmek udev_set_log_priority(udev, LOG_INFO);
e49b5aada0df13c9e8fce7338ae34e075dd7ccd1Lennart Poettering if (strcmp(cmds[i].name, command) == 0) {
e49b5aada0df13c9e8fce7338ae34e075dd7ccd1Lennart Poettering rc = run_command(udev, &cmds[i], argc, argv);
e49b5aada0df13c9e8fce7338ae34e075dd7ccd1Lennart Poettering fprintf(stderr, "missing or unknown command\n\n");