Browse Source

Plan 9 from Bell Labs 2007-10-30

David du Colombier 16 years ago
parent
commit
e478c06247

+ 25 - 13
dist/replica/_plan9.db

@@ -1,8 +1,8 @@
 386 - 20000000775 sys sys 1010957353 0
-386/9load - 775 sys sys 1193603518 337132
-386/9loaddebug - 775 sys sys 1193603527 450713
-386/9loadlite - 775 sys sys 1193603532 160432
-386/9loadlitedebug - 775 sys sys 1193603540 236256
+386/9load - 775 sys sys 1193687665 337132
+386/9loaddebug - 775 sys sys 1193687675 450713
+386/9loadlite - 775 sys sys 1193687678 160432
+386/9loadlitedebug - 775 sys sys 1193687682 236256
 386/9pc - 775 sys sys 1192646200 2054406
 386/9pc.gz - 664 sys sys 1192646200 873537
 386/9pccpu - 775 sys sys 1191889923 1749481
@@ -11,7 +11,7 @@
 386/9pcdisk.gz - 664 sys sys 1192741561 973813
 386/9pcf - 775 sys sys 1191889940 2874011
 386/9pcf.gz - 664 sys sys 1191889940 1230163
-386/9pxeload - 775 sys sys 1193603555 337136
+386/9pxeload - 775 sys sys 1193687689 337136
 386/bin - 20000000775 sys sys 1018897690 0
 386/bin/8a - 775 sys sys 1168402260 116604
 386/bin/8c - 775 sys sys 1190520740 367214
@@ -173,6 +173,7 @@
 386/bin/cat - 775 sys sys 1148500611 37482
 386/bin/cb - 775 sys sys 1168402293 77628
 386/bin/cdfs - 775 sys sys 1179372081 166023
+386/bin/cec - 775 sys sys 1193714267 75896
 386/bin/cfs - 775 sys sys 1190863294 130565
 386/bin/chgrp - 775 sys sys 1168402294 59522
 386/bin/chmod - 775 sys sys 1168402294 62518
@@ -205,7 +206,7 @@
 386/bin/disk - 20000000775 sys sys 984788664 0
 386/bin/disk/dump9660 - 775 sys sys 1188446897 152095
 386/bin/disk/exsort - 775 sys sys 1168402301 60455
-386/bin/disk/fdisk - 775 sys sys 1168402301 104096
+386/bin/disk/fdisk - 775 sys sys 1193714268 104619
 386/bin/disk/format - 775 sys sys 1178568266 89440
 386/bin/disk/kfs - 775 sys sys 1190863302 248673
 386/bin/disk/kfscmd - 775 sys sys 1148500626 38257
@@ -216,7 +217,7 @@
 386/bin/disk/mkfs - 775 sys sys 1168402303 87969
 386/bin/disk/mksacfs - 775 sys sys 1020319074 71451
 386/bin/disk/partfs - 775 sys sys 1193426743 149859
-386/bin/disk/prep - 775 sys sys 1168402303 96167
+386/bin/disk/prep - 775 sys sys 1193714270 96195
 386/bin/disk/sacfs - 775 sys sys 1020319075 79882
 386/bin/dossrv - 775 sys sys 1178568267 136537
 386/bin/du - 775 sys sys 1179777650 76275
@@ -264,7 +265,7 @@
 386/bin/games/sudoku - 775 sys sys 1179372090 171015
 386/bin/getmap - 775 sys sys 1168402311 65423
 386/bin/gif - 775 sys sys 1179372091 158603
-386/bin/grap - 775 sys sys 1184529901 282814
+386/bin/grap - 775 sys sys 1193686113 282795
 386/bin/graph - 775 sys sys 1168402312 129250
 386/bin/grep - 775 sys sys 1168402312 79569
 386/bin/gs - 775 sys sys 1188447224 13278980
@@ -7817,6 +7818,7 @@ sys/man/8/apm - 664 sys sys 1017679308 1811
 sys/man/8/auth - 664 sys sys 1191472798 4996
 sys/man/8/boot - 664 sys sys 1188515985 8331
 sys/man/8/booting - 664 sys sys 1015024984 4136
+sys/man/8/cec - 644 sys sys 1193683685 1929
 sys/man/8/cpurc - 664 sys sys 1187227584 1522
 sys/man/8/cron - 664 sys sys 1063858596 1867
 sys/man/8/dhcpd - 664 sys sys 1191306105 5575
@@ -9195,7 +9197,7 @@ sys/src/boot/pc/kfs.h - 664 sys sys 1032215924 861
 sys/src/boot/pc/kfsboot.c - 664 sys sys 1032215914 4788
 sys/src/boot/pc/l.s - 664 sys sys 1193167045 18213
 sys/src/boot/pc/lib.h - 664 sys sys 1190921452 2847
-sys/src/boot/pc/load.c - 664 sys sys 1193607906 9806
+sys/src/boot/pc/load.c - 664 sys sys 1193687652 9808
 sys/src/boot/pc/mbr.s - 664 sys sys 1015007953 6234
 sys/src/boot/pc/mem.h - 664 sys sys 1190921475 3437
 sys/src/boot/pc/memory.c - 664 sys sys 1019533021 10272
@@ -9998,6 +10000,15 @@ sys/src/cmd/cdfs/fns.h - 664 sys sys 969542122 297
 sys/src/cmd/cdfs/main.c - 664 sys sys 1017679316 11040
 sys/src/cmd/cdfs/mkfile - 664 sys sys 959922196 182
 sys/src/cmd/cdfs/mmc.c - 664 sys sys 1146318348 17198
+sys/src/cmd/cec - 20000000775 sys sys 1193683647 0
+sys/src/cmd/cec/LICENSE - 644 sys sys 1186248056 1554
+sys/src/cmd/cec/Protocol - 664 sys sys 1186248056 2881
+sys/src/cmd/cec/cec.c - 644 sys sys 1193683596 6829
+sys/src/cmd/cec/cec.h - 644 sys sys 1193681095 537
+sys/src/cmd/cec/mkfile - 644 sys sys 1193683556 131
+sys/src/cmd/cec/mux.c - 664 sys sys 1193683306 1641
+sys/src/cmd/cec/plan9.c - 644 sys sys 1193683385 1408
+sys/src/cmd/cec/utils.c - 644 sys sys 1193681177 676
 sys/src/cmd/cfs - 20000000775 sys sys 1045505024 0
 sys/src/cmd/cfs/bcache.c - 664 sys sys 1172123361 2964
 sys/src/cmd/cfs/bcache.h - 664 sys sys 1014925220 797
