udevadm-settle.c revision 17fcfb5972977b6a3aedca6ad2aa8d1fbfbc761d
/*
* Copyright (C) 2006-2008 Kay Sievers <kay@vrfy.org>
*
* 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 "udev.h"
#define DEFAULT_TIMEOUT 180
#define LOOP_PER_SECOND 20
{
struct name_entry *item;
return;
printf("\n\nAfter the udevadm settle timeout, the events queue contains:\n\n");
char target[UTIL_NAME_SIZE];
continue;
filename++;
if (*filename == '\0')
continue;
if (len < 0)
continue;
}
printf("\n\n");
}
{
char queuename[UTIL_PATH_SIZE];
char filename[UTIL_PATH_SIZE];
unsigned long long seq_kernel;
unsigned long long seq_udev;
char seqnum[32];
int fd;
int timeout = DEFAULT_TIMEOUT;
int loop;
{}
};
int option;
int rc = 1;
int seconds;
while (1) {
if (option == -1)
break;
switch (option) {
case 't':
if (seconds > 0)
else
break;
case 'h':
printf("Usage: udevadm settle [--help] [--timeout=<seconds>]\n\n");
goto exit;
}
}
while (loop--) {
/* wait for events in queue to finish */
while (loop--) {
break;
}
}
if (loop <= 0) {
goto exit;
}
/* read current udev seqnum */
if (fd < 0)
goto exit;
if (len <= 0)
goto exit;
/* read current kernel seqnum */
if (fd < 0)
goto exit;
if (len <= 0)
goto exit;
/* make sure all kernel events have arrived in the queue */
if (seq_udev >= seq_kernel) {
rc = 0;
goto exit;
}
}
exit:
return rc;
}