[gPXE] Setting delay time to boot, so client waits for SAN server

Shao Miller Shao.Miller at yrdsb.edu.on.ca
Sun Mar 28 12:26:27 EDT 2010


Ok.  You could try this out, if you like.  Forever means forever, 
though...  - Shao

 From 31189196d38c0b27dcbd42023d96f068652201ae Mon Sep 17 00:00:00 2001
From: Shao Miller <shao.miller at yrdsb.edu.on.ca>
Date: Sun, 28 Mar 2010 16:09:40 +0000
Subject: [PATCH] [time_cmd] Add 'tryfor' command

Usage:
  tryfor <seconds> <command>

Keep trying <command> up to a maximum of
<second> seconds. 0 == forever.

Uncompresed code size cost: 226 bytes

Suggested-by: Jonathan Andrews <jon at jonshouse.co.uk>
Suggested-by: Piotr Jaroszynski <p.jaroszynski at gmail.com>
---
 src/hci/commands/time_cmd.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 src/hci/commands/time_cmd.c

diff --git a/src/hci/commands/time_cmd.c b/src/hci/commands/time_cmd.c
old mode 100644
new mode 100755
index 947410e..e736b87
--- a/src/hci/commands/time_cmd.c
+++ b/src/hci/commands/time_cmd.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009 Daniel Verkamp <daniel at drv.nu>.
+ * Portions copyright (C) 2010 Shao Miller <shao.miller at yrdsb.edu.on.ca>.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -17,6 +18,9 @@
  *
  * March-19-2009 @ 02:44: Added sleep command.
  * Shao Miller <shao.miller at yrdsb.edu.on.ca>.
+ *
+ * March-28-2010 @ 11:33: Added tryfor command.
+ * Shao Miller <shao.miller at yrdsb.edu.on.ca>.
  */
 
 #include <stdio.h>
@@ -82,3 +86,29 @@ struct command sleep_command __command = {
     .name = "sleep",
     .exec = sleep_exec,
 };
+
+static int tryfor_exec ( int argc, char **argv ) {
+    unsigned long start, timeout;
+    int rc;
+
+    if ( argc < 3 ) {
+        printf ( "Usage:\n"
+             "  %s <seconds> <command>\n"
+             "\n"
+             "Keep trying <command> up to a maximum of <second> "
+             "seconds. 0 == forever\n",
+             argv[0] );
+        return 1;
+    }
+    start = currticks();
+    timeout = strtoul ( argv[1], NULL, 0 ) * ticks_per_sec();
+    while ( ( ( rc = execv ( argv[2], &argv[2] ) ) != 0 ) &&
+        ( ( timeout == 0 ) ||
+          ( ( currticks() - start ) <= timeout ) ) ) {};
+    return rc;
+}
+
+struct command tryfor_command __command = {
+    .name = "tryfor",
+    .exec = tryfor_exec,
+};
-- 
1.5.3.4

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-time_cmd-Add-tryfor-command.patch
Url: http://etherboot.org/pipermail/gpxe/attachments/20100328/e9e4b963/attachment.cc 


More information about the gPXE mailing list