Browse Source

Plan 9 from Bell Labs 2003-06-16

David du Colombier 21 years ago
parent
commit
215f76e2af
100 changed files with 1734 additions and 1461 deletions
  1. 200 183
      dist/replica/plan9.db
  2. 264 0
      dist/replica/plan9.log
  3. 1 0
      lib/vgadb
  4. 1 1
      rc/bin/ps2gif
  5. 1 1
      rc/bin/stock
  6. 4 0
      sys/include/String.h
  7. 4 2
      sys/include/stdio.h
  8. 10 10
      sys/man/1/ar
  9. 9 0
      sys/man/1/dd
  10. 19 1
      sys/man/1/nedmail
  11. 6 0
      sys/man/2/authsrv
  12. 5 0
      sys/man/2/string
  13. 1 1
      sys/man/3/fs
  14. 11 8
      sys/man/3/realtime
  15. 110 0
      sys/man/4/ext2srv
  16. 47 4
      sys/man/4/fossil
  17. 27 5
      sys/man/6/venti.conf
  18. 7 2
      sys/man/8/aliasmail
  19. 37 4
      sys/man/8/fossilcons
  20. 14 3
      sys/man/8/fs
  21. 50 35
      sys/man/8/ipconfig
  22. 23 2
      sys/man/8/ndb
  23. 39 25
      sys/man/8/prep
  24. 3 0
      sys/man/8/venti
  25. 30 0
      sys/man/8/ventiaux
  26. 0 58
      sys/man/8/x509
  27. 16 16
      sys/src/9/alphapc/dat.h
  28. 1 492
      sys/src/9/alphapc/devether.c
  29. 0 50
      sys/src/9/alphapc/errstr.h
  30. 0 51
      sys/src/9/bitsy/errstr.h
  31. 2 1
      sys/src/9/bitsy/l.s
  32. 1 1
      sys/src/9/bitsy/mem.h
  33. 1 0
      sys/src/9/bitsy/mmu.c
  34. 1 1
      sys/src/9/bitsy/sdata.c
  35. 1 1
      sys/src/9/bitsy/trap.c
  36. 0 1
      sys/src/9/boot/boot.c
  37. 2 0
      sys/src/9/boot/boot.h
  38. 1 0
      sys/src/9/boot/bootip.c
  39. 1 2
      sys/src/9/ip/igmp.c
  40. 1 5
      sys/src/9/ip/il.c
  41. 2 1
      sys/src/9/ip/loopbackmedium.c
  42. 33 35
      sys/src/9/ip/rudp.c
  43. 1 3
      sys/src/9/ip/tcp.c
  44. 36 38
      sys/src/9/ip/udp.c
  45. 0 50
      sys/src/9/mtx/errstr.h
  46. 4 1
      sys/src/9/pc/archmp.c
  47. 10 7
      sys/src/9/pc/devarch.c
  48. 2 2
      sys/src/9/pc/devfloppy.c
  49. 0 50
      sys/src/9/pc/errstr.h
  50. 2 0
      sys/src/9/pc/ether8139.c
  51. 3 7
      sys/src/9/pc/ether82543gc.c
  52. 1 3
      sys/src/9/pc/ether82557.c
  53. 0 3
      sys/src/9/pc/floppy.h
  54. 7 10
      sys/src/9/pc/i8253.c
  55. 2 1
      sys/src/9/pc/l.s
  56. 5 4
      sys/src/9/pc/main.c
  57. 3 2
      sys/src/9/pc/pc
  58. 2 1
      sys/src/9/pc/pcauth
  59. 7 3
      sys/src/9/pc/pcdisk
  60. 1 0
      sys/src/9/pc/pcflop
  61. 74 32
      sys/src/9/pc/sd53c8xx.c
  62. 1 1
      sys/src/9/pc/sdscsi.c
  63. 1 0
      sys/src/9/pc/vgas3.c
  64. 1 1
      sys/src/9/pc/wavelan.c
  65. 0 1
      sys/src/9/pc/wavelan.h
  66. 0 1
      sys/src/9/port/auth.c
  67. 1 1
      sys/src/9/port/cache.c
  68. 49 39
      sys/src/9/port/chan.c
  69. 4 4
      sys/src/9/port/cis.c
  70. 1 1
      sys/src/9/port/devaudio.c
  71. 1 1
      sys/src/9/port/devbridge.c
  72. 3 3
      sys/src/9/port/devcons.c
  73. 2 2
      sys/src/9/port/devmnt.c
  74. 4 4
      sys/src/9/port/devpnp.c
  75. 11 5
      sys/src/9/port/devrealtime.c
  76. 13 13
      sys/src/9/port/devsd.c
  77. 1 2
      sys/src/9/port/devsdp.c
  78. 5 3
      sys/src/9/port/devtls.c
  79. 3 4
      sys/src/9/port/devuart.c
  80. 25 8
      sys/src/9/port/edf.c
  81. 5 3
      sys/src/9/port/edf.h
  82. 1 0
      sys/src/9/port/error.h
  83. 5 0
      sys/src/9/port/initcode.c
  84. 45 12
      sys/src/9/port/mkbootrules
  85. 1 28
      sys/src/9/port/mkdevc
  86. 2 12
      sys/src/9/port/mkdevlist
  87. 1 1
      sys/src/9/port/page.c
  88. 2 1
      sys/src/9/port/pgrp.c
  89. 6 6
      sys/src/9/port/portclock.c
  90. 25 20
      sys/src/9/port/portdat.h
  91. 5 1
      sys/src/9/port/portfns.h
  92. 1 7
      sys/src/9/port/portmkfile
  93. 9 8
      sys/src/9/port/proc.c
  94. 4 2
      sys/src/9/port/qlock.c
  95. 5 2
      sys/src/9/port/realtimesub.c
  96. 0 1
      sys/src/9/port/sd.h
  97. 1 1
      sys/src/9/port/swap.c
  98. 342 36
      sys/src/9/port/sysfile.c
  99. 2 1
      sys/src/9/port/sysproc.c
  100. 0 6
      sys/src/cmd/auth/passwd.c

File diff suppressed because it is too large
+ 200 - 183
dist/replica/plan9.db


+ 264 - 0
dist/replica/plan9.log

@@ -12046,3 +12046,267 @@
 1055091688 3 c sys/src/9/pc/pccd - 664 sys sys 1055090302 1302
 1055091688 3 c sys/src/9/pc/pccd - 664 sys sys 1055090302 1302
 1055091688 4 c sys/src/9/pc/vganvidia.c - 664 sys sys 1055090312 6543
 1055091688 4 c sys/src/9/pc/vganvidia.c - 664 sys sys 1055090312 6543
 1055091688 5 d sys/src/9/pc/ether82543.c - 664 sys sys 1039803177 0
 1055091688 5 d sys/src/9/pc/ether82543.c - 664 sys sys 1039803177 0
+1055689364 0 c sys/src/9/port/auth.c - 664 sys sys 1055688251 2308
+1055689364 1 c sys/src/9/port/cache.c - 664 sys sys 1055688274 9241
+1055689364 2 c sys/src/9/port/chan.c - 664 sys sys 1055688280 29137
+1055689364 3 c sys/src/9/port/cis.c - 664 sys sys 1055688285 8082
+1055689364 4 c sys/src/9/port/devaudio.c - 664 sys sys 1055688292 21132
+1055689364 5 c sys/src/9/port/devbridge.c - 664 sys sys 1055688301 24308
+1055689364 6 c sys/src/9/port/devcons.c - 664 sys sys 1055688321 20946
+1055689364 7 c sys/src/9/port/devmnt.c - 664 sys sys 1055688328 21594
+1055689364 8 c sys/src/9/port/devpnp.c - 664 sys sys 1055688361 13021
+1055689364 9 c sys/src/9/port/devrealtime.c - 664 sys sys 1055688366 16209
+1055689364 10 c sys/src/9/port/devsd.c - 664 sys sys 1055688396 28669
+1055689364 11 c sys/src/9/port/devsdp.c - 664 sys sys 1055688405 44800
+1055689364 12 c sys/src/9/port/devtls.c - 664 sys sys 1055688453 43764
+1055689364 13 c sys/src/9/port/devuart.c - 664 sys sys 1055688473 11586
+1055689364 14 c sys/src/9/port/edf.c - 664 sys sys 1055688474 24743
+1055689364 15 c sys/src/9/port/page.c - 664 sys sys 1055688510 8107
+1055689364 16 c sys/src/9/port/pgrp.c - 664 sys sys 1055688510 3940
+1055689364 17 c sys/src/9/port/portclock.c - 664 sys sys 1055688512 3829
+1055689364 18 c sys/src/9/port/proc.c - 664 sys sys 1055688525 24316
+1055689364 19 c sys/src/9/port/qlock.c - 664 sys sys 1055688539 3311
+1055689364 20 c sys/src/9/port/swap.c - 664 sys sys 1055688551 6980
+1055689364 21 c sys/src/9/port/sysfile.c - 664 sys sys 1055688552 21766
+1055689364 22 c sys/src/9/port/sysproc.c - 664 sys sys 1055688564 15125
+1055689364 23 c sys/src/9/port/initcode.c - 664 sys sys 1055688491 574
+1055689364 24 c sys/src/9/port/realtimesub.c - 664 sys sys 1055688540 9185
+1055689364 25 a sys/src/cmd/ext2srv - 20000000775 sys sys 1055687763 0
+1055689364 26 a sys/src/cmd/ext2srv/chat.c - 664 sys sys 1055687746 827
+1055689364 27 a sys/src/cmd/ext2srv/dat.h - 664 sys sys 1055687746 5275
+1055689364 28 a sys/src/cmd/ext2srv/errstr.h - 664 sys sys 1055687747 565
+1055689364 29 a sys/src/cmd/ext2srv/ext2fs.c - 664 sys sys 1055687747 6063
+1055689364 30 a sys/src/cmd/ext2srv/ext2srv.man - 664 sys sys 1055687747 2409
+1055689364 31 a sys/src/cmd/ext2srv/ext2subs.c - 664 sys sys 1055687747 38701
+1055689364 32 a sys/src/cmd/ext2srv/fns.h - 664 sys sys 1055687748 1803
+1055689364 33 a sys/src/cmd/ext2srv/iobuf.c - 664 sys sys 1055687748 2854
+1055689364 34 a sys/src/cmd/ext2srv/mkfile - 664 sys sys 1055687748 194
+1055689364 35 a sys/src/cmd/ext2srv/readme - 664 sys sys 1055687748 1700
+1055689364 36 a sys/src/cmd/ext2srv/version - 664 sys sys 1055687763 870
+1055689364 37 a sys/src/cmd/ext2srv/xfile.c - 664 sys sys 1055687749 2543
+1055689364 38 a sys/src/cmd/ext2srv/xfssrv.c - 664 sys sys 1055687749 1292
+1055691165 0 c sys/src/9/pc/archmp.c - 664 sys sys 1055689883 2239
+1055691165 1 c sys/src/9/pc/devarch.c - 664 sys sys 1055689884 17647
+1055691165 2 c sys/src/9/pc/devfloppy.c - 664 sys sys 1055689885 20024
+1055691165 3 c sys/src/9/pc/ether8139.c - 664 sys sys 1055689886 18012
+1055691165 4 c sys/src/9/pc/ether82543gc.c - 664 sys sys 1055689887 32296
+1055691165 5 c sys/src/9/pc/ether82557.c - 664 sys sys 1055689889 29634
+1055691165 6 c sys/src/9/pc/i8253.c - 664 sys sys 1055689890 6219
+1055691165 7 c sys/src/9/pc/main.c - 664 sys sys 1055689890 14496
+1055691165 8 c sys/src/9/pc/sd53c8xx.c - 664 sys sys 1055689891 52089
+1055691165 9 c sys/src/9/pc/sdscsi.c - 664 sys sys 1055689892 7406
+1055691165 10 c sys/src/9/pc/vgas3.c - 664 sys sys 1055689893 12082
+1055691165 11 c sys/src/9/pc/wavelan.c - 664 sys sys 1055689894 27253
+1055692967 0 a sys/man/4/ext2srv - 664 sys sys 1055692986 2409
+1055692967 1 c sys/man/8/prep - 664 sys sys 1055692961 13573
+1055692967 2 c sys/src/cmd/disk/prep/prep.c - 664 sys sys 1055692957 10634
+1055694769 0 c sys/man/1/dd - 664 sys sys 1055693436 3346
+1055694769 1 c sys/src/cmd/dd.c - 664 sys sys 1055693435 11721
+1055700173 0 c sys/src/cmd/auth/passwd.c - 664 sys sys 1055699009 2761
+1055700173 1 c sys/src/cmd/auth/secstore/secchk.c - 664 sys sys 1055698993 560
+1055700173 2 c sys/src/cmd/eqn/eqn.c - 664 sys sys 1055698950 19576
+1055700173 3 c sys/src/cmd/exportfs/exportfs.c - 664 sys sys 1055698967 15466
+1055700173 4 c sys/src/cmd/hget.c - 664 sys sys 1055699046 22029
+1055700173 5 c sys/src/cmd/iostats/statsrv.c - 664 sys sys 1055699098 10756
+1055700173 6 c sys/src/cmd/ip/imap4d/msg.c - 664 sys sys 1055699143 31357
+1055700173 7 c sys/src/cmd/ip/ppp/ppp.c - 664 sys sys 1055699160 59236
+1055700173 8 c sys/src/cmd/ip/snoopy/ether.c - 664 sys sys 1055699192 1979
+1055700173 9 c sys/src/cmd/ip/snoopy/il.c - 664 sys sys 1055699197 2246
+1055700173 10 c sys/src/cmd/ip/snoopy/ip.c - 664 sys sys 1055699194 4291
+1055700173 11 c sys/src/cmd/ip/snoopy/tcp.c - 664 sys sys 1055699196 3593
+1055700173 12 c sys/src/cmd/ip/snoopy/udp.c - 664 sys sys 1055699195 1718
+1055700173 13 a sys/src/cmd/mk/acid - 664 sys sys 1055698806 10395
+1055700173 14 c sys/src/cmd/mk/file.c - 664 sys sys 1055698807 1310
+1055700173 15 c sys/src/cmd/mk/fns.h - 664 sys sys 1055698809 2199
+1055700173 16 c sys/src/cmd/mk/mk.h - 664 sys sys 1055698812 3735
+1055700173 17 c sys/src/cmd/mk/mkfile - 664 sys sys 1055698812 376
+1055700173 18 c sys/src/cmd/mk/plan9.c - 664 sys sys 1055698813 6818
+1055700173 19 a sys/src/cmd/mk/xyz - 775 sys sys 1055698814 134938
+1055700173 20 c sys/src/cmd/nntpfs.c - 664 sys sys 1055699250 18903
+1055700173 21 c sys/src/cmd/ql/asm.c - 664 sys sys 1055699283 12469
+1055700173 22 c sys/src/cmd/ql/asmout.c - 664 sys sys 1055699283 30140
+1055700173 23 c sys/src/cmd/ql/obj.c - 664 sys sys 1055699284 23016
+1055700173 24 c sys/src/cmd/ramfs.c - 664 sys sys 1055699293 15087
+1055700173 25 c sys/src/cmd/rc/code.c - 664 sys sys 1055698766 8158
+1055700173 26 c sys/src/cmd/rc/exec.c - 664 sys sys 1055698767 16060
+1055700173 27 c sys/src/cmd/rc/exec.h - 664 sys sys 1055698767 2779
+1055700173 28 a sys/src/cmd/rc/fmtquote.c - 664 sys sys 1055698768 3609
+1055700173 29 c sys/src/cmd/rc/fns.h - 664 sys sys 1055698768 1377
+1055700173 30 c sys/src/cmd/rc/getflags.c - 664 sys sys 1055698770 3954
+1055700173 31 c sys/src/cmd/rc/glob.c - 664 sys sys 1055698770 4540
+1055700173 32 a sys/src/cmd/rc/havefork.c - 664 sys sys 1055698771 3473
+1055700173 33 a sys/src/cmd/rc/haventfork.c - 664 sys sys 1055698771 3122
+1055700173 34 c sys/src/cmd/rc/here.c - 664 sys sys 1055698771 2497
+1055700173 35 c sys/src/cmd/rc/io.c - 664 sys sys 1055698773 3623
+1055700173 36 c sys/src/cmd/rc/lex.c - 664 sys sys 1055698774 6042
+1055700173 37 c sys/src/cmd/rc/mkfile - 664 sys sys 1055698774 812
+1055700173 38 c sys/src/cmd/rc/pcmd.c - 664 sys sys 1055698775 2628
+1055700173 39 c sys/src/cmd/rc/pfnc.c - 664 sys sys 1055698776 1303
+1055700173 40 c sys/src/cmd/rc/plan9.c - 664 sys sys 1055698776 9382
+1055700173 41 c sys/src/cmd/rc/simple.c - 664 sys sys 1055698777 8993
+1055700173 42 c sys/src/cmd/rc/subr.c - 664 sys sys 1055698779 1206
+1055700173 43 c sys/src/cmd/rc/trap.c - 664 sys sys 1055698780 871
+1055700173 44 c sys/src/cmd/rc/tree.c - 664 sys sys 1055698780 2071
+1055700173 45 c sys/src/cmd/rc/unix.c - 664 sys sys 1055698781 8726
+1055700173 46 c sys/src/cmd/rc/var.c - 664 sys sys 1055698781 1298
+1055700173 47 a sys/src/cmd/rc/win32.c - 664 sys sys 1055698781 8699
+1055700173 48 c sys/src/cmd/rtstats/edfproc.c - 664 sys sys 1055699325 3109
+1055700173 49 c sys/src/cmd/unix/u9fs/u9fs.c - 664 sys sys 1055699455 30811
+1055700173 50 c sys/src/cmd/upas/common/libsys.c - 664 sys sys 1055699577 14010
+1055700173 51 c sys/src/cmd/upas/common/sys.h - 664 sys sys 1055699577 2223
+1055700173 52 c sys/src/cmd/upas/fs/pop3.c - 664 sys sys 1055699607 11699
+1055700173 53 c sys/src/cmd/usb/usbd/usbd.c - 664 sys sys 1055699682 5493
+1055700173 54 c sys/src/cmd/vac/vacfs.c - 664 sys sys 1055699701 13458
+1055700173 55 c sys/src/cmd/vl/asm.c - 664 sys sys 1055699754 30723
+1055700173 56 c sys/src/cmd/vl/list.c - 664 sys sys 1055699765 4753
+1055700173 57 c sys/src/cmd/ed.c - 664 sys sys 1055698917 21942
+1055700173 58 c sys/src/cmd/ls.c - 664 sys sys 1055699219 5284
+1055700173 59 c sys/src/cmd/stats.c - 664 sys sys 1055699395 27161
+1055700173 60 c sys/src/fs/dev/juke.c - 664 sys sys 1055699807 22892
+1055700173 61 c sys/src/fs/pc/trap.c - 664 sys sys 1055699801 7946
+1055700173 62 c sys/src/fs/port/portdat.h - 664 sys sys 1055699797 16701
+1055700173 63 c sys/src/libc/port/pool.c - 664 sys sys 1055699981 27944
+1055700173 64 c sys/src/libc/power/tas.s - 664 sys sys 1055700129 337
+1055700173 65 c sys/src/libmp/port/letomp.c - 664 sys sys 1055700222 432
+1055700173 66 c sys/src/libmp/port/mpaux.c - 664 sys sys 1055700209 2650
+1055700173 67 c sys/src/libmp/port/mpcmp.c - 664 sys sys 1055700210 465
+1055700173 68 d sys/src/cmd/ip/8.ipconfig - 775 sys sys 1051207029 0
+1055700173 69 d sys/src/cmd/ip/ipconfig.8 - 664 sys sys 1051207027 0
+1055701974 0 c 386/lib/libstdio.a - 664 sys sys 1055700387 128500
+1055701974 1 c 386/lib/libthread.a - 664 sys sys 1055700446 71726
+1055701974 2 c lib/vgadb - 664 sys sys 1055701446 27652
+1055701974 3 c rc/bin/ps2gif - 775 sys sys 1055701384 107
+1055701974 4 c rc/bin/stock - 775 sys sys 1055701355 288
+1055701974 5 c sys/include/String.h - 664 sys sys 1055701304 1291
+1055701974 6 c sys/include/stdio.h - 664 sys sys 1055700381 4199
+1055701974 7 c sys/man/1/ar - 664 sys sys 1055701045 3149
+1055701974 8 c sys/man/2/string - 664 sys sys 1055701090 5306
+1055701974 9 c sys/man/3/fs - 664 sys sys 1055701106 2706
+1055701974 10 c sys/man/3/realtime - 664 sys sys 1055701120 13121
+1055701974 11 c sys/man/4/fossil - 664 sys sys 1055701130 9208
+1055701974 12 c sys/man/8/aliasmail - 664 sys sys 1055701148 1353
+1055701974 13 c sys/man/8/fs - 664 sys sys 1055701170 15029
+1055701974 14 c sys/man/8/ipconfig - 664 sys sys 1055701180 4766
+1055701974 15 c sys/man/8/ndb - 664 sys sys 1055701183 9379
+1055701974 16 c sys/man/8/ventiaux - 664 sys sys 1055701197 9975
+1055701974 17 c sys/src/9/alphapc/dat.h - 664 sys sys 1055701016 5095
+1055701974 18 c sys/src/9/alphapc/devether.c - 664 sys sys 1055701009 28
+1055701974 19 c sys/src/9/bitsy/l.s - 664 sys sys 1055700934 18211
+1055701974 20 c sys/src/9/bitsy/mem.h - 664 sys sys 1055700932 8049
+1055701974 21 c sys/src/9/bitsy/mmu.c - 664 sys sys 1055700931 11228
+1055701974 22 c sys/src/9/bitsy/sdata.c - 664 sys sys 1055700868 44660
+1055701974 23 c sys/src/9/bitsy/trap.c - 664 sys sys 1055700865 19128
+1055701974 24 c sys/src/9/boot/boot.c - 664 sys sys 1055700840 5316
+1055701974 25 c sys/src/9/ip/igmp.c - 664 sys sys 1055700768 5175
+1055701974 26 c sys/src/9/ip/il.c - 664 sys sys 1055700772 26893
+1055701974 27 c sys/src/9/ip/loopbackmedium.c - 664 sys sys 1055701769 1671
+1055701974 28 c sys/src/9/ip/rudp.c - 664 sys sys 1055700790 21415
+1055701974 29 c sys/src/9/ip/tcp.c - 664 sys sys 1055700797 65217
+1055701974 30 c sys/src/9/ip/udp.c - 664 sys sys 1055700791 13069
+1055701974 31 c sys/src/9/pc/floppy.h - 664 sys sys 1055700609 3835
+1055701974 32 c sys/src/9/pc/l.s - 664 sys sys 1055700610 20868
+1055701974 33 c sys/src/9/pc/main.c - 664 sys sys 1055700611 14507
+1055701974 34 c sys/src/9/pc/pc - 664 sys sys 1055700612 1360
+1055701974 35 c sys/src/9/pc/pcauth - 664 sys sys 1055700612 609
+1055701974 36 c sys/src/9/pc/pcdisk - 664 sys sys 1055700613 1432
+1055701974 37 c sys/src/9/pc/pcflop - 664 sys sys 1055700671 1410
+1055701974 38 c sys/src/9/pc/wavelan.h - 664 sys sys 1055700615 6151
+1055701974 39 c sys/src/9/port/devcons.c - 664 sys sys 1055700516 20933
+1055701974 40 c sys/src/9/port/edf.h - 664 sys sys 1055700516 4469
+1055701974 41 c sys/src/9/port/error.h - 664 sys sys 1055700517 2630
+1055701974 42 c sys/src/9/port/mkdevc - 775 sys sys 1055700518 3446
+1055701974 43 c sys/src/9/port/mkdevlist - 775 sys sys 1055700519 510
+1055701974 44 c sys/src/9/port/portdat.h - 664 sys sys 1055700521 21390
+1055701974 45 c sys/src/9/port/portfns.h - 664 sys sys 1055700522 10769
+1055701974 46 c sys/src/9/port/portmkfile - 664 sys sys 1055700523 2057
+1055701974 47 c sys/src/9/port/sd.h - 664 sys sys 1055700523 2686
+1055701974 48 c sys/src/9/port/mkbootrules - 775 sys sys 1055700518 923
+1055701974 49 c sys/src/cmd/ndb/cs.c - 664 sys sys 1055701923 32739
+1055701974 50 c sys/src/cmd/ndb/dblookup.c - 664 sys sys 1055701929 17465
+1055701974 51 c sys/src/cmd/ndb/dn.c - 664 sys sys 1055701925 25919
+1055701974 52 a sys/src/cmd/ndb/dnarea.c - 664 sys sys 1055701929 2126
+1055701974 53 a sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1055701929 3062
+1055701974 54 c sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1055701926 15331
+1055701974 55 c sys/src/cmd/ndb/dns.c - 664 sys sys 1055701923 15221
+1055701974 56 c sys/src/cmd/ndb/dns.h - 664 sys sys 1055701923 8875
+1055701974 57 c sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1055701923 8359
+1055701974 58 c sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1055701924 5277
+1055701974 59 c sys/src/cmd/ndb/mkfile - 664 sys sys 1055701930 1877
+1055701974 60 c sys/src/cmd/sh.C - 664 sys sys 1055701754 10303
+1055701974 61 a sys/src/libString/s_rdinstack.c - 664 sys sys 1055701320 2259
+1055701974 62 c sys/src/libmp/port/mpexp.c - 664 sys sys 1055700261 1269
+1055701974 63 c sys/src/libmp/port/mpleft.c - 664 sys sys 1055700262 906
+1055701974 64 c sys/src/libmp/port/mpright.c - 664 sys sys 1055700262 872
+1055701974 65 c sys/src/libmp/port/mptoi.c - 664 sys sys 1055700264 580
+1055701974 66 c sys/src/libmp/port/mpveccmp.c - 664 sys sys 1055700265 378
+1055701974 67 c sys/src/libmp/port/strtomp.c - 664 sys sys 1055700266 3003
+1055701974 68 c sys/src/libndb/dnsquery.c - 664 sys sys 1055700336 2759
+1055701974 69 c sys/src/libstdio/fseek.c - 664 sys sys 1055700343 408
+1055701974 70 a sys/src/libstdio/fseeko.c - 664 sys sys 1055700377 415
+1055701974 71 a sys/src/libstdio/ftello.c - 664 sys sys 1055700384 318
+1055701974 72 c sys/src/libstdio/mkfile - 664 sys sys 1055700381 945
+1055701974 73 c sys/src/libthread/exit.c - 664 sys sys 1055700450 1318
+1055701974 74 c sys/src/libthread/note.c - 664 sys sys 1055700452 2265
+1055701974 75 c sys/src/libthread/threadimpl.h - 664 sys sys 1055700447 4689
+1055701974 76 d sys/man/8/x509 - 664 sys sys 1037581047 0
+1055701974 77 d sys/src/9/alphapc/errstr.h - 664 sys sys 1015012784 0
+1055701974 78 d sys/src/9/bitsy/errstr.h - 664 sys sys 1053021020 0
+1055701974 79 d sys/src/9/mtx/errstr.h - 664 sys sys 1018721285 0
+1055701974 80 d sys/src/9/pc/errstr.h - 664 sys sys 1022588155 0
+1055703779 0 c sys/src/cmd/upas/alias/aliasmail.c - 664 sys sys 1055702824 5442
+1055703779 1 c sys/src/cmd/upas/filterkit/deliver.c - 664 sys sys 1055702834 1978
+1055703779 2 c sys/src/cmd/upas/marshal/marshal.c - 664 sys sys 1055702829 32370
+1055703779 3 c sys/src/cmd/upas/ned/nedmail.c - 664 sys sys 1055703158 42722
+1055703779 4 c sys/src/cmd/upas/smtp/mxdial.c - 664 sys sys 1055703150 4887
+1055703779 5 c sys/src/cmd/upas/smtp/spam.c - 664 sys sys 1055702858 9221
+1055703779 6 c sys/src/cmd/fossil/9.h - 664 sys sys 1055703747 4129
+1055703779 7 c sys/src/cmd/fossil/9fsys.c - 664 sys sys 1055703733 29755
+1055703779 8 c sys/src/cmd/fossil/9p.c - 664 sys sys 1055703732 21416
+1055703779 9 c sys/src/cmd/fossil/9srv.c - 664 sys sys 1055703734 3589
+1055703779 10 c sys/src/cmd/fossil/9user.c - 664 sys sys 1055703735 17240
+1055703779 11 c sys/src/cmd/fossil/Ccons.c - 664 sys sys 1055703737 6620
+1055703779 12 c sys/src/cmd/fossil/cache.c - 664 sys sys 1055703739 42854
+1055703779 13 a sys/src/cmd/fossil/conf.rc - 775 sys sys 1055703747 1407
+1055703779 14 c sys/src/cmd/fossil/disk.c - 664 sys sys 1055703739 5809
+1055703779 15 c sys/src/cmd/fossil/file.c - 664 sys sys 1055703740 27846
+1055703779 16 c sys/src/cmd/fossil/fns.h - 664 sys sys 1055703743 3039
+1055703779 17 c sys/src/cmd/fossil/fossil.c - 664 sys sys 1055703731 2113
+1055703779 18 c sys/src/cmd/fossil/fs.c - 664 sys sys 1055703741 21075
+1055703779 19 c sys/src/cmd/fossil/fs.h - 664 sys sys 1055703744 1398
+1055703779 20 c sys/src/cmd/fossil/history - 664 sys sys 1055703793 1400
+1055703779 21 c sys/src/cmd/fossil/mkfile - 664 sys sys 1055703730 1842
+1055703779 22 c sys/src/cmd/fossil/source.c - 664 sys sys 1055703742 18778
+1055705583 0 c sys/man/1/nedmail - 664 sys sys 1055704205 11322
+1055705583 1 c sys/man/8/fossilcons - 664 sys sys 1055703814 14677
+1055705583 2 c sys/src/9/boot/boot.h - 664 sys sys 1055703887 1773
+1055705583 3 c sys/src/9/boot/bootip.c - 664 sys sys 1055703889 3414
+1055705583 4 c sys/src/libauthsrv/readnvram.c - 664 sys sys 1055705106 8446
+1055707382 0 c sys/man/6/venti.conf - 664 sys sys 1055707400 1898
+1055707382 1 c sys/man/8/ndb - 664 sys sys 1055706144 9838
+1055707382 2 c sys/man/8/venti - 664 sys sys 1055707404 5274
+1055707382 3 c sys/man/8/ventiaux - 664 sys sys 1055707404 10528
+1055707382 4 c sys/src/cmd/venti/buildindex.c - 664 sys sys 1055707428 3174
+1055707382 5 c sys/src/cmd/venti/checkindex.c - 664 sys sys 1055707429 4115
+1055707382 6 c sys/src/cmd/venti/clumpstats.c - 664 sys sys 1055707430 2239
+1055707382 7 c sys/src/cmd/venti/config.c - 664 sys sys 1055707438 4957
+1055707382 8 c sys/src/cmd/venti/copy.c - 664 sys sys 1055707434 3517
+1055707382 9 c sys/src/cmd/venti/dat.h - 664 sys sys 1055707422 15323
+1055707382 10 c sys/src/cmd/venti/findscore.c - 664 sys sys 1055707431 2597
+1055707382 11 c sys/src/cmd/venti/fmtarenas.c - 664 sys sys 1055707424 2177
+1055707382 12 c sys/src/cmd/venti/fmtindex.c - 664 sys sys 1055707425 2534
+1055707382 13 c sys/src/cmd/venti/fns.h - 664 sys sys 1055707422 6793
+1055707382 14 c sys/src/cmd/venti/icache.c - 664 sys sys 1055707439 3942
+1055707382 15 c sys/src/cmd/venti/ifile.c - 664 sys sys 1055707440 2288
+1055707382 16 c sys/src/cmd/venti/lump.c - 664 sys sys 1055707441 3844
+1055707382 17 c sys/src/cmd/venti/lumpqueue.c - 664 sys sys 1055707442 2263
+1055707382 18 c sys/src/cmd/venti/mkfile - 664 sys sys 1055707420 1782
+1055707382 19 c sys/src/cmd/venti/rdarena.c - 664 sys sys 1055707432 1621
+1055707382 20 c sys/src/cmd/venti/read.c - 664 sys sys 1055707434 1723
+1055707382 21 c sys/src/cmd/venti/syncindex.c - 664 sys sys 1055707433 983
+1055707382 22 c sys/src/cmd/venti/venti.c - 664 sys sys 1055707423 4509
+1055709063 0 c sys/man/6/venti.conf - 664 sys sys 1055707590 1917
+1055709063 1 c sys/man/8/fossilcons - 664 sys sys 1055707854 14700
+1055709063 2 a sys/src/cmd/venti/conf.rc - 775 sys sys 1055707446 1416
+1055709063 3 c sys/src/cmd/venti/syncarena.c - 664 sys sys 1055707444 4116
+1055709063 4 c sys/src/cmd/venti/utils.c - 664 sys sys 1055707445 4602
+1055719875 0 c sys/src/libauthsrv/readnvram.c - 664 sys sys 1055718668 8534

