summaryrefslogtreecommitdiff
path: root/sys/src/9
diff options
context:
space:
mode:
authoriru <devnull@localhost>2011-04-17 17:25:55 -0300
committeriru <devnull@localhost>2011-04-17 17:25:55 -0300
commitb261a0c31b3d2e134b3c6cc07020e83c593a29db (patch)
treeec024294ad69697f9585aaeaa24ec0b0909b959b /sys/src/9
parent6ef6d247bc815afcd821f81e580c5d2c1c505740 (diff)
Add /sys/src/9/boot/tread, a tool to read a line with a timeout.
While here, remove boot(8) references to pcload.
Diffstat (limited to 'sys/src/9')
-rw-r--r--sys/src/9/boot/bootmkfile4
-rw-r--r--sys/src/9/boot/bootrc20
-rwxr-xr-xsys/src/9/boot/conf.rc3
-rw-r--r--[-rwxr-xr-x]sys/src/9/boot/local.rc7
-rw-r--r--sys/src/9/boot/tread.c73
-rw-r--r--sys/src/9/port/bootfs.proto1
-rwxr-xr-xsys/src/9/port/mkbootfs5
7 files changed, 88 insertions, 25 deletions
diff --git a/sys/src/9/boot/bootmkfile b/sys/src/9/boot/bootmkfile
index 0b873ae7a..af1fcb3f6 100644
--- a/sys/src/9/boot/bootmkfile
+++ b/sys/src/9/boot/bootmkfile
@@ -16,3 +16,7 @@ $BOOTFILES: $BOOTDIR/boot.h
%.$O: $BOOTDIR/%.c
$CC -I$BOOTDIR $CFLAGS $BOOTDIR/$stem.c
+
+tread: tread.c
+ $CC tread.c
+ $LD -o tread tread.8
diff --git a/sys/src/9/boot/bootrc b/sys/src/9/boot/bootrc
index 2e2355a63..ac07aa42d 100644
--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -67,22 +67,17 @@ fn readmethod{
timeo=5
resp=()
while(~ $#resp 0){
- if(~ $#pcload 0)
- echo -n 'root is from: '
- if not
- echo -n 'kernel is at: '
- resp=`{read}
+ echo -n 'root is from: '
+ resp=`{tread $timeo}
if(! ~ $status ''){
bootconf # set configuration from file
if(! ~ $#nobootprompt 0)
bootargs=$nobootprompt
resp=$bootargs
}
- if(~ $resp !rc){
+ if(~ $resp !rc)
rc -i
- resp=()
- }
- timo=0
+ timeo=0
}
method=`{echo $resp | awk -F! '{print $1}'}
@@ -103,9 +98,6 @@ fn readmethod{
fn authentication{
if(! test -f /srv/factotum){
- # in pcload we only need to read the kernel
- if(~ $pcload 1)
- user=none
x=(auth/factotum -sfactotum)
if(~ $cpuflag 1)
x=($x -kS)
@@ -142,10 +134,6 @@ fn main{
$mp($connect)
must mount -c /srv/boot /root
- if(~ $pcload 1){
- echo reboot /root/$kern >/dev/reboot
- fatal kernel load failed: $kern
- }
swapproc
diff --git a/sys/src/9/boot/conf.rc b/sys/src/9/boot/conf.rc
index dd217c6c0..a82594d8d 100755
--- a/sys/src/9/boot/conf.rc
+++ b/sys/src/9/boot/conf.rc
@@ -28,8 +28,7 @@ fn confmount{
}
fn findconf{
- # search cd/dvd drives first
- for(d in $cddevs /dev/sd* /dev/fd*disk)
+ for(d in /dev/sd*)
for(p in `{ls $d}){
if(~ $found 0){
confmount $p
diff --git a/sys/src/9/boot/local.rc b/sys/src/9/boot/local.rc
index dd35a2f33..7b5c85cdb 100755..100644
--- a/sys/src/9/boot/local.rc
+++ b/sys/src/9/boot/local.rc
@@ -5,13 +5,6 @@ fn configlocal{
fstype=`{echo $disk | sed 's,.*/(.*)$,\1,g'}
disk=`{echo $disk | sed 's,(.*)/.*$,\1,'}
- if(~ $pcload 1){
- kern=`{echo $methodarg | sed 's,.*!(.*)$,\1,g'}
-
- # for now we only allow kernels in the same dev/part of $methodargs
- if(~ $#kern 0 || ! ~ $#bootfile 0)
- kern=`{echo $bootfile | sed 's,.*!(.*)$,\1,g'}
- }
diskparts
}
diff --git a/sys/src/9/boot/tread.c b/sys/src/9/boot/tread.c
new file mode 100644
index 000000000..068bcbfca
--- /dev/null
+++ b/sys/src/9/boot/tread.c
@@ -0,0 +1,73 @@
+#include <u.h>
+#include <libc.h>
+
+int c;
+
+int
+alarmed(void *a, char *msg)
+{
+ USED(a);
+ USED(msg);
+ if(!c)
+ exits("timedout");
+ noted(NCONT);
+ return 1;
+}
+
+void
+readline(int fd, char *buf, int nbuf)
+{
+ int i, n;
+
+ i = 0;
+ while(i < nbuf-1){
+ n = read(fd, &c, sizeof c);
+ alarm(0);
+ c &= 0xff;
+ write(fd, &c, 1);
+ if(n != 1 || c == '\04' || c == '\177'){
+ i = 0;
+ break;
+ } else if(c == '\n')
+ break;
+ else if(c == '\b' && i > 0)
+ --i;
+ else if(c == ('u' & 037)){
+ c = '\b';
+ for(n=0; n <= i; n++)
+ write(fd, &c, 1);
+ i = 0;
+ } else
+ buf[i++] = c;
+ }
+ buf[i] = 0;
+}
+
+void
+main(int argc, char *argv[])
+{
+ int fd, ctl, i;
+ char buf[256];
+ long n;
+
+ if(argc < 2)
+ sysfatal("usage: tread timeout");
+
+ atnotify(alarmed, 1);
+
+ fd = open("/dev/cons", ORDWR);
+ if(fd < 0)
+ sysfatal("open cons: %r");
+ ctl = open("/dev/consctl", OWRITE);
+ if(ctl < 0)
+ sysfatal("open consctl: %r");
+
+ write(ctl, "rawon", 5);
+ alarm(atoi(argv[1])*1000);
+
+ readline(fd, buf, sizeof(buf));
+ close(ctl);
+ close(fd);
+ print("%s", buf);
+ exits(nil);
+}
diff --git a/sys/src/9/port/bootfs.proto b/sys/src/9/port/bootfs.proto
index ea8d4942c..9046a8e51 100644
--- a/sys/src/9/port/bootfs.proto
+++ b/sys/src/9/port/bootfs.proto
@@ -30,6 +30,7 @@ $cputype
seq
srv
test
+ tread 555 sys sys ../boot/tread
unmount
usb
usbd
diff --git a/sys/src/9/port/mkbootfs b/sys/src/9/port/mkbootfs
index d8867c5ad..949284f45 100755
--- a/sys/src/9/port/mkbootfs
+++ b/sys/src/9/port/mkbootfs
@@ -33,6 +33,11 @@ fn rootbz2 {
rm boot.bz2
}
+@{cd ../boot
+ . /$cputype/mkfile
+ mk -f bootmkfile tread
+}
+
bootraw
bootbz2
rootbz2