udevadm-settle.c revision 7643ac9a8add1f07ffc237c054feb443b5612717
/*
* Copyright (C) 2006-2009 Kay Sievers <kay@vrfy.org>
* Copyright (C) 2009 Canonical Ltd.
* Copyright (C) 2009 Scott James Remnant <scott@netsplit.com>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
#include <syslog.h>
#include <getopt.h>
#include <signal.h>
#include <time.h>
#include "udev.h"
#include "util.h"
static void help(void) {
printf("Usage: udevadm settle OPTIONS\n"
" -t,--timeout=<seconds> maximum time to wait for events\n"
" -s,--seq-start=<seqnum> first seqnum to wait for\n"
" -e,--seq-end=<seqnum> last seqnum to wait for\n"
" -E,--exit-if-exists=<file> stop waiting if file exists\n"
" -q,--quiet do not print list after timeout\n"
" -h,--help\n\n");
}
{
{}
};
int quiet = 0;
unsigned int timeout = 120;
int rc = EXIT_FAILURE, c;
switch (c) {
case 's':
break;
case 'e':
break;
case 't': {
int r;
if (r < 0) {
};
break;
}
case 'E':
break;
case 'q':
quiet = 1;
break;
case 'h':
help();
case '?':
default:
assert_not_reached("Unkown argument");
}
}
if (udev_queue == NULL)
exit(2);
if (start > 0) {
unsigned long long kernel_seq;
/* unless specified, the last event is the current kernel seqnum */
if (end == 0)
log_error("seq-start larger than seq-end, ignoring\n");
start = 0;
end = 0;
}
log_error("seq-start or seq-end larger than current kernel value, ignoring\n");
start = 0;
end = 0;
}
log_debug("start=%llu end=%llu current=%llu\n", (unsigned long long)start, (unsigned long long)end, kernel_seq);
} else {
if (end > 0) {
log_error("seq-end needs seq-start parameter, ignoring\n");
end = 0;
}
}
/* guarantee that the udev daemon isn't pre-processing */
if (getuid() == 0) {
log_debug("no connection to daemon\n");
rc = EXIT_SUCCESS;
goto out;
}
}
}
log_error("inotify_init failed: %m\n");
} else {
}
}
for (;;) {
rc = EXIT_SUCCESS;
break;
}
if (start > 0) {
/* if asked for, wait for a specific sequence of events */
rc = EXIT_SUCCESS;
break;
}
} else {
/* exit if queue is empty */
rc = EXIT_SUCCESS;
break;
}
}
int delay;
delay = 100;
else
delay = 1000;
/* wake up after delay, or immediately after the queue is rebuilt */
}
} else {
sleep(1);
}
if (timeout > 0) {
struct udev_list_entry *list_entry;
log_debug("timeout waiting for udev queue\n");
printf(" %s (%s)\n",
}
break;
}
}
}
out:
return rc;
}
const struct udevadm_cmd udevadm_settle = {
.name = "settle",
.cmd = adm_settle,
.help = "wait for the event queue to finish",
};