@@ -10249,9 +10260,9 @@ sys/src/cmd/disk/prep - 20000000775 sys sys 1055692957 0
 sys/src/cmd/disk/prep/calc.y - 664 sys sys 1135487935 2406
 sys/src/cmd/disk/prep/edit.c - 664 sys sys 1017854327 9714
 sys/src/cmd/disk/prep/edit.h - 664 sys sys 1015009215 994
-sys/src/cmd/disk/prep/fdisk.c - 664 sys sys 1126623191 21983
+sys/src/cmd/disk/prep/fdisk.c - 664 sys sys 1193693218 22265
 sys/src/cmd/disk/prep/mkfile - 664 sys sys 1022450200 250
-sys/src/cmd/disk/prep/prep.c - 664 sys sys 1126278202 10098
+sys/src/cmd/disk/prep/prep.c - 664 sys sys 1193692640 10170
 sys/src/cmd/disk/rd9660.c - 664 sys sys 1021579990 7446
 sys/src/cmd/disk/sacfs - 20000000775 sys sys 1039727556 0
 sys/src/cmd/disk/sacfs/mkfile - 664 sys sys 964815354 204
@@ -10430,13 +10441,13 @@ sys/src/cmd/grap/frame.c - 664 sys sys 944960999 1572
 sys/src/cmd/grap/grap.h - 664 sys sys 944960999 6090
 sys/src/cmd/grap/grap.y - 664 sys sys 944960999 9292
 sys/src/cmd/grap/grapl.lx - 664 sys sys 944960999 4871
-sys/src/cmd/grap/input.c - 664 sys sys 944960999 11416
+sys/src/cmd/grap/input.c - 664 sys sys 1193674137 11417
 sys/src/cmd/grap/label.c - 664 sys sys 944960999 3043
 sys/src/cmd/grap/main.c - 664 sys sys 944960999 3399
 sys/src/cmd/grap/misc.c - 664 sys sys 944960999 5081
 sys/src/cmd/grap/mkfile - 664 sys sys 944960999 456
 sys/src/cmd/grap/plot.c - 664 sys sys 944960999 2783
-sys/src/cmd/grap/print.c - 664 sys sys 944960999 5254
+sys/src/cmd/grap/print.c - 664 sys sys 1193674141 5221
 sys/src/cmd/grap/ticks.c - 664 sys sys 944960999 10887
 sys/src/cmd/graph - 20000000775 sys sys 1039727559 0
 sys/src/cmd/graph/graph.c - 664 sys sys 1148227144 13164
@@ -15747,3 +15758,4 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
+sys/src/cmd/cwfs/sub.c - 664 sys sys 1193717342 24472

+ 25 - 14
dist/replica/plan9.db

@@ -1,8 +1,8 @@
 386 - 20000000775 sys sys 1010957353 0
-386/9load - 775 sys sys 1193603518 337132
-386/9loaddebug - 775 sys sys 1193603527 450713
-386/9loadlite - 775 sys sys 1193603532 160432
-386/9loadlitedebug - 775 sys sys 1193603540 236256
+386/9load - 775 sys sys 1193687665 337132
+386/9loaddebug - 775 sys sys 1193687675 450713
+386/9loadlite - 775 sys sys 1193687678 160432
+386/9loadlitedebug - 775 sys sys 1193687682 236256
 386/9pc - 775 sys sys 1192646200 2054406
 386/9pc.gz - 664 sys sys 1192646200 873537
 386/9pccpu - 775 sys sys 1191889923 1749481
@@ -11,7 +11,7 @@
 386/9pcdisk.gz - 664 sys sys 1192741561 973813
 386/9pcf - 775 sys sys 1191889940 2874011
 386/9pcf.gz - 664 sys sys 1191889940 1230163
-386/9pxeload - 775 sys sys 1193603555 337136
+386/9pxeload - 775 sys sys 1193687689 337136
 386/bin - 20000000775 sys sys 1018897690 0
 386/bin/8a - 775 sys sys 1168402260 116604
 386/bin/8c - 775 sys sys 1190520740 367214
@@ -173,6 +173,7 @@
 386/bin/cat - 775 sys sys 1148500611 37482
 386/bin/cb - 775 sys sys 1168402293 77628
 386/bin/cdfs - 775 sys sys 1179372081 166023
+386/bin/cec - 775 sys sys 1193714267 75896
 386/bin/cfs - 775 sys sys 1190863294 130565
 386/bin/chgrp - 775 sys sys 1168402294 59522
 386/bin/chmod - 775 sys sys 1168402294 62518
@@ -205,7 +206,7 @@
 386/bin/disk - 20000000775 sys sys 984788664 0
 386/bin/disk/dump9660 - 775 sys sys 1188446897 152095
 386/bin/disk/exsort - 775 sys sys 1168402301 60455
-386/bin/disk/fdisk - 775 sys sys 1168402301 104096
+386/bin/disk/fdisk - 775 sys sys 1193714268 104619
 386/bin/disk/format - 775 sys sys 1178568266 89440
 386/bin/disk/kfs - 775 sys sys 1190863302 248673
 386/bin/disk/kfscmd - 775 sys sys 1148500626 38257
@@ -216,7 +217,7 @@
 386/bin/disk/mkfs - 775 sys sys 1168402303 87969
 386/bin/disk/mksacfs - 775 sys sys 1020319074 71451
 386/bin/disk/partfs - 775 sys sys 1193426743 149859
-386/bin/disk/prep - 775 sys sys 1168402303 96167
+386/bin/disk/prep - 775 sys sys 1193714270 96195
 386/bin/disk/sacfs - 775 sys sys 1020319075 79882
 386/bin/dossrv - 775 sys sys 1178568267 136537
 386/bin/du - 775 sys sys 1179777650 76275
@@ -264,7 +265,7 @@
 386/bin/games/sudoku - 775 sys sys 1179372090 171015
 386/bin/getmap - 775 sys sys 1168402311 65423
 386/bin/gif - 775 sys sys 1179372091 158603
-386/bin/grap - 775 sys sys 1184529901 282814
+386/bin/grap - 775 sys sys 1193686113 282795
 386/bin/graph - 775 sys sys 1168402312 129250
 386/bin/grep - 775 sys sys 1168402312 79569
 386/bin/gs - 775 sys sys 1188447224 13278980
@@ -7817,6 +7818,7 @@ sys/man/8/apm - 664 sys sys 1017679308 1811
 sys/man/8/auth - 664 sys sys 1191472798 4996
 sys/man/8/boot - 664 sys sys 1188515985 8331
 sys/man/8/booting - 664 sys sys 1015024984 4136
