udevadm-settle.c revision 3e2147858f21943d5f4a781c60f33ac22c6096ed
/*
* 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"
{
{}
};
unsigned long long start_usec = now_usec();
unsigned long long start = 0;
unsigned long long end = 0;
int quiet = 0;
unsigned int timeout = 120;
int rc = EXIT_FAILURE;
for (;;) {
int option;
int seconds;
if (option == -1)
break;
switch (option) {
case 's':
break;
case 'e':
break;
case 't':
if (seconds >= 0)
else
break;
case 'q':
quiet = 1;
break;
case 'E':
break;
case 'h':
printf("Usage: udevadm settle OPTIONS\n"
" --timeout=<seconds> maximum time to wait for events\n"
" --seq-start=<seqnum> first seqnum to wait for\n"
" --seq-end=<seqnum> last seqnum to wait for\n"
" --exit-if-exists=<file> stop waiting if file exists\n"
" --quiet do not print list after timeout\n"
" --help\n\n");
default:
}
}
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)
start = 0;
end = 0;
}
start = 0;
end = 0;
}
} else {
if (end > 0) {
end = 0;
}
}
/* guarantee that the udev daemon isn't pre-processing */
if (getuid() == 0) {
rc = EXIT_SUCCESS;
goto out;
}
}
}
} 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) {
unsigned long long age_usec;
struct udev_list_entry *list_entry;
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",
};