summaryrefslogtreecommitdiff
path: root/udev
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2009-05-29 14:05:39 +0200
committerKay Sievers <kay.sievers@vrfy.org>2009-05-29 14:05:39 +0200
commit97f48a8c67520bf1a58f1516ea3f5953ef399a96 (patch)
treeb1118902ca6a3dfc1376d09b4b700f59dd83a8fb /udev
parente91ac78ffc62a7a4f10fc66ed492e5b67a11448a (diff)
udevadm: settle - add --exit-if-exists=<file>
Diffstat (limited to 'udev')
-rw-r--r--udev/udevadm-settle.c23
-rw-r--r--udev/udevadm.xml6
2 files changed, 24 insertions, 5 deletions
diff --git a/udev/udevadm-settle.c b/udev/udevadm-settle.c
index 9059adc341..0b3f2e2124 100644
--- a/udev/udevadm-settle.c
+++ b/udev/udevadm-settle.c
@@ -54,6 +54,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
{ "seq-start", required_argument, NULL, 's' },
{ "seq-end", required_argument, NULL, 'e' },
{ "timeout", required_argument, NULL, 't' },
+ { "exit-if-exists", required_argument, NULL, 'E' },
{ "quiet", no_argument, NULL, 'q' },
{ "help", no_argument, NULL, 'h' },
{}
@@ -61,6 +62,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
unsigned long long start = 0;
unsigned long long end = 0;
int quiet = 0;
+ const char *exists = NULL;
int timeout = DEFAULT_TIMEOUT;
struct sigaction act;
struct udev_queue *udev_queue = NULL;
@@ -80,7 +82,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
int option;
int seconds;
- option = getopt_long(argc, argv, "s:e:t:qh", options, NULL);
+ option = getopt_long(argc, argv, "s:e:t:E:qh", options, NULL);
if (option == -1)
break;
@@ -102,12 +104,16 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
case 'q':
quiet = 1;
break;
+ case 'E':
+ exists = optarg;
+ 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"
- " --quiet do not print list after timeout\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");
exit(0);
}
@@ -173,6 +179,13 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
}
while (1) {
+ struct stat statbuf;
+
+ if (exists != NULL && stat(exists, &statbuf) == 0) {
+ rc = 0;
+ break;
+ }
+
if (start > 0) {
/* if asked for, wait for a specific sequence of events */
if (udev_queue_get_seqnum_sequence_is_finished(udev_queue, start, end) == 1) {
diff --git a/udev/udevadm.xml b/udev/udevadm.xml
index 5996c01383..538180babe 100644
--- a/udev/udevadm.xml
+++ b/udev/udevadm.xml
@@ -237,6 +237,12 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>--exit-if-exists=<replaceable>file</replaceable></option></term>
+ <listitem>
+ <para>Stop waiting if file exists.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>--quiet</option></term>
<listitem>
<para>Do not print any output, like the remaining queue entries when reaching the timeout.</para>