+sys/man/8/cec - 644 sys sys 1193683685 1929
 sys/man/8/cpurc - 664 sys sys 1187227584 1522
 sys/man/8/cron - 664 sys sys 1063858596 1867
 sys/man/8/dhcpd - 664 sys sys 1191306105 5575
@@ -9195,7 +9197,7 @@ sys/src/boot/pc/kfs.h - 664 sys sys 1032215924 861
 sys/src/boot/pc/kfsboot.c - 664 sys sys 1032215914 4788
 sys/src/boot/pc/l.s - 664 sys sys 1193167045 18213
 sys/src/boot/pc/lib.h - 664 sys sys 1190921452 2847
-sys/src/boot/pc/load.c - 664 sys sys 1193607906 9806
+sys/src/boot/pc/load.c - 664 sys sys 1193687652 9808
 sys/src/boot/pc/mbr.s - 664 sys sys 1015007953 6234
 sys/src/boot/pc/mem.h - 664 sys sys 1190921475 3437
 sys/src/boot/pc/memory.c - 664 sys sys 1019533021 10272
@@ -9998,6 +10000,15 @@ sys/src/cmd/cdfs/fns.h - 664 sys sys 969542122 297
 sys/src/cmd/cdfs/main.c - 664 sys sys 1017679316 11040
 sys/src/cmd/cdfs/mkfile - 664 sys sys 959922196 182
 sys/src/cmd/cdfs/mmc.c - 664 sys sys 1146318348 17198
+sys/src/cmd/cec - 20000000775 sys sys 1193683647 0
+sys/src/cmd/cec/LICENSE - 644 sys sys 1186248056 1554
+sys/src/cmd/cec/Protocol - 664 sys sys 1186248056 2881
+sys/src/cmd/cec/cec.c - 644 sys sys 1193683596 6829
+sys/src/cmd/cec/cec.h - 644 sys sys 1193681095 537
+sys/src/cmd/cec/mkfile - 644 sys sys 1193683556 131
+sys/src/cmd/cec/mux.c - 664 sys sys 1193683306 1641
+sys/src/cmd/cec/plan9.c - 644 sys sys 1193683385 1408
+sys/src/cmd/cec/utils.c - 644 sys sys 1193681177 676
 sys/src/cmd/cfs - 20000000775 sys sys 1045505024 0
 sys/src/cmd/cfs/bcache.c - 664 sys sys 1172123361 2964
 sys/src/cmd/cfs/bcache.h - 664 sys sys 1014925220 797
@@ -10119,7 +10130,7 @@ sys/src/cmd/cwfs/portdat.h - 664 sys sys 1174716952 15241
 sys/src/cmd/cwfs/portfns.h - 664 sys sys 1174798778 6701
 sys/src/cmd/cwfs/portmkfile - 664 sys sys 1174798711 791
 sys/src/cmd/cwfs/scsi.c - 664 sys sys 1174282908 8865
-sys/src/cmd/cwfs/sub.c - 664 sys sys 1176500092 24371
+sys/src/cmd/cwfs/sub.c - 664 sys sys 1193717342 24472
 sys/src/cmd/cwfs/time.c - 664 sys sys 1171500176 1696
 sys/src/cmd/cwfs/uidgid.c - 664 sys sys 1174717700 9421
 sys/src/cmd/cwfs/wren.c - 664 sys sys 1174458303 2737
@@ -10249,9 +10260,9 @@ sys/src/cmd/disk/prep - 20000000775 sys sys 1055692957 0
 sys/src/cmd/disk/prep/calc.y - 664 sys sys 1135487935 2406
 sys/src/cmd/disk/prep/edit.c - 664 sys sys 1017854327 9714
 sys/src/cmd/disk/prep/edit.h - 664 sys sys 1015009215 994
-sys/src/cmd/disk/prep/fdisk.c - 664 sys sys 1126623191 21983
+sys/src/cmd/disk/prep/fdisk.c - 664 sys sys 1193693218 22265
 sys/src/cmd/disk/prep/mkfile - 664 sys sys 1022450200 250
-sys/src/cmd/disk/prep/prep.c - 664 sys sys 1126278202 10098
+sys/src/cmd/disk/prep/prep.c - 664 sys sys 1193692640 10170
 sys/src/cmd/disk/rd9660.c - 664 sys sys 1021579990 7446
 sys/src/cmd/disk/sacfs - 20000000775 sys sys 1039727556 0
 sys/src/cmd/disk/sacfs/mkfile - 664 sys sys 964815354 204
@@ -10430,13 +10441,13 @@ sys/src/cmd/grap/frame.c - 664 sys sys 944960999 1572
 sys/src/cmd/grap/grap.h - 664 sys sys 944960999 6090
 sys/src/cmd/grap/grap.y - 664 sys sys 944960999 9292
 sys/src/cmd/grap/grapl.lx - 664 sys sys 944960999 4871
-sys/src/cmd/grap/input.c - 664 sys sys 944960999 11416
+sys/src/cmd/grap/input.c - 664 sys sys 1193674137 11417
 sys/src/cmd/grap/label.c - 664 sys sys 944960999 3043
 sys/src/cmd/grap/main.c - 664 sys sys 944960999 3399
 sys/src/cmd/grap/misc.c - 664 sys sys 944960999 5081
 sys/src/cmd/grap/mkfile - 664 sys sys 944960999 456
 sys/src/cmd/grap/plot.c - 664 sys sys 944960999 2783
-sys/src/cmd/grap/print.c - 664 sys sys 944960999 5254
+sys/src/cmd/grap/print.c - 664 sys sys 1193674141 5221
 sys/src/cmd/grap/ticks.c - 664 sys sys 944960999 10887
 sys/src/cmd/graph - 20000000775 sys sys 1039727559 0
 sys/src/cmd/graph/graph.c - 664 sys sys 1148227144 13164

+ 25 - 0
dist/replica/plan9.log

@@ -53174,3 +53174,28 @@
 1193608804 1 c sys/src/boot/pc/devbios.c - 664 sys sys 1193607862 9299
 1193608804 2 c sys/src/boot/pc/sdbios.c - 664 sys sys 1193607899 3102
 1193608804 3 c sys/src/boot/pc/sdiahci.c - 664 sys sys 1193607891 27167