+ 1 - 0
lib/vgadb

@@ -128,6 +128,7 @@ ctlr
 	0xC0044="S3 86C765 Video BIOS"
 	0xC0044="S3 86C765 Video BIOS"
 	0xC0044="Stealth64 Video 2001"
 	0xC0044="Stealth64 Video 2001"
 	0xC993F="S3 86C765 Video BIOS. Version 1.03-08"
 	0xC993F="S3 86C765 Video BIOS. Version 1.03-08"
+	0xC0044="Phoenix S3 TRIO32 Enhanced VGA BIOS. Version 1.3-08"
 	link=vga
 	link=vga
 	hwgc=s3hwgc
 	hwgc=s3hwgc
 	ctlr=trio64 linear=1
 	ctlr=trio64 linear=1

+ 1 - 1
rc/bin/ps2gif

@@ -1,2 +1,2 @@
 #!/bin/rc
 #!/bin/rc
-cat $1|/bin/gs -dNOPAUSE -dQUIET '-sOUTPUTFILE='/fd/1 '-sDEVICE=inferno' - quit.ps| togif
+cat $1|/bin/gs -dNOPAUSE -dQUIET '-sOUTPUTFILE='/fd/1 '-sDEVICE=inferno' - quit.ps| crop | togif

+ 1 - 1
rc/bin/stock

@@ -8,7 +8,7 @@ hget 'http://quote.yahoo.com/d/quotes.csv?s='^$stock^'&f=snl1d1c1v&e=.exe' |
 	sed 's/ +"/"/;s/
//' |
 	sed 's/ +"/"/;s/
//' |
 	switch(`{date}){
 	switch(`{date}){
 	case *'Apr 1 '*
 	case *'Apr 1 '*
-		sed 's/("LU","LUCENT TECH"),([^,]*),(.*)$/\1,65.35,\3/'
+		sed 's/("LU","LUCENT TECH"),([^,]*),(.*)$/\1,2.35,\3/'
 	case *
 	case *
 		cat
 		cat
 	}
 	}

+ 4 - 0
sys/include/String.h

@@ -37,4 +37,8 @@ extern String*	s_grow(String*, int);
 extern int	s_read(Biobuf*, String*, int);
 extern int	s_read(Biobuf*, String*, int);
 extern char	*s_read_line(Biobuf*, String*);
 extern char	*s_read_line(Biobuf*, String*);
 extern char	*s_getline(Biobuf*, String*);
 extern char	*s_getline(Biobuf*, String*);
+typedef struct Sinstack Sinstack;
+extern char	*s_rdinstack(Sinstack*, String*);
+extern Sinstack	*s_allocinstack(char*);
+extern void	s_freeinstack(Sinstack*);
 #endif BGETC
 #endif BGETC

+ 4 - 2
sys/include/stdio.h

@@ -101,9 +101,11 @@ int ungetc(int, FILE *);
 long fread(void *, long, long, FILE *);
 long fread(void *, long, long, FILE *);
 long fwrite(const void *, long, long, FILE *);
 long fwrite(const void *, long, long, FILE *);
 int fgetpos(FILE *, fpos_t *);
 int fgetpos(FILE *, fpos_t *);
-int fseek(FILE *, long int, int);
+int fseek(FILE *, long, int);
+int fseeko(FILE *, long long, int);
 int fsetpos(FILE *, const fpos_t *);
 int fsetpos(FILE *, const fpos_t *);
-long int ftell(FILE *);
+long ftell(FILE *);
+long long ftello(FILE *);
 void rewind(FILE *);
 void rewind(FILE *);
 void clearerr(FILE *);
 void clearerr(FILE *);
 int feof(FILE *);
 int feof(FILE *);

+ 10 - 10
sys/man/1/ar

@@ -120,16 +120,16 @@ showing
 .B
 .B
 	mode uid/gid size date name
 	mode uid/gid size date name
 .TP
 .TP
-.B c
-Create.
-Normally
-.I ar
-will create a new archive when
-.I afile
-does not exist, and give a warning.
-Option 
-.B c
-discards any old contents and suppresses the warning.
+.\" .B c
+.\" Create.
+.\" Normally
+.\" .I ar
+.\" will create a new archive when
+.\" .I afile
+.\" does not exist, and give a warning.
+.\" Option 
+.\" .B c
+.\" discards any old contents and suppresses the warning.
 .TP
 .TP
 .B l
 .B l
 Local.
 Local.

+ 9 - 0
sys/man/1/dd

@@ -82,6 +82,15 @@ truncates the output file when it opens it;
 .B -trunc
 .B -trunc
 .B 0
 .B 0
 opens it without truncation.
 opens it without truncation.
+.TP
+.BI -quiet\  n\^
+By default,
+.I dd
+prints the number of blocks read and written
+once it is finished.
+.B -quiet
+.B 1
+silences this summary.
 .HP
 .HP
 \fL-conv\ ascii\ \ \ \ \fRConvert
 \fL-conv\ ascii\ \ \ \ \fRConvert
 .SM EBCDIC
 .SM EBCDIC

+ 19 - 1
sys/man/1/nedmail

@@ -243,6 +243,14 @@ Append the message to the specified mailbox.
 If
 If
 .I mfile
 .I mfile
 doesn't start with a `/', it is interpreted relative to the directory in which the mailbox resides.
 doesn't start with a `/', it is interpreted relative to the directory in which the mailbox resides.
+If
+.I mfile
+is a directory then the destination is a file in that directry.
+If the MIME header specifies a file name, that one is used.
+Otherwise, one is generated using
+.IR mktemp (2)
+and the string
+.BR att.XXXXXXXXXXX .
 .TP
 .TP
 .B q
 .B q
 Put undeleted mail back in the mailbox and stop.
 Put undeleted mail back in the mailbox and stop.
@@ -263,10 +271,20 @@ Remove mark for deletion.
 .B x
 .B x
 Exit, without changing the mailbox file.
 Exit, without changing the mailbox file.
 .TP
 .TP
+.B y
+Synchronize with the mail box.  Any deleted
+messages are purged and any new messages read.
+This is equivalent to quiting nedmail and restarting.
+.TP
 .BI | command
 .BI | command
 Run the
 Run the
 .I command
 .I command
-with the message as standard input.
+with the message body as standard input.
+.TP
+.BI || command
+Run the
+.I command
+with the whole message as standard input.
 .TP
 .TP
 .BI ! command
 .BI ! command
 Escape to the shell to do
 Escape to the shell to do

+ 6 - 0
sys/man/2/authsrv

@@ -131,6 +131,12 @@ On x86s and Alphas
 successively opens the following areas stopping with the
 successively opens the following areas stopping with the
 first to succeed:
 first to succeed:
 .PP
 .PP
+\- the partition named by the
+.B $nvram
+environment variable
+(commonly set via
+.IR plan9.ini (8))
+.br
 \- the partition
 \- the partition
 .B #S/sdC0/nvram
 .B #S/sdC0/nvram
 .br
 .br

+ 5 - 0
sys/man/2/string

@@ -225,6 +225,11 @@ The string is null terminated.
 reads up to the next newline and returns
 reads up to the next newline and returns
 a pointer to the beginning of the bytes read.  Leading
 a pointer to the beginning of the bytes read.  Leading
 spaces and tabs and the trailing newline are all discarded.
 spaces and tabs and the trailing newline are all discarded.
+.I S_getline
+will recursively read through files included with
+.B #include
+and discard all other lines beginning with
+.BR # .
 .SH SOURCE
 .SH SOURCE
 .B /sys/src/libString
 .B /sys/src/libString
 .SH SEE ALSO
 .SH SEE ALSO

+ 1 - 1
sys/man/3/fs

@@ -1,6 +1,6 @@
 .TH FS 3 
 .TH FS 3 
 .SH NAME
 .SH NAME
-fs \- file system devices.
+fs \- file system devices
 .SH SYNOPSIS
 .SH SYNOPSIS
 .nf
 .nf
 .B bind -b #k /dev
 .B bind -b #k /dev

+ 11 - 8
sys/man/3/realtime

@@ -70,7 +70,7 @@ a machine- and architecture-dependent unit called
 .IR tick ).
 .IR tick ).
 Every $T$ nanoseconds, the task is
 Every $T$ nanoseconds, the task is
 .I released
 .I released
-— i.e., it becomes schedulable — and it received a
+— i.e., it becomes schedulable — and it receives a
 .I slice
 .I slice
 of $C$ nsec.
 of $C$ nsec.
 When the task is released, its
 When the task is released, its
@@ -109,8 +109,8 @@ deadline.  When a task is released it can, therefore, preempt a task
 that has a later deadline, but was released earlier.
 that has a later deadline, but was released earlier.
 .PP
 .PP
 Real-time tasks sharing resources, however, may need to be prevented
 Real-time tasks sharing resources, however, may need to be prevented
-from preempting each other.  They can do this by declaring a shared
-resource.  The scheduler will not preempt one task with another that
+from preempting each other.  They must do this by declaring their shared
+resources.  The scheduler will not preempt one task with another that
 shares a common resource.  To do this, the scheduler needs to know the
 shares a common resource.  To do this, the scheduler needs to know the
 names of the sharable resources used by each of the tasks, the amount
 names of the sharable resources used by each of the tasks, the amount
 of time the resources are used, and the way in which resource usage is
 of time the resources are used, and the way in which resource usage is
@@ -124,13 +124,16 @@ it is not legal to acquire $A$, acquire $B$, release $A$ and release $B$
 in that order.
 in that order.
 .PP
 .PP
 During the admission test, information about resource sharing is used
 During the admission test, information about resource sharing is used
-to calculate secondary deadlines for each task, called
+to calculate
 .IR "inherited deadlines" ,
 .IR "inherited deadlines" ,
-$Δ$, which is the minimum of the deadlines $D$ of each of the tasks
-that shares a resource currently held by the current task.
+for each task.  A resource's
+.IR "inherited deadline" ,
+$Δ$, is the minimum of the deadlines $D$ of each of the tasks
+that shares that resource.  A task's $Δ$ is the minimum of the
+resource $Δ$s of all resources held by the task.
 .PP
 .PP
-Acquiring a resource will lower the $Δ$ of the task (or keep it the
-same); releasing one will increase the $Δ$ (or keep it the same).
+Acquiring a resource may lower the $Δ$ of the task; releasing one
+may increase it.
 .PP
 .PP
 The scheduler allows a released task $T$ to preempt running task $T'$
 The scheduler allows a released task $T$ to preempt running task $T'$
 iff $d < d' ^ D < Δ'$; the first half of the condition says that the
 iff $d < d' ^ D < Δ'$; the first half of the condition says that the

+ 110 - 0
sys/man/4/ext2srv

