add -W to specify window size.

various other little fixes.
diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c
index feef6b6..3dafb38 100644
--- a/src/cmd/9term/9term.c
+++ b/src/cmd/9term/9term.c
@@ -186,7 +186,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: 9term [-ars] [cmd ...]\n");
+	fprint(2, "usage: 9term [-ars] [-W winsize] [cmd ...]\n");
 	threadexitsall("usage");
 }
 
@@ -215,6 +215,9 @@
 	case 'w':	/* started from "rio" window manager */
 		use9wm = 1;
 		break;
+	case 'W':
+		winsize = EARGF(usage());
+		break;
 	}ARGEND
 
 	if(font)
diff --git a/src/cmd/acidtypes/type.c b/src/cmd/acidtypes/type.c
index c9e8431..5449077 100644
--- a/src/cmd/acidtypes/type.c
+++ b/src/cmd/acidtypes/type.c
@@ -463,7 +463,7 @@
 					name, nameof(tt, 0));
 				Bprint(b, "\tindent_%s(addr+%lud, indent+\"  \");\n",
 					nameof(tt, 1), t->val[j]);
-				Bprint(b, "\tprint(indent, \"\t}\\n\");\n");
+				Bprint(b, "\tprint(indent, \"}\\n\");\n");
 				break;
 			}
 		}
diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c
index 7c56338..8d0413f 100644
--- a/src/cmd/acme/acme.c
+++ b/src/cmd/acme/acme.c
@@ -96,9 +96,14 @@
 		if(loadfile == nil)
 			goto Usage;
 		break;
+	case 'W':
+		winsize = ARGF();
+		if(winsize == nil)
+			goto Usage;
+		break;
 	default:
 	Usage:
-		fprint(2, "usage: acme -a -c ncol -f fontname -F fixedwidthfontname -l loadfile\n");
+		fprint(2, "usage: acme -a -c ncol -f fontname -F fixedwidthfontname -l loadfile -W winsize\n");
 		exits("usage");
 	}ARGEND
 
diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c
index d4c2a29..afd8840 100644
--- a/src/cmd/auxstats/Linux.c
+++ b/src/cmd/auxstats/Linux.c
@@ -109,21 +109,20 @@
 	totinb = 0;
 	totoub = 0;
 	for(i=0; i<nline; i++){
+		if((q = strchr(line[i], ':')) != nil)
+			*q = ' ';
 		tokens(i);
 		if(ntok < 8+8)
 			continue;
 		if(strncmp(tok[0], "eth", 3) != 0)
 			continue;
-		q = strchr(tok[0], ':');
-		*q++ = 0;
-		tok[0] = q;
-		inb = atoll(tok[0]);
-		oub = atoll(tok[8]);
-		in = atoll(tok[1]);
-		ou = atoll(tok[9]);
+		inb = atoll(tok[1]);
+		oub = atoll(tok[9]);
+		in = atoll(tok[2]);
+		ou = atoll(tok[10]);
 		b = inb+oub;
 		p = in+ou;
-		e = atoll(tok[2])+atoll(tok[10]);
+		e = atoll(tok[3])+atoll(tok[11]);
 		totb += b;
 		totp += p;
 		tote += e;
diff --git a/src/cmd/draw/gview.c b/src/cmd/draw/gview.c
index 8249155..5e80ee2 100644
--- a/src/cmd/draw/gview.c
+++ b/src/cmd/draw/gview.c
@@ -1956,7 +1956,7 @@
 	int i;
 	fprintf(stderr,"Usage %s [options] [infile]\n", argv0);
 	fprintf(stderr,
-"option ::= -l logfile | -m\n"
+"option ::= -W winsize | -l logfile | -m\n"
 "\n"
 "Read a polygonal line graph in an ASCII format (one x y pair per line, delimited\n"
 "by spaces with a label after each polyline), and view it interactively.  Use\n"
@@ -1981,6 +1981,9 @@
 		break;
 	case 'l': logfil = fopen(ARGF(),"w");
 		break;
+	case 'W':
+		winsize = EARGF(usage());
+		break;
 	default: usage();
 	} ARGEND
 
diff --git a/src/cmd/draw/img.c b/src/cmd/draw/img.c
index 354e588..01caa3c 100644
--- a/src/cmd/draw/img.c
+++ b/src/cmd/draw/img.c
@@ -6,7 +6,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: img [file]\n");
+	fprint(2, "usage: img [-W winsize] [file]\n");
 	exits("usage");
 }
 
@@ -29,6 +29,9 @@
 	Event e;
 
 	ARGBEGIN{
+	case 'W':
+		winsize = EARGF(usage());
+		break;
 	default:
 		usage();
 	}ARGEND
@@ -48,6 +51,8 @@
 	if((image=readimage(display, fd, 0)) == nil)
 		sysfatal("readimage: %r");
 