+1193675405 0 c sys/src/cmd/grap/input.c - 664 sys sys 1193674137 11417
+1193675405 1 c sys/src/cmd/grap/print.c - 664 sys sys 1193674141 5221
+1193684403 0 a sys/man/8/cec - 644 sys sys 1193683685 1929
+1193684403 1 a sys/src/cmd/cec - 20000000775 sys sys 1193683647 0
+1193684403 2 a sys/src/cmd/cec/LICENSE - 644 sys sys 1186248056 1554
+1193684403 3 a sys/src/cmd/cec/Protocol - 664 sys sys 1186248056 2881
+1193684403 4 a sys/src/cmd/cec/cec.c - 644 sys sys 1193683596 6829
+1193684403 5 a sys/src/cmd/cec/cec.h - 644 sys sys 1193681095 537
+1193684403 6 a sys/src/cmd/cec/mkfile - 644 sys sys 1193683556 131
+1193684403 7 a sys/src/cmd/cec/mux.c - 664 sys sys 1193683306 1641
+1193684403 8 a sys/src/cmd/cec/plan9.c - 644 sys sys 1193683385 1408
+1193684403 9 a sys/src/cmd/cec/utils.c - 644 sys sys 1193681177 676
+1193686204 0 c 386/bin/grap - 775 sys sys 1193686113 282795
+1193688005 0 c 386/9load - 775 sys sys 1193687665 337132
+1193688005 1 c 386/9loaddebug - 775 sys sys 1193687675 450713
+1193688005 2 c 386/9loadlite - 775 sys sys 1193687678 160432
+1193688005 3 c 386/9loadlitedebug - 775 sys sys 1193687682 236256
+1193688005 4 c 386/9pxeload - 775 sys sys 1193687689 337136
+1193688005 5 c sys/src/boot/pc/load.c - 664 sys sys 1193687652 9808
+1193693404 0 c sys/src/cmd/disk/prep/fdisk.c - 664 sys sys 1193693218 22265
+1193693404 1 c sys/src/cmd/disk/prep/prep.c - 664 sys sys 1193692640 10170
+1193715004 0 a 386/bin/cec - 775 sys sys 1193714267 75896
+1193715004 1 c 386/bin/disk/fdisk - 775 sys sys 1193714268 104619
+1193715004 2 c 386/bin/disk/prep - 775 sys sys 1193714270 96195
+1193718604 0 c sys/src/cmd/cwfs/sub.c - 664 sys sys 1193717342 24472

+ 98 - 0
sys/man/8/cec

@@ -0,0 +1,98 @@
+.TH CEC 8
+.SH NAME
+cec \- Coraid Ethernet Console
+.SH SYNOPSIS
+.B cec
+[
+.B -d
+] [
+.B -s
+.I shelf
+] [
+.B -e
+.I esc
+]
+.I interface
+.SH DESCRIPTION
+The
+.I cec
+command uses raw Ethernet frames to connect to a CEC
+server for console access.  All clients share the same session.  Coraid
+appliances are currently the only CEC servers.
+.PP
+A
+.I cec
+process starts by probing the specified network interface
+(e.g.,
+.LR /net/ether0 )
+for available CEC servers.  If the shelf address of the server is
+specified with the
+.B -s
+flag, the connection will
+proceed immediately upon discovery of the first CEC server
+with this shelf address.  Otherwise, a selection prompt
+will be displayed showing the discovered CEC servers
+available for communication.  If no servers are discovered,
+.I cec
+exits.
+.IP
+.EX
+0 5 003048865f1e shelf5
+[#qp]:
+.EE
+.LP
+The selection prompt accepts
+.TP
+.I number
+Connect to server
+.I number
+(from the first column),
+.TP
+.B p
+Probe the interface again, and
+.TP
+.B q
+Quit.
+.PP
+Note the selection number is not the shelf address but the
+.IR cec -generated
+ID number printed in the leftmost column.
+.PP
+Once connected to a CEC server, entering the escape sequence
+will drop the user into an escape prompt where the user may
+type
+.L q
+to quit the connection,
+.L i
+to send the escape sequence
+across the connection, or
+.L .
+to continue the connection.
+The escape sequence is printed on connection.
+.PP
+If the
+.B -s
+option is used,
+.I cec
+will exit upon closing the connection.
+Otherwise,
+.I cec
+will return to the selection prompt upon connection close.
+.SS Options
+.TP 1i
+.B -d
+Output debugging information.
+.TP
+.BI -s " shelf"
+Connect to the server at shelf address
+.IR shelf .
+.TP
+.BI -e " esc"
+Set the escape caracter to
+.BI control -
+.IR esc .
+The default setting is
+.BR control -\e.
+.SH BUGS
+The CEC protocol should be integrated with the console server.
+The arbitration between the keyboard and network is suboptimal.

+ 1 - 1
sys/src/boot/pc/load.c

@@ -205,7 +205,7 @@ boot(Medium *mp, char *file)
 	}
 
 	sprint(BOOTLINE, "%s!%s", mp->name, file);
-	print("booting %s!%s", mp->name, file);
+	print("booting %s!%s\n", mp->name, file);
 	return (*mp->type->boot)(mp->dev, file, &b);
 }
 

+ 32 - 0
sys/src/cmd/cec/LICENSE

@@ -0,0 +1,32 @@
+The FreeBSD License
+
+Copyright 2006 Coraid, Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE BRANTLEY COILE COMPANY ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE BRANTLEY COILE COMPANY
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation
+are those of the authors and should not be interpreted as representing
+official policies, either expressed or implied, of the Brantley Coile
+Company.

+ 93 - 0
sys/src/cmd/cec/Protocol

