udevadm-settle.c revision 2ac23519d04835e8d8dfbce3d08d9ff76db58a68
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * Copyright (C) 2006-2009 Kay Sievers <kay@vrfy.org>
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * Copyright (C) 2009 Canonical Ltd.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * Copyright (C) 2009 Scott James Remnant <scott@netsplit.com>
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * This program is free software: you can redistribute it and/or modify
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers * it under the terms of the GNU General Public License as published by
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * the Free Software Foundation, either version 2 of the License, or
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * (at your option) any later version.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * This program is distributed in the hope that it will be useful,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * but WITHOUT ANY WARRANTY; without even the implied warranty of
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * GNU General Public License for more details.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * You should have received a copy of the GNU General Public License
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * along with this program. If not, see <http://www.gnu.org/licenses/>.
f18ca9dcdeda247e208f7143e834fd2fb2070d80Kay Sieversstatic void help(void) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering "Wait for pending udev events.\n\n"
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering " -h --help Show this help\n"
e1636421f46db6d06fbd028ef20a3113fa3e11f8Lennart Poettering " --version Show package version\n"
7085053a437456ab87d726f3697002dd811fdf7aDaniel Wallace " -t --timeout=SECONDS Maximum time to wait for events\n"
e1636421f46db6d06fbd028ef20a3113fa3e11f8Lennart Poettering " -E --exit-if-exists=FILE Stop waiting if file exists\n"
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poetteringstatic int adm_settle(struct udev *udev, int argc, char *argv[]) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering { "timeout", required_argument, NULL, 't' },
1b12a7b5896f94bdf33b3a6661ebabd761ea6adcHarald Hoyer { "exit-if-exists", required_argument, NULL, 'E' },
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering { "seq-start", required_argument, NULL, 's' }, /* removed */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering { "seq-end", required_argument, NULL, 'e' }, /* removed */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering { "quiet", no_argument, NULL, 'q' }, /* removed */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering while ((c = getopt_long(argc, argv, "t:E:hs:e:q", options, NULL)) >= 0) {
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers if (r < 0) {
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers fprintf(stderr, "Invalid timeout value '%s': %s\n",
480a61ae742378a6a9a0eb84cf29c6c1e4ea22ffLennart Poettering fprintf(stderr, "Extraneous argument: '%s'\n", argv[optind]);
599659860c770058f2eb04d578c521c16e0b1853Lennart Poettering /* guarantee that the udev daemon isn't pre-processing */
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn Landden log_debug("queue is empty, nothing to watch");
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers /* exit if queue is empty */
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn Landden /* wake up when queue is empty */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (poll(pfd, 1, MSEC_PER_SEC) > 0 && pfd[0].revents & POLLIN)