+	drawresizewindow(Rect(0,0,Dx(image->r),Dy(image->r)));
+
 	einit(Emouse|Ekeyboard);
 	eresized(0);
 	for(;;){
diff --git a/src/cmd/draw/stats.c b/src/cmd/draw/stats.c
index f49f541..8a43fb0 100644
--- a/src/cmd/draw/stats.c
+++ b/src/cmd/draw/stats.c
@@ -332,7 +332,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: stats [-O] [-S scale] [-LY] [-%s] [machine...]\n", argchars);
+	fprint(2, "usage: stats [-O] [-S scale] [-LY] [-W winsize] [-%s] [machine...]\n", argchars);
 	exits("usage");
 }
 
@@ -710,6 +710,9 @@
 	case 'O':
 		oldsystem = 1;
 		break;
+	case 'W':
+		winsize = EARGF(usage());
+		break;
 	default:
 		if(nargs>=sizeof args || strchr(argchars, ARGC())==nil)
 			usage();
diff --git a/src/cmd/draw/tweak.c b/src/cmd/draw/tweak.c
index c7e1287..82a22ee 100644
--- a/src/cmd/draw/tweak.c
+++ b/src/cmd/draw/tweak.c
@@ -172,12 +172,26 @@
 void	tclose1(Thing*);
 
 void