@@ -0,0 +1,93 @@
+Coraid Ethernet Console (cec)
+
+Abstract
+
+The Coraid Ethernet Console (cec) implements a bidirectional conversation
+over raw ethernet frames with provisions for retransmission and discovery.  
+Like serial consoles, each machine has a single shared interface per service
+type,  but any number connections can be made from any machine connected to 
+the same physical network.  The communications from the various connections
+will be interleaved.  The first implementation of cec is for console communications
+to Coraid appliances.
+
+Outline
+
+1. Packet format
+2. The Tdiscover packet and Toffer reply.
+3.  Initializing a connection. Tinit[abc]
+4.  The connection.  Tdata and Tack
+5.  Closing the connection.  Treset
+
+1. Packet Format
+
+All cec packets are follow the layout implied by the following structure
+
+	struct Pkt {
+		uchar	dst[6];		// destination ethernet address
+		uchar	src[6];		// source ethernet address
+		uchar	etype[2];		// service type
+		uchar	type;		// type of packet.
+		uchar	conn;		// unique connection id.
+		uchar	seq;		// packet sequence number
+		uchar	len;		// data length.
+		uchar	data[1500];
+	};
+
+The packet types are as follows:
+
+	enum {
+		Tinita,
+		Tinitb,
+		Tinitc,
+		Tdata,
+		Tack,
+		Tdiscover,
+		Toffer,
+		Treset,
+	};
+
+2. The Tdiscover packet and Toffer reply.
+
+The Tdiscover packet is used to discover the avaliable cec devices on the local
+network.  The packet sent is of the form
+
+	Tdiscover = {
+	[dest]	0xffffffff,
+	[src]	mac of local interface,
+	[etype]	service type,
+	[type]	Tdiscover,
+	[seq]	0,
+	[len]	0,
+	[data]	0,
+	}
+
+The reply to the Tdiscover packet is of type Toffer which differes from
+Tdiscover in that data and len may be set.  The contents of data is application
+specific.
+
+3.  Initializing a connection. Tinit[abc]
+
+A connection is initialized by the following conversation: In addition
+to the fields set for the Tdiscover packet, he client sends a packet
+of type Tinita with the conntag of its choice.  The server responds to
+Tinita with a packet of type Tinitb.  And finally the client sents a
+Tinitc packet back to the server, completing the connection.
+
+4.  The connection.  Tdata and Tack
+
+Data is sent from the client to the console server with the Tdata packet.
+The seq field is incremented for each data packet sent.  Thus data packets
+may be transmitted if lost.  The data is whatever data the client has to
+send to the server, up to 1500 bytes.  Typically, however, each keystroke
+is sent in a seperate packet.  The len field is the length of the
+data.
+
+The server responds to a Tdata message with a Tack message with the 
+same seq sequence number.
+
+5.  Closing the connection.  Treset
+
+Either the server of the client may send a Treset message to close the 
+connection.  There is no response to a Treset message, however any
+information associated with that connection (conntag) is discarded 
+when the Treset message is recieved.

+ 449 - 0
sys/src/cmd/cec/cec.c