@@ -0,0 +1,110 @@
+.TH EXT2SRV 4
+.SH NAME
+ext2srv \- ext2 file system
+.SH SYNOPSIS
+.B ext2srv
+[
+.B -vrs
+] [
+.B -f
+.I file
+] [
+.B -p
+.I passwd
+] [
+.B -g
+.I group
+] [
+.I service
+]
+.SH DESCRIPTION
+.I Ext2srv
+is a file server that interprets the Linux Second Extended File System.
+A single instance of
+.I ext2srv
+can provide access to multiple ext2 partitions simultaneously.
+.PP
+.I Ext2srv
+posts a file descriptor named
+.I service
+(default
+.BR ext2 )
+in the
+.B /srv
+directory.
+To access an ext2 file system on a device, use
+.B mount
+with the
+.I spec
+argument
+(see
+.IR bind (1))
+the name of the file holding the raw ext2 file system, typically the disk or partition.
+If
+.I spec
+is undefined in the
+.BR mount ,
+.I ext2srv
+will use
+.I file
+as the default name for the device holding the file system.
+.PP
+Normally
+.I ext2srv
+creates a pipe to act as the communications channel between
+itself and its clients.
+The
+.B -s
+flag instructs
+.I ext2srv
+to use its standard input and output instead.
+This flag also prevents the creation of an explicit service file in
+.BR /srv .
+.PP
+The
+.B -v
+flag causes verbose output for debugging, while
+the
+.B -r
+flag (recommended) makes the file system read-only.
+The optional
+.B -p
+and
+.B -g
+flags specify Unix-format password (respectively group) files
+that give the mapping between the numeric user- and group-ID
+numbers in the ext2 file system and the strings reported by Plan 9 status
+inquiries.
+.PP
+There is no authentication or permission checking.
+Anyone who can access the ext2 file system will have full access
+to all its files, including write access if
+.I ext2srv
+is not started with the
+.B -r
+flag, irrespective of file ownership and permission flags.
+.PP
+Some file system state is cached in memory, and may
+be flushed only when the file system is unmounted.
+Therefore if
+.I ext2srv
+is stopped or the machine is rebooted while an ext2 file system
+is still mounted,
+the superblock on the device will have been marked `not valid'
+(unless the
+.B -r
+flag was used),
+and a
+.I fsck
+will be required before that file system may be mounted again.
+.SH BUGS
+There is no authentication or permission checking.
+The implementation has not tracked any changes to the ext2
+specification since it was written.
+There may be other bugs.
+It is advisable to use
+.I ext2srv
+in read-only mode whenever possible.
+.SH AUTHOR
+Bodet Laurent (bl@mime.univ-paris8.fr),
+with later updates by Russ Cox and Richard Miller.

+ 47 - 4
sys/man/4/fossil

@@ -10,6 +10,10 @@ fossil \- archival file server
 .B -c
 .B -c
 .I cmd
 .I cmd
 ]...
 ]...
+[
+.B -f
+.I file
+]
 .PP
 .PP
 .B fossil/flchk
 .B fossil/flchk
 [
 [
@@ -46,6 +50,15 @@ fossil \- archival file server
 .I score
 .I score
 ]
 ]
 .I file
 .I file
+.PP
+.B fossil/conf
+[
+.B -w
+]
+.I file
+[
+.I config
+]
 .SH DESCRIPTION
 .SH DESCRIPTION
 Fossil
 Fossil
 will become the main file system for Plan 9.
 will become the main file system for Plan 9.
@@ -152,6 +165,8 @@ Authentication can be disabled using the
 .B -A
 .B -A
 flag to
 flag to
 .B open
 .B open
+or
+.B srv
 (see
 (see
 .IR fossilcons (8)).
 .IR fossilcons (8)).
 .PP
 .PP
@@ -213,6 +228,13 @@ which starts a file server console on
 See
 See
 .IR fossilcons (8)
 .IR fossilcons (8)
 for more information.
 for more information.
+.TP
+.BI -f " file
+Read and execute console commands stored in the Fossil disk 
+.IR file .
+.I Conf
+.RI ( q.v. )
+reads and writes the command set stored in the disk.
 .PD
 .PD
 .PP
 .PP
 .I Flchk
 .I Flchk
@@ -321,6 +343,27 @@ rather than by
 .IR vac (1),
 .IR vac (1),
 so that the appropriate snapshot metadata is present.
 so that the appropriate snapshot metadata is present.
 .PD
 .PD
+.PP
+.I Conf
+reads or writes the configuration branded on the Fossil disk
+.IR file .
+By default, it reads the configuration from the disk and prints it to
+standard output.
+If the
+.B -w
+flag is given,
+.I conf
+reads a new configuration from 
+.I config
+(or else from standard input)
+and writes it to the disk.
+The Plan 9 kernel boot process runs
+.RB `` fossil
+.B -f
+.IR disk ''
+to start a Fossil file server.
+The disk is just a convenient place to store configuration
+information.
 .SH EXAMPLES
 .SH EXAMPLES
 .PP
 .PP
 Place the root of the archive file system on
 Place the root of the archive file system on
@@ -345,7 +388,7 @@ checking turned off, create a users file, and mount the server:
 .IP
 .IP
 .EX
 .EX
 fossil/flfmt /dev/sdC0/fossil
 fossil/flfmt /dev/sdC0/fossil
-cat >flproto <<EOF
+fossil/conf -w /dev/sdC0/fossil <<EOF
 fsys main config /dev/sdC0/fossil
 fsys main config /dev/sdC0/fossil
 fsys main open -AWP
 fsys main open -AWP
 fsys main
 fsys main
@@ -355,7 +398,7 @@ users -w /active/adm/users
 srv -p fscons
 srv -p fscons
 srv fossil
 srv fossil
 EOF
 EOF
-fossil/fossil -c '. flproto'
+fossil/fossil -f /dev/sdC0/fossil
 mount /srv/fossil /n/fossil
 mount /srv/fossil /n/fossil
 .EE
 .EE
 .LP
 .LP
@@ -415,5 +458,5 @@ Changing to the new format will require reformatting
 the disk as in the example above,
 the disk as in the example above,
 but note that this will preserve most of the file system
 but note that this will preserve most of the file system
 (all but
 (all but
-.B /snapshot
-) with little effort.
+.BR /snapshot )
+with little effort.

+ 27 - 5
sys/man/6/venti.conf

@@ -9,9 +9,11 @@ a disk partition, in which they reside.  The configuration
 file is the only location that file names are used.  Internally,
 file is the only location that file names are used.  Internally,
 venti uses the names assigned when the components were formatted
 venti uses the names assigned when the components were formatted
 with 
 with 
-.IR fmtarenas (8)
+.I fmtarenas
 or 
 or 
-.IR fmtisect (8).
+.I fmtisect
+(see
+.IR ventiaux (8)).
 In particular, by changing the configuration a
 In particular, by changing the configuration a
 component can be copied to a different file.
 component can be copied to a different file.
 .PP
 .PP
@@ -26,17 +28,37 @@ Names the index for the system.
 .BI arenas " file
 .BI arenas " file
 .I File
 .I File
 contains a collection of arenas, formatted using
 contains a collection of arenas, formatted using
-.IR fmtarenas (8).
+.IR fmtarenas .
 .TP
 .TP
 .BI isect " file
 .BI isect " file
 .I File
 .I File
 contains an index section, formatted using
 contains an index section, formatted using
-.IR fmtisect (8).
+.IR fmtisect .
 .PP
 .PP
 After formatting a venti system using
 After formatting a venti system using
-.IR fmtindex (8),
+.IR fmtindex ,
 the order of arenas and index sections should not be changed.
 the order of arenas and index sections should not be changed.
 Additional arenas can be appended to the configuration.
 Additional arenas can be appended to the configuration.
+.PP
+The configuration file optionally holds configuration parameters
+for the venti server itself.
+These are:
+.TP
+.BI mem " cachesize
+.TP
+.BI bcmem " blockcachesize
+.TP
+.BI icmem " indexcachesize
+.TP
+.BI addr " ventiaddress
+.TP
+.BI httpaddr " httpaddress
+.TP
+.B queuewrites
+.PD
+See 
+.IR venti (8)
+for descriptions of these variables.
 .SH EXAMPLE
 .SH EXAMPLE
 .EX
 .EX
 # a sample venti configuration file
 # a sample venti configuration file

+ 7 - 2
sys/man/8/aliasmail

@@ -13,9 +13,14 @@ is normally invoked by a rule in in the
 upas rewrite file,
 upas rewrite file,
 .IR rewrite (6).
 .IR rewrite (6).
 .PP
 .PP
-Each line of an alias file begins with
+If a line of an alias file begins with
+.BR #include ,
+the line is replaced by the contents of the file whose name follows.
+Other lines, beginning with
 .B #
 .B #
-(comment) or with a name.
+are ignored as comment.
+.PP
+Otherwise, lines begin with a name.
 The rest of a name line gives the expansion.
 The rest of a name line gives the expansion.
 The expansion may contain multiple addresses and may be continued
 The expansion may contain multiple addresses and may be continued
 to another line by appending a backslash.
 to another line by appending a backslash.

+ 37 - 4
sys/man/8/fossilcons

@@ -179,7 +179,7 @@ con /srv/fscons
 ]
 ]
 .B epoch
 .B epoch
 [
 [
-.B -y
+.B -ry
 ]
 ]
 .I n
 .I n
 .PP
 .PP
@@ -233,6 +233,10 @@ con /srv/fscons
 .B -s
 .B -s
 .I interval
 .I interval
 ]
 ]
+[
+.B -t
+.I timeout
+]
 .PP
 .PP
 [
 [
 .B fsys
 .B fsys
@@ -479,9 +483,12 @@ adm:adm:adm:sys
 none:none::
 none:none::
 noworld:noworld::
 noworld:noworld::
 sys:sys::
 sys:sys::
+glenda:glenda:glenda:
 .PP
 .PP
-These users are mandatory and must appear in all user files.
-It is not possible to rename these unames.
+Except
+.BR glenda ,
+these users are mandatory: they must appear in all user
+files and cannot be renamed.
 .EE
 .EE
 .PP
 .PP
 The
 The
@@ -746,6 +753,20 @@ the archiver should take care
 of those snapshots (moving the blocks from disk to Venti)
 of those snapshots (moving the blocks from disk to Venti)
 if you give it more time.
 if you give it more time.
 .PP
 .PP
+The
+.B -r
+flag to epoch causes it to remove any now-inaccessible
+snapshot directories once it has changed the epoch.
+This flag only makes sense in conjunction with the
+.B -y
+flag.
+.PP
+.I Epoch
+is a very low-level way to retire snapshots.
+The preferred way is by setting an automatic timer
+with
+.IR snaptime .
+.PP
 .I Halt
 .I Halt
 suspends file system activity;
 suspends file system activity;
 .I unhalt
 .I unhalt
@@ -785,6 +806,9 @@ An archival snapshot is taken once a day, at
 while temporary snapshots are taken at multiples of
 while temporary snapshots are taken at multiples of
 .I interval
 .I interval
 minutes.
 minutes.
+Temporary snapshots are discarded once they are
+.I timeout
+minutes old.
 With no arguments,
 With no arguments,
 .I snaptime
 .I snaptime
 prints the current snapshot times.
 prints the current snapshot times.
@@ -800,7 +824,16 @@ or
 of
 of
 .L none
 .L none
 can be used to disable that kind of automatic snapshot.
 can be used to disable that kind of automatic snapshot.
-By default, both are disabled.
+The
+.B -t
+option sets the snapshot timeout.
+If
+.I timeout
+is
+.LR none ,
+temporary snapshots are not automatically discarded.
+By default, all three times are set to
+.LR none .
 .PP
 .PP
 .I Stat
 .I Stat
 displays metadata for each of the named
 displays metadata for each of the named

+ 14 - 3
sys/man/8/fs

@@ -266,6 +266,17 @@ to be advanced to the current WORM on the next dump.
 This is a discredited idea to try to keep operating
 This is a discredited idea to try to keep operating
 on the knee of the cache working set.
 on the knee of the cache working set.
 Buy more cache disk.
 Buy more cache disk.
+.TP
+.B trim
+reduces the file system's
+.I fsize
+to fit the device containing the file system.
+This is useful after copying a partially-full file system
+into a slightly smaller device.
+Running
+.B "check free"
+afterward will construct a new free list that contains no
+blocks outside the new, smaller file system.
 .PP
 .PP
 .I Clean
 .I Clean
 prints the block numbers in
 prints the block numbers in
@@ -359,13 +370,13 @@ The optional
 .I platter
 .I platter
 limits affected blocks to those on that platter.
 limits affected blocks to those on that platter.
 .TP
 .TP
-.BR prchain " [\fIstart\fP] [\fLback\fP]
+.BR prchain " [\fIstart\fP] [\fIback-flag\fP]
 Print the chain of superblocks for the directory containing the
 Print the chain of superblocks for the directory containing the
 roots of the dumped file systems, starting at block number
 roots of the dumped file systems, starting at block number
 .I start
 .I start
 (default 0) going forward (backwards if
 (default 0) going forward (backwards if
-.B back
-is supplied).
+.I back-flag
+is supplied and is non-zero).
 .TP
 .TP
 .BR searchtag " [\fIstart\fP] [\fItag\fP] [\fIblocks\fP]
 .BR searchtag " [\fIstart\fP] [\fItag\fP] [\fIblocks\fP]
 Reads the WORM device starting at block
 Reads the WORM device starting at block

+ 50 - 35
sys/man/8/ipconfig

@@ -3,9 +3,11 @@
 ipconfig, rip \- Internet configuration and routing
 ipconfig, rip \- Internet configuration and routing
 .SH SYNOPSIS
 .SH SYNOPSIS
 .B ip/ipconfig
 .B ip/ipconfig
-.RB [ -ndDrG ]
+.RB [ -DGPdnr ]
 .RB [ -b
 .RB [ -b
 .IR baud ]
 .IR baud ]
+.RB [ -c
+.IR ctl ]
 .RB [ -m
 .RB [ -m
 .IR mtu ]
 .IR mtu ]
 .RB [ -g
 .RB [ -g
@@ -39,6 +41,7 @@ in the command line or obtained via DHCP.  If DHCP is
 requested, it will also obtain the addresses of DNS
 requested, it will also obtain the addresses of DNS
 servers, NTP servers, gateways, a Plan 9 file server,
 servers, NTP servers, gateways, a Plan 9 file server,
 and a Plan 9 authentication server.  If this is the first
 and a Plan 9 authentication server.  If this is the first
+non-loopback
 interface on the IP stack, the information will be
 interface on the IP stack, the information will be
 written to
 written to
 .B /net/ndb
 .B /net/ndb
@@ -79,40 +82,6 @@ IP stack.
 .PP
 .PP
 The options are:
 The options are:
 .TP
 .TP
-.B x
-use the IP stack mounted at
-.I netmtpt
-instead of at
-.BR /net .
-.TP
-.B g
-the default gateway.
-.TP
-.B d
-use DHCP to determine any unspecified configuration parameters.
-.TP
-.B r
-by default, 
-.I ipconfig
-exits after trying DHCP for 15 seconds with no answer.
-This option directs
-.I ipconfig
-instead to fork a background
-process that keeps trying forever.
-.TP
-.B h
-the hostname to add to DHCP requests.  Some DHCP
-servers, such as the one used by COMCAST, will not respond
-unless a correct hostname is in the request.
-.TP
-.B n
-determine parameters but don't configure the interface.
-.TP
-.B b
-the baud rate to use on a serial line
-when configuring
-.BR PPP .
-.TP
 .B D
 .B D
 turn on debugging.
 turn on debugging.
 .TP
 .TP
@@ -126,9 +95,55 @@ interpret as the Plan 9 file server and auth server.
 Replies to these options contain a list of IP addresses for possible
 Replies to these options contain a list of IP addresses for possible
 file servers and auth servers.
 file servers and auth servers.
 .TP
 .TP
+.B P
+write configuration information to
+.BR /net/ndb ,
+even if other network interfaces are already configured
+.TP
+.B b
+the baud rate to use on a serial line
+when configuring
+.BR PPP .
+.TP
+.B c
+write the control string
+.I ctl
+to the ethernet device control file before starting to configure it.
+May be repeated to specify multiple control writes.
+.TP
+.B d
+use DHCP to determine any unspecified configuration parameters.
+.TP
+.B g
+the default gateway.
+.TP
+.B h
+the hostname to add to DHCP requests.  Some DHCP
+servers, such as the one used by COMCAST, will not respond
+unless a correct hostname is in the request.
+.TP
 .B m
 .B m
 the maximum IP packet size to use on this
 the maximum IP packet size to use on this
 interface.
 interface.
+.TP
+.B n
+determine parameters but don't configure the interface.
+.TP
+.B r
+by default, 
+.I ipconfig
+exits after trying DHCP for 15 seconds with no answer.
+This option directs
+.I ipconfig
+instead to fork a background
+process that keeps trying forever.
+.TP
+.B x
+use the IP stack mounted at
+.I netmtpt
+instead of at
+.BR /net .
+.PD
 .PP
 .PP
 If DHCP is requested, a process is forked
 If DHCP is requested, a process is forked
 off to renew the lease before it
 off to renew the lease before it

+ 23 - 2
sys/man/8/ndb

@@ -43,13 +43,16 @@ query, mkhash, mkdb, cs, csquery, dns, dnsquery, ipquery, dnsdebug, mkhosts \- n
 .br
 .br
 .B ndb/dns
 .B ndb/dns
 [
 [
-.B -rs
+.B -rsn
 ] [
 ] [
 .B -f
 .B -f
 .I dbfile
 .I dbfile
 ] [
 ] [
 .B -x
 .B -x
 .I netmtpt
 .I netmtpt
+] [
+.B -z
+.I program
 ]
 ]
 .br
 .br
 .B ndb/dnsquery
 .B ndb/dnsquery
@@ -192,6 +195,15 @@ network.
 .B -s
 .B -s
 also answer domain requests sent to UDP port 53.
 also answer domain requests sent to UDP port 53.
 .TP
 .TP
+.B -n
+whenever a zone that we serve changes, send UDP NOTIFY
+messages to any dns slaves for that zone.
+.TP
+.B -z
+whenever we receive a UDP NOTIFY message, run
+.I program
+with the domain name of the area as its argument.
+.TP
 .B -r
 .B -r
 defer to other servers to resolve queries.
 defer to other servers to resolve queries.
 .PP
 .PP
@@ -251,6 +263,8 @@ dom=cs.bell-labs.com soa=
 	mb=presotto@plan9.bell-labs.com
 	mb=presotto@plan9.bell-labs.com
 	mx=mail.research.bell-labs.com pref=20
 	mx=mail.research.bell-labs.com pref=20
 	mx=plan9.bell-labs.com pref=10
 	mx=plan9.bell-labs.com pref=10
+	dnsslave=nslocum.cs.bell-labs.com
+	dnsslave=vex.cs.bell-labs.com
 
 
 .EE
 .EE
 Here, the
 Here, the
@@ -266,6 +280,13 @@ and
 .B ttl
 .B ttl
 define the area refresh interval and the minimum TTL for
 define the area refresh interval and the minimum TTL for
 records in this domain.
 records in this domain.
+The
+.B dnsslave
+entries specify slave DNS servers that should be notified
+when the domain changes.  The notification also requires
+the
+.B -n
+flag.
 .PP
 .PP
 You can also serve reverse lookups (returning the name that
 You can also serve reverse lookups (returning the name that
 goes with an IP address) by adding an
 goes with an IP address) by adding an
@@ -284,7 +305,7 @@ dom=104.135.in-addr.arpa soa=
 Notice the form of the reverse address, i.e., it's the bytes of the
 Notice the form of the reverse address, i.e., it's the bytes of the
 address range you are serving reversed and with
 address range you are serving reversed and with
 .B .in-addr.arpa
 .B .in-addr.arpa
-appended.  This is a standard form for an IPv4 PTR record name.
+appended.  This is a standard form for a domain name in an IPv4 PTR record.
 .PP
 .PP
 If such an entry exists in the database, reverse addresses will
 If such an entry exists in the database, reverse addresses will
 automaticly be generated from any IP addresses in the database
 automaticly be generated from any IP addresses in the database

+ 39 - 25
sys/man/8/prep

@@ -4,9 +4,13 @@ prep, fdisk, format, mbr \- prepare hard and floppy diskettes, flashes
 .SH SYNOPSIS
 .SH SYNOPSIS
 .B disk/prep
 .B disk/prep
 [
 [
-.B -abcfnprw
+.B -bcfnprw
 ]
 ]
 [
 [
+.B -a
+.I name
+]...
+[
 .B -s 
 .B -s 
 .I sectorsize
 .I sectorsize
 ]
 ]
@@ -91,7 +95,7 @@ do not overlap.
 The Plan 9 partition often contains a number of
 The Plan 9 partition often contains a number of
 conventionally named subpartitions.
 conventionally named subpartitions.
 They include:
 They include:
-.TF cache
+.TF arenas
 .TP 
 .TP 
 .B 9fat
 .B 9fat
 A small FAT file system used to hold
 A small FAT file system used to hold
@@ -109,16 +113,39 @@ See the discussion of the
 option to
 option to
 .IR format .
 .IR format .
 .TP
 .TP
+.B arenas
+A
+.IR venti (8)
+arenas partition.
+.TP
 .B cache
 .B cache
 A
 A
 .IR cfs (4)
 .IR cfs (4)
 file system cache.
 file system cache.
 .TP
 .TP
+.B fossil
+A
+.IR fossil (4)
+file system.
+.TP
 .B fs
 .B fs
 A
 A
 .IR kfs (4)
 .IR kfs (4)
 file system.
 file system.
 .TP
 .TP
+.B isect
+A
+.IR venti (8)
+index section.
+.TP
+.B nvram
+A one-sector partition used to simulate non-volatile RAM on PCs.
+.TP
+.B other
+A non-archived
+.IR fossil (4)
+file system.
+.TP
 .B swap
 .B swap
 A 
 A 
 .IR swap (8)
 .IR swap (8)
@@ -158,29 +185,16 @@ Plan 9 partition already exists.
 If no other partition on the disk is marked active (i.e. marked as the boot partition),
 If no other partition on the disk is marked active (i.e. marked as the boot partition),
 .I fdisk
 .I fdisk
 will mark the new partition active.
 will mark the new partition active.
-.I Prep
-will create 
-.BR 9fat ,
-.BR swap ,
-and
-.B fs
-partitions, doing
-nothing if the disk
-has already been partitioned.
-If the
-.B -c
-option is present, 
-.I prep
-will also create a 
-.B cache
-partition.
-If the
-.B -n
-option is present,
+.IR Prep 's
+.B -a
+flag takes the name of a partition to create.
+(See the list above for partition names.)
+It can be repeated to specify a list of partitions to create.
+If the disk is currently unpartitioned, 
 .I prep
 .I prep
-will create a one-sector
-.B nvram
-partition.
+will create the named partitions on the disk,
+attempting to use the entire disk in a sensible manner.
+The partition names must be from the list given above.
 .TP
 .TP
 .B -b
 .B -b
 Start with a blank disk, ignoring any extant partition table.
 Start with a blank disk, ignoring any extant partition table.
@@ -649,7 +663,7 @@ Initialize the blank hard disk
 .EX
 .EX
 disk/mbr -m /386/mbr /dev/sdC0/data
 disk/mbr -m /386/mbr /dev/sdC0/data
 disk/fdisk -baw /dev/sdC0/data
 disk/fdisk -baw /dev/sdC0/data
-disk/prep -baw /dev/sdC0/plan9
+disk/prep -bw -a^(9fat fs cache swap) /dev/sdC0/plan9
 disk/format -b /386/pbs -d -r 2 /dev/sdC0/9fat 9load 9pcdisk plan9.ini
 disk/format -b /386/pbs -d -r 2 /dev/sdC0/9fat 9load 9pcdisk plan9.ini
 .EE
 .EE
 .PP
 .PP

+ 3 - 0
sys/man/8/venti

@@ -201,6 +201,9 @@ The units for the various cache sizes above can be specified by appending a
 or
 or
 .LR g
 .LR g
 to indicate kilobytes, megabytes, or gigabytes respectively.
 to indicate kilobytes, megabytes, or gigabytes respectively.
+The command line options override options found in the
+.IR venti.conf (6)
+file.
 .PP
 .PP
 .I Sync
 .I Sync
 connects to a running Venti server and executes a sync rpc
 connects to a running Venti server and executes a sync rpc

+ 30 - 0
sys/man/8/ventiaux

@@ -3,6 +3,7 @@
 buildindex,
 buildindex,
 checkarenas,
 checkarenas,
 checkindex,
 checkindex,
+conf,
 copy,
 copy,
 fmtarenas,
 fmtarenas,
 fmtindex,
 fmtindex,
@@ -41,6 +42,15 @@ write \- Venti maintenance and debugging commands
 .I venti.config
 .I venti.config
 .I tmp
 .I tmp
 .PP
 .PP
+.B venti/conf
+[
+.B -w
+]
+.I partition
+[
+.I configfile
+]
+.PP
 .B venti/copy
 .B venti/copy
 [
 [
 .B -f
 .B -f
@@ -464,6 +474,26 @@ children are also already on
 .IR dst .
 .IR dst .
 Without this flag, the copy often transfers many times more
 Without this flag, the copy often transfers many times more
 data than necessary.
 data than necessary.
+.PP
+To make it easier to bootstrap servers, the configuration
+file can be stored at the beginning of any Venti partitions using
+.IR conf .
+A partition so branded with a configuration file can
+be used in place of a configuration file when invoking any
+of the venti commands.
+By default,
+.I conf
+prints the configuration stored in
+.IR partition .
+When invoked with the
+.B -w
+flag,
+.I conf
+reads a configuration file from 
+.I configfile
+(or else standard input)
+and stores it in
+.IR partition .
 .SH SOURCE
 .SH SOURCE
 .B /sys/src/cmd/venti
 .B /sys/src/cmd/venti
 .SH "SEE ALSO"
 .SH "SEE ALSO"

+ 0 - 58
sys/man/8/x509

@@ -1,58 +0,0 @@
-.TH X509 8
-.SH NAME
-X509gen \- create a self-signed X.509 certificate
-.SH SYNOPSIS
-.B aux/X509gen
-[
-.B -e
-.I s
-]
-[
-.B -p
-]
-.I key.secret
-.I subj
-.SH DESCRIPTION
-.I X509gen
-writes a self-signed X.509 certificate to standard output,
-given an RSA public/private key pair
-.I key.secret
-and an issuer/subject string
-.IR subj ,
-also known as a "Distinguished Name" and conventionally of the form:
-.EX
-   C=US ST=NJ L=07922 O=Lucent OU='Bell Labs' CN=G.R.Emlin
-.EE
-Of course, to pass
-.I subj
-to
-.I x509gen
-using
-.IR rc (1)
-the string would be quoted as in:
-.EX
-   'C=US ST=NJ L=07922 O=Lucent OU=''Bell Labs'' CN=G.R.Emlin'
-.EE
-The key pair can be generated by
-.I aux/ssh_genkey
-(see
-.IR ssh (1)).
-.PP
-Command-line options are:
-.TP
-.B -e
-number of seconds for which certificate should be valid,
-by default 3 years.
-.TP
-.B -p
-write certificate in PEM format (instead of the default DER format)
-.SH SOURCE
-.B /sys/src/cmd/aux/X509gen.c
-.SH "SEE ALSO"
-.br
-.IR ssh (1),
-.IR rsa (2)
-.SH BUGS
-Web browsers and email clients in other operating systems
-expect certificates to be issued by a well known
-root certificate authority.

+ 16 - 16
sys/src/9/alphapc/dat.h

@@ -160,7 +160,7 @@ struct Mach
 	int	load;
 	int	load;
 	int	intr;
 	int	intr;
 	int	flushmmu;		/* make current proc flush it's mmu state */
 	int	flushmmu;		/* make current proc flush it's mmu state */
-	int		ilockdepth;
+	int	ilockdepth;
 
 
 	ulong	spuriousintr;
 	ulong	spuriousintr;
 	int	lastintr;
 	int	lastintr;
@@ -197,18 +197,18 @@ struct PCArch
 	int	(*intrvecno)(int);
 	int	(*intrvecno)(int);
 	int	(*intrdisable)(int);
 	int	(*intrdisable)(int);
 
 
-	int		(*_inb)(int);
+	int	(*_inb)(int);
 	ushort	(*_ins)(int);
 	ushort	(*_ins)(int);
 	ulong	(*_inl)(int);
 	ulong	(*_inl)(int);
-	void		(*_outb)(int, int);
-	void		(*_outs)(int, ushort);
-	void		(*_outl)(int, ulong);
-	void		(*_insb)(int, void*, int);
-	void		(*_inss)(int, void*, int);
-	void		(*_insl)(int, void*, int);
-	void		(*_outsb)(int, void*, int);
-	void		(*_outss)(int, void*, int);
-	void		(*_outsl)(int, void*, int);
+	void	(*_outb)(int, int);
+	void	(*_outs)(int, ushort);
+	void	(*_outl)(int, ulong);
+	void	(*_insb)(int, void*, int);
+	void	(*_inss)(int, void*, int);
+	void	(*_insl)(int, void*, int);
+	void	(*_outsb)(int, void*, int);
+	void	(*_outss)(int, void*, int);
+	void	(*_outsl)(int, void*, int);
 };
 };
 
 
 /*
 /*
@@ -217,9 +217,9 @@ struct PCArch
 #define NISAOPT		8
 #define NISAOPT		8
 
 
 struct ISAConf {
 struct ISAConf {
-	char		*type;
+	char	*type;
 	ulong	port;
 	ulong	port;
-	ulong	irq;
+	int	irq;
 	ulong	dma;
 	ulong	dma;
 	ulong	mem;
 	ulong	mem;
 	ulong	size;
 	ulong	size;
@@ -242,13 +242,13 @@ extern register Proc	*up;
  */
  */
 typedef struct {
 typedef struct {
 	ulong	port;	
 	ulong	port;	
-	int		size;
+	int	size;
 } port_t;
 } port_t;
 
 
 struct DevConf
 struct DevConf
 {
 {
 	ulong	intnum;	/* interrupt number */
 	ulong	intnum;	/* interrupt number */
-	char		*type;	/* card type, malloced */
-	int		nports;	/* Number of ports */
+	char	*type;	/* card type, malloced */
+	int	nports;	/* Number of ports */
 	port_t	*ports;	/* The ports themselves */
 	port_t	*ports;	/* The ports themselves */
 };
 };

+ 1 - 492
sys/src/9/alphapc/devether.c

@@ -1,492 +1 @@
-#include "u.h"
-#include "../port/lib.h"
-#include "mem.h"
-#include "dat.h"
-#include "fns.h"
-#include "io.h"
-#include "ureg.h"
-#include "../port/error.h"
-#include "../port/netif.h"
-
-#include "etherif.h"
-
-static volatile Ether *etherxx[MaxEther];
-
-Chan*
-etherattach(char* spec)
-{
-	ulong ctlrno;
-	char *p;
-	Chan *chan;
-
-	ctlrno = 0;
-	if(spec && *spec){
-		ctlrno = strtoul(spec, &p, 0);
-		if((ctlrno == 0 && p == spec) || *p || (ctlrno >= MaxEther))
-			error(Ebadarg);
-	}
-	if(etherxx[ctlrno] == 0)
-		error(Enodev);
-
-	chan = devattach('l', spec);
-	chan->dev = ctlrno;
-	if(etherxx[ctlrno]->attach)
-		etherxx[ctlrno]->attach(etherxx[ctlrno]);
-	return chan;
-}
-
-static Walkqid*
-etherwalk(Chan* chan, Chan* nchan, char** name, int nname)
-{
-	return netifwalk(etherxx[chan->dev], chan, nchan, name, nname);
-}
-
-static int
-etherstat(Chan* chan, uchar* dp, int n)
-{
-	return netifstat(etherxx[chan->dev], chan, dp, n);
-}
-
-static Chan*
-etheropen(Chan* chan, int omode)
-{
-	return netifopen(etherxx[chan->dev], chan, omode);
-}
-
-static void
-ethercreate(Chan*, char*, int, ulong)
-{
-}
-
-static void
-etherclose(Chan* chan)
-{
-	netifclose(etherxx[chan->dev], chan);
-}
-
-static long
-etherread(Chan* chan, void* buf, long n, vlong off)
-{
-	Ether *ether;
-	ulong offset = off;
-
-	ether = etherxx[chan->dev];
-	if((chan->qid.type & QTDIR) == 0 && ether->ifstat){
-		/*
-		 * With some controllers it is necessary to reach
-		 * into the chip to extract statistics.
-		 */
-		if(NETTYPE(chan->qid.path) == Nifstatqid)
-			return ether->ifstat(ether, buf, n, offset);
-		else if(NETTYPE(chan->qid.path) == Nstatqid)
-			ether->ifstat(ether, buf, 0, offset);
-	}
-
-	return netifread(ether, chan, buf, n, offset);
-}
-
-static Block*
-etherbread(Chan* chan, long n, ulong offset)
-{
-	return netifbread(etherxx[chan->dev], chan, n, offset);
-}
-
-static int
-etherwstat(Chan* chan, uchar* dp, int n)
-{
-	return netifwstat(etherxx[chan->dev], chan, dp, n);
-}
-
-static void
-etherrtrace(Netfile* f, Etherpkt* pkt, int len)
-{
-	int i, n;
-	Block *bp;
-
-	if(qwindow(f->in) <= 0)
-		return;
-	if(len > 58)
-		n = 58;
-	else
-		n = len;
-	bp = iallocb(64);
-	if(bp == nil)
-		return;
-	memmove(bp->wp, pkt->d, n);
-	i = TK2MS(MACHP(0)->ticks);
-	bp->wp[58] = len>>8;
-	bp->wp[59] = len;
-	bp->wp[60] = i>>24;
-	bp->wp[61] = i>>16;
-	bp->wp[62] = i>>8;
-	bp->wp[63] = i;
-	bp->wp += 64;
-	qpass(f->in, bp);
-}
-
-Block*
-etheriq(Ether* ether, Block* bp, int fromwire)
-{
-	Etherpkt *pkt;
-	ushort type;
-	int len, multi, tome, fromme;
-	Netfile **ep, *f, **fp, *fx;
-	Block *xbp;
-
-	ether->inpackets++;
-
-	pkt = (Etherpkt*)bp->rp;
-	len = BLEN(bp);
-	type = (pkt->type[0]<<8)|pkt->type[1];
-	fx = 0;
-	ep = &ether->f[Ntypes];
-
-	multi = pkt->d[0] & 1;
-	/* check for valid multcast addresses */
-	if(multi && memcmp(pkt->d, ether->bcast, sizeof(pkt->d)) && ether->prom == 0){
-		if(!activemulti(ether, pkt->d, sizeof(pkt->d))){
-			if(fromwire){
-				freeb(bp);
-				bp = 0;
-			}
-			return bp;
-		}
-	}
-
-	/* is it for me? */
-	tome = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0;
-	fromme = memcmp(pkt->s, ether->ea, sizeof(pkt->s)) == 0;
-
-	/*
-	 * Multiplex the packet to all the connections which want it.
-	 * If the packet is not to be used subsequently (fromwire != 0),
-	 * attempt to simply pass it into one of the connections, thereby
-	 * saving a copy of the data (usual case hopefully).
-	 */
-	for(fp = ether->f; fp < ep; fp++){
-		if(f = *fp)
-		if(f->type == type || f->type < 0)
-		if(tome || multi || f->prom){
-			/* Don't want to hear bridged packets */
-			if(f->bridge && !fromwire && !fromme)
-				continue;
-			if(!f->headersonly){
-				if(fromwire && fx == 0)
-					fx = f;
-				else if(xbp = iallocb(len)){
-					memmove(xbp->wp, pkt, len);
-					xbp->wp += len;
-					if(qpass(f->in, xbp) < 0)
-						ether->soverflows++;
-				}
-				else
-					ether->soverflows++;
-			}
-			else
-				etherrtrace(f, pkt, len);
-		}
-	}
-
-	if(fx){
-		if(qpass(fx->in, bp) < 0)
-			ether->soverflows++;
-		return 0;
-	}
-	if(fromwire){
-		freeb(bp);
-		return 0;
-	}
-
-	return bp;
-}
-
-static int
-etheroq(Ether* ether, Block* bp)
-{
-	int len, loopback, s;
-	Etherpkt *pkt;
-
-	ether->outpackets++;
-
-	/*
-	 * Check if the packet has to be placed back onto the input queue,
-	 * i.e. if it's a loopback or broadcast packet or the interface is
-	 * in promiscuous mode.
-	 * If it's a loopback packet indicate to etheriq that the data isn't
-	 * needed and return, etheriq will pass-on or free the block.
-	 * To enable bridging to work, only packets that were originated
-	 * by this interface are fed back.
-	 */
-	pkt = (Etherpkt*)bp->rp;
-	len = BLEN(bp);
-	loopback = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0;
-	if(loopback || memcmp(pkt->d, ether->bcast, sizeof(pkt->d)) == 0 || ether->prom){
-		s = splhi();
-		etheriq(ether, bp, 0);
-		splx(s);
-	}
-
-	if(!loopback){
-		qbwrite(ether->oq, bp);
-		ether->transmit(ether);
-	} else
-		freeb(bp);
-
-	return len;
-}
-
-static long
-etherwrite(Chan* chan, void* buf, long n, vlong)
-{
-	Ether *ether;
-	Block *bp;
-	int nn;
-
-	ether = etherxx[chan->dev];
-	if(NETTYPE(chan->qid.path) != Ndataqid) {
-		nn = netifwrite(ether, chan, buf, n);
-		if(nn >= 0)
-			return nn;
-		if(n == sizeof("nonblocking")-1 && strncmp((char*)buf, "nonblocking", n) == 0){
-			qnoblock(ether->oq, 1);
-			return n;
-		}
-		if(ether->ctl!=nil)
-			return ether->ctl(ether,buf,n);
-
-		error(Ebadctl);
-	}
-
-	if(n > ether->maxmtu)
-		error(Etoobig);
-	if(n < ether->minmtu)
-		error(Etoosmall);
-
-	bp = allocb(n);
-	if(waserror()){
-		freeb(bp);
-		nexterror();
-	}
-	memmove(bp->rp, buf, n);
-	memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen);
-	poperror();
-	bp->wp += n;
-
-	return etheroq(ether, bp);
-}
-
-static long
-etherbwrite(Chan* chan, Block* bp, ulong)
-{
-	Ether *ether;
-	long n;
-
-	n = BLEN(bp);
-	if(NETTYPE(chan->qid.path) != Ndataqid){
-		if(waserror()) {
-			freeb(bp);
-			nexterror();
-		}
-		n = etherwrite(chan, bp->rp, n, 0);
-		poperror();
-		freeb(bp);
-		return n;
-	}
-	ether = etherxx[chan->dev];
-
-	if(n > ether->maxmtu){
-		freeb(bp);
-		error(Etoobig);
-	}
-	if(n < ether->minmtu){
-		freeb(bp);
-		error(Etoosmall);
-	}
-
-	return etheroq(ether, bp);
-}
-
-static struct {
-	char*	type;
-	int	(*reset)(Ether*);
-} cards[MaxEther+1];
-
-void
-addethercard(char* t, int (*r)(Ether*))
-{
-	static int ncard;
-
-	if(ncard == MaxEther)
-		panic("too many ether cards");
-	cards[ncard].type = t;
-	cards[ncard].reset = r;
-	ncard++;
-}
-
-int
-parseether(uchar *to, char *from)
-{
-	char nip[4];
-	char *p;
-	int i;
-
-	p = from;
-	for(i = 0; i < Eaddrlen; i++){
-		if(*p == 0)
-			return -1;
-		nip[0] = *p++;
-		if(*p == 0)
-			return -1;
-		nip[1] = *p++;
-		nip[2] = 0;
-		to[i] = strtoul(nip, 0, 16);
-		if(*p == ':')
-			p++;
-	}
-	return 0;
-}
-
-static void
-etherreset(void)
-{
-	Ether *ether;
-	int i, n, ctlrno;
-	char name[32], buf[256];
-
-	for(ether = 0, ctlrno = 0; ctlrno < MaxEther; ctlrno++){
-		if(ether == 0)
-			ether = malloc(sizeof(Ether));
-		memset(ether, 0, sizeof(Ether));
-		ether->ctlrno = ctlrno;
-		ether->tbdf = BUSUNKNOWN;
-		ether->mbps = 10;
-		ether->minmtu = ETHERMINTU;
-		ether->maxmtu = ETHERMAXTU;
-		if(isaconfig("ether", ctlrno, ether) == 0)
-			continue;
-		for(n = 0; cards[n].type; n++){
-			if(cistrcmp(cards[n].type, ether->type))
-				continue;
-			for(i = 0; i < ether->nopt; i++){
-				if(strncmp(ether->opt[i], "ea=", 3))
-					continue;
-				if(parseether(ether->ea, &ether->opt[i][3]))
-					memset(ether->ea, 0, Eaddrlen);
-			}
-			if(cards[n].reset(ether))
-				break;
-
-			/*
-			 * IRQ2 doesn't really exist, it's used to gang the interrupt
-			 * controllers together. A device set to IRQ2 will appear on
-			 * the second interrupt controller as IRQ9.
-			 */
-			if(ether->irq == 2 && BUSTYPE(ether->tbdf) != BusPCI)
-				ether->irq = 9;
-			snprint(name, sizeof(name), "ether%d", ctlrno);
-			/*
-			 * If ether->irq is 0, it is a hack to indicate no
-			 * interrupt used by ethersink.
-			 */
-			if(ether->irq > 0)
-				intrenable(ether->irq, ether->interrupt,
-					ether, ether->tbdf, name);
-
-			i = sprint(buf, "#l%d (%s): %s: %dMbps port 0x%luX irq %lud",
-				ctlrno, name, ether->type, ether->mbps,
-				ether->port, ether->irq);
-			if(ether->mem)
-				i += sprint(buf+i, " addr 0x%luX", PADDR(ether->mem));
-			if(ether->size)
-				i += sprint(buf+i, " size 0x%luX", ether->size);
-			i += sprint(buf+i, ": %2.2uX%2.2uX%2.2uX%2.2uX%2.2uX%2.2uX",
-				ether->ea[0], ether->ea[1], ether->ea[2],
-				ether->ea[3], ether->ea[4], ether->ea[5]);
-			sprint(buf+i, "\n");
-			print(buf);
-
-			if(ether->mbps == 100){
-				netifinit(ether, name, Ntypes, 256*1024);
-				if(ether->oq == 0)
-					ether->oq = qopen(256*1024, Qmsg, 0, 0);
-			}
-			else{
-				netifinit(ether, name, Ntypes, 65*1024);
-				if(ether->oq == 0)
-					ether->oq = qopen(65*1024, Qmsg, 0, 0);
-			}
-			if(ether->oq == 0)
-				panic("etherreset %s", name);
-			ether->alen = Eaddrlen;
-			memmove(ether->addr, ether->ea, Eaddrlen);
-			memset(ether->bcast, 0xFF, Eaddrlen);
-
-			etherxx[ctlrno] = ether;
-			ether = 0;
-			break;
-		}
-	}
-	if(ether)
-		free(ether);
-}
-
-/* imported from ../pc; not ready for use yet */
-static void
-ethershutdown(void)
-{
-	Ether *ether;
-	int i;
-
-	for(i = 0; i < MaxEther; i++){
-		ether = etherxx[i];
-		if(ether == nil)
-			continue;
-		if(ether->shutdown == nil) {
-			print("#l%d: no shutdown fuction\n", i);
-			continue;
-		}
-		(*ether->shutdown)(ether);
-	}
-}
-
-
-#define POLY 0xedb88320
-
-/* really slow 32 bit crc for ethers */
-ulong
-ethercrc(uchar *p, int len)
-{
-	int i, j;
-	ulong crc, b;
-
-	crc = 0xffffffff;
-	for(i = 0; i < len; i++){
-		b = *p++;
-		for(j = 0; j < 8; j++){
-			crc = (crc>>1) ^ (((crc^b) & 1) ? POLY : 0);
-			b >>= 1;
-		}
-	}
-	return crc;
-}
-
-Dev etherdevtab = {
-	'l',
-	"ether",
-
-	etherreset,
-	devinit,
-	devshutdown,
-	etherattach,
-	etherwalk,
-	etherstat,
-	etheropen,
-	ethercreate,
-	etherclose,
-	etherread,
-	etherbread,
-	etherwrite,
-	etherbwrite,
-	devremove,
-	etherwstat,
-};
+#include "../pc/devether.c"

+ 0 - 50
sys/src/9/alphapc/errstr.h

@@ -1,50 +0,0 @@
-char Enoerror[] = "no error";
-char Emount[] = "inconsistent mount";
-char Eunmount[] = "not mounted";
-char Eunion[] = "not in union";
-char Emountrpc[] = "mount rpc error";
-char Eshutdown[] = "device shut down";
-char Enocreate[] = "mounted directory forbids creation";
-char Enonexist[] = "file does not exist";
-char Eexist[] = "file already exists";
-char Ebadsharp[] = "unknown device in # filename";
-char Enotdir[] = "not a directory";
-char Eisdir[] = "file is a directory";
-char Ebadchar[] = "bad character in file name";
-char Efilename[] = "file name syntax";
-char Eperm[] = "permission denied";
-char Ebadusefd[] = "inappropriate use of fd";
-char Ebadarg[] = "bad arg in system call";
-char Einuse[] = "device or object already in use";
-char Eio[] = "i/o error";
-char Etoobig[] = "read or write too large";
-char Etoosmall[] = "read or write too small";
-char Enoport[] = "network port not available";
-char Ehungup[] = "i/o on hungup channel";
-char Ebadctl[] = "bad process or channel control request";
-char Enodev[] = "no free devices";
-char Eprocdied[] = "process exited";
-char Enochild[] = "no living children";
-char Eioload[] = "i/o error in demand load";
-char Enovmem[] = "virtual memory allocation failed";
-char Ebadfd[] = "fd out of range or not open";
-char Enofd[] = "no free file descriptors";
-char Eisstream[] = "seek on a stream";
-char Ebadexec[] = "exec header invalid";
-char Etimedout[] = "connection timed out";
-char Econrefused[] = "connection refused";
-char Econinuse[] = "connection in use";
-char Eintr[] = "interrupted";
-char Enomem[] = "kernel allocate failed";
-char Enoswap[] = "swap space full";
-char Esoverlap[] = "segments overlap";
-char Emouseset[] = "mouse type already set";
-char Eshort[] = "i/o count too small";
-char Egreg[] = "ken has left the building";
-char Ebadspec[] = "bad attach specifier";
-char Enoreg[] = "process has no saved registers";
-char Enoattach[] = "mount/attach disallowed";
-char Eshortstat[] = "stat buffer too small";
-char Ebadstat[] = "malformed stat buffer";
-char Enegoff[] = "negative i/o offset";
-char Ecmdargs[] = "wrong #args in control message";

+ 0 - 51
sys/src/9/bitsy/errstr.h

@@ -1,51 +0,0 @@
-char Enoerror[] = "no error";
-char Emount[] = "inconsistent mount";
-char Eunmount[] = "not mounted";
-char Eismtpt[] = "is a mount point";
-char Eunion[] = "not in union";
-char Emountrpc[] = "mount rpc error";
-char Eshutdown[] = "device shut down";
-char Enocreate[] = "mounted directory forbids creation";
-char Enonexist[] = "file does not exist";
-char Eexist[] = "file already exists";
-char Ebadsharp[] = "unknown device in # filename";
-char Enotdir[] = "not a directory";
-char Eisdir[] = "file is a directory";
-char Ebadchar[] = "bad character in file name";
-char Efilename[] = "file name syntax";
-char Eperm[] = "permission denied";
-char Ebadusefd[] = "inappropriate use of fd";
-char Ebadarg[] = "bad arg in system call";
-char Einuse[] = "device or object already in use";
-char Eio[] = "i/o error";
-char Etoobig[] = "read or write too large";
-char Etoosmall[] = "read or write too small";
-char Enoport[] = "network port not available";
-char Ehungup[] = "i/o on hungup channel";
-char Ebadctl[] = "bad process or channel control request";
-char Enodev[] = "no free devices";
-char Eprocdied[] = "process exited";
-char Enochild[] = "no living children";
-char Eioload[] = "i/o error in demand load";
-char Enovmem[] = "virtual memory allocation failed";
-char Ebadfd[] = "fd out of range or not open";
-char Enofd[] = "no free file descriptors";
-char Eisstream[] = "seek on a stream";
-char Ebadexec[] = "exec header invalid";
-char Etimedout[] = "connection timed out";
-char Econrefused[] = "connection refused";
-char Econinuse[] = "connection in use";
-char Eintr[] = "interrupted";
-char Enomem[] = "kernel allocate failed";
-char Enoswap[] = "swap space full";
-char Esoverlap[] = "segments overlap";
-char Emouseset[] = "mouse type already set";
-char Eshort[] = "i/o count too small";
-char Egreg[] = "ken has left the building";
-char Ebadspec[] = "bad attach specifier";
-char Enoreg[] = "process has no saved registers";
-char Enoattach[] = "mount/attach disallowed";
-char Eshortstat[] = "stat buffer too small";
-char Ebadstat[] = "malformed stat buffer";
-char Enegoff[] = "negative i/o offset";
-char Ecmdargs[] = "wrong #args in control message";

+ 2 - 1
sys/src/9/bitsy/l.s

@@ -167,7 +167,8 @@ TEXT putttb(SB), $-4
  */
  */
 TEXT mmuenable(SB), $-4
 TEXT mmuenable(SB), $-4
 	MRC	CpMMU, 0, R0, C(CpControl), C(0x0)
 	MRC	CpMMU, 0, R0, C(CpControl), C(0x0)
-	ORR	$(CpCmmuena|CpCdcache|CpCicache|CpCwb), R0
+	ORR	$(CpCmmuena|CpCdcache|CpCicache|CpCwb|CpCsystem), R0
+	BIC	$(CpCrom), R0
 	MCR     CpMMU, 0, R0, C(CpControl), C(0x0)
 	MCR     CpMMU, 0, R0, C(CpControl), C(0x0)
 	MOVW R0, R0
 	MOVW R0, R0
 	MOVW R0, R0
 	MOVW R0, R0

+ 1 - 1
sys/src/9/bitsy/mem.h

@@ -150,7 +150,7 @@
  *  Internal MMU coprocessor registers
  *  Internal MMU coprocessor registers
  */
  */
 #define CpCPUID		0		/* R: */
 #define CpCPUID		0		/* R: */
-#define CpControl	1		/* R: */
+#define CpControl	1		/* RW: */
 #define CpTTB		2		/* RW: translation table base */
 #define CpTTB		2		/* RW: translation table base */
 #define CpDAC		3		/* RW: domain access control */
 #define CpDAC		3		/* RW: domain access control */
 #define CpFSR		5		/* RW: fault status */
 #define CpFSR		5		/* RW: fault status */

+ 1 - 0
sys/src/9/bitsy/mmu.c

@@ -27,6 +27,7 @@ enum
 	L1Buffered=	(1<<2),
 	L1Buffered=	(1<<2),
 	L1DomShift=	5,
 	L1DomShift=	5,
 	L1Domain0=	(0<<L1DomShift),
 	L1Domain0=	(0<<L1DomShift),
+	L1KernelRO=	(0x0<<10),
 	L1KernelRW=	(0x1<<10),
 	L1KernelRW=	(0x1<<10),
 	L1UserRO=	(0x2<<10),
 	L1UserRO=	(0x2<<10),
 	L1UserRW=	(0x3<<10),
 	L1UserRW=	(0x3<<10),

+ 1 - 1
sys/src/9/bitsy/sdata.c

@@ -1775,7 +1775,7 @@ scsirio(SDreq* r)
 
 
 			while(waserror())
 			while(waserror())
 				;
 				;
-			tsleep(&r->unit->rendez, return0, 0, 500);
+			tsleep(&up->sleep, return0, 0, 500);
 			poperror();
 			poperror();
 			scsitest(r);
 			scsitest(r);
 			return 2;
 			return 2;

+ 1 - 1
sys/src/9/bitsy/trap.c

@@ -434,7 +434,7 @@ trap(Ureg *ureg)
 				postnote(up, 1, buf, NDebug);
 				postnote(up, 1, buf, NDebug);
 			}
 			}
 		}else{
 		}else{
-			warnregs(ureg, "undefined instruction");
+			iprint("undefined instruction: pc=0x%lux, inst=0x%lux, 0x%lux, 0x%lux, 0x%lux, 0x%lux\n", ureg->pc, ((ulong*)ureg->pc)[-2], ((ulong*)ureg->pc)[-1], ((ulong*)ureg->pc)[0], ((ulong*)ureg->pc)[1], ((ulong*)ureg->pc)[2]);
 			panic("undefined instruction");
 			panic("undefined instruction");
 		}
 		}
 		break;
 		break;

+ 0 - 1
sys/src/9/boot/boot.c

@@ -44,7 +44,6 @@ boot(int argc, char *argv[])
 	bind("#ec", "/env", MREPL|MCREATE);
 	bind("#ec", "/env", MREPL|MCREATE);
 	bind("#e", "/env", MAFTER);
 	bind("#e", "/env", MAFTER);
 	bind("#s", "/srv", MREPL|MCREATE);
 	bind("#s", "/srv", MREPL|MCREATE);
-
 #ifdef DEBUG
 #ifdef DEBUG
 	print("argc=%d\n", argc);
 	print("argc=%d\n", argc);
 	for(fd = 0; fd < argc; fd++)
 	for(fd = 0; fd < argc; fd++)

+ 2 - 0
sys/src/9/boot/boot.h

@@ -70,5 +70,7 @@ extern int	connectpaq(void);
 extern void	configembed(Method*);
 extern void	configembed(Method*);
 extern int	connectembed(void);
 extern int	connectembed(void);
 
 
+extern void	configip(void);
+
 /* hack for passing authentication address */
 /* hack for passing authentication address */
 extern char	*authaddr;
 extern char	*authaddr;

+ 1 - 0
sys/src/9/boot/bootip.c

@@ -56,6 +56,7 @@ configip(void)
 	bind("#l3", mpoint, MAFTER);
 	bind("#l3", mpoint, MAFTER);
 	werrstr("");
 	werrstr("");
 
 
+	print("ip...");
 	/* let ipconfig configure the ip interface */
 	/* let ipconfig configure the ip interface */
 	switch(pid = fork()){
 	switch(pid = fork()){
 	case -1:
 	case -1:

+ 1 - 2
sys/src/9/ip/igmp.c

@@ -59,7 +59,6 @@ struct IGMP
 {
 {
 	Lock;
 	Lock;
 	Rendez	r;
 	Rendez	r;
-	Rendez	r0;
 	IGMPrep	*reports;
 	IGMPrep	*reports;
 };
 };
 
 
@@ -159,7 +158,7 @@ igmpproc(void *a)
 				continue;
 				continue;
 			}
 			}
 
 
-			tsleep(&igmpalloc.r0, return0, 0, MSPTICK);
+			tsleep(&up->sleep, return0, 0, MSPTICK);
 		}
 		}
 		unlock(&igmpalloc);
 		unlock(&igmpalloc);
 	}
 	}

+ 1 - 5
sys/src/9/ip/il.c

@@ -195,8 +195,6 @@ struct Ilpriv
 	ulong	dup;
 	ulong	dup;
 	ulong	dupb;
 	ulong	dupb;
 
 
-	Rendez	ilr;
-
 	/* keeping track of the ack kproc */
 	/* keeping track of the ack kproc */
 	int	ackprocstarted;
 	int	ackprocstarted;
 	QLock	apl;
 	QLock	apl;
@@ -1127,13 +1125,11 @@ ilackproc(void *x)
 	Ilcb *ic;
 	Ilcb *ic;
 	Conv **s, *p;
 	Conv **s, *p;
 	Proto *il;
 	Proto *il;
-	Ilpriv *ipriv;
 
 
 	il = x;
 	il = x;
-	ipriv = il->priv;
 
 
 loop:
 loop:
-	tsleep(&ipriv->ilr, return0, 0, Iltickms);
+	tsleep(&up->sleep, return0, 0, Iltickms);
 	for(s = il->conv; s && *s; s++) {
 	for(s = il->conv; s && *s; s++) {
 		p = *s;
 		p = *s;
 		ic = (Ilcb*)p->ptcl;
 		ic = (Ilcb*)p->ptcl;

+ 2 - 1
sys/src/9/ip/loopbackmedium.c

@@ -29,8 +29,9 @@ loopbackbind(Ipifc *ifc, int, char**)
 
 
 	lb = smalloc(sizeof(*lb));
 	lb = smalloc(sizeof(*lb));
 	lb->f = ifc->conv->p->f;
 	lb->f = ifc->conv->p->f;
-	lb->q = qopen(128*1024, Qmsg, nil, nil);
+	lb->q = qopen(1024*1024, Qmsg, nil, nil);
 	ifc->arg = lb;
 	ifc->arg = lb;
+	ifc->mbps = 1000;
 
 
 	kproc("loopbackread", loopbackread, ifc);
 	kproc("loopbackread", loopbackread, ifc);
 
 

+ 33 - 35
sys/src/9/ip/rudp.c

@@ -30,6 +30,7 @@ enum
 	UDP_RHDRSIZE	= 36,	/* pseudo header + udp header + rudp header */
 	UDP_RHDRSIZE	= 36,	/* pseudo header + udp header + rudp header */
 	UDP_IPHDR	= 8,	/* ip header */
 	UDP_IPHDR	= 8,	/* ip header */
 	IP_UDPPROTO	= 254,
 	IP_UDPPROTO	= 254,
+	UDP_USEAD7	= 52,
 	UDP_USEAD6	= 36,
 	UDP_USEAD6	= 36,
 	UDP_USEAD4	= 12,
 	UDP_USEAD4	= 12,
 
 
@@ -146,7 +147,6 @@ struct Rudpstats
 typedef struct Rudppriv Rudppriv;
 typedef struct Rudppriv Rudppriv;
 struct Rudppriv
 struct Rudppriv
 {
 {
-	Rendez	vous;
 	Ipht	ht;
 	Ipht	ht;
 
 
 	/* MIB counters */
 	/* MIB counters */
@@ -358,9 +358,9 @@ rudpkick(void *x)
 
 
 	ucb = (Rudpcb*)c->ptcl;
 	ucb = (Rudpcb*)c->ptcl;
 	switch(ucb->headers) {
 	switch(ucb->headers) {
-	case 6:
+	case 7:
 		/* get user specified addresses */
 		/* get user specified addresses */
-		bp = pullupblock(bp, UDP_USEAD6);
+		bp = pullupblock(bp, UDP_USEAD7);
 		if(bp == nil)
 		if(bp == nil)
 			return;
 			return;
 		ipmove(raddr, bp->rp);
 		ipmove(raddr, bp->rp);
@@ -370,18 +370,20 @@ rudpkick(void *x)
 		/* pick interface closest to dest */
 		/* pick interface closest to dest */
 		if(ipforme(f, laddr) != Runi)
 		if(ipforme(f, laddr) != Runi)
 			findlocalip(f, laddr, raddr);
 			findlocalip(f, laddr, raddr);
+		bp->rp += IPaddrlen;		/* Ignore ifc address */
 		rport = nhgets(bp->rp);
 		rport = nhgets(bp->rp);
-
-		bp->rp += 4;			/* Igonore local port */
+		bp->rp += 2+2;			/* Ignore local port */
 		break;
 		break;
-	case 4:
-		bp = pullupblock(bp, UDP_USEAD4);
+	case 6:
+		/* get user specified addresses */
+		bp = pullupblock(bp, UDP_USEAD6);
 		if(bp == nil)
 		if(bp == nil)
 			return;
 			return;
-		v4tov6(raddr, bp->rp);
-		bp->rp += IPv4addrlen;
-		v4tov6(laddr, bp->rp);
-		bp->rp += IPv4addrlen;
+		ipmove(raddr, bp->rp);
+		bp->rp += IPaddrlen;
+		ipmove(laddr, bp->rp);
+		bp->rp += IPaddrlen;
+		/* pick interface closest to dest */
 		if(ipforme(f, laddr) != Runi)
 		if(ipforme(f, laddr) != Runi)
 			findlocalip(f, laddr, raddr);
 			findlocalip(f, laddr, raddr);
 		rport = nhgets(bp->rp);
 		rport = nhgets(bp->rp);
@@ -415,8 +417,8 @@ rudpkick(void *x)
 	uh->frag[1] = 0;
 	uh->frag[1] = 0;
 	hnputs(uh->udpplen, ptcllen);
 	hnputs(uh->udpplen, ptcllen);
 	switch(ucb->headers){
 	switch(ucb->headers){
-	case 4:
 	case 6:
 	case 6:
+	case 7:
 		v6tov4(uh->udpdst, raddr);
 		v6tov4(uh->udpdst, raddr);
 		hnputs(uh->udpdport, rport);
 		hnputs(uh->udpdport, rport);
 		v6tov4(uh->udpsrc, laddr);
 		v6tov4(uh->udpsrc, laddr);
@@ -488,6 +490,7 @@ rudpiput(Proto *rudp, Ipifc *ifc, Block *bp)
 	ushort rport, lport;
 	ushort rport, lport;
 	Rudppriv *upriv;
 	Rudppriv *upriv;
 	Fs *f;
 	Fs *f;
+	uchar *p;
 
 
 	upriv = rudp->priv;
 	upriv = rudp->priv;
 	f = rudp->f;
 	f = rudp->f;
@@ -565,27 +568,24 @@ rudpiput(Proto *rudp, Ipifc *ifc, Block *bp)
 		raddr, rport, laddr, lport, len);
 		raddr, rport, laddr, lport, len);
 
 
 	switch(ucb->headers){
 	switch(ucb->headers){
-	case 6:
+	case 7:
 		/* pass the src address */
 		/* pass the src address */
-		bp = padblock(bp, UDP_USEAD6);
-		ipmove(bp->rp, raddr);
-		if(ipforme(f, laddr) == Runi)
-			ipmove(bp->rp+IPaddrlen, laddr);
-		else
-			ipmove(bp->rp+IPaddrlen, ifc->lifc->local);
-		hnputs(bp->rp+2*IPaddrlen, rport);
-		hnputs(bp->rp+2*IPaddrlen+2, lport);
+		bp = padblock(bp, UDP_USEAD7);
+		p = bp->rp;
+		ipmove(p, raddr); p += IPaddrlen;
+		ipmove(p, laddr); p += IPaddrlen;
+		ipmove(p, ifc->lifc->local); p += IPaddrlen;
+		hnputs(p, rport); p += 2;
+		hnputs(p, lport);
 		break;
 		break;
-	case 4:
+	case 6:
 		/* pass the src address */
 		/* pass the src address */
-		bp = padblock(bp, UDP_USEAD4);
-		v6tov4(bp->rp, raddr);
-		if(ipforme(f, laddr) == Runi)
-			v6tov4(bp->rp+IPv4addrlen, laddr);
-		else
-			v6tov4(bp->rp+IPv4addrlen, ifc->lifc->local);
-		hnputs(bp->rp + 2*IPv4addrlen, rport);
-		hnputs(bp->rp + 2*IPv4addrlen + 2, lport);
+		bp = padblock(bp, UDP_USEAD6);
+		p = bp->rp;
+		ipmove(p, raddr); p += IPaddrlen;
+		ipmove(p, ipforme(f, laddr)==Runi ? laddr : ifc->lifc->local); p += IPaddrlen;
+		hnputs(p, rport); p += 2;
+		hnputs(p, lport);
 		break;
 		break;
 	default:
 	default:
 		/* connection oriented rudp */
 		/* connection oriented rudp */
@@ -629,8 +629,8 @@ rudpctl(Conv *c, char **f, int n)
 	if(n < 1)
 	if(n < 1)
 		return rudpunknown;
 		return rudpunknown;
 
 
-	if(strcmp(f[0], "headers4") == 0){
-		ucb->headers = 4;
+	if(strcmp(f[0], "headers++4") == 0){
+		ucb->headers = 7;
 		return nil;
 		return nil;
 	} else if(strcmp(f[0], "headers") == 0){
 	} else if(strcmp(f[0], "headers") == 0){
 		ucb->headers = 6;
 		ucb->headers = 6;
@@ -760,13 +760,11 @@ relackproc(void *a)
 	Proto *rudp;
 	Proto *rudp;
 	Reliable *r;
 	Reliable *r;
 	Conv **s, *c;
 	Conv **s, *c;
-	Rudppriv *upriv;
 
 
 	rudp = (Proto *)a;
 	rudp = (Proto *)a;
-	upriv = rudp->priv;
 
 
 loop:
 loop:
-	tsleep(&upriv->vous, return0, 0, Rudptickms);
+	tsleep(&up->sleep, return0, 0, Rudptickms);
 
 
 	for(s = rudp->conv; *s; s++) {
 	for(s = rudp->conv; *s; s++) {
 		c = *s;
 		c = *s;

+ 1 - 3
sys/src/9/ip/tcp.c

@@ -336,8 +336,6 @@ struct Tcppriv
 	QLock 	tl;
 	QLock 	tl;
 	Tcptimer *timers;
 	Tcptimer *timers;
 
 
-	Rendez	tcpr;			/* used by tcpackproc */
-
 	/* hash table for matching conversations */
 	/* hash table for matching conversations */
 	Ipht	ht;
 	Ipht	ht;
 
 
@@ -645,7 +643,7 @@ tcpackproc(void *a)
 	priv = tcp->priv;
 	priv = tcp->priv;
 
 
 	for(;;) {
 	for(;;) {
-		tsleep(&priv->tcpr, return0, 0, MSPTICK);
+		tsleep(&up->sleep, return0, 0, MSPTICK);
 
 
 		qlock(&priv->tl);
 		qlock(&priv->tl);
 		timeo = nil;
 		timeo = nil;

+ 36 - 38
sys/src/9/ip/udp.c

@@ -23,8 +23,8 @@ enum
 	UDP6_PHDR_OFF = 0,
 	UDP6_PHDR_OFF = 0,
 
 
 	IP_UDPPROTO	= 17,
 	IP_UDPPROTO	= 17,
+	UDP_USEAD7	= 52,
 	UDP_USEAD6	= 36,
 	UDP_USEAD6	= 36,
-	UDP_USEAD4	= 12,
 
 
 	Udprxms		= 200,
 	Udprxms		= 200,
 	Udptickms	= 100,
 	Udptickms	= 100,
@@ -199,9 +199,9 @@ udpkick(void *x, Block *bp)
 
 
 	ucb = (Udpcb*)c->ptcl;
 	ucb = (Udpcb*)c->ptcl;
 	switch(ucb->headers) {
 	switch(ucb->headers) {
-	case 6:
+	case 7:
 		/* get user specified addresses */
 		/* get user specified addresses */
-		bp = pullupblock(bp, UDP_USEAD6);
+		bp = pullupblock(bp, UDP_USEAD7);
 		if(bp == nil)
 		if(bp == nil)
 			return;
 			return;
 		ipmove(raddr, bp->rp);
 		ipmove(raddr, bp->rp);
@@ -211,37 +211,37 @@ udpkick(void *x, Block *bp)
 		/* pick interface closest to dest */
 		/* pick interface closest to dest */
 		if(ipforme(f, laddr) != Runi)
 		if(ipforme(f, laddr) != Runi)
 			findlocalip(f, laddr, raddr);
 			findlocalip(f, laddr, raddr);
+		bp->rp += IPaddrlen;		/* Ignore ifc address */
 		rport = nhgets(bp->rp);
 		rport = nhgets(bp->rp);
 		bp->rp += 2+2;			/* Ignore local port */
 		bp->rp += 2+2;			/* Ignore local port */
 		break;
 		break;
-	case 4:
-		bp = pullupblock(bp, UDP_USEAD4);
+	case 6:
+		/* get user specified addresses */
+		bp = pullupblock(bp, UDP_USEAD6);
 		if(bp == nil)
 		if(bp == nil)
 			return;
 			return;
-		v4tov6(raddr, bp->rp);
-		bp->rp += IPv4addrlen;
-		v4tov6(laddr, bp->rp);
-		bp->rp += IPv4addrlen;
+		ipmove(raddr, bp->rp);
+		bp->rp += IPaddrlen;
+		ipmove(laddr, bp->rp);
+		bp->rp += IPaddrlen;
+		/* pick interface closest to dest */
 		if(ipforme(f, laddr) != Runi)
 		if(ipforme(f, laddr) != Runi)
 			findlocalip(f, laddr, raddr);
 			findlocalip(f, laddr, raddr);
 		rport = nhgets(bp->rp);
 		rport = nhgets(bp->rp);
-		bp->rp += 2+2;
+		bp->rp += 2+2;			/* Ignore local port */
 		break;
 		break;
 	default:
 	default:
 		rport = 0;
 		rport = 0;
 		break;
 		break;
 	}
 	}
 
 
-	if(ucb->headers == 6) {
+	if(ucb->headers) {
 		if(memcmp(laddr, v4prefix, IPv4off) == 0 ||
 		if(memcmp(laddr, v4prefix, IPv4off) == 0 ||
 		    ipcmp(laddr, IPnoaddr) == 0)
 		    ipcmp(laddr, IPnoaddr) == 0)
 			version = 4;
 			version = 4;
 		else
 		else
 			version = 6;
 			version = 6;
-	}
-	else if(ucb->headers == 4)
-		version = 4;
-	else {
+	} else {
 		if( (memcmp(c->raddr, v4prefix, IPv4off) == 0 &&
 		if( (memcmp(c->raddr, v4prefix, IPv4off) == 0 &&
 			memcmp(c->laddr, v4prefix, IPv4off) == 0)
 			memcmp(c->laddr, v4prefix, IPv4off) == 0)
 			|| ipcmp(c->raddr, IPnoaddr) == 0)
 			|| ipcmp(c->raddr, IPnoaddr) == 0)
@@ -266,7 +266,7 @@ udpkick(void *x, Block *bp)
 		uh4->frag[0] = 0;
 		uh4->frag[0] = 0;
 		uh4->frag[1] = 0;
 		uh4->frag[1] = 0;
 		hnputs(uh4->udpplen, ptcllen);
 		hnputs(uh4->udpplen, ptcllen);
-		if(ucb->headers == 4 || ucb->headers == 6) {
+		if(ucb->headers) {
 			v6tov4(uh4->udpdst, raddr);
 			v6tov4(uh4->udpdst, raddr);
 			hnputs(uh4->udpdport, rport);
 			hnputs(uh4->udpdport, rport);
 			v6tov4(uh4->udpsrc, laddr);
 			v6tov4(uh4->udpsrc, laddr);
@@ -301,7 +301,7 @@ udpkick(void *x, Block *bp)
 		ptcllen = dlen + UDP_UDPHDR_SZ;
 		ptcllen = dlen + UDP_UDPHDR_SZ;
 		hnputl(uh6->viclfl, ptcllen);
 		hnputl(uh6->viclfl, ptcllen);
 		uh6->hoplimit = IP_UDPPROTO;
 		uh6->hoplimit = IP_UDPPROTO;
-		if(ucb->headers == 6) {
+		if(ucb->headers) {
 			ipmove(uh6->udpdst, raddr);
 			ipmove(uh6->udpdst, raddr);
 			hnputs(uh6->udpdport, rport);
 			hnputs(uh6->udpdport, rport);
 			ipmove(uh6->udpsrc, laddr);
 			ipmove(uh6->udpsrc, laddr);
@@ -347,6 +347,7 @@ udpiput(Proto *udp, Ipifc *ifc, Block *bp)
 	Fs *f;
 	Fs *f;
 	int version;
 	int version;
 	int ottl, oviclfl, olen;
 	int ottl, oviclfl, olen;
+	uchar *p;
 
 
 	upriv = udp->priv;
 	upriv = udp->priv;
 	f = udp->f;
 	f = udp->f;
@@ -494,27 +495,24 @@ udpiput(Proto *udp, Ipifc *ifc, Block *bp)
 	       laddr, lport, len);
 	       laddr, lport, len);
 
 
 	switch(ucb->headers){
 	switch(ucb->headers){
-	case 6:
+	case 7:
 		/* pass the src address */
 		/* pass the src address */
-		bp = padblock(bp, UDP_USEAD6);
-		ipmove(bp->rp, raddr);
-		if(ipforme(f, laddr) == Runi)
-			ipmove(bp->rp+IPaddrlen, laddr);
-		else
-			ipmove(bp->rp+IPaddrlen, ifc->lifc->local);
-		hnputs(bp->rp+2*IPaddrlen, rport);
-		hnputs(bp->rp+2*IPaddrlen+2, lport);
+		bp = padblock(bp, UDP_USEAD7);
+		p = bp->rp;
+		ipmove(p, raddr); p += IPaddrlen;
+		ipmove(p, laddr); p += IPaddrlen;
+		ipmove(p, ifc->lifc->local); p += IPaddrlen;
+		hnputs(p, rport); p += 2;
+		hnputs(p, lport);
 		break;
 		break;
-	case 4:
+	case 6:
 		/* pass the src address */
 		/* pass the src address */
-		bp = padblock(bp, UDP_USEAD4);
-		v6tov4(bp->rp, raddr);
-		if(ipforme(f, laddr) == Runi)
-			v6tov4(bp->rp+IPv4addrlen, laddr);
-		else
-			v6tov4(bp->rp+IPv4addrlen, ifc->lifc->local);
-		hnputs(bp->rp + 2*IPv4addrlen, rport);
-		hnputs(bp->rp + 2*IPv4addrlen + 2, lport);
+		bp = padblock(bp, UDP_USEAD6);
+		p = bp->rp;
+		ipmove(p, raddr); p += IPaddrlen;
+		ipmove(p, ipforme(f, laddr)==Runi ? laddr : ifc->lifc->local); p += IPaddrlen;
+		hnputs(p, rport); p += 2;
+		hnputs(p, lport);
 		break;
 		break;
 	}
 	}
 
 
@@ -541,11 +539,11 @@ udpctl(Conv *c, char **f, int n)
 
 
 	ucb = (Udpcb*)c->ptcl;
 	ucb = (Udpcb*)c->ptcl;
 	if(n == 1){
 	if(n == 1){
-		if(strcmp(f[0], "headers4") == 0){
-			ucb->headers = 4;
+		if(strcmp(f[0], "oldheaders") == 0){
+			ucb->headers = 6;
 			return nil;
 			return nil;
 		} else if(strcmp(f[0], "headers") == 0){
 		} else if(strcmp(f[0], "headers") == 0){
-			ucb->headers = 6;
+			ucb->headers = 7;
 			return nil;
 			return nil;
 		}
 		}
 	}
 	}

+ 0 - 50
sys/src/9/mtx/errstr.h

@@ -1,50 +0,0 @@
-char Enoerror[] = "no error";
-char Emount[] = "inconsistent mount";
-char Eunmount[] = "not mounted";
-char Eunion[] = "not in union";
-char Emountrpc[] = "mount rpc error";
-char Eshutdown[] = "device shut down";
-char Enocreate[] = "mounted directory forbids creation";
-char Enonexist[] = "file does not exist";
-char Eexist[] = "file already exists";
-char Ebadsharp[] = "unknown device in # filename";
-char Enotdir[] = "not a directory";
-char Eisdir[] = "file is a directory";
-char Ebadchar[] = "bad character in file name";
-char Efilename[] = "file name syntax";
-char Eperm[] = "permission denied";
-char Ebadusefd[] = "inappropriate use of fd";
-char Ebadarg[] = "bad arg in system call";
-char Einuse[] = "device or object already in use";
-char Eio[] = "i/o error";
-char Etoobig[] = "read or write too large";
-char Etoosmall[] = "read or write too small";
-char Enoport[] = "network port not available";
-char Ehungup[] = "i/o on hungup channel";
-char Ebadctl[] = "bad process or channel control request";
-char Enodev[] = "no free devices";
-char Eprocdied[] = "process exited";
-char Enochild[] = "no living children";
-char Eioload[] = "i/o error in demand load";
-char Enovmem[] = "virtual memory allocation failed";
-char Ebadfd[] = "fd out of range or not open";
-char Enofd[] = "no free file descriptors";
-char Eisstream[] = "seek on a stream";
-char Ebadexec[] = "exec header invalid";
-char Etimedout[] = "connection timed out";
-char Econrefused[] = "connection refused";
-char Econinuse[] = "connection in use";
-char Eintr[] = "interrupted";
-char Enomem[] = "kernel allocate failed";
-char Enoswap[] = "swap space full";
-char Esoverlap[] = "segments overlap";
-char Emouseset[] = "mouse type already set";
-char Eshort[] = "i/o count too small";
-char Egreg[] = "ken has left the building";
-char Ebadspec[] = "bad attach specifier";
-char Enoreg[] = "process has no saved registers";
-char Enoattach[] = "mount/attach disallowed";
-char Eshortstat[] = "stat buffer too small";
-char Ebadstat[] = "malformed stat buffer";
-char Enegoff[] = "negative i/o offset";
-char Ecmdargs[] = "wrong #args in control message";

+ 4 - 1
sys/src/9/pc/archmp.c

@@ -96,6 +96,9 @@ syncclock(void)
 {
 {
 	uvlong x;
 	uvlong x;
 
 
+	if(arch->fastclock != tscticks)
+		return;
+
 	if(m->machno == 0){
 	if(m->machno == 0){
 		wrmsr(0x10, 0);
 		wrmsr(0x10, 0);
 		m->tscticks = 0;
 		m->tscticks = 0;
@@ -130,6 +133,6 @@ PCArch archmp = {
 .reset=		mpshutdown,
 .reset=		mpshutdown,
 .intrinit=	mpinit,
 .intrinit=	mpinit,
 .intrenable=	mpintrenable,
 .intrenable=	mpintrenable,
-.fastclock=	tscticks,
+.fastclock=	i8253read,
 .timerset=	lapictimerset,
 .timerset=	lapictimerset,
 };
 };

+ 10 - 7
sys/src/9/pc/devarch.c

@@ -55,7 +55,7 @@ int narchdir = Qbase;
 int (*_pcmspecial)(char*, ISAConf*);
 int (*_pcmspecial)(char*, ISAConf*);
 void (*_pcmspecialclose)(int);
 void (*_pcmspecialclose)(int);
 
 
-extern int i8253dotimerset;
+static int dotimerset = 1;
 
 
 /*
 /*
  * Add a file to the #P listing.  Once added, you can't delete it.
  * Add a file to the #P listing.  Once added, you can't delete it.
@@ -111,9 +111,9 @@ ioinit(void)
 	ioalloc(0x10000, 1, 0, "dummy");
 	ioalloc(0x10000, 1, 0, "dummy");
 	/*
 	/*
 	 * Someone needs to explain why this was here...
 	 * Someone needs to explain why this was here...
+	 */
 	ioalloc(0x0fff, 1, 0, "dummy");	// i82557 is at 0x1000, the dummy
 	ioalloc(0x0fff, 1, 0, "dummy");	// i82557 is at 0x1000, the dummy
 					// entry is needed for swappable devs.
 					// entry is needed for swappable devs.
-	 */
 
 
 	if ((excluded = getconf("ioexclude")) != nil) {
 	if ((excluded = getconf("ioexclude")) != nil) {
 		char *s;
 		char *s;
@@ -754,6 +754,7 @@ archctlread(Chan*, void *a, long nn, vlong offset)
 	n += snprint(buf+n, sizeof buf-n, "pge %s\n", getcr4()&0x80 ? "on" : "off");
 	n += snprint(buf+n, sizeof buf-n, "pge %s\n", getcr4()&0x80 ? "on" : "off");
 	n += snprint(buf+n, sizeof buf-n, "coherence %s\n",
 	n += snprint(buf+n, sizeof buf-n, "coherence %s\n",
 		coherence==wbflush ? "wbflush" : "nop");
 		coherence==wbflush ? "wbflush" : "nop");
+	n += snprint(buf+n, sizeof buf-n, "timerset %s\n", dotimerset ? "on" : "off");
 	buf[n] = 0;
 	buf[n] = 0;
 	return readstr(offset, a, nn, buf);
 	return readstr(offset, a, nn, buf);
 }
 }
@@ -808,10 +809,11 @@ archctlwrite(Chan*, void *a, long n, vlong)
 		break;
 		break;
 	case CMi8253set:
 	case CMi8253set:
 		if(strcmp(cb->f[1], "on") == 0)
 		if(strcmp(cb->f[1], "on") == 0)
-			i8253dotimerset = 1;
-		else if(strcmp(cb->f[1], "off") == 0)
-			i8253dotimerset = 0;
-		else
+			dotimerset = 1;
+		else if(strcmp(cb->f[1], "off") == 0){
+			dotimerset = 0;
+			(*arch->timerset)(0);
+		}else
 			cmderror(cb, "invalid i2853set ctl");
 			cmderror(cb, "invalid i2853set ctl");
 		break;
 		break;
 	}
 	}
@@ -895,5 +897,6 @@ fastticks(uvlong *hz)
 void
 void
 timerset(uvlong x)
 timerset(uvlong x)
 {
 {
-	(*arch->timerset)(x);
+	if(dotimerset)
+		(*arch->timerset)(x);
 }
 }

+ 2 - 2
sys/src/9/pc/devfloppy.c

@@ -509,7 +509,7 @@ floppykproc(void *)
 				qunlock(&fl);
 				qunlock(&fl);
 			}
 			}
 		}
 		}
-		tsleep(&fl.kr, return0, 0, 1000);
+		tsleep(&up->sleep, return0, 0, 1000);
 	}
 	}
 }
 }
 
 
@@ -531,7 +531,7 @@ floppyon(FDrive *dp)
 	outb(Pdor, fl.motor | Fintena | Fena | dp->dev);
 	outb(Pdor, fl.motor | Fintena | Fena | dp->dev);
 	if(!alreadyon){
 	if(!alreadyon){
 		/* wait for drive to spin up */
 		/* wait for drive to spin up */
-		tsleep(&dp->r, return0, 0, 750);
+		tsleep(&up->sleep, return0, 0, 750);
 
 
 		/* clear any pending interrupts */
 		/* clear any pending interrupts */
 		floppysense();
 		floppysense();

+ 0 - 50
sys/src/9/pc/errstr.h

@@ -1,50 +0,0 @@
-char Enoerror[] = "no error";
-char Emount[] = "inconsistent mount";
-char Eunmount[] = "not mounted";
-char Eunion[] = "not in union";
-char Emountrpc[] = "mount rpc error";
-char Eshutdown[] = "device shut down";
-char Enocreate[] = "mounted directory forbids creation";
-char Enonexist[] = "file does not exist";
-char Eexist[] = "file already exists";
-char Ebadsharp[] = "unknown device in # filename";
-char Enotdir[] = "not a directory";
-char Eisdir[] = "file is a directory";
-char Ebadchar[] = "bad character in file name";
-char Efilename[] = "file name syntax";
-char Eperm[] = "permission denied";
-char Ebadusefd[] = "inappropriate use of fd";
-char Ebadarg[] = "bad arg in system call";
-char Einuse[] = "device or object already in use";
-char Eio[] = "i/o error";
-char Etoobig[] = "read or write too large";
-char Etoosmall[] = "read or write too small";
-char Enoport[] = "network port not available";
-char Ehungup[] = "i/o on hungup channel";
-char Ebadctl[] = "bad process or channel control request";
-char Enodev[] = "no free devices";
-char Eprocdied[] = "process exited";
-char Enochild[] = "no living children";
-char Eioload[] = "i/o error in demand load";
-char Enovmem[] = "virtual memory allocation failed";
-char Ebadfd[] = "fd out of range or not open";
-char Enofd[] = "no free file descriptors";
-char Eisstream[] = "seek on a stream";
-char Ebadexec[] = "exec header invalid";
-char Etimedout[] = "connection timed out";
-char Econrefused[] = "connection refused";
-char Econinuse[] = "connection in use";
-char Eintr[] = "interrupted";
-char Enomem[] = "kernel allocate failed";
-char Enoswap[] = "swap space full";
-char Esoverlap[] = "segments overlap";
-char Emouseset[] = "mouse type already set";
-char Eshort[] = "i/o count too small";
-char Egreg[] = "ken has left the building";
-char Ebadspec[] = "bad attach specifier";
-char Enoreg[] = "process has no saved registers";
-char Enoattach[] = "mount/attach disallowed";
-char Eshortstat[] = "stat buffer too small";
-char Ebadstat[] = "malformed stat buffer";
-char Enegoff[] = "negative i/o offset";
-char Ecmdargs[] = "wrong #args in control message";

+ 2 - 0
sys/src/9/pc/ether8139.c

@@ -636,6 +636,8 @@ static struct {
 } rtl8139pci[] = {
 } rtl8139pci[] = {
 	{ "rtl8139",	(0x8139<<16)|0x10EC, },	/* generic */
 	{ "rtl8139",	(0x8139<<16)|0x10EC, },	/* generic */
 	{ "smc1211",	(0x1211<<16)|0x1113, },	/* SMC EZ-Card */
 	{ "smc1211",	(0x1211<<16)|0x1113, },	/* SMC EZ-Card */
+	{ "dfe-538tx",	(0x1300<<16)|0x1186, }, /* D-Link DFE-538TX */
+	{ "dfe-560txd",	(0x1340<<16)|0x1186, }, /* D-Link DFE-560TXD */
 	{ nil },
 	{ nil },
 };
 };
 
 

+ 3 - 7
sys/src/9/pc/ether82543gc.c

@@ -377,7 +377,6 @@ typedef struct Ctlr {
 	Block*	tb[Ntdesc];		/* transmit buffers */
 	Block*	tb[Ntdesc];		/* transmit buffers */
 	int	tdh;			/* transmit descriptor head */
 	int	tdh;			/* transmit descriptor head */
 	int	tdt;			/* transmit descriptor tail */
 	int	tdt;			/* transmit descriptor tail */
-	Rendez	timer;			/* watchdog timer */
 	int	txstalled;		/* count of times unable to send */
 	int	txstalled;		/* count of times unable to send */
 
 
 	int	txcw;
 	int	txcw;
@@ -1228,8 +1227,7 @@ gc82543watchdog(void* arg)
 
 
 	edev = arg;
 	edev = arg;
 	for(;;){
 	for(;;){
-		ctlr = edev->ctlr;
-		tsleep(&ctlr->timer, return0, 0, 1000);
+		tsleep(&up->sleep, return0, 0, 1000);
 
 
 		ctlr = edev->ctlr;
 		ctlr = edev->ctlr;
 		if(ctlr == nil){
 		if(ctlr == nil){
@@ -1256,14 +1254,12 @@ gc82543pci(void)
 
 
 		switch((p->did<<16)|p->vid){
 		switch((p->did<<16)|p->vid){
 		case (0x1000<<16)|0x8086:	/* LSI L2A1157 (82542) */
 		case (0x1000<<16)|0x8086:	/* LSI L2A1157 (82542) */
+		case (0x1004<<16)|0x8086:	/* Intel PRO/1000 T */
+		case (0x1008<<16)|0x8086:	/* Intel PRO/1000 XT */
 		default:
 		default:
 			continue;
 			continue;
 		case (0x1001<<16)|0x8086:	/* Intel PRO/1000 F */
 		case (0x1001<<16)|0x8086:	/* Intel PRO/1000 F */
 			break;
 			break;
-		case (0x1004<<16)|0x8086:	/* Intel PRO/1000 T */
-			break;
-		case (0x1008<<16)|0x8086:	/* Intel PRO/1000 XT */
-			break;
 		}
 		}
 
 
 		port = upamalloc(p->mem[0].bar & ~0x0F, p->mem[0].size, 0);
 		port = upamalloc(p->mem[0].bar & ~0x0F, p->mem[0].size, 0);

+ 1 - 3
sys/src/9/pc/ether82557.c

@@ -198,7 +198,6 @@ typedef struct Ctlr {
 
 
 	Lock	miilock;
 	Lock	miilock;
 
 
-	Rendez	timer;			/* watchdog timer for receive lockup errata */
 	int	tick;
 	int	tick;
 
 
 	Lock	rlock;			/* registers */
 	Lock	rlock;			/* registers */
@@ -349,8 +348,7 @@ watchdog(void* arg)
 
 
 	ether = arg;
 	ether = arg;
 	for(;;){
 	for(;;){
-		ctlr = ether->ctlr;
-		tsleep(&ctlr->timer, return0, 0, 4000);
+		tsleep(&up->sleep, return0, 0, 4000);
 
 
 		/*
 		/*
 		 * Hmmm. This doesn't seem right. Currently
 		 * Hmmm. This doesn't seem right. Currently

+ 0 - 3
sys/src/9/pc/floppy.h

@@ -30,8 +30,6 @@ struct FDrive
 	uchar	*cache;		/* track cache */
 	uchar	*cache;		/* track cache */
 	int	ccyl;
 	int	ccyl;
 	int	chead;
 	int	chead;
-
-	Rendez	r;		/* waiting here for motor to spin up */
 };
 };
 
 
 /*
 /*
@@ -52,7 +50,6 @@ struct FController
 	int	confused;	/* controler needs to be reset */
 	int	confused;	/* controler needs to be reset */
 	Rendez	r;		/* wait here for command termination */
 	Rendez	r;		/* wait here for command termination */
 	int	motor;		/* bit mask of spinning disks */
 	int	motor;		/* bit mask of spinning disks */
-	Rendez	kr;		/* for motor watcher */
 };
 };
 
 
 /*
 /*

+ 7 - 10
sys/src/9/pc/i8253.c

@@ -66,6 +66,8 @@ static struct
 
 
 	ushort	last;		/* last value of clock 1 */
 	ushort	last;		/* last value of clock 1 */
 	uvlong	ticks;		/* cumulative ticks of counter 1 */
 	uvlong	ticks;		/* cumulative ticks of counter 1 */
+
+	ulong	periodset;
 }i8253;
 }i8253;
 
 
 
 
@@ -185,9 +187,6 @@ guesscpuhz(int aalcycles)
 	i8253.hz = Freq<<Tickshift;
 	i8253.hz = Freq<<Tickshift;
 }
 }
 
 
-ulong i8253periodset;
-int i8253dotimerset = 1;
-
 ulong phist[128];
 ulong phist[128];
 
 
 void
 void
@@ -197,14 +196,11 @@ i8253timerset(uvlong next)
 	ulong want;
 	ulong want;
 	ulong now;
 	ulong now;
 
 
-	if(i8253dotimerset == 0)
-		return;
-
-	want = next>>Tickshift;
-	now = i8253.ticks;	/* assuming whomever called us just did fastticks() */
-
 	period = MaxPeriod;
 	period = MaxPeriod;
 	if(next != 0){
 	if(next != 0){
+		want = next>>Tickshift;
+		now = i8253.ticks;	/* assuming whomever called us just did fastticks() */
+
 		period = want - now;
 		period = want - now;
 		if(period < MinPeriod)
 		if(period < MinPeriod)
 			period = MinPeriod;
 			period = MinPeriod;
@@ -224,7 +220,7 @@ phist[nelem(phist)-1] = period;
 
 
 		/* remember period */
 		/* remember period */
 		i8253.period = period;
 		i8253.period = period;
-		i8253periodset++;
+		i8253.periodset++;
 		iunlock(&i8253);
 		iunlock(&i8253);
 	}
 	}
 }
 }
@@ -238,6 +234,7 @@ i8253clock(Ureg* ureg, void*)
 void
 void
 i8253enable(void)
 i8253enable(void)
 {
 {
+print("i8253enable...");
 	i8253.enabled = 1;
 	i8253.enabled = 1;
 	i8253.period = Freq/HZ;
 	i8253.period = Freq/HZ;
 	intrenable(IrqCLOCK, i8253clock, 0, BUSUNKNOWN, "clock");
 	intrenable(IrqCLOCK, i8253clock, 0, BUSUNKNOWN, "clock");

+ 2 - 1
sys/src/9/pc/l.s

@@ -7,7 +7,7 @@
  * Some machine instructions not handled by 8[al].
  * Some machine instructions not handled by 8[al].
  */
  */
 #define OP16		BYTE $0x66
 #define OP16		BYTE $0x66
-#define	DELAY		BYTE $0xEB; BYTE $0x00	/* JMP .+2 */
+#define DELAY		BYTE $0xEB; BYTE $0x00	/* JMP .+2 */
 #define CPUID		BYTE $0x0F; BYTE $0xA2	/* CPUID, argument in AX */
 #define CPUID		BYTE $0x0F; BYTE $0xA2	/* CPUID, argument in AX */
 #define WRMSR		BYTE $0x0F; BYTE $0x30	/* WRMSR, argument in AX/DX (lo/hi) */
 #define WRMSR		BYTE $0x0F; BYTE $0x30	/* WRMSR, argument in AX/DX (lo/hi) */
 #define RDMSR		BYTE $0x0F; BYTE $0x32	/* RDMSR, result in AX/DX (lo/hi) */
 #define RDMSR		BYTE $0x0F; BYTE $0x32	/* RDMSR, result in AX/DX (lo/hi) */
@@ -827,3 +827,4 @@ TEXT vectortable(SB), $0
 	CALL _strayintr(SB); BYTE $0xFD
 	CALL _strayintr(SB); BYTE $0xFD
 	CALL _strayintr(SB); BYTE $0xFE
 	CALL _strayintr(SB); BYTE $0xFE
 	CALL _strayintr(SB); BYTE $0xFF
 	CALL _strayintr(SB); BYTE $0xFF
+

+ 5 - 4
sys/src/9/pc/main.c

@@ -86,7 +86,7 @@ main(void)
 	screeninit();
 	screeninit();
 	meminit();
 	meminit();
 	confinit();
 	confinit();
-	archinit();
+	archinit();	/* launches other processors on an mp */
 	xinit();
 	xinit();
 	trapinit();
 	trapinit();
 	printinit();
 	printinit();
@@ -102,10 +102,10 @@ main(void)
 	procinit0();
 	procinit0();
 	initseg();
 	initseg();
 	links();
 	links();
-conf.monitor = 1;
+	conf.monitor = 1;
 	chandevreset();
 	chandevreset();
-	i8253link();
 	pageinit();
 	pageinit();
+	i8253link();
 	swapinit();
 	swapinit();
 	userinit();
 	userinit();
 	schedinit();
 	schedinit();
@@ -619,7 +619,8 @@ shutdown(int ispanic)
 		if(cpuserver)
 		if(cpuserver)
 			delay(10000);
 			delay(10000);
 		else
 		else
-			for(;;);
+			for(;;)
+				halt();
 	}
 	}
 	else
 	else
 		delay(1000);
 		delay(1000);

+ 3 - 2
sys/src/9/pc/pc

@@ -45,7 +45,7 @@ link
 	ether8139
 	ether8139
 	ether82543gc	pci
 	ether82543gc	pci
 	ether82557	pci
 	ether82557	pci
-	ether83815
+	ether83815	pci
 	etherec2t	ether8390
 	etherec2t	ether8390
 	etherelnk3	pci
 	etherelnk3	pci
 	etherga620	pci
 	etherga620	pci
@@ -56,6 +56,7 @@ link
 	ethermedium
 	ethermedium
 	pcmciamodem
 	pcmciamodem
 	netdevmedium
 	netdevmedium
+	loopbackmedium
 	usbuhci
 	usbuhci
 
 
 misc
 misc
@@ -108,4 +109,4 @@ boot
 bootdir
 bootdir
 	bootpc.out boot
 	bootpc.out boot
 	/386/bin/ip/ipconfig
 	/386/bin/ip/ipconfig
-	factotum.hack factotum
+	/386/bin/auth/factotum

+ 2 - 1
sys/src/9/pc/pcauth

@@ -23,6 +23,7 @@ dev
 	vga
 	vga
 
 
 	sd
 	sd
+	fs
 	floppy		dma
 	floppy		dma
 
 
 	uart
 	uart
@@ -61,5 +62,5 @@ boot cpu boot #S/sdC0/
 bootdir
 bootdir
 	bootpcauth.out boot
 	bootpcauth.out boot
 	/386/bin/ip/ipconfig
 	/386/bin/ip/ipconfig
-	factotum.hack factotum
+	/386/bin/auth/factotum
 	/386/bin/disk/kfs
 	/386/bin/disk/kfs

+ 7 - 3
sys/src/9/pc/pcdisk

@@ -24,6 +24,7 @@ dev
 	vga
 	vga
 
 
 	sd
 	sd
+	fs
 	floppy		dma
 	floppy		dma
 	lpt
 	lpt
 
 
@@ -43,18 +44,20 @@ link
 	ether79c970	pci
 	ether79c970	pci
 	ether8003	ether8390
 	ether8003	ether8390
 	ether8139
 	ether8139
-	ether82557	pci
 	ether82543gc	pci
 	ether82543gc	pci
+	ether82557	pci
 	ether83815	pci
 	ether83815	pci
 	etherec2t	ether8390
 	etherec2t	ether8390
-	etherga620	pci
 	etherelnk3	pci
 	etherelnk3	pci
+	etherga620	pci
+	etherigbe	pci ethermii
 	ethersink
 	ethersink
 	ethersmc	devi82365 cis
 	ethersmc	devi82365 cis
 	etherwavelan	wavelan devi82365 cis pci
 	etherwavelan	wavelan devi82365 cis pci
 	ethermedium
 	ethermedium
 	pcmciamodem
 	pcmciamodem
 	netdevmedium
 	netdevmedium
+	loopbackmedium
 	usbuhci
 	usbuhci
 
 
 misc
 misc
@@ -65,6 +68,7 @@ misc
 	sdmylex		pci sdscsi
 	sdmylex		pci sdscsi
 
 
 	uarti8250
 	uarti8250
+	uartpci		pci
 
 
 	vga3dfx		+cur
 	vga3dfx		+cur
 	vgaark2000pv	+cur
 	vgaark2000pv	+cur
@@ -107,6 +111,6 @@ boot boot #S/sdC0/
 bootdir
 bootdir
 	bootpcdisk.out boot
 	bootpcdisk.out boot
 	/386/bin/ip/ipconfig
 	/386/bin/ip/ipconfig
-	factotum.hack factotum
+	/386/bin/auth/factotum
 	/386/bin/disk/kfs
 	/386/bin/disk/kfs
 	/386/bin/cfs
 	/386/bin/cfs

+ 1 - 0
sys/src/9/pc/pcflop

@@ -49,6 +49,7 @@ link
 	etherec2t	ether8390
 	etherec2t	ether8390
 	etherelnk3	pci
 	etherelnk3	pci
 	etherga620	pci
 	etherga620	pci
+	etherigbe pci ethermii
 #	ethersink
 #	ethersink
 	ethersmc	devi82365 cis
 	ethersmc	devi82365 cis
 	etherwavelan	wavelan devi82365 cis pci
 	etherwavelan	wavelan devi82365 cis pci

+ 74 - 32
sys/src/9/pc/sd53c8xx.c

@@ -391,8 +391,9 @@ dsaalloc(Controller *c, int target, int lun)
 	ilock(&c->dsalist);
 	ilock(&c->dsalist);
 	if ((d = c->dsalist.freechain) == 0) {
 	if ((d = c->dsalist.freechain) == 0) {
 		d = xalloc(sizeof(*d));
 		d = xalloc(sizeof(*d));
-		if (DEBUG(1))
+		if (DEBUG(1)) {
 			KPRINT(PRINTPREFIX "%d/%d: allocated new dsa %lux\n", target, lun, (ulong)d);
 			KPRINT(PRINTPREFIX "%d/%d: allocated new dsa %lux\n", target, lun, (ulong)d);
+		}
 		lesetl(d->next, 0);
 		lesetl(d->next, 0);
 		lesetl(&d->stateb, A_STATE_ALLOCATED);
 		lesetl(&d->stateb, A_STATE_ALLOCATED);
 		if (legetl(c->dsalist.head) == 0)
 		if (legetl(c->dsalist.head) == 0)
@@ -402,8 +403,9 @@ dsaalloc(Controller *c, int target, int lun)
 		c->dsalist.tail = d;
 		c->dsalist.tail = d;
 	}
 	}
 	else {
 	else {
-		if (DEBUG(1))
+		if (DEBUG(1)) {
 			KPRINT(PRINTPREFIX "%d/%d: reused dsa %lux\n", target, lun, (ulong)d);
 			KPRINT(PRINTPREFIX "%d/%d: reused dsa %lux\n", target, lun, (ulong)d);
+		}
 		c->dsalist.freechain = d->freechain;
 		c->dsalist.freechain = d->freechain;
 		lesetl(&d->stateb, A_STATE_ALLOCATED);
 		lesetl(&d->stateb, A_STATE_ALLOCATED);
 	}
 	}
@@ -446,7 +448,12 @@ dumpncrregs(Controller *c, int intr)
 	Ncr *n = c->n;
 	Ncr *n = c->n;
 	int depth = c->v->registers / 4;
 	int depth = c->v->registers / 4;
 
 
-	KPRINT("sa = %.8lux\n", c->scriptpa);
+	if (intr) {
+		IPRINT("sa = %.8lux\n", c->scriptpa);
+	}
+	else {
+		KPRINT("sa = %.8lux\n", c->scriptpa);
+	}
 	for (i = 0; i < depth; i++) {
 	for (i = 0; i < depth; i++) {
 		int j;
 		int j;
 		for (j = 0; j < 4; j++) {
 		for (j = 0; j < 4; j++) {
@@ -455,16 +462,20 @@ dumpncrregs(Controller *c, int intr)
 
 
 			/* display little-endian to make 32-bit values readable */
 			/* display little-endian to make 32-bit values readable */
 			p = (uchar*)n+k*4;
 			p = (uchar*)n+k*4;
-			if (intr)
+			if (intr) {
 				IPRINT(" %.2x%.2x%.2x%.2x %.2x %.2x", p[3], p[2], p[1], p[0], k * 4, (k * 4) + 0x80);
 				IPRINT(" %.2x%.2x%.2x%.2x %.2x %.2x", p[3], p[2], p[1], p[0], k * 4, (k * 4) + 0x80);
-			else
+			}
+			else {
 				KPRINT(" %.2x%.2x%.2x%.2x %.2x %.2x", p[3], p[2], p[1], p[0], k * 4, (k * 4) + 0x80);
 				KPRINT(" %.2x%.2x%.2x%.2x %.2x %.2x", p[3], p[2], p[1], p[0], k * 4, (k * 4) + 0x80);
+			}
 			USED(p);
 			USED(p);
 		}
 		}
-		if (intr)
+		if (intr) {
 			IPRINT("\n");
 			IPRINT("\n");
-		else
+		}
+		else {
 			KPRINT("\n");
 			KPRINT("\n");
+		}
 	}
 	}
 }	
 }	
 
 
@@ -1119,33 +1130,38 @@ sd53c8xxinterrupt(Ureg *ur, void *a)
 	Ncr *n = c->n;
 	Ncr *n = c->n;
 
 
 	USED(ur);
 	USED(ur);
-	if (DEBUG(1))
+	if (DEBUG(1)) {
 		IPRINT(PRINTPREFIX "int\n");
 		IPRINT(PRINTPREFIX "int\n");
+	}
 	ilock(c);
 	ilock(c);
 	istat = n->istat;
 	istat = n->istat;
 	if (istat & Intf) {
 	if (istat & Intf) {
 		Dsa *d;
 		Dsa *d;
 		int wokesomething = 0;
 		int wokesomething = 0;
-		if (DEBUG(1))
+		if (DEBUG(1)) {
 			IPRINT(PRINTPREFIX "Intfly\n");
 			IPRINT(PRINTPREFIX "Intfly\n");
+		}
 		n->istat = Intf;
 		n->istat = Intf;
 		/* search for structures in A_STATE_DONE */
 		/* search for structures in A_STATE_DONE */
 		for (d = KPTR(legetl(c->dsalist.head)); d; d = KPTR(legetl(d->next))) {
 		for (d = KPTR(legetl(c->dsalist.head)); d; d = KPTR(legetl(d->next))) {
 			if (d->stateb == A_STATE_DONE) {
 			if (d->stateb == A_STATE_DONE) {
 				d->p9status = d->status;
 				d->p9status = d->status;
-				if (DEBUG(1))
+				if (DEBUG(1)) {
 					IPRINT(PRINTPREFIX "waking up dsa %lux\n", (ulong)d);
 					IPRINT(PRINTPREFIX "waking up dsa %lux\n", (ulong)d);
+				}
 				wakeup(d);
 				wakeup(d);
 				wokesomething = 1;
 				wokesomething = 1;
 			}
 			}
 		}
 		}
-		if (!wokesomething)
+		if (!wokesomething) {
 			IPRINT(PRINTPREFIX "nothing to wake up\n");
 			IPRINT(PRINTPREFIX "nothing to wake up\n");
+		}
 	}
 	}
 
 
 	if ((istat & (Sip | Dip)) == 0) {
 	if ((istat & (Sip | Dip)) == 0) {
-		if (DEBUG(1))
+		if (DEBUG(1)) {
 			IPRINT(PRINTPREFIX "int end %x\n", istat);
 			IPRINT(PRINTPREFIX "int end %x\n", istat);
+		}
 		iunlock(c);
 		iunlock(c);
 		return;
 		return;
 	}
 	}
@@ -1155,8 +1171,9 @@ sd53c8xxinterrupt(Ureg *ur, void *a)
 	dsa = (Dsa *)DMASEG_TO_KADDR(legetl(n->dsa));
 	dsa = (Dsa *)DMASEG_TO_KADDR(legetl(n->dsa));
 	c->running = 0;
 	c->running = 0;
 	if (istat & Sip) {
 	if (istat & Sip) {
-		if (DEBUG(1))
+		if (DEBUG(1)) {
 			IPRINT("sist = %.4x\n", sist);
 			IPRINT("sist = %.4x\n", sist);
+		}
 		if (sist & 0x80) {
 		if (sist & 0x80) {
 			ulong addr;
 			ulong addr;
 			ulong sa;
 			ulong sa;
@@ -1167,9 +1184,10 @@ sd53c8xxinterrupt(Ureg *ur, void *a)
 
 
 			addr = legetl(n->dsp);
 			addr = legetl(n->dsp);
 			sa = addr - c->scriptpa;
 			sa = addr - c->scriptpa;
-			if (DEBUG(1) || DEBUG(2))
+			if (DEBUG(1) || DEBUG(2)) {
 				IPRINT(PRINTPREFIX "%d/%d: Phase Mismatch sa=%.8lux\n",
 				IPRINT(PRINTPREFIX "%d/%d: Phase Mismatch sa=%.8lux\n",
 				    dsa->target, dsa->lun, sa);
 				    dsa->target, dsa->lun, sa);
+			}
 			/*
 			/*
 			 * now recover
 			 * now recover
 			 */
 			 */
@@ -1184,9 +1202,10 @@ sd53c8xxinterrupt(Ureg *ur, void *a)
 				dsa->dmablks = 0;
 				dsa->dmablks = 0;
 				n->scratcha[2] = 0;
 				n->scratcha[2] = 0;
 				advancedata(&dsa->data_buf, tbc);
 				advancedata(&dsa->data_buf, tbc);
-				if (DEBUG(1) || DEBUG(2))
+				if (DEBUG(1) || DEBUG(2)) {
 					IPRINT(PRINTPREFIX "%d/%d: transferred = %ld residue = %ld\n",
 					IPRINT(PRINTPREFIX "%d/%d: transferred = %ld residue = %ld\n",
 					    dsa->target, dsa->lun, tbc, legetl(dsa->data_buf.dbc));
 					    dsa->target, dsa->lun, tbc, legetl(dsa->data_buf.dbc));
+				}
 				cont = E_data_mismatch_recover;
 				cont = E_data_mismatch_recover;
 			}
 			}
 			else if (sa == E_data_in_block_mismatch) {
 			else if (sa == E_data_in_block_mismatch) {
@@ -1216,9 +1235,10 @@ sd53c8xxinterrupt(Ureg *ur, void *a)
 				dsa->dmablks = 0;
 				dsa->dmablks = 0;
 				n->scratcha[2] = 0;
 				n->scratcha[2] = 0;
 				advancedata(&dsa->data_buf, tbc);
 				advancedata(&dsa->data_buf, tbc);
-				if (DEBUG(1) || DEBUG(2))
+				if (DEBUG(1) || DEBUG(2)) {
 					IPRINT(PRINTPREFIX "%d/%d: transferred = %ld residue = %ld\n",
 					IPRINT(PRINTPREFIX "%d/%d: transferred = %ld residue = %ld\n",
 					    dsa->target, dsa->lun, tbc, legetl(dsa->data_buf.dbc));
 					    dsa->target, dsa->lun, tbc, legetl(dsa->data_buf.dbc));
+				}
 				cont = E_data_mismatch_recover;
 				cont = E_data_mismatch_recover;
 			}
 			}
 			else if (sa == E_data_out_block_mismatch) {
 			else if (sa == E_data_out_block_mismatch) {
@@ -1290,8 +1310,9 @@ sd53c8xxinterrupt(Ureg *ur, void *a)
 			}
 			}
 		}
 		}
 		/*else*/ if (sist & 0x400) {
 		/*else*/ if (sist & 0x400) {
-			if (DEBUG(0))
+			if (DEBUG(0)) {
 				IPRINT(PRINTPREFIX "%d/%d Sto\n", dsa->target, dsa->lun);
 				IPRINT(PRINTPREFIX "%d/%d Sto\n", dsa->target, dsa->lun);
+			}
 			dsa->p9status = SDtimeout;
 			dsa->p9status = SDtimeout;
 			dsa->stateb = A_STATE_DONE;
 			dsa->stateb = A_STATE_DONE;
 			softreset(c);
 			softreset(c);
@@ -1311,8 +1332,9 @@ sd53c8xxinterrupt(Ureg *ur, void *a)
 		}
 		}
 	}
 	}
 	if (istat & Dip) {
 	if (istat & Dip) {
-		if (DEBUG(1))
+		if (DEBUG(1)) {
 			IPRINT("dstat = %.2x\n", dstat);
 			IPRINT("dstat = %.2x\n", dstat);
+		}
 		/*else*/ if (dstat & Ssi) {
 		/*else*/ if (dstat & Ssi) {
 			ulong *p = DMASEG_TO_KADDR(legetl(n->dsp));
 			ulong *p = DMASEG_TO_KADDR(legetl(n->dsp));
 			ulong w = (uchar *)p - (uchar *)c->script;
 			ulong w = (uchar *)p - (uchar *)c->script;
@@ -1336,9 +1358,10 @@ sd53c8xxinterrupt(Ureg *ur, void *a)
 				/* back up one in the data transfer */
 				/* back up one in the data transfer */
 				IPRINT(PRINTPREFIX "%d/%d: ignore wide residue %d, WSR = %d\n",
 				IPRINT(PRINTPREFIX "%d/%d: ignore wide residue %d, WSR = %d\n",
 				    dsa->target, dsa->lun, n->scratcha[1], n->scntl2 & 1);
 				    dsa->target, dsa->lun, n->scratcha[1], n->scntl2 & 1);
-				if (dsa->flag == 2)
+				if (dsa->flag == 2) {
 					IPRINT(PRINTPREFIX "%d/%d: transfer over; residue ignored\n",
 					IPRINT(PRINTPREFIX "%d/%d: transfer over; residue ignored\n",
 					    dsa->target, dsa->lun);
 					    dsa->target, dsa->lun);
+				}
 				else {
 				else {
 					calcblockdma(dsa, legetl(dsa->dmaaddr) - 1,
 					calcblockdma(dsa, legetl(dsa->dmaaddr) - 1,
 					    dsa->dmablks * A_BSIZE + legetl(dsa->data_buf.dbc) + 1);
 					    dsa->dmablks * A_BSIZE + legetl(dsa->data_buf.dbc) + 1);
@@ -1427,8 +1450,9 @@ sd53c8xxinterrupt(Ureg *ur, void *a)
 				ulong *dsp = DMASEG_TO_KADDR(legetl(n->dsp));
 				ulong *dsp = DMASEG_TO_KADDR(legetl(n->dsp));
 				int x;
 				int x;
 				IPRINT(PRINTPREFIX "code at %lux", dsp - c->script);
 				IPRINT(PRINTPREFIX "code at %lux", dsp - c->script);
-				for (x = 0; x < 6; x++)
+				for (x = 0; x < 6; x++) {
 					IPRINT(" %.8lux", dsp[x]);
 					IPRINT(" %.8lux", dsp[x]);
+				}
 				IPRINT("\n");
 				IPRINT("\n");
 				USED(dsp);
 				USED(dsp);
 				cont = -2;
 				cont = -2;
@@ -1444,15 +1468,18 @@ sd53c8xxinterrupt(Ureg *ur, void *a)
 				cont = -2;
 				cont = -2;
 				break;
 				break;
 			case A_SIR_NOTIFY_RESELECTED_ON_SELECT:
 			case A_SIR_NOTIFY_RESELECTED_ON_SELECT:
-				IPRINT(PRINTPREFIX "%d/%d: reselected during select\n",
-				    dsa->target, dsa->lun);
+				if (DEBUG(2)) {
+					IPRINT(PRINTPREFIX "%d/%d: reselected during select\n",
+ 					    dsa->target, dsa->lun);
+				}
 				cont = -2;
 				cont = -2;
 				break;
 				break;
 			case A_error_reselected:		/* dsa isn't valid here */
 			case A_error_reselected:		/* dsa isn't valid here */
 				print(PRINTPREFIX "reselection error\n");
 				print(PRINTPREFIX "reselection error\n");
 				dumpncrregs(c, 1);
 				dumpncrregs(c, 1);
-				for (dsa = KPTR(legetl(c->dsalist.head)); dsa; dsa = KPTR(legetl(dsa->next)))
+				for (dsa = KPTR(legetl(c->dsalist.head)); dsa; dsa = KPTR(legetl(dsa->next))) {
 					IPRINT(PRINTPREFIX "dsa target %d lun %d state %d\n", dsa->target, dsa->lun, dsa->stateb);
 					IPRINT(PRINTPREFIX "dsa target %d lun %d state %d\n", dsa->target, dsa->lun, dsa->stateb);
+				}
 				break;
 				break;
 			default:
 			default:
 				IPRINT(PRINTPREFIX "%d/%d: script error %ld\n",
 				IPRINT(PRINTPREFIX "%d/%d: script error %ld\n",
@@ -1534,8 +1561,9 @@ dumpwritedata(uchar *data, int datalen)
 
 
 	if (datalen) {
 	if (datalen) {
 		KPRINT(PRINTPREFIX "write:");
 		KPRINT(PRINTPREFIX "write:");
-		for (i = 0, bp = data; i < 50 && i < datalen; i++, bp++)
+		for (i = 0, bp = data; i < 50 && i < datalen; i++, bp++) {
 			KPRINT("%.2ux", *bp);
 			KPRINT("%.2ux", *bp);
+		}
 		if (i < datalen) {
 		if (i < datalen) {
 			KPRINT("...");
 			KPRINT("...");
 		}
 		}
@@ -1555,8 +1583,9 @@ dumpreaddata(uchar *data, int datalen)
 
 
 	if (datalen) {
 	if (datalen) {
 		KPRINT(PRINTPREFIX "read:");
 		KPRINT(PRINTPREFIX "read:");
-		for (i = 0, bp = data; i < 50 && i < datalen; i++, bp++)
+		for (i = 0, bp = data; i < 50 && i < datalen; i++, bp++) {
 			KPRINT("%.2ux", *bp);
 			KPRINT("%.2ux", *bp);
+		}
 		if (i < datalen) {
 		if (i < datalen) {
 			KPRINT("...");
 			KPRINT("...");
 		}
 		}
@@ -1601,7 +1630,7 @@ sd53c8xxrio(SDreq* r)
 	uchar *bp;
 	uchar *bp;
 	Controller *c;
 	Controller *c;
 	uchar target_expo, my_expo;
 	uchar target_expo, my_expo;
-	int bc, check, status, target;
+	int bc, check, i, status, target;
 
 
 	if((target = r->unit->subno) == 0x07)
 	if((target = r->unit->subno) == 0x07)
 		return r->status = SDtimeout;	/* assign */
 		return r->status = SDtimeout;	/* assign */
@@ -1677,12 +1706,14 @@ docheck:
 
 
 	if (DEBUG(0)) {
 	if (DEBUG(0)) {
 		KPRINT(PRINTPREFIX "%d/%d: exec: ", target, r->lun);
 		KPRINT(PRINTPREFIX "%d/%d: exec: ", target, r->lun);
-		for (bp = r->cmd; bp < &r->cmd[r->clen]; bp++)
+		for (bp = r->cmd; bp < &r->cmd[r->clen]; bp++) {
 			KPRINT("%.2ux", *bp);
 			KPRINT("%.2ux", *bp);
+		}
 		KPRINT("\n");
 		KPRINT("\n");
-		if (!r->write)
+		if (!r->write) {
 			KPRINT(PRINTPREFIX "%d/%d: exec: limit=(%d)%ld\n",
 			KPRINT(PRINTPREFIX "%d/%d: exec: limit=(%d)%ld\n",
 			  target, r->lun, d->dmablks, legetl(d->data_buf.dbc));
 			  target, r->lun, d->dmablks, legetl(d->data_buf.dbc));
+		}
 		else
 		else
 			dumpwritedata(r->data, r->dlen);
 			dumpwritedata(r->data, r->dlen);
 	}
 	}
@@ -1730,9 +1761,10 @@ docheck:
 	 * adjust datalen
 	 * adjust datalen
 	 */
 	 */
 	r->rlen = r->dlen;
 	r->rlen = r->dlen;
-	if (DEBUG(0))
+	if (DEBUG(0)) {
 		KPRINT(PRINTPREFIX "%d/%d: exec: before rlen adjust: dmablks %d flag %d dbc %lud\n",
 		KPRINT(PRINTPREFIX "%d/%d: exec: before rlen adjust: dmablks %d flag %d dbc %lud\n",
 		    target, r->lun, d->dmablks, d->flag, legetl(d->data_buf.dbc));
 		    target, r->lun, d->dmablks, d->flag, legetl(d->data_buf.dbc));
+	}
 	r->rlen = r->dlen;
 	r->rlen = r->dlen;
 	if (d->flag != 2) {
 	if (d->flag != 2) {
 		r->rlen -= d->dmablks * A_BSIZE;
 		r->rlen -= d->dmablks * A_BSIZE;
@@ -1740,9 +1772,10 @@ docheck:
 	}
 	}
 	if(!r->write)
 	if(!r->write)
 		dumpreaddata(r->data, r->rlen);
 		dumpreaddata(r->data, r->rlen);
-	if (DEBUG(0))
+	if (DEBUG(0)) {
 		KPRINT(PRINTPREFIX "%d/%d: exec: p9status=%d status %d rlen %ld\n",
 		KPRINT(PRINTPREFIX "%d/%d: exec: p9status=%d status %d rlen %ld\n",
 		    target, r->lun, d->p9status, status, r->rlen);
 		    target, r->lun, d->p9status, status, r->rlen);
+	}
 	/*
 	/*
 	 * spot the identify
 	 * spot the identify
 	 */
 	 */
@@ -1778,8 +1811,17 @@ docheck:
 		status = SDcheck;
 		status = SDcheck;
 		r->flags |= SDvalidsense;
 		r->flags |= SDvalidsense;
 	}
 	}
-	KPRINT(PRINTPREFIX "%d: r flags %8.8uX status %d rlen %ld\n",
-		target, r->flags, status, r->rlen);
+	if(DEBUG(0))
+		KPRINT(PRINTPREFIX "%d: r flags %8.8uX status %d rlen %ld\n",
+			target, r->flags, status, r->rlen);
+	if(r->flags & SDvalidsense){
+		if(!DEBUG(0))
+			KPRINT(PRINTPREFIX "%d: r flags %8.8uX status %d rlen %ld\n",
+				target, r->flags, status, r->rlen);
+		for(i = 0; i < r->rlen; i++)
+			KPRINT(" %2.2uX", r->sense[i]);
+		KPRINT("\n");
+	}
 	return r->status = status;
 	return r->status = status;
 }
 }
 
 

+ 1 - 1
sys/src/9/pc/sdscsi.c

@@ -157,7 +157,7 @@ scsirio(SDreq* r)
 
 
 			while(waserror())
 			while(waserror())
 				;
 				;
-			tsleep(&r->unit->rendez, return0, 0, 500);
+			tsleep(&up->sleep, return0, 0, 500);
 			poperror();
 			poperror();
 			scsitest(r);
 			scsitest(r);
 			return 2;
 			return 2;

+ 1 - 0
sys/src/9/pc/vgas3.c

@@ -322,6 +322,7 @@ s3move(VGAscr* scr, Point p)
 	vgaxo(Crtx, 0x4E, xo);
 	vgaxo(Crtx, 0x4E, xo);
 	vgaxo(Crtx, 0x4F, yo);
 	vgaxo(Crtx, 0x4F, yo);
 	vgaxo(Crtx, 0x48, (y>>8) & 0x07);
 	vgaxo(Crtx, 0x48, (y>>8) & 0x07);
+	s3vsyncactive();
 
 
 	return 0;
 	return 0;
 }
 }

+ 1 - 1
sys/src/9/pc/wavelan.c

@@ -690,7 +690,7 @@ w_timer(void* arg)
 
 
 	ctlr->timerproc = up;
 	ctlr->timerproc = up;
 	for(;;){
 	for(;;){
-		tsleep(&ctlr->timer, return0, 0, MSperTick);
+		tsleep(&up->sleep, return0, 0, MSperTick);
 		ctlr = (Ctlr*)ether->ctlr;
 		ctlr = (Ctlr*)ether->ctlr;
 		if(ctlr == 0)
 		if(ctlr == 0)
 			break;
 			break;

+ 0 - 1
sys/src/9/pc/wavelan.h

@@ -261,7 +261,6 @@ enum {
 struct Ctlr
 struct Ctlr
 {
 {
 	Lock;
 	Lock;
-	Rendez	timer;
 
 
 	int	state;	// Attached | Power
 	int	state;	// Attached | Power
 	int	slot;
 	int	slot;

+ 0 - 1
sys/src/9/port/auth.c

@@ -75,7 +75,6 @@ sysfauth(ulong *arg)
 	}
 	}
 
 
 	ac = mntauth(c, aname);
 	ac = mntauth(c, aname);
-
 	/* at this point ac is responsible for keeping c alive */
 	/* at this point ac is responsible for keeping c alive */
 	cclose(c);
 	cclose(c);
 	poperror();	/* c */
 	poperror();	/* c */

+ 1 - 1
sys/src/9/port/cache.c

@@ -539,7 +539,7 @@ cupdate(Chan *c, uchar *buf, int len, vlong off)
 			len -= o;
 			len -= o;
 			offset += o;
 			offset += o;
 			if(len <= 0) {
 			if(len <= 0) {
-if (f && p->start + p->len > f->start) print("CACHE: p->start=%uld p->len=%d f->start=%uld\n", p->start, p->len, f->start);
+if(f && p->start + p->len > f->start) print("CACHE: p->start=%uld p->len=%d f->start=%uld\n", p->start, p->len, f->start);
 				qunlock(m);
 				qunlock(m);
 				return;
 				return;
 			}
 			}

+ 49 - 39
sys/src/9/port/chan.c

@@ -49,7 +49,7 @@ dumpmount(void)		/* DEBUGGING */
 
 
 
 
 char*
 char*
-c2name(Chan *c)		/* DEBUGGING */
+channame(Chan *c)		/* DEBUGGING */
 {
 {
 	if(c == nil)
 	if(c == nil)
 		return "<nil chan>";
 		return "<nil chan>";
@@ -243,6 +243,7 @@ newchan(void)
 	c->ref = 1;
 	c->ref = 1;
 	c->dev = 0;
 	c->dev = 0;
 	c->offset = 0;
 	c->offset = 0;
+	c->devoffset = 0;
 	c->iounit = 0;
 	c->iounit = 0;
 	c->umh = 0;
 	c->umh = 0;
 	c->uri = 0;
 	c->uri = 0;
@@ -253,6 +254,7 @@ newchan(void)
 	c->mux = 0;
 	c->mux = 0;
 	memset(&c->mqid, 0, sizeof(c->mqid));
 	memset(&c->mqid, 0, sizeof(c->mqid));
 	c->name = 0;
 	c->name = 0;
+	c->ismtpt = 0;
 	return c;
 	return c;
 }
 }
 
 
@@ -327,6 +329,12 @@ chanfree(Chan *c)
 {
 {
 	c->flag = CFREE;
 	c->flag = CFREE;
 
 
+	if(c->dirrock != nil){
+		free(c->dirrock);
+		c->dirrock = 0;
+		c->nrock = 0;
+		c->mrock = 0;
+	}
 	if(c->umh != nil){
 	if(c->umh != nil){
 		putmhead(c->umh);
 		putmhead(c->umh);
 		c->umh = nil;
 		c->umh = nil;
@@ -655,12 +663,12 @@ findmount(Chan **cp, Mhead **mp, int type, int dev, Qid qid)
 	rlock(&pg->ns);
 	rlock(&pg->ns);
 	for(m = MOUNTH(pg, qid); m; m = m->hash){
 	for(m = MOUNTH(pg, qid); m; m = m->hash){
 		rlock(&m->lock);
 		rlock(&m->lock);
-if(m->from == nil){
-	print("m %p m->from 0\n", m);
-	runlock(&m->lock);
-	continue;
-}
-		if(eqchantdqid(m->from, type, dev, qid, 1)) {
+		if(m->from == nil){
+			print("m %p m->from 0\n", m);
+			runlock(&m->lock);
+			continue;
+		}
+		if(eqchantdqid(m->from, type, dev, qid, 1)){
 			runlock(&pg->ns);
 			runlock(&pg->ns);
 			if(mp != nil){
 			if(mp != nil){
 				incref(m);
 				incref(m);
@@ -771,9 +779,7 @@ walk(Chan **cp, char **names, int nnames, int nomount, int *nerror)
 			cclose(c);
 			cclose(c);
 			strcpy(up->errstr, Enotdir);
 			strcpy(up->errstr, Enotdir);
 			if(mh != nil)
 			if(mh != nil)
-{print("walk 1\n");
 				putmhead(mh);
 				putmhead(mh);
-}
 			return -1;
 			return -1;
 		}
 		}
 		ntry = nnames - nhave;
 		ntry = nnames - nhave;
@@ -801,7 +807,7 @@ walk(Chan **cp, char **names, int nnames, int nomount, int *nerror)
 			/* try a union mount, if any */
 			/* try a union mount, if any */
 			if(mh && !nomount){
 			if(mh && !nomount){
 				/*
 				/*
-				 * mh->mount == c, so start at mh->mount->next
+				 * mh->mount->to == c, so start at mh->mount->next
 				 */
 				 */
 				rlock(&mh->lock);
 				rlock(&mh->lock);
 				for(f = mh->mount->next; f; f = f->next)
 				for(f = mh->mount->next; f; f = f->next)
@@ -825,14 +831,14 @@ walk(Chan **cp, char **names, int nnames, int nomount, int *nerror)
 		}
 		}
 
 
 		nmh = nil;
 		nmh = nil;
-		if(dotdot) {
+		if(dotdot){
 			assert(wq->nqid == 1);
 			assert(wq->nqid == 1);
 			assert(wq->clone != nil);
 			assert(wq->clone != nil);
 
 
 			cname = addelem(cname, "..");
 			cname = addelem(cname, "..");
 			nc = undomount(wq->clone, cname);
 			nc = undomount(wq->clone, cname);
 			n = 1;
 			n = 1;
-		} else {
+		}else{
 			nc = nil;
 			nc = nil;
 			if(!nomount)
 			if(!nomount)
 				for(i=0; i<wq->nqid && i<ntry-1; i++)
 				for(i=0; i<wq->nqid && i<ntry-1; i++)
@@ -1023,26 +1029,42 @@ memrchr(void *va, int c, long n)
 	return nil;
 	return nil;
 }
 }
 
 
+void
+nameerror(char *name, char *error)
+{
+	int len;
+	char tmperr[ERRMAX], *p;
+
+	strcpy(tmperr, error);	/* error might be in genbuf or tmperr */
+	len = strlen(name);
+	if(len < ERRMAX/3 || (p=strrchr(name, '/'))==nil || p==name)
+		snprint(up->genbuf, sizeof up->genbuf, "%s", name);
+	else
+		snprint(up->genbuf, sizeof up->genbuf, "...%s", p);
+	snprint(up->errstr, ERRMAX, "%#q %s", up->genbuf, tmperr);
+	nexterror();
+}
+
 /*
 /*
  * Turn a name into a channel.
  * Turn a name into a channel.
  * &name[0] is known to be a valid address.  It may be a kernel address.
  * &name[0] is known to be a valid address.  It may be a kernel address.
  *
  *
- * Opening with amode Aopen, Acreate, or Aremove guarantees
+ * Opening with amode Aopen, Acreate, Aremove, or Aaccess guarantees
  * that the result will be the only reference to that particular fid.
  * that the result will be the only reference to that particular fid.
  * This is necessary since we might pass the result to
  * This is necessary since we might pass the result to
  * devtab[]->remove().
  * devtab[]->remove().
  *
  *
- * Opening Atodir, Amount, or Aaccess does not guarantee this.
+ * Opening Atodir or Amount does not guarantee this.
  *
  *
- * Opening Aaccess can, under certain conditions, return a
- * correct Chan* but with an incorrect Cname attached.
- * Since the functions that open Aaccess (sysstat, syswstat, sys_stat)
- * do not use the Cname*, this avoids an unnecessary clone.
+ * Under certain circumstances, opening Aaccess will cause
+ * an unnecessary clone in order to get a cunique Chan so it
+ * can attach the correct name.  Sysstat and sys_stat need the
+ * correct name so they can rewrite the stat info.
  */
  */
 Chan*
 Chan*
 namec(char *aname, int amode, int omode, ulong perm)
 namec(char *aname, int amode, int omode, ulong perm)
 {
 {
-	int n, prefix, len, t, nomount, npath;
+	int n, t, nomount, npath;
 	Chan *c, *cnew;
 	Chan *c, *cnew;
 	Cname *cname;
 	Cname *cname;
 	Elemlist e;
 	Elemlist e;
@@ -1107,7 +1129,6 @@ namec(char *aname, int amode, int omode, ulong perm)
 		incref(c);
 		incref(c);
 		break;
 		break;
 	}
 	}
-	prefix = name - aname;
 
 
 	e.name = nil;
 	e.name = nil;
 	e.elems = nil;
 	e.elems = nil;
@@ -1134,8 +1155,7 @@ namec(char *aname, int amode, int omode, ulong perm)
 		/* perm must have DMDIR if last element is / or /. */
 		/* perm must have DMDIR if last element is / or /. */
 		if(e.mustbedir && !(perm&DMDIR)){
 		if(e.mustbedir && !(perm&DMDIR)){
 			npath = e.nelems;
 			npath = e.nelems;
-			strcpy(tmperrbuf, "create without DMDIR");
-			goto NameError;
+			nameerror(aname, "create without DMDIR");
 		}
 		}
 
 
 		/* don't try to walk the last path element just yet. */
 		/* don't try to walk the last path element just yet. */
@@ -1149,21 +1169,12 @@ namec(char *aname, int amode, int omode, ulong perm)
 			print("namec %s walk error npath=%d\n", aname, npath);
 			print("namec %s walk error npath=%d\n", aname, npath);
 			nexterror();
 			nexterror();
 		}
 		}
-		strcpy(tmperrbuf, up->errstr);
-	NameError:
-		len = prefix+e.off[npath];
-		if(len < ERRMAX/3 || (name=memrchr(aname, '/', len))==nil || name==aname)
-			snprint(up->genbuf, sizeof up->genbuf, "%.*s", len, aname);
-		else
-			snprint(up->genbuf, sizeof up->genbuf, "...%.*s", (int)(len-(name-aname)), name);
-		snprint(up->errstr, ERRMAX, "%#q %s", up->genbuf, tmperrbuf);
-		nexterror();
+		nameerror(aname, up->errstr);
 	}
 	}
 
 
 	if(e.mustbedir && !(c->qid.type&QTDIR)){
 	if(e.mustbedir && !(c->qid.type&QTDIR)){
 		npath = e.nelems;
 		npath = e.nelems;
-		strcpy(tmperrbuf, "not a directory");
-		goto NameError;
+		nameerror(aname, "not a directory");
 	}
 	}
 
 
 	if(amode == Aopen && (omode&3) == OEXEC && (c->qid.type&QTDIR)){
 	if(amode == Aopen && (omode&3) == OEXEC && (c->qid.type&QTDIR)){
@@ -1172,11 +1183,6 @@ namec(char *aname, int amode, int omode, ulong perm)
 	}
 	}
 
 
 	switch(amode){
 	switch(amode){
-	case Aaccess:
-		if(!nomount)
-			domount(&c, nil);
-		break;
-
 	case Abind:
 	case Abind:
 		m = nil;
 		m = nil;
 		if(!nomount)
 		if(!nomount)
@@ -1186,6 +1192,7 @@ namec(char *aname, int amode, int omode, ulong perm)
 		c->umh = m;
 		c->umh = m;
 		break;
 		break;
 
 
+	case Aaccess:
 	case Aremove:
 	case Aremove:
 	case Aopen:
 	case Aopen:
 	Open:
 	Open:
@@ -1203,7 +1210,11 @@ namec(char *aname, int amode, int omode, ulong perm)
 		cnameclose(c->name);
 		cnameclose(c->name);
 		c->name = cname;
 		c->name = cname;
 
 
+		/* record whether c is on a mount point */
+		c->ismtpt = m!=nil;
+
 		switch(amode){
 		switch(amode){
+		case Aaccess:
 		case Aremove:
 		case Aremove:
 			putmhead(m);
 			putmhead(m);
 			break;
 			break;
@@ -1215,7 +1226,6 @@ if(c->umh != nil){
 	putmhead(c->umh);
 	putmhead(c->umh);
 	c->umh = nil;
 	c->umh = nil;
 }
 }
-
 			/* only save the mount head if it's a multiple element union */
 			/* only save the mount head if it's a multiple element union */
 			if(m && m->mount && m->mount->next)
 			if(m && m->mount && m->mount->next)
 				c->umh = m;
 				c->umh = m;

+ 4 - 4
sys/src/9/port/cis.c

@@ -64,15 +64,15 @@ xcistuple(int slotno, int tuple, int subtuple, void *v, int nv, int attr)
 			break;
 			break;
 
 
 		n = link;
 		n = link;
-		if (link > 1 && subtuple != -1) {
-			if (readc(&cis, &c) != 1)
+		if(link > 1 && subtuple != -1){
+			if(readc(&cis, &c) != 1)
 				break;
 				break;
 			subtype = c;
 			subtype = c;
 			n--;
 			n--;
-		} else
+		}else
 			subtype = -1;
 			subtype = -1;
 
 
-		if(type == tuple && subtype == subtuple) {
+		if(type == tuple && subtype == subtuple){
 			p = v;
 			p = v;
 			for(l=0; l<nv && l<n; l++)
 			for(l=0; l<nv && l<n; l++)
 				if(readc(&cis, p++) != 1)
 				if(readc(&cis, p++) != 1)

+ 1 - 1
sys/src/9/port/devaudio.c

@@ -347,7 +347,7 @@ contindma(void)
 		goto shutdown;
 		goto shutdown;
 
 
 	b = audio.current;
 	b = audio.current;
-	if (b){
+	if(b){
 		audio.totcount += Bufsize;
 		audio.totcount += Bufsize;
 		audio.tottime = todget(nil);
 		audio.tottime = todget(nil);
 	}
 	}

+ 1 - 1
sys/src/9/port/devbridge.c

@@ -1032,7 +1032,7 @@ if(0)print("devbridge: etherread: blocklen = %d\n", blocklen(bp));
 				port->inunknown++;
 				port->inunknown++;
 				bp2 = bp; bp = nil;
 				bp2 = bp; bp = nil;
 				ethermultiwrite(b, bp2, port);
 				ethermultiwrite(b, bp2, port);
-			} else if (ce->port != port->id) {
+			}else if(ce->port != port->id){
 				b->hit++;
 				b->hit++;
 				bp2 = bp; bp = nil;
 				bp2 = bp; bp = nil;
 				etherwrite(b->port[ce->port], bp2);
 				etherwrite(b->port[ce->port], bp2);

+ 3 - 3
sys/src/9/port/devcons.c

@@ -227,7 +227,7 @@ panic(char *fmt, ...)
 void
 void
 _assert(char *fmt)
 _assert(char *fmt)
 {
 {
-	panic("assert failed: %s", fmt);
+	panic("assert failed at 0x%lux: %s", getcallerpc(&fmt), fmt);
 }
 }
 
 
 int
 int
@@ -462,7 +462,6 @@ static void
 kbdputcclock(void)
 kbdputcclock(void)
 {
 {
 	char *iw;
 	char *iw;
-
 	/* this amortizes cost of qproduce */
 	/* this amortizes cost of qproduce */
 	if(kbd.iw != kbd.ir){
 	if(kbd.iw != kbd.ir){
 		iw = kbd.iw;
 		iw = kbd.iw;
@@ -658,6 +657,7 @@ consread(Chan *c, void *buf, long n, vlong off)
 
 
 	if(n <= 0)
 	if(n <= 0)
 		return n;
 		return n;
+
 	switch((ulong)c->qid.path){
 	switch((ulong)c->qid.path){
 	case Qdir:
 	case Qdir:
 		return devdirread(c, buf, n, consdir, nelem(consdir), devgen);
 		return devdirread(c, buf, n, consdir, nelem(consdir), devgen);
@@ -975,7 +975,7 @@ conswrite(Chan *c, void *va, long n, vlong off)
 			kickpager();
 			kickpager();
 			break;
 			break;
 		}
 		}
-		if(cpuserver && !iseve())
+		if(!iseve())
 			error(Eperm);
 			error(Eperm);
 		if(buf[0]<'0' || '9'<buf[0])
 		if(buf[0]<'0' || '9'<buf[0])
 			error(Ebadarg);
 			error(Ebadarg);

+ 2 - 2
sys/src/9/port/devmnt.c

@@ -1151,12 +1151,12 @@ mntchk(Chan *c)
 	/* This routine is mostly vestiges of prior lives; now it's just sanity checking */
 	/* This routine is mostly vestiges of prior lives; now it's just sanity checking */
 
 
 	if(c->mchan == nil)
 	if(c->mchan == nil)
-		panic("mntchk 1: nil mchan c %s\n", c2name(c));
+		panic("mntchk 1: nil mchan c %s\n", channame(c));
 
 
 	m = c->mchan->mux;
 	m = c->mchan->mux;
 
 
 	if(m == nil)
 	if(m == nil)
-		print("mntchk 2: nil mux c %s c->mchan %s \n", c2name(c), c2name(c->mchan));
+		print("mntchk 2: nil mux c %s c->mchan %s \n", channame(c), channame(c->mchan));
 
 
 	/*
 	/*
 	 * Was it closed and reused (was error(Eshutdown); now, it can't happen)
 	 * Was it closed and reused (was error(Eshutdown); now, it can't happen)

+ 4 - 4
sys/src/9/port/devpnp.c

@@ -127,21 +127,21 @@ isolate(int rddata, ulong *id1, ulong *id2)
 	outb(Address, 0x01);	/* point to serial isolation register */
 	outb(Address, 0x01);	/* point to serial isolation register */
 	delay(1);
 	delay(1);
 	csum = 0x6a;
 	csum = 0x6a;
-	for (i = 0; i < 64; i++) {
+	for(i = 0; i < 64; i++){
 		bit = readbit(rddata);
 		bit = readbit(rddata);
 		csum = (csum>>1) | (((csum&1) ^ ((csum>>1)&1) ^ bit)<<7);
 		csum = (csum>>1) | (((csum&1) ^ ((csum>>1)&1) ^ bit)<<7);
 		p = &id[i>>3];
 		p = &id[i>>3];
 		*p = (*p>>1) | (bit<<7);
 		*p = (*p>>1) | (bit<<7);
 	}
 	}
-	for (; i < 72; i++) {
+	for(; i < 72; i++){
 		p = &id[i>>3];
 		p = &id[i>>3];
 		*p = (*p>>1) | (readbit(rddata)<<7);
 		*p = (*p>>1) | (readbit(rddata)<<7);
 	}
 	}
 	*id1 = (id[3]<<24)|(id[2]<<16)|(id[1]<<8)|id[0];
 	*id1 = (id[3]<<24)|(id[2]<<16)|(id[1]<<8)|id[0];
 	*id2 = (id[7]<<24)|(id[6]<<16)|(id[5]<<8)|id[4];
 	*id2 = (id[7]<<24)|(id[6]<<16)|(id[5]<<8)|id[4];
-	if (*id1 == 0)
+	if(*id1 == 0)
 		return 0;
 		return 0;
-	if (id[8] != csum)
+	if(id[8] != csum)
 		DPRINT("pnp: bad checksum id1 %lux id2 %lux csum %x != %x\n", *id1, *id2, csum, id[8]); /**/
 		DPRINT("pnp: bad checksum id1 %lux id2 %lux csum %x != %x\n", *id1, *id2, csum, id[8]); /**/
 	return id[8] == csum;
 	return id[8] == csum;
 }
 }

+ 11 - 5
sys/src/9/port/devrealtime.c

@@ -617,6 +617,8 @@ devrtwrite(Chan *c, void *va, long n, vlong)
 			}else if (strcmp(a, "acquire") == 0){
 			}else if (strcmp(a, "acquire") == 0){
 				if (v == nil)
 				if (v == nil)
 					error("acquire: value missing");
 					error("acquire: value missing");
+				if (up->task != t)
+					error("acquire: not for another task");
 				if ((r = resource(v, 0)) == nil)
 				if ((r = resource(v, 0)) == nil)
 					error("acquire: no such resource");
 					error("acquire: no such resource");
 				for (l = (CSN*)t->csns.next; l; l = (CSN*)l->next){
 				for (l = (CSN*)t->csns.next; l; l = (CSN*)l->next){
@@ -632,6 +634,8 @@ DEBUG("l->p (0x%p) == t->curcsn (0x%p) && l->S (%T) != 0\n", l->p, t->curcsn, ti
 			}else if (strcmp(a, "release") == 0){
 			}else if (strcmp(a, "release") == 0){
 				if (v == nil)
 				if (v == nil)
 					error("release: value missing");
 					error("release: value missing");
+				if (up->task != t)
+					error("release: not for another task");
 				if ((r = resource(v, 0)) == nil)
 				if ((r = resource(v, 0)) == nil)
 					error("release: no such resource");
 					error("release: no such resource");
 				if (t->curcsn->i != r)
 				if (t->curcsn->i != r)
@@ -680,6 +684,13 @@ DEBUG("l->p (0x%p) == t->curcsn (0x%p) && l->S (%T) != 0\n", l->p, t->curcsn, ti
 			}else if (strcmp(a, "admit") == 0){
 			}else if (strcmp(a, "admit") == 0){
 				if (e = edf->edfadmit(t))
 				if (e = edf->edfadmit(t))
 					error(e);
 					error(e);
+			}else if (strcmp(a, "besteffort") == 0){
+				t->T = Infinity;
+				t->D = Infinity;
+				t->C = 0;
+				t->flags |= BestEffort;
+				if (e = edf->edfadmit(t))
+					error(e);
 			}else if (strcmp(a, "expel") == 0){
 			}else if (strcmp(a, "expel") == 0){
 				edf->edfexpel(t);
 				edf->edfexpel(t);
 			}else if (strcmp(a, "remove") == 0){
 			}else if (strcmp(a, "remove") == 0){
@@ -731,12 +742,7 @@ devrtremove(Chan *c)
 	if (t == nil)
 	if (t == nil)
 		error(Enonexist);
 		error(Enonexist);
 	qlock(&edfschedlock);
 	qlock(&edfschedlock);
-	if (waserror()){
-		qunlock(&edfschedlock);
-		nexterror();
-	}
 	removetask(t);
 	removetask(t);
-	poperror();
 	qunlock(&edfschedlock);
 	qunlock(&edfschedlock);
 }
 }
 
 

+ 13 - 13
sys/src/9/port/devsd.c

@@ -229,7 +229,7 @@ sdgetdev(int idno)
 
 
 	qlock(&devslock);
 	qlock(&devslock);
 	for(i = 0; i != ndevs; i++)
 	for(i = 0; i != ndevs; i++)
-		if (devs[i].dt_dev->idno == idno)
+		if(devs[i].dt_dev->idno == idno)
 			break;
 			break;
 	
 	
 	if(i == ndevs)
 	if(i == ndevs)
@@ -276,10 +276,6 @@ sdgetunit(SDev* sdev, int subno)
 		}
 		}
 		sdev->unitflg[subno] = 1;
 		sdev->unitflg[subno] = 1;
 
 
-		if(sdev->enabled == 0 && sdev->ifc->enable)
-			sdev->ifc->enable(sdev);
-		sdev->enabled = 1;
-
 		snprint(buf, sizeof(buf), "%s%d", sdev->name, subno);
 		snprint(buf, sizeof(buf), "%s%d", sdev->name, subno);
 		kstrdup(&unit->name, buf);
 		kstrdup(&unit->name, buf);
 		kstrdup(&unit->user, eve);
 		kstrdup(&unit->user, eve);
@@ -287,6 +283,10 @@ sdgetunit(SDev* sdev, int subno)
 		unit->subno = subno;
 		unit->subno = subno;
 		unit->dev = sdev;
 		unit->dev = sdev;
 
 
+		if(sdev->enabled == 0 && sdev->ifc->enable)
+			sdev->ifc->enable(sdev);
+		sdev->enabled = 1;
+
 		/*
 		/*
 		 * No need to lock anything here as this is only
 		 * No need to lock anything here as this is only
 		 * called before the unit is made available in the
 		 * called before the unit is made available in the
@@ -471,7 +471,7 @@ sdgen(Chan* c, char*, Dirtab*, int, int s, Dir* dp)
 
 
 		qlock(&devslock);
 		qlock(&devslock);
 		for(i = 0; i != ndevs; i++){
 		for(i = 0; i != ndevs; i++){
-			if (s < devs[i].dt_nunits)
+			if(s < devs[i].dt_nunits)
 				break;
 				break;
 			s -= devs[i].dt_nunits;
 			s -= devs[i].dt_nunits;
 		}
 		}
@@ -482,7 +482,7 @@ sdgen(Chan* c, char*, Dirtab*, int, int s, Dir* dp)
 			return -1;
 			return -1;
 		}
 		}
 
 
-		if ((sdev = devs[i].dt_dev) == nil){
+		if((sdev = devs[i].dt_dev) == nil){
 			qunlock(&devslock);
 			qunlock(&devslock);
 			return 0;
 			return 0;
 		}
 		}
@@ -604,7 +604,7 @@ sdattach(char* spec)
 
 
 	qlock(&devslock);
 	qlock(&devslock);
 	for (sdev = nil, i = 0; i != ndevs; i++)
 	for (sdev = nil, i = 0; i != ndevs; i++)
-		if ((sdev = devs[i].dt_dev) != nil && sdev->idno == idno)
+		if((sdev = devs[i].dt_dev) != nil && sdev->idno == idno)
 			break;
 			break;
 
 
 	if(i == ndevs || subno >= sdev->nunit || sdgetunit(sdev, subno) == nil){
 	if(i == ndevs || subno >= sdev->nunit || sdgetunit(sdev, subno) == nil){
@@ -695,7 +695,7 @@ sdclose(Chan* c)
 		break;
 		break;
 	case Qraw:
 	case Qraw:
 		sdev = sdgetdev(DEV(c->qid));
 		sdev = sdgetdev(DEV(c->qid));
-		if (sdev) {
+		if(sdev){
 			unit = sdev->unit[UNIT(c->qid)];
 			unit = sdev->unit[UNIT(c->qid)];
 			unit->rawinuse = 0;
 			unit->rawinuse = 0;
 			decref(&sdev->r);
 			decref(&sdev->r);
@@ -905,7 +905,7 @@ sdread(Chan *c, void *a, long n, vlong off)
 
 
 	case Qctl:
 	case Qctl:
 		sdev = sdgetdev(DEV(c->qid));
 		sdev = sdgetdev(DEV(c->qid));
-		if (sdev == nil)
+		if(sdev == nil)
 			error(Enonexist);
 			error(Enonexist);
 
 
 		unit = sdev->unit[UNIT(c->qid)];
 		unit = sdev->unit[UNIT(c->qid)];
@@ -944,7 +944,7 @@ sdread(Chan *c, void *a, long n, vlong off)
 
 
 	case Qraw:
 	case Qraw:
 		sdev = sdgetdev(DEV(c->qid));
 		sdev = sdgetdev(DEV(c->qid));
-		if (sdev == nil)
+		if(sdev == nil)
 			error(Enonexist);
 			error(Enonexist);
 
 
 		unit = sdev->unit[UNIT(c->qid)];
 		unit = sdev->unit[UNIT(c->qid)];
@@ -1139,7 +1139,7 @@ sdwrite(Chan* c, void* a, long n, vlong off)
 	case Qctl:
 	case Qctl:
 		cb = parsecmd(a, n);
 		cb = parsecmd(a, n);
 		sdev = sdgetdev(DEV(c->qid));
 		sdev = sdgetdev(DEV(c->qid));
-		if (sdev == nil)
+		if(sdev == nil)
 			error(Enonexist);
 			error(Enonexist);
 		unit = sdev->unit[UNIT(c->qid)];
 		unit = sdev->unit[UNIT(c->qid)];
 
 
@@ -1244,7 +1244,7 @@ sdwstat(Chan* c, uchar* dp, int n)
 		error(Eperm); 
 		error(Eperm); 
 
 
 	sdev = sdgetdev(DEV(c->qid));
 	sdev = sdgetdev(DEV(c->qid));
-	if (sdev == nil)
+	if(sdev == nil)
 		error(Enonexist);
 		error(Enonexist);
 	unit = sdev->unit[UNIT(c->qid)];
 	unit = sdev->unit[UNIT(c->qid)];
 	qlock(&unit->ctl);
 	qlock(&unit->ctl);

+ 1 - 2
sys/src/9/port/devsdp.c

@@ -160,7 +160,6 @@ struct Conv {
 struct Sdp {
 struct Sdp {
 	QLock;
 	QLock;
 	Log;
 	Log;
-	Rendez	vous;			/* used by sdpackproc */
 	int	nconv;
 	int	nconv;
 	Conv *conv[Maxconv];
 	Conv *conv[Maxconv];
 	int ackproc;
 	int ackproc;
@@ -909,7 +908,7 @@ sdpackproc(void *a)
 	Conv *c;
 	Conv *c;
 
 
 	for(;;) {
 	for(;;) {
-		tsleep(&sdp->vous, return0, 0, 1000);
+		tsleep(&up->sleep, return0, 0, 1000);
 		sec = TK2SEC(m->ticks);
 		sec = TK2SEC(m->ticks);
 		qlock(sdp);
 		qlock(sdp);
 		for(i=0; i<sdp->nconv; i++) {
 		for(i=0; i<sdp->nconv; i++) {

+ 5 - 3
sys/src/9/port/devtls.c

@@ -318,7 +318,7 @@ tlsgen(Chan *c, char*, Dirtab *, int, int s, Dir *dp)
 			nm = tr->user;
 			nm = tr->user;
 		else
 		else
 			nm = eve;
 			nm = eve;
-		if ((name = trnames[s]) == nil) {
+		if((name = trnames[s]) == nil){
 			name = trnames[s] = smalloc(16);
 			name = trnames[s] = smalloc(16);
 			sprint(name, "%d", s);
 			sprint(name, "%d", s);
 		}
 		}
@@ -802,7 +802,9 @@ tlsrecread(TlsRec *tr)
 		put64(seq, in->seq);
 		put64(seq, in->seq);
 		in->seq++;
 		in->seq++;
 		(*tr->packMac)(in->sec, in->sec->mackey, seq, header, p, len, hmac);
 		(*tr->packMac)(in->sec, in->sec->mackey, seq, header, p, len, hmac);
-		if(unpad_len <= in->sec->maclen || memcmp(hmac, p+len, in->sec->maclen) != 0)
+		if(unpad_len <= in->sec->maclen)
+			rcvError(tr, EBadRecordMac, "short record mac");
+		if(memcmp(hmac, p+len, in->sec->maclen) != 0)
 			rcvError(tr, EBadRecordMac, "record mac mismatch");
 			rcvError(tr, EBadRecordMac, "record mac mismatch");
 		b->wp = b->rp + len;
 		b->wp = b->rp + len;
 	}
 	}
@@ -1085,7 +1087,7 @@ tlsbread(Chan *c, long n, ulong offset)
 		if(tr->hprocessed == nil){
 		if(tr->hprocessed == nil){
 			b = qbread(tr->handq, MaxRecLen + 1);
 			b = qbread(tr->handq, MaxRecLen + 1);
 			if(*b->rp++ == RAlert){
 			if(*b->rp++ == RAlert){
-				strecpy(up->errstr, up->errstr+ERRMAX, (char*)b->rp);
+				kstrcpy(up->errstr, (char*)b->rp, ERRMAX);
 				freeb(b);
 				freeb(b);
 				nexterror();
 				nexterror();
 			}
 			}

+ 3 - 4
sys/src/9/port/devuart.c

@@ -179,7 +179,6 @@ uartreset(void)
 	dp->length = 0;
 	dp->length = 0;
 	dp->perm = DMDIR|0555;
 	dp->perm = DMDIR|0555;
 	dp++;
 	dp++;
-
 	p = uartlist;
 	p = uartlist;
 	for(i = 0; i < uartnuart; i++){
 	for(i = 0; i < uartnuart; i++){
 		/* 3 directory entries per port */
 		/* 3 directory entries per port */
@@ -535,7 +534,7 @@ uartpower(int on)
 	Uart *p;
 	Uart *p;
 
 
 	for(p = uartlist; p != nil; p = p->next) {
 	for(p = uartlist; p != nil; p = p->next) {
-		if (p->phys->power)
+		if(p->phys->power)
 			(*p->phys->power)(p, on);
 			(*p->phys->power)(p, on);
 	}
 	}
 }
 }
@@ -623,7 +622,7 @@ uartrecv(Uart *p,  char ch)
 	if(p->xonoff){
 	if(p->xonoff){
 		if(ch == CTLS){
 		if(ch == CTLS){
 			p->blocked = 1;
 			p->blocked = 1;
-		}else if (ch == CTLQ){
+		}else if(ch == CTLQ){
 			p->blocked = 0;
 			p->blocked = 0;
 			p->ctsbackoff = 2; /* clock gets output going again */
 			p->ctsbackoff = 2; /* clock gets output going again */
 		}
 		}
@@ -632,7 +631,7 @@ uartrecv(Uart *p,  char ch)
 	/* receive the character */
 	/* receive the character */
 	if(p->putc)
 	if(p->putc)
 		p->putc(p->iq, ch);
 		p->putc(p->iq, ch);
-	else {
+	else{
 		next = p->iw + 1;
 		next = p->iw + 1;
 		if(next == p->ie)
 		if(next == p->ie)
 			next = p->istage;
 			next = p->istage;

+ 25 - 8
sys/src/9/port/edf.c

@@ -16,6 +16,7 @@ char *edfstatename[] = {
 	[EdfUnused] =		"Unused",
 	[EdfUnused] =		"Unused",
 	[EdfExpelled] =		"Expelled",
 	[EdfExpelled] =		"Expelled",
 	[EdfAdmitted] =	"Admitted",
 	[EdfAdmitted] =	"Admitted",
+	[EdfBestEffort] =	"BestEffort",
 	[EdfIdle] =			"Idle",
 	[EdfIdle] =			"Idle",
 	[EdfAwaitrelease] =	"Awaitrelease",
 	[EdfAwaitrelease] =	"Awaitrelease",
 	[EdfReleased] =		"Released",
 	[EdfReleased] =		"Released",
@@ -331,6 +332,11 @@ edfadmit(Task *t)
 	}
 	}
 	ilock(&edflock);
 	ilock(&edflock);
 	DPRINT("%d edfadmit, %s, %d\n", m->machno, edfstatename[t->state], t->runq.n);
 	DPRINT("%d edfadmit, %s, %d\n", m->machno, edfstatename[t->state], t->runq.n);
+	if (t->flags & BestEffort){
+		t->state = EdfBestEffort;
+		iunlock(&edflock);
+		return nil;
+	}
 	now = fastticks(nil);
 	now = fastticks(nil);
 
 
 	t->state = EdfAdmitted;
 	t->state = EdfAdmitted;
@@ -359,7 +365,6 @@ edfadmit(Task *t)
 	}else{
 	}else{
 		if (t->runq.n){
 		if (t->runq.n){
 			if (edfstack[m->machno].head == nil){
 			if (edfstack[m->machno].head == nil){
-				t->state = EdfAdmitted;
 				t->r = now;
 				t->r = now;
 				edfrelease(t);
 				edfrelease(t);
 				setdelta();
 				setdelta();
@@ -672,7 +677,7 @@ edfresched(Task *t)
 				edfrelease(t);
 				edfrelease(t);
 				return;
 				return;
 			}
 			}
-			if (now < t->d && (t->flags & Useblocking) == 0){
+			if ((t->flags & Useblocking) == 0 && now < t->d){
 				if (t->S > 0){
 				if (t->S > 0){
 					DPRINT("%d edfresched, resume\n", m->machno);
 					DPRINT("%d edfresched, resume\n", m->machno);
 					/* Released, not yet at deadline, release (again) */
 					/* Released, not yet at deadline, release (again) */
@@ -1000,7 +1005,7 @@ edftestschedulability(Task *thetask)
 	for (l = tasks.next; l; l = l->next){
 	for (l = tasks.next; l; l = l->next){
 		t = l->i;
 		t = l->i;
 		assert(t);
 		assert(t);
-		if (t->state <= EdfExpelled && t != thetask)
+		if (t->state <= EdfExpelled && t != thetask && (t->flags & BestEffort) == 0)
 			continue;
 			continue;
 		t->testtype = Release;
 		t->testtype = Release;
 		t->testtime = 0;
 		t->testtime = 0;
@@ -1060,11 +1065,15 @@ resacquire(Task *t, CSN *c)
 {
 {
 	Ticks now, when, used;
 	Ticks now, when, used;
 
 
+	ilock(&edflock);
 	now = fastticks(nil);
 	now = fastticks(nil);
 	used = now - t->scheduled;
 	used = now - t->scheduled;
 	t->scheduled = now;
 	t->scheduled = now;
 	t->total += used;
 	t->total += used;
-	t->S -= used;
+	if (t->flags & BestEffort)
+		c->S = c->C;
+	else
+		t->S -= used;
 	if (t->curcsn)
 	if (t->curcsn)
 		t->curcsn->S -= used;
 		t->curcsn->S -= used;
 	when = now + c->S;
 	when = now + c->S;
@@ -1074,6 +1083,8 @@ resacquire(Task *t, CSN *c)
 	}
 	}
 	t->Delta = c->Delta;
 	t->Delta = c->Delta;
 	t->curcsn = c;
 	t->curcsn = c;
+	t->state = EdfRunning;
+	iunlock(&edflock);
 	if(devrt) devrt(t, now, SResacq);
 	if(devrt) devrt(t, now, SResacq);
 	/* priority is going up, no need to reschedule */
 	/* priority is going up, no need to reschedule */
 }
 }
@@ -1084,6 +1095,7 @@ resrelease(Task *t)
 	Ticks now, when, used;
 	Ticks now, when, used;
 	CSN *c;
 	CSN *c;
 
 
+	ilock(&edflock);
 	c = t->curcsn;
 	c = t->curcsn;
 	assert(c);
 	assert(c);
 	t->curcsn = c->p;
 	t->curcsn = c->p;
@@ -1091,7 +1103,8 @@ resrelease(Task *t)
 	used = now - t->scheduled;
 	used = now - t->scheduled;
 	t->scheduled = now;
 	t->scheduled = now;
 	t->total += used;
 	t->total += used;
-	t->S -= used;
+	if ((t->flags & BestEffort) == 0)
+		t->S -= used;
 	c->S -= used;
 	c->S -= used;
 	if (now + t->S > t->d)
 	if (now + t->S > t->d)
 		when = t->d;
 		when = t->d;
@@ -1102,14 +1115,18 @@ resrelease(Task *t)
 		t->Delta = t->curcsn->Delta;
 		t->Delta = t->curcsn->Delta;
 		if (when > now + t->curcsn->S)
 		if (when > now + t->curcsn->S)
 			when = now + t->curcsn->S;
 			when = now + t->curcsn->S;
-	}else
+	}else{
 		t->Delta = Infinity;
 		t->Delta = Infinity;
-	c->S = 0LL;	/* don't allow reuse */
-	if(devrt) devrt(t, now, SResrel);
+		if (t->flags & BestEffort)
+			t->state = EdfBestEffort;
+	}
+	c->S = 0LL;	/* don't allow reuse this period */
 	deadlinetimer[m->machno].when = when;
 	deadlinetimer[m->machno].when = when;
 	timeradd(&deadlinetimer[m->machno]);
 	timeradd(&deadlinetimer[m->machno]);
+	iunlock(&edflock);
 
 
 	qunlock(&edfschedlock);
 	qunlock(&edfschedlock);
+	if(devrt) devrt(t, now, SResrel);
 	sched();	/* reschedule */
 	sched();	/* reschedule */
 	qlock(&edfschedlock);
 	qlock(&edfschedlock);
 }
 }

+ 5 - 3
sys/src/9/port/edf.h

@@ -7,8 +7,9 @@ enum {
 	Maxsteps = Maxtasks * 2 * 100,	/* 100 periods of maximum # of tasks */
 	Maxsteps = Maxtasks * 2 * 100,	/* 100 periods of maximum # of tasks */
 
 
 	/* Edf.flags field */
 	/* Edf.flags field */
-	Verbose = 0x1,
-	Useblocking = 0x2,
+	Verbose		= 0x1,
+	Useblocking	= 0x2,
+	BestEffort		= 0x4,
 
 
 	Infinity = 0xffffffffffffffffULL,
 	Infinity = 0xffffffffffffffffULL,
 
 
@@ -18,9 +19,10 @@ enum Edfstate {
 	EdfUnused,		/* task structure not in use */
 	EdfUnused,		/* task structure not in use */
 	EdfExpelled,		/* in initialization, not yet admitted */
 	EdfExpelled,		/* in initialization, not yet admitted */
 	EdfAdmitted,		/* admitted, but not started */
 	EdfAdmitted,		/* admitted, but not started */
+	EdfBestEffort,		/* admitted, but not RT scheduled */
 
 
 	EdfIdle,			/* admitted, but no member processes */
 	EdfIdle,			/* admitted, but no member processes */
-	EdfAwaitrelease,	/* released, but too early (on qwaitrelease) */
+	EdfAwaitrelease,	/* waiting for release (on qwaitrelease) */
 	EdfReleased,		/* released, but not yet scheduled (on qreleased) */
 	EdfReleased,		/* released, but not yet scheduled (on qreleased) */
 	EdfRunning,		/* one of this task's procs is running (on stack) */
 	EdfRunning,		/* one of this task's procs is running (on stack) */
 	EdfExtra,			/* one of this task's procs is running in extra time (off stack) */
 	EdfExtra,			/* one of this task's procs is running in extra time (off stack) */

+ 1 - 0
sys/src/9/port/error.h

@@ -1,6 +1,7 @@
 extern char Enoerror[];		/* no error */
 extern char Enoerror[];		/* no error */
 extern char Emount[];		/* inconsistent mount */
 extern char Emount[];		/* inconsistent mount */
 extern char Eunmount[];		/* not mounted */
 extern char Eunmount[];		/* not mounted */
+extern char Eismtpt[];		/* is a mount point */
 extern char Eunion[];		/* not in union */
 extern char Eunion[];		/* not in union */
 extern char Emountrpc[];	/* mount rpc error */
 extern char Emountrpc[];	/* mount rpc error */
 extern char Eshutdown[];	/* device shut down */
 extern char Eshutdown[];	/* device shut down */

+ 5 - 0
sys/src/9/port/initcode.c

@@ -1,3 +1,8 @@
+/*
+ * IMPORTANT!  DO NOT ADD LIBRARY CALLS TO THIS FILE.
+ * The entire text image must fit on one page.
+ */
+
 #include <u.h>
 #include <u.h>
 #include <libc.h>
 #include <libc.h>
 
 

+ 45 - 12
sys/src/9/port/mkbootrules

@@ -1,26 +1,59 @@
 #!/bin/rc
 #!/bin/rc
 
 
-awk -v 'objtype='$objtype '
+rfork e
+if(~ $#CONF 0)
+	CONF=$1
+awk -v 'objtype='$objtype -v 'CONF='$CONF '
+BEGIN { nfs = 0 }
 /^$/{
 /^$/{
-		next;
+	next;
 }
 }
 /^#/{
 /^#/{
-		next;
+	next;
 }
 }
 collect && /^[^ \t]/{
 collect && /^[^ \t]/{
-		collect = 0;
+	collect = 0;
 }
 }
-collect && section ~ "bootdir"{
+collect && section ~ "bootdir" {
+	if(NF >= 2)
+		x = $2;
+	else{
 		x = $1;
 		x = $1;
-		gsub(/[^a-zA-Z0-9_]/, "_", x);
-		printf "%s.root.s: %s\n\t../port/mkroot %s %s\n", x, $1, $1, x;
+		sub(/.*\//, "", x);
+	}
+	fsname[nfs] = x;
+	x = $1;
+	gsub(/[^a-zA-Z0-9_]/, "_", x);
+	fs[nfs] = x;
+	file[nfs] = $1;
+	nfs++;
 }
 }
 $0 ~ /^[^ \t]/{
 $0 ~ /^[^ \t]/{
-		if($0 ~ "bootdir"){
-			section = $0;
-			collect = 1;
-		}
-		next;
+	if($0 ~ "bootdir"){
+		section = $0;
+		collect = 1;
+	}
+	next;
+}
+
+END{
+	printf "%s.root.s:D:", CONF;
+	for(i=0; i<nfs; i++)
+		printf " %s", file[i];
+	printf "\n";
+	printf "\t../port/mkrootall \\\n";
+	for(i=0; i<nfs; i++)
+		printf "\t\t%s %s %s\\\n", fsname[i], fs[i], file[i];
+	printf "\t>$target\n";
+
+	printf "%s.rootc.c:D:", CONF;
+	for(i=0; i<nfs; i++)
+		printf " %s", file[i];
+	printf "\n";
+	printf "\t../port/mkrootc \\\n";
+	for(i=0; i<nfs; i++)
+		printf "\t\t%s %s %s\\\n", fsname[i], fs[i], file[i];
+	printf "\t>$target\n";
 }
 }
 
 
 ' $*
 ' $*

+ 1 - 28
sys/src/9/port/mkdevc

@@ -2,7 +2,6 @@
 
 
 awk -v 'objtype='$objtype '
 awk -v 'objtype='$objtype '
 BEGIN{
 BEGIN{
-		nfs = 0;
 		if(ARGC < 2)
 		if(ARGC < 2)
 			exit
 			exit
 }
 }
@@ -45,27 +44,6 @@ collect && section ~ "misc"{
 					vgacur[nvgacur++] = $1;
 					vgacur[nvgacur++] = $1;
 			}
 			}
 		}
 		}
-		else if($1 ~ ".*\.root"){
-			x = substr($1, 1, index($1, ".")-1);
-			if(x ~ "(9660srv|dossrv|kfs|nkfs|vdfs|bzfs)")
-				x = "kfs";
-			if(x ~ "nfactotum")
-				x = "factotum";
-			fsname[nfs] = x;
-			fs[nfs++] = x;
-		}
-}
-collect && section ~ "bootdir"{
-		if(NF >= 2)
-			x = $2;
-		else{
-			x = $1;
-			sub(/.*\//, "", x);
-		}
-		fsname[nfs] = x;
-		x = $1;
-		gsub(/[^a-zA-Z0-9_]/, "_", x);
-		fs[nfs++] = x;
 }
 }
 
 
 collect && section ~ "port"{
 collect && section ~ "port"{
@@ -99,16 +77,11 @@ END{
 		printf "\tnil,\n};\n\n";
 		printf "\tnil,\n};\n\n";
 
 
 
 
-		for(i = 0; i < nfs; i++){
-			printf "extern uchar %scode[];\n", fs[i];
-			printf "extern ulong %slen;\n", fs[i];
-		}
 		for(i = 0; i < nlink; i++)
 		for(i = 0; i < nlink; i++)
 			printf "extern void %slink(void);\n", link[i];
 			printf "extern void %slink(void);\n", link[i];
 
 
 		printf "void links(void){\n";
 		printf "void links(void){\n";
-		for(i = 0; i < nfs; i++)
-			printf "\taddbootfile(\"%s\", %scode, %slen);\n", fsname[i], fs[i], fs[i];
+		print "\tbootlinks();\n";
 		for(i = 0; i < nlink; i++)
 		for(i = 0; i < nlink; i++)
 			printf "\t%slink();\n", link[i];
 			printf "\t%slink();\n", link[i];
 		printf "}\n\n";
 		printf "}\n\n";

+ 2 - 12
sys/src/9/port/mkdevlist

@@ -1,7 +1,7 @@
 #!/bin/rc
 #!/bin/rc
 
 
 awk '
 awk '
-BEGIN{		collect = isdev = isbootdir = 0;
+BEGIN{		collect = isdev = 0;
 }
 }
 
 
 /^$/{		next;
 /^$/{		next;
@@ -9,15 +9,9 @@ BEGIN{		collect = isdev = isbootdir = 0;
 /^#/{		next;
 /^#/{		next;
 }
 }
 collect && /^[^	\t]/{
 collect && /^[^	\t]/{
-		collect = isdev = isbootdir = 0;
+		collect = isdev = 0;
 }
 }
 collect && $0 ~ /[^ \t]+/{
 collect && $0 ~ /[^ \t]+/{
-		if(isbootdir){
-			x = $1;
-			gsub(/[^a-zA-Z0-9_]/, "_", x);
-			obj[x ".root.'$O'"]++;
-			next;
-		}
 		if(isdev)
 		if(isdev)
 			obj["dev" $1 "'.$O'"]++;
 			obj["dev" $1 "'.$O'"]++;
 		else
 		else
@@ -34,10 +28,6 @@ $0 ~ /^[^ \t]/{
 		}
 		}
 		else if($1 ~ "misc" || $1 ~ "link" || $1 ~ "ip")
 		else if($1 ~ "misc" || $1 ~ "link" || $1 ~ "ip")
 			collect = 1;
 			collect = 1;
-		else if($1 ~ "bootdir"){
-			isbootdir = 1;
-			collect = 1;
-		}
 		next
 		next
 }
 }
 
 

+ 1 - 1
sys/src/9/port/page.c

@@ -66,7 +66,7 @@ static void
 pageunchain(Page *p)
 pageunchain(Page *p)
 {
 {
 	if(canlock(&palloc))
 	if(canlock(&palloc))
-		panic("pageunchain");
+		panic("pageunchain (palloc %p)", &palloc);
 	if(p->prev)
 	if(p->prev)
 		p->prev->next = p->next;
 		p->prev->next = p->next;
 	else
 	else

+ 2 - 1
sys/src/9/port/pgrp.c

@@ -180,8 +180,9 @@ dupfgrp(Fgrp *f)
 	if(i != 0)
 	if(i != 0)
 		new->nfd += DELTAFD - i;
 		new->nfd += DELTAFD - i;
 	new->fd = malloc(new->nfd*sizeof(Chan*));
 	new->fd = malloc(new->nfd*sizeof(Chan*));
-	if(new->fd == 0){
+	if(new->fd == nil){
 		unlock(f);
 		unlock(f);
+		free(new);
 		error("no memory for fgrp");
 		error("no memory for fgrp");
 	}
 	}
 	new->ref = 1;
 	new->ref = 1;

+ 6 - 6
sys/src/9/port/portclock.c

@@ -31,7 +31,7 @@ tadd(Timers *tt, Timer *nt)
 			*last = t->next;
 			*last = t->next;
 			break;
 			break;
 		}
 		}
-		if (t->period == nt->period){
+		if(t->period == nt->period){
 			/* look for another timer at same frequency for combining */
 			/* look for another timer at same frequency for combining */
 			pt = t;
 			pt = t;
 		}
 		}
@@ -52,7 +52,7 @@ tadd(Timers *tt, Timer *nt)
 	}
 	}
 	nt->next = *last;
 	nt->next = *last;
 	*last = nt;
 	*last = nt;
-	if (last == &tt->head)
+	if(last == &tt->head)
 		return nt->when;
 		return nt->when;
 	else
 	else
 		return 0;
 		return 0;
@@ -68,7 +68,7 @@ timeradd(Timer *nt)
 	tt = &timers[m->machno];
 	tt = &timers[m->machno];
 	ilock(tt);
 	ilock(tt);
 	when = tadd(tt, nt);
 	when = tadd(tt, nt);
-	if (when)
+	if(when)
 		timerset(when);
 		timerset(when);
 	iunlock(tt);
 	iunlock(tt);
 }
 }
@@ -87,7 +87,7 @@ timerdel(Timer *dt)
 			break;
 			break;
 		}
 		}
 	}
 	}
-	if (last == &tt->head && tt->head)
+	if(last == &tt->head && tt->head)
 		timerset(tt->head->when);
 		timerset(tt->head->when);
 	iunlock(tt);
 	iunlock(tt);
 }
 }
@@ -163,7 +163,7 @@ timerintr(Ureg *u, uvlong)
 		tt->head = t->next;
 		tt->head = t->next;
 		fcallcount[m->machno]++;
 		fcallcount[m->machno]++;
 		iunlock(tt);
 		iunlock(tt);
-		if (t->f){
+		if(t->f){
 			(*t->f)(u, t);
 			(*t->f)(u, t);
 			splhi();
 			splhi();
 		} else
 		} else
@@ -201,7 +201,7 @@ addclock0link(void (*f)(void), int ms)
 	/* Synchronize this to hztimer: reduces # of interrupts */
 	/* Synchronize this to hztimer: reduces # of interrupts */
 	nt = malloc(sizeof(Timer));
 	nt = malloc(sizeof(Timer));
 	nt->when = 0;
 	nt->when = 0;
-	if (ms == 0)
+	if(ms == 0)
 		ms = 1000/HZ;
 		ms = 1000/HZ;
 	nt->period = ms2fastticks(ms);
 	nt->period = ms2fastticks(ms);
 	nt->f = (void (*)(Ureg*, Timer*))f;
 	nt->f = (void (*)(Ureg*, Timer*))f;

+ 25 - 20
sys/src/9/port/portdat.h

@@ -155,7 +155,8 @@ struct Chan
 	Ref;
 	Ref;
 	Chan*	next;			/* allocation */
 	Chan*	next;			/* allocation */
 	Chan*	link;
 	Chan*	link;
-	vlong	offset;			/* in file */
+	vlong	offset;			/* in fd */
+	vlong	devoffset;			/* in underlying device; see read */
 	ushort	type;
 	ushort	type;
 	ulong	dev;
 	ulong	dev;
 	ushort	mode;			/* read/write */
 	ushort	mode;			/* read/write */
@@ -168,6 +169,11 @@ struct Chan
 	QLock	umqlock;		/* serialize unionreads */
 	QLock	umqlock;		/* serialize unionreads */
 	int	uri;			/* union read index */
 	int	uri;			/* union read index */
 	int	dri;			/* devdirread index */
 	int	dri;			/* devdirread index */
+	uchar*	dirrock;	/* directory entry rock for translations */
+	int	nrock;
+	int	mrock;
+	QLock	rockqlock;
+	int	ismtpt;
 	ulong	mountid;
 	ulong	mountid;
 	Mntcache *mcp;			/* Mount cache pointer */
 	Mntcache *mcp;			/* Mount cache pointer */
 	Mnt		*mux;		/* Mnt for clients using me for messages */
 	Mnt		*mux;		/* Mnt for clients using me for messages */
@@ -218,7 +224,7 @@ struct Dirtab
 {
 {
 	char	name[KNAMELEN];
 	char	name[KNAMELEN];
 	Qid	qid;
 	Qid	qid;
-	vlong length;
+	vlong	length;
 	long	perm;
 	long	perm;
 };
 };
 
 
@@ -329,7 +335,6 @@ struct Swapalloc
 	uchar*	last;			/* Speed swap allocation */
 	uchar*	last;			/* Speed swap allocation */
 	uchar*	top;			/* Top of swap map */
 	uchar*	top;			/* Top of swap map */
 	Rendez	r;			/* Pager kproc idle sleep */
 	Rendez	r;			/* Pager kproc idle sleep */
-	Rendez	pause;
 	ulong	highwater;		/* Pager start threshold */
 	ulong	highwater;		/* Pager start threshold */
 	ulong	headroom;		/* Space pager frees under highwater */
 	ulong	headroom;		/* Space pager frees under highwater */
 }swapalloc;
 }swapalloc;
@@ -442,8 +447,8 @@ struct Egrp
 	Ref;
 	Ref;
 	RWlock;
 	RWlock;
 	Evalue	**ent;
 	Evalue	**ent;
-	int nent;
-	int ment;
+	int	nent;
+	int	ment;
 	ulong	path;	/* qid.path of next Evalue to be allocated */
 	ulong	path;	/* qid.path of next Evalue to be allocated */
 	ulong	vers;	/* of Egrp */
 	ulong	vers;	/* of Egrp */
 };
 };
@@ -543,7 +548,7 @@ enum
 	TCSys,
 	TCSys,
 	TCReal,
 	TCReal,
 
 
-	NERR = 15,
+	NERR = 64,
 	NNOTE = 5,
 	NNOTE = 5,
 
 
 	Nrq		= 20,	/* number of scheduler priority levels */
 	Nrq		= 20,	/* number of scheduler priority levels */
@@ -649,9 +654,9 @@ struct Proc
 	Note	lastnote;
 	Note	lastnote;
 	int	(*notify)(void*, char*);
 	int	(*notify)(void*, char*);
 
 
-	Lock		*lockwait;
-	Lock		*lastlock;	/* debugging */
-	Lock		*lastilock;	/* debugging */
+	Lock	*lockwait;
+	Lock	*lastlock;	/* debugging */
+	Lock	*lastilock;	/* debugging */
 
 
 	Mach	*wired;
 	Mach	*wired;
 	Mach	*mp;		/* machine this process last ran on */
 	Mach	*mp;		/* machine this process last ran on */
@@ -667,7 +672,7 @@ struct Proc
 	int	preempted;	/* true if this process hasn't finished the interrupt
 	int	preempted;	/* true if this process hasn't finished the interrupt
 				 *  that last preempted it
 				 *  that last preempted it
 				 */
 				 */
-	Task		*task;	/* if non-null, real-time proc, task contains scheduling params */
+	Task	*task;		/* if non-null, real-time proc, task contains scheduling params */
 
 
 	ulong	qpc;		/* pc calling last blocking qlock */
 	ulong	qpc;		/* pc calling last blocking qlock */
 
 
@@ -861,18 +866,18 @@ struct Timer
 };
 };
 
 
 struct Edfinterface {
 struct Edfinterface {
-	int		(*isedf)(Proc*);
-	void		(*edfbury)(Proc*);
-	int		(*edfanyready)(void);
-	void		(*edfready)(Proc*);
+	int	(*isedf)(Proc*);
+	void	(*edfbury)(Proc*);
+	int	(*edfanyready)(void);
+	void	(*edfready)(Proc*);
 	Proc*	(*edfrunproc)(void);
 	Proc*	(*edfrunproc)(void);
-	void		(*edfblock)(Proc*);
-	void		(*edfinit)(void);
-	void		(*edfexpel)(Task*);
+	void	(*edfblock)(Proc*);
+	void	(*edfinit)(void);
+	void	(*edfexpel)(Task*);
 	char *	(*edfadmit)(Task*);
 	char *	(*edfadmit)(Task*);
-	void		(*edfdeadline)(Proc*);
-	void		(*resacquire)(Task*, CSN*);
-	void		(*resrelease)(Task*);
+	void	(*edfdeadline)(Proc*);
+	void	(*resacquire)(Task*, CSN*);
+	void	(*resrelease)(Task*);
 };
 };
 
 
 /*
 /*

+ 5 - 1
sys/src/9/port/portfns.h

@@ -13,10 +13,11 @@ Image*		attachimage(int, Chan*, ulong, ulong);
 Page*		auxpage(void);
 Page*		auxpage(void);
 Block*		bl2mem(uchar*, Block*, int);
 Block*		bl2mem(uchar*, Block*, int);
 int		blocklen(Block*);
 int		blocklen(Block*);
+void		bootlinks(void);
 void		cachedel(Image*, ulong);
 void		cachedel(Image*, ulong);
 void		cachepage(Page*, Image*);
 void		cachepage(Page*, Image*);
 void		callwithureg(void(*)(Ureg*));
 void		callwithureg(void(*)(Ureg*));
-char*		c2name(Chan*);
+char*		channame(Chan*);
 int		cangetc(void*);
 int		cangetc(void*);
 int		canlock(Lock*);
 int		canlock(Lock*);
 int		canpage(Proc*);
 int		canpage(Proc*);
@@ -91,6 +92,7 @@ int		emptystr(char*);
 int		encrypt(void*, void*, int);
 int		encrypt(void*, void*, int);
 void		envcpy(Egrp*, Egrp*);
 void		envcpy(Egrp*, Egrp*);
 int		eqchan(Chan*, Chan*, int);
 int		eqchan(Chan*, Chan*, int);
+int		eqchantdqid(Chan*, int, int, Qid, int);
 int		eqqid(Qid, Qid);
 int		eqqid(Qid, Qid);
 void		error(char*);
 void		error(char*);
 long		execregs(ulong, ulong, ulong);
 long		execregs(ulong, ulong, ulong);
@@ -100,6 +102,7 @@ uvlong		fastticks(uvlong*);
 int		fault(ulong, int);
 int		fault(ulong, int);
 void		fdclose(int, int);
 void		fdclose(int, int);
 Chan*		fdtochan(int, int, int, int);
 Chan*		fdtochan(int, int, int, int);
+int		findmount(Chan**, Mhead**, int, int, Qid);
 int		fixfault(Segment*, ulong, int, int);
 int		fixfault(Segment*, ulong, int, int);
 void		flushmmu(void);
 void		flushmmu(void);
 void		forkchild(Proc*, Ureg*);
 void		forkchild(Proc*, Ureg*);
@@ -180,6 +183,7 @@ ulong		ms2tk(ulong);
 uvlong		ms2fastticks(ulong);
 uvlong		ms2fastticks(ulong);
 void		muxclose(Mnt*);
 void		muxclose(Mnt*);
 Chan*		namec(char*, int, int, ulong);
 Chan*		namec(char*, int, int, ulong);
+void		nameerror(char*, char*);
 #define		nelem(x)	(sizeof(x)/sizeof(x[0]))
 #define		nelem(x)	(sizeof(x)/sizeof(x[0]))
 Chan*		newchan(void);
 Chan*		newchan(void);
 int		newfd(Chan*);
 int		newfd(Chan*);

+ 1 - 7
sys/src/9/port/portmkfile

@@ -30,7 +30,7 @@ all:V:
 		mk 'CONF='$i
 		mk 'CONF='$i
 
 
 clean:V:
 clean:V:
-	rm -f *.[$OS] *.root.s cfs.h fs.h init.h conf.h *.out factotum.hack ipconfig.hack
+	rm -f *.[$OS] *.root.s *.rootc.c cfs.h fs.h init.h conf.h *.out
 	for(i in $CONFLIST)
 	for(i in $CONFLIST)
 		mk $i.clean
 		mk $i.clean
 
 
@@ -82,10 +82,4 @@ boot$CONF.out: $CONF print.$O $BOOTDIR/boot.c $BOOTLIB
 	$CC $CFLAGS boot$CONF.c
 	$CC $CFLAGS boot$CONF.c
 	$LD -o boot$CONF.out boot$CONF.$O $BOOTLIB print.$O
 	$LD -o boot$CONF.out boot$CONF.$O $BOOTLIB print.$O
 
 
-# this lets us say "factotum.hack factotum" instead of "/386/bin/auth/factotum factotum"
-# in the kernel config files.  the latter won't work until we have long file names.
-factotum.hack: /$objtype/bin/auth/factotum
-	cp $prereq $target
 
 
-ipconfig.hack: /$objtype/bin/ip/ipconfig
-	cp $prereq $target

+ 9 - 8
sys/src/9/port/proc.c

@@ -76,7 +76,7 @@ schedinit(void)		/* never returns */
 			break;
 			break;
 		case Moribund:
 		case Moribund:
 			up->state = Dead;
 			up->state = Dead;
-			if (edf->isedf(up))
+			if(edf->isedf(up))
 				edf->edfbury(up);
 				edf->edfbury(up);
 
 
 			/*
 			/*
@@ -362,7 +362,7 @@ runproc(void)
 
 
 	start = perfticks();
 	start = perfticks();
 
 
-	if ((p = edf->edfrunproc()) != nil)
+	if((p = edf->edfrunproc()) != nil)
 		return p;
 		return p;
 
 
 	/* 10 is completely arbitrary - it interacts with the comparison in rebalance */
 	/* 10 is completely arbitrary - it interacts with the comparison in rebalance */
@@ -583,7 +583,7 @@ sleep(Rendez *r, int (*f)(void*), void *arg)
 
 
 	s = splhi();
 	s = splhi();
 
 
-	if (up->nlocks)
+	if(up->nlocks)
 		print("process %lud sleeps with %lud locks held, last lock 0x%p locked at pc 0x%lux\n",
 		print("process %lud sleeps with %lud locks held, last lock 0x%p locked at pc 0x%lux\n",
 			up->pid, up->nlocks, up->lastlock, up->lastlock->pc);
 			up->pid, up->nlocks, up->lastlock, up->lastlock->pc);
 	lock(r);
 	lock(r);
@@ -633,9 +633,8 @@ sleep(Rendez *r, int (*f)(void*), void *arg)
 			 */
 			 */
 			unlock(&up->rlock);
 			unlock(&up->rlock);
 			unlock(r);
 			unlock(r);
-			// Behind unlock, we may call wakeup on ourselves.
 
 
-			if (edf->isedf(up))
+			if(edf->isedf(up))
 				edf->edfblock(up);
 				edf->edfblock(up);
 
 
 			gotolabel(&m->sched);
 			gotolabel(&m->sched);
@@ -836,7 +835,7 @@ addbroken(Proc *p)
 	broken.p[broken.n++] = p;
 	broken.p[broken.n++] = p;
 	qunlock(&broken);
 	qunlock(&broken);
 
 
-	if (edf->isedf(up))
+	if(edf->isedf(up))
 		edf->edfbury(up);
 		edf->edfbury(up);
 	p->state = Broken;
 	p->state = Broken;
 	p->psstate = 0;
 	p->psstate = 0;
@@ -1007,7 +1006,7 @@ pexit(char *exitstr, int freemem)
 	lock(&procalloc);
 	lock(&procalloc);
 	lock(&palloc);
 	lock(&palloc);
 
 
-	if (edf->isedf(up))
+	if(edf->isedf(up))
 		edf->edfbury(up);
 		edf->edfbury(up);
 	up->state = Moribund;
 	up->state = Moribund;
 	sched();
 	sched();
@@ -1260,7 +1259,7 @@ procctl(Proc *p)
 		qunlock(&p->debug);
 		qunlock(&p->debug);
 		splhi();
 		splhi();
 		p->state = Stopped;
 		p->state = Stopped;
-		if (edf->isedf(up))
+		if(edf->isedf(up))
 			edf->edfblock(up);
 			edf->edfblock(up);
 		sched();
 		sched();
 		p->psstate = state;
 		p->psstate = state;
@@ -1275,6 +1274,8 @@ void
 error(char *err)
 error(char *err)
 {
 {
 	spllo();
 	spllo();
+
+	assert(up->nerrlab < NERR);
 	kstrcpy(up->errstr, err, ERRMAX);
 	kstrcpy(up->errstr, err, ERRMAX);
 	setlabel(&up->errlab[NERR-1]);
 	setlabel(&up->errlab[NERR-1]);
 	nexterror();
 	nexterror();

+ 4 - 2
sys/src/9/port/qlock.c

@@ -23,6 +23,8 @@ qlock(QLock *q)
 	if(up != nil && up->nlocks)
 	if(up != nil && up->nlocks)
 		print("qlock: %lux: nlocks %lud", getcallerpc(&q), up->nlocks);
 		print("qlock: %lux: nlocks %lud", getcallerpc(&q), up->nlocks);
 
 
+	if(q->use.key == 0x55555555)
+		panic("qlock: q %p, key 5*\n", q);
 	lock(&q->use);
 	lock(&q->use);
 	rwstats.qlock++;
 	rwstats.qlock++;
 	if(!q->locked) {
 	if(!q->locked) {
@@ -107,7 +109,7 @@ rlock(RWlock *q)
 	up->qnext = 0;
 	up->qnext = 0;
 	up->state = QueueingR;
 	up->state = QueueingR;
 	unlock(&q->use);
 	unlock(&q->use);
-	if (edf->isedf(up))
+	if(edf->isedf(up))
 		edf->edfblock(up);
 		edf->edfblock(up);
 	sched();
 	sched();
 }
 }
@@ -164,7 +166,7 @@ wlock(RWlock *q)
 	up->qnext = 0;
 	up->qnext = 0;
 	up->state = QueueingW;
 	up->state = QueueingW;
 	unlock(&q->use);
 	unlock(&q->use);
-	if (edf->isedf(up))
+	if(edf->isedf(up))
 		edf->edfblock(up);
 		edf->edfblock(up);
 	sched();
 	sched();
 }
 }

+ 5 - 2
sys/src/9/port/realtimesub.c

@@ -184,9 +184,12 @@ resourcetimes(Task *task, Head *h)
 			C =  c->p->C;
 			C =  c->p->C;
 		else
 		else
 			C =  task->C;
 			C =  task->C;
-		if (c->C > C)
+		if (task->flags & BestEffort){
+			if (c->C == 0)
+				error("no cost specified for resource");
+		}else if (c->C > C)
 			error("resource uses too much time");
 			error("resource uses too much time");
-		if (c->C == 0)
+		else if (c->C == 0)
 			c->C = C;
 			c->C = C;
 		r = c->i;
 		r = c->i;
 		assert(r);
 		assert(r);

+ 0 - 1
sys/src/9/port/sd.h

@@ -47,7 +47,6 @@ struct SDunit {
 	int	subno;
 	int	subno;
 	uchar	inquiry[256];		/* format follows SCSI spec */
 	uchar	inquiry[256];		/* format follows SCSI spec */
 	SDperm;
 	SDperm;
-	Rendez	rendez;
 
 
 	QLock	ctl;
 	QLock	ctl;
 	ulong	sectors;
 	ulong	sectors;

+ 1 - 1
sys/src/9/port/swap.c

@@ -167,7 +167,7 @@ loop:
 
 
 			/* Emulate the old system if no swap channel */
 			/* Emulate the old system if no swap channel */
 			print("no physical memory\n");
 			print("no physical memory\n");
-			tsleep(&swapalloc.pause, return0, 0, 5000);
+			tsleep(&up->sleep, return0, 0, 5000);
 			wakeup(&palloc.r);
 			wakeup(&palloc.r);
 		}
 		}
 	}
 	}

+ 342 - 36
sys/src/9/port/sysfile.c

@@ -342,9 +342,9 @@ unionread(Chan *c, void *va, long n)
 		mount = mount->next;
 		mount = mount->next;
 
 
 	nr = 0;
 	nr = 0;
-	while(mount != nil) {
+	while(mount != nil){
 		/* Error causes component of union to be skipped */
 		/* Error causes component of union to be skipped */
-		if(mount->to && !waserror()) {
+		if(mount->to && !waserror()){
 			if(c->umc == nil){
 			if(c->umc == nil){
 				c->umc = cclone(mount->to);
 				c->umc = cclone(mount->to);
 				c->umc = devtab[c->umc->type]->open(c->umc, OREAD);
 				c->umc = devtab[c->umc->type]->open(c->umc, OREAD);
@@ -359,7 +359,7 @@ unionread(Chan *c, void *va, long n)
 
 
 		/* Advance to next element */
 		/* Advance to next element */
 		c->uri++;
 		c->uri++;
-		if(c->umc) {
+		if(c->umc){
 			cclose(c->umc);
 			cclose(c->umc);
 			c->umc = nil;
 			c->umc = nil;
 		}
 		}
@@ -370,52 +370,314 @@ unionread(Chan *c, void *va, long n)
 	return nr;
 	return nr;
 }
 }
 
 
+static void
+unionrewind(Chan *c)
+{
+	qlock(&c->umqlock);
+	c->uri = 0;
+	if(c->umc){
+		cclose(c->umc);
+		c->umc = nil;
+	}
+	qunlock(&c->umqlock);
+}
+
+static void
+dirqid(uchar *p, Qid *q)
+{
+	p += BIT16SZ+BIT16SZ+BIT32SZ;
+	q->type = GBIT8(p);
+	p += BIT8SZ;
+	q->vers = GBIT32(p);
+	p += BIT32SZ;
+	q->path = GBIT64(p);
+}
+
+static char*
+dirname(uchar *p, int *n)
+{
+	p += BIT16SZ+BIT16SZ+BIT32SZ+BIT8SZ+BIT32SZ+BIT64SZ
+		+ BIT32SZ+BIT32SZ+BIT32SZ+BIT64SZ;
+	*n = GBIT16(p);
+	return (char*)p+BIT16SZ;
+}
+
+static long
+dirsetname(char *name, int len, uchar *p, long n, long maxn)
+{
+	char *oname;
+	int olen;
+	long nn;
+
+	if(n == BIT16SZ)
+		return BIT16SZ;
+
+	oname = dirname(p, &olen);
+
+	nn = n+len-olen;
+	PBIT16(p, nn-BIT16SZ);
+	if(nn > maxn)
+		return BIT16SZ;
+
+	if(len != olen)
+		memmove(oname+len, oname+olen, p+n-(uchar*)(oname+olen));
+	PBIT16((uchar*)(oname-2), len);
+	memmove(oname, name, len);
+	return nn;
+}
+
+/*
+ * Mountfix might have caused the fixed results of the directory read
+ * to overflow the buffer.  Catch the overflow in c->dirrock.
+ */
+static void
+mountrock(Chan *c, uchar *p, uchar **pe)
+{
+	uchar *e, *r;
+	int len, n;
+
+	e = *pe;
+
+	/* find last directory entry */
+	for(;;){
+		len = BIT16SZ+GBIT16(p);
+		if(p+len >= e)
+			break;
+		p += len;
+	}
+
+	/* save it away */
+	qlock(&c->rockqlock);
+	if(c->nrock+len > c->mrock){
+		n = ROUND(c->nrock+len, 1024);
+		r = smalloc(n);
+		memmove(r, c->dirrock, c->nrock);
+		free(c->dirrock);
+		c->dirrock = r;
+		c->mrock = n;
+	}
+	memmove(c->dirrock+c->nrock, p, len);
+	c->nrock += len;
+	qunlock(&c->rockqlock);
+
+	/* drop it */
+	*pe = p;
+}
+
+/*
+ * Satisfy a directory read with the results saved in c->dirrock.
+ */
+static int
+mountrockread(Chan *c, uchar *op, long n, long *nn)
+{
+	long dirlen;
+	uchar *rp, *erp, *ep, *p;
+
+	/* common case */
+	if(c->nrock == 0)
+		return 0;
+
+	/* copy out what we can */
+	qlock(&c->rockqlock);
+	rp = c->dirrock;
+	erp = rp+c->nrock;
+	p = op;
+	ep = p+n;
+	while(rp+BIT16SZ <= erp){
+		dirlen = BIT16SZ+GBIT16(rp);
+		if(p+dirlen > ep)
+			break;
+		memmove(p, rp, dirlen);
+		p += dirlen;
+		rp += dirlen;
+	}
+
+	if(p == op){
+		qunlock(&c->rockqlock);
+		return 0;
+	}
+
+	/* shift the rest */
+	if(rp != erp)
+		memmove(c->dirrock, rp, erp-rp);
+	c->nrock = erp - rp;
+
+	*nn = p - op;
+	qunlock(&c->rockqlock);
+	return 1;
+}
+
+static void
+mountrewind(Chan *c)
+{
+	c->nrock = 0;
+}
+
+/*
+ * Rewrite the results of a directory read to reflect current 
+ * name space bindings and mounts.  Specifically, replace
+ * directory entries for bind and mount points with the results
+ * of statting what is mounted there.  Except leave the old names.
+ */
+static long
+mountfix(Chan *c, uchar *op, long n, long maxn)
+{
+	char *name;
+	int nbuf, nname;
+	Chan *nc;
+	Mhead *mh;
+	Mount *m;
+	uchar *p;
+	int dirlen, rest;
+	long l;
+	Qid q;
+	uchar *buf, *e;
+
+	p = op;
+	buf = nil;
+	nbuf = 0;
+	for(e=&p[n]; p+BIT16SZ<e; p+=dirlen){
+		dirlen = BIT16SZ+GBIT16(p);
+		if(p+dirlen > e)
+			break;
+		dirqid(p, &q);
+		nc = nil;
+		mh = nil;
+		if(findmount(&nc, &mh, c->type, c->dev, q)){
+			/*
+			 * If it's a union directory and the original is
+			 * in the union, don't rewrite anything.
+			 */
+			for(m=mh->mount; m; m=m->next)
+				if(eqchantdqid(m->to, c->type, c->dev, q, 1))
+					goto Norewrite;
+
+			name = dirname(p, &nname);
+		//	print("mnted %.*s\n", utfnlen(name, nname), name);
+			/*
+			 * Do the stat but fix the name.  If it fails, leave old entry.
+			 * BUG: If it fails because there isn't room for the entry,
+			 * what can we do?  Nothing, really.  Might as well skip it.
+			 */
+			if(buf == nil){
+				buf = smalloc(4096);
+				nbuf = 4096;
+			}
+			if(waserror())
+				goto Norewrite;
+			l = devtab[nc->type]->stat(nc, buf, nbuf);
+			l = dirsetname(name, nname, buf, l, nbuf);
+			if(l == BIT16SZ)
+				goto Norewrite;
+			poperror();
+
+			/*
+			 * Shift data in buffer to accomodate new entry,
+			 * possibly overflowing into rock.
+			 */
+			rest = e - (p+dirlen);
+			if(l > dirlen){
+				while(p+l+rest > op+maxn){
+					mountrock(c, p, &e);
+					if(e == p){
+						dirlen = 0;
+						goto Norewrite;
+					}
+					rest = e - (p+dirlen);
+				}
+			}
+			if(l != dirlen){
+				memmove(p+l, p+dirlen, rest);
+				dirlen = l;
+				e = p+dirlen+rest;
+			}
+
+			/*
+			 * Rewrite directory entry.
+			 */
+			memmove(p, buf, l);
+
+		    Norewrite:
+			cclose(nc);
+			putmhead(mh);
+		}
+	}
+	if(buf)
+		free(buf);
+
+	if(p != e)
+		error("oops in rockfix");
+
+	return e-op;
+}
+
 static long
 static long
 read(ulong *arg, vlong *offp)
 read(ulong *arg, vlong *offp)
 {
 {
 	int dir;
 	int dir;
-	long n;
+	long n, nn, nnn;
+	uchar *p;
 	Chan *c;
 	Chan *c;
 	vlong off;
 	vlong off;
 
 
 	n = arg[2];
 	n = arg[2];
 	validaddr(arg[1], n, 1);
 	validaddr(arg[1], n, 1);
+	p = (void*)arg[1];
 	c = fdtochan(arg[0], OREAD, 1, 1);
 	c = fdtochan(arg[0], OREAD, 1, 1);
 
 
-	if(waserror()) {
+	if(waserror()){
 		cclose(c);
 		cclose(c);
 		nexterror();
 		nexterror();
 	}
 	}
 
 
-	dir = c->qid.type&QTDIR;
 	/*
 	/*
-	 * The offset is passed through on directories, normally. sysseek complains but
-	 * pread is used by servers and e.g. exportfs that shouldn't need to worry about this issue.
+	 * The offset is passed through on directories, normally.
+	 * Sysseek complains, but pread is used by servers like exportfs,
+	 * that shouldn't need to worry about this issue.
+	 *
+	 * Notice that c->devoffset is the offset that c's dev is seeing.
+	 * The number of bytes read on this fd (c->offset) may be different
+	 * due to rewritings in rockfix.
 	 */
 	 */
-
 	if(offp == nil)	/* use and maintain channel's offset */
 	if(offp == nil)	/* use and maintain channel's offset */
 		off = c->offset;
 		off = c->offset;
 	else
 	else
 		off = *offp;
 		off = *offp;
-
 	if(off < 0)
 	if(off < 0)
 		error(Enegoff);
 		error(Enegoff);
 
 
-	if(dir && c->umh)
-		n = unionread(c, (void*)arg[1], n);
-	else
-		n = devtab[c->type]->read(c, (void*)arg[1], n, off);
+	if(off == 0){	/* rewind to the beginning of the directory */
+		if(offp == nil){
+			c->offset = 0;
+			c->devoffset = 0;
+		}
+		mountrewind(c);
+		unionrewind(c);
+	}
 
 
-	if(offp == nil){
-		lock(c);
-		c->offset += n;
-		unlock(c);
+	dir = c->qid.type&QTDIR;
+	if(dir && mountrockread(c, p, n, &nn)){
+		/* do nothing: mountrockread filled buffer */
+	}else{
+		if(dir && c->umh)
+			nn = unionread(c, p, n);
+		else
+			nn = devtab[c->type]->read(c, p, n, off);
 	}
 	}
+	if(dir)
+		nnn = mountfix(c, p, nn, n);
+	else
+		nnn = nn;
+
+	lock(c);
+	c->devoffset += nn;
+	c->offset += nnn;
+	unlock(c);
 
 
 	poperror();
 	poperror();
 	cclose(c);
 	cclose(c);
 
 
-	return n;
+	return nnn;
 }
 }
 
 
 long
 long
@@ -635,6 +897,21 @@ validstat(uchar *s, int n)
 		validname(buf, 0);
 		validname(buf, 0);
 }
 }
 
 
+static char*
+cnamelast(Cname *n)
+{
+	char *s;
+
+	if(n == nil)
+		return nil;
+	if(n->len == 0)
+		return nil;
+	s = strrchr(n->s, '/');
+	if(s)
+		return s+1;
+	return n->s;
+}
+
 long
 long
 sysfstat(ulong *arg)
 sysfstat(ulong *arg)
 {
 {
@@ -657,6 +934,7 @@ sysfstat(ulong *arg)
 long
 long
 sysstat(ulong *arg)
 sysstat(ulong *arg)
 {
 {
+	char *name;
 	Chan *c;
 	Chan *c;
 	uint l;
 	uint l;
 
 
@@ -669,6 +947,10 @@ sysstat(ulong *arg)
 		nexterror();
 		nexterror();
 	}
 	}
 	l = devtab[c->type]->stat(c, (uchar*)arg[1], l);
 	l = devtab[c->type]->stat(c, (uchar*)arg[1], l);
+	name = cnamelast(c->name);
+	if(name)
+		l = dirsetname(name, strlen(name), (uchar*)arg[1], l, arg[2]);
+
 	poperror();
 	poperror();
 	cclose(c);
 	cclose(c);
 	return l;
 	return l;
@@ -859,6 +1141,12 @@ sysremove(ulong *arg)
 		cclose(c);
 		cclose(c);
 		nexterror();
 		nexterror();
 	}
 	}
+	/*
+	 * Removing mount points is disallowed to avoid surprises
+	 * (which should be removed: the mount point or the mounted Chan?).
+	 */
+	if(c->ismtpt)
+		error(Eismtpt);
 	devtab[c->type]->remove(c);
 	devtab[c->type]->remove(c);
 	/*
 	/*
 	 * Remove clunks the fid, but we need to recover the Chan
 	 * Remove clunks the fid, but we need to recover the Chan
@@ -870,6 +1158,31 @@ sysremove(ulong *arg)
 	return 0;
 	return 0;
 }
 }
 
 
+static long
+wstat(Chan *c, uchar *d, int nd)
+{
+	long l;
+	int namelen;
+
+	if(waserror()){
+		cclose(c);
+		nexterror();
+	}
+	if(c->ismtpt){
+		/*
+		 * Renaming mount points is disallowed to avoid surprises
+		 * (which should be renamed: the mount point or the mounted Chan?).
+		 */
+		dirname(d, &namelen);
+		if(namelen)
+			nameerror(channame(c), Eismtpt);
+	}
+	l = devtab[c->type]->wstat(c, d, nd);
+	poperror();
+	cclose(c);
+	return l;
+}
+
 long
 long
 syswstat(ulong *arg)
 syswstat(ulong *arg)
 {
 {
@@ -881,14 +1194,7 @@ syswstat(ulong *arg)
 	validstat((uchar*)arg[1], l);
 	validstat((uchar*)arg[1], l);
 	validaddr(arg[0], 1, 0);
 	validaddr(arg[0], 1, 0);
 	c = namec((char*)arg[0], Aaccess, 0, 0);
 	c = namec((char*)arg[0], Aaccess, 0, 0);
-	if(waserror()){
-		cclose(c);
-		nexterror();
-	}
-	l = devtab[c->type]->wstat(c, (uchar*)arg[1], l);
-	poperror();
-	cclose(c);
-	return l;
+	return wstat(c, (uchar*)arg[1], l);
 }
 }
 
 
 long
 long
@@ -901,14 +1207,7 @@ sysfwstat(ulong *arg)
 	validaddr(arg[1], l, 0);
 	validaddr(arg[1], l, 0);
 	validstat((uchar*)arg[1], l);
 	validstat((uchar*)arg[1], l);
 	c = fdtochan(arg[0], -1, 1, 1);
 	c = fdtochan(arg[0], -1, 1, 1);
-	if(waserror()) {
-		cclose(c);
-		nexterror();
-	}
-	l = devtab[c->type]->wstat(c, (uchar*)arg[1], l);
-	poperror();
-	cclose(c);
-	return l;
+	return wstat(c, (uchar*)arg[1], l);
 }
 }
 
 
 static void
 static void
@@ -951,7 +1250,7 @@ sys_stat(ulong *arg)
 	Chan *c;
 	Chan *c;
 	uint l;
 	uint l;
 	uchar buf[128];	/* old DIRLEN plus a little should be plenty */
 	uchar buf[128];	/* old DIRLEN plus a little should be plenty */
-	char strs[128];
+	char strs[128], *name;
 	Dir d;
 	Dir d;
 	char old[] = "old stat system call - recompile";
 	char old[] = "old stat system call - recompile";
 
 
@@ -966,6 +1265,9 @@ sys_stat(ulong *arg)
 	/* buf contains a new stat buf; convert to old. yuck. */
 	/* buf contains a new stat buf; convert to old. yuck. */
 	if(l <= BIT16SZ)	/* buffer too small; time to face reality */
 	if(l <= BIT16SZ)	/* buffer too small; time to face reality */
 		error(old);
 		error(old);
+	name = cnamelast(c->name);
+	if(name)
+		l = dirsetname(name, strlen(name), buf, l, sizeof buf);
 	l = convM2D(buf, l, &d, strs);
 	l = convM2D(buf, l, &d, strs);
 	if(l == 0)
 	if(l == 0)
 		error(old);
 		error(old);
@@ -980,6 +1282,7 @@ long
 sys_fstat(ulong *arg)
 sys_fstat(ulong *arg)
 {
 {
 	Chan *c;
 	Chan *c;
+	char *name;
 	uint l;
 	uint l;
 	uchar buf[128];	/* old DIRLEN plus a little should be plenty */
 	uchar buf[128];	/* old DIRLEN plus a little should be plenty */
 	char strs[128];
 	char strs[128];
@@ -996,6 +1299,9 @@ sys_fstat(ulong *arg)
 	/* buf contains a new stat buf; convert to old. yuck. */
 	/* buf contains a new stat buf; convert to old. yuck. */
 	if(l <= BIT16SZ)	/* buffer too small; time to face reality */
 	if(l <= BIT16SZ)	/* buffer too small; time to face reality */
 		error(old);
 		error(old);
+	name = cnamelast(c->name);
+	if(name)
+		l = dirsetname(name, strlen(name), buf, l, sizeof buf);
 	l = convM2D(buf, l, &d, strs);
 	l = convM2D(buf, l, &d, strs);
 	if(l == 0)
 	if(l == 0)
 		error(old);
 		error(old);

+ 2 - 1
sys/src/9/port/sysproc.c

@@ -659,6 +659,7 @@ generrstr(char *buf, uint nbuf)
 	if(nbuf > sizeof tmp)
 	if(nbuf > sizeof tmp)
 		nbuf = sizeof tmp;
 		nbuf = sizeof tmp;
 	memmove(tmp, buf, nbuf);
 	memmove(tmp, buf, nbuf);
+
 	/* make sure it's NUL-terminated */
 	/* make sure it's NUL-terminated */
 	tmp[nbuf-1] = '\0';
 	tmp[nbuf-1] = '\0';
 	memmove(buf, up->syserrstr, nbuf);
 	memmove(buf, up->syserrstr, nbuf);
@@ -838,7 +839,7 @@ sysrendezvous(ulong *arg)
 	*l = up;
 	*l = up;
 	up->state = Rendezvous;
 	up->state = Rendezvous;
 	unlock(up->rgrp);
 	unlock(up->rgrp);
-	if (edf->isedf(up))
+	if(edf->isedf(up))
 		edf->edfblock(up);
 		edf->edfblock(up);
 
 
 	sched();
 	sched();

+ 0 - 6
sys/src/cmd/auth/passwd.c

@@ -54,12 +54,6 @@ main(int argc, char **argv)
 	ARGBEGIN{
 	ARGBEGIN{
 	}ARGEND
 	}ARGEND
 
 
-	s = getenv("service");
-	if(s && strcmp(s, "cpu") == 0){
-		fprint(2, "passwd must not be run on the cpu server\n");
-		exits("boofhead");
-	}
-
 	s = nil;
 	s = nil;
 	if(argc > 0){
 	if(argc > 0){
 		user = argv[0];
 		user = argv[0];

Some files were not shown because too many files changed in this diff