Browse Source

Plan 9 from Bell Labs 2010-01-22

David du Colombier 14 years ago
parent
commit
4b8493e999

+ 16 - 11
386/bin/usb/probe

@@ -1,21 +1,26 @@
 #!/bin/rc
+# usb/probe [-h] - list all usb devices, including hubs
 rfork e
 test -e /dev/usb || bind -a '#u' /dev || {
 	echo no '#u/usb' >[1=2]
 	exit nousb
 }
 
-awk 'BEGIN{ep="";}
-	$1 ~ /ep[0-9]+\.0/ && $2 == "enabled" && $NF ~ /busy|idle/ {
-		ep=$1;
-		next;
-	}
-	{
-		if(ep != ""){
-			printf("%s %s\n", ep, $0);
-			ep="";
-		}
+filter = cat
+if (~ $1 -h)
+	filter = (grep -v ' (root)?hub ')
+
+awk 'BEGIN	{ ep = "" }
+$1 ~ /ep[0-9]+\.0/ && $2 == "enabled" && $NF ~ /busy|idle/ {
+	ep=$1
+	next
+}
+{
+	if(ep != ""){
+		printf "%s %s\n", ep, $0
+		ep = ""
 	}
-' /dev/usb/ctl
+}
+' /dev/usb/ctl | $filter
 
 exit ''

+ 19 - 0
sys/doc/ape.ms

@@ -414,6 +414,25 @@ and
 (for parsing a line into fields).
 See the Research Unix System Programmer's Manual, Tenth Edition, for a description
 of these functions.
+.XX
+.CW _C99_SNPRINTF_EXTENSION .
+This extension permits the use of the return values of
+.I snprintf
+and
+.I vsnprintf .
+Before C99, the 1999 C standard,
+these functions usually returned the number of bytes,
+excluding terminating NUL,
+actually stored in the target string.
+(GNU, as usual, had to be different and returned -1 if the target
+string was too small.)
+C99 requires them to instead return the number of bytes,
+excluding terminating NUL,
+that would have been written into the target string if it were infinitely large,
+so old programs compiled under C99 rules will be prone to overrunning
+their buffers.
+This extension is a way for the programmer to declare that he or she understands
+the situation and has adjusted the code being compiled to compensate.
 .SH
 Common Problems
 .PP

+ 656 - 486
sys/doc/ape.ps

@@ -3129,6 +3129,7 @@ cleartomark
 %%EndResource
 %!PS-Adobe-2.0
 %%Version: 0.1
+%%Creator: troff, Plan 9 edition
 %%Pages: (atend)
 %%EndComments
 %
@@ -5234,249 +5235,289 @@ mark
 10 /LucidaSansUnicode20 f
 (\023) 816 4896 w
 10 /LucidaTypewriter f
-(_REGEXP_EXTENSION) 970 4896 w
-10 /LucidaSansUnicode00 f
-(.) 2194 4896 w
-(This) 2291 4896 w
-(extension) 2529 4896 w
-(allows) 3037 4896 w
-(inclusion) 3372 4896 w
-(of) 3841 4896 w
-10 /LucidaTypewriter f
-(<regexp.h>) 3973 4896 w
-10 /LucidaSansUnicode00 f
-(,) 4693 4896 w
-(which) 4759 4896 w
-(defines) 970 5016 w
-(the) 1365 5016 w
-(regular) 1561 5016 w
-(expression) 1947 5016 w
-(matching) 2518 5016 w
-(functions) 3009 5016 w
-(described) 3501 5016 w
-(in) 4014 5016 w
-(the) 4145 5016 w
-(Plan) 4340 5016 w
-(9) 4581 5016 w
-(manual) 4684 5016 w
-(page) 970 5136 w
-10 /LucidaSans-Italic f
-(regexp) 1238 5136 w
+(_PLAN9_EXTENSION) 970 4896 w
+10 /LucidaSansUnicode00 f
+(.) 2122 4896 w
+(This) 2234 4896 w
+(extension) 2487 4896 w
+(allows) 3010 4896 w
+(inclusion) 3360 4896 w
+(of) 3844 4896 w
+10 /LucidaTypewriter f
+(<u.h>) 3991 4896 w
+10 /LucidaSansUnicode00 f
+(,) 4351 4896 w
+10 /LucidaTypewriter f
+(<lock.h>) 4432 4896 w
+10 /LucidaSansUnicode00 f
+(,) 5008 4896 w
+10 /LucidaTypewriter f
+(<qlock.h>) 970 5016 w
+10 /LucidaSansUnicode00 f
+(,) 1618 5016 w
+10 /LucidaTypewriter f
+(<utf.h>) 1689 5016 w
+10 /LucidaSansUnicode00 f
+(,) 2193 5016 w
+10 /LucidaTypewriter f
+(<fmt.h>) 2264 5016 w
+10 /LucidaSansUnicode00 f
+(,) 2768 5016 w
+(and) 2839 5016 w
+10 /LucidaTypewriter f
+(<draw.h>) 3058 5016 w
 10 /LucidaSansUnicode00 f
-(\(2\).) 1568 5136 w
+(.) 3634 5016 w
+(These) 3737 5016 w
+(are) 4064 5016 w
+(pieces) 4255 5016 w
+(of) 4600 5016 w
+(Plan) 4737 5016 w
+(9) 4977 5016 w
+(source code ported into APE, mostly from) 970 5136 w
+10 /LucidaTypewriter f
+(<libc.h>) 3022 5136 w
+10 /LucidaSansUnicode00 f
+(.) 3598 5136 w
 10 /LucidaSansUnicode20 f
 (\023) 816 5292 w
 10 /LucidaTypewriter f
-(_RESEARCH_SOURCE) 970 5292 w
+(_REGEXP_EXTENSION) 970 5292 w
+10 /LucidaSansUnicode00 f
+(.) 2194 5292 w
+(This) 2291 5292 w
+(extension) 2529 5292 w
+(allows) 3037 5292 w
+(inclusion) 3372 5292 w
+(of) 3841 5292 w
+10 /LucidaTypewriter f
+(<regexp.h>) 3973 5292 w
+10 /LucidaSansUnicode00 f
+(,) 4693 5292 w
+(which) 4759 5292 w
+(defines) 970 5412 w
+(the) 1365 5412 w
+(regular) 1561 5412 w
+(expression) 1947 5412 w
+(matching) 2518 5412 w
+(functions) 3009 5412 w
+(described) 3501 5412 w
+(in) 4014 5412 w
+(the) 4145 5412 w
+(Plan) 4340 5412 w
+(9) 4581 5412 w
+(manual) 4684 5412 w
+(page) 970 5532 w
+10 /LucidaSans-Italic f
+(regexp) 1238 5532 w
 10 /LucidaSansUnicode00 f
-(.) 2122 5292 w
-(This) 2230 5292 w
-(extension) 2479 5292 w
-(enables) 2998 5292 w
-(a) 3414 5292 w
-(small) 3513 5292 w
-(library) 3814 5292 w
-(of) 4168 5292 w
-(functions) 4311 5292 w
-(from) 4808 5292 w
-(the) 970 5412 w
-(Tenth) 1184 5412 w
-(Edition) 1523 5412 w
-(Unix) 1917 5412 w
-(Research) 2197 5412 w
-(System) 2691 5412 w
-(\(V10\).) 3093 5412 w
-(These) 3473 5412 w
-(functions) 3820 5412 w
-(and) 4330 5412 w
-(the) 4568 5412 w
-(types) 4781 5412 w
-(needed) 970 5532 w
-(to) 1364 5532 w
-(use) 1500 5532 w
-(them) 1707 5532 w
-(are) 1993 5532 w
-(all) 2183 5532 w
-(defined) 2334 5532 w
-(in) 2738 5532 w
-(the) 2867 5532 w
+(\(2\).) 1568 5532 w
+10 /LucidaSansUnicode20 f
+(\023) 816 5688 w
 10 /LucidaTypewriter f
-(<libv.h>) 3060 5532 w
+(_RESEARCH_SOURCE) 970 5688 w
 10 /LucidaSansUnicode00 f
-(header.) 3674 5532 w
-(The) 4109 5532 w
-(provided) 4328 5532 w
-(func\255) 4795 5532 w
-(tions) 970 5652 w
-(are:) 1264 5652 w
+(.) 2122 5688 w
+(This) 2230 5688 w
+(extension) 2479 5688 w
+(enables) 2998 5688 w
+(a) 3414 5688 w
+(small) 3513 5688 w
+(library) 3814 5688 w
+(of) 4168 5688 w
+(functions) 4311 5688 w
+(from) 4808 5688 w
+(the) 970 5808 w
+(Tenth) 1184 5808 w
+(Edition) 1523 5808 w
+(Unix) 1917 5808 w
+(Research) 2197 5808 w
+(System) 2691 5808 w
+(\(V10\).) 3093 5808 w
+(These) 3473 5808 w
+(functions) 3820 5808 w
+(and) 4330 5808 w
+(the) 4568 5808 w
+(types) 4781 5808 w
+(needed) 970 5928 w
+(to) 1364 5928 w
+(use) 1500 5928 w
+(them) 1707 5928 w
+(are) 1993 5928 w
+(all) 2183 5928 w
+(defined) 2334 5928 w
+(in) 2738 5928 w
+(the) 2867 5928 w
 10 /LucidaTypewriter f
-(srand) 1502 5652 w
+(<libv.h>) 3060 5928 w
 10 /LucidaSansUnicode00 f
-(,) 1862 5652 w
+(header.) 3674 5928 w
+(The) 4109 5928 w
+(provided) 4328 5928 w
+(func\255) 4795 5928 w
+(tions) 970 6048 w
+(are:) 1264 6048 w
 10 /LucidaTypewriter f
-(rand) 1948 5652 w
+(srand) 1502 6048 w
 10 /LucidaSansUnicode00 f
-(,) 2236 5652 w
+(,) 1862 6048 w
 10 /LucidaTypewriter f
-(nrand) 2322 5652 w
+(rand) 1948 6048 w
 10 /LucidaSansUnicode00 f
-(,) 2682 5652 w
+(,) 2236 6048 w
 10 /LucidaTypewriter f
-(lrand) 2768 5652 w
+(nrand) 2322 6048 w
 10 /LucidaSansUnicode00 f
-(,) 3128 5652 w
-(and) 3213 5652 w
+(,) 2682 6048 w
 10 /LucidaTypewriter f
-(frand) 3446 5652 w
+(lrand) 2768 6048 w
 10 /LucidaSansUnicode00 f
-(\(better) 3859 5652 w
-(random) 4235 5652 w
-(number) 4663 5652 w
-(generators\);) 970 5772 w
+(,) 3128 6048 w
+(and) 3213 6048 w
 10 /LucidaTypewriter f
-(getpass) 1591 5772 w
+(frand) 3446 6048 w
 10 /LucidaSansUnicode00 f
-(,) 2095 5772 w
+(\(better) 3859 6048 w
+(random) 4235 6048 w
+(number) 4663 6048 w
+(generators\);) 970 6168 w
 10 /LucidaTypewriter f
-(tty_echoon) 2161 5772 w
+(getpass) 1591 6168 w
 10 /LucidaSansUnicode00 f
-(,) 2881 5772 w
+(,) 2095 6168 w
 10 /LucidaTypewriter f
-(tty_echooff) 2947 5772 w
+(tty_echoon) 2161 6168 w
 10 /LucidaSansUnicode00 f
-(\(for) 3774 5772 w
-(dealing) 3981 5772 w
-(with) 4372 5772 w
-(the) 4612 5772 w
-(com\255) 4802 5772 w
-(mon) 970 5892 w
-(needs) 1238 5892 w
-(for) 1578 5892 w
-(mucking) 1769 5892 w
-(with) 2238 5892 w
-(terminal) 2495 5892 w
-(characteristics\);) 2949 5892 w
+(,) 2881 6168 w
 10 /LucidaTypewriter f
-(min) 3763 5892 w
+(tty_echooff) 2947 6168 w
 10 /LucidaSansUnicode00 f
-(and) 4031 5892 w
+(\(for) 3774 6168 w
+(dealing) 3981 6168 w
+(with) 4372 6168 w
+(the) 4612 6168 w
+(com\255) 4802 6168 w
+(mon) 970 6288 w
+(needs) 1238 6288 w
+(for) 1578 6288 w
+(mucking) 1769 6288 w
+(with) 2238 6288 w
+(terminal) 2495 6288 w
+(characteristics\);) 2949 6288 w
 10 /LucidaTypewriter f
-(max) 4262 5892 w
+(min) 3763 6288 w
 10 /LucidaSansUnicode00 f
-(;) 4478 5892 w
+(and) 4031 6288 w
 10 /LucidaTypewriter f
-(nap) 4561 5892 w
+(max) 4262 6288 w
 10 /LucidaSansUnicode00 f
-(;) 4777 5892 w
-(and) 4860 5892 w
+(;) 4478 6288 w
 10 /LucidaTypewriter f
-(setfields) 970 6012 w
+(nap) 4561 6288 w
 10 /LucidaSansUnicode00 f
-(,) 1618 6012 w
+(;) 4777 6288 w
+(and) 4860 6288 w
 10 /LucidaTypewriter f
-(getfields) 1682 6012 w
+(setfields) 970 6408 w
 10 /LucidaSansUnicode00 f
-(, and) 2330 6012 w
+(,) 1618 6408 w
 10 /LucidaTypewriter f
-(getmfields) 2606 6012 w
+(getfields) 1682 6408 w
 10 /LucidaSansUnicode00 f
-(\(for) 3359 6012 w
-(parsing) 3564 6012 w
-(a) 3960 6012 w
-(line) 4048 6012 w
-(into) 4257 6012 w
-(fields\).) 4479 6012 w
-(See) 4874 6012 w
-(the) 970 6132 w
-(Research) 1159 6132 w
-(Unix) 1628 6132 w
-(System) 1883 6132 w
-(Programmer) 2260 6132 w
+(, and) 2330 6408 w
+10 /LucidaTypewriter f
+(getmfields) 2606 6408 w
+10 /LucidaSansUnicode00 f
+(\(for) 3359 6408 w
+(parsing) 3564 6408 w
+(a) 3960 6408 w
+(line) 4048 6408 w
+(into) 4257 6408 w
+(fields\).) 4479 6408 w
+(See) 4874 6408 w
+(the) 970 6528 w
+(Research) 1159 6528 w
+(Unix) 1628 6528 w
+(System) 1883 6528 w
+(Programmer) 2260 6528 w
 10 /LucidaSansUnicode20 f
-(\031) 2858 6132 w
-10 /LucidaSansUnicode00 f
-(s) 2890 6132 w
-(Manual,) 2975 6132 w
-(Tenth) 3390 6132 w
-(Edition,) 3704 6132 w
-(for) 4105 6132 w
-(a) 4278 6132 w
-(description) 4366 6132 w
-(of) 4942 6132 w
-(these functions.) 970 6252 w
-10 /LucidaSans-Demi f
-(Common Problems) 720 6492 w
-10 /LucidaSansUnicode00 f
-(Some) 970 6648 w
-(large) 1273 6648 w
-(systems,) 1555 6648 w
-(including) 2017 6648 w
-(X11,) 2506 6648 w
-(have) 2767 6648 w
-(been) 3032 6648 w
-(ported) 3309 6648 w
-(successfully) 3670 6648 w
-(to) 4292 6648 w
-(Plan) 4430 6648 w
-(9) 4671 6648 w
-(using) 4774 6648 w
-(APE) 720 6768 w
-(\(the) 948 6768 w
-(X11) 1185 6768 w
-(port) 1423 6768 w
-(is) 1674 6768 w
-(not) 1803 6768 w
-(included) 2012 6768 w
-(in) 2476 6768 w
-(the) 2616 6768 w
-(distribution,) 2820 6768 w
-(however,) 3465 6768 w
-(because) 3951 6768 w
-(supporting) 4394 6768 w
-(it) 4974 6768 w
-(properly) 720 6888 w
-(is) 1181 6888 w
-(too) 1316 6888 w
-(big) 1530 6888 w
-(a) 1739 6888 w
-(job\).) 1849 6888 w
-(The) 2155 6888 w
-(problems) 2391 6888 w
-(encountered) 2903 6888 w
-(fall) 3565 6888 w
-(into) 3771 6888 w
-(three) 4016 6888 w
-(categories:) 4324 6888 w
-(\(1\)) 4911 6888 w
-(non-ANSI) 720 7008 w
-(C/POSIX) 1230 7008 w
-(features) 1672 7008 w
-(used;) 2108 7008 w
-(\(2\)) 2413 7008 w
-(inadequate) 2583 7008 w
-(simulation) 3162 7008 w
-(of) 3710 7008 w
-(POSIX) 3848 7008 w
-(functions;) 4167 7008 w
-(and) 4691 7008 w
-(\(3\)) 4911 7008 w
-(compiler/loader bugs.) 720 7128 w
-(By far the majority of problems are in the first category.) 1867 7128 w
-(POSIX) 970 7284 w
-(is) 1282 7284 w
-(just) 1395 7284 w
-(starting) 1608 7284 w
-(to) 2015 7284 w
-(be) 2146 7284 w
-(a) 2298 7284 w
-(target) 2386 7284 w
-(for) 2707 7284 w
-(programmers.) 2879 7284 w
-(Most) 3633 7284 w
-(existing) 3901 7284 w
-(code) 4322 7284 w
-(is) 4587 7284 w
-(written) 4701 7284 w
+(\031) 2858 6528 w
+10 /LucidaSansUnicode00 f
+(s) 2890 6528 w
+(Manual,) 2975 6528 w
+(Tenth) 3390 6528 w
+(Edition,) 3704 6528 w
+(for) 4105 6528 w
+(a) 4278 6528 w
+(description) 4366 6528 w
+(of) 4942 6528 w
+(these functions.) 970 6648 w
+10 /LucidaSansUnicode20 f
+(\023) 816 6804 w
+10 /LucidaTypewriter f
+(_C99_SNPRINTF_EXTENSION) 970 6804 w
+10 /LucidaSansUnicode00 f
+(.) 2626 6804 w
+(This) 2743 6804 w
+(extension) 3001 6804 w
+(permits) 3529 6804 w
+(the) 3952 6804 w
+(use) 4160 6804 w
+(of) 4382 6804 w
+(the) 4533 6804 w
+(return) 4741 6804 w
+(values) 970 6924 w
+(of) 1310 6924 w
+10 /LucidaSans-Italic f
+(snprintf) 1443 6924 w
+10 /LucidaSansUnicode00 f
+(and) 1864 6924 w
+10 /LucidaSans-Italic f
+(vsnprintf) 2078 6924 w
+10 /LucidaSansUnicode00 f
+(.) 2519 6924 w
+(Before) 2617 6924 w
+(C99,) 2960 6924 w
+(the) 3221 6924 w
+(1999) 3410 6924 w
+(C) 3696 6924 w
+(standard,) 3799 6924 w
+(these) 4292 6924 w
+(functions) 4588 6924 w
+(usually returned the number of bytes, excluding terminating NUL,) 970 7044 w
+(actually) 4204 7044 w
+(stored) 4607 7044 w
+(in) 4949 7044 w
+(the) 970 7164 w
+(target) 1163 7164 w
+(string.) 1489 7164 w
+(\(GNU,) 1873 7164 w
+(as) 2191 7164 w
+(usual,) 2335 7164 w
+(had) 2664 7164 w
+(to) 2881 7164 w
+(be) 3016 7164 w
+(different) 3172 7164 w
+(and) 3627 7164 w
+(returned) 3844 7164 w
+(-1) 4299 7164 w
+(if) 4457 7164 w
+(the) 4560 7164 w
+(target) 4752 7164 w
+(string) 970 7284 w
+(was) 1296 7284 w
+(too) 1523 7284 w
+(small.\)) 1726 7284 w
+(C99) 2124 7284 w
+(requires) 2363 7284 w
+(them) 2806 7284 w
+(to) 3099 7284 w
+(instead) 3242 7284 w
+(return) 3640 7284 w
+(the) 3984 7284 w
+(number) 4184 7284 w
+(of) 4606 7284 w
+(bytes,) 4749 7284 w
 cleartomark
 showpage
 saveobj restore
@@ -5487,349 +5528,478 @@ mark
 4 pagesetup
 10 /LucidaSansUnicode00 f
 (\255 4 \255) 2783 480 w
-(to) 720 840 w
-(work) 853 840 w
-(with) 1125 840 w
-(one) 1365 840 w
-(or) 1579 840 w
-(both) 1716 840 w
-(of) 1974 840 w
-(a) 2107 840 w
-(BSD) 2197 840 w
-(or) 2419 840 w
-(a) 2556 840 w
-(System) 2646 840 w
-(V) 3024 840 w
-(Unix.) 3124 840 w
-(System) 3444 840 w
-(V) 3822 840 w
-(is) 3922 840 w
-(fairly) 4037 840 w
-(close) 4315 840 w
-(to) 4597 840 w
-(POSIX,) 4729 840 w
-(but) 720 960 w
-(there) 918 960 w
-(are) 1206 960 w
-(some) 1394 960 w
-(differences.) 1691 960 w
-(Also,) 2330 960 w
-(many) 2608 960 w
-(System) 2906 960 w
-(V) 3285 960 w
-(systems) 3386 960 w
-(have) 3813 960 w
-(imported) 4075 960 w
-(some) 4555 960 w
-(BSD) 4853 960 w
-(features) 720 1080 w
-(that) 1152 1080 w
-(are) 1380 1080 w
-(not) 1568 1080 w
-(part) 1764 1080 w
-(of) 1996 1080 w
-(POSIX.) 2130 1080 w
-(A) 2509 1080 w
-(good) 2614 1080 w
-(strategy) 2897 1080 w
-(for) 3324 1080 w
-(porting) 3499 1080 w
-(external) 3890 1080 w
-(programs) 4323 1080 w
-(is) 4826 1080 w
-(to) 4942 1080 w
-(first) 720 1200 w
-(try) 999 1200 w
-(using) 1213 1200 w
-10 /LucidaTypewriter f
-(CFLAGS=-D_POSIX_SOURCE) 1563 1200 w
-10 /LucidaSansUnicode00 f
-(;) 3147 1200 w
-(if) 3263 1200 w
-(that) 3414 1200 w
-(doesn) 3690 1200 w
+(excluding) 970 840 w
+(terminating) 1482 840 w
+(NUL,) 2082 840 w
+(that) 2347 840 w
+(would) 2575 840 w
+(have) 2904 840 w
+(been) 3166 840 w
+(written) 3439 840 w
+(into) 3814 840 w
+(the) 4039 840 w
+(target) 4230 840 w
+(string) 4554 840 w
+(if) 4872 840 w
+(it) 4974 840 w
+(were) 970 960 w
+(infinitely) 1244 960 w
+(large,) 1711 960 w
+(so) 2031 960 w
+(old) 2188 960 w
+(programs) 2386 960 w
+(compiled) 2898 960 w
+(under) 3388 960 w
+(C99) 3717 960 w
+(rules) 3957 960 w
+(will) 4241 960 w
+(be) 4450 960 w
+(prone) 4614 960 w
+(to) 4942 960 w
+(overrunning) 970 1080 w
+(their) 1602 1080 w
+(buffers.) 1869 1080 w
+(This) 2322 1080 w
+(extension) 2569 1080 w
+(is) 3085 1080 w
+(a) 3206 1080 w
+(way) 3302 1080 w
+(for) 3527 1080 w
+(the) 3707 1080 w
+(programmer) 3903 1080 w
+(to) 4550 1080 w
+(declare) 4689 1080 w
+(that) 970 1200 w
+(he) 1194 1200 w
+(or) 1346 1200 w
+(she) 1482 1200 w
+(understands) 1685 1200 w
+(the) 2322 1200 w
+(situation) 2511 1200 w
+(and) 2968 1200 w
+(has) 3182 1200 w
+(adjusted) 3384 1200 w
+(the) 3835 1200 w
+(code) 4024 1200 w
+(being) 4289 1200 w
+(compiled) 4595 1200 w
+(to compensate.) 970 1320 w
+10 /LucidaSans-Demi f
+(Common Problems) 720 1560 w
+10 /LucidaSansUnicode00 f
+(Some) 970 1716 w
+(large) 1273 1716 w
+(systems,) 1555 1716 w
+(including) 2017 1716 w
+(X11,) 2506 1716 w
+(have) 2767 1716 w
+(been) 3032 1716 w
+(ported) 3309 1716 w
+(successfully) 3670 1716 w
+(to) 4292 1716 w
+(Plan) 4430 1716 w
+(9) 4671 1716 w
+(using) 4774 1716 w
+(APE) 720 1836 w
+(\(the) 948 1836 w
+(X11) 1185 1836 w
+(port) 1423 1836 w
+(is) 1674 1836 w
+(not) 1803 1836 w
+(included) 2012 1836 w
+(in) 2476 1836 w
+(the) 2616 1836 w
+(distribution,) 2820 1836 w
+(however,) 3465 1836 w
+(because) 3951 1836 w
+(supporting) 4394 1836 w
+(it) 4974 1836 w
+(properly) 720 1956 w
+(is) 1181 1956 w
+(too) 1316 1956 w
+(big) 1530 1956 w
+(a) 1739 1956 w
+(job\).) 1849 1956 w
+(The) 2155 1956 w
+(problems) 2391 1956 w
+(encountered) 2903 1956 w
+(fall) 3565 1956 w
+(into) 3771 1956 w
+(three) 4016 1956 w
+(categories:) 4324 1956 w
+(\(1\)) 4911 1956 w
+(non-ANSI) 720 2076 w
+(C/POSIX) 1230 2076 w
+(features) 1672 2076 w
+(used;) 2108 2076 w
+(\(2\)) 2413 2076 w
+(inadequate) 2583 2076 w
+(simulation) 3162 2076 w
+(of) 3710 2076 w
+(POSIX) 3848 2076 w
+(functions;) 4167 2076 w
+(and) 4691 2076 w
+(\(3\)) 4911 2076 w
+(compiler/loader bugs.) 720 2196 w
+(By far the majority of problems are in the first category.) 1867 2196 w
+(POSIX) 970 2352 w
+(is) 1282 2352 w
+(just) 1395 2352 w
+(starting) 1608 2352 w
+(to) 2015 2352 w
+(be) 2146 2352 w
+(a) 2298 2352 w
+(target) 2386 2352 w
+(for) 2707 2352 w
+(programmers.) 2879 2352 w
+(Most) 3633 2352 w
+(existing) 3901 2352 w
+(code) 4322 2352 w
+(is) 4587 2352 w
+(written) 4701 2352 w
+(to) 720 2472 w
+(work) 853 2472 w
+(with) 1125 2472 w
+(one) 1365 2472 w
+(or) 1579 2472 w
+(both) 1716 2472 w
+(of) 1974 2472 w
+(a) 2107 2472 w
+(BSD) 2197 2472 w
+(or) 2419 2472 w
+(a) 2556 2472 w
+(System) 2646 2472 w
+(V) 3024 2472 w
+(Unix.) 3124 2472 w
+(System) 3444 2472 w
+(V) 3822 2472 w
+(is) 3922 2472 w
+(fairly) 4037 2472 w
+(close) 4315 2472 w
+(to) 4597 2472 w
+(POSIX,) 4729 2472 w
+(but) 720 2592 w
+(there) 918 2592 w
+(are) 1206 2592 w
+(some) 1394 2592 w
+(differences.) 1691 2592 w
+(Also,) 2330 2592 w
+(many) 2608 2592 w
+(System) 2906 2592 w
+(V) 3285 2592 w
+(systems) 3386 2592 w
+(have) 3813 2592 w
+(imported) 4075 2592 w
+(some) 4555 2592 w
+(BSD) 4853 2592 w
+(features) 720 2712 w
+(that) 1152 2712 w
+(are) 1380 2712 w
+(not) 1568 2712 w
+(part) 1764 2712 w
+(of) 1996 2712 w
+(POSIX.) 2130 2712 w
+(A) 2509 2712 w
+(good) 2614 2712 w
+(strategy) 2897 2712 w
+(for) 3324 2712 w
+(porting) 3499 2712 w
+(external) 3890 2712 w
+(programs) 4323 2712 w
+(is) 4826 2712 w
+(to) 4942 2712 w
+(first) 720 2832 w
+(try) 999 2832 w
+(using) 1213 2832 w
+10 /LucidaTypewriter f
+(CFLAGS=-D_POSIX_SOURCE) 1563 2832 w
+10 /LucidaSansUnicode00 f
+(;) 3147 2832 w
+(if) 3263 2832 w
+(that) 3414 2832 w
+(doesn) 3690 2832 w
 10 /LucidaSansUnicode20 f
-(\031) 3983 1200 w
+(\031) 3983 2832 w
 10 /LucidaSansUnicode00 f
-(t) 4015 1200 w
-(work,) 4137 1200 w
-(try) 4491 1200 w
-(adding) 4706 1200 w
+(t) 4015 2832 w
+(work,) 4137 2832 w
+(try) 4491 2832 w
+(adding) 4706 2832 w
 10 /LucidaTypewriter f
-(_D_BSD_EXTENSION) 720 1320 w
+(_D_BSD_EXTENSION) 720 2952 w
 10 /LucidaSansUnicode00 f
-(and) 1915 1320 w
-(perhaps) 2138 1320 w
-(include) 2571 1320 w
+(and) 1915 2952 w
+(perhaps) 2138 2952 w
+(include) 2571 2952 w
 10 /LucidaTypewriter f
-(<bsd.h>) 2965 1320 w
+(<bsd.h>) 2965 2952 w
 10 /LucidaSansUnicode00 f
-(in) 3511 1320 w
-(source) 3644 1320 w
-(files.) 4008 1320 w
-(Here) 4316 1320 w
-(are) 4585 1320 w
-(some) 4779 1320 w
-(solutions to problems that might remain:) 720 1440 w
+(in) 3511 2952 w
+(source) 3644 2952 w
+(files.) 4008 2952 w
+(Here) 4316 2952 w
+(are) 4585 2952 w
+(some) 4779 2952 w
+(solutions to problems that might remain:) 720 3072 w
 10 /LucidaSansUnicode20 f
-(\023) 816 1596 w
+(\023) 816 3228 w
 10 /LucidaSansUnicode00 f
-(Third \(environment\) argument to) 970 1596 w
+(Third \(environment\) argument to) 970 3228 w
 10 /LucidaTypewriter f
-(main) 2599 1596 w
+(main) 2599 3228 w
 10 /LucidaSansUnicode00 f
-(.) 2887 1596 w
-(Use the) 2983 1596 w
+(.) 2887 3228 w
+(Use the) 2983 3228 w
 10 /LucidaTypewriter f
-(environ) 3378 1596 w
+(environ) 3378 3228 w
 10 /LucidaSansUnicode00 f
-(global instead.) 3914 1596 w
+(global instead.) 3914 3228 w
 10 /LucidaSansUnicode20 f
-(\023) 816 1752 w
+(\023) 816 3384 w
 10 /LucidaTypewriter f
-(OPEN_MAX) 970 1752 w
+(OPEN_MAX) 970 3384 w
 10 /LucidaSansUnicode00 f
-(,) 1546 1752 w
+(,) 1546 3384 w
 10 /LucidaTypewriter f
-(PATH_MAX) 1667 1752 w
+(PATH_MAX) 1667 3384 w
 10 /LucidaSansUnicode00 f
-(,) 2243 1752 w
-(etc.,) 2365 1752 w
-(assumed) 2663 1752 w
-(in) 3184 1752 w
+(,) 2243 3384 w
+(etc.,) 2365 3384 w
+(assumed) 2663 3384 w
+(in) 3184 3384 w
 10 /LucidaTypewriter f
-(<limits.h>) 3365 1752 w
+(<limits.h>) 3365 3384 w
 10 /LucidaSansUnicode00 f
-(.) 4085 1752 w
-(Rewrite) 4239 1752 w
-(to) 4688 1752 w
-(call) 4876 1752 w
+(.) 4085 3384 w
+(Rewrite) 4239 3384 w
+(to) 4688 3384 w
+(call) 4876 3384 w
 10 /LucidaTypewriter f
-(sysconf) 970 1872 w
+(sysconf) 970 3504 w
 10 /LucidaSansUnicode00 f
-(or define) 1506 1872 w
+(or define) 1506 3504 w
 10 /LucidaTypewriter f
-(_LIMITS_EXTENSION) 1975 1872 w
+(_LIMITS_EXTENSION) 1975 3504 w
 10 /LucidaSansUnicode00 f
-(.) 3199 1872 w
+(.) 3199 3504 w
 10 /LucidaSansUnicode20 f
-(\023) 816 2028 w
-10 /LucidaTypewriter f
-(<varargs.h>) 970 2028 w
-10 /LucidaSansUnicode00 f
-(.) 1762 2028 w
-(Rewrite to use) 1858 2028 w
-10 /LucidaTypewriter f
-(<stdarg.h>) 2580 2028 w
-10 /LucidaSansUnicode00 f
-(.) 3300 2028 w
-(The) 970 2184 w
-(second) 1187 2184 w
-(class) 1567 2184 w
-(of) 1840 2184 w
-(problems) 1974 2184 w
-(has) 2467 2184 w
-(to) 2671 2184 w
-(do) 2805 2184 w
-(with) 2965 2184 w
-(inadequacies) 3206 2184 w
-(in) 3874 2184 w
-(the) 4002 2184 w
-(Plan) 4194 2184 w
-(9) 4432 2184 w
-(simulation) 4532 2184 w
-(of) 720 2304 w
-(POSIX) 854 2304 w
-(functions.) 1169 2304 w
-(These) 1720 2304 w
-(shortcomings) 2043 2304 w
-(have) 2739 2304 w
-(rarely) 2999 2304 w
-(gotten) 3308 2304 w
-(in) 3658 2304 w
-(the) 3784 2304 w
-(way) 3974 2304 w
-(\(except,) 4193 2304 w
-(perhaps,) 4617 2304 w
-(for the) 720 2424 w
-10 /LucidaTypewriter f
-(link) 1078 2424 w
-10 /LucidaSansUnicode00 f
-(problem\).) 1398 2424 w
+(\023) 816 3660 w
+10 /LucidaTypewriter f
+(<varargs.h>) 970 3660 w
+10 /LucidaSansUnicode00 f
+(.) 1762 3660 w
+(Rewrite to use) 1858 3660 w
+10 /LucidaTypewriter f
+(<stdarg.h>) 2580 3660 w
+10 /LucidaSansUnicode00 f
+(.) 3300 3660 w
+(The) 970 3816 w
+(second) 1187 3816 w
+(class) 1567 3816 w
+(of) 1840 3816 w
+(problems) 1974 3816 w
+(has) 2467 3816 w
+(to) 2671 3816 w
+(do) 2805 3816 w
+(with) 2965 3816 w
+(inadequacies) 3206 3816 w
+(in) 3874 3816 w
+(the) 4002 3816 w
+(Plan) 4194 3816 w
+(9) 4432 3816 w
+(simulation) 4532 3816 w
+(of) 720 3936 w
+(POSIX) 854 3936 w
+(functions.) 1169 3936 w
+(These) 1720 3936 w
+(shortcomings) 2043 3936 w
+(have) 2739 3936 w
+(rarely) 2999 3936 w
+(gotten) 3308 3936 w
+(in) 3658 3936 w
+(the) 3784 3936 w
+(way) 3974 3936 w
+(\(except,) 4193 3936 w
+(perhaps,) 4617 3936 w
+(for the) 720 4056 w
+10 /LucidaTypewriter f
+(link) 1078 4056 w
+10 /LucidaSansUnicode00 f
+(problem\).) 1398 4056 w
 10 /LucidaSansUnicode20 f
-(\023) 816 2580 w
-10 /LucidaSansUnicode00 f
-(Functions) 970 2580 w
-(for) 1476 2580 w
-(setting) 1653 2580 w
-(the) 2025 2580 w
-(userid,) 2218 2580 w
-(groupid,) 2590 2580 w
-(effective) 3041 2580 w
-(userid) 3490 2580 w
-(and) 3830 2580 w
-(effective) 4048 2580 w
-(groupid) 4497 2580 w
-(do) 4916 2580 w
-(not) 970 2700 w
-(do) 1173 2700 w
-(anything) 1340 2700 w
-(useful.) 1803 2700 w
-(The) 2206 2700 w
-(concept) 2429 2700 w
-(is) 2852 2700 w
-(impossible) 2974 2700 w
-(to) 3541 2700 w
-(simulate) 3681 2700 w
-(in) 4135 2700 w
-(Plan) 4268 2700 w
-(9.) 4511 2700 w
-10 /LucidaTypewriter f
-(Chown) 4680 2700 w
-10 /LucidaSansUnicode00 f
-(also does nothing.) 970 2820 w
+(\023) 816 4212 w
+10 /LucidaSansUnicode00 f
+(Functions) 970 4212 w
+(for) 1476 4212 w
+(setting) 1653 4212 w
+(the) 2025 4212 w
+(userid,) 2218 4212 w
+(groupid,) 2590 4212 w
+(effective) 3041 4212 w
+(userid) 3490 4212 w
+(and) 3830 4212 w
+(effective) 4048 4212 w
+(groupid) 4497 4212 w
+(do) 4916 4212 w
+(not) 970 4332 w
+(do) 1173 4332 w
+(anything) 1340 4332 w
+(useful.) 1803 4332 w
+(The) 2206 4332 w
+(concept) 2429 4332 w
+(is) 2852 4332 w
+(impossible) 2974 4332 w
+(to) 3541 4332 w
+(simulate) 3681 4332 w
+(in) 4135 4332 w
+(Plan) 4268 4332 w
+(9.) 4511 4332 w
+10 /LucidaTypewriter f
+(Chown) 4680 4332 w
+10 /LucidaSansUnicode00 f
+(also does nothing.) 970 4452 w
 10 /LucidaSansUnicode20 f
-(\023) 816 2976 w
+(\023) 816 4608 w
 10 /LucidaTypewriter f
-(execlp) 970 2976 w
+(execlp) 970 4608 w
 10 /LucidaSansUnicode00 f
-(and) 1440 2976 w
-(the) 1658 2976 w
-(related) 1851 2976 w
-(functions) 2226 2976 w
-(do) 2716 2976 w
-(not) 2879 2976 w
-(look) 3078 2976 w
-(at) 3326 2976 w
-(the) 3457 2976 w
+(and) 1440 4608 w
+(the) 1658 4608 w
+(related) 1851 4608 w
+(functions) 2226 4608 w
+(do) 2716 4608 w
+(not) 2879 4608 w
+(look) 3078 4608 w
+(at) 3326 4608 w
+(the) 3457 4608 w
 10 /LucidaTypewriter f
-(PATH) 3651 2976 w
+(PATH) 3651 4608 w
 10 /LucidaSansUnicode00 f
-(environment) 3978 2976 w
-(variable.) 4628 2976 w
-(They just try the current directory and) 970 3096 w
+(environment) 3978 4608 w
+(variable.) 4628 4608 w
+(They just try the current directory and) 970 4728 w
 10 /LucidaTypewriter f
-(/bin) 2853 3096 w
+(/bin) 2853 4728 w
 10 /LucidaSansUnicode00 f
-(if the pathname is not absolute.) 3173 3096 w
+(if the pathname is not absolute.) 3173 4728 w
 10 /LucidaSansUnicode20 f
-(\023) 816 3252 w
+(\023) 816 4884 w
 10 /LucidaSansUnicode00 f
-(Advisory locking via) 970 3252 w
+(Advisory locking via) 970 4884 w
 10 /LucidaTypewriter f
-(fcntl) 1972 3252 w
+(fcntl) 1972 4884 w
 10 /LucidaSansUnicode00 f
-(is not implemented.) 2364 3252 w
+(is not implemented.) 2364 4884 w
 10 /LucidaSansUnicode20 f
-(\023) 816 3408 w
-10 /LucidaTypewriter f
-(isatty) 970 3408 w
-10 /LucidaSansUnicode00 f
-(is) 1444 3408 w
-(hard) 1566 3408 w
-(to) 1829 3408 w
-(do) 1969 3408 w
-(correctly.) 2136 3408 w
-(The) 2662 3408 w
-(approximation) 2886 3408 w
-(used) 3639 3408 w
-(is) 3914 3408 w
-(only) 4037 3408 w
-(sometimes) 4284 3408 w
-(cor\255) 4854 3408 w
-(rect.) 970 3528 w
+(\023) 816 5040 w
+10 /LucidaTypewriter f
+(isatty) 970 5040 w
+10 /LucidaSansUnicode00 f
+(is) 1444 5040 w
+(hard) 1566 5040 w
+(to) 1829 5040 w
+(do) 1969 5040 w
+(correctly.) 2136 5040 w
+(The) 2662 5040 w
+(approximation) 2886 5040 w
+(used) 3639 5040 w
+(is) 3914 5040 w
+(only) 4037 5040 w
+(sometimes) 4284 5040 w
+(cor\255) 4854 5040 w
+(rect.) 970 5160 w
 10 /LucidaSansUnicode20 f
-(\023) 816 3684 w
+(\023) 816 5316 w
 10 /LucidaTypewriter f
-(link) 970 3684 w
+(link) 970 5316 w
 10 /LucidaSansUnicode00 f
-(always fails.) 1290 3684 w
+(always fails.) 1290 5316 w
 10 /LucidaSansUnicode20 f
-(\023) 816 3840 w
+(\023) 816 5472 w
 10 /LucidaSansUnicode00 f
-(With) 970 3840 w
+(With) 970 5472 w
 10 /LucidaTypewriter f
-(open) 1222 3840 w
+(open) 1222 5472 w
 10 /LucidaSansUnicode00 f
-(,) 1510 3840 w
-(the) 1580 3840 w
+(,) 1510 5472 w
+(the) 1580 5472 w
 10 /LucidaTypewriter f
-(O_NOCTTY) 1773 3840 w
+(O_NOCTTY) 1773 5472 w
 10 /LucidaSansUnicode00 f
-(option) 2387 3840 w
-(has) 2738 3840 w
-(no) 2944 3840 w
-(effect.) 3105 3840 w
-(The) 3481 3840 w
-(concept) 3700 3840 w
-(of) 4120 3840 w
-(a) 4257 3840 w
-(controlling) 4351 3840 w
-(tty) 4914 3840 w
-(is foreign to Plan 9.) 970 3960 w
+(option) 2387 5472 w
+(has) 2738 5472 w
+(no) 2944 5472 w
+(effect.) 3105 5472 w
+(The) 3481 5472 w
+(concept) 3700 5472 w
+(of) 4120 5472 w
+(a) 4257 5472 w
+(controlling) 4351 5472 w
+(tty) 4914 5472 w
+(is foreign to Plan 9.) 970 5592 w
 10 /LucidaSansUnicode20 f
-(\023) 816 4116 w
-10 /LucidaTypewriter f
-(setsid) 970 4116 w
-10 /LucidaSansUnicode00 f
-(forks) 1448 4116 w
-(the) 1742 4116 w
-(name) 1943 4116 w
-(space) 2256 4116 w
-(and) 2579 4116 w
-(note) 2806 4116 w
-(group,) 3069 4116 w
-(which) 3437 4116 w
-(is) 3765 4116 w
-(only) 3892 4116 w
-(approximately) 4143 4116 w
-(the) 4885 4116 w
-(right behavior.) 970 4236 w
+(\023) 816 5748 w
+10 /LucidaTypewriter f
+(setsid) 970 5748 w
+10 /LucidaSansUnicode00 f
+(forks) 1448 5748 w
+(the) 1742 5748 w
+(name) 1943 5748 w
+(space) 2256 5748 w
+(and) 2579 5748 w
+(note) 2806 5748 w
+(group,) 3069 5748 w
+(which) 3437 5748 w
+(is) 3765 5748 w
+(only) 3892 5748 w
+(approximately) 4143 5748 w
+(the) 4885 5748 w
+(right behavior.) 970 5868 w
 10 /LucidaSansUnicode20 f
-(\023) 816 4392 w
+(\023) 816 6024 w
 10 /LucidaSansUnicode00 f
-(The) 970 4392 w
-(functions) 1198 4392 w
-(dealing) 1697 4392 w
-(with) 2100 4392 w
-(stacking) 2352 4392 w
-(signals,) 2804 4392 w
+(The) 970 6024 w
+(functions) 1198 6024 w
+(dealing) 1697 6024 w
+(with) 2100 6024 w
+(stacking) 2352 6024 w
+(signals,) 2804 6024 w
 10 /LucidaTypewriter f
-(sigpending) 3222 4392 w
+(sigpending) 3222 6024 w
 10 /LucidaSansUnicode00 f
-(,) 3942 4392 w
+(,) 3942 6024 w
 10 /LucidaTypewriter f
-(sigprocmask) 4021 4392 w
+(sigprocmask) 4021 6024 w
 10 /LucidaSansUnicode00 f
-(and) 4860 4392 w
+(and) 4860 6024 w
 10 /LucidaTypewriter f
-(sigsuspend) 970 4512 w
+(sigsuspend) 970 6144 w
 10 /LucidaSansUnicode00 f
-(, do not work.) 1690 4512 w
+(, do not work.) 1690 6144 w
 10 /LucidaSansUnicode20 f
-(\023) 816 4668 w
+(\023) 816 6300 w
 10 /LucidaTypewriter f
-(umask) 970 4668 w
+(umask) 970 6300 w
 10 /LucidaSansUnicode00 f
-(has no effect, as there is no such concept in Plan 9.) 1362 4668 w
+(has no effect, as there is no such concept in Plan 9.) 1362 6300 w
 10 /LucidaSansUnicode20 f
-(\023) 816 4824 w
+(\023) 816 6456 w
 10 /LucidaSansUnicode00 f
-(code) 970 4824 w
-(that) 1236 4824 w
-(does) 1462 4824 w
+(code) 970 6456 w
+(that) 1236 6456 w
+(does) 1462 6456 w
 10 /LucidaTypewriter f
-(getenv\("HOME"\)) 1729 4824 w
+(getenv\("HOME"\)) 1729 6456 w
 10 /LucidaSansUnicode00 f
-(should) 2773 4824 w
-(be) 3137 4824 w
-(changed) 3292 4824 w
-(to) 3739 4824 w
+(should) 2773 6456 w
+(be) 3137 6456 w
+(changed) 3292 6456 w
+(to) 3739 6456 w
 10 /LucidaTypewriter f
-(getenv\("home"\)) 3873 4824 w
+(getenv\("home"\)) 3873 6456 w
 10 /LucidaSansUnicode00 f
-(on) 4917 4824 w
-(Plan 9.) 970 4944 w
+(on) 4917 6456 w
+(Plan 9.) 970 6576 w
 cleartomark
 showpage
 saveobj restore

+ 8 - 1
sys/include/ape/stdio.h

@@ -88,12 +88,19 @@ extern int fscanf(FILE *, const char *, ...);
 extern int printf(const char *, ...);
 extern int scanf(const char *, ...);
 extern int sprintf(char *, const char *, ...);
+#define _C99_SNPRINTF_EXTENSION
+#ifdef _C99_SNPRINTF_EXTENSION		/* user knows about c99 treachery */
 extern int snprintf(char *, size_t, const char *, ...);
+extern int vsnprintf(char *, size_t, const char *, va_list);
+#else
+/* draw errors on any attempt to use *snprintf value so old code gets changed */
+extern void snprintf(char *, size_t, const char *, ...);
+extern void vsnprintf(char *, size_t, const char *, va_list);
+#endif
 extern int sscanf(const char *, const char *, ...);
 extern int vfprintf(FILE *, const char *, va_list);
 extern int vprintf(const char *, va_list);
 extern int vsprintf(char *, const char *, va_list);
-extern int vsnprintf(char *, size_t, const char *, va_list);
 extern int vfscanf(FILE *, const char *, va_list);
 extern int fgetc(FILE *);
 extern char *fgets(char *, int, FILE *);

+ 18 - 0
sys/man/1/2l

@@ -92,6 +92,16 @@ is the first letter of the loader name.
 Insert profiling code into the executable output; no special action is needed
 during compilation or assembly.
 .TP
+.B -e
+Insert (\fLe\fPmbedded) tracing code into the executable output; no special action is needed
+during compilation or assembly.
+The added code calls
+.L _tracein
+at function entries
+and
+.L _traceout
+at function exits.
+.TP
 .B -s
 Strip the symbol tables from the output file.
 .TP
@@ -132,6 +142,14 @@ restricts the imported symbols to those listed in the file.
 See
 .IR dynld (2).
 .TP
+.B -t
+(\c
+.I 5l
+and
+.I vl
+only)
+Move strings into the text segment.
+.TP
 .BI -H n
 Executable header is type
 .IR n .

+ 16 - 16
sys/man/4/upasfs

@@ -167,9 +167,9 @@ is used to direct
 .I fs
 to open/close new mailboxes or to delete groups of messages atomically.
 The messages that can be written to this file are:
-.TP 2i
-.PD 0
-.B "open \fIpath mboxname\fP
+.TF "delete\fI mboxname number ...\fP
+.TP
+.BI open " path mboxname"
 opens a new mailbox.
 .I path
 is the file to open, and
@@ -177,14 +177,14 @@ is the file to open, and
 is the name that appears under
 .BR /mail/fs .
 .TP
-.B "close \fImboxname\fP
+.BI close " mboxname"
 close
 .IR mboxname .
 The close takes affect only after all files open under
 .BI /mail/fs/ mboxname
 have been closed.
 .TP
-.B "delete \fImboxname number ...\fP
+.BI delete " mboxname number ..."
 Delete the messages with the given numbers from
 .IR mboxname.
 .PD
@@ -266,9 +266,13 @@ cleartext POP with password authentication
 .B apop
 cleartext POP with challenge-response (APOP) authentication
 .TP
+.B pops
+.TP
 .B poptls
 TLS-encrypted POP with password authentication
 .TP
+.B apops
+.TP
 .B apoptls
 TLS-encrypted POP with challenge-response (APOP) authentication
 .TP
@@ -288,20 +292,16 @@ and
 .B apoptls
 connect to port 110 in plaintext and start TLS using the POP
 STLS command.
-.B Imaps
-connects to port 993 and starts TLS before initiating the IMAP conversation.
-There should probably be
-.BR pops ,
-.BR apops ,
-and
-.B imaptls
-protocols as well.
-.RB ( Pops
+.B Pops
 and
 .B apops
-would connect to port 995 and start TLS before initiating the POP conversation,
-and
+connect to port 995 and start TLS before initiating the POP conversation.
+.B Imaps
+connects to port 993 and starts TLS before initiating the IMAP conversation.
+There should probably be an
 .B imaptls
+protocol as well.
+.RB ( Imaptls
 would connect to port 143 in plaintext and start TLS using the IMAP
 STARTTLS command.
 (That's the nice thing about standards\(emthere's so many to choose from.))

+ 14 - 1
sys/man/8/ndb

@@ -1,6 +1,6 @@
 .TH NDB 8
 .SH NAME
-query, ipquery, mkhash, mkdb, mkhosts, cs, csquery, dns, dnstcp, dnsquery, dnsdebug \- network database
+query, ipquery, mkhash, mkdb, mkhosts, cs, csquery, dns, dnstcp, dnsquery, dnsdebug, inform \- network database
 .SH SYNOPSIS
 .B ndb/query
 [
@@ -103,6 +103,12 @@ query, ipquery, mkhash, mkdb, mkhosts, cs, csquery, dns, dnstcp, dnsquery, dnsde
 [
 .I type
 ] ]
+.br
+.B ndb/inform
+[
+.B -x
+.I netmtpt
+]
 .SH DESCRIPTION
 The network database holds administrative information used by
 network programs such as
@@ -156,6 +162,13 @@ with entries of attribute type
 and
 value
 .IR value .
+.PP
+.I Ndb/inform
+sends an RFC2136 DNS
+.I inform
+packet to a nameserver to associate the host's IPv4 address with its DNS name.
+This is required if the domain's nameserver is
+a Microsoft Windows Active Directory controller.
 .SS "Database maintenance"
 .I Ndb/mkhash
 creates a hash file for all entries with attribute

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

@@ -369,3 +369,6 @@ struct PCMslot
 	int	time;
 	PCMmap	mmap[4];	/* maps, last is always for the kernel */
 };
+
+#pragma varargck	type	"T"	int
+#pragma varargck	type	"T"	uint

+ 13 - 10
sys/src/9/pc/pci.c

@@ -97,13 +97,12 @@ static char* bustypes[] = {
 	"XPRESS",
 };
 
-#pragma	varargck	type	"T"	int
-
 static int
 tbdffmt(Fmt* fmt)
 {
 	char *p;
-	int l, r, type, tbdf;
+	int l, r;
+	uint type, tbdf;
 
 	if((p = malloc(READSTR)) == nil)
 		return fmtstrcpy(fmt, "(tbdfconv)");
@@ -111,13 +110,17 @@ tbdffmt(Fmt* fmt)
 	switch(fmt->r){
 	case 'T':
 		tbdf = va_arg(fmt->args, int);
-		type = BUSTYPE(tbdf);
-		if(type < nelem(bustypes))
-			l = snprint(p, READSTR, bustypes[type]);
-		else
-			l = snprint(p, READSTR, "%d", type);
-		snprint(p+l, READSTR-l, ".%d.%d.%d",
-			BUSBNO(tbdf), BUSDNO(tbdf), BUSFNO(tbdf));
+		if(tbdf == BUSUNKNOWN)
+			snprint(p, READSTR, "unknown");
+		else{
+			type = BUSTYPE(tbdf);
+			if(type < nelem(bustypes))
+				l = snprint(p, READSTR, bustypes[type]);
+			else
+				l = snprint(p, READSTR, "%d", type);
+			snprint(p+l, READSTR-l, ".%d.%d.%d",
+				BUSBNO(tbdf), BUSDNO(tbdf), BUSFNO(tbdf));
+		}
 		break;
 
 	default:

+ 10 - 8
sys/src/ape/lib/ap/plan9/opendir.c

@@ -40,7 +40,7 @@ opendir(const char *filename)
 		errno = ENOMEM;
 		return NULL;
 	}
-	d->dd_buf = ((char *)d) + sizeof(DIR);
+	d->dd_buf = (char *)d + sizeof(DIR);
 	d->dd_fd = f;
 	d->dd_loc = 0;
 	d->dd_size = 0;
@@ -67,18 +67,14 @@ closedir(DIR *d)
 void
 rewinddir(DIR *d)
 {
-	int f;
-	char dname[300];
-
+	if(!d)
+		return;
 	d->dd_loc = 0;
 	d->dd_size = 0;
 	d->dirsize = 0;
 	d->dirloc = 0;
 	free(d->dirs);
 	d->dirs = nil;
-	if(!d){
-		return;
-	}
 	if(_SEEK(d->dd_fd, 0, 0) < 0){
 		_syserrno();
 		return;
@@ -99,12 +95,18 @@ readdir(DIR *d)
 	if(d->dd_loc >= d->dd_size){
 		if(d->dirloc >= d->dirsize){
 			free(d->dirs);
+			d->dirs = NULL;
 			d->dirsize = _dirread(d->dd_fd, &d->dirs);
 			d->dirloc = 0;
 		}
+		if(d->dirsize < 0) {	/* malloc or read failed in _dirread? */
+			free(d->dirs);
+			d->dirs = NULL;
+		}
 		if(d->dirs == NULL)
 			return NULL;
-		dr = (struct dirent *)(d->dd_buf);
+
+		dr = (struct dirent *)d->dd_buf;
 		dirs = d->dirs;
 		for(i=0; i<DBLOCKSIZE && d->dirloc < d->dirsize; i++){
 			strncpy(dr[i].d_name, dirs[d->dirloc++].name, MAXNAMLEN);

+ 8 - 3
sys/src/ape/lib/ap/plan9/profile.c

@@ -134,16 +134,21 @@ _profout(void)
 static void
 err(char *fmt, ...)
 {
-	int n, fd;
+	int fd;
 	va_list arg;
 	char buf[128];
 
 	if((fd = open("/dev/cons", OWRITE)) == -1)
 		return;
 	va_start(arg, fmt);
-	n = vsnprintf(buf, sizeof(buf), fmt, arg);
+	/*
+	 * C99 now requires *snprintf to return the number of characters
+	 * that *would* have been emitted, had there been room for them.
+	 * Arrgh!
+	 */
+	vsnprintf(buf, sizeof buf, fmt, arg);
 	va_end(arg);
-	write(fd, buf, n);
+	write(fd, buf, strlen(buf));
 	close(fd);
 }
 

+ 3 - 0
sys/src/ape/lib/ap/stdio/snprintf.c

@@ -1,7 +1,10 @@
 /*
  * pANS stdio -- sprintf
  */
+#define _C99_SNPRINTF_EXTENSION
+
 #include "iolib.h"
+
 int snprintf(char *buf, size_t nbuf, const char *fmt, ...){
 	int n;
 	va_list args;

+ 3 - 0
sys/src/ape/lib/ap/stdio/vsnprintf.c

@@ -1,7 +1,10 @@
 /*
  * pANS stdio -- vsnprintf
  */
+#define _C99_SNPRINTF_EXTENSION
+
 #include "iolib.h"
+
 int vsnprintf(char *buf, size_t nbuf, const char *fmt, va_list args){
 	int n;
 	FILE *f=_IO_sopenw();

+ 38 - 5
sys/src/cmd/1l/obj.c

@@ -1165,15 +1165,24 @@ void
 doprof2(void)
 {
 	Sym *s2, *s4;
-	Prog *p, *q, *ps2, *ps4;
+	Prog *p, *q, *q2, *ps2, *ps4;
 
 	if(debug['v'])
 		Bprint(&bso, "%5.2f profile 2\n", cputime());
 	Bflush(&bso);
-	s2 = lookup("_profin", 0);
-	s4 = lookup("_profout", 0);
+
+	if(debug['e']){
+		s2 = lookup("_tracein", 0);
+		s4 = lookup("_traceout", 0);
+	}else{
+		s2 = lookup("_profin", 0);
+		s4 = lookup("_profout", 0);
+	}
 	if(s2->type != STEXT || s4->type != STEXT) {
-		diag("_profin/_profout not defined");
+		if(debug['e'])
+			diag("_tracein/_traceout not defined %d %d", s2->type, s4->type);
+		else
+			diag("_profin/_profout not defined");
 		return;
 	}
 
@@ -1209,7 +1218,20 @@ doprof2(void)
 			q->line = p->line;
 			q->pc = p->pc;
 			q->link = p->link;
-			p->link = q;
+			if(debug['e']){		/* embedded tracing */
+				q2 = prg();
+				p->link = q2;
+				q2->link = q;
+
+				q2->line = p->line;
+				q2->pc = p->pc;
+
+				q2->as = AJMP;
+				q2->to.type = D_BRANCH;
+				q2->to.sym = p->to.sym;
+				q2->pcond = q->link;
+			}else
+				p->link = q;
 			p = q;
 			p->as = ABSR;
 			p->to.type = D_BRANCH;
@@ -1219,6 +1241,17 @@ doprof2(void)
 			continue;
 		}
 		if(p->as == ARTS) {
+			/*
+			 * RTS (default)
+			 */
+			if(debug['e']){		/* embedded tracing */
+				q = prg();
+				q->line = p->line;
+				q->pc = p->pc;
+				q->link = p->link;
+				p->link = q;
+				p = q;
+			}
 			/*
 			 * RTS
 			 */

+ 38 - 5
sys/src/cmd/2l/obj.c

@@ -1187,15 +1187,24 @@ void
 doprof2(void)
 {
 	Sym *s2, *s4;
-	Prog *p, *q, *ps2, *ps4;
+	Prog *p, *q, *q2, *ps2, *ps4;
 
 	if(debug['v'])
 		Bprint(&bso, "%5.2f profile 2\n", cputime());
 	Bflush(&bso);
-	s2 = lookup("_profin", 0);
-	s4 = lookup("_profout", 0);
+
+	if(debug['e']){
+		s2 = lookup("_tracein", 0);
+		s4 = lookup("_traceout", 0);
+	}else{
+		s2 = lookup("_profin", 0);
+		s4 = lookup("_profout", 0);
+	}
 	if(s2->type != STEXT || s4->type != STEXT) {
-		diag("_profin/_profout not defined");
+		if(debug['e'])
+			diag("_tracein/_traceout not defined %d %d", s2->type, s4->type);
+		else
+			diag("_profin/_profout not defined");
 		return;
 	}
 
@@ -1231,7 +1240,20 @@ doprof2(void)
 			q->line = p->line;
 			q->pc = p->pc;
 			q->link = p->link;
-			p->link = q;
+			if(debug['e']){		/* embedded tracing */
+				q2 = prg();
+				p->link = q2;
+				q2->link = q;
+
+				q2->line = p->line;
+				q2->pc = p->pc;
+
+				q2->as = AJMP;
+				q2->to.type = D_BRANCH;
+				q2->to.sym = p->to.sym;
+				q2->pcond = q->link;
+			}else
+				p->link = q;
 			p = q;
 			p->as = ABSR;
 			p->to.type = D_BRANCH;
@@ -1241,6 +1263,17 @@ doprof2(void)
 			continue;
 		}
 		if(p->as == ARTS) {
+			/*
+			 * RTS (default)
+			 */
+			if(debug['e']){		/* embedded tracing */
+				q = prg();
+				q->line = p->line;
+				q->pc = p->pc;
+				q->link = p->link;
+				p->link = q;
+				p = q;
+			}
 			/*
 			 * RTS
 			 */

+ 39 - 5
sys/src/cmd/5l/obj.c

@@ -1230,17 +1230,27 @@ void
 doprof2(void)
 {
 	Sym *s2, *s4;
-	Prog *p, *q, *ps2, *ps4;
+	Prog *p, *q, *q2, *ps2, *ps4;
 
 	if(debug['v'])
 		Bprint(&bso, "%5.2f profile 2\n", cputime());
 	Bflush(&bso);
-	s2 = lookup("_profin", 0);
-	s4 = lookup("_profout", 0);
+
+	if(debug['e']){
+		s2 = lookup("_tracein", 0);
+		s4 = lookup("_traceout", 0);
+	}else{
+		s2 = lookup("_profin", 0);
+		s4 = lookup("_profout", 0);
+	}
 	if(s2->type != STEXT || s4->type != STEXT) {
-		diag("_profin/_profout not defined");
+		if(debug['e'])
+			diag("_tracein/_traceout not defined %d %d", s2->type, s4->type);
+		else
+			diag("_profin/_profout not defined");
 		return;
 	}
+
 	ps2 = P;
 	ps4 = P;
 	for(p = firstp; p != P; p = p->link) {
@@ -1276,7 +1286,20 @@ doprof2(void)
 			q->line = p->line;
 			q->pc = p->pc;
 			q->link = p->link;
-			p->link = q;
+			if(debug['e']){		/* embedded tracing */
+				q2 = prg();
+				p->link = q2;
+				q2->link = q;
+
+				q2->line = p->line;
+				q2->pc = p->pc;
+
+				q2->as = AB;
+				q2->to.type = D_BRANCH;
+				q2->to.sym = p->to.sym;
+				q2->cond = q->link;
+			}else
+				p->link = q;
 			p = q;
 			p->as = ABL;
 			p->to.type = D_BRANCH;
@@ -1286,6 +1309,17 @@ doprof2(void)
 			continue;
 		}
 		if(p->as == ARET) {
+			/*
+			 * RET (default)
+			 */
+			if(debug['e']){		/* embedded tracing */
+				q = prg();
+				q->line = p->line;
+				q->pc = p->pc;
+				q->link = p->link;
+				p->link = q;
+				p = q;
+			}
 			/*
 			 * RET
 			 */

+ 38 - 5
sys/src/cmd/7l/obj.c

@@ -1134,15 +1134,24 @@ void
 doprof2(void)
 {
 	Sym *s2, *s4;
-	Prog *p, *q, *ps2, *ps4;
+	Prog *p, *q, *q2, *ps2, *ps4;
 
 	if(debug['v'])
 		Bprint(&bso, "%5.2f profile 2\n", cputime());
 	Bflush(&bso);
-	s2 = lookup("_profin", 0);
-	s4 = lookup("_profout", 0);
+
+	if(debug['e']){
+		s2 = lookup("_tracein", 0);
+		s4 = lookup("_traceout", 0);
+	}else{
+		s2 = lookup("_profin", 0);
+		s4 = lookup("_profout", 0);
+	}
 	if(s2->type != STEXT || s4->type != STEXT) {
-		diag("_profin/_profout not defined");
+		if(debug['e'])
+			diag("_tracein/_traceout not defined %d %d", s2->type, s4->type);
+		else
+			diag("_profin/_profout not defined");
 		return;
 	}
 
@@ -1181,7 +1190,20 @@ doprof2(void)
 			q->line = p->line;
 			q->pc = p->pc;
 			q->link = p->link;
-			p->link = q;
+			if(debug['e']){		/* embedded tracing */
+				q2 = prg();
+				p->link = q2;
+				q2->link = q;
+
+				q2->line = p->line;
+				q2->pc = p->pc;
+
+				q2->as = AJMP;
+				q2->to.type = D_BRANCH;
+				q2->to.sym = p->to.sym;
+				q2->cond = q->link;
+			}else
+				p->link = q;
 			p = q;
 			p->as = AJSR;
 			p->to.type = D_BRANCH;
@@ -1191,6 +1213,17 @@ doprof2(void)
 			continue;
 		}
 		if(p->as == ARET) {
+			/*
+			 * JSR (default)
+			 */
+			if(debug['e']){		/* embedded tracing */
+				q = prg();
+				q->line = p->line;
+				q->pc = p->pc;
+				q->link = p->link;
+				p->link = q;
+				p = q;
+			}
 			/*
 			 * JSR	profout
 			 */

+ 37 - 5
sys/src/cmd/8l/obj.c

@@ -1231,16 +1231,24 @@ void
 doprof2(void)
 {
 	Sym *s2, *s4;
-	Prog *p, *q, *ps2, *ps4;
+	Prog *p, *q, *q2, *ps2, *ps4;
 
 	if(debug['v'])
 		Bprint(&bso, "%5.2f profile 2\n", cputime());
 	Bflush(&bso);
 
-	s2 = lookup("_profin", 0);
-	s4 = lookup("_profout", 0);
+	if(debug['e']){
+		s2 = lookup("_tracein", 0);
+		s4 = lookup("_traceout", 0);
+	}else{
+		s2 = lookup("_profin", 0);
+		s4 = lookup("_profout", 0);
+	}
 	if(s2->type != STEXT || s4->type != STEXT) {
-		diag("_profin/_profout not defined");
+		if(debug['e'])
+			diag("_tracein/_traceout not defined %d %d", s2->type, s4->type);
+		else
+			diag("_profin/_profout not defined");
 		return;
 	}
 
@@ -1281,7 +1289,20 @@ doprof2(void)
 			q->line = p->line;
 			q->pc = p->pc;
 			q->link = p->link;
-			p->link = q;
+			if(debug['e']){		/* embedded tracing */
+				q2 = prg();
+				p->link = q2;
+				q2->link = q;
+
+				q2->line = p->line;
+				q2->pc = p->pc;
+
+				q2->as = AJMP;
+				q2->to.type = D_BRANCH;
+				q2->to.sym = p->to.sym;
+				q2->pcond = q->link;
+			}else
+				p->link = q;
 			p = q;
 			p->as = ACALL;
 			p->to.type = D_BRANCH;
@@ -1291,6 +1312,17 @@ doprof2(void)
 			continue;
 		}
 		if(p->as == ARET) {
+			/*
+			 * RET (default)
+			 */
+			if(debug['e']){		/* embedded tracing */
+				q = prg();
+				q->line = p->line;
+				q->pc = p->pc;
+				q->link = p->link;
+				p->link = q;
+				p = q;
+			}
 			/*
 			 * RET
 			 */

+ 4 - 2
sys/src/cmd/ar.c

@@ -698,11 +698,13 @@ getdir(Biobuf *b)
 		free(bp);
 		return 0;
 	}
-	if(strncmp(bp->hdr.fmag, ARFMAG, sizeof(bp->hdr.fmag)))
+	if(strncmp(bp->hdr.fmag, ARFMAG, sizeof(bp->hdr.fmag)) != 0)
 		phaseerr(Boffset(b));
 	strncpy(name, bp->hdr.name, sizeof(bp->hdr.name));
 	cp = name+sizeof(name)-1;
-	while(*--cp==' ')
+	*cp = '\0';
+	/* skip trailing spaces and (gnu-produced) slashes */
+	while(*--cp == ' ' || *cp == '/')
 		;
 	cp[1] = '\0';
 	file = name;

+ 37 - 6
sys/src/cmd/kl/obj.c

@@ -1090,16 +1090,24 @@ void
 doprof2(void)
 {
 	Sym *s2, *s4;
-	Prog *p, *q, *ps2, *ps4;
+	Prog *p, *q, *q2, *ps2, *ps4;
 
 	if(debug['v'])
 		Bprint(&bso, "%5.2f profile 2\n", cputime());
 	Bflush(&bso);
 
-	s2 = lookup("_profin", 0);
-	s4 = lookup("_profout", 0);
+	if(debug['e']){
+		s2 = lookup("_tracein", 0);
+		s4 = lookup("_traceout", 0);
+	}else{
+		s2 = lookup("_profin", 0);
+		s4 = lookup("_profout", 0);
+	}
 	if(s2->type != STEXT || s4->type != STEXT) {
-		diag("_profin/_profout not defined");
+		if(debug['e'])
+			diag("_tracein/_traceout not defined %d %d", s2->type, s4->type);
+		else
+			diag("_profin/_profout not defined");
 		return;
 	}
 
@@ -1140,7 +1148,20 @@ doprof2(void)
 			q->line = p->line;
 			q->pc = p->pc;
 			q->link = p->link;
-			p->link = q;
+			if(debug['e']){		/* embedded tracing */
+				q2 = prg();
+				p->link = q2;
+				q2->link = q;
+
+				q2->line = p->line;
+				q2->pc = p->pc;
+
+				q2->as = AJMP;
+				q2->to.type = D_BRANCH;
+				q2->to.sym = p->to.sym;
+				q2->cond = q->link;
+			}else
+				p->link = q;
 			p = q;
 			p->as = AJMPL;
 			p->to.type = D_BRANCH;
@@ -1150,7 +1171,17 @@ doprof2(void)
 			continue;
 		}
 		if(p->as == ARETURN) {
-
+			/*
+			 * RETURN (default)
+			 */
+			if(debug['e']){		/* embedded tracing */
+				q = prg();
+				q->line = p->line;
+				q->pc = p->pc;
+				q->link = p->link;
+				p->link = q;
+				p = q;
+			}
 			/*
 			 * RETURN
 			 */

+ 224 - 0
sys/src/cmd/ndb/inform.c

@@ -0,0 +1,224 @@
+/* RFC2136 DNS inform - necessary for Win2k3 DNS servers */
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include <ndb.h>
+#include <ip.h>
+
+enum {
+	FQDNMAX	= 255,
+
+	Cin	= 1,		/* internet */
+	Call	= 255,		/* all classes */
+
+	Ta	= 1,		/* v4 address */
+	Tsoa	= 6,		/* start of authority */
+	Taaaa	= 28,		/* v6 address */
+	Tall	= 255,		/* all types */
+};
+
+char *errmsgs[] = {
+	[0]  "ok",
+	[1]  "request format error",
+	[2]  "internal server error",
+	[3]  "domain name does not exist",
+	[4]  "request not supported",
+	[5]  "permission denied",
+	[6]  "domain name already exists",
+	[7]  "resource record already exists",
+	[8]  "resource record does not exist",
+	[9]  "server not authoritative",
+	[10] "domain name not in zone",
+};
+
+char *dnsrch[] = {
+	"dnsdomain",
+	"dom",
+};
+
+void
+usage(void)
+{
+	fprint(2, "usage: %s [-x netmtpt]\n", argv0);
+	exits("usage");
+}
+
+void
+ding(void *, char *msg)
+{
+	if(strstr(msg, "alarm") != nil)
+		noted(NCONT);
+	noted(NDFLT);
+}
+
+int
+g16(uchar **p)
+{
+	int n;
+
+	n  = *(*p)++ << 8;
+	n |= *(*p)++;
+	return n;
+}
+
+void
+p16(uchar **p, int n)
+{
+	*(*p)++ = n >> 8;
+	*(*p)++ = n;
+}
+
+void
+p32(uchar **p, int n)
+{
+	*(*p)++ = n >> 24;
+	*(*p)++ = n >> 16;
+	*(*p)++ = n >> 8;
+	*(*p)++ = n;
+}
+
+void
+pmem(uchar **p, void *v, int len)
+{
+	memmove(*p, v, len);
+	*p += len;
+}
+
+void
+pname(uchar **p, char *s)
+{
+	uchar *len;
+
+	while (*s){
+		len = (*p)++;
+		while(*s && *s != '.')
+			*(*p)++ = *s++;
+		*len = *p - len - 1;
+		if(*s == '.')
+			s++;
+	}
+	*(*p)++ = 0;
+}
+
+void
+main(int argc, char *argv[])
+{
+	int debug, len, fd;
+	uint err;
+	char *sysname, *dnsdomain, *dom, *ns, net[32];
+	uchar *p, buf[4096], addr[IPv4addrlen], v6addr[IPaddrlen];
+	ushort txid;
+	Ndb *db;
+	Ndbtuple *t, *tt;
+	static char *query[] = { "dom", "dnsdomain", "ns", };
+
+	fmtinstall('I', eipfmt);
+	fmtinstall('V', eipfmt);
+	setnetmtpt(net, sizeof net, nil);
+
+	debug = 0;
+	ns = nil;
+	dom = nil;
+	dnsdomain = nil;
+	ARGBEGIN{
+	case 'd':
+		debug = 1;
+		break;
+	case 'x':
+		setnetmtpt(net, sizeof net, EARGF(usage()));
+		break;
+	default:
+		usage();
+	}ARGEND;
+
+	if(argc != 0)
+		usage();
+
+	if((sysname = getenv("sysname")) == nil)
+		sysfatal("$sysname not set");
+
+	if((db = ndbopen(nil)) == nil)
+		sysfatal("can't open ndb: %r");
+	tt = ndbipinfo(db, "sys", sysname, query, nelem(query));
+	for(t = tt; t; t = t->entry)
+		if(strcmp(t->attr, "ns") == 0)
+			ns = t->val;
+		else if(strcmp(t->attr, "dom") == 0)
+			dom = t->val;
+		else if(strcmp(t->attr, "dnsdomain") == 0)
+			dnsdomain = t->val;
+	ndbfree(tt);
+	ndbclose(db);
+
+	if(!ns)
+		sysfatal("no relevant ns=");
+	if(!dom)
+		sysfatal("no relevant dom=");
+	if(!dnsdomain)
+		sysfatal("no relevant dnsdomain=");
+
+	myipaddr(v6addr, net);
+	memmove(addr, v6addr + IPaddrlen - IPv4addrlen, IPv4addrlen);
+
+	if(debug){
+		print("ip=%V\n", addr);
+		print("ns=%s\n", ns);
+		print("dnsdomain=%s\n", dnsdomain);
+		print("dom=%s\n", dom);
+	}
+
+	if((fd = dial(netmkaddr(ns, "udp", "dns"), 0, 0, 0)) < 0)
+		sysfatal("can't dial %s: %r", ns);
+
+	txid = time(nil) + getpid();
+
+	p = buf;
+	p16(&p, txid);		/* ID */
+	p16(&p, 5<<11);		/* flags */
+	p16(&p, 1);		/* # Zones */
+	p16(&p, 0);		/* # prerequisites */
+	p16(&p, 2);		/* # updates */
+	p16(&p, 0);		/* # additionals */
+
+        pname(&p, dnsdomain);	/* zone */
+	p16(&p, Tsoa);		/* zone type */
+	p16(&p, Cin);		/* zone class */
+
+	/* delete old name */
+        pname(&p, dom);		/* name */
+	p16(&p, Ta);		/* type: v4 addr */
+	p16(&p, Call);		/* class */
+	p32(&p, 0);		/* TTL */
+	p16(&p, 0);		/* data len */
+
+	/* add new A record */
+	pname(&p, dom);		/* name */
+	p16(&p, Ta);		/* type: v4 addr */
+	p16(&p, Cin);		/* class */
+	p32(&p, 60*60*25);	/* TTL (25 hours) */
+	p16(&p, IPv4addrlen);	/* data len */
+	pmem(&p, addr, IPv4addrlen);	/* v4 address */
+
+	len = p - buf;
+	if(write(fd, buf, len) != len)
+		sysfatal("write failed: %r");
+
+	notify(ding);
+	alarm(3000);
+	do{
+		if(read(fd, buf, sizeof buf) < 0)
+			sysfatal("timeout");
+		p = buf;
+	}while(g16(&p) != txid);
+	alarm(0);
+
+	close(fd);
+
+	err = g16(&p) & 7;
+	if(err != 0 && err != 7)	/* err==7 is just a "yes, I know" warning */
+		if(err < nelem(errmsgs))
+			sysfatal("%s", errmsgs[err]);
+		else
+			sysfatal("unknown dns server error %d", err);
+	exits(0);
+}

+ 2 - 1
sys/src/cmd/ndb/mkfile

@@ -13,10 +13,11 @@ TARG =	\
 	dnstcp\
 	dnsdebug\
 	ipquery\
+	inform\
 
 
 DNSOBJ = dns.$O dnudpserver.$O dn.$O dnresolve.$O dblookup.$O dnserver.$O dnnotify.$O\
-	 dnarea.$O convM2DNS.$O convDNS2M.$O
+	 dnarea.$O convM2DNS.$O convDNS2M.$O # lock.$O coherence.$O
 
 DNSTCPOBJ = dnstcp.$O dn.$O dnresolve.$O dblookup.$O dnserver.$O\
 	 dnarea.$O convM2DNS.$O convDNS2M.$O

+ 40 - 9
sys/src/cmd/ql/obj.c

@@ -17,7 +17,7 @@ char	*thestring 	= "power";
 /*
  *	-H0 -T0x200000 -R0		is boot
  *	-H1 -T0x100000 -R4		is Be boot
- *	-H2 -T4128 -R4096		is plan9 format
+ *	-H2 -T0x100020 -R0x100000	is plan9 format (was -T4128 -R4096)
  *	-H3 -T0x02010000 -D0x00001000	is raw
  *	-H4 -T0x1000200 -D0x20000e00 -R4	is aix xcoff executable
  *	-H5 -T0x80010000 -t0x10000	ELF, phys = 10000, vaddr = 0x8001...
@@ -153,11 +153,11 @@ main(int argc, char *argv[])
 	case 2:	/* plan 9 */
 		HEADR = 32L;
 		if(INITTEXT == -1)
-			INITTEXT = 4128;
+			INITTEXT = 0x100020;
 		if(INITDAT == -1)
 			INITDAT = 0;
 		if(INITRND == -1)
-			INITRND = 4096;
+			INITRND = 0x100000;
 		break;
 	case 3:	/* raw */
 		HEADR = 0;
@@ -1224,16 +1224,24 @@ void
 doprof2(void)
 {
 	Sym *s2, *s4;
-	Prog *p, *q, *ps2, *ps4;
+	Prog *p, *q, *q2, *ps2, *ps4;
 
 	if(debug['v'])
 		Bprint(&bso, "%5.2f profile 2\n", cputime());
 	Bflush(&bso);
 
-	s2 = lookup("_profin", 0);
-	s4 = lookup("_profout", 0);
+	if(debug['e']){
+		s2 = lookup("_tracein", 0);
+		s4 = lookup("_traceout", 0);
+	}else{
+		s2 = lookup("_profin", 0);
+		s4 = lookup("_profout", 0);
+	}
 	if(s2->type != STEXT || s4->type != STEXT) {
-		diag("_profin/_profout not defined");
+		if(debug['e'])
+			diag("_tracein/_traceout not defined %d %d", s2->type, s4->type);
+		else
+			diag("_profin/_profout not defined");
 		return;
 	}
 
@@ -1274,7 +1282,20 @@ doprof2(void)
 			q->line = p->line;
 			q->pc = p->pc;
 			q->link = p->link;
-			p->link = q;
+			if(debug['e']){		/* embedded tracing */
+				q2 = prg();
+				p->link = q2;
+				q2->link = q;
+
+				q2->line = p->line;
+				q2->pc = p->pc;
+
+				q2->as = ABR;
+				q2->to.type = D_BRANCH;
+				q2->to.sym = p->to.sym;
+				q2->cond = q->link;
+			}else
+				p->link = q;
 			p = q;
 			p->as = ABL;
 			p->to.type = D_BRANCH;
@@ -1284,7 +1305,17 @@ doprof2(void)
 			continue;
 		}
 		if(p->as == ARETURN) {
-
+			/*
+			 * RETURN (default)
+			 */
+			if(debug['e']){		/* embedded tracing */
+				q = prg();
+				q->line = p->line;
+				q->pc = p->pc;
+				q->link = p->link;
+				p->link = q;
+				p = q;
+			}
 			/*
 			 * RETURN
 			 */

+ 12 - 4
sys/src/cmd/split.c

@@ -70,13 +70,18 @@ main(int argc, char *argv[])
 		Binit(b, 0, OREAD);
 
 	if(pattern) {
-		if(!(exp = regcomp(iflag? fold(pattern,strlen(pattern)): pattern)))
+		Resub match[2];
+
+		if(!(exp = regcomp(iflag? fold(pattern, strlen(pattern)):
+		    pattern)))
 			badexp();
+		memset(match, 0, sizeof match);
+		matchfile(match);
 		while((line=Brdline(b,'\n')) != 0) {
-			Resub match[2];
 			memset(match, 0, sizeof match);
 			line[Blinelen(b)-1] = 0;
-			if(regexec(exp,iflag?fold(line,Blinelen(b)-1):line,match,2)) {
+			if(regexec(exp, iflag? fold(line, Blinelen(b)-1): line,
+			    match, 2)) {
 				if(matchfile(match) && xflag)
 					continue;
 			} else if(output == 0)
@@ -110,7 +115,8 @@ main(int argc, char *argv[])
 int
 nextfile(void)
 {
-	static canopen = 1;
+	static int canopen = 1;
+
 	if(suff[0] > 'z') {
 		if(canopen)
 			fprint(2, "split: file %szz not split\n",stem);
@@ -129,6 +135,7 @@ matchfile(Resub *match)
 {
 	if(match[1].sp) {
 		int len = match[1].ep - match[1].sp;
+
 		strncpy(name, match[1].sp, len);
 		strcpy(name+len, suffix);
 		openf();
@@ -141,6 +148,7 @@ void
 openf(void)
 {
 	static int fd = 0;
+
 	Bflush(output);
 	Bterm(output);
 	if(fd > 0)

+ 12 - 11
sys/src/cmd/usb/lib/fs.c

@@ -292,8 +292,7 @@ static Rpc*
 fswalk(Rpc *r)
 {
 	int i;
-	Fid *nfid;
-	Fid *ofid;
+	Fid *nfid, *ofid;
 
 	if(r->fid->omode != ONONE)
 		return fserror(r, Eisopen);
@@ -331,11 +330,10 @@ fswalk(Rpc *r)
 static void
 fsioproc(void* a)
 {
+	long rc;
 	Channel *p = a;
 	Rpc *rpc;
-	long rc;
-	Fcall *t;
-	Fcall *r;
+	Fcall *t, *r;
 	Fid *fid;
 
 	dprint(2, "%s: fsioproc pid %d\n", argv0, getpid());
@@ -355,16 +353,21 @@ fsioproc(void* a)
 			}
 			break;
 		case Tread:
-			rc = fsops->read(fsops,fid,r->data,t->count,t->offset);
+			rc = fsops->read(fsops, fid, r->data, t->count, t->offset);
 			if(rc >= 0){
 				if(rc > t->count)
 					print("%s: bug: read %ld bytes > %ud wanted\n",
 						argv0, rc, t->count);
 				r->count = rc;
 			}
+			/*
+			 * TODO: if we encounter a long run of continuous read
+			 * errors, we should do something more drastic so that
+			 * our caller doesn't just spin its wheels forever.
+			 */
 			break;
 		case Twrite:
-			rc = fsops->write(fsops,fid,t->data,t->count,t->offset);
+			rc = fsops->write(fsops, fid, t->data, t->count, t->offset);
 			r->count = rc;
 			break;
 		default:
@@ -398,11 +401,9 @@ fsopen(Rpc *r)
 int
 usbdirread(Usbfs*f, Qid q, char *data, long cnt, vlong off, Dirgen gen, void *arg)
 {
-	Dir d;
+	int i, n, nd;
 	char name[Namesz];
-	int i;
-	int n;
-	int nd;
+	Dir d;
 
 	memset(&d, 0, sizeof(d));
 	d.name = name;

+ 16 - 11
sys/src/cmd/usb/probe

@@ -1,21 +1,26 @@
 #!/bin/rc
+# usb/probe [-h] - list all usb devices, including hubs
 rfork e
 test -e /dev/usb || bind -a '#u' /dev || {
 	echo no '#u/usb' >[1=2]
 	exit nousb
 }
 
-awk 'BEGIN{ep="";}
-	$1 ~ /ep[0-9]+\.0/ && $2 == "enabled" && $NF ~ /busy|idle/ {
-		ep=$1;
-		next;
-	}
-	{
-		if(ep != ""){
-			printf("%s %s\n", ep, $0);
-			ep="";
-		}
+filter = cat
+if (~ $1 -h)
+	filter = (grep -v ' (root)?hub ')
+
+awk 'BEGIN	{ ep = "" }
+$1 ~ /ep[0-9]+\.0/ && $2 == "enabled" && $NF ~ /busy|idle/ {
+	ep=$1
+	next
+}
+{
+	if(ep != ""){
+		printf "%s %s\n", ep, $0
+		ep = ""
 	}
-' /dev/usb/ctl
+}
+' /dev/usb/ctl | $filter
 
 exit ''

+ 16 - 1
sys/src/cmd/usb/serial/serial.c

@@ -413,6 +413,7 @@ dread(Usbfs *fs, Fid *fid, void *data, long count, vlong offset)
 	char *e, *buf, *err;	/* change */
 	Qid q;
 	Serial *ser;
+	static int errrun;
 
 	q = fid->qid;
 	path = fid->qid.path & ~fs->qid;
@@ -442,8 +443,22 @@ dread(Usbfs *fs, Fid *fid, void *data, long count, vlong offset)
 				rcount = read(dfd, data, count);
 				qlock(ser);
 			}
-			if(rcount < 0)
+			/*
+			 * if we encounter a long run of continuous read
+			 * errors, do something drastic so that our caller
+			 * doesn't just spin its wheels forever.
+			 */
+			if(rcount < 0) {
 				snprint(err, Serbufsize, "%r");
+				if (++errrun > 1000) {
+					/* the line has been dropped; give up */
+					qunlock(ser);
+					fprint(2, "%s: line is gone: %r\n",
+						argv0);
+					threadexitsall("serial line gone");
+				}
+			} else
+				errrun = 0;
 			if(usbdebug >= 3)
 				dsprint(2, "serial: read: %s %ld\n", err, rcount);
 		} while(rcount < 0 && strstr(err, "timed out") != nil);

+ 38 - 5
sys/src/cmd/vl/obj.c

@@ -1171,15 +1171,24 @@ void
 doprof2(void)
 {
 	Sym *s2, *s4;
-	Prog *p, *q, *ps2, *ps4;
+	Prog *p, *q, *q2, *ps2, *ps4;
 
 	if(debug['v'])
 		Bprint(&bso, "%5.2f profile 2\n", cputime());
 	Bflush(&bso);
-	s2 = lookup("_profin", 0);
-	s4 = lookup("_profout", 0);
+
+	if(debug['e']){
+		s2 = lookup("_tracein", 0);
+		s4 = lookup("_traceout", 0);
+	}else{
+		s2 = lookup("_profin", 0);
+		s4 = lookup("_profout", 0);
+	}
 	if(s2->type != STEXT || s4->type != STEXT) {
-		diag("_profin/_profout not defined");
+		if(debug['e'])
+			diag("_tracein/_traceout not defined %d %d", s2->type, s4->type);
+		else
+			diag("_profin/_profout not defined");
 		return;
 	}
 
@@ -1218,7 +1227,20 @@ doprof2(void)
 			q->line = p->line;
 			q->pc = p->pc;
 			q->link = p->link;
-			p->link = q;
+			if(debug['e']){		/* embedded tracing */
+				q2 = prg();
+				p->link = q2;
+				q2->link = q;
+
+				q2->line = p->line;
+				q2->pc = p->pc;
+
+				q2->as = AJMP;
+				q2->to.type = D_BRANCH;
+				q2->to.sym = p->to.sym;
+				q2->cond = q->link;
+			}else
+				p->link = q;
 			p = q;
 			p->as = AJAL;
 			p->to.type = D_BRANCH;
@@ -1228,6 +1250,17 @@ doprof2(void)
 			continue;
 		}
 		if(p->as == ARET) {
+			/*
+			 * RET (default)
+			 */
+			if(debug['e']){		/* embedded tracing */
+				q = prg();
+				q->line = p->line;
+				q->pc = p->pc;
+				q->link = p->link;
+				p->link = q;
+				p = q;
+			}
 			/*
 			 * RET
 			 */

+ 4 - 2
sys/src/libsec/port/tlshand.c

@@ -1150,7 +1150,8 @@ msgRecv(TlsConnection *c, Msg *m)
 		nn = get16(p);
 		p += 2;
 		n -= 2;
-		if(nn == 0 || n != nn)
+		/* nn == 0 can happen; yahoo's servers do it */
+		if(nn != n)
 			goto Short;
 		/* cas */
 		i = 0;
@@ -1163,7 +1164,8 @@ msgRecv(TlsConnection *c, Msg *m)
 			if(nn < 1 || nn > n)
 				goto Short;
 			m->u.certificateRequest.nca = i+1;
-			m->u.certificateRequest.cas = erealloc(m->u.certificateRequest.cas, (i+1)*sizeof(Bytes));
+			m->u.certificateRequest.cas = erealloc(
+				m->u.certificateRequest.cas, (i+1)*sizeof(Bytes));
 			m->u.certificateRequest.cas[i] = makebytes(p, nn);
 			p += nn;
 			n -= nn;