@@ -0,0 +1,449 @@
+/*
+ * Copyright © Coraid, Inc. 2006, 2007.  All Rights Reserved.
+ * ethernet console for Coraid storage products.
+ *  simple command line version.
+ */
+#include <u.h>
+#include <libc.h>
+#include <ip.h>	/* really! */
+#include <ctype.h>
+#include "cec.h"
+
+enum {
+	Tinita = 0,
+	Tinitb,
+	Tinitc,
+	Tdata,
+	Tack,
+	Tdiscover,
+	Toffer,
+	Treset,
+
+	HDRSIZ = 18,
+	Eaddrlen = 6,
+};
+
+typedef struct Shelf Shelf;
+
+struct Shelf {
+	uchar	ea[Eaddrlen];
+	int	shelfno;
+	char	*str;
+};
+
+void 	conn(int);
+void	exits0(char *);
+void 	gettingkilled(int);
+int 	pickone(void);
+void 	probe(void);
+void	sethdr(Pkt *, int);
+int	shelfidx(void);
+
+extern int errno;
+extern int fd;			/* set in netopen */
+
+Shelf	tab[1000];
+int	ntab;
+uchar	contag;
+int	shelf = -1;
+Shelf	*connp;
+char 	esc = '';
+
+void
+usage(void)
+{
+	fprint(2, "usage: cec [-d] [-e esc] [-s shelf] interface\n");
+	exits0("usage");
+}
+
+void
+catch(void*, char *note)
+{
+	if(strcmp(note, "alarm") == 0)
+		noted(NCONT);
+	noted(NDFLT);
+}
+
+void
+main(int argc, char **argv)
+{
+	int r, n;
+
+	ARGBEGIN{
+	case 'd':
+		debug++;
+		break;
+	case 's':
+		shelf = atoi(EARGF(usage()));
+		break;
+	case 'e':
+		esc = toupper(*(EARGF(usage()))) - 'A' + 1;
+		if(esc <= 0 || esc >= ' ')
+			usage();
+		break;
+	default:
+		usage();
+	}ARGEND
+	if(debug)
+		fprint(2, "debug is on\n");
+	if(argc != 1)
+		usage();
+
+	fmtinstall('E', eipfmt);
+	r = netopen(*argv);
+	if(r == -1){
+		fprint(2, "cec: can't netopen %s\n", *argv);
+		exits0("open");
+	}
+	notify(catch);
+	probe();
+	for(;;){
+		n = 0;
+		if(shelf == -1)
+			n = pickone();
+		rawon();
+		conn(n);
+		rawoff();
+		if(shelf != -1)
+			exits0("shelf not found");
+	}
+}
+
+void
+timewait(int ms)  /* arrange for a sig_alarm signal after `ms' milliseconds */
+{
+	alarm(ms);
+}
+
+int
+didtimeout(void)
+{
+	char buf[ERRMAX];
+
+	rerrstr(buf, sizeof buf);
+	if(strcmp(buf, "interrupted") == 0){
+		werrstr(buf, 0);
+		return 1;
+	}
+	return 0;
+}
+
+ushort
+htons(ushort h)
+{
+	ushort n;
+	uchar *p;
+
+	p = (uchar*)&n;
+	p[0] = h >> 8;
+	p[1] = h;
+	return n;
+}
+
+ushort
+ntohs(int h)
+{
+	ushort n;
+	uchar *p;
+
+	n = h;
+	p = (uchar*)&n;
+	return p[0] << 8 | p[1];
+}
+
+void
+probe(void)
+{
+	int n;
+	char *sh, *other;
+	uchar buf[1500];
+	Pkt q;
+	Shelf *p;
+
+	ntab = 0;
+	memset(buf, 0xff, Eaddrlen);
+	memset(q.dst, 0xff, Eaddrlen);
+	memset(q.src, 0, Eaddrlen);
+	q.etype = htons(Etype);
+	q.type = Tdiscover;
+	q.len = 0;
+	q.conn = 0;
+	q.seq = 0;
+	netsend(&q, 60);
+//	fprint(2, "Probing for shelves ... ");
+	timewait(Iowait);
+	while((n = netget(&q, sizeof q)) >= 0) {
+		if((n <= 0 && didtimeout()) || ntab == nelem(tab))
+			break;
+		if(n < 60 || q.len == 0 || q.type != Toffer)
+			continue;
+		q.data[q.len] = 0;
+		sh = strtok((char *)q.data, " \t");
+		if(sh == nil)
+			continue;
+		if(shelf != -1 && atoi(sh) != shelf)
+			continue;
+		other = strtok(nil, "\x1");
+		p = tab + ntab++;
+		memcpy(p->ea, q.src, Eaddrlen);
+		p->shelfno = atoi(sh);
+		p->str = other? strdup(other): "";
+		if(shelf != -1) {
+			fprint(2, "shelf %d found.\n", shelf);
+			break;
+		}
+	}
+	alarm(0);
+	if(ntab == 0) {
+		fprint(2, "none found.\n");
+		exits0("none found");
+	}
+//	fprint(2, "done.\n");
+}
+
+void
+showtable(void)
+{
+	int i;
+
+	for(i = 0; i < ntab; i++)
+		print("%2d   %5d %E %s\n", i,
+			tab[i].shelfno, tab[i].ea, tab[i].str);
+}
+
+int
+pickone(void)
+{
+	char buf[80];
+	int n, i;
+
+	for(;;){
+		showtable();
+		print("[#qp]: ");
+		switch(n = read(0, buf, sizeof buf)){
+		case 1:
+			if(buf[0] == '\n')
+				continue;
+			/* fall through */
+		case 2:
+			if(buf[0] == 'p'){
+				probe();
+				break;
+			}
+			if(buf[0] == 'q')
+			/* fall through */
+		case 0:
+		case -1:
+				exits0(0);
+		}
+		if(isdigit(buf[0])){
+			buf[n] = 0;
+			i = atoi(buf);
+			if(i >= 0 && i < ntab)
+				break;
+		}
+	}
+	return i;
+}
+
+void
+sethdr(Pkt *pp, int type)
+{
+	memmove(pp->dst, connp->ea, Eaddrlen);
+	memset(pp->src, 0, Eaddrlen);
+	pp->etype = htons(Etype);
+	pp->type = type;
+	pp->len = 0;
+	pp->conn = contag;
+}
+
+void
+ethclose(void)
+{
+	static Pkt msg;
+
+	sethdr(&msg, Treset);
+	timewait(Iowait);
+	netsend(&msg, 60);
+	alarm(0);
+	connp = 0;
+}
+
+int
+ethopen(void)
+{
+	Pkt tpk, rpk;
+	int i, n;
+
+	contag = (getpid() >> 8) ^ (getpid() & 0xff);
+	sethdr(&tpk, Tinita);
+	sethdr(&rpk, 0);
+	for(i = 0; i < 3 && rpk.type != Tinitb; i++){
+		netsend(&tpk, 60);
+		timewait(Iowait);
+		n = netget(&rpk, 1000);
+		alarm(0);
+		if(n < 0)
+			return -1;
+	}
+	if(rpk.type != Tinitb)
+		return -1;
+	sethdr(&tpk, Tinitc);
+	netsend(&tpk, 60);
+	return 0;
+}
+
+char
+escape(void)
+{
+	char buf[64];
+
+	for(;;){
+		fprint(2, ">>> ");
+		buf[0] = '.';
+		rawoff();
+		read(0, buf, sizeof buf-1);
+		rawon();
+		switch(buf[0]){
+		case 'i':
+		case 'q':
+		case '.':
+			return buf[0];
+		}
+		fprint(2, "	(q)uit, (i)nterrupt, (.)continue\n");
+	}
+}
+
+/*
+ * this is a bit too agressive.  it really needs to replace only \n\r with \n.
+ */
+static uchar crbuf[1514];
+
+void
+nocrwrite(int fd, uchar *buf, int n)
+{
+	int i, j, c;
+
+	j = 0;
+	for(i = 0; i < n; i++){
+		if((c = buf[i]) == '\r')
+			continue;
+		crbuf[j++] = c;
+	}
+	write(fd, crbuf, j);
+}
+
+int
+doloop(void)
+{
+	int unacked, retries, set[2];
+	uchar c, tseq, rseq;
+	uchar ea[Eaddrlen];
+	Mux * m;
+	Pkt tpk, spk;
+
+	memmove(ea, connp->ea, Eaddrlen);
+	retries = 0;
+	unacked = 0;
+	tseq = 0;
+	rseq = -1;
+	set[0] = 0;
+	set[1] = fd;
+top:
+	if ((m = mux(set)) == 0)
+		exits0("mux: %r");
+	for (; ; )
+		switch (muxread(m, &spk)) {
+		case -1:
+			if (unacked == 0)
+				break;
+			if (retries-- == 0) {
+				fprint(2, "Connection timed out\n");
+				muxfree(m);
+				return 0;
+			}
+			netsend(&tpk, HDRSIZ + unacked);
+			break;
+		case 0:
+			c = spk.data[0];
+			if (c == esc) {
+				muxfree(m);
+				switch (escape()) {
+				case 'q':
+					tpk.len = 0;
+					tpk.type = Treset;
+					netsend(&tpk, 60);
+					return 0;
+				case '.':
+					goto top;
+				case 'i':
+					if ((m = mux(set)) == 0)
+						exits0("mux: %r");
+					break;
+				}
+			}
+			sethdr(&tpk, Tdata);
+			memcpy(tpk.data, spk.data, spk.len);
+			tpk.len = spk.len;
+			tpk.seq = ++tseq;
+			unacked = spk.len;
+			retries = 2;
+			netsend(&tpk, HDRSIZ + spk.len);
+			break;
+		default:
+			if (memcmp(spk.src, ea, Eaddrlen) != 0 ||
+			    ntohs(spk.etype) != Etype)
+				continue;
+			if (spk.type == Toffer) {
+				muxfree(m);
+				return 1;
+			}
+			if (spk.conn != contag)
+				continue;
+			switch (spk.type) {
+			case Tdata:
+				if (spk.seq == rseq)
+					break;
+				nocrwrite(1, spk.data, spk.len);
+				if (0)
+					write(1, spk.data, spk.len);
+				memmove(spk.dst, spk.src, Eaddrlen);
+				memset(spk.src, 0, Eaddrlen);
+				spk.type = Tack;
+				spk.len = 0;
+				rseq = spk.seq;
+				netsend(&spk, 60);
+				break;
+			case Tack:
+				if (spk.seq == tseq)
+					unacked = 0;
+				break;
+			case Treset:
+				muxfree(m);
+				return 1;
+			}
+		}
+}
+
+void
+conn(int n)
+{
+	do {
+		if(connp)
+			ethclose();
+		connp = &tab[n];
+		if(ethopen() < 0){
+			fprint(2, "connection failed.\n");
+			return;
+		}
+	} while(doloop());
+}
+
+void
+exits0(char *s)
+{
+	if(connp != nil)
+		ethclose();
+	rawoff();
+	exits(s);
+}