+usage(void)
+{
+	fprint(2, "usage: tweak [-W winsize] file...\n");
+	exits("usage");
+}
+
+void
 main(int argc, char *argv[])
 {
 	int i;
 	Event e;
 	Thing *t;
 
+	ARGBEGIN{
+	case 'W':
+		winsize = EARGF(usage());
+		break;
+	default:
+		usage();
+	}ARGEND
 	mag = Mag;
 	if(initdraw(error, 0, "tweak") < 0){
 		fprint(2, "tweak: initdraw failed: %r\n");
@@ -191,7 +205,7 @@
 	}
 	einit(Emouse|Ekeyboard);
 	eresized(0);
-	i = 1;
+	i = 0;
 	setjmp(err);
 	for(; i<argc; i++){
 		file = argv[i];
diff --git a/src/cmd/jpg/bmp.c b/src/cmd/jpg/bmp.c
index f7e07a0..ba1b813 100644
--- a/src/cmd/jpg/bmp.c
+++ b/src/cmd/jpg/bmp.c
@@ -44,12 +44,22 @@
 }
 
 void
+usage(void)
+{
+	fprint(2, "usage: bmp -39cdektv -W winsize [file.bmp ...]\n");
+	exits("usage");
+}
+
+void
 main(int argc, char *argv[])
 {
 	int fd, i;
 	char *err;
 
 	ARGBEGIN{
+	case 'W':
+		winsize = EARGF(usage());
+		break;
 	case '3':		/* produce encoded, compressed, three-color bitmap file; no display by default */
 		threeflag++;
 		/* fall through */
@@ -89,8 +99,7 @@
 			outchan = CMAP8;
 		break;
 	default:
-		fprint(2, "usage: bmp -39cdektv  [file.bmp ...]\n");
-		exits("usage");
+		usage();
 	}ARGEND;
 
 	err = nil;
diff --git a/src/cmd/jpg/gif.c b/src/cmd/jpg/gif.c
index f992701..f8f89de 100644
--- a/src/cmd/jpg/gif.c
+++ b/src/cmd/jpg/gif.c
@@ -57,12 +57,23 @@
 }
 
 void
+usage(void)
+{
+	fprint(2, "usage: gif -39cdektv -W winsize [file.gif ...]\n");
+	exits("usage");
+}
+
+
+void
 main(int argc, char *argv[])
 {
 	int fd, i;
 	char *err;
 
 	ARGBEGIN{
+	case 'W':
+		winsize = EARGF(usage());
+		break;
 	case '3':		/* produce encoded, compressed, three-color bitmap file; no display by default */
 		threeflag++;
 		/* fall through */
@@ -102,8 +113,7 @@
 			outchan = CMAP8;
 		break;
 	default:
-		fprint(2, "usage: gif -39cdektv  [file.gif ...]\n");
-		exits("usage");
+		usage();
 	}ARGEND;
 
 	err = nil;
diff --git a/src/cmd/jpg/ico.c b/src/cmd/jpg/ico.c
index 3a275e6..1380b18 100644
--- a/src/cmd/jpg/ico.c
+++ b/src/cmd/jpg/ico.c
@@ -258,7 +258,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: %s [file]\n", argv0);
+	fprint(2, "usage: %s -W winsize [file]\n", argv0);
 	exits("usage");
 }
 
@@ -444,6 +444,9 @@
 	Event e;
 
 	ARGBEGIN{
+	case 'W':
+		winsize = EARGF(usage());
+		break;
 	case 'd':
 		debug = 1;
 		break;
diff --git a/src/cmd/jpg/jpg.c b/src/cmd/jpg/jpg.c
index cf438a9..f61172a 100644
--- a/src/cmd/jpg/jpg.c
+++ b/src/cmd/jpg/jpg.c
@@ -46,6 +46,13 @@
 }
 
 void
+usage(void)
+{
+	fprint(2, "usage: jpg -39cdefFkJrtv -W winsize [file.jpg ...]\n");
+	exits("usage");
+}
+
+void
 main(int argc, char *argv[])
 {
 	int fd, i, yflag;
@@ -54,6 +61,9 @@
 
 	yflag = 0;
 	ARGBEGIN{
+	case 'W':
+		winsize = EARGF(usage());
+		break;
 	case 'c':		/* produce encoded, compressed, bitmap file; no display by default */
 		cflag++;
 		dflag++;
@@ -110,8 +120,7 @@
 			outchan = CMAP8;
 		break;
 	default:
-		fprint(2, "usage: jpg -39cdefFkJrtv [file.jpg ...]\n");
-		exits("usage");
+		usage();
 	}ARGEND;
 
 	if(yflag==0 && dflag==0 && colorspace==CYCbCr){	/* see if we should convert right to RGB */
diff --git a/src/cmd/jpg/png.c b/src/cmd/jpg/png.c
index d653fe6..a815abf 100644
--- a/src/cmd/jpg/png.c
+++ b/src/cmd/jpg/png.c
@@ -44,6 +44,13 @@
 }
 
 void
+usage(void)
+{
+	fprint(2, "usage: png -39cdekrtv -W winsize [file.png ...]\n");
+	exits("usage");
+}
+
+void
 main(int argc, char *argv[])
 {
 	int fd, i;
@@ -51,6 +58,9 @@
 	char buf[12+1];
 
 	ARGBEGIN{
+	case 'W':
+		winsize = EARGF(usage());
+		break;
 	case 'c':		/* produce encoded, compressed, bitmap file; no display by default */
 		cflag++;
 		dflag++;
@@ -96,8 +106,7 @@
 			outchan = CMAP8;
 		break;
 	default:
-		fprint(2, "usage: png -39cdekrtv [file.png ...]\n");
-		exits("usage");
+		usage();
 	}ARGEND;
 
 	if(dflag==0 && colorspace==CYCbCr){	/* see if we should convert right to RGB */
diff --git a/src/cmd/jpg/ppm.c b/src/cmd/jpg/ppm.c
index 24019df..d90344e 100644
--- a/src/cmd/jpg/ppm.c
+++ b/src/cmd/jpg/ppm.c
@@ -42,12 +42,22 @@
 }
 
 void
+usage(void)
+{
+	fprint(2, "usage: ppm -39cdektv -W winsize [file.ppm ...]\n");
+	exits("usage");
+}
+
+void
 main(int argc, char *argv[])
 {
 	int fd, i;
 	char *err;
 
 	ARGBEGIN{
+	case 'W':
+		winsize = EARGF(usage());
+		break;
 	case '3':		/* produce encoded, compressed, three-color bitmap file; no display by default */
 		threeflag++;
 		/* fall through */
@@ -87,8 +97,7 @@
 			outchan = CMAP8;
 		break;
 	default:
-		fprint(2, "usage: ppm -39cdektv  [file.ppm ...]\n");
-		exits("usage");
+		usage();
 	}ARGEND;
 
 	err = nil;
diff --git a/src/cmd/jpg/yuv.c b/src/cmd/jpg/yuv.c
index 929ccf3..6027236 100644
--- a/src/cmd/jpg/yuv.c
+++ b/src/cmd/jpg/yuv.c
@@ -44,12 +44,22 @@
 }
 
 void
+usage(void)
+{
+	fprint(2, "usage: yuv -39cdektv -W winsize [file.yuv ...]\n");
+	exits("usage");
+}
+
+void
 main(int argc, char *argv[])
 {
 	int fd, i;
 	char *err;
 
 	ARGBEGIN{
+	case 'W':
+		winsize = EARGF(usage());
+		break;
 	case '3':		/* produce encoded, compressed, three-color bitmap file; no display by default */
 		threeflag++;
 		/* fall through */
@@ -89,8 +99,7 @@
 			outchan = CMAP8;
 		break;
 	default:
-		fprint(2, "usage: yuv -39cdektv  [file.yuv ...]\n");
-		exits("usage");
+		usage();
 	}ARGEND;
 
 	err = nil;
diff --git a/src/cmd/mc.c b/src/cmd/mc.c
deleted file mode 100644
index 45e7adf..0000000
--- a/src/cmd/mc.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * mc - columnate
- *
- * mc[-][-LINEWIDTH][-t][file...]
- *	- causes break on colon
- *	-LINEWIDTH sets width of line in which to columnate(default 80)
- *	-t suppresses expanding multiple blanks into tabs
- *
- */
-#include	<u.h>
-#include	<sys/ioctl.h>
-#include	<sys/termios.h>
-#include	<libc.h>
-#include	<draw.h>
-#include	<bio.h>
-
-#define	WIDTH			80
-#define	TAB	4
-#define	WORD_ALLOC_QUANTA	1024
-#define	ALLOC_QUANTA		4096
-
-int linewidth=WIDTH;
-int colonflag=0;
-int tabflag=0;	/* -t flag turned off forever */
-Rune *cbuf, *cbufp;
-Rune **word;
-int maxwidth=0;
-int nalloc=ALLOC_QUANTA;
-int nwalloc=WORD_ALLOC_QUANTA;
-int nchars=0;
-int nwords=0;
-Biobuf	bin;
-Biobuf	bout;
-
-void getwidth(void), readbuf(int), error(char *);
-void scanwords(void), columnate(void), morechars(void);
-
-void
-main(int argc, char *argv[])
-{
-	int i;
-	int lineset;
-	int ifd;
-
-	lineset = 0;
-	Binit(&bout, 1, OWRITE);
-	while(argc > 1 && argv[1][0] == '-'){
-		--argc; argv++;
-		switch(argv[0][1]){
-		case '\0':
-			colonflag = 1;
-			break;
-		case 't':
-			tabflag = 0;
-			break;
-		default:
-			linewidth = atoi(&argv[0][1]);
-			if(linewidth <= 1)
-				linewidth = WIDTH;
-			lineset = 1;
-			break;
-		}
-	}
-	if(lineset == 0)
-		getwidth();
-	cbuf = cbufp = malloc(ALLOC_QUANTA*(sizeof *cbuf));
-	word = malloc(WORD_ALLOC_QUANTA*(sizeof *word));
-	if(word == 0 || cbuf == 0)
-		error("out of memory");
-	if(argc == 1)
-		readbuf(0);
-	else{
-		for(i = 1; i < argc; i++){
-			if((ifd = open(*++argv, OREAD)) == -1)
-				fprint(2, "mc: can't open %s (%r)\n", *argv);
-			else{
-				readbuf(ifd);
-				Bflush(&bin);
-				close(ifd);
-			}
-		}
-	}
-	columnate();
-	exits(0);
-}
-void
-error(char *s)
-{
-	fprint(2, "mc: %s\n", s);
-	exits(s);
-}
-void
-readbuf(int fd)
-{
-	int lastwascolon = 0;
-	long c;
-	int linesiz = 0;
-
-	Binit(&bin, fd, OREAD);
-	do{
-		if(nchars++ >= nalloc)
-			morechars();
-		*cbufp++ = c = Bgetrune(&bin);
-		linesiz++;
-		if(c == '\t') {
-			cbufp[-1] = L' ';
-			while(linesiz%TAB != 0) {
-				if(nchars++ >= nalloc)
-					morechars();
-				*cbufp++ = L' ';
-				linesiz++;
-			}
-		}
-		if(colonflag && c == ':')
-			lastwascolon++;
-		else if(lastwascolon){
-			if(c == '\n'){
-				--nchars; 	/* skip newline */
-				*cbufp = L'\0';
-				while(nchars > 0 && cbuf[--nchars] != '\n')
-					;
-				if(nchars)
-					nchars++;
-				columnate();
-				if (nchars)
-					Bputc(&bout, '\n');
-				Bprint(&bout, "%S", cbuf+nchars);
-				nchars = 0;
-				cbufp = cbuf;
-			}
-			lastwascolon = 0;
-		}
-		if(c == '\n')
-			linesiz = 0;
-	}while(c >= 0);
-}
-void
-scanwords(void)
-{
-	Rune *p, *q;
-	int i;
-
-	nwords=0;
-	maxwidth=0;
-	for(p = q = cbuf, i = 0; i < nchars; i++){
-		if(*p++ == L'\n'){
-			if(nwords >= nwalloc){
-				nwalloc += WORD_ALLOC_QUANTA;
-				if((word = realloc(word, nwalloc*sizeof(*word)))==0)
-					error("out of memory");
-			}
-			word[nwords++] = q;
-			p[-1] = L'\0';
-			if(p-q > maxwidth)
-				maxwidth = p-q;
-			q = p;
-		}
-	}
-}
-
-void
-columnate(void)
-{
-	int i, j;
-	int words_per_line;
-	int nlines;
-	int col;
-	int endcol;
-
-
-	scanwords();
-	if(nwords==0)
-		return;
-	words_per_line = linewidth/maxwidth;
-	if(words_per_line <= 0)
-		words_per_line = 1;
-	nlines=(nwords+words_per_line-1)/words_per_line;
-	for(i = 0; i < nlines; i++){
-		col = endcol = 0;
-		for(j = i; j < nwords; j += nlines){
-			endcol += maxwidth;
-			Bprint(&bout, "%S", word[j]);
-			col += word[j+1]-word[j]-1;
-			if(j+nlines < nwords){
-				if(tabflag) {
-					int tabcol = (col|(TAB-1))+1;
-					while(tabcol <= endcol){
-						Bputc(&bout, '\t');
-						col = tabcol;
-						tabcol += TAB;
-					}
-				}
-				while(col < endcol){
-					Bputc(&bout, ' ');
-					col++;
-				}
-			}
-		}
-		Bputc(&bout, '\n');
-	}
-}
-
-void
-morechars(void)
-{
-	nalloc += ALLOC_QUANTA;
-	if((cbuf = realloc(cbuf, nalloc*sizeof(*cbuf))) == 0)
-		error("out of memory");
-	cbufp = cbuf+nchars-1;
-}
-
-/*
- * These routines discover the width of the display.
- * It takes some work.  If we do the easy calls to the
- * draw library, the screen flashes due to repainting
- * when mc exits.
- */
-
-int
-windowrect(struct winsize *ws)
-{
-	int tty;
-
-	if((tty = open("/dev/tty", OWRITE)) < 0)
-		tty = 1;
-
-	if(ioctl(tty, TIOCGWINSZ, ws) < 0){
-		if(tty != 1)
-			close(tty);
-		return -1;
-	}
-	if(tty != 1)
-		close(tty);
-	return 0;
-}
-
-void
-getwidth(void)
-{
-	struct winsize ws;
-
-	if(windowrect(&ws) < 0)
-		return;
-	linewidth = ws.ws_col;
-}
diff --git a/src/cmd/plot/plot.c b/src/cmd/plot/plot.c
index 04e5cf5..1360f68 100644
--- a/src/cmd/plot/plot.c
+++ b/src/cmd/plot/plot.c
@@ -149,6 +149,7 @@
 	fd = dup(0, -1);		/* because openpl will close 0! */
 	dflag=0;
 	oflag="";
+	winsize = "512x512";
 	for(i=1;i!=arc;i++) if(arv[i][0]=='-') switch(arv[i][1]){
 	case 'd': dflag=1; break;
 	case 'o': oflag=arv[i]+2; break;
@@ -168,7 +169,6 @@
 			case 'D': break;
 			case 'd': break;
 			case 'o': break;
-			case 'W': break;
 			case 's': break;
 			case 'e': erase(); break;
 			case 'C': closepl(); break;
@@ -177,6 +177,7 @@
 			case 'f': cfill(ap+1); break;
 			case 'p': pen(ap+1); break;
 			case 'g': grade(atof(ap+1)); break;
+			case 'W': winsize = ap+1; break;
 			}
 		}
 		else if ((bp = Bopen(arv[1], OREAD)) == 0) {
diff --git a/src/cmd/sam/sam.c b/src/cmd/sam/sam.c
index 078d943..5a009bb 100644
--- a/src/cmd/sam/sam.c
+++ b/src/cmd/sam/sam.c
@@ -29,6 +29,8 @@
 Disk	*disk;
 long	seq;
 
+char *winsize;
+
 Rune	baddir[] = { '<', 'b', 'a', 'd', 'd', 'i', 'r', '>', '\n'};
 
 void	usage(void);
@@ -82,6 +84,10 @@
                         argc--;
                         break;
 
+		case 'W':
+			--argc, argv++;
+			break;
+
 		default:
 			dprint("sam: unknown flag %c\n", argv[0][1]);
 			exits("usage");
@@ -101,7 +107,7 @@
 	if(home == 0)
 		home = "/";
 	if(!dflag)
-		startup(machine, Rflag, arg, ap);
+		startup(machine, Rflag, arg, argv);
 	notify(notifyf);
 	getcurwd();
 	if(argc>1){
diff --git a/src/cmd/samterm/plan9.c b/src/cmd/samterm/plan9.c
index feb8957..4d58c60 100644
--- a/src/cmd/samterm/plan9.c
+++ b/src/cmd/samterm/plan9.c
@@ -28,10 +28,15 @@
 void
 getscreen(int argc, char **argv)
 {
+	int i;
 	char *t;
 
-	USED(argc);
-	USED(argv);
+	/* not exactly right */
+	for(i=0; i<argc-1; i++){
+		if(strcmp(argv[i], "-W") == 0)
+			winsize = argv[i+1];
+	}
+
 	if(initdraw(panic1, nil, "sam") < 0){
 		fprint(2, "samterm: initdraw: %r\n");
 		threadexitsall("init");
diff --git a/src/cmd/vac/vtdump.c b/src/cmd/vac/vtdump.c
index daabedc..ee6a0c6 100644
--- a/src/cmd/vac/vtdump.c
+++ b/src/cmd/vac/vtdump.c
@@ -87,10 +87,12 @@
 		Bprint(bout, "prev: %V\n", root.prev);
 	}
 
+fprint(2, "read...\n");
 	n = vtread(z, root.score, VtDirType, buf, bsize);
 	if(n < 0)
 		sysfatal("could not read root dir");
 
+fprint(2, "...\n");
 	/* fake up top level source */
 	memset(&source, 0, sizeof(source));
 	memmove(source.score, root.score, VtScoreSize);
diff --git a/src/lib9/create.c b/src/lib9/create.c
index 97f6e7e..eaea479 100644
--- a/src/lib9/create.c
+++ b/src/lib9/create.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE	/* for Linux O_DIRECT */
 #include <u.h>
 #define NOPLAN9DEFINES
 #include <libc.h>
@@ -25,6 +26,10 @@
 	}else{
 		umode = (mode&3)|O_CREAT|O_TRUNC;
 		mode &= ~(3|OTRUNC);
+		if(mode&ODIRECT){
+			umode |= O_DIRECT;
+			mode &= ~ODIRECT;
+		}
 		if(mode&OEXCL){
 			umode |= O_EXCL;
 			mode &= ~OEXCL;
diff --git a/src/lib9/mkfile b/src/lib9/mkfile
index 6a3b1fc..273a79b 100644
--- a/src/lib9/mkfile
+++ b/src/lib9/mkfile
@@ -167,3 +167,4 @@
 %.$O: utf/%.c
 	$CC $CFLAGS utf/$stem.c
 
+rendez-Linux.$O: rendez-futex.c rendez-signal.c
diff --git a/src/lib9/open.c b/src/lib9/open.c
index 0356a7d..b70a9a2 100644
--- a/src/lib9/open.c
+++ b/src/lib9/open.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE	/* for Linux O_DIRECT */
 #include <u.h>
 #define NOPLAN9DEFINES
 #include <libc.h>
@@ -16,6 +17,10 @@
 		umode |= O_TRUNC;
 		mode ^= OTRUNC;
 	}
+	if(mode&ODIRECT){
+		umode |= O_DIRECT;
+		mode ^= ODIRECT;
+	}
 	if(mode){
 		werrstr("mode not supported");
 		return -1;
diff --git a/src/lib9/qlock.c b/src/lib9/qlock.c
index 55a1846..00bbcc7 100644
--- a/src/lib9/qlock.c
+++ b/src/lib9/qlock.c
@@ -34,8 +34,10 @@
 	for(p = op+1; ; p++){
 		if(p == &ql.x[nelem(ql.x)])
 			p = ql.x;
-		if(p == op)
+		if(p == op){
+			fprint(2, "qlock: out of qlp\n");
 			abort();
+		}
 		if(_tas(&(p->inuse)) == 0){
 			ql.p = p;
 			p->next = nil;
@@ -233,8 +235,10 @@
 	QLp *p;
 
 	lock(&q->lock);
-	if(q->writer == 0)
+	if(q->writer == 0){
+		fprint(2, "wunlock: not holding lock\n");
 		abort();
+	}
 	p = q->head;
 	if(p == nil){
 		q->writer = 0;
@@ -252,8 +256,10 @@
 		return;
 	}
 
-	if(p->state != QueuingR)
+	if(p->state != QueuingR){
+		fprint(2, "wunlock: bad state\n");
 		abort();
+	}
 
 	/* wake waiting readers */
 	while(q->head != nil && q->head->state == QueuingR){
@@ -274,12 +280,16 @@
 {
 	QLp *t, *me;
 
-	if(!r->l)
+	if(!r->l){
+		fprint(2, "rsleep: no lock\n");
 		abort();
+	}
 	lock(&r->l->lock);
 	/* we should hold the qlock */
-	if(!r->l->locked)
+	if(!r->l->locked){
+		fprint(2, "rsleep: not locked\n");
 		abort();
+	}
 
 	/* add ourselves to the wait list */
 	me = getqlp();
@@ -309,8 +319,10 @@
 	while((*_rendezvousp)((ulong)me, 0x23456) == ~0)
 		;
 	me->inuse = 0;
-	if(!r->l->locked)
+	if(!r->l->locked){
+		fprint(2, "rsleep: not locked after wakeup\n");
 		abort();
+	}
 }
 
 int
@@ -323,11 +335,15 @@
 	 * put on front so guys that have been waiting will not get starved
 	 */
 	
-	if(!r->l)
+	if(!r->l){
+		fprint(2, "rwakeup: no lock\n");
 		abort();
+	}
 	lock(&r->l->lock);
-	if(!r->l->locked)
+	if(!r->l->locked){
+		fprint(2, "rwakeup: not locked\n");
 		abort();
+	}
 
 	t = r->head;
 	if(t == nil){
diff --git a/src/libdraw/x11-init.c b/src/libdraw/x11-init.c
index 671de1d..3388407 100644
--- a/src/libdraw/x11-init.c
+++ b/src/libdraw/x11-init.c
@@ -11,6 +11,9 @@
 #include <cursor.h>
 #include "x11-memdraw.h"
 
+char *winsize;
+static int parsewinsize(char*, Rectangle*, int*);
+
 static Memimage	*xattach(char*);
 static void	plan9cmap(void);
 static int	setupcmap(XWindow);
@@ -180,7 +183,7 @@
 xattach(char *label)
 {
 	char *argv[2], *disp;
-	int i, n, xrootid;
+	int i, n, xrootid, havemin;
 	Rectangle r;
 	XClassHint classhint;
 	XDrawable pmid;
@@ -318,8 +321,14 @@
 	 * This is arbitrary.  In theory we should read the
 	 * command line and allow the traditional X options.
 	 */
-	r = Rect(0, 0, WidthOfScreen(xscreen)*3/4,
+	if(winsize){
+		if(parsewinsize(winsize, &r, &havemin) < 0)
+			sysfatal("%r");
+	}else{
+		r = Rect(0, 0, WidthOfScreen(xscreen)*3/4,
 			HeightOfScreen(xscreen)*3/4);
+		havemin = 0;
+	}
 
 	memset(&attr, 0, sizeof attr);
 	attr.colormap = _x.cmap;
@@ -353,7 +362,14 @@
 	name.nitems = strlen((char*)name.value);
 
 	memset(&normalhint, 0, sizeof normalhint);
-	normalhint.flags = USSize|PMaxSize;
+	normalhint.flags = PSize|PMaxSize;
+	if(winsize){
+		normalhint.flags &= ~PSize;
+		normalhint.flags |= USSize;
+		normalhint.width = Dx(r);
+		normalhint.height = Dy(r);
+	}
+
 	normalhint.max_width = WidthOfScreen(xscreen);
 	normalhint.max_height = HeightOfScreen(xscreen);
 
@@ -382,6 +398,15 @@
 	);
 	XFlush(_x.display);
 
+	if(havemin){
+		XWindowChanges ch;
+
+		memset(&ch, 0, sizeof ch);
+		ch.x = r.min.x;
+		ch.y = r.min.y;
+		XConfigureWindow(_x.display, _x.drawable, CWX|CWY, &ch);
+fprint(2, "havemin %d %d\n", r.min.x, r.min.y);
+	}
 	/*
 	 * Look up clipboard atom.
 	 */
@@ -783,3 +808,73 @@
 	return 1;
 }
 
+static int
+parsewinsize(char *s, Rectangle *r, int *havemin)
+{
+	char c, *os;
+	int i, j, k, l;
+
+	os = s;
+	*havemin = 0;
+	*r = Rect(0,0,0,0);
+	if(!isdigit(*s))
+		goto oops;
+	i = strtol(s, &s, 0);
+	if(*s == 'x'){
+		s++;
+		if(!isdigit(*s))
+			goto oops;
+		j = strtol(s, &s, 0);
+		r->max.x = i;
+		r->max.y = j;
+		if(*s == 0)
+			return 0;
+		if(*s != '@')
+			goto oops;
+
+		s++;
+		if(!isdigit(*s))
+			goto oops;
+		i = strtol(s, &s, 0);
+		if(*s != ',' && *s != ' ')
+			goto oops;
+		s++;
+		if(!isdigit(*s))
+			goto oops;
+		j = strtol(s, &s, 0);
+		if(*s != 0)
+			goto oops;
+		*r = rectaddpt(*r, Pt(i,j));
+		*havemin = 1;
+		return 0;
+	}
+
+	c = *s;
+	if(c != ' ' && c != ',')
+		goto oops;
+	s++;
+	if(!isdigit(*s))
+		goto oops;
+	j = strtol(s, &s, 0);
+	if(*s != c)
+		goto oops;
+	s++;
+	if(!isdigit(*s))
+		goto oops;
+	k = strtol(s, &s, 0);
+	if(*s != c)
+		goto oops;
+	s++;
+	if(!isdigit(*s))
+		goto oops;
+	l = strtol(s, &s, 0);
+	if(*s != 0)
+		goto oops;
+	*r = Rect(i,j,k,l);
+	*havemin = 1;
+	return 0;
+
+oops:
+	werrstr("bad syntax in window size '%s'", os);
+	return -1;
+}
diff --git a/src/libdraw/x11-wsys.c b/src/libdraw/x11-wsys.c
index c996bd3..83f3e1b 100644
--- a/src/libdraw/x11-wsys.c
+++ b/src/libdraw/x11-wsys.c
@@ -15,3 +15,18 @@
 	XFlush(_x.display);
 }
 
+void
+drawresizewindow(Rectangle r)
+{
+//	XConfigureRequestEvent e;
+	XWindowChanges e;
+	int value_mask;
+
+	memset(&e, 0, sizeof e);
+	value_mask = CWWidth|CWHeight;
+//	e.x = r.min.x;
+//	e.y = r.min.y;
+	e.width = Dx(r);
+	e.height = Dy(r);
+	XConfigureWindow(_x.display, _x.drawable, value_mask, &e);
+}
diff --git a/src/libmach/dwarfget.c b/src/libmach/dwarfget.c
index da8558c..3e9fe65 100644
--- a/src/libmach/dwarfget.c
+++ b/src/libmach/dwarfget.c
@@ -156,6 +156,7 @@
 {n1++;
 		return c;
 }
+	c &= ~0x80;
 	d = *b->p++;
 	c |= (d&0x7F)<<7;
 	if(!(d&0x80))
diff --git a/src/libthread/create.c b/src/libthread/create.c
index a8647f9..b63fee4 100644
--- a/src/libthread/create.c
+++ b/src/libthread/create.c
@@ -155,6 +155,7 @@
 	else
 		*_threadpq.tail = p;
 	_threadpq.tail = &p->next;
+
 	if(_threadprocs == 1)
 		_threadmultiproc();
 	_threadprocs++;
diff --git a/src/libthread/id.c b/src/libthread/id.c
index 727798d..e920b87 100644
--- a/src/libthread/id.c
+++ b/src/libthread/id.c
@@ -52,20 +52,20 @@
 }
 
 void
-threadsetname(char *name)
+threadsetname(char *fmt, ...)
 {
-/*
-	int fd, n;
-	char buf[128], *s;
-*/
 	Proc *p;
 	Thread *t;
+	va_list arg;
 
 	p = _threadgetproc();
 	t = p->thread;
 	if (t->cmdname)
 		free(t->cmdname);
-	t->cmdname = strdup(name);
+	va_start(arg, fmt);
+	t->cmdname = vsmprint(fmt, arg);
+	va_end(fmt);
+
 /* Plan 9 only 
 	if(p->nthreads == 1){
 		snprint(buf, sizeof buf, "#p/%d/args", getpid());
diff --git a/src/libthread/tprimes.c b/src/libthread/tprimes.c
index e028f98..89d30c0 100644
--- a/src/libthread/tprimes.c
+++ b/src/libthread/tprimes.c
@@ -52,7 +52,7 @@
 		buffer = atoi(ARGF());
 		break;
 	case 'p':
-		fn=proccreate;
+		fn = proccreate;
 		break;
 	}ARGEND
 
diff --git a/src/libventi/server.c b/src/libventi/server.c
index 7ecaf7c..837cbf4 100644
--- a/src/libventi/server.c
+++ b/src/libventi/server.c
@@ -13,6 +13,8 @@
 struct VtSconn
 {
 	int ctl;
+	int ref;
+	QLock lk;
 	char dir[NETPATHLEN];
 	VtSrv *srv;
 	VtConn *c;
@@ -29,6 +31,27 @@
 static void listenproc(void*);
 static void connproc(void*);
 
+static void
+scincref(VtSconn *sc)
+{
+	qlock(&sc->lk);
+	sc->ref++;
+	qunlock(&sc->lk);
+}
+
+static void
+scdecref(VtSconn *sc)
+{
+	qlock(&sc->lk);
+	if(--sc->ref > 0){
+		qunlock(&sc->lk);
+		return;
+	}
+	if(sc->c)
+		vtfreeconn(sc->c);
+	vtfree(sc);
+}
+
 VtSrv*
 vtlisten(char *addr)
 {
@@ -55,14 +78,13 @@
 
 	srv = v;
 	for(;;){
-fprint(2, "listen for venti\n");
 		ctl = listen(srv->adir, dir);
 		if(ctl < 0){
 			srv->dead = 1;
 			break;
 		}
-fprint(2, "got one\n");
 		sc = vtmallocz(sizeof(VtSconn));
+		sc->ref = 1;
 		sc->ctl = ctl;
 		sc->srv = srv;
 		strcpy(sc->dir, dir);
@@ -82,8 +104,8 @@
 	int fd;
 
 	r = nil;
-	c = nil;
 	sc = v;
+	sc->c = nil;
 	fprint(2, "new call %s on %d\n", sc->dir, sc->ctl);
 	fd = accept(sc->ctl, sc->dir);
 	close(sc->ctl);
@@ -122,7 +144,9 @@
 			break;
 		r->rx.tag = r->tx.tag;
 		r->sc = sc;
+		scincref(sc);
 		if(_vtqsend(sc->srv->q, r) < 0){
+			scdecref(sc);
 			fprint(2, "hungup queue\n");
 			break;
 		}
@@ -136,10 +160,8 @@
 		vtfcallclear(&r->tx);
 		vtfree(r);
 	}
-	if(c)
-		vtfreeconn(c);
 	fprint(2, "freed %s\n", sc->dir);
-	vtfree(sc);
+	scdecref(sc);
 	return;
 }
 
@@ -167,6 +189,7 @@
 		return;
 	}
 	vtsend(sc->c, p);
+	scdecref(sc);
 	vtfcallclear(&r->tx);
 	vtfcallclear(&r->rx);
 	vtfree(r);