+ 40 - 0
sys/src/cmd/cec/cec.h

@@ -0,0 +1,40 @@
+/* cec.h: definitions for cec */
+
+typedef struct {
+	uchar	dst[6];
+	uchar	src[6];
+	ushort	etype;
+	uchar	type;
+	uchar	conn;
+	uchar	seq;
+	uchar	len;
+	uchar	data[1500];
+} Pkt;
+
+enum {
+	Fkbd,
+	Fcec,
+	Floc,
+};
+
+typedef struct Mux Mux;
+#pragma incomplete Mux;
+
+enum {
+	Iowait		= 2000,
+	Etype 		= 0xbcbc,
+};
+int debug;
+
+Mux *mux(int fd[2]);
+int muxread(Mux*, Pkt*);
+void muxfree(Mux*);
+
+int netopen(char *name);
+int netsend(void *, int);
+int netget(void *, int);
+
+void rawon(void);
+void rawoff(void);
+void dump(uchar*, int);
+void exits0(char*);

+ 14 - 0
sys/src/cmd/cec/mkfile

@@ -0,0 +1,14 @@
+</$objtype/mkfile
+
+TARG=cec
+
+OFILES=\
+	cec.$O\
+	plan9.$O\
+	mux.$O\
+	utils.$O\
+
+HFILES=cec.h
+
+BIN=/$objtype/bin
+</sys/src/cmd/mkone

+ 109 - 0
sys/src/cmd/cec/mux.c

@@ -0,0 +1,109 @@
+/* Copyright © Coraid, Inc. 2006.  All rights reserved. */
+#include <u.h>
+#include <libc.h>
+#include "cec.h"
+
+typedef struct {
+	char	type;
+	char	pad[3];
+	Pkt	p;
+} Muxmsg;
+
+typedef struct {
+	int	fd;
+	int	type;
+	int	pid;
+} Muxproc;
+
+struct Mux {
+	Muxmsg	m;
+	Muxproc	p[2];
+	int	pfd[2];
+	int	inuse;
+};
+
+static Mux smux = {
+.inuse	= -1,
+};
+
+void
+muxcec(int, int cfd)
+{
+	Muxmsg m;
+	int l;
+
+	m.type = Fcec;
+	while((l = netget(&m.p, sizeof m.p)) > 0)
+		if(write(cfd, &m, l+4) != l+4)
+			break;
+	exits("");
+}
+
+void
+muxkbd(int kfd, int cfd)
+{
+	Muxmsg m;
+
+	m.type = Fkbd;
+	while((m.p.len = read(kfd, m.p.data, sizeof m.p.data)) > 0)
+		if(write(cfd, &m, m.p.len+22) != m.p.len+22)
+			break;
+	exits("");
+}
+
+int
+muxproc(Mux *m, Muxproc *p, int fd, void (*f)(int, int), int type)
+{
+	memset(p, 0, sizeof p);
+	p->type = -1;
+	switch(p->pid = rfork(RFPROC|RFFDG)){
+	case -1:
+		return -1;
+	case 0:
+		close(m->pfd[0]);
+		f(fd, m->pfd[1]);
+	default:
+		p->fd = fd;
+		p->type = type;
+		return p->pid;
+	}
+}
+
+void
+muxfree(Mux *m)
+{
+	close(m->pfd[0]);
+	close(m->pfd[1]);
+	postnote(PNPROC, m->p[0].pid, "this note goes to 11");
+	postnote(PNPROC, m->p[1].pid, "this note goes to 11");
+	waitpid();
+	waitpid();
+	memset(m, 0, sizeof *m);
+	m->inuse = -1;
+}
+
+Mux*
+mux(int fd[2])
+{
+	Mux *m;
+
+	if(smux.inuse != -1)
+		sysfatal("mux in use");
+	m = &smux;
+	m->inuse = 1;
+	if(pipe(m->pfd) == -1)
+		sysfatal("pipe: %r");
+	muxproc(m, m->p+0, fd[0], muxkbd, Fkbd);
+	muxproc(m, m->p+1, fd[1], muxcec, Fcec);
+	close(m->pfd[1]);
+	return m;
+}
+
+int
+muxread(Mux *m, Pkt *p)
+{
+	if(read(m->pfd[0], &m->m, sizeof m->m) == -1)
+		return -1;
+	memcpy(p, &m->m.p, sizeof *p);
+	return m->m.type;
+}

+ 89 - 0
sys/src/cmd/cec/plan9.c

@@ -0,0 +1,89 @@
+/* Copyright © Coraid, Inc. 2006.  All rights reserved. */
+#include <u.h>
+#include <libc.h>
+#include "cec.h"
+
+int	fd = -1;
+int	cfd = -1;
+int	efd = -1;
+
+int
+netopen0(char *e)
+{
+	char buf[128], ctl[13];
+	int n;
+
+	snprint(buf, sizeof buf, "%s/clone", e);
+	if((efd = open(buf, ORDWR)) == -1)
+		return -1;
+	memset(ctl, 0, sizeof ctl);
+	if(read(efd, ctl, sizeof ctl) < 0)
+		return -1;
+	n = atoi(ctl);
+	snprint(buf, sizeof buf, "connect %d", Etype);
+	if(write(efd, buf, strlen(buf)) != strlen(buf))
+		return -1;
+	snprint(buf, sizeof buf, "%s/%d/ctl", e, n);
+	if((cfd = open(buf, ORDWR)) < 0)
+		return -1;
+	snprint(buf, sizeof buf, "nonblocking");
+	if(write(cfd, buf, strlen(buf)) != strlen(buf))
+		return -1;
+	snprint(buf, sizeof buf, "%s/%d/data", e, n);
+	fd = open(buf, ORDWR);
+	return fd;
+}
+
+void
+netclose(void)
+{
+	close(efd);
+	close(cfd);
+	close(fd);
+	efd = -1;
+	cfd = -1;
+	fd = -1;
+}
+
+int
+netopen(char *e)
+{
+	int r;
+
+	if((r = netopen0(e)) >= 0)
+		return r;
+	perror("netopen");
+	netclose();
+	return -1;
+}
+
+/* what if len < netlen? */
+int
+netget(void *v, int len)
+{
+	int l;
+
+	l = read(fd, v, len);
+	if(debug && l > 0){
+		fprint(2, "read %d bytes\n", l);
+		dump((uchar*)v, l);
+	}
+	if (l <= 0)
+		return 0;
+	return l;
+}
+
+int
+netsend(void *v, int len)
+{
+	uchar *p;
+
+	p = v;
+	if (debug) {
+		fprint(2, "sending %d bytes\n", len);
+		dump(p, len);
+	}
+	if (len < 60)
+		len = 60;	/* mintu */
+	return write(fd, p, len);
+}

+ 48 - 0
sys/src/cmd/cec/utils.c

@@ -0,0 +1,48 @@
+/* Copyright Coraid, Inc.  2006.  All Rights Reserved */
+#include <u.h>
+#include <libc.h>
+#include "cec.h"
+
+static int fd = -1;
+
+void
+rawon(void)
+{
+	if((fd = open("/dev/consctl", OWRITE)) == -1 ||
+	    write(fd, "rawon", 5) != 5)
+		fprint(2, "Can't make console raw\n");
+}
+
+void
+rawoff(void)
+{
+	close(fd);
+}
+
+enum {
+	Perline	= 16,
+	Perch	= 3,
+};
+
+char	line[Perch*Perline+1];
+
+static void
+format(uchar *buf, int n, int t)
+{
+	int i, r;
+
+	for(i = 0; i < n; i++){
+		r = (i + t) % Perline;
+		if(r == 0 && i + t > 0)
+			fprint(2, "%s\n", line);
+		sprint(line + r*Perch, "%.2x ", buf[i]);
+	}
+}
+
+void
+dump(uchar *p, int n)
+{
+	format(p, n, 0);
+	if(n % 16 > 0)
+		print("%s\n", line);
+}

+ 5 - 1
sys/src/cmd/cwfs/sub.c

@@ -512,7 +512,11 @@ loop:
 	bp = getbuf(dev, a, Bmod);
 	memset(bp->iobuf, 0, RBUFSIZE);
 	settag(bp, tag, qid);
-	if(tag == Tind1 || tag == Tind2 || tag == Tdir)
+	if(tag == Tind1 || tag == Tind2 ||
+#ifndef COMPAT32
+	    tag == Tind3 || tag == Tind4 ||  /* add more Tind tags here ... */
+#endif
+	    tag == Tdir)
 		bp->flags |= Bimm;
 	putbuf(bp);
 	putbuf(p);

+ 12 - 4
sys/src/cmd/disk/prep/fdisk.c

@@ -14,7 +14,7 @@ enum {
 	Mpart = 64,
 };
 
-static void rdpart(Edit*, ulong, ulong);
+static void rdpart(Edit*, uvlong, uvlong);
 static void findmbr(Edit*);
 static void autopart(Edit*);
 static void wrpart(Edit*);
@@ -381,7 +381,7 @@ Error:
 }
 
 static Dospart*
-mkpart(char *name, int primary, u32int lba, u32int size, Tentry *t)
+mkpart(char *name, int primary, vlong lba, vlong size, Tentry *t)
 {
 	static int n;
 	Dospart *p;
@@ -405,7 +405,11 @@ mkpart(char *name, int primary, u32int lba, u32int size, Tentry *t)
 	p->ctlstart = lba;
 	p->ctlend = lba+size;
 	p->lba = lba;
+	if (p->lba != lba)
+		fprint(2, "%s: start of partition (%lld) won't fit in MBR table\n", argv0, lba);
 	p->size = size;
+	if (p->size != size)
+		fprint(2, "%s: size of partition (%lld) won't fit in MBR table\n", argv0, size);
 	p->primary = primary;
 	return p;
 }
@@ -473,7 +477,7 @@ recover(Edit *edit)
  * from the disk into the part array.
  */
 static void
-rdpart(Edit *edit, ulong lba, ulong xbase)
+rdpart(Edit *edit, uvlong lba, uvlong xbase)
 {
 	char *err;
 	Table table;
@@ -736,6 +740,7 @@ cmdokname(Edit*, char *name)
 	return nil;
 }
 
+#define TB (1024LL*GB)
 #define GB (1024*1024*1024)
 #define MB (1024*1024)
 #define KB (1024)
@@ -759,7 +764,10 @@ cmdsum(Edit *edit, Part *vp, vlong a, vlong b)
 	ty = p ? typestr0(p->type) : "";
 
 	sz = (b-a)*edit->disk->secsize*sec2cyl;
-	if(sz >= 1*GB){
+	if(sz >= 1*TB){
+		suf = "TB";
+		div = TB;
+	}else if(sz >= 1*GB){
 		suf = "GB";
 		div = GB;
 	}else if(sz >= 1*MB){

+ 8 - 4
sys/src/cmd/disk/prep/prep.c

@@ -50,14 +50,15 @@ Edit edit = {
 typedef struct Auto Auto;
 struct Auto
 {
-	char *name;
+	char	*name;
 	uvlong	min;
 	uvlong	max;
-	uint weight;
+	uint	weight;
 	uchar	alloc;
 	uvlong	size;
 };
 
+#define TB (1024LL*GB)
 #define GB (1024*1024*1024)
 #define MB (1024*1024)
 #define KB (1024)
@@ -205,7 +206,10 @@ cmdsum(Edit *edit, Part *p, vlong a, vlong b)
 	name = p ? p->name : "empty";
 
 	sz = (b-a)*edit->disk->secsize;
-	if(sz >= 1*GB){
+	if(sz >= 1*TB){
+		suf = "TB";
+		div = TB;
+	}else if(sz >= 1*GB){
 		suf = "GB";
 		div = GB;
 	}else if(sz >= 1*MB){
@@ -288,8 +292,8 @@ static void
 rdpart(Edit *edit)
 {
 	int i, nline, nf, waserr;
-	char *line[128];
 	vlong a, b;
+	char *line[128];
 	char *f[5];
 	char *err;
 	Disk *disk;

+ 1 - 1
sys/src/cmd/grap/input.c

@@ -454,7 +454,7 @@ void eprint(void)	/* try to print context around error */
 		if (isprint(*p))
 			putc(*p, stderr);
 	fprintf(stderr, " >>> ");
-	for (; p < q; p++)
+	for (; p < ep; p++)
 		if (isprint(*p))
 			putc(*p, stderr);
 	fprintf(stderr, " <<< ");

+ 0 - 2
sys/src/cmd/grap/print.c

@@ -223,8 +223,6 @@ void reset(void)		/* done at each "graph ..." statement */
 
 void opentemp(void)
 {
-	if (tfd != NULL)
-		fclose(tfd);
 	if (tfd != stdout) {
 		if (tfd != NULL)
 			fclose(tfd);